Skip to content

Commit 26355ec

Browse files
authored
chore: flatten config directory (#94)
1 parent d1c3ad3 commit 26355ec

File tree

14 files changed

+112
-117
lines changed

14 files changed

+112
-117
lines changed

src/__tests__/utils/blockchain/starknet.spec.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
import {ChainType, TransactionHashPrefix} from '../../../enums';
22
import utils from '../../../utils';
33

4-
describe('starknet', () => {
4+
const {getTransactionHash, hashEquals} = utils.blockchain.starknet;
5+
6+
describe('starknet blockchain utils', () => {
7+
describe('hashEquals', () => {
8+
it('should compare hashes', () => {
9+
expect(hashEquals([1, 2])).toBeTruthy();
10+
expect(hashEquals([1, 2, 3], [1, 2, 3])).toBeTruthy();
11+
expect(hashEquals([1, 2, 3], [1, 2, 3], [1, 2, 3])).toBeTruthy();
12+
expect(hashEquals([1, 2, 3], [1, 2, 3], [1])).toBeFalsy();
13+
expect(hashEquals([1, 2, 3], [1, 2])).toBeFalsy();
14+
});
15+
});
16+
517
describe('getTransactionHash', () => {
6-
it('should calc tx hash', () => {
18+
it('should calc tx hash from message params', () => {
719
const from_address = '0xc3511006C04EF1d78af4C8E0e74Ec18A6E64Ff9e';
820
const to_address =
921
'3256441166037631918262930812410838598500200462657642943867372734773841898370';
@@ -17,7 +29,7 @@ describe('starknet', () => {
1729
];
1830

1931
expect(
20-
utils.blockchain.starknet.getTransactionHash(
32+
getTransactionHash(
2133
TransactionHashPrefix.L1_HANDLER,
2234
from_address,
2335
to_address,

src/__tests__/utils/date.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import utils from '../../utils';
33
const {get24Time, getDate} = utils.date;
44

55
describe('getDate', () => {
6-
it('should get date', () => {
6+
it('should return date of the form DD/MM/YYYY from timestamp', () => {
77
expect(getDate(1644828892412)).toEqual('14/02/2022');
88
});
99
});
1010

1111
describe('get24Time', () => {
12-
it('should get 24 time', () => {
12+
it('should return 24 time of the form HH:MM:SS from timestamp', () => {
1313
expect(get24Time(1644828892412).endsWith(':54:52')).toBeTruthy();
1414
});
1515
});

src/__tests__/utils/hash.spec.js

-13
This file was deleted.
File renamed without changes.

src/abis/l2/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import L2_ERC20_ABI from './ERC20.json';
1+
import L2_ERC20_ABI from './erc20.json';
22
import L2_BRIDGE_ABI from './token_bridge.json';
33

44
export {L2_ERC20_ABI, L2_BRIDGE_ABI};

src/config/addresses/index.js

-3
This file was deleted.

src/config/addresses/tokens/tokens.l1.js

-78
This file was deleted.

src/config/addresses/contracts/contracts.l1.js src/config/contracts.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ChainType} from '../../../enums';
1+
import {ChainType} from '../enums';
22

33
export const STARKNET_CONTRACT_ADDRESS = {
44
[ChainType.MAIN.id]: '',

src/config/addresses/tokens/tokens.l2.js src/config/tokens.js

+81-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,83 @@
1-
import {ChainType, NetworkType} from '../../../enums';
1+
import {ChainType, NetworkType} from '../enums';
22

3-
export const L2Tokens = [
3+
const l1tokens = [
4+
{
5+
name: NetworkType.L1.tokenName,
6+
symbol: NetworkType.L1.symbol,
7+
decimals: 18,
8+
bridgeAddress: {
9+
[ChainType.MAIN.id]: '',
10+
[ChainType.GOERLI.id]: '0xc3511006C04EF1d78af4C8E0e74Ec18A6E64Ff9e'
11+
}
12+
},
13+
{
14+
name: 'Wrapped BTC',
15+
symbol: 'WBTC',
16+
decimals: 8,
17+
bridgeAddress: {
18+
[ChainType.MAIN.id]: '',
19+
[ChainType.GOERLI.id]: '0xf29aE3446Ce4688fCc792b232C21D1B9581E7baC'
20+
},
21+
tokenAddress: {
22+
[ChainType.MAIN.id]: '',
23+
[ChainType.GOERLI.id]: '0xC04B0d3107736C32e19F1c62b2aF67BE61d63a05'
24+
}
25+
},
26+
{
27+
name: 'Goerli USD Coin',
28+
symbol: 'USDC',
29+
decimals: 6,
30+
bridgeAddress: {
31+
[ChainType.MAIN.id]: '',
32+
[ChainType.GOERLI.id]: '0xBA9cE9F22A3Cfa7Fcb5c31f6B2748b1e72C06204'
33+
},
34+
tokenAddress: {
35+
[ChainType.MAIN.id]: '',
36+
[ChainType.GOERLI.id]: '0x07865c6e87b9f70255377e024ace6630c1eaa37f'
37+
}
38+
},
39+
{
40+
name: 'Tether USD',
41+
symbol: 'USDT',
42+
decimals: 6,
43+
bridgeAddress: {
44+
[ChainType.MAIN.id]: '',
45+
[ChainType.GOERLI.id]: '0xA1f590F18b23EFece02804704E5006E91348C997'
46+
},
47+
tokenAddress: {
48+
[ChainType.MAIN.id]: '',
49+
[ChainType.GOERLI.id]: '0x509Ee0d083DdF8AC028f2a56731412edD63223B9'
50+
}
51+
},
52+
{
53+
name: 'DAI',
54+
symbol: 'DAI',
55+
decimals: 18,
56+
bridgeAddress: {
57+
[ChainType.MAIN.id]: '',
58+
[ChainType.GOERLI.id]: '0x3ebB6C28BD63aDa2feA81f1e6c5a50aFe53B5feE'
59+
},
60+
tokenAddress: {
61+
[ChainType.MAIN.id]: '',
62+
[ChainType.GOERLI.id]: '0x11fE4B6AE13d2a6055C8D9cF65c55bac32B5d844'
63+
}
64+
},
65+
{
66+
name: 'SelfService',
67+
symbol: 'SLF',
68+
decimals: 6,
69+
bridgeAddress: {
70+
[ChainType.MAIN.id]: '',
71+
[ChainType.GOERLI.id]: '0x160e7631f22035149A01420cADD1012267551181'
72+
},
73+
tokenAddress: {
74+
[ChainType.MAIN.id]: '',
75+
[ChainType.GOERLI.id]: '0xd44BB808bfE43095dBb94c83077766382D63952a'
76+
}
77+
}
78+
];
79+
80+
const l2tokens = [
481
{
582
name: NetworkType.L1.tokenName,
683
symbol: NetworkType.L1.symbol,
@@ -80,3 +157,5 @@ export const L2Tokens = [
80157
}
81158
}
82159
];
160+
161+
export {l1tokens, l2tokens};

src/hooks/useContract.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {useCallback, useMemo} from 'react';
33
import {L1_ERC20_ABI, L1_ERC20_BRIDGE_ABI, L1_ETH_BRIDGE_ABI, L1_MESSAGING_ABI} from '../abis/l1';
44
import {L2_BRIDGE_ABI, L2_ERC20_ABI} from '../abis/l2';
55
import {useTransferData} from '../components/Features/Transfer/Transfer.hooks';
6-
import {STARKNET_CONTRACT_ADDRESS} from '../config/addresses';
6+
import {STARKNET_CONTRACT_ADDRESS} from '../config/contracts';
77
import {NetworkType} from '../enums';
88
import {useL1Token} from '../providers/TokensProvider';
99
import {useL1Wallet, useWallets} from '../providers/WalletsProvider';

src/providers/TokensProvider/tokens-reducer.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import {L1Tokens, L2Tokens} from '../../config/addresses';
1+
import {l1tokens, l2tokens} from '../../config/tokens';
22

33
export const actions = {
44
UPDATE_TOKEN_STATE: 'Tokens/UPDATE_TOKEN_STATE'
55
};
66

7-
const l1Tokens = L1Tokens.map(t => ({...t, isL1: true}));
8-
const l2Tokens = L2Tokens.map(t => ({...t, isL2: true}));
9-
export const initialState = [...l1Tokens, ...l2Tokens];
7+
export const initialState = [
8+
...l1tokens.map(t => ({...t, isL1: true})),
9+
...l2tokens.map(t => ({...t, isL2: true}))
10+
];
1011

1112
export const reducer = (state, action) => {
1213
switch (action.type) {

src/utils/blockchain/starknet.js

+6
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,9 @@ export const getTransactionHash = (
8181
...additionalData
8282
]);
8383
};
84+
85+
export const hashEquals = (...data) => {
86+
return !!data.reduce((d1, d2) =>
87+
starknet.hash.computeHashOnElements(d1) === starknet.hash.computeHashOnElements(d2) ? d1 : ''
88+
);
89+
};

src/utils/hash.js

-7
This file was deleted.

src/utils/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import strings from '../config/strings';
22
import * as blockchain from './blockchain';
33
import * as browser from './browser';
44
import * as date from './date';
5-
import * as hash from './hash';
65
import * as logger from './logger';
76
import * as object from './object';
87
import * as parser from './parser';
@@ -28,7 +27,6 @@ const utils = {
2827
string,
2928
token,
3029
parser,
31-
hash,
3230
date,
3331
object,
3432
blockchain,

0 commit comments

Comments
 (0)