Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the new cross window functionality in web wallet #1067

Merged
merged 197 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
197 commits
Select commit Hold shift + click to select a range
751f144
add walletV2 provider WIP
andreigiura Jul 27, 2023
0a9ada9
get wallet address from state
andreigiura Jul 27, 2023
4bbdddc
Message communication working
arhtudormorar Jul 27, 2023
4e3c2bd
login with wallet v2
andreigiura Jul 27, 2023
2c40875
login with wallet v2
andreigiura Jul 27, 2023
4c90115
Navigation working
arhtudormorar Jul 27, 2023
6f810a7
fix event listener removal
andreigiura Jul 27, 2023
e742795
Merge branch 'web-wallet-child-tab' of github.com:multiversx/mx-sdk-d…
andreigiura Jul 27, 2023
b944291
prepare sign
andreigiura Jul 27, 2023
f8723c4
Fix yarn lock
arhtudormorar Jul 27, 2023
1a73ca1
Minor refactor
arhtudormorar Jul 27, 2023
e9d4f5e
FIx error
arhtudormorar Jul 27, 2023
b90662f
close child window on unload
andreigiura Jul 28, 2023
6b5859a
remove console log
andreigiura Jul 28, 2023
49d70a6
remove console log
andreigiura Jul 28, 2023
c8a946a
sign when child window is closed
andreigiura Jul 28, 2023
ab5ff16
sign when child window is closed
andreigiura Jul 28, 2023
99faef3
cancel tx
andreigiura Jul 28, 2023
4cc32fb
Add logout
arhtudormorar Jul 28, 2023
b84c9d9
Merge branch 'development' into web-wallet-child-tab
arhtudormorar Aug 9, 2023
a8be493
Update yarn lock
arhtudormorar Aug 9, 2023
d1c93b9
Work on login event
arhtudormorar Aug 28, 2023
0f443f5
Work on walletProvider
arhtudormorar Aug 28, 2023
e5fedb5
Remove isChildTab key
arhtudormorar Sep 8, 2023
c659691
Merge branch 'development' into web-wallet-child-tab
arhtudormorar Oct 31, 2023
5e27212
Rename walletV2 to crossWindow
arhtudormorar Oct 31, 2023
8cca4c1
Updated parentDapp to window.document.referrer
arhtudormorar Nov 3, 2023
2eb5aa7
Remove reference to referrer
arhtudormorar Nov 3, 2023
6ef15db
Update version to alpha
arhtudormorar Nov 3, 2023
7dbe467
provider wip
andreigiura Nov 7, 2023
b515b44
sign transactions
andreigiura Nov 9, 2023
0861799
Add comments
arhtudormorar Nov 9, 2023
dc67052
Update alpha version
arhtudormorar Nov 10, 2023
20388d9
fix wallet refresh (handshake lost)
andreigiura Nov 10, 2023
3587768
cancel action from dApp
andreigiura Nov 13, 2023
b307e3c
Update version
arhtudormorar Nov 13, 2023
15d6110
Merge branch 'web-wallet-child-tab' of github.com:multiversx/mx-sdk-d…
andreigiura Nov 14, 2023
d1d3fc4
use provider from package
andreigiura Nov 14, 2023
e008288
fix import
andreigiura Nov 14, 2023
a74b557
alpha version
andreigiura Nov 28, 2023
8928849
yarn lock
andreigiura Nov 28, 2023
8d5ebc9
Merge branch 'development' into web-wallet-child-tab
andreigiura Nov 28, 2023
f1268c2
alpha version increment
andreigiura Nov 28, 2023
4e21e27
merge development
andreigiura Nov 29, 2023
1523fce
increment cross window provider version
andreigiura Dec 4, 2023
b9dfd96
increment alpha version
andreigiura Dec 4, 2023
13f2a84
regenerate yarn lock
andreigiura Dec 5, 2023
24cfdb0
Add comment
arhtudormorar Dec 5, 2023
528fb1b
bump version
andreigiura Dec 5, 2023
0378a4a
regenerate yarn lock
andreigiura Dec 5, 2023
73aece9
Merge branch 'web-wallet-child-tab' of github.com:multiversx/mx-sdk-d…
andreigiura Dec 5, 2023
46c327e
bump provider version
andreigiura Dec 6, 2023
a25cc4d
bump alpha version
andreigiura Dec 6, 2023
f31674a
Merge branch 'development' into web-wallet-child-tab
andreigiura Dec 7, 2023
ed98a3d
Merge branch 'main' into web-wallet-child-tab
andreigiura Dec 19, 2023
92f7fea
New webview provider (#996)
CiprianDraghici Dec 19, 2023
3df437e
Merge branch 'development' into web-wallet-child-tab
andreigiura Dec 20, 2023
f6b4ed0
yarn.lock
andreigiura Dec 20, 2023
749d539
increment version
andreigiura Dec 20, 2023
2223716
regenerate yarn lock
andreigiura Dec 20, 2023
057ade9
apply minification
CiprianDraghici Dec 20, 2023
afcbccd
Merge branch 'development' into cross-window-hub
arhtudormorar Dec 21, 2023
8c942af
Update version
arhtudormorar Dec 21, 2023
79df71d
rename NewWebViewProvider into ExperimentalWebviewProvider
CiprianDraghici Dec 22, 2023
2bb3453
2.26.0-alpha.3
CiprianDraghici Dec 22, 2023
fb3b689
Merge branch 'development' into cross-window-hub
razvantomegea Dec 28, 2023
0ef8ac8
2.26.0-alpha-4
razvantomegea Dec 28, 2023
84d84cc
Fixed build error
razvantomegea Dec 28, 2023
15092c0
Merge branch 'development' into cross-window-hub
arhtudormorar Jan 3, 2024
b838f97
Upgrade @multiversx/sdk-web-wallet-cross-window-provider@0.0.10
arhtudormorar Jan 3, 2024
463857e
Upgrade version
arhtudormorar Jan 3, 2024
eb80853
Upgrade provider
arhtudormorar Jan 4, 2024
3cd002c
Merge branch 'development' into cross-window-hub
arhtudormorar Jan 4, 2024
dcb21a2
cleanup
CiprianDraghici Jan 4, 2024
e7a5e2e
2.26.0-alpha-8
CiprianDraghici Jan 4, 2024
c7b2a27
fix sign message
CiprianDraghici Jan 4, 2024
88d8f82
2.26.0-alpha-9
CiprianDraghici Jan 4, 2024
69e974f
try to fix the issue of accessing origin from Window outside of the i…
CiprianDraghici Jan 5, 2024
5fd54b3
2.26.0-alpha.10
CiprianDraghici Jan 5, 2024
58a9968
Merge remote-tracking branch 'origin/development' into cross-window-hub
CiprianDraghici Jan 8, 2024
60a5a9f
Merge remote-tracking branch 'origin/development' into cross-window-hub
CiprianDraghici Jan 9, 2024
1c225bb
fix build
CiprianDraghici Jan 9, 2024
b0b0c24
2.27.0-alpha.0
CiprianDraghici Jan 9, 2024
6ad395c
cleanup after merge
CiprianDraghici Jan 10, 2024
224cbd4
2.27.0-alpha.1
CiprianDraghici Jan 10, 2024
d095d85
Fix axios instance
arhtudormorar Jan 10, 2024
4b9b922
Merge branch 'cross-window-hub' into tm/cross-window-hub-axios
arhtudormorar Jan 10, 2024
90866a6
Update version
arhtudormorar Jan 10, 2024
b291a01
Add axios patch
arhtudormorar Jan 10, 2024
9cb8086
Set interceptors
arhtudormorar Jan 10, 2024
88294d6
Fix interceptors
arhtudormorar Jan 10, 2024
c514909
Merge pull request #1019 from multiversx/tm/cross-window-hub-axios
arhtudormorar Jan 10, 2024
0ba5884
Fix tests
arhtudormorar Jan 10, 2024
ff1c53a
Merge branch 'development' into cross-window-hub
arhtudormorar Jan 10, 2024
67339ea
Update README
arhtudormorar Jan 11, 2024
2453f7c
Merge branch 'main' into cross-window-hub
arhtudormorar Jan 12, 2024
8e09284
Upgrade corss-window-provider
arhtudormorar Jan 12, 2024
e2a8eb1
2.28.0-alpha.3
arhtudormorar Jan 12, 2024
31ca954
Changed postMessage payload from string to plain object (#1025)
razvantomegea Jan 18, 2024
fc0db02
Improve tsc support (#1026)
DanutIlie Jan 18, 2024
36f1ce4
Update sdk-web-wallet-cross-window-provider@0.0.19
arhtudormorar Jan 19, 2024
789920d
2.28.0-alpha.7
arhtudormorar Jan 19, 2024
fef859c
Updated sdk-core
razvantomegea Jan 25, 2024
1a3edbd
2.28.1-alpha.0
razvantomegea Jan 25, 2024
6dbf965
Merge branch 'development' into rt/feature/multisig
arhtudormorar Jan 26, 2024
34218da
Merge branch 'development' into cross-window-hub
arhtudormorar Jan 31, 2024
79958c3
Update yarn lock
arhtudormorar Jan 31, 2024
4a5a1bb
Merge development
arhtudormorar Jan 31, 2024
26a3f83
2.28.4-alpha.1
arhtudormorar Jan 31, 2024
10191b7
Merge branch 'development' into cross-window-hub
razvantomegea Jan 31, 2024
9ed35d0
Fix extension cancel mesage
arhtudormorar Jan 31, 2024
fe4af14
2.28.4-alpha.2
arhtudormorar Jan 31, 2024
a22ec5e
Merge branch 'development' into rt/feature/multisig
razvantomegea Feb 5, 2024
f21f6df
Updated sdk-core
razvantomegea Feb 5, 2024
42e3347
2.28.5-alpha.0
razvantomegea Feb 5, 2024
1b2b9b6
Updated sdk-core
razvantomegea Feb 5, 2024
97d9af8
2.28.5-alpha.1
razvantomegea Feb 5, 2024
a4071d3
Merge branch 'rt/feature/multisig' into cross-window-hub
arhtudormorar Feb 5, 2024
1eb3553
Update yarn lock
arhtudormorar Feb 5, 2024
9ea9d97
2.28.5-alpha.2
arhtudormorar Feb 5, 2024
a572101
Upgrade @multiversx/sdk-web-wallet-cross-window-provider@0.0.20
arhtudormorar Feb 5, 2024
fd5a580
2.28.5-alpha.3
arhtudormorar Feb 5, 2024
a164f70
Extract multisig login logic
arhtudormorar Feb 5, 2024
94897a9
Fix login
arhtudormorar Feb 5, 2024
b0bc108
2.28.5-alpha.4
arhtudormorar Feb 5, 2024
e3f52c8
Merge pull request #1039 from multiversx/tm/chw-multisig-login
arhtudormorar Feb 5, 2024
1a3d5d7
Fixed wallet connect breaks login with other providers (#1041)
razvantomegea Feb 8, 2024
bb4f93f
2.28.6-alpha.0 (#1045)
razvantomegea Feb 8, 2024
f131b63
2.28.6-alpha.1
arhtudormorar Feb 9, 2024
672b2d4
Fix types
arhtudormorar Feb 9, 2024
e0bb3a8
2.28.6-alpha.2
arhtudormorar Feb 9, 2024
5f2d338
Merge branch 'development' into rt/feature/multisig
razvantomegea Feb 9, 2024
56d7719
2.28.6-alpha.5
razvantomegea Feb 9, 2024
14457f2
Merge branch 'development' into rt/feature/multisig
razvantomegea Feb 13, 2024
497a3dc
2.28.7-alpha.0
razvantomegea Feb 13, 2024
753ce73
Merge branch 'development' into cross-window-hub
razvantomegea Feb 13, 2024
42a6a04
2.28.7-alpha.1
razvantomegea Feb 13, 2024
ce33a23
Fix tests and build
razvantomegea Feb 13, 2024
061bec1
Add support for nativeAuth impersonate (#1049)
arhtudormorar Feb 14, 2024
c289a1c
Fixed issues with wallet connect (#1050)
mgavrila Feb 15, 2024
c875f6f
Merge branch 'rt/feature/multisig' into cross-window-hub
razvantomegea Feb 15, 2024
b98ad16
2.28.7-alpha.4
razvantomegea Feb 15, 2024
479cb88
Add getHasNativeAuth (#1051)
mgavrila Feb 16, 2024
261927f
Avoid sending nativeAuth if it is not configured
mgavrila Feb 16, 2024
1316149
Update QR initialization to not do extra steps if it is not mounted
mgavrila Feb 16, 2024
b1c86da
Update walletConnect initialization (#1052)
mgavrila Feb 19, 2024
2c13cac
Fix wallet connect chainID (#1053)
mgavrila Feb 20, 2024
65b8b41
Added new fee and receiver fields.
Feb 21, 2024
93ef894
Merge branch 'cross-window-hub' into mm-new-sign-screen
Feb 22, 2024
3c20b22
Updated data field styles.
Feb 22, 2024
db15884
Updated wording.
Feb 23, 2024
7e1dd29
Merge pull request #1055 from multiversx/mm-new-sign-screen
andreigiura Feb 28, 2024
64aec1e
increment alpha
andreigiura Feb 28, 2024
307ef1f
increment alpha
andreigiura Feb 28, 2024
57fc256
Added markup.
Feb 29, 2024
b125d21
Fixed wrongfully placed data test identifier.
Feb 29, 2024
6d9e775
2.28.7-alpha.19
Feb 29, 2024
563adfa
Merge pull request #1056 from multiversx/mm-fix-receiver-data-testid
andreigiura Feb 29, 2024
8cdbcc7
Added missing data test identifier.
Feb 29, 2024
0f14d71
2.28.7-alpha.20
Feb 29, 2024
dc37b12
Merge branch 'cross-window-hub' into mm-fix-receiver-data-testid
Feb 29, 2024
573ab1d
Merge pull request #1057 from multiversx/mm-fix-receiver-data-testid
andreigiura Feb 29, 2024
c2daf6f
Merge branch 'cross-window-hub' into mm-new-sign-screen-amount
Feb 29, 2024
e683058
Updated layout.
Feb 29, 2024
71a1fe4
Updated file structure.
Mar 4, 2024
8fb2778
2.28.7-alpha.21
Mar 4, 2024
fb8e1dc
Updated code quality.
Mar 4, 2024
bcaae77
Removed redundant condition.
Mar 4, 2024
b050ee8
Updated imports to be relative.
Mar 4, 2024
e3a3f47
Merge pull request #1058 from multiversx/mm-new-sign-screen-amount
Mar 4, 2024
1154ca2
Fix ledger guardian signing (#1059)
arhtudormorar Mar 6, 2024
af74c0e
2.28.7-alpha.22
arhtudormorar Mar 6, 2024
3e296e5
Added missing "data-testid".
Mar 6, 2024
233baa5
2.28.7-alpha.23
Mar 6, 2024
8357749
Fix Sign step progress (#1060)
arhtudormorar Mar 7, 2024
e2f9978
Merge branch 'development' into rt/fix/base64utils
razvantomegea Mar 7, 2024
3a769ea
2.28.8-alpha.0
razvantomegea Mar 7, 2024
9e4ada9
Merge pull request #1063 from multiversx/rt/fix/base64utils
razvantomegea Mar 7, 2024
28813d4
Update WalletConnect (#1064)
radumojic Mar 7, 2024
3fa3646
Fixed tests.
Mar 7, 2024
b83204b
Added "data-value".
Mar 8, 2024
898d297
Merge branch 'cross-window-hub' into mm-fix-data-testids
Mar 8, 2024
9f95cca
2.28.8-alpha.3
Mar 8, 2024
9059a82
Added variable.
Mar 8, 2024
b6a6b76
Merge pull request #1065 from multiversx/mm-fix-data-testids
Mar 8, 2024
88f1b84
Fixed code.
Mar 8, 2024
3be40be
2.28.8-alpha.4
Mar 8, 2024
351e5eb
Merge pull request #1066 from multiversx/mm-fix-data-testids
Mar 8, 2024
b4d8fd4
extend ExperimentalWebviewProvider with reset state option
CiprianDraghici Mar 8, 2024
acd7fed
fix merge conflicts
CiprianDraghici Mar 8, 2024
c58f804
2.28.8-alpha.5
CiprianDraghici Mar 8, 2024
1443204
update changelog
CiprianDraghici Mar 8, 2024
5aead1a
update changelog
CiprianDraghici Mar 8, 2024
342310f
Tm/cwh-fixes (#1068)
arhtudormorar Mar 8, 2024
92b25b0
2.28.8-alpha.6
arhtudormorar Mar 8, 2024
470007a
fix reset state action
CiprianDraghici Mar 8, 2024
b032864
2.28.8-alpha.7
CiprianDraghici Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"linebreak-style": ["error", "unix"],
"quotes": ["error", "single"],
"semi": ["error", "always"],
"prefer-object-spread": 2,
"object-curly-newline": "off",
"arrow-body-style": "off",
"react/jsx-props-no-spreading": "off",
Expand Down
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,51 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- [Fixed types and file names](https://github.com/multiversx/mx-sdk-dapp/pull/1068)
- [Add support for the new cross window functionality in web wallet](https://github.com/multiversx/mx-sdk-dapp/pull/1067)
- [Update WalletConnect package and functionality](https://github.com/multiversx/mx-sdk-dapp/pull/1064)
- [Fixed sign step signing and labels](https://github.com/multiversx/mx-sdk-dapp/pull/1060)
- [Fixed signing multiple transactions with guarded ledger](https://github.com/multiversx/mx-sdk-dapp/pull/1059)
- [Added getHasNativeAuth in order to see if nativeAuth has been configured on development mode](https://github.com/multiversx/mx-sdk-dapp/pull/1051)
- [Added support for nativeAuth impersonat](https://github.com/multiversx/mx-sdk-dapp/pull/1049)
- [Updated WalletConnectV2 account provider to be updated on new or existing session](https://github.com/multiversx/mx-sdk-dapp/pull/1050)

## [[v2.28.8]](https://github.com/multiversx/mx-sdk-dapp/pull/1062)] - 2024-03-07

- [Fixed base64 utils conversion](https://github.com/multiversx/mx-sdk-dapp/pull/1061)

## [[v2.28.7]](https://github.com/multiversx/mx-sdk-dapp/pull/1048)] - 2024-02-13

- [Updated AddressRow data-testids](https://github.com/multiversx/mx-sdk-dapp/pull/1047)

## [[v2.28.6]](https://github.com/multiversx/mx-sdk-dapp/pull/1044)] - 2024-02-08

- [Added option to access URL search param from application load time in `useParseSignedTransactions`](https://github.com/multiversx/mx-sdk-dapp/pull/1042)
- [Fixed wallet connect breaks login with other providers](https://github.com/multiversx/mx-sdk-dapp/pull/1043)
- [Fixed possibly undefined payload on custom toasts](https://github.com/multiversx/mx-sdk-dapp/pull/1036)

## [[v2.28.5]](https://github.com/multiversx/mx-sdk-dapp/pull/1036)] - 2024-02-01

- [Fixed logout with web wallet infinite loop](https://github.com/multiversx/mx-sdk-dapp/pull/1036)

## [[v2.28.4]](https://github.com/multiversx/mx-sdk-dapp/pull/1035)] - 2024-02-01

- [Reverted setting walletconnectV2 `accountProvider` on init](https://github.com/multiversx/mx-sdk-dapp/pull/1036)
- [Fixed setting `loginToken` in `nativeAuthService` losing previous state](https://github.com/multiversx/mx-sdk-dapp/pull/1034)
- [Fixed setting walletconnectV2 `accountProvider` on init](https://github.com/multiversx/mx-sdk-dapp/pull/1033)

## [[v2.28.3]](https://github.com/multiversx/mx-sdk-dapp/pull/1032)] - 2024-01-30

- [Added transaction toast wrapper id](https://github.com/multiversx/mx-sdk-dapp/pull/1031)

## [[v2.28.2]](https://github.com/multiversx/mx-sdk-dapp/pull/1030)] - 2024-01-26

- [Added support for `checkIsValidSender` with array option](https://github.com/multiversx/mx-sdk-dapp/pull/1029)

## [[v2.28.1]](https://github.com/multiversx/mx-sdk-dapp/pull/1028)] - 2024-01-25
- [Added support for Web Wallet multisig token login](https://github.com/multiversx/mx-sdk-dapp/pull/1027)

- [Added support for Web Wallet multisig token login](https://github.com/multiversx/mx-sdk-dapp/pull/1027)
- [Changed postMessage payload from string to plain object](https://github.com/multiversx/mx-sdk-dapp/pull/1025)

## [[v2.28.0]](https://github.com/multiversx/mx-sdk-dapp/pull/1022)] - 2024-01-11

Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,12 @@ The sdk-dapp library exposes bundles for both CommonJS and ESModules, however, i
moduleNameMapper: {
'@multiversx/sdk-dapp/(.*)':
'<rootDir>/node_modules/@multiversx/sdk-dapp/__commonjs/$1.js'
}
},
```

You may need in your setupJest.js file do:
```javascript
import 'isomorphic-fetch';
```

# sdk-dapp exports
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-dapp",
"version": "2.28.8",
"version": "2.28.8-alpha.7",
"description": "A library to hold the main logic for a dapp on the MultiversX blockchain",
"author": "MultiversX",
"license": "GPL-3.0-or-later",
Expand Down Expand Up @@ -83,6 +83,7 @@
"history": "5.3.0",
"husky": "8.0.1",
"identity-obj-proxy": "3.0.0",
"isomorphic-fetch": "3.0.0",
"jest": "28.1.1",
"jest-environment-jsdom": "28.1.3",
"jest-mock": "29.3.1",
Expand Down Expand Up @@ -142,14 +143,15 @@
"**/*.d.ts"
],
"dependencies": {
"@multiversx/sdk-core": "12.18.0",
"@lifeomic/axios-fetch": "3.0.1",
"@multiversx/sdk-core": "13.0.0-alpha.2",
"@multiversx/sdk-extension-provider": "3.0.0",
"@multiversx/sdk-hw-provider": "6.4.0",
"@multiversx/sdk-native-auth-client": "1.0.7",
"@multiversx/sdk-opera-provider": "1.0.0-alpha.1",
"@multiversx/sdk-wallet": "4.2.0",
"@multiversx/sdk-wallet-connect-provider": "4.1.0",
"@multiversx/sdk-web-wallet-cross-window-provider": "0.0.14",
"@multiversx/sdk-wallet-connect-provider": "4.1.1",
"@multiversx/sdk-web-wallet-cross-window-provider": "0.0.24",
"@multiversx/sdk-web-wallet-provider": "3.2.1",
"@reduxjs/toolkit": "1.8.2",
"axios": "1.6.5",
Expand Down
112 changes: 112 additions & 0 deletions src/UI/Balance/Balance.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import React from 'react';
import classNames from 'classnames';

import MultiversXSymbol from 'assets/icons/mvx-icon-simple.svg';
import { withStyles } from 'hocs/withStyles';
import { WithClassnameType } from 'UI/types';

import { WithStylesImportType } from '../../hocs/useStyles';

interface BalancePropsType extends WithClassnameType, WithStylesImportType {
amount: string;
addEqualSign?: boolean;
displayAsUsd?: boolean;
egldIcon?: boolean;
showTokenLabel?: boolean;
tokenLabel?: string;
showTokenLabelSup?: boolean;
}

export const BalanceComponent = ({
amount,
displayAsUsd,
addEqualSign,
egldIcon,
className,
showTokenLabel = true,
styles,
tokenLabel,
showTokenLabelSup,
'data-testid': dataTestId
}: BalancePropsType) => {
const [mainBalance, decimalBalance] = amount.split('.');
const processedMainBalance =
displayAsUsd && mainBalance.indexOf('$') < 0
? `$${mainBalance}`
: mainBalance;

const getBalancePayload = () => {
const balancePayload: Record<string, string> = { processedMainBalance };

if (addEqualSign && displayAsUsd) {
balancePayload.approximation = '≈';
}

if (decimalBalance) {
balancePayload.decimalBalance = `.${decimalBalance}`;
}

if (!displayAsUsd && showTokenLabel) {
balancePayload.tokenLabel = ` ${tokenLabel}`;
}

return balancePayload;
};

const balancePayload = getBalancePayload();
const dataValues = [
balancePayload.approximation,
balancePayload.processedMainBalance,
balancePayload.decimalBalance,
balancePayload.tokenLabel
];

const dataBalanceValue = dataValues.reduce(
(totalDataValue, dataValueItem) =>
dataValueItem ? totalDataValue.concat(dataValueItem) : totalDataValue,
''
);

return (
<div
className={classNames(styles?.balance, className)}
data-testid={dataTestId}
data-value={dataBalanceValue}
>
{egldIcon && !displayAsUsd && (
<MultiversXSymbol className={styles?.balanceSymbol} />
)}

{balancePayload.approximation && (
<span className={styles?.balanceApproximation}>
{balancePayload.approximation}
</span>
)}

{balancePayload.processedMainBalance && (
<span className={styles?.balanceMain}>{processedMainBalance}</span>
)}

{balancePayload.decimalBalance && (
<span className={styles?.balanceDecimals}>
{balancePayload.decimalBalance}
</span>
)}

{balancePayload.tokenLabel && (
<sup
className={classNames(styles?.balanceSuffix, {
[styles?.balanceSuffixSup]: showTokenLabelSup
})}
>
{balancePayload.tokenLabel}
</sup>
)}
</div>
);
};

export const Balance = withStyles(BalanceComponent, {
ssrStyles: () => import('UI/Balance/balanceStyles.scss'),
clientStyles: () => require('UI/Balance/balanceStyles.scss').default
});
38 changes: 38 additions & 0 deletions src/UI/Balance/balanceStyles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.balance {
display: flex;
align-items: center;
line-height: 1;
gap: 4px;

.balanceApproximation {
opacity: 0.75;
}

.balanceSymbol {
width: auto;
height: 0.666em;
position: relative;
top: 0.05em;

path {
fill: currentColor;
}
}

.balanceDecimals {
opacity: 0.75;
margin-left: -4px;
}

.balanceSuffix {
opacity: 0.75;

&.balanceSuffixSup {
font-size: 66%;
position: relative;
top: -0.125em;
vertical-align: unset;
white-space: nowrap;
}
}
}
1 change: 1 addition & 0 deletions src/UI/Balance/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Balance';
6 changes: 5 additions & 1 deletion src/UI/SignTransactionsModals/SignTransactionsModals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useGetLoginInfo } from 'hooks';
import { LoginMethodsEnum } from 'types';

import { ConfirmationScreen, DeviceConfirmationScreen } from './components';
import { SignWithCrossWindowWalletModal } from './SignWithCrossWindowWalletModal';
import { SignWithExtensionModal } from './SignWithExtensionModal';
import { SignWithExtraModal } from './SignWithExtraModal';
import { SignWithLedgerModal } from './SignWithLedgerModal';
Expand Down Expand Up @@ -36,6 +37,8 @@ export const SignTransactionsModals = ({
CustomConfirmScreens?.WalletConnect ?? SignWithWalletConnectModal,
Extension: CustomConfirmScreens?.Extension ?? SignWithExtensionModal,
Opera: CustomConfirmScreens?.Opera ?? SignWithOperaModal,
CrossWindow:
CustomConfirmScreens?.CrossWindow ?? SignWithCrossWindowWalletModal,
// The purpose of having this is to have a consistent flow of transaction signing.
// The logic for redirecting to the web wallet is placed in the ConfirmationScreen component,
// so we have to render that component when we are logged in with the web wallet provider
Expand All @@ -60,7 +63,6 @@ export const SignTransactionsModals = ({
},
[verifyReceiverScam, className]
);

switch (loginMethod) {
case LoginMethodsEnum.ledger:
return renderScreen({ Screen: ConfirmScreens.Ledger, isDevice: true });
Expand All @@ -70,6 +72,8 @@ export const SignTransactionsModals = ({
return renderScreen({ Screen: ConfirmScreens.Extension });
case LoginMethodsEnum.opera:
return renderScreen({ Screen: ConfirmScreens.Opera });
case LoginMethodsEnum.crossWindow:
return renderScreen({ Screen: ConfirmScreens.CrossWindow });
case LoginMethodsEnum.wallet:
return renderScreen({ Screen: ConfirmScreens.Wallet });
case LoginMethodsEnum.extra:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';

import { useSelector } from 'reduxStore/DappProviderContext';
import { networkSelector } from 'reduxStore/selectors';
import { SignModalPropsType } from 'types';
import {
SignWaitingScreenModal,
SignWaitingScreenModalPropsType
} from '../components';

export const SignWithCrossWindowWalletModal = (props: SignModalPropsType) => {
const { walletAddress } = useSelector(networkSelector);

const description = props.error
? props.error
: props.transactions?.length > 1
? 'Check your MultiversX Wallet to sign the transactions'
: 'Check your MultiversX Wallet to sign the transaction';

const waitingScreenProps: SignWaitingScreenModalPropsType = {
...props,
description,
title: `Confirm on ${walletAddress}`
};

return <SignWaitingScreenModal {...waitingScreenProps} />;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './SignWithCrossWindowWalletModal';
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.extension-modal {
color: inherit;
}

.modal-container {
color: inherit;
}

.extension {
color: inherit;
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ const SignStepComponent = (props: SignStepType & WithStylesImportType) => {

const signLastTransaction = isLastTransaction && !waitingForDevice;

const onSubmit = () => {
onSignTransaction();
const onSubmit = async () => {
await onSignTransaction();
if (signLastTransaction && GuardianScreen) {
return setShowGuardianScreen(true);
}
Expand Down
Loading
Loading