Skip to content

Commit

Permalink
Add support for Theta (#326)
Browse files Browse the repository at this point in the history
* Adding Theta support
  • Loading branch information
jieyilong authored Oct 4, 2021
1 parent dbd94bd commit cf8e28d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-weeks-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@usedapp/core": patch
---

Add support for Theta
4 changes: 2 additions & 2 deletions docs/source/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,7 @@ ChainId
Enum that represents chain ids.
**Values:**
``Mainnet, Goerli, Kovan, Rinkeby, Ropsten, BSC, xDai, Polygon, Moonriver, Mumbai, Harmony, Palm``
``Mainnet, Goerli, Kovan, Rinkeby, Ropsten, BSC, xDai, Polygon, Moonriver, Mumbai, Harmony, Theta, Palm``
Helpers
*******
Expand Down Expand Up @@ -746,6 +745,7 @@ Returns name of a chain for a given `chainId`.
getChainName(ChainId.Mainnet) // Mainnet
getChainName(ChainId.Ropsten) // Ropsten
getChainName(ChainId.xDai) // xDai
getChainName(ChainId.Theta) // Theta
getChainName(ChainId.Harmony) // Harmony
getChainName(ChainId.Moonriver) // Moonriver
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/constants/chainId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export enum ChainId {
BSC = 56,
xDai = 100,
Polygon = 137,
Theta = 361,
ThetaTestnet = 365,
Moonriver = 1285,
Mumbai = 80001,
Harmony = 1666600000,
Expand All @@ -24,6 +26,8 @@ export const CHAIN_NAMES = {
[ChainId.BSC]: 'BSC',
[ChainId.xDai]: 'xDai',
[ChainId.Polygon]: 'Polygon',
[ChainId.Theta]: 'Theta',
[ChainId.ThetaTestnet]: 'ThetaTestnet',
[ChainId.Moonriver]: 'Moonriver',
[ChainId.Mumbai]: 'Mumbai',
[ChainId.Harmony]: 'Harmony',
Expand All @@ -41,6 +45,8 @@ export const MULTICALL_ADDRESSES = {
[ChainId.BSC]: '0x41263cba59eb80dc200f3e2544eda4ed6a90e76c',
[ChainId.xDai]: '0xb5b692a88bdfc81ca69dcb1d924f59f0413a602a',
[ChainId.Polygon]: '0x11ce4B23bD875D7F5C6a31084f55fDe1e9A87507',
[ChainId.Theta]: '0xe2ec58a54f3ab2714eddbae87533793011f1e14e',
[ChainId.ThetaTestnet]: '0xf822bf2e728e264c58d7618022addd9cbc780350',
[ChainId.Moonriver]: '0xa9177F8d98DAaB74C24715Ba0A81b73654710523',
[ChainId.Mumbai]: '0x08411ADd0b5AA8ee47563b146743C13b3556c9Cc',
[ChainId.Harmony]: '0xFE4980f62D708c2A84D3929859Ea226340759320',
Expand All @@ -53,6 +59,7 @@ export const TEST_CHAINS = [
ChainId.Rinkeby,
ChainId.Goerli,
ChainId.Mumbai,
ChainId.ThetaTestnet,
ChainId.Localhost,
ChainId.Hardhat,
]
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/helpers/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export function getExplorerAddressLink(address: string, chainId: ChainId) {
return `https://explorer-mainnet.maticvigil.com/address/${address}/transactions`
case ChainId.Mumbai:
return `https://explorer-mumbai.maticvigil.com/address/${address}/transactions`
case ChainId.Theta:
return `https://explorer.thetatoken.org/address/${address}`
case ChainId.ThetaTestnet:
return `https://testnet-explorer.thetatoken.org/address/${address}`
case ChainId.Harmony:
return `https://explorer.harmony.one/address/${address}`
case ChainId.Moonriver:
Expand All @@ -53,6 +57,10 @@ export function getExplorerTransactionLink(transactionHash: string, chainId: Cha
return `https://explorer-mainnet.maticvigil.com/tx/${transactionHash}/internal-transactions`
case ChainId.Mumbai:
return `https://explorer-mumbai.maticvigil.com/tx/${transactionHash}/internal-transactions`
case ChainId.Theta:
return `https://explorer.thetatoken.org/tx/${transactionHash}`
case ChainId.ThetaTestnet:
return `https://testnet-explorer.thetatoken.org/tx/${transactionHash}`
case ChainId.Harmony:
return `https://explorer.harmony.one/tx/${transactionHash}`
case ChainId.Moonriver:
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/model/config/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const DEFAULT_CONFIG: FullConfig = {
ChainId.Hardhat,
ChainId.Polygon,
ChainId.Mumbai,
ChainId.Theta,
ChainId.ThetaTestnet,
ChainId.Harmony,
ChainId.Moonriver,
ChainId.Palm,
Expand Down
15 changes: 15 additions & 0 deletions packages/core/test/helpers/chain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ describe('Chain helpers', () => {
expect(getChainName(ChainId.xDai)).to.eq('xDai')
expect(getChainName(ChainId.Polygon)).to.eq('Polygon')
expect(getChainName(ChainId.Mumbai)).to.eq('Mumbai')
expect(getChainName(ChainId.Theta)).to.eq('Theta')
expect(getChainName(ChainId.ThetaTestnet)).to.eq('ThetaTestnet')
expect(getChainName(ChainId.Harmony)).to.eq('Harmony')
expect(getChainName(ChainId.Moonriver)).to.eq('Moonriver')
expect(getChainName(ChainId.Palm)).to.eq('Palm')
Expand All @@ -33,6 +35,7 @@ describe('Chain helpers', () => {
expect(isTestChain(ChainId.BSC)).to.be.false
expect(isTestChain(ChainId.xDai)).to.be.false
expect(isTestChain(ChainId.Polygon)).to.be.false
expect(isTestChain(ChainId.Theta)).to.be.false
expect(isTestChain(ChainId.Mumbai)).to.be.true
expect(isTestChain(ChainId.Harmony)).to.be.false
expect(isTestChain(ChainId.Moonriver)).to.be.false
Expand Down Expand Up @@ -82,6 +85,12 @@ describe('Chain helpers', () => {
expect(getExplorerAddressLink(address, ChainId.Mumbai)).to.eq(
'https://explorer-mumbai.maticvigil.com/address/0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987/transactions'
)
expect(getExplorerAddressLink(address, ChainId.Theta)).to.eq(
'https://explorer.thetatoken.org/address/0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987'
)
expect(getExplorerAddressLink(address, ChainId.ThetaTestnet)).to.eq(
'https://testnet-explorer.thetatoken.org/address/0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987'
)
expect(getExplorerAddressLink(address, ChainId.Harmony)).to.eq(
'https://explorer.harmony.one/address/0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987'
)
Expand Down Expand Up @@ -122,6 +131,12 @@ describe('Chain helpers', () => {
expect(getExplorerTransactionLink(tx, ChainId.Mumbai)).to.eq(
'https://explorer-mumbai.maticvigil.com/tx/0x5d53558791c9346d644d077354420f9a93600acf54eb6a279f12b43025392c3a/internal-transactions'
)
expect(getExplorerTransactionLink(tx, ChainId.Theta)).to.eq(
'https://explorer.thetatoken.org/tx/0x5d53558791c9346d644d077354420f9a93600acf54eb6a279f12b43025392c3a'
)
expect(getExplorerTransactionLink(tx, ChainId.ThetaTestnet)).to.eq(
'https://testnet-explorer.thetatoken.org/tx/0x5d53558791c9346d644d077354420f9a93600acf54eb6a279f12b43025392c3a'
)
expect(getExplorerTransactionLink(tx, ChainId.Harmony)).to.eq(
'https://explorer.harmony.one/tx/0x5d53558791c9346d644d077354420f9a93600acf54eb6a279f12b43025392c3a'
)
Expand Down

0 comments on commit cf8e28d

Please sign in to comment.