Skip to content

Commit

Permalink
Merge pull request #99 from etherspot/fix/use-etherspot-assets-type-fix
Browse files Browse the repository at this point in the history
updated get assets accepted param
  • Loading branch information
poocart authored Feb 20, 2024
2 parents 1e34185 + d062fae commit d5c6bed
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [0.7.4] - 2024-02-20

### Added Changes
- Added `chainId` param to `useEtherspotAssets` hook's `getAssets` method

## [0.7.3] - 2024-02-20

### Added Changes
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@etherspot/transaction-kit",
"description": "React Etherspot Transaction Kit",
"version": "0.7.3",
"version": "0.7.4",
"main": "dist/cjs/index.js",
"scripts": {
"rollup:build": "NODE_OPTIONS=--max-old-space-size=8192 rollup -c",
Expand Down
14 changes: 8 additions & 6 deletions src/hooks/useEtherspotAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TokenListToken } from '@etherspot/prime-sdk';
import useEtherspot from './useEtherspot';

interface IEtherspotAssetsHook {
getAssets: () => Promise<TokenListToken[]>;
getAssets: (chainId?: number) => Promise<TokenListToken[]>;
}

/**
Expand All @@ -14,14 +14,16 @@ interface IEtherspotAssetsHook {
* @returns {IEtherspotAssetsHook} - hook method to fetch Etherspot supported assets
*/
const useEtherspotAssets = (chainId?: number): IEtherspotAssetsHook => {
const { getSdk, chainId: defaultChainId } = useEtherspot();
const { getSdk, chainId: etherspotChainId } = useEtherspot();

const assetsChainId = useMemo(() => {
const defaultChainId = useMemo(() => {
if (chainId) return chainId;
return defaultChainId;
}, [chainId, defaultChainId]);
return etherspotChainId;
}, [chainId, etherspotChainId]);

const getAssets = async (): Promise<TokenListToken[]> => {
const getAssets = async (
assetsChainId: number = defaultChainId,
): Promise<TokenListToken[]> => {
const sdkForChainId = await getSdk(assetsChainId);

let assets: TokenListToken[] = [];
Expand Down

0 comments on commit d5c6bed

Please sign in to comment.