Skip to content

Commit

Permalink
fix: Unified tsconfig.json in all subpackages to eliminate build di…
Browse files Browse the repository at this point in the history
…screpancies (#487)

## Description
This PR fixes the issue that each package uses a unique `tsconfig.json`
which may lead to different transpilation results.


## Related Issue Or Context
- Discovered by @LyonSsS that `BaseTransfer` constructor was causing
issue

Log:

```
2024-08-20 17:24:45        API/INIT: tangle-testnet/1100: Not decorating unknown runtime apis: 0x7ee4fdd3f4b9d4d0/1, JobsApi/1, 0xa33d43f58731ad84/2
/home/liviu/Sygma/SDK_V3/sygma-sdk/packages/substrate/src/fungible.ts:37
    super(transfer, config);
         ^


TypeError: Class constructor BaseTransfer cannot be invoked without 'new'
    at SubstrateFungibleAssetTransfer (/home/liviu/Sygma/SDK_V3/sygma-sdk/package
```

---------

Co-authored-by: Anton Lykhoyda <[email protected]>
  • Loading branch information
saadahmsiddiqui and Lykhoyda authored Aug 21, 2024
1 parent 9e9937c commit 7be55ff
Show file tree
Hide file tree
Showing 20 changed files with 46 additions and 182 deletions.
7 changes: 4 additions & 3 deletions examples/substrate-to-evm-fungible-transfer/src/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const substrateTransfer = async (): Promise<void> => {
source: RHALA_CHAIN_ID,
destination: SEPOLIA_CHAIN_ID,
sourceNetworkProvider: api,
sourceAddress: account.address,
resource: RESOURCE_ID_SYGMA_USD,
amount: BigInt("1"),
destinationAddress: recipient,
Expand All @@ -55,17 +56,17 @@ const substrateTransfer = async (): Promise<void> => {

if (status.isInBlock) {
console.log(
`Transaction included at blockHash ${status.asInBlock.toString()}`,
`Transaction included at blockHash ${status.asInBlock.toString()}`
);
} else if (status.isFinalized) {
const blockNumber = results.blockNumber.toNumber();
const extrinsicIndex = results.txIndex;

console.log(
`Transaction finalized at blockHash ${status.asFinalized.toString()}`,
`Transaction finalized at blockHash ${status.asFinalized.toString()}`
);
console.log(
`Explorer URL: ${getSygmaExplorerTransferUrl({ blockNumber, extrinsicIndex })}`,
`Explorer URL: ${getSygmaExplorerTransferUrl({ blockNumber, extrinsicIndex })}`
);
unsub();
process.exit(0);
Expand Down
4 changes: 1 addition & 3 deletions packages/core/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"exclude": ["src/**/__test__/**", "test/**"],
"extends": "./tsconfig.json",
"exclude": ["node_modules/**", "src/**/__test__/**", "test/**"],
"compilerOptions": {
"declaration": true,
"esModuleInterop": true,
"module": "commonjs",
"outDir": "./dist-cjs"
}
Expand Down
5 changes: 2 additions & 3 deletions packages/core/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"exclude": ["src/**/__test__/**", "test/**"],
"extends": "./tsconfig.json",
"exclude": ["node_modules/**", "src/**/__test__/**", "test/**"],
"compilerOptions": {
"module": "ES2020",
"esModuleInterop": true,
"module": "ES2022",
"outDir": "./dist-esm"
}
}
32 changes: 2 additions & 30 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,5 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "ES2022",
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"moduleResolution": "node",
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"preserveSymlinks": true,
"preserveWatchOutput": true,
"pretty": false,
"strict": true,
"sourceMap": true,
"target": "es2020",
"skipLibCheck": true,
"baseUrl": "./src",
"resolveJsonModule": true
},
"extends": "../../tsconfig.base.json",
"exclude": ["node_modules/**"],
"include": ["./src/**/*.ts", "./test/**/*.ts", "substrate-asset-transfer.ts", "./src/environment.d.ts"],
"ts-node": {
"esm": true,
"experimentalSpecifierResolution": "node"
}
"include": ["./src/**/*.ts"]
}
11 changes: 3 additions & 8 deletions packages/core/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"moduleResolution": "node",
"emitDeclarationOnly": true,
"outDir": "types",
"esModuleInterop": true,
"resolveJsonModule": true,
"module": "ES2022",
"target": "ESNext"
"outDir": "types"
},
"exclude": ["test"]
"exclude": ["test", "src/**/__test__/**"]
}
7 changes: 1 addition & 6 deletions packages/evm/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
"exclude": [
"src/**/__test__/**",
"test/**",
],
"extends": "./tsconfig.json",
"exclude": ["node_modules/**", "src/**/__test__/**", "test/**"],
"compilerOptions": {
"declaration": true,
"esModuleInterop": true,
"module": "commonjs",
"outDir": "./dist-cjs"
}
Expand Down
8 changes: 2 additions & 6 deletions packages/evm/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"exclude": [
"src/**/__test__/**",
"test/**"
],
"extends": "./tsconfig.json",
"exclude": ["node_modules/**", "src/**/__test__/**", "test/**"],
"compilerOptions": {
"module": "ES2020",
"esModuleInterop": true,
"module": "ES2022",
"outDir": "./dist-esm"
}
}
31 changes: 2 additions & 29 deletions packages/evm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "ES2022",
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"moduleResolution": "node",
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"preserveSymlinks": true,
"preserveWatchOutput": true,
"pretty": false,
"strict": true,
"sourceMap": true,
"target": "es2020",
"skipLibCheck": true,
"baseUrl": "./src"
},
"extends": "../../tsconfig.base.json",
"exclude": ["node_modules/**"],
"include": ["./src/**/*.ts", "./test/**/*.ts", "substrate-asset-transfer.ts"],
"ts-node": {
"esm": true,
"experimentalSpecifierResolution": "node"
}
"include": ["./src/**/*.ts"]
}
3 changes: 1 addition & 2 deletions packages/evm/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "types"
},
"extends": "./tsconfig.json",
"exclude": ["test", "src/**/__test__/**"]
}
1 change: 1 addition & 0 deletions packages/substrate/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './fungible.js';
export * from './utils/index.js';
6 changes: 3 additions & 3 deletions packages/substrate/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extends": "./tsconfig.base.json",
"extends": "./tsconfig.json",
"exclude": ["node_modules/**", "src/**/__test__/**", "test/**"],
"compilerOptions": {
"module": "commonjs",
"outDir": "./dist-cjs"
},
"exclude": ["test/**", "src/**/*.test.ts"]
}
}
12 changes: 4 additions & 8 deletions packages/substrate/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"extends": "./tsconfig.base.json",
"extends": "./tsconfig.json",
"exclude": ["node_modules/**", "src/**/__test__/**", "test/**"],
"compilerOptions": {
"module": "ES2020",
"module": "ES2022",
"outDir": "./dist-esm"
},
"ts-node": {
"esm": true,
"experimentalSpecifierResolution": "node"
},
"exclude": ["test/**", "src/**/*.test.ts"]
}
}
14 changes: 3 additions & 11 deletions packages/substrate/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "ES2022",
"target": "es2020"
},
"include": ["./src/**/*.ts", "./test/**/*.ts", "substrate-asset-transfer.ts"],
"exclude": ["test/setupJest.js"],
"ts-node": {
"esm": true,
"experimentalSpecifierResolution": "node"
}
"extends": "../../tsconfig.base.json",
"exclude": ["node_modules/**"],
"include": ["./src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/substrate/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.base.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"outDir": "types"
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/substrate/balances.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { SubstrateResource } from '@buildwithsygma/core';
import { getAssetBalance, getNativeTokenBalance } from '@buildwithsygma/substrate/types/utils';
import { getAssetBalance, getNativeTokenBalance } from '@buildwithsygma/substrate';
import { ApiPromise } from '@polkadot/api';
import { WsProvider } from '@polkadot/rpc-provider';

Expand Down
4 changes: 1 addition & 3 deletions packages/utils/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"exclude": ["src/**/__test__/**", "test/**"],
"extends": "./tsconfig.json",
"exclude": ["node_modules/**", "src/**/__test__/**", "test/**"],
"compilerOptions": {
"declaration": true,
"esModuleInterop": true,
"module": "commonjs",
"outDir": "./dist-cjs"
}
Expand Down
5 changes: 2 additions & 3 deletions packages/utils/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"exclude": ["src/**/__test__/**", "test/**"],
"extends": "./tsconfig.json",
"exclude": ["node_modules/**", "src/**/__test__/**", "test/**"],
"compilerOptions": {
"module": "ES2020",
"esModuleInterop": true,
"module": "ES2022",
"outDir": "./dist-esm"
}
}
32 changes: 2 additions & 30 deletions packages/utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,5 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "ES2022",
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"moduleResolution": "node",
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"preserveSymlinks": true,
"preserveWatchOutput": true,
"pretty": false,
"strict": true,
"sourceMap": true,
"target": "es2020",
"skipLibCheck": true,
"baseUrl": "./src",
"resolveJsonModule": true
},
"extends": "../../tsconfig.base.json",
"exclude": ["node_modules/**"],
"include": ["./src/**/*.ts", "./test/**/*.ts", "substrate-asset-transfer.ts"],
"ts-node": {
"esm": true,
"experimentalSpecifierResolution": "node"
}
"include": ["./src/**/*.ts"]
}
31 changes: 2 additions & 29 deletions packages/utils/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"allowSyntheticDefaultImports": true,
"module": "ES2022",
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"moduleResolution": "node",
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"preserveSymlinks": true,
"preserveWatchOutput": true,
"pretty": false,
"strict": true,
"sourceMap": false,
"target": "es2020",
"skipLibCheck": true,
"baseUrl": "./src",
"resolveJsonModule": true,
"outDir": "types"
},
"exclude": ["node_modules/**", "src/**/__test__/**", "test/**"],
"include": ["./src/**/*.ts"],
"ts-node": {
"esm": true,
"experimentalSpecifierResolution": "node"
}
"exclude": ["test", "src/**/__test__/**"]
}
11 changes: 8 additions & 3 deletions packages/substrate/tsconfig.base.json → tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "ES2022",
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
Expand All @@ -18,9 +19,13 @@
"pretty": false,
"strict": true,
"sourceMap": true,
"target": "ES2022",
"skipLibCheck": true,
"resolveJsonModule": true,
"baseUrl": "./src"
"baseUrl": "./src",
"resolveJsonModule": true
},
"exclude": ["node_modules/**", "dist"]
"ts-node": {
"esm": true,
"experimentalSpecifierResolution": "node"
}
}

0 comments on commit 7be55ff

Please sign in to comment.