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

refactor: set up monorepo #554

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
72ebc46
feat: sets up monorepo
douglance Dec 9, 2024
7523c4a
move some config
douglance Dec 10, 2024
80db7a8
fix config items
douglance Dec 10, 2024
a96be4c
remove extra changes
douglance Dec 10, 2024
072e54c
remove more
douglance Dec 10, 2024
8cfe6fc
update linting/formatting
douglance Dec 10, 2024
349365c
restore typechain nohoise
douglance Dec 10, 2024
f02b23d
update linter settings and deps locale
douglance Dec 10, 2024
006dd92
revert deps change
douglance Dec 10, 2024
b362bb9
revert hoist
douglance Dec 10, 2024
4b9749c
Merge branch 'main' into dl/monorepo
douglance Dec 11, 2024
9d48d62
test change to lock file
douglance Dec 11, 2024
4723065
debug
douglance Dec 11, 2024
f92e150
update dotenv
douglance Dec 11, 2024
1174942
fix lint
douglance Dec 11, 2024
9edac93
fix imports
douglance Dec 11, 2024
9030353
revert debug tests
douglance Dec 12, 2024
c58abd3
simplify how env is loaded
douglance Dec 12, 2024
85ec17d
change prettier file type
douglance Dec 12, 2024
1db4f38
bump yarnlock for ci
douglance Dec 12, 2024
5dc312e
revert cachekey to test
douglance Dec 12, 2024
6205d10
test no hoise fix env
douglance Dec 12, 2024
121cd2d
swap cache key
douglance Dec 13, 2024
88b994a
fix pr comments
douglance Dec 13, 2024
c80b628
revert resolution change
douglance Dec 13, 2024
4d06422
test cache key
douglance Dec 13, 2024
36bda6a
test different thing
douglance Dec 13, 2024
5c4e9c6
test
douglance Dec 13, 2024
b2581fc
update cachekey
douglance Dec 13, 2024
e602f8f
fix extra space
douglance Dec 13, 2024
aa230c2
Merge branch 'main' into dl/monorepo
douglance Dec 13, 2024
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
root: true,
env: {
commonjs: true,
es6: true,
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

env:
MAINNET_RPC: ${{ secrets.MAINNET_RPC }}
CACHE_KEY: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-monorepo

jobs:
install:
Expand All @@ -25,6 +26,8 @@ jobs:

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
with:
cache-key: ${{ env.CACHE_KEY }}

lint:
name: Lint on Node.js v${{ matrix.node-version }}
Expand All @@ -48,6 +51,8 @@ jobs:

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
with:
cache-key: ${{ env.CACHE_KEY }}

- name: Lint sdk
run: |
Expand Down Expand Up @@ -93,6 +98,8 @@ jobs:

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
with:
cache-key: ${{ env.CACHE_KEY }}

- run: yarn audit:ci

Expand All @@ -114,6 +121,8 @@ jobs:

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
with:
cache-key: ${{ env.CACHE_KEY }}

- name: Build
run: |
Expand Down Expand Up @@ -176,6 +185,8 @@ jobs:

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
with:
cache-key: ${{ env.CACHE_KEY }}

- name: Set up the local node
uses: OffchainLabs/actions/run-nitro-test-node@main
Expand Down
64 changes: 12 additions & 52 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,56 +1,19 @@
{
"name": "@arbitrum/sdk",
"version": "4.0.2",
"description": "Typescript library client-side interactions with Arbitrum",
"author": "Offchain Labs, Inc.",
"license": "Apache-2.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/offchainlabs/arbitrum-sdk.git"
},
"engines": {
"node": ">=v11",
"npm": "please-use-yarn",
"yarn": ">= 1.0.0"
},
"bugs": {
"url": "https://github.com/offchainlabs/arbitrum-sdk/issues"
},
"homepage": "https://offchainlabs.com",
"private": true,
"scripts": {
"audit:ci": "audit-ci --config ./audit-ci.jsonc",
"prepare": "yarn run gen:abi",
"gen:abi": "node ./scripts/genAbi.js",
"gen:network": "ts-node ./scripts/genNetwork.ts",
"prepublishOnly": "yarn build && yarn format",
"preversion": "yarn lint",
"prebuild": "yarn gen:abi",
"build": "./scripts/builder",
"watch": "tsc --watch",
"test": "mocha",
"test:coverage": "nyc mocha",
"test:fork": "SHOULD_FORK=1 hardhat test tests/fork/*.test.ts",
"test:integration": "mocha tests/integration/ --timeout 30000000 --bail",
"test:unit": "mocha --parallel tests/unit/ --timeout 30000 --bail",
"test:ci": "nyc --reporter=lcovonly mocha --reporter xunit",
"lint": "eslint .",
"format": "prettier './**/*.{js,json,md,ts,yml}' '!./src/lib/abi' --write && yarn run lint --fix",
"clean:compile": "ts-node scripts/cleanCompileContracts.ts",
"checkRetryable": "ts-node scripts/checkRetryableStatus.ts",
"redeemRetryable": "ts-node scripts/redeemRetryable.ts",
"setStandard": "ts-node scripts/setStandardGateways.ts",
"setCustom": "ts-node scripts/setArbCustomGateways.ts",
"cancelRetryable": "ts-node scripts/cancelRetryable.ts",
"bridgeStandardToken": "ts-node scripts/deployStandard.ts"
"build": "yarn workspace @arbitrum/sdk build",
"lint": "yarn workspace @arbitrum/sdk lint",
"format": "yarn workspace @arbitrum/sdk format",
"test:unit": "yarn workspace @arbitrum/sdk test:unit",
"test:integration": "yarn workspace @arbitrum/sdk test:integration",
"gen:abi": "yarn workspace @arbitrum/sdk gen:abi",
"gen:network": "yarn workspace @arbitrum/sdk gen:network"
},
"dependencies": {
"@ethersproject/address": "^5.0.8",
"@ethersproject/bignumber": "^5.1.1",
"@ethersproject/bytes": "^5.0.8",
"async-mutex": "^0.4.0",
"ethers": "^5.1.0"
"workspaces": {
"packages": [
"packages/*"
]
},
"devDependencies": {
"@arbitrum/nitro-contracts": "^1.1.1",
Expand Down Expand Up @@ -87,9 +50,6 @@
"typescript": "^4.9.5",
"yargs": "^17.3.1"
},
"files": [
"dist/**/*"
],
"resolutions": {
Copy link
Member

Choose a reason for hiding this comment

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

should we move resolutions for runtime dependencies to the package's package.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking it would be nice to have them shared among packages, but I guess it's probably better to just deal with issues individually if they come up. so i moved the resolutions down to the sdk package 88b994a

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh actually, those are all there for audit-ci fixing purposes, so we want them there c80b628

"lodash.pick": "https://github.com/lodash/lodash/archive/refs/tags/4.17.21.tar.gz",
"**/@ethersproject/providers/ws": "7.5.10",
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions packages/sdk/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"root": false,
"extends": ["../../.eslintrc.js"],
"parserOptions": {
"files": ["src/**/*.ts", "src/**/*.js"]
},
"ignorePatterns": ["dist/**/*", "node_modules/**/*"]
}
File renamed without changes.
5 changes: 5 additions & 0 deletions packages/sdk/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const baseConfig = require('../../.prettierrc.js')

module.exports = {
...baseConfig,
}
58 changes: 58 additions & 0 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "@arbitrum/sdk",
"version": "4.0.2",
"description": "Typescript library client-side interactions with Arbitrum",
"author": "Offchain Labs, Inc.",
"license": "Apache-2.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/offchainlabs/arbitrum-sdk.git"
},
"engines": {
"node": ">=v11",
"npm": "please-use-yarn",
"yarn": ">= 1.0.0"
},
"bugs": {
"url": "https://github.com/offchainlabs/arbitrum-sdk/issues"
},
"homepage": "https://offchainlabs.com",
"files": [
"dist/**/*"
],
"scripts": {
"audit:ci": "audit-ci --config ./audit-ci.jsonc",
"prepare": "yarn run gen:abi",
"gen:abi": "node ./scripts/genAbi.js",
"gen:network": "ts-node ./scripts/genNetwork.ts",
"prepublishOnly": "yarn build && yarn format",
"preversion": "yarn lint",
"prebuild": "yarn gen:abi",
"build": "./scripts/builder",
"watch": "tsc --watch",
"test": "mocha",
"test:coverage": "nyc mocha",
"test:fork": "SHOULD_FORK=1 hardhat test tests/fork/*.test.ts",
"test:integration": "mocha tests/integration/ --timeout 30000000 --bail",
"test:unit": "mocha --parallel tests/unit/ --timeout 30000 --bail",
"test:ci": "nyc --reporter=lcovonly mocha --reporter xunit",
"lint": "eslint .",
"format": "prettier './**/*.{js,json,md,ts,yml}' '!./src/lib/abi' --write && yarn run lint --fix",
"clean:compile": "ts-node scripts/cleanCompileContracts.ts",
"checkRetryable": "ts-node scripts/checkRetryableStatus.ts",
"redeemRetryable": "ts-node scripts/redeemRetryable.ts",
"setStandard": "ts-node scripts/setStandardGateways.ts",
"setCustom": "ts-node scripts/setArbCustomGateways.ts",
"cancelRetryable": "ts-node scripts/cancelRetryable.ts",
"bridgeStandardToken": "ts-node scripts/deployStandard.ts"
},
"dependencies": {
"@ethersproject/address": "^5.0.8",
"@ethersproject/bignumber": "^5.1.1",
"@ethersproject/bytes": "^5.0.8",
"async-mutex": "^0.4.0",
"ethers": "^5.1.0"
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { instantiateBridge } from './instantiate_bridge'
import dotenv from 'dotenv'
import { loadEnv } from '../src/lib/utils/env'
import args from './getCLargs'
import { constants, BigNumber, utils } from 'ethers'
import { MultiCaller } from '../src'
import axios from 'axios'
import prompt from 'prompts'
dotenv.config()

loadEnv()

const privKey = process.env.PRIVKEY as string
if (!privKey) {
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions scripts/genNetwork.ts → packages/sdk/scripts/genNetwork.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as dotenv from 'dotenv'
dotenv.config()
import { loadEnv } from '../src/lib/utils/env'
import { execSync } from 'child_process'
import * as fs from 'fs'

Expand All @@ -11,6 +10,8 @@ import {
mapL2NetworkToArbitrumNetwork,
} from '../src/lib/dataEntities/networks'

loadEnv()

const isTestingOrbitChains = process.env.ORBIT_TEST === '1'

function getLocalNetworksFromContainer(which: 'l1l2' | 'l2l3'): any {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import { JsonRpcProvider } from '@ethersproject/providers'
import { Wallet } from '@ethersproject/wallet'
import { loadEnv } from '../src/lib/utils/env'

import dotenv from 'dotenv'
import args from './getCLargs'
import { EthBridger, InboxTools, Erc20Bridger } from '../src'
import {
Expand All @@ -29,7 +29,7 @@ import {
import { Signer } from 'ethers'
import { AdminErc20Bridger } from '../src/lib/assetBridger/erc20Bridger'

dotenv.config()
loadEnv()

const arbKey = process.env['ARB_KEY'] as string
const ethKey = process.env['ETH_KEY'] as string
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions scripts/testSetup.ts → packages/sdk/scripts/testSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { JsonRpcProvider } from '@ethersproject/providers'
import { Wallet } from '@ethersproject/wallet'
import { Provider } from '@ethersproject/abstract-provider'
import dotenv from 'dotenv'
import { loadEnv } from '../src/lib/utils/env'

import { EthBridger, InboxTools, Erc20Bridger } from '../src'
import {
Expand All @@ -41,7 +41,7 @@ import {
} from '../tests/integration/custom-fee-token/customFeeTokenTestHelpers'
import { fundParentSigner } from '../tests/integration/testHelpers'

dotenv.config()
loadEnv()

const isTestingOrbitChains = process.env.ORBIT_TEST === '1'

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions packages/sdk/src/lib/utils/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as dotenv from 'dotenv'
import * as path from 'path'

export const loadEnv = () => {
dotenv.config({ path: path.resolve(__dirname, '../../../../../.env') })
Copy link
Member

Choose a reason for hiding this comment

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

will this work properly both in the case when you're running commands at the root level of the monorepo, and when you cd into the package and run it there?

Copy link
Contributor Author

@douglance douglance Dec 13, 2024

Choose a reason for hiding this comment

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

it does work from both locations. __dirname is the location of this file.

}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import { expect } from 'chai'
import { ethers, constants, Wallet } from 'ethers'
import dotenv from 'dotenv'
import { loadEnv } from '../../../src/lib/utils/env'

import { parseEther, parseUnits } from '@ethersproject/units'

Expand All @@ -34,7 +34,7 @@ import { ChildToParentMessageStatus } from '../../../src'
import { ChildToParentMessage } from '../../../src/lib/message/ChildToParentMessage'
import { getNativeTokenDecimals } from '../../../src/lib/utils/lib'

dotenv.config()
loadEnv()

describeOnlyWhenCustomGasToken(
'EthBridger (with custom fee token)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
'use strict'

import { expect } from 'chai'
import dotenv from 'dotenv'

import { loadEnv } from '../../src/lib/utils/env'
import { Wallet } from '@ethersproject/wallet'
import { parseEther } from '@ethersproject/units'
import { constants } from 'ethers'
Expand All @@ -44,7 +43,7 @@ import {
} from '../../src/lib/utils/lib'
import { parseUnits } from 'ethers/lib/utils'

dotenv.config()
loadEnv()

describe('Ether', async () => {
beforeEach('skipIfMainnet', async function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import dotenv from 'dotenv'
import { JsonRpcProvider } from '@ethersproject/providers'
import { constants } from 'ethers'
import { expect } from 'chai'
import { loadEnv } from '../../src/lib/utils/env'

import {
getArbitrumNetwork,
getArbitrumNetworkInformationFromRollup,
} from '../../src/lib/dataEntities/networks'

dotenv.config()
loadEnv()

describe('getArbitrumNetworkInformationFromRollup', () => {
it('fetches information about arbitrum one', async () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions packages/sdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
},
"include": ["src/**/*.ts", "src/**/*.d.ts"],
"exclude": ["node_modules", "dist", "tests", "scripts"]
}
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"target": "ES2017",
"module": "commonjs",
"declaration": true,
"rootDir": "./src",
"outDir": "./dist",
"strict": true,
"allowJs": true,
"noImplicitAny": true,
Expand All @@ -14,7 +12,9 @@
"noImplicitThis": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"experimentalDecorators": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.js"]
"experimentalDecorators": true,
"paths": {
"@ethersproject/*": ["./node_modules/@ethersproject/*"]
}
}
}