Skip to content

Commit

Permalink
Merge pull request #667 from near/dev
Browse files Browse the repository at this point in the history
v7.6.1 Release (dev -> main)
  • Loading branch information
kujtimprenkuSQA authored Jan 27, 2023
2 parents ff6220e + c047895 commit f17fcaa
Show file tree
Hide file tree
Showing 52 changed files with 407 additions and 146 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "near-wallet-selector",
"version": "7.6.0",
"version": "7.6.1",
"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",
"keywords": [
"near",
Expand Down
2 changes: 1 addition & 1 deletion packages/account-export/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/account-export",
"version": "7.6.0",
"version": "7.6.1",
"peerDependencies": {
"near-api-js": "^0.44.2 || ^1.0.0"
}
Expand Down
42 changes: 40 additions & 2 deletions packages/account-export/src/lib/components/AccountSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { ReactElement } from "react";
import React, { Fragment } from "react";
import { translate } from "@near-wallet-selector/core";
import { ModalHeader } from "./ModalHeader";
import type { ExportAccountData } from "./ExportAccount";
import { ACCESS_KEY_TYPES } from "./ExportAccount";

interface AccountSelectProps {
onCloseModal: () => void;
Expand All @@ -14,9 +16,42 @@ interface AccountSelectProps {
isLoading: boolean;
}

interface WarningLabelProp {
hasBalance: boolean;
type: string;
}

const LOADING_ICON_DATA_URL =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAR3SURBVHgBpVZ9aJVVGH+e55z33bi7zY9hMz+yMAeNoEIq6A9ZRKQWEsQNFIIpsf5Y9E+GsD9iBEEDMUkDa6ShRKKZYIWiRkaKaUGUGCKOTGMF84PNO99773vOefq9720yK5ZzD/dwPt/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e5KRzGhBMiqNxllKju7d8NOYXjseRBytQngcVDL3wD9H+7vf3YS7mnnzqrZpwSxrwkh04cpM5NTMyJdHbIgaESyxJ6tZ5cDbw3qd0tqVCp25Se/4yYdr5/zm/ehjwvpxZHgN0Wlub0/Yt7awdykqRYFHy6NUQVrBd4o6p6ngrVL2Bo8ksuJqoXzq9Ln9m6rj9U74b6Wjo8OeP082aY5NUxRsYzwDkeFsU+MdUU3U4PG0QtbahqhadDMuHTy4fvS/9EwIUpdeuW/ZiShOipFxURRbNdWETFMRZrCFlEZGkuPHdycTafgLExNiI6YfUpcAAAAASUVORK5CYII=";

const getWarningLabel = ({
hasBalance,
type,
}: WarningLabelProp): ReactElement | null => {
if (type === ACCESS_KEY_TYPES.UNKNOWN) {
return (
<span className="error">
{translate("modal.exportAccounts.selectAccounts.error")}
</span>
);
}
if (type === ACCESS_KEY_TYPES.LEDGER) {
return (
<span className="warning">
{translate("modal.exportAccounts.selectAccounts.warningLedger")}
</span>
);
}
if (!hasBalance) {
return (
<span className="warning">
{translate("modal.exportAccounts.selectAccounts.noBalance")}
</span>
);
}
return null;
};

export const AccountSelect: React.FC<AccountSelectProps> = ({
onCloseModal,
onBack,
Expand Down Expand Up @@ -95,7 +130,7 @@ export const AccountSelect: React.FC<AccountSelectProps> = ({
{translate("modal.exportAccounts.selectAccounts.unavailable")}
</span>
<div className="account-selection">
{disabledAccounts.map(({ accountId }) => (
{disabledAccounts.map(({ accountId, type, hasBalance }) => (
<div className="account-selection-row" key={accountId}>
<div className="checkbox">
<input
Expand All @@ -109,7 +144,10 @@ export const AccountSelect: React.FC<AccountSelectProps> = ({
value={accountId}
disabled
/>
<label htmlFor={accountId}> {accountId}</label>
<label htmlFor={accountId}>
<span>{accountId}</span>
{getWarningLabel({ hasBalance, type })}
</label>
</div>
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const EXPORT_ACCOUNT_STEPS = {
COMPLETE: "COMPLETE",
};

const ACCESS_KEY_TYPES = {
export const ACCESS_KEY_TYPES = {
LEDGER: "Ledger",
FULL_ACCESS_KEY: "Full Access Key",
MULTI_SIG: "Multi-Sig",
Expand Down
41 changes: 30 additions & 11 deletions packages/account-export/src/lib/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@

.nws-modal-wrapper .nws-modal .nws-modal-body button.middleButton:disabled,
.nws-modal-wrapper .nws-modal .nws-modal-body button.middleButton[disabled]{
border-color: var(--secondary-button-border-color);
background-color: var(--secondary-button-bg-color);
cursor: not-allowed;
background-color: var(--wallet-selector-home-button-bg, var(--home-button-bg));
color: #606060;
border: none;
}


Expand All @@ -46,15 +47,14 @@
}

.checkbox {
width: 100%;
position: relative;
display: block;
}

.checkbox label {
position: relative;
display: block;
padding-left: 50px;
padding-left: 40px;
margin-bottom: 0;
cursor: pointer;
color: var(--wallet-selector-heading-color, var(--heading-color));
Expand Down Expand Up @@ -111,6 +111,18 @@
.checkbox input[type="checkbox"]:disabled + label {
color: var(--wallet-selector-text-color, var(--text-color));
cursor: not-allowed;
display: flex;
flex-direction: column;
}

.checkbox input[type="checkbox"]:disabled + label > span.error {
color: var(--wallet-selector-error, var(--error));
font-size: 10px;
}

.checkbox input[type="checkbox"]:disabled + label > span.warning {
color: #E9B870;
font-size: 10px;
}

.checkbox input[type="checkbox"]:disabled + label::before {
Expand Down Expand Up @@ -156,6 +168,7 @@

.account-export {
height: 100%;
margin-top: 15px !important;
}

.account-export .content {
Expand Down Expand Up @@ -185,7 +198,7 @@
width: 100%;
max-height: 200px;
overflow-y: auto;
margin-top: 20px;
margin: 20px 0;
}

.account-export .account-select-all {
Expand All @@ -208,15 +221,20 @@
flex-direction: row;
align-items: center;
width: 100%;
padding: 0 12px;
margin-bottom: 24px;
padding: 15px 12px;
border-bottom: 1px solid #313030;
}

.account-export .account-selection .account-selection-row label {
display: flex;
flex-direction: column;
}

.account-export .passphrase-title {
font-size: 14px;
font-size: 15px;
text-align: center;
font-weight: 400;
color: #c1c1c1;
font-weight: 500;
color: var(--wallet-selector-text-color, var(--text-color));
margin: 40px 0 30px;
}

Expand All @@ -236,8 +254,9 @@
}

.account-export .passphrase-label {
font-size: 10px;
font-size: 12px;
cursor: copy;
color: var(--wallet-selector-text-color, var(--text-color));
}

.account-export .complete-desc {
Expand Down
2 changes: 1 addition & 1 deletion packages/coin98-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/coin98-wallet",
"version": "7.6.0",
"version": "7.6.1",
"description": "Coin 98 wallet package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
16 changes: 13 additions & 3 deletions packages/coin98-wallet/src/lib/coin98-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,24 @@ const Coin98Wallet: WalletBehaviourFactory<InjectedWallet> = async ({
}) => {
const _state = setupCoin98WalletState();

const getAccounts = (): Array<Account> => {
const getAccounts = async (): Promise<Array<Account>> => {
const accountId = _state.wallet.near.account;

if (!accountId) {
return [];
}

return [{ accountId: _state.wallet.near.account }];
return [
{
accountId: _state.wallet.near.account,
publicKey: (
await _state.wallet.near.signer.getPublicKey(
accountId,
options.network.networkId
)
).toString(),
},
];
};

const transformTransactions = (
Expand Down Expand Up @@ -85,7 +95,7 @@ const Coin98Wallet: WalletBehaviourFactory<InjectedWallet> = async ({

return {
async signIn({ contractId }) {
const existingAccounts = getAccounts();
const existingAccounts = await getAccounts();

if (existingAccounts.length) {
return existingAccounts;
Expand Down
1 change: 1 addition & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const selector = await setupWalletSelector({
- `indexerUrl` (`string`): Custom URL for the Indexer service.
- `debug` (`boolean?`): Enable internal logging for debugging purposes. Defaults to `false`.
- `optimizeWalletOrder` (`boolean?`): Enable automatic wallet order. Reorders last signed in wallet on top, then installed wallets over not installed and deprecated wallets.
- `allowMultipleSelectors` (`boolean?`): Optionally allow creating new instances of wallet selector.
- `storage` (`StorageService?`): Async storage implementation. Useful when [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) is unavailable. Defaults to `localStorage`.
- `modules` (`Array<WalletModuleFactory>`): List of wallets to support in your dApp.

Expand Down
2 changes: 1 addition & 1 deletion packages/core/docs/api/wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Returns one or more accounts when signed in. This method can be useful for walle
(async () => {
const wallet = await selector.wallet("sender");
const accounts = await wallet.getAccounts();
console.log(accounts); // [{ accountId: "test.testnet" }]
console.log(accounts); // [{ accountId: "test.testnet", publicKey: "..." }]
})();
```

Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-wallet-selector/core",
"version": "7.6.0",
"version": "7.6.1",
"description": "This is the core package for NEAR Wallet Selector.",
"keywords": [
"near",
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/lib/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,15 @@
"button": "Get Passphrase",
"deselectAll": "Deselect All",
"selectAll": "Select All",
"unavailable": "Transfer Unavailable"
"unavailable": "Transfer Unavailable",
"error": "Account does not exist",
"warningLedger": "Ledger support required",
"noBalance": "Account not funded"
},
"getPassphrase": {
"title": "Copy Temporary Password",
"desc": "You’ll need to enter this password when you begin exporting your accounts to a different wallet.",
"button": "Transfer Accounts",
"button": "Continue",
"label": "Click to Copy",
"checkLabel": "I copied or wrote down the password"
},
Expand Down
Loading

0 comments on commit f17fcaa

Please sign in to comment.