Update to SDK 1.3.4

Use maxBlockAge value in HyperlaneJsonRpcProvider
pull/35/head
J M Rossy 2 years ago
parent b30acac4b3
commit 1eb60a022d
  1. 2
      package.json
  2. 1
      src/features/debugger/debugMessage.ts
  3. 3
      src/features/messages/pi-queries/fetchPiChainMessages.test.ts
  4. 22
      src/features/providers/HyperlaneJsonRpcProvider.ts
  5. 4
      src/features/providers/SmartProvider.test.ts
  6. 1
      src/features/providers/SmartProvider.ts
  7. 22
      src/features/providers/multiProvider.ts
  8. 32
      yarn.lock

@ -5,7 +5,7 @@
"author": "J M Rossy",
"dependencies": {
"@headlessui/react": "^1.7.11",
"@hyperlane-xyz/sdk": "1.3.3",
"@hyperlane-xyz/sdk": "1.3.4",
"@hyperlane-xyz/widgets": "1.3.3",
"@metamask/jazzicon": "https://github.com/jmrossy/jazzicon#7a8df28974b4e81129bfbe3cab76308b889032a6",
"@rainbow-me/rainbowkit": "^0.11.0",

@ -251,7 +251,6 @@ async function fetchTransactionDetails(
chainName: ChainName,
) {
const provider = multiProvider.getProvider(chainName);
// TODO explorer may be faster, more robust way to get tx and its logs
// Note: receipt is null if tx not found
const transactionReceipt = await provider.getTransactionReceipt(txHash);
if (transactionReceipt) {

@ -13,9 +13,10 @@ import { fetchMessagesFromPiChain } from './fetchPiChainMessages';
jest.setTimeout(30000);
const goerliMailbox = hyperlaneEnvironments.testnet.goerli.mailbox;
const goerliIgp = hyperlaneEnvironments.testnet.goerli.interchainGasPaymaster;
const goerliConfigWithExplorer: ChainConfig = {
...chainMetadata.goerli,
contracts: { mailbox: goerliMailbox },
contracts: { mailbox: goerliMailbox, interchainGasPaymaster: goerliIgp },
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { blockExplorers, ...goerliConfigNoExplorer } = goerliConfigWithExplorer;

@ -37,10 +37,9 @@ export class HyperlaneJsonRpcProvider
if (!paginationOptions || !params.filter) return superPerform();
const { fromBlock, toBlock, address, topics } = params.filter;
// TODO update when sdk is updated
const { blocks: maxBlockRange, from: minBlockNumber } = paginationOptions;
const { maxBlockRange, minBlockNumber, maxBlockAge } = paginationOptions;
if (!maxBlockRange && isNullish(minBlockNumber)) return superPerform();
if (!maxBlockRange && !maxBlockAge && isNullish(minBlockNumber)) return superPerform();
const currentBlockNumber = await super.perform(ProviderMethod.GetBlockNumber, null);
@ -66,14 +65,21 @@ export class HyperlaneJsonRpcProvider
logger.warn(`Start block ${startBlock} greater than end block. Using ${endBlock} instead`);
startBlock = endBlock;
}
const minQueryable = maxBlockRange
const minForBlockRange = maxBlockRange
? endBlock - maxBlockRange * NUM_LOG_BLOCK_RANGES_TO_QUERY + 1
: 0;
if (startBlock < minQueryable) {
logger.warn(`Start block ${startBlock} requires too many queries, using ${minQueryable}.`);
startBlock = minQueryable;
if (startBlock < minForBlockRange) {
logger.warn(
`Start block ${startBlock} requires too many queries, using ${minForBlockRange}.`,
);
startBlock = minForBlockRange;
}
const minForBlockAge = maxBlockAge ? currentBlockNumber - maxBlockAge : 0;
if (startBlock < minForBlockAge) {
logger.warn(`Start block ${startBlock} below max block age, increasing to ${minForBlockAge}`);
startBlock = minForBlockAge;
}
if (startBlock < minBlockNumber) {
if (minBlockNumber && startBlock < minBlockNumber) {
logger.warn(`Start block ${startBlock} below config min, increasing to ${minBlockNumber}`);
startBlock = minBlockNumber;
}

@ -19,8 +19,8 @@ const TRANSFER_TX_HASH = '0x45a586f90ffd5d0f8e618f0f3703b14c2c9e4611af6231d6fed3
const goerliRpcConfig = {
...chainMetadata.goerli.publicRpcUrls[0],
pagination: {
blocks: 1000,
from: MIN_BLOCK_NUM,
maxBlockRange: 1000,
minBlockNumber: MIN_BLOCK_NUM,
},
};
const justExplorersConfig: ChainMetadata = { ...chainMetadata.goerli, publicRpcUrls: [] };

@ -154,7 +154,6 @@ function chainMetadataToProviderNetwork(chainMetadata: ChainMetadata): providers
return {
name: chainMetadata.name,
chainId: chainMetadata.chainId,
// @ts-ignore TODO remove when SDK updated
ensAddress: chainMetadata.ensAddress,
};
}

@ -1,12 +1,6 @@
import { useMemo } from 'react';
import {
ChainName,
CoreChainName,
MultiProvider,
TestChains,
chainMetadata,
} from '@hyperlane-xyz/sdk';
import { ChainName, MultiProvider, chainMetadata } from '@hyperlane-xyz/sdk';
import { useChainConfigsWithQueryParams } from '../chains/useChainConfigs';
@ -19,19 +13,11 @@ export class SmartMultiProvider extends MultiProvider {
if (!metadata) return null;
const { name, publicRpcUrls, blockExplorers } = metadata;
// TODO fix when sdk is updated
const providers = this['providers'];
if (providers[name]) return providers[name];
if (TestChains.includes(name as CoreChainName)) {
providers[name] = new providers.JsonRpcProvider('http://localhost:8545', 31337);
} else if (publicRpcUrls?.length || blockExplorers?.length) {
providers[name] = new HyperlaneSmartProvider(metadata);
} else {
return null;
if (!this.providers[name] && (publicRpcUrls?.length || blockExplorers?.length)) {
this.providers[name] = new HyperlaneSmartProvider(metadata);
}
return providers[name];
return (this.providers[name] as HyperlaneSmartProvider) || null;
}
}

@ -1294,14 +1294,14 @@ __metadata:
languageName: node
linkType: hard
"@hyperlane-xyz/core@npm:1.3.3":
version: 1.3.3
resolution: "@hyperlane-xyz/core@npm:1.3.3"
"@hyperlane-xyz/core@npm:1.3.4":
version: 1.3.4
resolution: "@hyperlane-xyz/core@npm:1.3.4"
dependencies:
"@hyperlane-xyz/utils": 1.3.3
"@hyperlane-xyz/utils": 1.3.4
"@openzeppelin/contracts": ^4.8.0
"@openzeppelin/contracts-upgradeable": ^4.8.0
checksum: d21ede2e49e1152c518c7c89ff1c19811ae3eb78aaacf02dd7db028cbcc436b25bc39c77e2c93d7a08790dd32f5f9f921de4e0e0fccf0a1c8b8a7285cab18e01
checksum: aaea49039a37dc093fb785ba79480be28a41b62936dd2910ac25fbe07e8275ea6a1f8f477e0872c8d5880dede24e2fb5bce5f0153626a36113de18578e4032f7
languageName: node
linkType: hard
@ -1310,7 +1310,7 @@ __metadata:
resolution: "@hyperlane-xyz/explorer@workspace:."
dependencies:
"@headlessui/react": ^1.7.11
"@hyperlane-xyz/sdk": 1.3.3
"@hyperlane-xyz/sdk": 1.3.4
"@hyperlane-xyz/widgets": 1.3.3
"@metamask/jazzicon": "https://github.com/jmrossy/jazzicon#7a8df28974b4e81129bfbe3cab76308b889032a6"
"@rainbow-me/rainbowkit": ^0.11.0
@ -1349,12 +1349,12 @@ __metadata:
languageName: unknown
linkType: soft
"@hyperlane-xyz/sdk@npm:1.3.3":
version: 1.3.3
resolution: "@hyperlane-xyz/sdk@npm:1.3.3"
"@hyperlane-xyz/sdk@npm:1.3.4":
version: 1.3.4
resolution: "@hyperlane-xyz/sdk@npm:1.3.4"
dependencies:
"@hyperlane-xyz/core": 1.3.3
"@hyperlane-xyz/utils": 1.3.3
"@hyperlane-xyz/core": 1.3.4
"@hyperlane-xyz/utils": 1.3.4
"@types/coingecko-api": ^1.0.10
"@types/debug": ^4.1.7
"@wagmi/chains": ^0.2.6
@ -1363,16 +1363,16 @@ __metadata:
debug: ^4.3.4
ethers: ^5.7.2
zod: ^3.21.2
checksum: c54f9fc6b6ae93f00651d345591cf2945b8a3516b15b6f7a649b210abc1ed3c0725bbc80a0d2d5240cbe988bb21b10f7bb1f0c13348d3d3e2c4c1e2fe856c093
checksum: c881b51ea1e0aada4cf12a485a0b614ee0fbb6095941c63ec0ba7bc41a59b29e7a05498ab8ac3e89a50430b2973218dece6f2cbd09fd8697bead49be99b3663a
languageName: node
linkType: hard
"@hyperlane-xyz/utils@npm:1.3.3":
version: 1.3.3
resolution: "@hyperlane-xyz/utils@npm:1.3.3"
"@hyperlane-xyz/utils@npm:1.3.4":
version: 1.3.4
resolution: "@hyperlane-xyz/utils@npm:1.3.4"
dependencies:
ethers: ^5.7.2
checksum: 1141ff5f8c7559f8727c63782b37cf0f9444942e3f48059fad7dde533b160137a15bcfcc9f590ae3ee56faf33b1da4f7c99f8d32134792acd94c41fc235f19c1
checksum: 7bed3465604dd3e20d31ebc2b4d101cfe6a934df9d0625a11e9fb5dfa39dbd009c1fc4ad269a32662d4c4a3abadacf5195f53462be021494ba15896036a53f7a
languageName: node
linkType: hard

Loading…
Cancel
Save