Skip to content

Commit

Permalink
Release/1.14.0 (#1118)
Browse files Browse the repository at this point in the history
* New tx sign

* Release 1.13.0 version

* Migrate to [email protected] version

* Update casper js sdk and casper wallet core versions

* Update PEM files parsing logic

* Update secretKey validation

* Configure proxy headers

* Make createAsymmetricKeys sync and returned secretKey nullable

* Make signing sync

* Update Deploy.toJSON method

* Use contractPackageHash for CEP-18 transfers

* Fix keys issue and refactor

* Update casper-js-sdk and @bringweb3/chrome-extension-kit

* Add error handling for incorrect pem file

* Update casper-wallet-core and remove @make-software/ces-js-parser

* Update safari's bundled files

* Fix signDeploy and signMessage naming and tests

* Update casper-js-sdk and casper-wallet-core to latest versions
  • Loading branch information
Comp0te authored Jan 24, 2025
1 parent eb5b282 commit c67572c
Show file tree
Hide file tree
Showing 56 changed files with 1,064 additions and 1,102 deletions.
529 changes: 248 additions & 281 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -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.12.0",
"version": "1.14.0",
"author": "MAKE LLC",
"scripts": {
"devtools:redux": "redux-devtools --hostname=localhost",
Expand Down Expand Up @@ -52,7 +52,7 @@
"styled-components": "^5"
},
"dependencies": {
"@bringweb3/chrome-extension-kit": "^1.2.4",
"@bringweb3/chrome-extension-kit": "^1.2.11",
"@formatjs/intl": "2.10.4",
"@hookform/resolvers": "2.9.10",
"@lapo/asn1js": "1.2.4",
Expand All @@ -61,19 +61,17 @@
"@ledgerhq/hw-transport-webhid": "^6.28.6",
"@ledgerhq/hw-transport-webusb": "^6.28.6",
"@lottiefiles/react-lottie-player": "3.5.3",
"@make-software/ces-js-parser": "1.3.2",
"@noble/ciphers": "^0.3.0",
"@scure/bip32": "1.3.2",
"@scure/bip39": "1.2.1",
"@tanstack/react-query": "^5.52.3",
"@types/argon2-browser": "1.18.1",
"@types/webextension-polyfill": "0.9.2",
"@zondax/ledger-casper": "^2.6.1",
"@zondax/ledger-casper": "^2.6.3",
"base64-loader": "1.0.0",
"big.js": "^6.2.1",
"casper-cep18-js-client": "1.0.2",
"casper-js-sdk": "2.15.4",
"casper-wallet-core": "git+ssh://[email protected]:make-software/casper-wallet-core.git#v0.9.7",
"casper-js-sdk": "5.0.5-beta2",
"casper-wallet-core": "git+ssh://[email protected]:make-software/casper-wallet-core.git#v1.0.0",
"date-fns": "^2.30.0",
"dotenv-webpack": "^8.1.0",
"i18next": "^23.11.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_all.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
HASH=$(git rev-parse --short HEAD)

npm run build:chrome && npm run build:firefox && cd ./build && zip -r casper-wallet-1.12.0#$HASH.zip ./* && npm run build:src
npm run build:chrome && npm run build:firefox && cd ./build && zip -r casper-wallet-1.14.0#$HASH.zip ./* && npm run build:src
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isError } from 'casper-wallet-core';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';

Expand Down Expand Up @@ -50,25 +51,37 @@ export function useSecretKeyFileReader({
const fileContents = reader.result as string;

const fileValidationError = isFileValid(fileContents);

if (fileValidationError) {
return onFailure(fileValidationError.message);
}

const { publicKeyHex, secretKeyBase64 } =
parseSecretKeyString(fileContents);
try {
const { publicKeyHex, secretKeyBase64 } =
parseSecretKeyString(fileContents);

const secretKeyError = await doesSecretKeyExist(secretKeyBase64);
if (secretKeyError) {
return onFailure(secretKeyError.message);
}
const secretKeyError = await doesSecretKeyExist(secretKeyBase64);

if (secretKeyError) {
return onFailure(secretKeyError.message);
}

return onSuccess({
imported: true,
name: name.trim(),
publicKey: publicKeyHex,
secretKey: secretKeyBase64,
hidden: false
});
return onSuccess({
imported: true,
name: name.trim(),
publicKey: publicKeyHex,
secretKey: secretKeyBase64,
hidden: false
});
} catch (e) {
return onFailure(
isError(e)
? e.message
: t(
'A private key was not detected. Try importing a different file.'
)
);
}
};
},
[t, onSuccess, onFailure]
Expand Down
19 changes: 11 additions & 8 deletions src/apps/popup/pages/download-account-keys/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Trans, useTranslation } from 'react-i18next';
import { PasswordProtectionPage } from '@popup/pages/password-protection-page';
import { RouterPath, useTypedNavigate } from '@popup/router';

