-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add safe wallet support #77
Changes from all commits
a03fda3
a4defde
ca3d2ef
6649037
bc8663d
1cecf9b
e3e6ff7
4b57e5f
be9be5a
c57fa93
4c3cb0a
6f3cb59
e3e1e18
a1d6ea9
3ad6177
1baf049
b27dd59
60de9e7
3b47f5e
4da45e1
af4085b
d681b54
3c0b635
457c91a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16.18.1 | ||
18 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
module.exports = {}; | ||
module.exports = { | ||
// pino throw error during yarn build, | ||
// see https://github.com/WalletConnect/walletconnect-monorepo/issues/1908#issuecomment-1487801131 | ||
webpack: (config, context) => { | ||
if (config.plugins) { | ||
config.plugins.push( | ||
new context.webpack.IgnorePlugin({ | ||
resourceRegExp: /^(lokijs|pino-pretty|encoding)$/, | ||
}), | ||
); | ||
} | ||
return config; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,23 @@ import { | |
} from '@arbitrum/sdk'; | ||
import { Inbox__factory } from '@arbitrum/sdk/dist/lib/abi/factories/Inbox__factory'; | ||
import { getBaseFee } from '@arbitrum/sdk/dist/lib/utils/lib'; | ||
import { useNetwork, useSigner } from 'wagmi'; | ||
import { goerli, mainnet, sepolia, useNetwork, useSigner } from 'wagmi'; | ||
import { getProviderFromChainId, getTargetChainId } from '@/utils'; | ||
import { BigNumber } from 'ethers'; | ||
import { ChainId } from '@/utils/network'; | ||
import { useAccountType } from '@/utils/useAccountType'; | ||
|
||
function getL1ChainIdFromL2ChainId(l2ChainId: number | undefined) { | ||
if (!l2ChainId) { | ||
return ChainId.Mainnet; | ||
} | ||
|
||
return { | ||
[ChainId.ArbitrumOne]: ChainId.Mainnet, | ||
[ChainId.ArbitrumGoerli]: ChainId.Goerli, | ||
[ChainId.ArbitrumSepolia]: ChainId.Sepolia, | ||
}[l2ChainId]; | ||
} | ||
|
||
function RecoverFundsButton({ | ||
balanceToRecover, | ||
|
@@ -25,8 +39,12 @@ function RecoverFundsButton({ | |
}) { | ||
const [message, setMessage] = useState(''); | ||
const [loading, setLoading] = useState(false); | ||
const { isSmartContractWallet, isLoading: isLoadingAccountType } = | ||
useAccountType(); | ||
const { chain } = useNetwork(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this the connected chain or the first chain from the config?? i'm slightly confused about this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. useNetwork return the currently connected chain https://1.x.wagmi.sh/react/hooks/useNetwork |
||
const { data: signer } = useSigner({ chainId: chain?.id }); | ||
const { data: signer } = useSigner({ | ||
chainId: getL1ChainIdFromL2ChainId(chainID), | ||
}); | ||
|
||
const handleRecover = useCallback(async () => { | ||
if (!signer) { | ||
|
@@ -45,10 +63,7 @@ function RecoverFundsButton({ | |
setLoading(true); | ||
setMessage(''); | ||
|
||
// We instantiate the Inbox factory object to make use of its methods | ||
const targetChainID = getTargetChainId(chainID); | ||
|
||
const baseL2Provider = getProviderFromChainId(targetChainID); | ||
const baseL2Provider = getProviderFromChainId(chainID); | ||
const l2Network = await getL2Network(baseL2Provider); | ||
const inbox = Inbox__factory.connect( | ||
l2Network.ethBridge.inbox, | ||
|
@@ -143,26 +158,47 @@ function RecoverFundsButton({ | |
|
||
if (!signer) return null; | ||
|
||
if (chain?.id !== 1 && chain?.id !== 5) { | ||
if ( | ||
chain?.id !== mainnet.id && | ||
chain?.id !== goerli.id && | ||
chain?.id !== sepolia.id | ||
) { | ||
return ( | ||
<div>Unknown L1 chain id. This chain is not supported by this tool</div> | ||
); | ||
} | ||
|
||
if (chain?.id !== chainID) { | ||
if (getTargetChainId(chain?.id) !== chainID) { | ||
return ( | ||
<div> | ||
To recover funds, connect to chain ${chain?.id} (${chain?.name}) | ||
To recover funds, connect to chain {chain?.id} ({chain?.name}) | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<div className="recover-funds-form"> | ||
<button id="recover-button" disabled={loading} onClick={handleRecover}> | ||
Recover | ||
</button> | ||
<div> | ||
<button | ||
className="button" | ||
id="recover-button" | ||
disabled={loading} | ||
onClick={handleRecover} | ||
> | ||
Recover | ||
</button> | ||
</div> | ||
{loading && isSmartContractWallet && !isLoadingAccountType && ( | ||
<div className="flex flex-col"> | ||
<span> | ||
<b> | ||
To continue, please approve tx on your smart contract wallet. | ||
</b>{' '} | ||
If you have k of n signers, then k of n will need to sign. | ||
</span> | ||
</div> | ||
Comment on lines
+193
to
+200
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: text appear aligned to the left, not centered like the rest of the texts |
||
)} | ||
</div> | ||
<div> | ||
{message && ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix error in building for nextjs: WalletConnect/walletconnect-monorepo#1908 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
best if we add a link to this in the file