Skip to content

Commit

Permalink
Function key set (#617)
Browse files Browse the repository at this point in the history
* feat: add ref-modal-ui package

* feat: update wallet selector modal ui

---------

Co-authored-by: naturexie <[email protected]>
  • Loading branch information
xieqiancaosissi and naturexie authored Oct 10, 2024
1 parent a52d1bd commit e8dce17
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
"react-use-websocket": "^4.3.1",
"recharts": "^2.1.6",
"reconnecting-websocket": "^4.4.0",
"ref-modal-ui": "^8.9.13",
"respinner": "^3.0.8",
"rxjs": "7.8.1",
"socket.io-client": "^4.5.4",
Expand Down
32 changes: 26 additions & 6 deletions src/context/WalletSelectorContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type {
Wallet,
Network,
} from '@near-wallet-selector/core';
import { setupModal } from '@near-wallet-selector/modal-ui';
import type { WalletSelectorModal } from '@near-wallet-selector/modal-ui';
import { setupModal } from 'ref-modal-ui';
import type { WalletSelectorModal } from 'ref-modal-ui';
import { setupMyNearWallet } from '@near-wallet-selector/my-near-wallet';
import { setupSender } from '@near-wallet-selector/sender';
import { setupLedger } from '@near-wallet-selector/ledger';
Expand All @@ -32,9 +32,8 @@ import { setupOKXWallet } from '@near-wallet-selector/okx-wallet';
import { setupMintbaseWallet } from '@near-wallet-selector/mintbase-wallet';
import { setupBitteWallet } from '@near-wallet-selector/bitte-wallet';

import '@near-wallet-selector/modal-ui/styles.css';
import 'ref-modal-ui/styles.css';
import { near } from '../services/near';
import { getOrderlyConfig } from '../pages/Orderly/config';
import { REF_ORDERLY_ACCOUNT_VALID } from '../pages/Orderly/components/UserBoard/index';
import {
REF_FI_SENDER_WALLET_ACCESS_KEY,
Expand Down Expand Up @@ -154,7 +153,7 @@ export const WalletSelectorContextProvider: React.FC<any> = ({ children }) => {
localStorage.removeItem('endPoint');
}
} catch (error) {}
const _selector = await setupWalletSelector({
const _selector: any = await setupWalletSelector({
network: {
networkId: getConfig().networkId as NetworkId,
nodeUrl: RPC_LIST[endPoint].url,
Expand Down Expand Up @@ -232,6 +231,21 @@ export const WalletSelectorContextProvider: React.FC<any> = ({ children }) => {
});
const _modal = setupModal(_selector, {
contractId: CONTRACT_ID,
blockFunctionKeyWallets: [
'okx-wallet',
'my-near-wallet',
'meteor-wallet',
'neth',
'nightly',
'ledger',
'wallet-connect',
'keypom',
'mintbase-wallet',
'bitte-wallet',
'ethereum-wallets',
'sender',
'coin98-wallet',
],
});
const state = _selector.store.getState();
syncAccountState(localStorage.getItem(ACCOUNT_ID_KEY), state.accounts);
Expand Down Expand Up @@ -289,7 +303,13 @@ export const WalletSelectorContextProvider: React.FC<any> = ({ children }) => {
const account = await near.account(accountId);

const allKeys = (await account.getAccessKeys()) as IAccountKey[];

const b = allKeys.find((b) => {
b.public_key == 'ed25519:4EEGqXX9Qu1tVmyc5T5QMw69WKDGdyjR8UGHYkmr6Vk2';
});
console.log('00000000-allKeys', JSON.stringify(allKeys));
if (b) {
debugger;
}
const isWalletMeta = allKeys.some((k) => {
if (k.access_key.permission === 'FullAccess') return false;
const meta = (
Expand Down
6 changes: 6 additions & 0 deletions src/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,12 @@ input[type='range']::-webkit-slider-runnable-track {
.nws-modal-wrapper .nws-modal {
border: 1px solid #414d55;
}
.nws-modal-wrapper .nws-modal .modal-left .modal-left-title {
background-color: rgb(49, 61, 70) !important;
}
input:checked + .nws-slider {
background-color: #47e586;
}

:root {
--wallet-selector-backdrop-bg: rgba(0, 0, 0, 0.5);
Expand Down
30 changes: 30 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3617,6 +3617,16 @@
near-api-js "4.0.3"
rxjs "7.8.1"

"@near-wallet-selector/[email protected]":
version "8.9.13"
resolved "https://registry.yarnpkg.com/@near-wallet-selector/core/-/core-8.9.13.tgz#d7190d7914e6c2cceac5af107d1f7366266f923a"
integrity sha512-ufI2yctF2N7+D6s5QaSs9Bqorh8xPH48wuBEvTbArJ6z9qvSCNsK9ZO5Mt5BFfO64ovmcflOOUBtZ4/BcNO6aQ==
dependencies:
borsh "0.7.0"
events "3.3.0"
js-sha256 "0.9.0"
rxjs "7.8.1"

"@near-wallet-selector/[email protected]", "@near-wallet-selector/core@^8.0.3":
version "8.9.5"
resolved "https://registry.yarnpkg.com/@near-wallet-selector/core/-/core-8.9.5.tgz#15e49f17252ee4e54a1c9719b8c2b98fd71aae74"
Expand Down Expand Up @@ -17454,6 +17464,15 @@ [email protected], qrcode@^1.4.4:
pngjs "^5.0.0"
yargs "^15.3.1"

[email protected]:
version "1.5.4"
resolved "https://registry.yarnpkg.com/qrcode/-/qrcode-1.5.4.tgz#5cb81d86eb57c675febb08cf007fff963405da88"
integrity sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==
dependencies:
dijkstrajs "^1.0.1"
pngjs "^5.0.0"
yargs "^15.3.1"

[email protected]:
version "6.11.0"
resolved "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a"
Expand Down Expand Up @@ -18095,6 +18114,17 @@ reduce-css-calc@^2.1.8:
css-unit-converter "^1.1.1"
postcss-value-parser "^3.3.0"

ref-modal-ui@^8.9.13:
version "8.9.13"
resolved "https://registry.yarnpkg.com/ref-modal-ui/-/ref-modal-ui-8.9.13.tgz#be0e81e1b6eb1d6e547639957dcf54ea1dbbf206"
integrity sha512-qelBsqRNl82TCIi4dgWXu+EYFakDfUwRudZMSLVPlvDtV6OpSe0xaEvCg1yCNxRficM0eMwt9yq5kGpcX1hjpw==
dependencies:
"@near-wallet-selector/core" "8.9.13"
copy-to-clipboard "3.3.3"
qrcode "1.5.4"
react "18.2.0"
react-dom "18.2.0"

reflect.getprototypeof@^1.0.4:
version "1.0.4"
resolved "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.4.tgz#aaccbf41aca3821b87bb71d9dcbc7ad0ba50a3f3"
Expand Down

0 comments on commit e8dce17

Please sign in to comment.