From 75b6fdd43e2b211ad083bb4bf262043a1ccee79a Mon Sep 17 00:00:00 2001 From: mootz12 Date: Tue, 29 Oct 2024 17:48:23 -0400 Subject: [PATCH 1/2] feat: add wallet connect to wallet-kit and add escape from building and signing overlay --- .env.production | 2 + .env.testnet | 2 + package-lock.json | 92 +++++++++++++--------- package.json | 6 +- src/components/common/OverlayModal.tsx | 40 +++++++++- src/components/common/OverlayModalText.tsx | 29 ++++++- src/contexts/wallet.tsx | 44 +++++++++-- 7 files changed, 160 insertions(+), 55 deletions(-) diff --git a/.env.production b/.env.production index 36ac2f9..dad551a 100644 --- a/.env.production +++ b/.env.production @@ -2,6 +2,8 @@ NEXT_PUBLIC_STELLAR_EXPERT_URL=https://stellar.expert/explorer/public NEXT_PUBLIC_RPC_URL=https://soroban-rpc.creit.tech/ NEXT_PUBLIC_HORIZON_URL=https://horizon.stellar.org NEXT_PUBLIC_PASSPHRASE=Public Global Stellar Network ; September 2015 +NEXT_PUBLIC_WALLET_CONNECT_URL=https://mainnet.blend.capital +NEXT_PUBLIC_WALLET_CONNECT_NAME=Blend Mainnet NEXT_PUBLIC_BACKSTOP=CAO3AGAMZVRMHITL36EJ2VZQWKYRPWMQAPDQD5YEOF3GIF7T44U4JAL3 NEXT_PUBLIC_USDC_ISSUER=GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN NEXT_PUBLIC_BLND_ISSUER=GDJEHTBE6ZHUXSWFI642DCGLUOECLHPF3KSXHPXTSTJ7E3JF6MQ5EZYY diff --git a/.env.testnet b/.env.testnet index 26aefee..3c89f3c 100644 --- a/.env.testnet +++ b/.env.testnet @@ -2,6 +2,8 @@ NEXT_PUBLIC_STELLAR_EXPERT_URL=https://stellar.expert/explorer/testnet NEXT_PUBLIC_RPC_URL=https://soroban-testnet.stellar.org NEXT_PUBLIC_HORIZON_URL=https://horizon-testnet.stellar.org NEXT_PUBLIC_PASSPHRASE=Test SDF Network ; September 2015 +NEXT_PUBLIC_WALLET_CONNECT_URL=https://testnet.blend.capital +NEXT_PUBLIC_WALLET_CONNECT_NAME=Blend Testnet NEXT_PUBLIC_BACKSTOP=CDJQJS3TLZ6LEWSBOZ2E6QEZZ4NS3JU5LDT2BT7A4UHWAXPLSNE6MM37 NEXT_PUBLIC_USDC_ISSUER=GATALTGTWIOT6BUDBCZM3Q4OQ4BO2COLOAZ7IYSKPLC2PMSOPPGF5V56 NEXT_PUBLIC_BLND_ISSUER=GATALTGTWIOT6BUDBCZM3Q4OQ4BO2COLOAZ7IYSKPLC2PMSOPPGF5V56 diff --git a/package-lock.json b/package-lock.json index bd7f33b..a86ef84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,14 +8,14 @@ "name": "blend-ui", "version": "1.1.5", "dependencies": { - "@blend-capital/blend-sdk": "2.0.4", - "@creit.tech/stellar-wallets-kit": "1.2.1", + "@blend-capital/blend-sdk": "2.1.1", + "@creit.tech/stellar-wallets-kit": "1.2.3", "@emotion/react": "^11.9.3", "@emotion/styled": "^11.9.3", "@mui/icons-material": "^5.8.4", "@mui/material": "^5.8.6", "@stellar/freighter-api": "^3.0.0", - "@stellar/stellar-sdk": "12.2.0", + "@stellar/stellar-sdk": "12.3.0", "@tanstack/react-query": "5.52.0", "copy-to-clipboard": "^3.3.3", "next": "^14.2.11", @@ -191,20 +191,20 @@ } }, "node_modules/@blend-capital/blend-sdk": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@blend-capital/blend-sdk/-/blend-sdk-2.0.4.tgz", - "integrity": "sha512-t3USvFpQmD9nm7y0H3fA7CEDM/nyTis+WVP44eUFQc6DXtDqTJCpXvqN2xVanGOSfgXAI2tAO+k3vA4p73tTwg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@blend-capital/blend-sdk/-/blend-sdk-2.1.1.tgz", + "integrity": "sha512-cEP6rwXKl79rrjNb8jTYHhsL2gxHqBoVtHjj3oBo0+jEa0BnMUqDqd6vAr+eNBaydtRUqi+r6YCPE+kOfRn3UQ==", "license": "MIT", "dependencies": { - "@stellar/stellar-sdk": "12.2.0", + "@stellar/stellar-sdk": "12.3.0", "buffer": "6.0.3", "follow-redirects": ">=1.15.6" } }, "node_modules/@creit.tech/stellar-wallets-kit": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@creit.tech/stellar-wallets-kit/-/stellar-wallets-kit-1.2.1.tgz", - "integrity": "sha512-MHvA6kwXaOFIdbQiGcYGNtn6RICpIWpnzarkdEGJq7EQkR3Is5bgv4izfcWj62QDdYwB2PqaIc+oGC/WLL1yUg==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@creit.tech/stellar-wallets-kit/-/stellar-wallets-kit-1.2.3.tgz", + "integrity": "sha512-AM1fL/cQkI0i+lefJlViOPR4uxZrPDImbF+eCYST7FEIWYZrPsd/Mtne5qGVJDC6Umzdg9HqJt7CSFZTUJ2b3A==", "dependencies": { "@albedo-link/intent": "0.12.0", "@creit.tech/xbull-wallet-connect": "0.3.0", @@ -1514,9 +1514,9 @@ "license": "Apache-2.0" }, "node_modules/@stellar/stellar-base": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/@stellar/stellar-base/-/stellar-base-12.1.0.tgz", - "integrity": "sha512-pWwn+XWP5NotmIteZNuJzHeNn9DYSqH3lsYbtFUoSYy1QegzZdi9D8dK6fJ2fpBAnf/rcDjHgHOw3gtHaQFVbg==", + "version": "12.1.1", + "resolved": "https://registry.npmjs.org/@stellar/stellar-base/-/stellar-base-12.1.1.tgz", + "integrity": "sha512-gOBSOFDepihslcInlqnxKZdIW9dMUO1tpOm3AtJR33K2OvpXG6SaVHCzAmCFArcCqI9zXTEiSoh70T48TmiHJA==", "license": "Apache-2.0", "dependencies": { "@stellar/js-xdr": "^3.1.2", @@ -1531,13 +1531,13 @@ } }, "node_modules/@stellar/stellar-sdk": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@stellar/stellar-sdk/-/stellar-sdk-12.2.0.tgz", - "integrity": "sha512-Wy5sDOqb5JvAC76f4sQIV6Pe3JNyZb0PuyVNjwt3/uWsjtxRkFk6s2yTHTefBLWoR+mKxDjO7QfzhycF1v8FXQ==", + "version": "12.3.0", + "resolved": "https://registry.npmjs.org/@stellar/stellar-sdk/-/stellar-sdk-12.3.0.tgz", + "integrity": "sha512-F2DYFop/M5ffXF0lvV5Ezjk+VWNKg0QDX8gNhwehVU3y5LYA3WAY6VcCarMGPaG9Wdgoeh1IXXzOautpqpsltw==", "license": "Apache-2.0", "dependencies": { - "@stellar/stellar-base": "^12.1.0", - "axios": "^1.7.2", + "@stellar/stellar-base": "^12.1.1", + "axios": "^1.7.7", "bignumber.js": "^9.1.2", "eventsource": "^2.0.2", "randombytes": "^2.1.0", @@ -2358,7 +2358,8 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" }, "node_modules/atomic-sleep": { "version": "1.0.0", @@ -2393,9 +2394,9 @@ } }, "node_modules/axios": { - "version": "1.7.5", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.5.tgz", - "integrity": "sha512-fZu86yCo+svH3uqJ/yTdQ0QHpQu5oL+/QE+QPSv6BZSkDAoky9vytxp7u5qk83OJFS3kEBcesWni9WTZAv3tSw==", + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", @@ -2458,12 +2459,14 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "license": "MIT" }, "node_modules/bignumber.js": { "version": "9.1.2", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", + "license": "MIT", "engines": { "node": "*" } @@ -2518,6 +2521,7 @@ "url": "https://feross.org/support" } ], + "license": "MIT", "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.2.1" @@ -2706,6 +2710,7 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", "dependencies": { "delayed-stream": "~1.0.0" }, @@ -2935,6 +2940,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", "engines": { "node": ">=0.4.0" } @@ -3675,6 +3681,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-2.0.2.tgz", "integrity": "sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==", + "license": "MIT", "engines": { "node": ">=12.0.0" } @@ -3833,15 +3840,16 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.15.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", - "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", "funding": [ { "type": "individual", "url": "https://github.com/sponsors/RubenVerborgh" } ], + "license": "MIT", "engines": { "node": ">=4.0" }, @@ -3861,9 +3869,10 @@ } }, "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", + "license": "MIT", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -4258,7 +4267,8 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "license": "BSD-3-Clause" }, "node_modules/ignore": { "version": "5.3.1", @@ -5059,6 +5069,7 @@ "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", "engines": { "node": ">= 0.6" } @@ -5067,6 +5078,7 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", "dependencies": { "mime-db": "1.52.0" }, @@ -5264,9 +5276,9 @@ } }, "node_modules/node-gyp-build": { - "version": "4.8.1", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.1.tgz", - "integrity": "sha512-OSs33Z9yWr148JZcbZd5WiAXhh/n9z8TxQcdMhIOlpN9AhWpLfvVFO73+m77bBABQMaY9XSvIa+qk0jlI7Gcaw==", + "version": "4.8.2", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.2.tgz", + "integrity": "sha512-IRUxE4BVsHWXkV/SFOut4qTlagw2aM8T5/vnTsmrHJvVoKueJHRc/JaFND7QDDc61kLYUJ6qlZM3sqTSyx2dTw==", "license": "MIT", "optional": true, "bin": { @@ -5753,7 +5765,8 @@ "node_modules/proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" }, "node_modules/punycode": { "version": "2.3.1", @@ -5832,6 +5845,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "license": "MIT", "dependencies": { "safe-buffer": "^5.1.0" } @@ -6275,10 +6289,9 @@ } }, "node_modules/sodium-native": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-4.1.1.tgz", - "integrity": "sha512-LXkAfRd4FHtkQS4X6g+nRcVaN7mWVNepV06phIsC6+IZFvGh1voW5TNQiQp2twVaMf05gZqQjuS+uWLM6gHhNQ==", - "hasInstallScript": true, + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-4.2.1.tgz", + "integrity": "sha512-48X3PfRLW+f0fgb3J7f7mkZ9eBKcGR/bD5mdXXLAx4RWwKUe3095yPQgiUUQTfh8Q29JzwhSQATitQDBIozN/w==", "license": "MIT", "optional": true, "dependencies": { @@ -6926,7 +6939,8 @@ "node_modules/urijs": { "version": "1.19.11", "resolved": "https://registry.npmjs.org/urijs/-/urijs-1.19.11.tgz", - "integrity": "sha512-HXgFDgDommxn5/bIv0cnQZsPhHDA90NPHD6+c/v21U5+Sx5hoP8+dP9IZXBU1gIfvdRfhG8cel9QNPeionfcCQ==" + "integrity": "sha512-HXgFDgDommxn5/bIv0cnQZsPhHDA90NPHD6+c/v21U5+Sx5hoP8+dP9IZXBU1gIfvdRfhG8cel9QNPeionfcCQ==", + "license": "MIT" }, "node_modules/use-sync-external-store": { "version": "1.2.0", diff --git a/package.json b/package.json index 879e157..00f3b16 100644 --- a/package.json +++ b/package.json @@ -12,14 +12,14 @@ "lint": "next lint" }, "dependencies": { - "@blend-capital/blend-sdk": "2.0.4", - "@creit.tech/stellar-wallets-kit": "1.2.1", + "@blend-capital/blend-sdk": "2.1.1", + "@creit.tech/stellar-wallets-kit": "1.2.3", "@emotion/react": "^11.9.3", "@emotion/styled": "^11.9.3", "@mui/icons-material": "^5.8.4", "@mui/material": "^5.8.6", "@stellar/freighter-api": "^3.0.0", - "@stellar/stellar-sdk": "12.2.0", + "@stellar/stellar-sdk": "12.3.0", "@tanstack/react-query": "5.52.0", "copy-to-clipboard": "^3.3.3", "next": "^14.2.11", diff --git a/src/components/common/OverlayModal.tsx b/src/components/common/OverlayModal.tsx index ff013e5..2d4875a 100644 --- a/src/components/common/OverlayModal.tsx +++ b/src/components/common/OverlayModal.tsx @@ -1,5 +1,6 @@ -import { Box } from '@mui/material'; +import { Box, useTheme } from '@mui/material'; import { useRouter } from 'next/router'; +import { useEffect, useState } from 'react'; import { useSettings } from '../../contexts'; import { TxStatus, TxType, useWallet } from '../../contexts/wallet'; import { OverlayModalFail } from './OverlayModalFail'; @@ -12,9 +13,12 @@ export interface CloseableOverlayProps { export const OverlayModal: React.FC = () => { const router = useRouter(); + const theme = useTheme(); const { lastPool } = useSettings(); const { txStatus, txType, clearLastTx } = useWallet(); + const [showReturnButton, setShowReturnButton] = useState(false); + const display = txStatus !== TxStatus.NONE ? 'flex' : 'none'; const { poolId } = router.query; @@ -36,6 +40,22 @@ export const OverlayModal: React.FC = () => { } }; + useEffect(() => { + let timer: NodeJS.Timeout; + setShowReturnButton(false); + if (txStatus === TxStatus.BUILDING || txStatus === TxStatus.SIGNING) { + timer = setTimeout(() => { + setShowReturnButton(true); + }, 6000); + } + + return () => { + if (timer) { + clearTimeout(timer); + } + }; + }, [txStatus]); + if (txStatus === TxStatus.NONE) { return <>; } @@ -58,13 +78,25 @@ export const OverlayModal: React.FC = () => { }} > {txStatus === TxStatus.BUILDING && ( - + )} {txStatus === TxStatus.SIGNING && ( - + )} {txStatus === TxStatus.SUBMITTING && ( - + {}} + /> )} {txStatus === TxStatus.SUCCESS && } {txStatus === TxStatus.FAIL && } diff --git a/src/components/common/OverlayModalText.tsx b/src/components/common/OverlayModalText.tsx index 0778d73..862dcba 100644 --- a/src/components/common/OverlayModalText.tsx +++ b/src/components/common/OverlayModalText.tsx @@ -1,11 +1,19 @@ +import ArrowForwardIcon from '@mui/icons-material/ArrowForward'; import { Box, Typography, useTheme } from '@mui/material'; import CircularProgress from '@mui/material/CircularProgress'; +import { OpaqueButton } from './OpaqueButton'; export interface OverlayModalTextProps { message: string; + allowReturn: boolean; + handleCloseOverlay: () => void; } -export const OverlayModalText: React.FC = ({ message }) => { +export const OverlayModalText: React.FC = ({ + message, + allowReturn, + handleCloseOverlay, +}) => { const theme = useTheme(); return ( @@ -38,6 +46,25 @@ export const OverlayModalText: React.FC = ({ message }) = {message} + {allowReturn && ( + + + Return + + + + + + )} ); diff --git a/src/contexts/wallet.tsx b/src/contexts/wallet.tsx index 2f224cc..df900a9 100644 --- a/src/contexts/wallet.tsx +++ b/src/contexts/wallet.tsx @@ -20,6 +20,10 @@ import { XBULL_ID, xBullModule, } from '@creit.tech/stellar-wallets-kit/index'; +import { + WalletConnectAllowedMethods, + WalletConnectModule, +} from '@creit.tech/stellar-wallets-kit/modules/walletconnect.module'; import { getNetworkDetails as getFreighterNetwork } from '@stellar/freighter-api'; import { Asset, @@ -117,6 +121,28 @@ export enum TxType { PREREQ, } +const walletKit: StellarWalletsKit = new StellarWalletsKit({ + network: (process.env.NEXT_PUBLIC_PASSPHRASE ?? WalletNetwork.TESTNET) as WalletNetwork, + selectedWalletId: XBULL_ID, + modules: [ + new xBullModule(), + new FreighterModule(), + new LobstrModule(), + new AlbedoModule(), + new WalletConnectModule({ + url: process.env.NEXT_PUBLIC_WALLET_CONNECT_URL ?? '', + projectId: 'a0fd1483122937b5cabbe0d85fa9c34e', + method: WalletConnectAllowedMethods.SIGN, + description: `Blend is a liquidity protocol primitive, enabling the creation of money markets for any use case.`, + name: process.env.NEXT_PUBLIC_WALLET_CONNECT_NAME ?? '', + icons: [ + 'https://docs.blend.capital/~gitbook/image?url=https%3A%2F%2F3627113658-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FlsteMPgIzWJ2y9ruiTJy%252Fuploads%252FVsvCoCALpHWAw8LpU12e%252FBlend%2520Logo%25403x.png%3Falt%3Dmedia%26token%3De8c06118-43b7-4ddd-9580-6c0fc47ce971&width=768&dpr=2&quality=100&sign=f4bb7bc2&sv=1', + ], + network: (process.env.NEXT_PUBLIC_PASSPHRASE ?? WalletNetwork.TESTNET) as WalletNetwork, + }), + ], +}); + const WalletContext = React.createContext(undefined); export const WalletProvider = ({ children = null as any }) => { @@ -137,16 +163,16 @@ export const WalletProvider = ({ children = null as any }) => { // wallet state const [walletAddress, setWalletAddress] = useState(''); - const walletKit: StellarWalletsKit = new StellarWalletsKit({ - network: network.passphrase as WalletNetwork, - selectedWalletId: autoConnect !== undefined && autoConnect !== 'false' ? autoConnect : XBULL_ID, - modules: [new xBullModule(), new FreighterModule(), new LobstrModule(), new AlbedoModule()], - }); - useEffect(() => { - if (!connected && autoConnect !== 'false') { + if ( + !connected && + autoConnect !== undefined && + autoConnect !== 'false' && + autoConnect !== 'wallet_connect' + ) { // @dev: timeout ensures chrome has the ability to load extensions setTimeout(() => { + walletKit.setWallet(autoConnect); handleSetWalletAddress(); }, 750); } @@ -645,8 +671,10 @@ export const WalletProvider = ({ children = null as any }) => { cleanWalletCache(); } } - } catch (e) { + } catch (e: any) { console.error('Failed to create trustline: ', e); + setFailureMessage(e?.message); + setTxStatus(TxStatus.FAIL); } } From 6c550f60f57e68711393b120128909049e583e6e Mon Sep 17 00:00:00 2001 From: mootz12 Date: Wed, 30 Oct 2024 11:22:34 -0400 Subject: [PATCH 2/2] chore: rev version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index a86ef84..4cd7ab6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "blend-ui", - "version": "1.1.5", + "version": "1.1.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "blend-ui", - "version": "1.1.5", + "version": "1.1.6", "dependencies": { "@blend-capital/blend-sdk": "2.1.1", "@creit.tech/stellar-wallets-kit": "1.2.3", diff --git a/package.json b/package.json index 00f3b16..c4b7199 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blend-ui", - "version": "1.1.5", + "version": "1.1.6", "private": true, "type": "module", "scripts": {