Skip to content

Commit

Permalink
Update @alephium/web3 to 0.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Lbqds committed Oct 27, 2023
1 parent 0baa915 commit fdee7df
Show file tree
Hide file tree
Showing 17 changed files with 1,264 additions and 1,115 deletions.
314 changes: 167 additions & 147 deletions bridge_ui/package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions bridge_ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"private": true,
"dependencies": {
"@alephium/token-list": "0.0.11",
"@alephium/web3": "^0.18.2",
"@alephium/web3-react": "^0.18.2",
"@alephium/wormhole-sdk": "0.1.2",
"@alephium/web3": "^0.22.0",
"@alephium/web3-react": "^0.22.0",
"@alephium/wormhole-sdk": "0.2.0",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",
Expand Down
12 changes: 3 additions & 9 deletions bridge_ui/src/components/AlephiumWalletKey.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { ALEPHIUM_BRIDGE_GROUP_INDEX, CLUSTER } from "../utils/consts";
import ToggleConnectedButton from "./ToggleConnectedButton";
import { AlephiumConnectButton, useConnect } from "@alephium/web3-react"
import { AlephiumConnectButton } from "@alephium/web3-react"

const AlephiumWalletKey = () => {
const { disconnect } = useConnect({
addressGroup: ALEPHIUM_BRIDGE_GROUP_INDEX,
networkId: CLUSTER
})

return (
<AlephiumConnectButton.Custom displayAccount={(account) => account.address}>
{({ isConnected, show, address }) => {
{({ isConnected, show, disconnect, account }) => {
return (
// `show` and `hide` will never be undefined. TODO: Fix the types in web3-react
<ToggleConnectedButton connect={show!} disconnect={disconnect} connected={isConnected} pk={address ?? ''} />
<ToggleConnectedButton connect={show!} disconnect={disconnect} connected={isConnected} pk={account?.address ?? ''} />
)
}}
</AlephiumConnectButton.Custom>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function AlephiumTokenPicker(props: AlephiumTokenPickerProps) {

const getAddress: (address: string, tokenId?: string) => Promise<ParsedTokenAccount> = useCallback(
async (address: string, tokenId?: string) => {
if (isReady && alphWallet) {
if (isReady && alphWallet.connectionStatus === 'connected') {
try {
const contractId = tryGetContractId(address)
const tokenInfo = await getLocalTokenInfo(web3.getCurrentNodeProvider(), contractId)
Expand Down
6 changes: 4 additions & 2 deletions bridge_ui/src/components/Transactions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ export default function Transactions() {

const blockNumberFetcherGetter = useCallback((chainId: ChainId) => {
if (chainId === CHAIN_ID_ALEPHIUM) {
return alphWallet === undefined ? undefined : () => alphBlockNumberFetcher(alphWallet.nodeProvider, alphWallet.account.group)
return alphWallet.connectionStatus !== 'connected'
? undefined
: () => alphBlockNumberFetcher(alphWallet.nodeProvider, alphWallet.account.group)
}
if (bothAreEvmChain) {
if (chainId === txSourceChain && sourceChainReady) {
Expand All @@ -230,7 +232,7 @@ export default function Transactions() {
const targetChainBlockNumber = useBlockNumber(blockNumberFetcherGetter, txTargetChain)

const getIsTxsCompleted = useCallback(async (txs: BridgeTransaction[]) => {
if (txTargetChain === CHAIN_ID_ALEPHIUM && alphWallet) {
if (txTargetChain === CHAIN_ID_ALEPHIUM && alphWallet.connectionStatus === 'connected') {
const tokenBridgeForChainId = getTokenBridgeForChainId(ALEPHIUM_TOKEN_BRIDGE_CONTRACT_ID, txSourceChain, alphWallet.account.group)
return await getIsTxsCompletedAlph(tokenBridgeForChainId, txs.map((t) => BigInt(t.sequence)))
}
Expand Down
2 changes: 1 addition & 1 deletion bridge_ui/src/components/Transfer/AddToAlephium.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function AddToAlephium() {
})(alphWallet.nodeProvider)
}
}, [alphWallet, targetAsset, enqueueSnackbar])
return alphWallet !== undefined && isExtensionWallet(alphWallet.signer) ? (
return alphWallet.connectionStatus === 'connected' && isExtensionWallet(alphWallet.signer) ? (
<Button
onClick={handleClick}
size="small"
Expand Down
2 changes: 1 addition & 1 deletion bridge_ui/src/hooks/useGetIsTransferCompleted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default function useGetIsTransferCompleted(
setIsLoading(false);
}
})();
} else if (targetChain === CHAIN_ID_ALEPHIUM && !!alphWallet) {
} else if (targetChain === CHAIN_ID_ALEPHIUM && alphWallet.connectionStatus === 'connected') {
setIsLoading(true);
(async () => {
try {
Expand Down
2 changes: 1 addition & 1 deletion bridge_ui/src/hooks/useGetTargetParsedTokenAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function useGetTargetParsedTokenAccounts() {
}
let cancelled = false;

if (targetChain === CHAIN_ID_ALEPHIUM && !!alphWallet) {
if (targetChain === CHAIN_ID_ALEPHIUM && alphWallet.connectionStatus === 'connected') {
if (!cancelled && decimals !== undefined) {
const balanceStr = balance?.toString() || '0'
const uiAmount = formatUnits(balanceStr, decimals)
Expand Down
2 changes: 1 addition & 1 deletion bridge_ui/src/hooks/useSyncTargetAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function useSyncTargetAddress(shouldFire: boolean, nft?: boolean) {
)
)
);
} else if(targetChain === CHAIN_ID_ALEPHIUM && alphWallet) {
} else if(targetChain === CHAIN_ID_ALEPHIUM && alphWallet.connectionStatus === 'connected') {
dispatch(setTargetAddressHex(uint8ArrayToHex(base58.decode(alphWallet.account.address))))
} else if (targetChain === CHAIN_ID_ALGORAND && algoAccounts[0]) {
dispatch(
Expand Down
Loading

0 comments on commit fdee7df

Please sign in to comment.