Skip to content

Commit c67572c

Browse files
authored
Release/1.14.0 (#1118)
* New tx sign * Release 1.13.0 version * Migrate to casper-js-sdk@5.0.0-rc8 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
1 parent eb5b282 commit c67572c

File tree

56 files changed

+1064
-1102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1064
-1102
lines changed

package-lock.json

Lines changed: 248 additions & 281 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Casper Wallet",
33
"description": "Securely manage your CSPR tokens and interact with dapps with the self-custody wallet for the Casper blockchain.",
4-
"version": "1.12.0",
4+
"version": "1.14.0",
55
"author": "MAKE LLC",
66
"scripts": {
77
"devtools:redux": "redux-devtools --hostname=localhost",
@@ -52,7 +52,7 @@
5252
"styled-components": "^5"
5353
},
5454
"dependencies": {
55-
"@bringweb3/chrome-extension-kit": "^1.2.4",
55+
"@bringweb3/chrome-extension-kit": "^1.2.11",
5656
"@formatjs/intl": "2.10.4",
5757
"@hookform/resolvers": "2.9.10",
5858
"@lapo/asn1js": "1.2.4",
@@ -61,19 +61,17 @@
6161
"@ledgerhq/hw-transport-webhid": "^6.28.6",
6262
"@ledgerhq/hw-transport-webusb": "^6.28.6",
6363
"@lottiefiles/react-lottie-player": "3.5.3",
64-
"@make-software/ces-js-parser": "1.3.2",
6564
"@noble/ciphers": "^0.3.0",
6665
"@scure/bip32": "1.3.2",
6766
"@scure/bip39": "1.2.1",
6867
"@tanstack/react-query": "^5.52.3",
6968
"@types/argon2-browser": "1.18.1",
7069
"@types/webextension-polyfill": "0.9.2",
71-
"@zondax/ledger-casper": "^2.6.1",
70+
"@zondax/ledger-casper": "^2.6.3",
7271
"base64-loader": "1.0.0",
7372
"big.js": "^6.2.1",
74-
"casper-cep18-js-client": "1.0.2",
75-
"casper-js-sdk": "2.15.4",
76-
"casper-wallet-core": "git+ssh://git@github.com:make-software/casper-wallet-core.git#v0.9.7",
73+
"casper-js-sdk": "5.0.5-beta2",
74+
"casper-wallet-core": "git+ssh://git@github.com:make-software/casper-wallet-core.git#v1.0.0",
7775
"date-fns": "^2.30.0",
7876
"dotenv-webpack": "^8.1.0",
7977
"i18next": "^23.11.0",

scripts/build_all.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
HASH=$(git rev-parse --short HEAD)
22

3-
npm run build:chrome && npm run build:firefox && cd ./build && zip -r casper-wallet-1.12.0#$HASH.zip ./* && npm run build:src
3+
npm run build:chrome && npm run build:firefox && cd ./build && zip -r casper-wallet-1.14.0#$HASH.zip ./* && npm run build:src

src/apps/import-account-with-file/pages/import-account-with-file-upload/hooks/use-secret-key-file-reader.ts

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isError } from 'casper-wallet-core';
12
import { useCallback } from 'react';
23
import { useTranslation } from 'react-i18next';
34

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

5253
const fileValidationError = isFileValid(fileContents);
54+
5355
if (fileValidationError) {
5456
return onFailure(fileValidationError.message);
5557
}
5658

57-
const { publicKeyHex, secretKeyBase64 } =
58-
parseSecretKeyString(fileContents);
59+
try {
60+
const { publicKeyHex, secretKeyBase64 } =
61+
parseSecretKeyString(fileContents);
5962

60-
const secretKeyError = await doesSecretKeyExist(secretKeyBase64);
61-
if (secretKeyError) {
62-
return onFailure(secretKeyError.message);
63-
}
63+
const secretKeyError = await doesSecretKeyExist(secretKeyBase64);
64+
65+
if (secretKeyError) {
66+
return onFailure(secretKeyError.message);
67+
}
6468

65-
return onSuccess({
66-
imported: true,
67-
name: name.trim(),
68-
publicKey: publicKeyHex,
69-
secretKey: secretKeyBase64,
70-
hidden: false
71-
});
69+
return onSuccess({
70+
imported: true,
71+
name: name.trim(),
72+
publicKey: publicKeyHex,
73+
secretKey: secretKeyBase64,
74+
hidden: false
75+
});
76+
} catch (e) {
77+
return onFailure(
78+
isError(e)
79+
? e.message
80+
: t(
81+
'A private key was not detected. Try importing a different file.'
82+
)
83+
);
84+
}
7285
};
7386
},
7487
[t, onSuccess, onFailure]

