Skip to content

Commit

Permalink
🧹 Update @LayerZero-Labs dependencies (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Jun 12, 2024
1 parent 66277fa commit 05a4cf8
Show file tree
Hide file tree
Showing 16 changed files with 351 additions and 562 deletions.
9 changes: 9 additions & 0 deletions .changeset/lucky-comics-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@stargatefinance/stg-definitions-v2": patch
"@stargatefinance/stg-evm-oftwrapper": patch
"@stargatefinance/stg-error-parser": patch
"@stargatefinance/stg-evm-sdk-v2": patch
"@stargatefinance/stg-evm-v2": patch
---

Update @LayerZero-Labs dependencies
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
]
},
"resolutions": {
"@layerzerolabs/lz-definitions": "2.3.20",
"es5-ext": "https://github.com/LayerZero-Labs/es5-ext"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/stg-definitions-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"devDependencies": {
"@ethersproject/units": "~5.7.0",
"@layerzerolabs/lz-definitions": "~2.3.20",
"@layerzerolabs/lz-definitions": "~2.3.22",
"@layerzerolabs/tsup-config-next": "~2.3.10",
"@layerzerolabs/typescript-config-next": "~2.3.10",
"@safe-global/protocol-kit": "^1.3.0",
Expand Down
6 changes: 2 additions & 4 deletions packages/stg-error-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
"dist/**/*"
],
"scripts": {
"build": "$npm_execpath clean-prebuild && $npm_execpath populate && $npm_execpath tsup",
"build": "$npm_execpath tsup --clean",
"clean": "rm -rf dist .turbo",
"clean-prebuild": "rm -rf dist 'src/errors/*.json'",
"populate": "ts-node scripts/populate.ts && $npm_execpath prettier --write 'src/errors/*.json'",
"test": "jest"
},
"dependencies": {
Expand All @@ -25,7 +23,7 @@
"devDependencies": {
"@layerzerolabs/tsup-config-next": "~2.3.10",
"@layerzerolabs/typescript-config-next": "~2.3.10",
"@stargatefinance/stg-evm-sdk-v2": "*",
"@stargatefinance/stg-evm-sdk-v2": "~1.0.0",
"@types/jest": "^29.5.10",
"@types/node": "^18.15.11",
"jest": "^29.7.0",
Expand Down
13 changes: 0 additions & 13 deletions packages/stg-error-parser/scripts/populate.ts

This file was deleted.

100 changes: 0 additions & 100 deletions packages/stg-error-parser/src/errors/errorSelectors.json

This file was deleted.

100 changes: 0 additions & 100 deletions packages/stg-error-parser/src/errors/errors.json

This file was deleted.

4 changes: 2 additions & 2 deletions packages/stg-error-parser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LayerZeroErrorParser, LayerZeroParsedError } from '@layerzerolabs/evm-sdks-core'
import { errors } from '@stargatefinance/stg-evm-sdk-v2'

import errors from './errors/errors.json'
import { LayerZeroErrorParser, LayerZeroParsedError } from '@layerzerolabs/evm-sdks-core'

/**
* This function is a wrapper for LayerZeroErrorParser.check.
Expand Down
18 changes: 9 additions & 9 deletions packages/stg-evm-oftwrapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
"devDependencies": {
"@babel/core": "^7.24.3",
"@layerzerolabs/eslint-config-next": "~2.3.10",
"@layerzerolabs/lz-definitions": "~2.3.20",
"@layerzerolabs/lz-evm-messagelib-v2": "~2.3.20",
"@layerzerolabs/lz-evm-oapp-v2": "~2.3.20",
"@layerzerolabs/lz-evm-protocol-v2": "~2.3.20",
"@layerzerolabs/lz-evm-v1-0.7": "~2.3.20",
"@layerzerolabs/lz-v2-utilities": "~2.3.20",
"@layerzerolabs/lz-definitions": "~2.3.22",
"@layerzerolabs/lz-evm-messagelib-v2": "~2.3.22",
"@layerzerolabs/lz-evm-oapp-v2": "~2.3.22",
"@layerzerolabs/lz-evm-protocol-v2": "~2.3.22",
"@layerzerolabs/lz-evm-v1-0.7": "~2.3.22",
"@layerzerolabs/lz-v2-utilities": "~2.3.22",
"@layerzerolabs/prettier-config-next": "~2.3.10",
"@layerzerolabs/solhint-config": "~2.3.10",
"@layerzerolabs/test-devtools-evm-foundry": "^0.2.3",
"@layerzerolabs/toolbox-foundry": "~0.1.5",
"@layerzerolabs/toolbox-hardhat": "~0.2.27",
"@layerzerolabs/test-devtools-evm-foundry": "^0.2.4",
"@layerzerolabs/toolbox-foundry": "~0.1.6",
"@layerzerolabs/toolbox-hardhat": "~0.2.29",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
"@nomicfoundation/hardhat-ethers": "^3.0.5",
"@nomiclabs/hardhat-ethers": "^2.2.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/stg-evm-sdk-v2/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
artifacts
deployments
dist
src/errors
src/errors.json
6 changes: 2 additions & 4 deletions packages/stg-evm-sdk-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@
"dist/**/*"
],
"scripts": {
"build": "tsup --clean > /dev/null 2>&1 || true && rm -rf src/errors && $npm_execpath populate && tsup --clean",
"clean": "rm -rf .turbo dist artifacts deployments src/errors",
"populate": "$npm_execpath ts-node scripts/populate.ts"
"build": "$npm_execpath tsup --clean",
"clean": "rm -rf .turbo dist artifacts deployments"
},
"devDependencies": {
"@layerzerolabs/evm-sdks-build": "~2.3.20",
"@layerzerolabs/tsup-config-next": "~2.3.10",
"@layerzerolabs/typescript-config-next": "~2.3.10",
"@stargatefinance/stg-evm-v2": "~1.0.0",
Expand Down
7 changes: 0 additions & 7 deletions packages/stg-evm-sdk-v2/scripts/populate.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/stg-evm-sdk-v2/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as errors } from './errors/errors.json'
export { default as errorSelectors } from './errors/errorSelectors.json'
// The errors.json file is generated during the build phase
export { default as errors } from './errors.json'
27 changes: 27 additions & 0 deletions packages/stg-evm-sdk-v2/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { writeFileSync } from 'fs'
import { createRequire } from 'module'
import { dirname, join } from 'path'

import { contracts } from '@stargatefinance/stg-evm-v2/deployed'
import { clean } from 'esbuild-plugin-clean'
import { copy } from 'esbuild-plugin-copy'

Expand All @@ -16,6 +18,31 @@ export default defineConfig({
clean({
cleanOnStartPatterns: ['./artifacts', './deployments'],
}),
{
name: 'Generate error ABI fragments',
setup({ onStart }) {
onStart(() => {
// We'll create a list of all the errors found in all the stargate contracts
const errorEntries = Object.values(contracts)
// First we get one ABI per network for every contract
.flatMap(({ abis: abisByNetworkName }) => Object.values(abisByNetworkName))
// Then we flatten all the ABIs into one massive ABI
.flat()
// Then we take the error fragments out
.filter((fragment: any) => fragment.type === 'error')
// Then we'll need to deduplicate the errors so we create a hash key by stringifying the error
//
// Simple yet effective
.map((fragment) => [JSON.stringify(fragment), fragment] as const)

// Now that we have the errors in array of [hash, fragment] tuples, we can just deduplicate them
// by turning them into an object and getting all of its values
const errors = Object.values(Object.fromEntries(errorEntries))

writeFileSync(join('src', 'errors.json'), JSON.stringify(errors, null, '\t'))
})
},
},
copy({
copyOnStart: true,
resolveFrom: 'cwd',
Expand Down
Loading

0 comments on commit 05a4cf8

Please sign in to comment.