Fix for CwTokenAdapter getBalance method (#3107)

### Description

Use getBalance instead of queryContractSmart for CwTokenAdapter

### Drive-by Changes

Fix SmartProvider unit test

### Backward compatibility

Yes

### Testing

Tested in warp UI
pull/3110/head
J M Rossy 11 months ago committed by GitHub
parent 4ce89df7ef
commit a04454d6d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .changeset/gorgeous-needles-sparkle.md
  2. 8
      typescript/sdk/src/providers/SmartProvider/SmartProvider.test.ts
  3. 9
      typescript/sdk/src/token/adapters/CosmWasmTokenAdapter.ts

@ -0,0 +1,5 @@
---
'@hyperlane-xyz/sdk': patch
---
Use getBalance instead of queryContractSmart for CwTokenAdapter

@ -10,13 +10,13 @@ import { ChainMetadata } from '../../metadata/chainMetadataTypes';
import { ProviderMethod } from './ProviderMethods';
import { HyperlaneSmartProvider } from './SmartProvider';
const MIN_BLOCK_NUM = 10000000;
const MIN_BLOCK_NUM = 10200000;
const DEFAULT_ACCOUNT = '0x9d525E28Fe5830eE92d7Aa799c4D21590567B595';
const WETH_CONTRACT = '0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6';
const WETH_TRANSFER_TOPIC0 =
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';
const WETH_TRANSFER_TOPIC1 =
'0x0000000000000000000000004648a43b2c14da09fdf82b161150d3f634f40491';
'0x00000000000000000000000022a9af161b9660f3dc1b996bf1e622a2c58b8558';
const WETH_CALL_DATA =
'0x70a082310000000000000000000000004f7a67464b5976d7547c860109e4432d50afb38e';
const TRANSFER_TX_HASH =
@ -61,7 +61,9 @@ describe('SmartProvider', () => {
for (const [description, config] of configs) {
describe(description, () => {
provider = HyperlaneSmartProvider.fromChainMetadata(config);
provider = HyperlaneSmartProvider.fromChainMetadata(config, {
debug: true,
});
itDoesIfSupported(ProviderMethod.GetBlock, async () => {
const latestBlock = await provider.getBlock('latest');

@ -121,12 +121,9 @@ export class CwTokenAdapter
}
async getBalance(address: Address): Promise<string> {
const resp = await this.queryToken<BalanceResponse>({
balance: {
address,
},
});
return resp.balance;
const provider = await this.getProvider();
const balance = await provider.getBalance(address, this.addresses.token);
return balance.amount;
}
async getMetadata(): Promise<CW20Metadata> {

Loading…
Cancel
Save