diff --git a/README.md b/README.md index f545366d5..6b58aa6aa 100755 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ --- +## Integrate Casper Wallet Into Your App + +The recommended way of integrating Casper Wallet into your app is through [CSPR.click](https://CSPR.click), which provides a combined integration of major wallets in the Casper ecosystem, all at once, without the burden of maintaining multiple integrations at the same time. Please head over to [the CSPR.click documentation](https://docs.cspr.click) to start. + ## Testing Casper Wallet integration on **Casper Wallet Playground** *Casper Wallet Playground is a React webapp created as a developer tool to help test integration with various features available in Casper Wallet.* diff --git a/package.json b/package.json index 07905a380..0ce54135f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Casper Wallet", "description": "Securely manage your CSPR tokens and interact with dapps with the self-custody wallet for the Casper blockchain.", - "version": "1.6.1", + "version": "1.6.2", "author": "MAKE LLC", "scripts": { "devtools:redux": "redux-devtools --hostname=localhost", diff --git a/src/apps/popup/pages/home/components/tokens-list/utils.ts b/src/apps/popup/pages/home/components/tokens-list/utils.ts index c7beb6cf7..61f7aa679 100644 --- a/src/apps/popup/pages/home/components/tokens-list/utils.ts +++ b/src/apps/popup/pages/home/components/tokens-list/utils.ts @@ -32,8 +32,8 @@ export const formatErc20TokenBalance = ( name: token.contract_name, balance: token.balance, amount: erc20Amount, - symbol: token.metadata.symbol, - decimals: token.metadata.decimals, + symbol: token.metadata?.symbol || '', + decimals: token.metadata?.decimals, amountFiat: null, icon: token.icon_url || 'assets/icons/erc20-avatar.svg' }; diff --git a/src/background/index.ts b/src/background/index.ts index 2c16cc549..c724a0560 100644 --- a/src/background/index.ts +++ b/src/background/index.ts @@ -59,10 +59,7 @@ import { MapExtendedDeploy, MapPaginatedExtendedDeploys } from '@libs/services/account-activity-service'; -import { - fetchContractPackage, - fetchErc20Tokens -} from '@libs/services/erc20-service'; +import { fetchErc20Tokens } from '@libs/services/erc20-service'; import { openWindow } from './open-window'; import { @@ -102,7 +99,7 @@ import { } from './redux/settings/actions'; import { activeOriginChanged } from './redux/active-origin/actions'; import { selectApiConfigBasedOnActiveNetwork } from './redux/settings/selectors'; -import { getUrlOrigin, hasHttpPrefix, notEmpty } from '@src/utils'; +import { getUrlOrigin, hasHttpPrefix } from '@src/utils'; import { CannotGetActiveAccountError, CannotGetSenderOriginError @@ -642,28 +639,11 @@ browser.runtime.onMessage.addListener( }); if (tokensList) { - const erc20Tokens = await Promise.allSettled( - tokensList?.map(token => - fetchContractPackage({ - casperApiUrl, - contractPackageHash: token.contract_package_hash - }).then(contractPackage => ({ - ...contractPackage, - balance: token.balance, - contractHash: token.latest_contract?.contract_hash - })) - ) - ).then(results => - results - .map(result => { - if (result.status === 'fulfilled') { - return result.value; - } else { - return null; - } - }) - .filter(notEmpty) - ); + const erc20Tokens = tokensList.map(token => ({ + balance: token.balance, + contractHash: token.latest_contract?.contract_hash, + ...(token?.contract_package ?? {}) + })); return sendResponse( serviceMessage.fetchErc20TokensResponse(erc20Tokens) diff --git a/src/libs/services/erc20-service/constants.ts b/src/libs/services/erc20-service/constants.ts index 27e20d8ac..44b5ee417 100644 --- a/src/libs/services/erc20-service/constants.ts +++ b/src/libs/services/erc20-service/constants.ts @@ -1,5 +1,5 @@ export const getErc20TokensUrl = (casperApiUrl: string, accountHash: string) => - `${casperApiUrl}/accounts/${accountHash}/erc20-tokens?fields=latest_contract`; + `${casperApiUrl}/accounts/${accountHash}/erc20-tokens?fields=latest_contract,contract_package`; export const getContractPackageUrl = ( casperApiUrl: string, diff --git a/src/libs/services/erc20-service/types.ts b/src/libs/services/erc20-service/types.ts index 9ffad3549..3cdce250c 100644 --- a/src/libs/services/erc20-service/types.ts +++ b/src/libs/services/erc20-service/types.ts @@ -12,6 +12,7 @@ export interface Erc20Token { protocol_version: string; timestamp: string; }; + contract_package: ContractPackage; } export interface ContractPackage { diff --git a/src/libs/ui/components/token-plate/token-plate.tsx b/src/libs/ui/components/token-plate/token-plate.tsx index 2942a4cad..0cb1d2605 100644 --- a/src/libs/ui/components/token-plate/token-plate.tsx +++ b/src/libs/ui/components/token-plate/token-plate.tsx @@ -79,7 +79,7 @@ export const TokenPlate = ({ type="bodyHash" color="contentSecondary" ellipsis={!!(token?.symbol && token.symbol.length > 6)} - loading={!token?.symbol} + loading={!token?.symbol && token?.symbol !== ''} > {token?.symbol} diff --git a/xcode-project/Casper Wallet/Casper Wallet.xcodeproj/project.pbxproj b/xcode-project/Casper Wallet/Casper Wallet.xcodeproj/project.pbxproj index 17d15efa9..30570fdf1 100644 --- a/xcode-project/Casper Wallet/Casper Wallet.xcodeproj/project.pbxproj +++ b/xcode-project/Casper Wallet/Casper Wallet.xcodeproj/project.pbxproj @@ -564,7 +564,7 @@ CODE_SIGN_ENTITLEMENTS = "Casper Wallet/Casper Wallet.entitlements"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 30; + CURRENT_PROJECT_VERSION = 32; ENABLE_HARDENED_RUNTIME = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "Casper Wallet/Info.plist"; @@ -578,7 +578,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; OTHER_LDFLAGS = ( "-framework", SafariServices, @@ -601,7 +601,7 @@ CODE_SIGN_ENTITLEMENTS = "Casper Wallet/Casper Wallet.entitlements"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 30; + CURRENT_PROJECT_VERSION = 32; ENABLE_HARDENED_RUNTIME = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "Casper Wallet/Info.plist"; @@ -615,7 +615,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; OTHER_LDFLAGS = ( "-framework", SafariServices,