Skip to content
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

Use latest-transaction endpoint in DW #1000

Draft
wants to merge 3 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/desktop-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
"@alephium/shared-react": "workspace:*",
"@alephium/token-list": "^0.0.19",
"@alephium/typescript-config": "workspace:*",
"@alephium/walletconnect-provider": "1.5.1",
"@alephium/web3": "1.5.1",
"@alephium/web3-wallet": "1.5.1",
"@alephium/walletconnect-provider": "1.9.0",
"@alephium/web3": "1.9.0",
"@alephium/web3-wallet": "1.9.0",
"@electron/notarize": "^1.2.3",
"@json-rpc-tools/utils": "^1.7.6",
"@reduxjs/toolkit": "^1.9.1",
Expand Down
8 changes: 2 additions & 6 deletions apps/desktop-wallet/src/api/queries/transactionQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,14 @@ export const addressLatestTransactionQuery = ({ addressHash, networkId, skip }:
queryFn:
!skip && networkId !== undefined
? async ({ queryKey }) => {
const transactions = await throttledClient.explorer.addresses.getAddressesAddressTransactions(addressHash, {
page: 1,
limit: 1
})
const latestTx = await throttledClient.explorer.addresses.getAddressesAddressLatestTransaction(addressHash)

const latestTx = transactions.length > 0 ? transactions[0] : undefined
const cachedData = queryClient.getQueryData(queryKey) as AddressLatestTransactionQueryFnData | undefined
const cachedLatestTx = cachedData?.latestTx

// The following block invalidates queries that need to refetch data if a new transaction hash has been
// detected. This way, we don't need to use the latest tx hash in the queryKey of each of those queries.
if (latestTx !== undefined && latestTx.hash !== cachedLatestTx?.hash) {
if (latestTx?.hash && latestTx.hash !== cachedLatestTx?.hash) {
queryClient.invalidateQueries({ queryKey: ['address', addressHash, 'balance'] })
queryClient.invalidateQueries({ queryKey: ['wallet', 'transactions', 'latest'] })
}
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@alephium/shared-crypto": "workspace:*",
"@alephium/shared-react": "workspace:*",
"@alephium/token-list": "^0.0.19",
"@alephium/web3": "1.5.1",
"@alephium/web3": "1.9.0",
"@tanstack/query-sync-storage-persister": "5.45.0",
"@tanstack/react-query": "5.45.0",
"@tanstack/react-query-persist-client": "^5.45.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"@alephium/shared-crypto": "workspace:*",
"@alephium/shared-react": "workspace:*",
"@alephium/token-list": "^0.0.19",
"@alephium/walletconnect-provider": "1.5.1",
"@alephium/web3": "1.5.1",
"@alephium/walletconnect-provider": "1.9.0",
"@alephium/web3": "1.9.0",
"@expo/vector-icons": "^14.0.4",
"@json-rpc-tools/utils": "^1.7.6",
"@react-native-async-storage/async-storage": "1.23.1",
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile-wallet/src/contexts/SendContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import { getTransactionAssetAmounts } from '~/utils/transactions'

type UnsignedTxData = {
unsignedTxs: {
txId: node.BuildTransactionResult['txId'] | node.SweepAddressTransaction['txId']
unsignedTx: node.BuildTransactionResult['unsignedTx'] | node.SweepAddressTransaction['unsignedTx']
txId: node.BuildTransferTxResult['txId'] | node.SweepAddressTransaction['txId']
unsignedTx: node.BuildTransferTxResult['unsignedTx'] | node.SweepAddressTransaction['unsignedTx']
}[]
fees: bigint
}
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile-wallet/src/types/walletConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
import {
BuildDeployContractTxResult,
BuildExecuteScriptTxResult,
BuildTransactionResult,
BuildTransferTxResult,
DecodeUnsignedTxResult
} from '@alephium/web3/dist/src/api/api-alephium'

Expand All @@ -35,7 +35,7 @@ export type SessionRequestData =
| {
type: 'transfer'
wcData: TransferTxData
unsignedTxData: BuildTransactionResult
unsignedTxData: BuildTransferTxResult
}
| {
type: 'call-contract'
Expand Down
2 changes: 1 addition & 1 deletion packages/keyring/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dependencies": {
"@alephium/encryptor": "workspace:*",
"@alephium/shared": "workspace:*",
"@alephium/web3": "1.5.1",
"@alephium/web3": "1.9.0",
"@metamask/scure-bip39": "^2.1.1",
"blakejs": "^1.1.1",
"ethereum-cryptography": "^2.1.3"
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
},
"dependencies": {
"@alephium/token-list": "^0.0.19",
"@alephium/walletconnect-provider": "1.5.1",
"@alephium/web3": "1.5.1",
"@alephium/walletconnect-provider": "1.9.0",
"@alephium/web3": "1.9.0",
"@metamask/scure-bip39": "^2.1.1",
"@reduxjs/toolkit": "^1.9.1",
"@walletconnect/sign-client": "2.15.1",
Expand Down
60 changes: 30 additions & 30 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.