Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 4c7c098

Browse files
authored
chore(substrate): add more substrate fungible tests (#423)
Closes #410
1 parent bb4f7b3 commit 4c7c098

File tree

11 files changed

+239
-149
lines changed

11 files changed

+239
-149
lines changed

.eslintrc.cjs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
module.exports = {
22
root: true,
3-
extends: [
4-
"@chainsafe",
5-
"plugin:require-extensions/recommended"
6-
],
7-
plugins: [
8-
"require-extensions"
9-
]
10-
}
3+
extends: ["@chainsafe", "plugin:require-extensions/recommended"],
4+
plugins: ["require-extensions"],
5+
};
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
2-
"compilerOptions": {
3-
"composite": true,
4-
"module": "ES2022",
5-
"allowJs": true,
6-
"declaration": true,
7-
"sourceMap": true,
8-
"declarationMap": true,
9-
"resolveJsonModule": true,
10-
"skipLibCheck": true,
11-
"strict": true,
12-
"esModuleInterop": true,
13-
"downlevelIteration": true,
14-
"allowSyntheticDefaultImports": true,
15-
"forceConsistentCasingInFileNames": true,
16-
"moduleResolution": "node",
17-
},
18-
"include": [
19-
"src"
20-
]
2+
"compilerOptions": {
3+
"composite": true,
4+
"module": "ES2022",
5+
"allowJs": true,
6+
"declaration": true,
7+
"sourceMap": true,
8+
"declarationMap": true,
9+
"resolveJsonModule": true,
10+
"skipLibCheck": true,
11+
"strict": true,
12+
"esModuleInterop": true,
13+
"downlevelIteration": true,
14+
"allowSyntheticDefaultImports": true,
15+
"forceConsistentCasingInFileNames": true,
16+
"moduleResolution": "node"
17+
},
18+
"include": [
19+
"src"
20+
]
2121
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"scripts": {
1616
"lint": "yarn workspaces foreach -A run lint",
1717
"clean": "yarn workspaces foreach -A run clean",
18-
"build": "yarn run clean && yarn workspaces foreach -A run build:all",
18+
"build": "yarn run clean && yarn workspaces foreach -A -t run build:all",
1919
"test": "yarn workspaces foreach -A run test:unit --ci --silent --coverage",
2020
"core:build": "yarn workspace @buildwithsygma/core build:all",
2121
"core:cleanDist": "yarn workspace @buildwithsygma/core clean",

packages/core/src/baseTransfer.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Config } from './config/config.js';
2-
import type { Domainlike, EvmResource, Domain, SubstrateResource } from './types.js';
2+
import type { Domain, Domainlike, EvmResource, SubstrateResource } from './types.js';
33

44
export interface BaseTransferParams {
55
source: Domainlike;
@@ -13,7 +13,6 @@ export abstract class BaseTransfer {
1313
protected sourceDomain: Domain;
1414
protected transferResource: EvmResource | SubstrateResource;
1515
protected sygmaConfiguration: Config;
16-
1716
protected sourceAddress: string;
1817

1918
public get source(): Domain {
@@ -78,8 +77,7 @@ export abstract class BaseTransfer {
7877
* @param destination
7978
* @returns
8079
*/
81-
setDesinationDomain(destination: Domainlike): void {
82-
const domain = this.config.getDomain(destination);
83-
this.destinationDomain = domain;
80+
setDestinationDomain(destination: Domainlike): void {
81+
this.destinationDomain = this.config.getDomain(destination);
8482
}
8583
}

packages/core/src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as process from 'node:process';
22

33
import { decodeAddress, encodeAddress } from '@polkadot/keyring';
44
import { hexToU8a, isHex } from '@polkadot/util';
5-
import validate, { Network as BitcoinNetwork } from 'bitcoin-address-validation';
5+
import { Network as BitcoinNetwork, validate } from 'bitcoin-address-validation';
66
import { ethers } from 'ethers';
77

88
import { ExplorerUrl, IndexerUrl } from './constants.js';

packages/evm/src/__test__/fungible.test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -344,4 +344,20 @@ describe('Fungible - Deposit', () => {
344344
'Insufficient ERC20 token balance',
345345
);
346346
});
347+
348+
it('should throw ERROR - Insufficient account balance', async () => {
349+
(ERC20__factory.connect as jest.Mock).mockReturnValue({
350+
balanceOf: jest.fn().mockResolvedValue(BigNumber.from(parseEther('1').toBigInt())), // Mock balance less than the required amount
351+
populateTransaction: {
352+
approve: jest.fn().mockResolvedValue({}),
353+
},
354+
allowance: jest.fn().mockResolvedValue(parseEther('0')),
355+
});
356+
357+
const transfer = await createEvmFungibleAssetTransfer(TRANSFER_PARAMS);
358+
359+
await expect(transfer.getTransferTransaction()).rejects.toThrow(
360+
'Insufficient ERC20 token balance',
361+
);
362+
});
347363
});

packages/evm/src/baseTransfer.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)