refactor: upgrade packages, p2

This commit is contained in:
kyranjamie
2023-06-30 15:11:31 +02:00
committed by kyranjamie
parent cb7da02fb4
commit 51b7da0a84
6 changed files with 683 additions and 348 deletions

View File

@@ -131,7 +131,7 @@
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"@fungible-systems/zone-file": "2.0.0",
"@hirosystems/token-metadata-api-client": "1.0.3",
"@hirosystems/token-metadata-api-client": "1.1.0",
"@ledgerhq/hw-transport-webusb": "6.27.16",
"@noble/hashes": "1.3.1",
"@noble/secp256k1": "2.0.0",
@@ -147,8 +147,8 @@
"@stacks/auth": "6.5.4",
"@stacks/blockchain-api-client": "6.3.4",
"@stacks/common": "6.5.2",
"@stacks/connect": "7.3.1",
"@stacks/connect-ui": "6.1.1",
"@stacks/connect": "7.2.1",
"@stacks/connect-ui": "6.0.0",
"@stacks/encryption": "6.5.4",
"@stacks/network": "6.5.4",
"@stacks/profile": "6.5.4",
@@ -168,7 +168,7 @@
"@tippyjs/react": "4.2.6",
"@typescript-eslint/eslint-plugin": "5.60.1",
"@vkontakte/vk-qr": "2.0.13",
"@zondax/ledger-stacks": "1.0.3",
"@zondax/ledger-stacks": "1.0.4",
"are-passive-events-supported": "1.1.1",
"argon2-browser": "1.18.0",
"assert": "2.0.0",
@@ -187,7 +187,7 @@
"downshift": "6.1.7",
"ecdsa-sig-formatter": "1.0.11",
"ecpair": "2.1.0",
"formik": "2.4.1",
"formik": "2.4.2",
"jotai": "2.2.1",
"jotai-redux": "0.2.1",
"jsontokens": "4.0.1",
@@ -213,6 +213,7 @@
"redux-persist": "6.0.0",
"rxjs": "7.8.1",
"ts-debounce": "4.0.0",
"url": "0.11.1",
"url-join": "5.0.0",
"use-events": "1.4.2",
"use-latest": "1.2.1",
@@ -224,9 +225,9 @@
},
"devDependencies": {
"@actions/core": "1.10.0",
"@babel/core": "7.21.8",
"@babel/preset-react": "7.18.6",
"@babel/preset-typescript": "7.21.5",
"@babel/core": "7.22.5",
"@babel/preset-react": "7.22.5",
"@babel/preset-typescript": "7.22.5",
"@btckit/types": "0.0.18",
"@emotion/babel-plugin": "11.11.0",
"@emotion/babel-preset-css-prop": "11.11.0",
@@ -253,7 +254,7 @@
"@types/html-webpack-plugin": "3.2.6",
"@types/jest": "29.2.6",
"@types/jest-dev-server": "5.0.0",
"@types/jsdom": "20.0.1",
"@types/jsdom": "21.1.1",
"@types/lodash.get": "4.4.7",
"@types/node": "20.3.2",
"@types/object-hash": "3.0.2",
@@ -261,7 +262,7 @@
"@types/promise-memoize": "1.2.1",
"@types/punycode": "2.1.0",
"@types/qrcode.react": "1.0.2",
"@types/react": "18.2.7",
"@types/react": "18.2.14",
"@types/react-dom": "18.2.6",
"@types/react-lottie": "1.2.6",
"@types/react-router-dom": "5.3.3",
@@ -288,9 +289,9 @@
"cross-env": "7.0.3",
"crypto-browserify": "3.12.0",
"deepmerge": "4.3.1",
"dependency-cruiser": "13.0.2",
"dependency-cruiser": "13.0.4",
"dotenv-webpack": "8.0.1",
"esbuild": "0.17.19",
"esbuild": "0.18.10",
"esbuild-loader": "3.0.1",
"eslint-plugin-deprecation": "1.4.1",
"eslint-plugin-react": "7.32.2",
@@ -302,7 +303,7 @@
"jest-chrome": "0.8.0",
"jest-circus": "29.3.1",
"jest-dev-server": "6.2.0",
"jsdom": "21.1.0",
"jsdom": "22.1.0",
"prettier": "2.8.8",
"process": "0.11.10",
"progress-bar-webpack-plugin": "2.1.0",
@@ -316,7 +317,7 @@
"ts-node": "10.9.1",
"ts-unused-exports": "7.0.3",
"tsconfig-paths-webpack-plugin": "4.0.1",
"typescript": "5.0.4",
"typescript": "5.1.6",
"vitest": "0.32.2",
"vm-browserify": "1.1.2",
"web-ext": "7.4.0",

View File

@@ -2,10 +2,9 @@ import { useCallback, useState } from 'react';
import { ProfileUpdatePayload } from '@stacks/connect';
import { createFetchFn } from '@stacks/network';
import { PublicPersonProfile } from '@stacks/profile';
import { PublicPersonProfile, PublicProfileBase } from '@stacks/profile';
import {
DEFAULT_PROFILE,
Profile as WalletSdkProfile,
fetchAccountProfileUrl,
fetchProfileFromUrl,
signAndUploadProfile,
@@ -44,7 +43,7 @@ function useUpdateProfileSoftwareWallet() {
appsMeta: profile.appsMeta,
};
await signAndUploadProfile({
profile: updatedProfile as unknown as WalletSdkProfile,
profile: updatedProfile as unknown as PublicProfileBase,
account,
gaiaHubUrl: gaiaUrl,
});

View File

@@ -1,15 +1,15 @@
import {
FtMetadataResponse,
NftMetadataResponse,
TokenNotFoundResponse,
NotFoundErrorResponse,
} from '@hirosystems/token-metadata-api-client';
export type FtAssetResponse = FtMetadataResponse | TokenNotFoundResponse;
export type NftAssetResponse = NftMetadataResponse | TokenNotFoundResponse;
export type FtAssetResponse = FtMetadataResponse | NotFoundErrorResponse;
export type NftAssetResponse = NftMetadataResponse | NotFoundErrorResponse;
function isAssetMetadataNotFoundResponse(
resp: FtAssetResponse | NftAssetResponse
): resp is TokenNotFoundResponse {
): resp is NotFoundErrorResponse {
return 'error' in resp;
}

View File

@@ -1,6 +1,6 @@
import { bytesToHex } from '@noble/hashes/utils';
import { createSelector } from '@reduxjs/toolkit';
import { HARDENED_OFFSET } from '@scure/bip32';
import { HARDENED_OFFSET, HDKey } from '@scure/bip32';
import {
AddressVersion,
createStacksPrivateKey,
@@ -29,39 +29,41 @@ import {
StacksAccount,
} from './stacks-account.models';
function initalizeStacksAccount(rootKeychain: HDKey, index: number) {
const stxPrivateKey = deriveStxPrivateKey({ rootNode: rootKeychain, index } as any);
const pubKey = getPublicKey(createStacksPrivateKey(stxPrivateKey));
const identitiesKeychain = rootKeychain.derive(DATA_DERIVATION_PATH);
const identityKeychain = identitiesKeychain.deriveChild(index + HARDENED_OFFSET);
if (!identityKeychain.privateKey) throw new Error('Must have private key to derive identities');
const dataPrivateKey = bytesToHex(identityKeychain.privateKey);
const appsKey = identityKeychain.deriveChild(0 + HARDENED_OFFSET).privateExtendedKey;
const salt = deriveStacksSalt(identitiesKeychain);
return {
index,
appsKey,
dataPrivateKey,
stxPrivateKey,
publicKey: pubKey,
salt,
mainnetAddress: publicKeyToAddress(AddressVersion.MainnetSingleSig, pubKey),
testnetAddress: publicKeyToAddress(AddressVersion.TestnetSingleSig, pubKey),
};
}
const selectStacksWalletState = createSelector(
selectRootKeychain,
selectStacksChain,
(keychain, chain) => {
if (!keychain) return;
const { highestAccountIndex, currentAccountIndex } = chain[defaultKeyId];
const accountsToRender = Math.max(highestAccountIndex, currentAccountIndex) + 1;
return createNullArrayOfLength(accountsToRender).map((_, index) => {
const stxPrivateKey = deriveStxPrivateKey({ rootNode: keychain, index });
const pubKey = getPublicKey(createStacksPrivateKey(stxPrivateKey));
const identitiesKeychain = keychain.derive(DATA_DERIVATION_PATH);
const identityKeychain = identitiesKeychain.deriveChild(index + HARDENED_OFFSET);
if (!identityKeychain.privateKey)
throw new Error('Must have private key to derive identities');
const dataPrivateKey = bytesToHex(identityKeychain.privateKey);
const appsKey = identityKeychain.deriveChild(0 + HARDENED_OFFSET).privateExtendedKey;
const salt = deriveStacksSalt(identitiesKeychain);
return {
index,
appsKey,
dataPrivateKey,
stxPrivateKey,
publicKey: pubKey,
salt,
mainnetAddress: publicKeyToAddress(AddressVersion.MainnetSingleSig, pubKey),
testnetAddress: publicKeyToAddress(AddressVersion.TestnetSingleSig, pubKey),
};
});
const numberOfAccountsToDerive = Math.max(highestAccountIndex, currentAccountIndex) + 1;
return createNullArrayOfLength(numberOfAccountsToDerive).map((_, index) =>
initalizeStacksAccount(keychain, index)
);
}
);

View File

@@ -14,9 +14,9 @@ export const selectDefaultWalletKey = createSelector(
state => state.keys[defaultKeyId]
);
export const selectRootKeychain = createSelector(selectDefaultWalletKey, state => {
if (!state) return null;
return mnemonicToRootNode(state);
export const selectRootKeychain = createSelector(selectDefaultWalletKey, key => {
if (!key) return null;
return mnemonicToRootNode(key);
});
export function useDefaultWalletSecretKey() {

925
yarn.lock

File diff suppressed because it is too large Load Diff