-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add USDT/ETH token assets; improve CryptoInput docs; refactor d…
…emos with Token assets
- Loading branch information
1 parent
171b613
commit ca59ac5
Showing
18 changed files
with
197 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './wallets'; | ||
export * from './chains/ethereum'; | ||
export * from './token'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { ChainIds, type Token } from '@ant-design/web3-common'; | ||
import { EthereumColorful } from '@ant-design/web3-icons'; | ||
|
||
export const ETH: Token = { | ||
name: 'Ethereum', | ||
symbol: 'ETH', | ||
decimal: 18, | ||
icon: <EthereumColorful />, | ||
availableChains: [ | ||
{ | ||
chain: { | ||
name: 'Ethereum', | ||
id: ChainIds.Mainnet, | ||
}, | ||
}, | ||
{ | ||
chain: { | ||
name: 'Polygon', | ||
id: ChainIds.Polygon, | ||
}, | ||
contract: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', | ||
}, | ||
{ | ||
chain: { | ||
name: 'BSC', | ||
id: ChainIds.BSC, | ||
}, | ||
contract: '0x2170Ed0880ac9A755fd29B2688956BD959F933F8', | ||
}, | ||
{ | ||
chain: { | ||
name: 'Arbitrum', | ||
id: ChainIds.Arbitrum, | ||
}, | ||
contract: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1', | ||
}, | ||
{ | ||
chain: { | ||
name: 'Optimism', | ||
id: ChainIds.Optimism, | ||
}, | ||
contract: '0x4200000000000000000000000000000000000006', | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './ethereum'; | ||
export * from './usdt'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { ChainIds, type Token } from '@ant-design/web3-common'; | ||
import { USDTColorful } from '@ant-design/web3-icons'; | ||
|
||
export const USDT: Token = { | ||
name: 'Tether USD', | ||
symbol: 'USDT', | ||
decimal: 6, | ||
icon: <USDTColorful />, | ||
availableChains: [ | ||
{ | ||
chain: { | ||
name: 'Ethereum', | ||
id: ChainIds.Mainnet, | ||
}, | ||
contract: '0xdac17f958d2ee523a2206206994597c13d831ec7', | ||
}, | ||
{ | ||
chain: { | ||
name: 'Polygon', | ||
id: ChainIds.Polygon, | ||
}, | ||
contract: '0x3813e82e6f7098b9583FC0F33a962D02018B6803', | ||
}, | ||
{ | ||
chain: { | ||
name: 'BSC', | ||
id: ChainIds.BSC, | ||
}, | ||
contract: '0x55d398326f99059fF775485246999027B3197955', | ||
}, | ||
{ | ||
chain: { | ||
name: 'Arbitrum', | ||
id: ChainIds.Arbitrum, | ||
}, | ||
contract: '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9', | ||
}, | ||
{ | ||
chain: { | ||
name: 'Optimism', | ||
id: ChainIds.Optimism, | ||
}, | ||
contract: '0x7f5c764cbc14f9669b88837ca1490cca17c31607', | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,11 @@ | ||
import { useState } from 'react'; | ||
import type { CryptoInputProps } from '@ant-design/web3'; | ||
import { ChainIds, CryptoInput } from '@ant-design/web3'; | ||
import { EthereumColorful } from '@ant-design/web3-icons'; | ||
import { CryptoInput, type CryptoInputProps } from '@ant-design/web3'; | ||
import { ETH, USDT } from '@ant-design/web3-assets'; | ||
|
||
const App: React.FC = () => { | ||
const [crypto, setCrypto] = useState<CryptoInputProps['value']>(); | ||
|
||
return ( | ||
<CryptoInput | ||
value={crypto} | ||
footer={false} | ||
onChange={setCrypto} | ||
tokenList={[ | ||
{ | ||
name: 'Ethereum', | ||
symbol: 'ETH', | ||
icon: <EthereumColorful />, | ||
decimal: 18, | ||
availableChains: [ | ||
{ | ||
chain: { | ||
id: ChainIds.Mainnet, | ||
name: 'Ethereum', | ||
}, | ||
contract: '0x', | ||
}, | ||
], | ||
}, | ||
]} | ||
/> | ||
); | ||
return <CryptoInput value={crypto} footer={false} onChange={setCrypto} tokenList={[ETH, USDT]} />; | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useState } from 'react'; | ||
import { CryptoInput, type CryptoInputProps, type Token } from '@ant-design/web3'; | ||
import { ETH, USDT } from '@ant-design/web3-assets'; | ||
|
||
const App: React.FC = () => { | ||
const [crypto, setCrypto] = useState<CryptoInputProps['value']>(); | ||
|
||
const [tokenBalance, setTokenBalance] = useState<{ | ||
amount: string; | ||
unitPrice: string; | ||
}>(); | ||
|
||
const handleQueryCrypto = async (token?: Token) => { | ||
if (!token) { | ||
return setTokenBalance(undefined); | ||
} | ||
|
||
// mock query token balance | ||
setTimeout(() => { | ||
setTokenBalance({ | ||
amount: '100', | ||
unitPrice: '100', | ||
}); | ||
}, 500); | ||
}; | ||
|
||
return ( | ||
<CryptoInput | ||
value={crypto} | ||
balance={tokenBalance} | ||
onChange={(value) => { | ||
setCrypto(value); | ||
|
||
if (value?.token?.symbol !== crypto?.token?.symbol) { | ||
handleQueryCrypto(value?.token); | ||
} | ||
}} | ||
tokenList={[ETH, USDT]} | ||
/> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.