Skip to content

Commit

Permalink
chore: Upgrade Viem and Solana Web3 (#4821)
Browse files Browse the repository at this point in the history
### Description

- Breaking change: Upgrade Viem from 1.x to 2.2
- Upgrade Solana Web3 to 1.9
- Upgrade Solana SPL Token to 0.4.9

### Related issues

Required for
hyperlane-xyz/hyperlane-warp-ui-template#173


### Backward compatibility

No

### Testing

Tested EVM and Solana wallet connections and transfers in the Warp UI.
See hyperlane-xyz/hyperlane-warp-ui-template#315
  • Loading branch information
jmrossy authored Nov 6, 2024
1 parent 8360602 commit f48cf87
Show file tree
Hide file tree
Showing 8 changed files with 354 additions and 157 deletions.
7 changes: 7 additions & 0 deletions .changeset/empty-needles-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@hyperlane-xyz/utils': major
'@hyperlane-xyz/sdk': major
---

Upgrade Viem to 2.2 and Solana Web3 to 1.9
Rename `chainMetadataToWagmiChain` to `chainMetadataToViemChain`
2 changes: 1 addition & 1 deletion typescript/infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@safe-global/api-kit": "1.3.0",
"@safe-global/protocol-kit": "1.3.0",
"@safe-global/safe-core-sdk-types": "2.3.0",
"@solana/web3.js": "^1.78.0",
"@solana/web3.js": "^1.95.4",
"asn1.js": "5.4.1",
"aws-kms-ethers-signer": "^0.1.3",
"deep-object-diff": "^1.1.9",
Expand Down
7 changes: 3 additions & 4 deletions typescript/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
"@safe-global/api-kit": "1.3.0",
"@safe-global/protocol-kit": "1.3.0",
"@safe-global/safe-deployments": "1.37.8",
"@solana/spl-token": "^0.3.8",
"@solana/web3.js": "^1.78.0",
"@wagmi/chains": "^1.8.0",
"@solana/spl-token": "^0.4.9",
"@solana/web3.js": "^1.95.4",
"bignumber.js": "^9.1.1",
"coingecko-api-v3": "^0.0.29",
"cosmjs-types": "^0.9.0",
"cross-fetch": "^3.1.5",
"ethers": "^5.7.2",
"pino": "^8.19.0",
"viem": "^1.20.0",
"viem": "^2.21.40",
"zod": "^3.21.2"
},
"devDependencies": {
Expand Down
20 changes: 10 additions & 10 deletions typescript/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export {
export { HyperlaneProxyFactoryDeployer } from './deploy/HyperlaneProxyFactoryDeployer.js';
export {
CheckerViolation,
OwnableConfig,
DeployedOwnableConfig,
OwnableConfig,
OwnerViolation,
ProxyAdminViolation,
ViolationType,
Expand Down Expand Up @@ -197,11 +197,11 @@ export {
export {
BlockExplorer,
BlockExplorerSchema,
EthJsonRpcBlockParameterTag,
ChainMetadata,
ChainMetadataSchema,
ChainMetadataSchemaObject,
ChainTechnicalStack,
EthJsonRpcBlockParameterTag,
ExplorerFamily,
ExplorerFamilyValue,
NativeToken,
Expand Down Expand Up @@ -390,12 +390,12 @@ export {
MailboxClientConfig as ConnectionClientConfig,
ClientViolation as ConnectionClientViolation,
ClientViolationType as ConnectionClientViolationType,
DestinationGas,
GasRouterConfig,
MailboxClientConfig,
ProxiedFactories,
ProxiedRouterConfig,
RemoteRouters,
DestinationGas,
RouterAddress,
RouterConfig,
RouterViolation,
Expand Down Expand Up @@ -448,9 +448,9 @@ export { HypERC20Checker } from './token/checker.js';
export { TokenType } from './token/config.js';
export {
HypERC20Factories,
hypERC20contracts,
HypERC721Factories,
TokenFactories,
hypERC20contracts,
hypERC20factories,
} from './token/contracts.js';
export { HypERC20Deployer, HypERC721Deployer } from './token/deploy.js';
Expand Down Expand Up @@ -499,7 +499,7 @@ export {
getSealevelAccountDataSchema,
} from './utils/sealevelSerialization.js';
export { getChainIdFromTxs } from './utils/transactions.js';
export { chainMetadataToWagmiChain } from './utils/wagmi.js';
export { chainMetadataToViemChain } from './utils/viem.js';
export {
FeeConstantConfig,
RouteBlacklist,
Expand Down Expand Up @@ -541,25 +541,25 @@ export {

export { EvmCoreModule } from './core/EvmCoreModule.js';
export {
proxyAdmin,
isProxy,
proxyAdmin,
proxyConstructorArgs,
proxyImplementation,
} from './deploy/proxy.js';
export {
ProxyFactoryFactoriesAddresses,
ProxyFactoryFactoriesSchema,
} from './deploy/schemas.js';
export { EvmIsmModule } from './ism/EvmIsmModule.js';
export { AnnotatedEV5Transaction } from './providers/ProviderType.js';
export { EvmERC20WarpModule } from './token/EvmERC20WarpModule.js';
export {
ChainGasOracleParams,
GasPriceConfig,
NativeTokenPriceConfig,
ChainGasOracleParams,
getCoingeckoTokenPrices,
getCosmosChainGasPrice,
getGasPrice,
getLocalStorageGasOracleConfig,
getTokenExchangeRateFromValues,
} from './gas/utils.js';
export { EvmIsmModule } from './ism/EvmIsmModule.js';
export { AnnotatedEV5Transaction } from './providers/ProviderType.js';
export { EvmERC20WarpModule } from './token/EvmERC20WarpModule.js';
2 changes: 1 addition & 1 deletion typescript/sdk/src/providers/transactionFeeEstimators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export async function estimateTransactionFeeViem({
...transaction.transaction,
blockNumber: undefined,
account: sender as `0x${string}`,
});
} as any); // Cast to silence overly-protective type enforcement from viem here
const feeData = await provider.provider.estimateFeesPerGas();
return computeEvmTxFee(
gasUnits,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { Chain as WagmiChain } from '@wagmi/chains';
import { Chain, defineChain } from 'viem';

import { test1 } from '../consts/testChains.js';
import {
ChainMetadata,
getChainIdNumber,
} from '../metadata/chainMetadataTypes.js';

export function chainMetadataToWagmiChain(metadata: ChainMetadata): WagmiChain {
return {
export function chainMetadataToViemChain(metadata: ChainMetadata): Chain {
return defineChain({
id: getChainIdNumber(metadata),
name: metadata.displayName || metadata.name,
network: metadata.name,
Expand All @@ -25,5 +25,5 @@ export function chainMetadataToWagmiChain(metadata: ChainMetadata): WagmiChain {
}
: undefined,
testnet: !!metadata.isTestnet,
};
});
}
2 changes: 1 addition & 1 deletion typescript/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "6.0.0",
"dependencies": {
"@cosmjs/encoding": "^0.32.4",
"@solana/web3.js": "^1.78.0",
"@solana/web3.js": "^1.95.4",
"bignumber.js": "^9.1.1",
"ethers": "^5.7.2",
"lodash-es": "^4.17.21",
Expand Down
Loading

0 comments on commit f48cf87

Please sign in to comment.