Skip to content

Commit

Permalink
refactor: set up monorepo (#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglance authored Dec 17, 2024
1 parent 5669af1 commit c47d1f5
Show file tree
Hide file tree
Showing 94 changed files with 130 additions and 72 deletions.
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
10 changes: 10 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
with:
cache-key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-monorepo

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

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
with:
cache-key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-monorepo

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

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
with:
cache-key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-monorepo

- run: yarn audit:ci

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

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
with:
cache-key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-monorepo

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

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
with:
cache-key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-monorepo

- 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": {
"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.
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.
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.
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.
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.
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') })
}
File renamed without changes.
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
File renamed without changes.
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.
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.
File renamed without changes.
File renamed without changes.
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/*"]
}
}
}

0 comments on commit c47d1f5

Please sign in to comment.