Skip to content

Commit cf6bdc1

Browse files
Merge pull request #228 from multiversx/development
Fix custom wallet address
2 parents b52781b + 0375fa2 commit cf6bdc1

File tree

13 files changed

+481
-472
lines changed

13 files changed

+481
-472
lines changed

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
'^.+\\.(ts|js|tsx|jsx)$': '@swc/jest'
1313
},
1414
transformIgnorePatterns: [
15-
'node_modules/(?!@multiversx/sdk-guardians-provider|@multiversx/sdk-dapp-form|@multiversx/sdk-dapp-nft|@multiversx/sdk-dapp|@multiversx/sdk-wallet-connect-provider|@multiversx/sdk-guardians-provider|react-redux|swiper|ssr-window|dom7|axios|react-tooltip|uuid|uint8arrays|multiformats|@lifeomic/axios-fetch)'
15+
'node_modules/(?!@multiversx/sdk-guardians-provider|@multiversx/sdk-dapp-form|@multiversx/sdk-dapp-nft|@multiversx/sdk-dapp|@multiversx/sdk-wallet-connect-provider|@multiversx/sdk-guardians-provider|@multiversx/sdk-wallet|react-redux|swiper|ssr-window|dom7|axios|react-tooltip|uuid|uint8arrays|multiformats|@lifeomic/axios-fetch|@walletconnect)'
1616
],
1717
moduleNameMapper: {
1818
'^react-native$': 'react-native-web',

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"@fortawesome/free-solid-svg-icons": "6.5.1",
1111
"@fortawesome/react-fontawesome": "0.2.0",
1212
"@multiversx/sdk-core": "13.2.1",
13-
"@multiversx/sdk-dapp": "2.33.3",
13+
"@multiversx/sdk-dapp": "2.33.6",
1414
"@multiversx/sdk-network-providers": "2.4.3",
1515
"axios": "1.6.5",
1616
"classnames": "2.3.2",
@@ -53,6 +53,11 @@
5353
"@types/react-router-dom": "5.3.3",
5454
"@vitejs/plugin-basic-ssl": "^1.0.1",
5555
"@vitejs/plugin-react": "4.1.0",
56+
"@wdio/cli": "^8.33.1",
57+
"@wdio/concise-reporter": "8.32.4",
58+
"@wdio/local-runner": "^8.32.4",
59+
"@wdio/mocha-framework": "^8.32.4",
60+
"@wdio/spec-reporter": "^8.32.4",
5661
"autoprefixer": "10.4.16",
5762
"eslint": "8.50.0",
5863
"eslint-config-prettier": "9.0.0",
@@ -75,17 +80,12 @@
7580
"prettier": "3.0.3",
7681
"tailwindcss": "3.3.3",
7782
"ts-jest": "29.1.1",
83+
"ts-node": "10.9.2",
7884
"typescript": "5.2.2",
7985
"vite": "4.4.9",
8086
"vite-plugin-node-polyfills": "0.14.1",
8187
"vite-plugin-svgr": "4.0.0",
82-
"vite-tsconfig-paths": "4.2.1",
83-
"@wdio/local-runner": "^8.32.4",
84-
"@wdio/mocha-framework": "^8.32.4",
85-
"@wdio/spec-reporter": "^8.32.4",
86-
"@wdio/cli": "^8.33.1",
87-
"ts-node": "10.9.2",
88-
"@wdio/concise-reporter": "8.32.4"
88+
"vite-tsconfig-paths": "4.2.1"
8989
},
9090
"resolutions": {
9191
"**/*/nth-check": "2.0.1"

src/components/sdkDappComponents.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export { WalletConnectLoginButton } from '@multiversx/sdk-dapp/UI/walletConnect/
1717
export { WebWalletLoginButton } from '@multiversx/sdk-dapp/UI/webWallet/WebWalletLoginButton/WebWalletLoginButton';
1818
export { CrossWindowLoginButton } from '@multiversx/sdk-dapp/UI/webWallet/CrossWindowLoginButton/CrossWindowLoginButton';
1919
export { XaliasLoginButton } from '@multiversx/sdk-dapp/UI/webWallet/XaliasLoginButton/XaliasLoginButton';
20+
export { XaliasCrossWindowLoginButton } from '@multiversx/sdk-dapp/UI/webWallet/XaliasCrossWindowLoginButton/XaliasCrossWindowLoginButton';
2021
export { AuthenticatedRoutesWrapper } from '@multiversx/sdk-dapp/wrappers/AuthenticatedRoutesWrapper/AuthenticatedRoutesWrapper';
2122
export { AxiosInterceptorContext } from '@multiversx/sdk-dapp/wrappers/AxiosInterceptorContext/AxiosInterceptorContext';
2223
export { DappProvider } from '@multiversx/sdk-dapp/wrappers/DappProvider/DappProvider';

src/pages/Dashboard/widgets/PingPongService/hooks/tests/useGetPingTransaction.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { useGetPingTransaction } from '../useGetPingTransaction';
55
const pingTransaction = {
66
nonce: 10705,
77
value: '1000000000000000000',
8-
receiver: 'erd1qqqqqqqqqqqqqpgq72l6vl07fkn3alyfq753mcy4nakm0l72396qkcud5x',
9-
sender: 'erd1wh9c0sjr2xn8hzf02lwwcr4jk2s84tat9ud2kaq6zr7xzpvl9l5q8awmex',
8+
receiver: 'erd1qqqqqqqqqqqqqpgqm6ad6xrsjvxlcdcffqe8w58trpec09ug9l5qde96pq',
9+
sender: 'erd1axhx4kenjlae6sknq7zjg2g4fvzavv979r2fg425p62wkl84avtqsf7vvv',
1010
gasPrice: 1000000000,
1111
gasLimit: 6000000,
1212
data: 'cGluZw==',

src/pages/Dashboard/widgets/PingPongService/hooks/tests/useGetPongTransaction.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { useGetPongTransaction } from '../useGetPongTransaction';
55
const pongTransaction = {
66
nonce: 10702,
77
value: '0',
8-
receiver: 'erd1qqqqqqqqqqqqqpgq72l6vl07fkn3alyfq753mcy4nakm0l72396qkcud5x',
9-
sender: 'erd1wh9c0sjr2xn8hzf02lwwcr4jk2s84tat9ud2kaq6zr7xzpvl9l5q8awmex',
8+
receiver: 'erd1qqqqqqqqqqqqqpgqm6ad6xrsjvxlcdcffqe8w58trpec09ug9l5qde96pq',
9+
sender: 'erd1axhx4kenjlae6sknq7zjg2g4fvzavv979r2fg425p62wkl84avtqsf7vvv',
1010
gasPrice: 1000000000,
1111
gasLimit: 6000000,
1212
data: 'cG9uZw==',

src/pages/Dashboard/widgets/SignMessage/helpers/tests/decodeMessage.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { decodeMessage } from '../decodeMessage';
22

33
const address =
4-
'erd1wh9c0sjr2xn8hzf02lwwcr4jk2s84tat9ud2kaq6zr7xzpvl9l5q8awmex';
4+
'erd1axhx4kenjlae6sknq7zjg2g4fvzavv979r2fg425p62wkl84avtqsf7vvv';
55
const signature =
6-
'0x079da60c478e32d5ddd2fba135708f025db08a6e0c3c440edac664ab151f0bb7c7efc303d96c4b290ff29aaf02f121e986bacbc33fe735fe2b49e7ba911fc608';
6+
'795b8437bdbcc9c2a3f610a96d95bd393d23d584d40121ea388999ebd9a34157117a665c86a0285cb207e7da23f4fced848f81c218ebab735da22a5cdb00f803';
77
const rawMessage = 'hello world';
88
const signedMessage = '0x68656c6c6f20776f726c64';
99

src/pages/Unlock/Unlock.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import {
1111
OperaWalletLoginButton,
1212
WalletConnectLoginButton,
1313
WebWalletLoginButton as WebWalletUrlLoginButton,
14-
XaliasLoginButton,
14+
XaliasCrossWindowLoginButton,
1515
CrossWindowLoginButton
1616
} from 'components/sdkDappComponents';
1717
import { nativeAuth } from 'config';
1818
import { RouteNamesEnum } from 'localConstants';
1919
import { useNavigate } from 'react-router-dom';
2020
import { AuthRedirectWrapper } from 'wrappers';
21-
import { WebWalletLoginWrapper, WebWalletLoginConfigEnum } from './components';
21+
import { WebWalletLoginWrapper, XaliasLoginWrapper } from './components';
2222

2323
type CommonPropsType =
2424
| OperaWalletLoginButtonPropsType
@@ -72,15 +72,14 @@ export const Unlock = () => {
7272
{...commonProps}
7373
/>
7474

75-
<XaliasLoginButton
75+
<XaliasCrossWindowLoginButton
7676
loginButtonText='xAlias'
7777
data-testid='xAliasLoginBtn'
78+
customWalletAddress='https://127.0.0.1:3000'
7879
{...commonProps}
7980
/>
80-
<WebWalletLoginWrapper
81-
{...commonProps}
82-
config={['crossWindow', 'url']}
83-
/>
81+
<XaliasLoginWrapper {...commonProps} />
82+
<WebWalletLoginWrapper {...commonProps} />
8483
</div>
8584
</div>
8685
</div>
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import React, { PropsWithChildren, useEffect, useRef, useState } from 'react';
2+
import { WebWalletLoginButtonPropsType } from '@multiversx/sdk-dapp/UI/webWallet/WebWalletLoginButton/WebWalletLoginButton';
3+
import { InitiateLoginFunctionType } from '@multiversx/sdk-dapp/types/login.types';
4+
5+
export const DualLoginButton = ({
6+
onInitiateLogin,
7+
label,
8+
children
9+
}: PropsWithChildren<
10+
WebWalletLoginButtonPropsType & {
11+
onInitiateLogin: InitiateLoginFunctionType;
12+
label: string;
13+
}
14+
>) => {
15+
const dropdownRef = useRef<HTMLButtonElement>(null);
16+
const anchorRef = useRef<HTMLAnchorElement>(null);
17+
const [showOptions, setShowOptions] = useState(false);
18+
19+
useEffect(() => {
20+
const handleClickOutside = (event: MouseEvent) => {
21+
const isOutside = [dropdownRef, anchorRef].every((ref) => {
22+
return ref.current && !ref.current.contains(event.target as Node);
23+
});
24+
if (isOutside) {
25+
setShowOptions(false);
26+
}
27+
};
28+
document.addEventListener('mousedown', handleClickOutside);
29+
return () => {
30+
document.removeEventListener('mousedown', handleClickOutside);
31+
};
32+
}, [dropdownRef, anchorRef]);
33+
34+
const onDropdownClick = () => {
35+
setShowOptions((current) => !current);
36+
};
37+
38+
const handleLegacyUrlLogin = (
39+
e: React.MouseEvent<HTMLAnchorElement, MouseEvent>
40+
) => {
41+
e.preventDefault();
42+
onInitiateLogin();
43+
};
44+
45+
return (
46+
<div className='flex items-center'>
47+
{children}
48+
<div
49+
style={{
50+
position: 'relative'
51+
}}
52+
>
53+
<button
54+
data-testid='legacyWebWalletLoginDropdownButton'
55+
className='flex-shrink-0 z-10 inline-flex items-center py-3.5 px-2 text-sm font-medium text-center text-gray-200 rounded-r-md border border-gray-200 dark:border-gray-700 dark:text-white hover:bg-gray-200 hover:text-gray-400 focus:ring-2 focus:outline-none focus:ring-gray-300 dark:bg-gray-600 dark:hover:bg-gray-700 dark:focus:ring-gray-800'
56+
type='button'
57+
ref={dropdownRef}
58+
onClick={onDropdownClick}
59+
>
60+
<svg
61+
className='w-2.5 h-2'
62+
aria-hidden='true'
63+
xmlns='http://www.w3.org/2000/svg'
64+
fill='none'
65+
viewBox='0 0 10 6'
66+
>
67+
<path
68+
stroke='currentColor'
69+
strokeLinecap='round'
70+
strokeLinejoin='round'
71+
strokeWidth='2'
72+
d='m1 1 4 4 4-4'
73+
/>
74+
</svg>
75+
</button>
76+
<div
77+
style={{
78+
position: 'absolute',
79+
inset: '0px auto auto 0px',
80+
margin: '0px',
81+
transform: 'translate3d(-148px, 40px, 0px)'
82+
}}
83+
className={`z-10 bg-white divide-y divide-gray-100 rounded-lg shadow w-44 dark:bg-gray-700 ${
84+
showOptions ? 'block' : 'hidden'
85+
}`}
86+
>
87+
<ul
88+
className='py-2 text-sm text-gray-700 dark:text-gray-200'
89+
aria-labelledby='dropdown-button'
90+
>
91+
<li>
92+
<a
93+
onClick={handleLegacyUrlLogin}
94+
data-testid='legacyWebWalletLoginButton'
95+
href='#'
96+
ref={anchorRef}
97+
className='block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white'
98+
>
99+
{label} URL login
100+
</a>
101+
</li>
102+
</ul>
103+
</div>
104+
</div>
105+
</div>
106+
);
107+
};
Lines changed: 9 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,24 @@
1-
import React, { useEffect, useRef, useState } from 'react';
1+
import React from 'react';
22
import { WebWalletLoginButtonPropsType } from '@multiversx/sdk-dapp/UI/webWallet/WebWalletLoginButton/WebWalletLoginButton';
33
import { useWebWalletLogin } from '@multiversx/sdk-dapp/hooks/login/useWebWalletLogin';
4-
import {
5-
CrossWindowLoginButton,
6-
WebWalletLoginButton as WebWalletUrlLoginButton
7-
} from 'components/sdkDappComponents';
8-
9-
export const WebWalletLoginConfigEnum = {
10-
crossWindow: 'crossWindow',
11-
url: 'url'
12-
};
4+
import { CrossWindowLoginButton } from 'components/sdkDappComponents';
5+
import { DualLoginButton } from './DualLoginButton';
136

147
export const WebWalletLoginWrapper = ({
15-
config,
168
...commonProps
17-
}: WebWalletLoginButtonPropsType & {
18-
config: (keyof typeof WebWalletLoginConfigEnum)[];
19-
}) => {
20-
const dropdownRef = useRef<HTMLButtonElement>(null);
21-
const anchorRef = useRef<HTMLAnchorElement>(null);
22-
9+
}: WebWalletLoginButtonPropsType) => {
2310
const [onInitiateLogin] = useWebWalletLogin({
2411
...commonProps
2512
});
2613

27-
const [showOptions, setShowOptions] = useState(false);
28-
29-
useEffect(() => {
30-
const handleClickOutside = (event: MouseEvent) => {
31-
const isOutside = [dropdownRef, anchorRef].every((ref) => {
32-
return ref.current && !ref.current.contains(event.target as Node);
33-
});
34-
if (isOutside) {
35-
setShowOptions(false);
36-
}
37-
};
38-
document.addEventListener('mousedown', handleClickOutside);
39-
return () => {
40-
document.removeEventListener('mousedown', handleClickOutside);
41-
};
42-
}, [dropdownRef, anchorRef]);
43-
44-
const onDropdownClick = () => {
45-
setShowOptions((current) => !current);
46-
};
47-
48-
const handleLegacyUrlLogin = (
49-
e: React.MouseEvent<HTMLAnchorElement, MouseEvent>
50-
) => {
51-
e.preventDefault();
52-
onInitiateLogin();
53-
};
54-
55-
const hasBothOptions = config.length === 2;
56-
57-
if (hasBothOptions) {
58-
return (
59-
<div className='flex items-center'>
60-
<CrossWindowLoginButton
61-
loginButtonText='Web Wallet'
62-
data-testid='webWalletLoginBtn'
63-
className='!mr-0 !rounded-none !rounded-l-md'
64-
{...commonProps}
65-
/>
66-
<div
67-
style={{
68-
position: 'relative'
69-
}}
70-
>
71-
<button
72-
data-testid='legacyWebWalletLoginDropdownButton'
73-
className='flex-shrink-0 z-10 inline-flex items-center py-3.5 px-2 text-sm font-medium text-center text-gray-200 rounded-r-md border border-gray-200 dark:border-gray-700 dark:text-white hover:bg-gray-200 hover:text-gray-400 focus:ring-2 focus:outline-none focus:ring-gray-300 dark:bg-gray-600 dark:hover:bg-gray-700 dark:focus:ring-gray-800'
74-
type='button'
75-
ref={dropdownRef}
76-
onClick={onDropdownClick}
77-
>
78-
<svg
79-
className='w-2.5 h-2'
80-
aria-hidden='true'
81-
xmlns='http://www.w3.org/2000/svg'
82-
fill='none'
83-
viewBox='0 0 10 6'
84-
>
85-
<path
86-
stroke='currentColor'
87-
strokeLinecap='round'
88-
strokeLinejoin='round'
89-
strokeWidth='2'
90-
d='m1 1 4 4 4-4'
91-
/>
92-
</svg>
93-
</button>
94-
<div
95-
style={{
96-
position: 'absolute',
97-
inset: '0px auto auto 0px',
98-
margin: '0px',
99-
transform: 'translate3d(-148px, 40px, 0px)'
100-
}}
101-
className={`z-10 bg-white divide-y divide-gray-100 rounded-lg shadow w-44 dark:bg-gray-700 ${
102-
showOptions ? 'block' : 'hidden'
103-
}`}
104-
>
105-
<ul
106-
className='py-2 text-sm text-gray-700 dark:text-gray-200'
107-
aria-labelledby='dropdown-button'
108-
>
109-
<li>
110-
<a
111-
onClick={handleLegacyUrlLogin}
112-
data-testid='legacyWebWalletLoginButton'
113-
href='#'
114-
ref={anchorRef}
115-
className='block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white'
116-
>
117-
Web Wallet URL login
118-
</a>
119-
</li>
120-
</ul>
121-
</div>
122-
</div>
123-
</div>
124-
);
125-
}
126-
127-
if (config.includes('url')) {
128-
return (
129-
<WebWalletUrlLoginButton
14+
return (
15+
<DualLoginButton label='Web Wallet' onInitiateLogin={onInitiateLogin}>
16+
<CrossWindowLoginButton
13017
loginButtonText='Web Wallet'
13118
data-testid='webWalletLoginBtn'
19+
className='!mr-0 !rounded-none !rounded-l-md'
13220
{...commonProps}
13321
/>
134-
);
135-
}
136-
137-
return (
138-
<CrossWindowLoginButton
139-
loginButtonText='Web Wallet'
140-
data-testid='webWalletLoginBtn'
141-
{...commonProps}
142-
/>
22+
</DualLoginButton>
14323
);
14424
};

0 commit comments

Comments
 (0)