Skip to content

Commit

Permalink
Cosmos adapter updates for gas and IBC (#2894)
Browse files Browse the repository at this point in the history
- Combine tx amounts in cw adapter when denoms match
- Update CosmosTokenAdapters with latest from warp ui
- Fix IBC-to-warp adapter for IGP support
- Add logos for cosmos related chains
  • Loading branch information
jmrossy authored Nov 9, 2023
1 parent bbc024a commit e4ed2c3
Show file tree
Hide file tree
Showing 18 changed files with 211 additions and 59 deletions.
4 changes: 2 additions & 2 deletions solidity/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@hyperlane-xyz/core",
"description": "Core solidity contracts for Hyperlane",
"version": "3.1.0-beta0",
"version": "3.1.0-beta3",
"dependencies": {
"@eth-optimism/contracts": "^0.6.0",
"@hyperlane-xyz/utils": "3.1.0-beta0",
"@hyperlane-xyz/utils": "3.1.0-beta3",
"@openzeppelin/contracts": "^4.8.0",
"@openzeppelin/contracts-upgradeable": "^4.8.0"
},
Expand Down
6 changes: 3 additions & 3 deletions typescript/helloworld/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@hyperlane-xyz/helloworld",
"description": "A basic skeleton of an Hyperlane app",
"version": "3.1.0-beta0",
"version": "3.1.0-beta3",
"dependencies": {
"@hyperlane-xyz/core": "3.1.0-beta0",
"@hyperlane-xyz/sdk": "3.1.0-beta0",
"@hyperlane-xyz/core": "3.1.0-beta3",
"@hyperlane-xyz/sdk": "3.1.0-beta3",
"@openzeppelin/contracts-upgradeable": "^4.8.0",
"ethers": "^5.7.2"
},
Expand Down
8 changes: 4 additions & 4 deletions typescript/infra/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hyperlane-xyz/infra",
"description": "Infrastructure utilities for the Hyperlane Network",
"version": "1.5.1",
"version": "3.1.0-beta3",
"dependencies": {
"@arbitrum/sdk": "^3.0.0",
"@aws-sdk/client-iam": "^3.74.0",
Expand All @@ -11,9 +11,9 @@
"@ethersproject/experimental": "^5.7.0",
"@ethersproject/hardware-wallets": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@hyperlane-xyz/helloworld": "3.1.0-beta0",
"@hyperlane-xyz/sdk": "3.1.0-beta0",
"@hyperlane-xyz/utils": "3.1.0-beta0",
"@hyperlane-xyz/helloworld": "3.1.0-beta3",
"@hyperlane-xyz/sdk": "3.1.0-beta3",
"@hyperlane-xyz/utils": "3.1.0-beta3",
"@nomiclabs/hardhat-etherscan": "^3.0.3",
"@safe-global/api-kit": "^1.3.0",
"@safe-global/protocol-kit": "^1.2.0",
Expand Down
1 change: 1 addition & 0 deletions typescript/sdk/logos/black/cosmos.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions typescript/sdk/logos/black/cosmwasm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions typescript/sdk/logos/black/manta.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions typescript/sdk/logos/black/neutron.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions typescript/sdk/logos/color/cosmos.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions typescript/sdk/logos/color/cosmwasm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions typescript/sdk/logos/color/manta.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions typescript/sdk/logos/color/neutron.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions typescript/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"name": "@hyperlane-xyz/sdk",
"description": "The official SDK for the Hyperlane Network",
"version": "3.1.0-beta0",
"version": "3.1.0-beta3",
"dependencies": {
"@cosmjs/cosmwasm-stargate": "^0.31.3",
"@cosmjs/stargate": "^0.31.3",
"@hyperlane-xyz/core": "3.1.0-beta0",
"@hyperlane-xyz/utils": "3.1.0-beta0",
"@hyperlane-xyz/core": "3.1.0-beta3",
"@hyperlane-xyz/utils": "3.1.0-beta3",
"@solana/spl-token": "^0.3.8",
"@solana/web3.js": "^1.78.0",
"@types/coingecko-api": "^1.0.10",
"@types/debug": "^4.1.7",
"@wagmi/chains": "^0.2.6",
"bignumber.js": "^9.1.1",
"coingecko-api": "^1.0.10",
"cosmjs-types": "^0.9.0",
"cross-fetch": "^3.1.5",
Expand Down
1 change: 1 addition & 0 deletions typescript/sdk/src/consts/chainMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ export const neutron: ChainMetadata = {
{
name: 'Mintscan',
url: 'https://www.mintscan.io/neutron',
// TODO API not actually supported, using url to meet validation requirements
apiUrl: 'https://www.mintscan.io/neutron',
family: ExplorerFamily.Other,
},
Expand Down
5 changes: 5 additions & 0 deletions typescript/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ export {
CwNativeTokenAdapter,
CwTokenAdapter,
} from './token/adapters/CosmWasmTokenAdapter';
export {
CosmIbcToWarpTokenAdapter,
CosmIbcTokenAdapter,
CosmNativeTokenAdapter,
} from './token/adapters/CosmosTokenAdapter';
export {
EvmHypCollateralAdapter,
EvmHypSyntheticAdapter,
Expand Down
33 changes: 22 additions & 11 deletions typescript/sdk/src/token/adapters/CosmWasmTokenAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ExecuteInstruction } from '@cosmjs/cosmwasm-stargate';
import { Coin } from '@cosmjs/stargate';
import BigNumber from 'bignumber.js';

import {
Address,
Expand Down Expand Up @@ -370,8 +371,27 @@ export class CwHypNativeAdapter
if (!txValue) {
throw new Error('txValue is required for native tokens');
}

const collateralDenom = await this.denom();

const funds: Coin[] =
collateralDenom === this.gasDenom
? [
{
amount: new BigNumber(weiAmountOrId).plus(txValue).toFixed(0),
denom: collateralDenom,
},
]
: [
{
amount: weiAmountOrId.toString(),
denom: collateralDenom,
},
{
amount: txValue.toString(),
denom: this.gasDenom,
},
];

return this.cw20adapter.prepareRouter(
{
transfer_remote: {
Expand All @@ -380,16 +400,7 @@ export class CwHypNativeAdapter
amount: weiAmountOrId.toString(),
},
},
[
{
amount: weiAmountOrId.toString(),
denom: collateralDenom,
},
{
amount: txValue.toString(),
denom: this.gasDenom,
},
],
funds,
);
}
}
Expand Down
Loading

0 comments on commit e4ed2c3

Please sign in to comment.