import { createAsymmetricKey } from '@libs/crypto/create-asymmetric-key';
import { createAsymmetricKeys } from '@libs/crypto/create-asymmetric-key';
import {
FooterButtonsContainer,
HeaderPopup,
Expand Down Expand Up @@ -43,19 +43,22 @@ export const DownloadAccountKeysPage = () => {
);
}

const downloadKeys = () => {
const downloadKeys = async () => {
const zip = new JSZip();

selectedAccounts.forEach(account => {
const asymmetricKey = createAsymmetricKey(
for (const account of selectedAccounts) {
const asymmetricKey = createAsymmetricKeys(
account.publicKey,
account.secretKey
);
const file = asymmetricKey.exportPrivateKeyInPem();
zip.file(`${account.name}_secret_key.pem`, file);
});

zip.generateAsync({ type: 'blob' }).then(function (content) {
if (asymmetricKey.secretKey) {
const file = asymmetricKey.secretKey.toPem();
zip.file(`${account.name}_secret_key.pem`, file);
}
}

await zip.generateAsync({ type: 'blob' }).then(function (content) {
downloadFile(new Blob([content]), 'casper-wallet-secret_keys.zip');
});

Expand Down
4 changes: 2 additions & 2 deletions src/apps/popup/pages/home/components/tokens-list/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export const formatCep18Tokens = (
cep18Tokens: TokenDto[] | undefined
): TokenType[] | undefined => {
return cep18Tokens
?.map(token => ({
?.map<TokenType>(token => ({
id: token.contractPackageHash,
contractHash: token.contractHash,
contractPackageHash: token.contractPackageHash,
name: token.name,
balance: token.balance,
amount: token.formattedDecimalBalance,
Expand Down
10 changes: 5 additions & 5 deletions src/apps/popup/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { HomePageTabName, NetworkSetting } from '@src/constants';
import { RouterPath, useTypedLocation, useTypedNavigate } from '@popup/router';

import {
selectActiveNetworkSetting,
selectShowCSPRNamePromotion,
selectActiveNetworkSetting, // selectShowCSPRNamePromotion,
selectVaultActiveAccount
} from '@background/redux/root-selector';

Expand All @@ -29,8 +28,8 @@ import {
Tile,
Typography
} from '@libs/ui/components';
import { CsprNameBanner } from '@libs/ui/components/cspr-name-banner/cspr-name-banner';

// import { CsprNameBanner } from '@libs/ui/components/cspr-name-banner/cspr-name-banner';
import { AccountBalance } from './components/account-balance';
import { DeploysList } from './components/deploys-list';
import { MoreButtonsModal } from './components/more-buttons-modal';
Expand Down Expand Up @@ -60,7 +59,7 @@ export function HomePageContent() {

const network = useSelector(selectActiveNetworkSetting);
const activeAccount = useSelector(selectVaultActiveAccount);
const showCSPRNamePromotion = useSelector(selectShowCSPRNamePromotion);
// const showCSPRNamePromotion = useSelector(selectShowCSPRNamePromotion);

useEffect(() => {
if (!state?.activeTabId) {
Expand All @@ -70,9 +69,10 @@ export function HomePageContent() {
}
}, [state?.activeTabId]);

// TODO CSPR.name
return (
<ContentContainer>
{showCSPRNamePromotion && <CsprNameBanner />}
{/*{showCSPRNamePromotion && <CsprNameBanner />}*/}
{activeAccount && (
<Tile>
<Container>
Expand Down
24 changes: 12 additions & 12 deletions src/apps/popup/pages/navigation-menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,18 @@ export function NavigationMenuPageContent() {
}
}
]
: []),
{
id: 6,
title: t('CSPR.name'),
description: t('Get names for your accounts'),
iconPath: 'assets/icons/cspr-name.svg',
// TODO: add url to CSPR.name
href: '',
currentValue: t('New'),
disabled: false,
isCsprName: true
}
: [])
// {
// id: 6,
// title: t('CSPR.name'),
// description: t('Get names for your accounts'),
// iconPath: 'assets/icons/cspr-name.svg',
// // TODO: add url to CSPR.name
// href: '',
// currentValue: t('New'),
// disabled: false,
// isCsprName: true
// }
// {
// id: 7,
// title: t('Add watch account'),
Expand Down
2 changes: 1 addition & 1 deletion src/apps/popup/pages/nft-details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const NftDetailsPage = () => {
/>
<HeaderViewInExplorer
nftTokenId={tokenId}
contractHash={contractPackageHash}
contractPackageHash={contractPackageHash}
/>
</>
)}
Expand Down
15 changes: 5 additions & 10 deletions src/apps/popup/pages/sign-with-ledger-in-new-window/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeployUtil } from 'casper-js-sdk';
import { Deploy } from 'casper-js-sdk';
import React, { useState } from 'react';
import { useSelector } from 'react-redux';

Expand All @@ -14,7 +14,7 @@ import { selectVaultActiveAccount } from '@background/redux/vault/selectors';

import { useLedger } from '@hooks/use-ledger';

import { createAsymmetricKey } from '@libs/crypto/create-asymmetric-key';
import { createAsymmetricKeys } from '@libs/crypto/create-asymmetric-key';
import { sendSignDeploy, signDeploy } from '@libs/services/deployer-service';
import { LedgerEventStatus } from '@libs/services/ledger';
import { LedgerConnectionView } from '@libs/ui/components';
Expand All @@ -33,19 +33,14 @@ export const SignWithLedgerInNewWindowPage = () => {
return;
}

const KEYS = createAsymmetricKey(
const KEYS = createAsymmetricKeys(
activeAccount.publicKey,
activeAccount.secretKey
);

const resp = DeployUtil.deployFromJson(JSON.parse(deploy));
const resp = Deploy.fromJSON(deploy);

if (!resp.ok) {
console.log('-------- json parse error', resp.val);
return;
}

const signedDeploy = await signDeploy(resp.val, [KEYS], activeAccount);
const signedDeploy = await signDeploy(resp, KEYS, activeAccount);

sendSignDeploy(signedDeploy, nodeUrl)
.then(resp => {
Expand Down
3 changes: 1 addition & 2 deletions src/apps/popup/pages/stakes/components/validator-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ export const ValidatorList = ({
const logo = validator?.svgLogo || validator?.imgLogo;

return (
<Container style={style}>
<Container style={style} key={key}>
<ValidatorPlate
key={key}
publicKey={validator?.publicKey}
fee={validator.fee}
name={validator?.name}
Expand Down
57 changes: 25 additions & 32 deletions src/apps/popup/pages/stakes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeployUtil } from 'casper-js-sdk';
import { Deploy, makeAuctionManagerDeploy } from 'casper-js-sdk';
import { formatNumber } from 'casper-wallet-core';
import { ValidatorDto } from 'casper-wallet-core/src/data/dto/validators';
import React, { useState } from 'react';
Expand All @@ -9,7 +9,8 @@ import styled from 'styled-components';
import {
AuctionManagerEntryPoint,
STAKE_COST_MOTES,
StakeSteps
StakeSteps,
networkNameToSdkNetworkNameMap
} from '@src/constants';

import { AmountStep } from '@popup/pages/stakes/amount-step';
Expand Down Expand Up @@ -41,7 +42,7 @@ import {
import { useLedger } from '@hooks/use-ledger';
import { useSubmitButton } from '@hooks/use-submit-button';

import { createAsymmetricKey } from '@libs/crypto/create-asymmetric-key';
import { createAsymmetricKeys } from '@libs/crypto/create-asymmetric-key';
import {
AlignedFlexRow,
CenteredFlexRow,
Expand All @@ -57,11 +58,7 @@ import {
createErrorLocationState
} from '@libs/layout';
import { useFetchWalletBalance } from '@libs/services/balance-service';
import {
makeAuctionManagerDeploy,
sendSignDeploy,
signDeploy
} from '@libs/services/deployer-service';
import { sendSignDeploy, signDeploy } from '@libs/services/deployer-service';
import {
Button,
HomePageTabsId,
Expand Down Expand Up @@ -106,7 +103,7 @@ export const StakesPage = () => {
const isActiveAccountFromLedger = useSelector(
selectIsActiveAccountFromLedger
);
const { networkName, nodeUrl, auctionManagerContractHash } = useSelector(
const { networkName, nodeUrl } = useSelector(
selectApiConfigBasedOnActiveNetwork
);
const ratedInStore = useSelector(selectRatedInStore);
Expand Down Expand Up @@ -157,23 +154,21 @@ export const StakesPage = () => {
if (activeAccount) {
const motesAmount = CSPRtoMotes(inputAmountCSPR);

const KEYS = createAsymmetricKey(
const KEYS = createAsymmetricKeys(
activeAccount.publicKey,
activeAccount.secretKey
);

const deploy = await makeAuctionManagerDeploy(
stakeType,
activeAccount.publicKey,
validatorPublicKey,
newValidatorPublicKey || null,
motesAmount,
networkName,
auctionManagerContractHash,
nodeUrl
);
const deploy = makeAuctionManagerDeploy({
amount: motesAmount,
chainName: networkNameToSdkNetworkNameMap[networkName],
contractEntryPoint: stakeType,
delegatorPublicKeyHex: activeAccount.publicKey,
newValidatorPublicKeyHex: newValidatorPublicKey,
validatorPublicKeyHex: validatorPublicKey
});

const signedDeploy = await signDeploy(deploy, [KEYS], activeAccount);
const signedDeploy = await signDeploy(deploy, KEYS, activeAccount);

sendSignDeploy(signedDeploy, nodeUrl)
.then(resp => {
Expand Down Expand Up @@ -227,19 +222,17 @@ export const StakesPage = () => {
if (activeAccount) {
const motesAmount = CSPRtoMotes(inputAmountCSPR);

const deploy = await makeAuctionManagerDeploy(
stakeType,
activeAccount.publicKey,
validatorPublicKey,
newValidatorPublicKey || null,
motesAmount,
networkName,
auctionManagerContractHash,
nodeUrl
);
const deploy = makeAuctionManagerDeploy({
amount: motesAmount,
chainName: networkNameToSdkNetworkNameMap[networkName],
contractEntryPoint: stakeType,
delegatorPublicKeyHex: activeAccount.publicKey,
newValidatorPublicKeyHex: newValidatorPublicKey,
validatorPublicKeyHex: validatorPublicKey
});

dispatchToMainStore(
ledgerDeployChanged(JSON.stringify(DeployUtil.deployToJson(deploy)))
ledgerDeployChanged(JSON.stringify(Deploy.toJSON(deploy)))
);
}
};
Expand Down
Loading

0 comments on commit c67572c

Please sign in to comment.