poc: solana#252
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Example of what using providers + context allow us. We can test the TransferPanel with connected state, display of balance, execution, etc...
There was a problem hiding this comment.
We get fetchers from Solana/EVM context and return fetcher based on the chainId
There was a problem hiding this comment.
We get signer from Solana/EVM context and return both signer (source and destination).
This allow us to claim without switching networks.
There was a problem hiding this comment.
Context with balance fetching (EVM)
There was a problem hiding this comment.
Context with balance fetching (Solana)
There was a problem hiding this comment.
Context with signer (EVM)
There was a problem hiding this comment.
Context with signer (Solana)
1207db7 to
13321c6
Compare
| DisabledFeatures.TRANSFERS_TO_NON_ARBITRUM_CHAINS, | ||
| ); | ||
|
|
||
| const shouldDisableConnectedChainSync = isSolanaEnabled(); |
There was a problem hiding this comment.
How is this going to work once the feature is shipped? Is it gonna break existing behavior for EVM chains?
| const provider = new providers.Web3Provider(walletProvider); | ||
| const signer = provider.getSigner(); |
There was a problem hiding this comment.
Ideally we'd use useSendTransaction from Wagmi
| }; | ||
|
|
||
| export class SolanaTransferStarter { | ||
| public async transfer({ |
There was a problem hiding this comment.
Ideally we'd eventually refactor the TransferStarter objects to just prepare transaction requests, and handle signing outside. So maybe some of the code that is currently in packages/arb-token-bridge-ui/src/wallet/providers/SolanaSignerProvider.tsx is moved here?
| try { | ||
| const { transactionRequest } = await getStepTransaction(selectedRoute.protocolData.step); | ||
|
|
||
| if (sourceWallet.account.chain?.id !== sourceChainId) { | ||
| await switchChain(wagmiConfig, { chainId: sourceChainId }); | ||
| } | ||
|
|
||
| const transferStarter = | ||
| sourceWallet.ecosystem === 'solana' ? SolanaTransferStarter : LifiTransferStarter; | ||
| const preparedTransaction = transferStarter.prepareTransaction(transactionRequest); | ||
| const result = await sourceWallet.sendTransaction(preparedTransaction); | ||
|
|
||
| setTransactionHash(result.hash); | ||
| await result.wait?.(); | ||
| } catch (error) { | ||
| setExecutionError(getErrorMessage(error)); | ||
| } finally { | ||
| setIsExecuting(false); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Ideally, we would create a BridgeTransferStarterFactory and it would return the correct transferStarter. Then sendTransaction take the prepared transaction, whether it's solana or evm
Depends on #251. This PR is part of a stack created with Aviator.
masterSummary
Steps to test