src/apps/popup/pages/download-account-keys/index.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Trans, useTranslation } from 'react-i18next';
55
import { PasswordProtectionPage } from '@popup/pages/password-protection-page';
66
import { RouterPath, useTypedNavigate } from '@popup/router';
77

8-
import { createAsymmetricKey } from '@libs/crypto/create-asymmetric-key';
8+
import { createAsymmetricKeys } from '@libs/crypto/create-asymmetric-key';
99
import {
1010
FooterButtonsContainer,
1111
HeaderPopup,
@@ -43,19 +43,22 @@ export const DownloadAccountKeysPage = () => {
4343
);
4444
}
4545

46-
const downloadKeys = () => {
46+
const downloadKeys = async () => {
4747
const zip = new JSZip();
4848

49-
selectedAccounts.forEach(account => {
50-
const asymmetricKey = createAsymmetricKey(
49+
for (const account of selectedAccounts) {
50+
const asymmetricKey = createAsymmetricKeys(
5151
account.publicKey,
5252
account.secretKey
5353
);
54-
const file = asymmetricKey.exportPrivateKeyInPem();
55-
zip.file(`${account.name}_secret_key.pem`, file);
56-
});
5754

58-
zip.generateAsync({ type: 'blob' }).then(function (content) {
55+
if (asymmetricKey.secretKey) {
56+
const file = asymmetricKey.secretKey.toPem();
57+
zip.file(`${account.name}_secret_key.pem`, file);
58+
}
59+
}
60+
61+
await zip.generateAsync({ type: 'blob' }).then(function (content) {
5962
downloadFile(new Blob([content]), 'casper-wallet-secret_keys.zip');
6063
});
6164

src/apps/popup/pages/home/components/tokens-list/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ export const formatCep18Tokens = (
66
cep18Tokens: TokenDto[] | undefined
77
): TokenType[] | undefined => {
88
return cep18Tokens
9-
?.map(token => ({
9+
?.map<TokenType>(token => ({
1010
id: token.contractPackageHash,
11-
contractHash: token.contractHash,
11+
contractPackageHash: token.contractPackageHash,
1212
name: token.name,
1313
balance: token.balance,
1414
amount: token.formattedDecimalBalance,

src/apps/popup/pages/home/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import { HomePageTabName, NetworkSetting } from '@src/constants';
88
import { RouterPath, useTypedLocation, useTypedNavigate } from '@popup/router';
99

1010
import {
11-
selectActiveNetworkSetting,
12-
selectShowCSPRNamePromotion,
11+
selectActiveNetworkSetting, // selectShowCSPRNamePromotion,
1312
selectVaultActiveAccount
1413
} from '@background/redux/root-selector';
1514

@@ -29,8 +28,8 @@ import {
2928
Tile,
3029
Typography
3130
} from '@libs/ui/components';
32-
import { CsprNameBanner } from '@libs/ui/components/cspr-name-banner/cspr-name-banner';
3331

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

6160
const network = useSelector(selectActiveNetworkSetting);
6261
const activeAccount = useSelector(selectVaultActiveAccount);
63-
const showCSPRNamePromotion = useSelector(selectShowCSPRNamePromotion);
62+
// const showCSPRNamePromotion = useSelector(selectShowCSPRNamePromotion);
6463

6564
useEffect(() => {
6665
if (!state?.activeTabId) {
@@ -70,9 +69,10 @@ export function HomePageContent() {
7069
}
7170
}, [state?.activeTabId]);
7271

72+
// TODO CSPR.name
7373
return (
7474
<ContentContainer>
75-
{showCSPRNamePromotion && <CsprNameBanner />}
75+
{/*{showCSPRNamePromotion && <CsprNameBanner />}*/}
7676
{activeAccount && (
7777
<Tile>
7878
<Container>

src/apps/popup/pages/navigation-menu/index.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,18 @@ export function NavigationMenuPageContent() {
197197
}
198198
}
199199
]
200-
: []),
201-
{
202-
id: 6,
203-
title: t('CSPR.name'),
204-
description: t('Get names for your accounts'),
205-
iconPath: 'assets/icons/cspr-name.svg',
206-
// TODO: add url to CSPR.name
207-
href: '',
208-
currentValue: t('New'),
209-
disabled: false,
210-
isCsprName: true
211-
}
200+
: [])
201+
// {
202+
// id: 6,
203+
// title: t('CSPR.name'),
204+
// description: t('Get names for your accounts'),
205+
// iconPath: 'assets/icons/cspr-name.svg',
206+
// // TODO: add url to CSPR.name
207+
// href: '',
208+
// currentValue: t('New'),
209+
// disabled: false,
210+
// isCsprName: true
211+
// }
212212
// {
213213
// id: 7,
214214
// title: t('Add watch account'),

src/apps/popup/pages/nft-details/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const NftDetailsPage = () => {
5555
/>
5656
<HeaderViewInExplorer
5757
nftTokenId={tokenId}
58-
contractHash={contractPackageHash}
58+
contractPackageHash={contractPackageHash}
5959
/>
6060
</>
6161
)}

src/apps/popup/pages/sign-with-ledger-in-new-window/index.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DeployUtil } from 'casper-js-sdk';
1+
import { Deploy } from 'casper-js-sdk';
22
import React, { useState } from 'react';
33
import { useSelector } from 'react-redux';
44

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

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

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

36-
const KEYS = createAsymmetricKey(
36+
const KEYS = createAsymmetricKeys(
3737
activeAccount.publicKey,
3838
activeAccount.secretKey
3939
);
4040

41-
const resp = DeployUtil.deployFromJson(JSON.parse(deploy));
41+
const resp = Deploy.fromJSON(deploy);
4242

43-
if (!resp.ok) {
44-
console.log('-------- json parse error', resp.val);
45-
return;
46-
}
47-
48-
const signedDeploy = await signDeploy(resp.val, [KEYS], activeAccount);
43+
const signedDeploy = await signDeploy(resp, KEYS, activeAccount);
4944

5045
sendSignDeploy(signedDeploy, nodeUrl)
5146
.then(resp => {

src/apps/popup/pages/stakes/components/validator-list.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ export const ValidatorList = ({
5151
const logo = validator?.svgLogo || validator?.imgLogo;
5252

5353
return (
54-
<Container style={style}>
54+
<Container style={style} key={key}>
5555
<ValidatorPlate
56-
key={key}
5756
publicKey={validator?.publicKey}
5857
fee={validator.fee}
5958
name={validator?.name}

src/apps/popup/pages/stakes/index.tsx

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DeployUtil } from 'casper-js-sdk';
1+
import { Deploy, makeAuctionManagerDeploy } from 'casper-js-sdk';
22
import { formatNumber } from 'casper-wallet-core';
33
import { ValidatorDto } from 'casper-wallet-core/src/data/dto/validators';
44
import React, { useState } from 'react';
@@ -9,7 +9,8 @@ import styled from 'styled-components';
99
import {
1010
AuctionManagerEntryPoint,
1111
STAKE_COST_MOTES,
12-
StakeSteps
12+
StakeSteps,
13+
networkNameToSdkNetworkNameMap
1314
} from '@src/constants';
1415

1516
import { AmountStep } from '@popup/pages/stakes/amount-step';
@@ -41,7 +42,7 @@ import {
4142
import { useLedger } from '@hooks/use-ledger';
4243
import { useSubmitButton } from '@hooks/use-submit-button';
4344

44-
import { createAsymmetricKey } from '@libs/crypto/create-asymmetric-key';
45+
import { createAsymmetricKeys } from '@libs/crypto/create-asymmetric-key';
4546
import {
4647
AlignedFlexRow,
4748
CenteredFlexRow,
@@ -57,11 +58,7 @@ import {
5758
createErrorLocationState
5859
} from '@libs/layout';
5960
import { useFetchWalletBalance } from '@libs/services/balance-service';
60-
import {
61-
makeAuctionManagerDeploy,
62-
sendSignDeploy,
63-
signDeploy
64-
} from '@libs/services/deployer-service';
61+
import { sendSignDeploy, signDeploy } from '@libs/services/deployer-service';
6562
import {
6663
Button,
6764
HomePageTabsId,
@@ -106,7 +103,7 @@ export const StakesPage = () => {
106103
const isActiveAccountFromLedger = useSelector(
107104
selectIsActiveAccountFromLedger
108105
);
109-
const { networkName, nodeUrl, auctionManagerContractHash } = useSelector(
106+
const { networkName, nodeUrl } = useSelector(
110107
selectApiConfigBasedOnActiveNetwork
111108
);
112109
const ratedInStore = useSelector(selectRatedInStore);
@@ -157,23 +154,21 @@ export const StakesPage = () => {
157154
if (activeAccount) {
158155
const motesAmount = CSPRtoMotes(inputAmountCSPR);
159156

160-
const KEYS = createAsymmetricKey(
157+
const KEYS = createAsymmetricKeys(
161158
activeAccount.publicKey,
162159
activeAccount.secretKey
163160
);
164161

165-
const deploy = await makeAuctionManagerDeploy(
166-
stakeType,
167-
activeAccount.publicKey,
168-
validatorPublicKey,
169-
newValidatorPublicKey || null,
170-
motesAmount,
171-
networkName,
172-
auctionManagerContractHash,
173-
nodeUrl
174-
);
162+
const deploy = makeAuctionManagerDeploy({
163+
amount: motesAmount,
164+
chainName: networkNameToSdkNetworkNameMap[networkName],
165+
contractEntryPoint: stakeType,
166+
delegatorPublicKeyHex: activeAccount.publicKey,
167+
newValidatorPublicKeyHex: newValidatorPublicKey,
168+
validatorPublicKeyHex: validatorPublicKey
169+
});
175170

176-
const signedDeploy = await signDeploy(deploy, [KEYS], activeAccount);
171+
const signedDeploy = await signDeploy(deploy, KEYS, activeAccount);
177172

178173
sendSignDeploy(signedDeploy, nodeUrl)
179174
.then(resp => {
@@ -227,19 +222,17 @@ export const StakesPage = () => {
227222
if (activeAccount) {
228223
const motesAmount = CSPRtoMotes(inputAmountCSPR);
229224

230-
const deploy = await makeAuctionManagerDeploy(
231-
stakeType,
232-
activeAccount.publicKey,
233-
validatorPublicKey,
234-
newValidatorPublicKey || null,
235-
motesAmount,
236-
networkName,
237-
auctionManagerContractHash,
238-
nodeUrl
239-
);
225+
const deploy = makeAuctionManagerDeploy({
226+
amount: motesAmount,
227+
chainName: networkNameToSdkNetworkNameMap[networkName],
228+
contractEntryPoint: stakeType,
229+
delegatorPublicKeyHex: activeAccount.publicKey,
230+
newValidatorPublicKeyHex: newValidatorPublicKey,
231+
validatorPublicKeyHex: validatorPublicKey
232+
});
240233

241234
dispatchToMainStore(
242-
ledgerDeployChanged(JSON.stringify(DeployUtil.deployToJson(deploy)))
235+
ledgerDeployChanged(JSON.stringify(Deploy.toJSON(deploy)))
243236
);
244237
}
245238
};

0 commit comments

Comments
 (0)