Skip to content

Commit

Permalink
Add mintbase wallet (#543)
Browse files Browse the repository at this point in the history
* add mintbase wallet

* fix pool issue for mint base wallet

* disbaled tris for mintbase  wallet

* update yarn.lock

* fix mintbase key delete error

* fix: create pool modal

---------

Co-authored-by: xieqian <[email protected]>
Co-authored-by: xieqian <[email protected]>
Co-authored-by: deep-path <[email protected]>
  • Loading branch information
4 people authored Jun 20, 2024
1 parent 134db7a commit 595ee0a
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 185 deletions.
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"@near-wallet-selector/nightly": "^8.9.7",
"@near-wallet-selector/sender": "^8.9.7",
"@near-wallet-selector/wallet-connect": "^7.9.1",
"@near-wallet-selector/mintbase-wallet": "^8.9.7",
"@react-icons/all-files": "https://github.com/react-icons/react-icons/releases/download/v4.7.1/react-icons-all-files-4.7.1.tgz",
"@transak/transak-sdk": "1.2.2",
"@walletconnect/client": "^2.0.0-beta.26",
Expand Down Expand Up @@ -204,7 +205,13 @@
"@types/react-dom": "17.0.2",
"@ledgerhq/devices": "6.27.1",
"@ledgerhq/hw-transport": "6.27.1",
"@ledgerhq/hw-transport-webhid": "6.27.1"
"@ledgerhq/hw-transport-webhid": "6.27.1",
"@near-js/accounts": "^1.0.2",
"@near-js/crypto": "^1.2.0",
"@near-js/keystores-browser": "^0.0.8",
"@near-js/transactions": "^1.1.0",
"@near-js/utils": "^0.0.5",
"@near-js/wallet-account": "^1.0.2"
},
"alias": {
"@ledgerhq/devices": "@ledgerhq/devices/lib-es",
Expand Down
3 changes: 2 additions & 1 deletion src/components/forms/SlippageSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ export default function SlippageSelector({
const selectedWalletId = window.selector?.store?.getState()?.selectedWalletId;
const trisDisbaled =
selectedWalletId === 'near-snap' ||
selectedWalletId === 'near-mobile-wallet';
selectedWalletId === 'near-mobile-wallet' ||
selectedWalletId === 'mintbase-wallet';
useEffect(() => {
if (trisDisbaled) {
setEnableTri(false);
Expand Down
2 changes: 1 addition & 1 deletion src/components/portfolio/AccessKeyModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function AuthorizedApps({
const [clear_loading, set_clear_loading] = useState<boolean>(false);
const [selectedKeys, setSelectedKeys] = useState<Set<string>>(new Set([]));
const { allKeys } = useWalletSelector();
const disbaledWallet = ['sender', 'neth'];
const disbaledWallet = ['sender', 'neth', 'keypom'];
const selectedWalletId = window.selector?.store?.getState()?.selectedWalletId;
const functionCallKeys = useMemo(() => {
return allKeys.filter((key) => key.access_key.permission !== 'FullAccess');
Expand Down
6 changes: 6 additions & 0 deletions src/context/WalletSelectorContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { setupNightly } from '@near-wallet-selector/nightly';
import getConfig from '../services/config';
import { setupWalletConnect } from '@near-wallet-selector/wallet-connect';
import { setupNearMobileWallet } from '@near-wallet-selector/near-mobile-wallet';
import { setupMintbaseWallet } from '@near-wallet-selector/mintbase-wallet';

import '@near-wallet-selector/modal-ui/styles.css';
import { near } from '../services/near';
Expand Down Expand Up @@ -186,6 +187,11 @@ export const WalletSelectorContextProvider: React.FC<any> = ({ children }) => {
url: '/#instant-url/ACCOUNT_ID#SECRET_KEY/MODULE_ID',
},
}),
setupMintbaseWallet({
walletUrl: 'https://wallet.mintbase.xyz',
contractId: CONTRACT_ID,
deprecated: false,
}),
],
});
const _modal = setupModal(_selector, {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/pools/AddPoolPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function AddPoolModal(
const isMobile = useClientMobile();
const cardWidth = isMobile ? '98vw' : '450px';

if (!tokens || !balances) return <Loading />;
// if (!tokens || !balances) return <Loading />;
if (!props.isOpen) return null;

const render = (token: TokenMetadata) => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/pools/LiquidityPage/LiquidityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,7 @@ function PcLiquidityPage({
</div>
)}
</div>
{isSignedIn && activeTab != 'v1' && (
{isSignedIn && selectTokens && selectBalances && (
<AddPoolModal
isOpen={showAddPoolModal}
onRequestClose={(e) => {
Expand Down
3 changes: 1 addition & 2 deletions src/services/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,6 @@ export const removeLiquidityByTokensFromStablePool = async ({
unregister = false,
}: RemoveLiquidityByTokensFromStablePoolOptions) => {
const tokenIds = tokens.map((token) => token.id);

const withDrawTransactions: Transaction[] = [];

for (let i = 0; i < tokenIds.length; i++) {
Expand Down Expand Up @@ -1275,7 +1274,7 @@ export const removeLiquidityByTokensFromStablePool = async ({
];
let need_split = false;
const selectedWalletId = window.selector?.store?.getState()?.selectedWalletId;
if (selectedWalletId == 'ledger') {
if (selectedWalletId == 'ledger' || selectedWalletId == 'mintbase-wallet') {
need_split = true;
}
if (explorerType !== ExplorerType.Firefox && !need_split) {
Expand Down
15 changes: 5 additions & 10 deletions src/services/portfolioData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getCurrentWallet } from '../utils/wallets-integration';
import { Transaction as WSTransaction } from '@near-wallet-selector/core';
import { getOrderlyConfig } from '../pages/Orderly/config';
const webWalletIds = ['my-near-wallet', 'mintbase-wallet'];
export async function batchDeleteKeys(publicKeys: string[]) {
const accountId = getCurrentWallet().wallet.getAccountId();
const wallet = await window.selector.wallet();
Expand All @@ -24,12 +25,12 @@ export async function batchDeleteKeys(publicKeys: string[]) {
transactions: wstransactions,
})
.then(() => {
if (wallet.id !== 'my-near-wallet') {
if (!webWalletIds.includes(wallet.id)) {
window.location.reload();
}
})
.catch(() => {
if (wallet.id !== 'my-near-wallet') {
if (!webWalletIds.includes(wallet.id)) {
window.location.reload();
}
});
Expand All @@ -39,12 +40,6 @@ export async function batchOrderelyDeleteKeys(publicKeys: string[]) {
const wallet = await window.selector.wallet();
const wstransactions: WSTransaction[] = [];
const len = 1;
// if (wallet.id === 'ledger') {
// len = 3;
// }
// if (wallet.id === 'my-near-wallet') {
// len = 10;
// }
const transactionsLength = Math.ceil(publicKeys.length / len);
for (let index = 0; index < transactionsLength; index++) {
const splitPublicKeys = publicKeys.slice(index * len, index * len + len);
Expand Down Expand Up @@ -73,12 +68,12 @@ export async function batchOrderelyDeleteKeys(publicKeys: string[]) {
transactions: wstransactions,
})
.then(() => {
if (wallet.id !== 'my-near-wallet') {
if (!webWalletIds.includes(wallet.id)) {
window.location.reload();
}
})
.catch(() => {
if (wallet.id !== 'my-near-wallet') {
if (!webWalletIds.includes(wallet.id)) {
window.location.reload();
}
});
Expand Down
Loading

0 comments on commit 595ee0a

Please sign in to comment.