Skip to content

Commit 282a1f4

Browse files
pradelbeguene
authored andcommitted
chore: upgrade stacks wallet-sdk to 3.4.0
Add webpack aliases to esm instead of polyfill closes #2283 closes #2282
1 parent a387ef1 commit 282a1f4

File tree

8 files changed

+1518
-1621
lines changed

8 files changed

+1518
-1621
lines changed

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = {
2929
diagnostics: false,
3030
tsconfig: '<rootDir>/tests/tsconfig.json',
3131
},
32+
Uint8Array: Uint8Array,
3233
VERSION: version,
3334
},
3435
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node', 'd.ts'],

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,19 @@
9696
"@sentry/react": "6.16.1",
9797
"@sentry/tracing": "6.16.1",
9898
"@stacks/blockchain-api-client": "0.65.0",
99-
"@stacks/common": "3.0.0",
100-
"@stacks/storage": "3.2.0",
99+
"@stacks/storage": "3.3.0",
100+
"@stacks/common": "3.3.0",
101101
"@stacks/connect": "6.4.0",
102102
"@stacks/connect-ui": "5.2.0",
103-
"@stacks/encryption": "3.0.0",
104-
"@stacks/network": "3.0.0",
103+
"@stacks/encryption": "3.3.0",
104+
"@stacks/network": "3.3.0",
105105
"@stacks/rpc-client": "1.0.3",
106-
"@stacks/transactions": "3.0.0",
106+
"@stacks/transactions": "3.3.0",
107107
"@stacks/ui": "7.10.0",
108108
"@stacks/ui-core": "7.3.0",
109109
"@stacks/ui-theme": "7.5.0",
110110
"@stacks/ui-utils": "7.5.0",
111-
"@stacks/wallet-sdk": "3.0.0",
111+
"@stacks/wallet-sdk": "3.4.0",
112112
"@styled-system/theme-get": "5.1.2",
113113
"@tippyjs/react": "4.2.6",
114114
"@vkontakte/vk-qr": "2.0.13",
@@ -267,7 +267,7 @@
267267
"resolutions": {
268268
"**/**/prismjs": "1.27.0",
269269
"**/**/xmldom": "github:xmldom/xmldom#0.7.0",
270-
"**/**/@stacks/network": "3.0.0",
270+
"**/**/@stacks/network": "3.3.0",
271271
"@redux-devtools/cli/**/tar": "4.4.18",
272272
"bn.js": "5.2.0",
273273
"buffer": "6.0.3",

src/app/store/keys/key.actions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@ import { sendMessage } from '@shared/messages';
1111
import { InternalMethods } from '@shared/message-types';
1212
import { inMemoryKeySlice } from '../in-memory-key/in-memory-key.slice';
1313
import { selectDefaultWalletKey } from '../in-memory-key/in-memory-key.selectors';
14+
import { StacksMainnet } from '@stacks/network';
1415

1516
async function restoredWalletHighestGeneratedAccountIndex(secretKey: string) {
1617
try {
1718
// Don't need, nor return, encrypted wallet value, so a legit password isn't
1819
// needed. Ideally `@stacks/wallet-sdk` should be updated so that the encrypt
1920
// function is a separate method
2021
const wallet = await generateWallet({ secretKey, password: '' });
22+
// use network to select addresses based on owned usernames
23+
const network = new StacksMainnet();
2124
const restoredWallet = await restoreWalletAccounts({
2225
wallet,
2326
gaiaHubUrl: gaiaUrl,
27+
network,
2428
});
2529
return restoredWallet.accounts.length - 1;
2630
} catch (e) {

src/app/store/transactions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
publicKeyToString,
1616
AddressVersion,
1717
} from '@stacks/transactions';
18-
import { serializePayload } from '@stacks/transactions/dist/payload';
18+
import { serializePayload } from '@stacks/transactions';
1919

2020
import { stxToMicroStx, validateStacksAddress } from '@app/common/stacks-utils';
2121
import { stacksTransactionToHex, whenChainId } from '@app/common/transactions/transaction-utils';

src/app/store/transactions/transaction.hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
unsignedTransactionState,
4242
unsignedStacksTransactionBaseState,
4343
} from './index';
44-
import { serializePayload } from '@stacks/transactions/dist/payload';
44+
import { serializePayload } from '@stacks/transactions';
4545
import { selectedAssetIdState } from '../assets/asset-search';
4646
import { generateUnsignedTransaction } from '@app/common/transactions/generate-unsigned-txs';
4747
import { logger } from '@shared/logger';

src/background/message-handler.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { gaiaUrl } from '@shared/constants';
22
import { logger } from '@shared/logger';
33
import { InternalMethods } from '@shared/message-types';
44
import { BackgroundActions } from '@shared/messages';
5+
import { StacksMainnet } from '@stacks/network';
56
import { generateNewAccount, generateWallet, restoreWalletAccounts } from '@stacks/wallet-sdk';
67
import memoize from 'promise-memoize';
78
import { backupWalletSaltForGaia } from './backup-old-wallet-salt';
@@ -20,7 +21,8 @@ const deriveWalletWithAccounts = memoize(async (secretKey: string, highestAccoun
2021
// method. This does the same as the catch case, with the addition that it will
2122
// also try and fetch usernames associated with an account
2223
try {
23-
return restoreWalletAccounts({ wallet, gaiaHubUrl: gaiaUrl });
24+
const network = new StacksMainnet();
25+
return restoreWalletAccounts({ wallet, gaiaHubUrl: gaiaUrl, network });
2426
} catch (e) {
2527
// To generate a new account, the wallet-sdk requires the entire `Wallet` to
2628
// be supplied so that it can count the `wallet.accounts[]` length, and return

webpack/webpack.config.base.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,17 @@ const HTML_PROD_OPTIONS = IS_DEV
6969
},
7070
};
7171

72-
const aliases = {};
72+
const aliases = {
73+
// alias stacks.js packages to their esm (default prefers /dist/polyfill)
74+
'@stacks/auth': '@stacks/auth/dist/esm',
75+
'@stacks/common': '@stacks/common/dist/esm',
76+
'@stacks/encryption': '@stacks/encryption/dist/esm',
77+
'@stacks/network': '@stacks/network/dist/esm',
78+
'@stacks/profile': '@stacks/profile/dist/esm',
79+
'@stacks/storage': '@stacks/storage/dist/esm',
80+
'@stacks/transactions': '@stacks/transactions/dist/esm',
81+
'@stacks/wallet-sdk': '@stacks/wallet-sdk/dist/esm',
82+
};
7383

7484
const config = {
7585
entry: {

0 commit comments

Comments
 (0)