Skip to content

Commit 984d0d7

Browse files
authored
Merge pull request #778 from near/dev
v8.0.0 Release (dev -> main)
2 parents 13edffd + be5ee49 commit 984d0d7

Some content is hidden

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

66 files changed

+500
-180
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ NEAR Wallet Selector makes it easy for users to interact with your dApp by provi
3030

3131
## Installation and Usage
3232

33-
The easiest way to use NEAR Wallet Selector is to install the [`core`](https://www.npmjs.com/package/@near-wallet-selector/core) package from the NPM registry, some packages may require `near-api-js` v0.44.2 or above check them at [`packages`](./packages)
33+
The easiest way to use NEAR Wallet Selector is to install the [`core`](https://www.npmjs.com/package/@near-wallet-selector/core) package from the NPM registry, some packages may require `near-api-js` v1.0.0 or above check them at [`packages`](./packages)
3434

3535
```bash
3636
# Using Yarn

examples/react/components/ExportContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { Fragment } from "react";
33
import { useExportAccountSelector } from "../contexts/WalletSelectorExportContext";
44

55
const ExportContent: NextPage = () => {
6-
const { ExportModal } = useExportAccountSelector();
6+
const { exportModal } = useExportAccountSelector();
77
return (
88
<Fragment>
9-
<button onClick={() => ExportModal.show()}>Open Modal</button>
9+
<button onClick={() => exportModal.show()}>Open Modal</button>
1010
<p>
1111
The Export Accounts modal assists users in migrating their accounts to
1212
any Wallet Selector wallet supporting account imports. Any sensitive

examples/react/contexts/WalletSelectorContext.tsx

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ import { setupNearSnap } from "@near-wallet-selector/near-snap";
1717
import { setupWelldoneWallet } from "@near-wallet-selector/welldone-wallet";
1818
import { setupXDEFI } from "@near-wallet-selector/xdefi";
1919
import type { ReactNode } from "react";
20-
import React, { useCallback, useContext, useEffect, useState } from "react";
20+
import React, {
21+
useCallback,
22+
useContext,
23+
useEffect,
24+
useState,
25+
useMemo,
26+
} from "react";
2127
import { distinctUntilChanged, map } from "rxjs";
2228

2329
import { setupNeth } from "@near-wallet-selector/neth";
@@ -51,6 +57,7 @@ export const WalletSelectorContextProvider: React.FC<{
5157
const [selector, setSelector] = useState<WalletSelector | null>(null);
5258
const [modal, setModal] = useState<WalletSelectorModal | null>(null);
5359
const [accounts, setAccounts] = useState<Array<AccountState>>([]);
60+
const [loading, setLoading] = useState<boolean>(true);
5461

5562
const init = useCallback(async () => {
5663
const _selector = await setupWalletSelector({
@@ -103,11 +110,14 @@ export const WalletSelectorContextProvider: React.FC<{
103110
const state = _selector.store.getState();
104111
setAccounts(state.accounts);
105112

113+
// this is added for debugging purpose only
114+
// for more information (https://github.com/near/wallet-selector/pull/764#issuecomment-1498073367)
106115
window.selector = _selector;
107116
window.modal = _modal;
108117

109118
setSelector(_selector);
110119
setModal(_modal);
120+
setLoading(false);
111121
}, []);
112122

113123
useEffect(() => {
@@ -141,24 +151,24 @@ export const WalletSelectorContextProvider: React.FC<{
141151
subscription.unsubscribe();
142152
onHideSubscription.remove();
143153
};
144-
}, [selector]);
154+
}, [selector, modal]);
155+
156+
const walletSelectorContextValue = useMemo<WalletSelectorContextValue>(
157+
() => ({
158+
selector: selector!,
159+
modal: modal!,
160+
accounts,
161+
accountId: accounts.find((account) => account.active)?.accountId || null,
162+
}),
163+
[selector, modal, accounts]
164+
);
145165

146-
if (!selector || !modal) {
166+
if (loading) {
147167
return <Loading />;
148168
}
149169

150-
const accountId =
151-
accounts.find((account) => account.active)?.accountId || null;
152-
153170
return (
154-
<WalletSelectorContext.Provider
155-
value={{
156-
selector,
157-
modal,
158-
accounts,
159-
accountId,
160-
}}
161-
>
171+
<WalletSelectorContext.Provider value={walletSelectorContextValue}>
162172
{children}
163173
</WalletSelectorContext.Provider>
164174
);

examples/react/contexts/WalletSelectorExportContext.tsx

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import type { ReactNode } from "react";
2-
import React, { useCallback, useContext, useEffect, useState } from "react";
2+
import React, {
3+
useCallback,
4+
useContext,
5+
useEffect,
6+
useState,
7+
useMemo,
8+
} from "react";
39
import { map, distinctUntilChanged } from "rxjs";
410
import { setupWalletSelector } from "@near-wallet-selector/core";
511
import type { WalletSelector, AccountState } from "@near-wallet-selector/core";
@@ -24,13 +30,13 @@ import { setupLedger } from "@near-wallet-selector/ledger";
2430
declare global {
2531
interface Window {
2632
importSelector: WalletSelector;
27-
ExportModal: WalletSelectorModal;
33+
exportModal: WalletSelectorModal;
2834
}
2935
}
3036

3137
interface ExportAccountSelectorContextValue {
3238
importSelector: WalletSelector;
33-
ExportModal: WalletSelectorModal;
39+
exportModal: WalletSelectorModal;
3440
accounts: Array<AccountState>;
3541
accountId: string | null;
3642
}
@@ -42,8 +48,9 @@ export const ExportAccountSelectorContextProvider: React.FC<{
4248
children: ReactNode;
4349
}> = ({ children }) => {
4450
const [importSelector, setSelector] = useState<WalletSelector | null>(null);
45-
const [ExportModal, setModal] = useState<WalletSelectorModal | null>(null);
51+
const [modal, setModal] = useState<WalletSelectorModal | null>(null);
4652
const [accounts, setAccounts] = useState<Array<AccountState>>([]);
53+
const [loading, setLoading] = useState<boolean>(true);
4754

4855
const init = useCallback(async () => {
4956
const _selector = await setupWalletSelector({
@@ -95,11 +102,14 @@ export const ExportAccountSelectorContextProvider: React.FC<{
95102
const state = _selector.store.getState();
96103
setAccounts(state.accounts);
97104

105+
// this is added for debugging purpose only
106+
// for more information (https://github.com/near/wallet-selector/pull/764#issuecomment-1498073367)
98107
window.importSelector = _selector;
99-
window.ExportModal = _modal;
108+
window.exportModal = _modal;
100109

101110
setSelector(_selector);
102111
setModal(_modal);
112+
setLoading(false);
103113
}, []);
104114

105115
useEffect(() => {
@@ -126,21 +136,25 @@ export const ExportAccountSelectorContextProvider: React.FC<{
126136
return () => subscription.unsubscribe();
127137
}, [importSelector]);
128138

129-
if (!importSelector || !ExportModal) {
139+
const exportWalletSelectorContextValue =
140+
useMemo<ExportAccountSelectorContextValue>(
141+
() => ({
142+
importSelector: importSelector!,
143+
exportModal: modal!,
144+
accounts,
145+
accountId:
146+
accounts.find((account) => account.active)?.accountId || null,
147+
}),
148+
[importSelector, modal, accounts]
149+
);
150+
151+
if (loading) {
130152
return <Loading />;
131153
}
132154

133-
const accountId =
134-
accounts.find((account) => account.active)?.accountId || null;
135-
136155
return (
137156
<ExportAccountSelectorContext.Provider
138-
value={{
139-
importSelector,
140-
ExportModal,
141-
accounts,
142-
accountId,
143-
}}
157+
value={exportWalletSelectorContextValue}
144158
>
145159
{children}
146160
</ExportAccountSelectorContext.Provider>

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "near-wallet-selector",
3-
"version": "7.9.3",
3+
"version": "8.0.0",
44
"description": "NEAR Wallet Selector makes it easy for users to interact with your dApp by providing an abstraction over various wallets within the NEAR ecosystem",
55
"keywords": [
66
"near",
@@ -101,8 +101,9 @@
101101
"core-js": "^3.6.5",
102102
"crypto-browserify": "^3.12.0",
103103
"ethers": "^5.7.2",
104+
"https-browserify": "^1.0.0",
104105
"is-mobile": "^3.1.1",
105-
"near-api-js": "^1.1.0",
106+
"near-api-js": "^2.1.0",
106107
"near-seed-phrase": "^0.2.0",
107108
"next": "12.2.3",
108109
"ngx-deploy-npm": "^4.3.10",
@@ -113,9 +114,11 @@
113114
"regenerator-runtime": "0.13.11",
114115
"rxjs": "^7.8.0",
115116
"stream-browserify": "^3.0.0",
117+
"stream-http": "^3.2.0",
116118
"tslib": "^2.3.0",
117119
"tweetnacl": "^1.0.3",
118120
"tweetnacl-util": "^0.15.1",
121+
"url": "^0.11.0",
119122
"zone.js": "~0.11.4"
120123
},
121124
"devDependencies": {

packages/account-export/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ modal.show();
4343
- `accounts` (`Array`): List of objects with an account id and its private key to be exported.
4444
- `theme` (`Theme?`): Specify light/dark theme for UI. Defaults to the browser configuration when omitted or set to 'auto'. This can be either `light`, `dark` or `auto`.
4545
- `description` (`string?`): Define a custom description in the UI.
46+
- `onComplete` (`(accounts: Array<string>) => void`): Triggers when the user completes the flow. By default it is not set.
4647

4748
## Styles & Customizing CSS
4849

packages/account-export/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@near-wallet-selector/account-export",
3-
"version": "7.9.3",
3+
"version": "8.0.0",
44
"description": "This is the Export Selector UI package for NEAR Wallet Selector.",
55
"keywords": [
66
"near",
@@ -21,6 +21,6 @@
2121
},
2222
"homepage": "https://github.com/near/wallet-selector/tree/magin/packages/account-export",
2323
"peerDependencies": {
24-
"near-api-js": "^0.44.2 || ^1.0.0"
24+
"near-api-js": "^1.0.0 || ^2.0.0"
2525
}
2626
}

packages/coin98-wallet/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Coin98 Wallet [Coin98 Wallet](https://chrome.google.com/webstore/detail/coin98-w
44

55
## Installation
66

7-
This package requires `near-api-js` v0.44.2 or above:
7+
This package requires `near-api-js` v1.0.0 or above:
88

99
```bash
1010
# Using Yarn
@@ -43,6 +43,7 @@ const selector = await setupWalletSelector({
4343
## Options
4444

4545
- `iconUrl`: (`string?`): Icon is optional. Default image point to Coin98 Wallet Logo in base64 format.
46+
- `deprecated`: (`boolean?`): Deprecated is optional. Default is `false`.
4647

4748
## License
4849

packages/coin98-wallet/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@near-wallet-selector/coin98-wallet",
3-
"version": "7.9.3",
3+
"version": "8.0.0",
44
"description": "Coin 98 wallet package for NEAR Wallet Selector.",
55
"keywords": [
66
"near",
@@ -22,6 +22,6 @@
2222
},
2323
"homepage": "https://github.com/near/wallet-selector/tree/main/packages/coin98-wallet",
2424
"peerDependencies": {
25-
"near-api-js": "^0.44.2 || ^1.0.0"
25+
"near-api-js": "^1.0.0 || ^2.0.0"
2626
}
2727
}

packages/core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This is the core package for NEAR Wallet Selector.
44

55
## Installation and Usage
66

7-
The easiest way to use this package is to install it from the NPM registry, this package requires `near-api-js` v0.44.2 or above:
7+
The easiest way to use this package is to install it from the NPM registry, this package requires `near-api-js` v1.0.0 or above:
88

99
```bash
1010
# Using Yarn

0 commit comments

Comments
 (0)