diff --git a/apps/wallet-mobile/package.json b/apps/wallet-mobile/package.json index edb1f9777a..5ca92b221f 100644 --- a/apps/wallet-mobile/package.json +++ b/apps/wallet-mobile/package.json @@ -127,7 +127,7 @@ "@yoroi/api": "1.5.1", "@yoroi/common": "1.5.3", "@yoroi/exchange": "2.1.0", - "@yoroi/explorers": "1.0.0", + "@yoroi/explorers": "1.0.1", "@yoroi/identicon": "1.0.0", "@yoroi/links": "1.5.6", "@yoroi/portfolio": "1.0.1", diff --git a/apps/wallet-mobile/src/features/Portfolio/common/helpers/build-token-managers.ts b/apps/wallet-mobile/src/features/Portfolio/common/helpers/build-token-managers.ts index 3d38cee0d2..b10c5050d4 100644 --- a/apps/wallet-mobile/src/features/Portfolio/common/helpers/build-token-managers.ts +++ b/apps/wallet-mobile/src/features/Portfolio/common/helpers/build-token-managers.ts @@ -29,16 +29,19 @@ export const buildPortfolioTokenManagers = () => { const mainnetPortfolioTokenManager = buildPortfolioTokenManager({network: Chain.Network.Mainnet}) const preprodPortfolioTokenManager = buildPortfolioTokenManager({network: Chain.Network.Preprod}) const sanchoPortfolioTokenManager = buildPortfolioTokenManager({network: Chain.Network.Sancho}) + const previewPortfolioTokenManager = buildPortfolioTokenManager({network: Chain.Network.Preview}) const tokenManagers: Readonly<{ [Chain.Network.Mainnet]: Portfolio.Manager.Token [Chain.Network.Preprod]: Portfolio.Manager.Token [Chain.Network.Sancho]: Portfolio.Manager.Token + [Chain.Network.Preview]: Portfolio.Manager.Token }> = freeze( { [Chain.Network.Mainnet]: mainnetPortfolioTokenManager.tokenManager, [Chain.Network.Preprod]: preprodPortfolioTokenManager.tokenManager, [Chain.Network.Sancho]: sanchoPortfolioTokenManager.tokenManager, + [Chain.Network.Preview]: previewPortfolioTokenManager.tokenManager, }, true, ) @@ -47,11 +50,13 @@ export const buildPortfolioTokenManagers = () => { [Chain.Network.Mainnet]: App.Storage [Chain.Network.Preprod]: App.Storage [Chain.Network.Sancho]: App.Storage + [Chain.Network.Preview]: App.Storage }> = freeze( { [Chain.Network.Mainnet]: mainnetPortfolioTokenManager.storage, [Chain.Network.Preprod]: preprodPortfolioTokenManager.storage, [Chain.Network.Sancho]: sanchoPortfolioTokenManager.storage, + [Chain.Network.Preview]: previewPortfolioTokenManager.storage, }, true, ) diff --git a/apps/wallet-mobile/src/features/WalletManager/network-manager/helpers/date-to-epoch-info.test.ts b/apps/wallet-mobile/src/features/WalletManager/network-manager/helpers/date-to-epoch-info.test.ts index fb12fca353..032bddaf2e 100644 --- a/apps/wallet-mobile/src/features/WalletManager/network-manager/helpers/date-to-epoch-info.test.ts +++ b/apps/wallet-mobile/src/features/WalletManager/network-manager/helpers/date-to-epoch-info.test.ts @@ -1,3 +1,5 @@ +import {Chain} from '@yoroi/types' + import {buildPortfolioTokenManagers} from '../../../Portfolio/common/helpers/build-token-managers' import {buildNetworkManagers, byronEraConfig, shelleyEraConfig, shelleyPreprodEraConfig} from '../network-manager' import {dateToEpochInfo} from './date-to-epoch-info' @@ -8,7 +10,7 @@ describe('dateToEpochInfo', () => { tokenManagers: buildPortfolioTokenManagers().tokenManagers, }) it('should return the correct epoch information', () => { - const convertDateToEpoch = dateToEpochInfo(networkManagers['mainnet'].eras) + const convertDateToEpoch = dateToEpochInfo(networkManagers[Chain.Network.Mainnet].eras) const inputDate = new Date('2024-05-14T12:30:00Z') const expectedOutput = { @@ -24,7 +26,7 @@ describe('dateToEpochInfo', () => { }) it('should throw an error for a date before the start of the known eras', () => { - const convertDateToEpoch = dateToEpochInfo(networkManagers['mainnet'].eras) + const convertDateToEpoch = dateToEpochInfo(networkManagers[Chain.Network.Mainnet].eras) const inputDate = new Date('1998-12-31T23:59:59Z') @@ -32,7 +34,7 @@ describe('dateToEpochInfo', () => { }) it('should return the first byron epoch - 0', () => { - const convertDateToEpoch = dateToEpochInfo(networkManagers['mainnet'].eras) + const convertDateToEpoch = dateToEpochInfo(networkManagers[Chain.Network.Mainnet].eras) const inputDate = new Date(1506203091000) const expectedOutput = { @@ -48,7 +50,7 @@ describe('dateToEpochInfo', () => { }) it('should return the last byron epoch - 207', () => { - const convertDateToEpoch = dateToEpochInfo(networkManagers['mainnet'].eras) + const convertDateToEpoch = dateToEpochInfo(networkManagers[Chain.Network.Mainnet].eras) const inputDate = new Date('2020-07-29T21:44:50.000Z') const expectedOutput = { @@ -64,7 +66,7 @@ describe('dateToEpochInfo', () => { }) it('should return the first shelley epoch - 208', () => { - const convertDateToEpoch = dateToEpochInfo(networkManagers['mainnet'].eras) + const convertDateToEpoch = dateToEpochInfo(networkManagers[Chain.Network.Mainnet].eras) const inputDate = new Date('2020-07-29T21:44:51.000Z') diff --git a/apps/wallet-mobile/src/features/WalletManager/network-manager/helpers/get-wallet-factory.ts b/apps/wallet-mobile/src/features/WalletManager/network-manager/helpers/get-wallet-factory.ts index 793e2f9497..a577281281 100644 --- a/apps/wallet-mobile/src/features/WalletManager/network-manager/helpers/get-wallet-factory.ts +++ b/apps/wallet-mobile/src/features/WalletManager/network-manager/helpers/get-wallet-factory.ts @@ -12,9 +12,11 @@ import {WalletFactory} from '../../common/types' const ShelleyWalletMainnet = makeCardanoWallet(networkManagers[Chain.Network.Mainnet], 'cardano-cip1852', MAINNET) const ShelleyWalletTestnet = makeCardanoWallet(networkManagers[Chain.Network.Preprod], 'cardano-cip1852', TESTNET) const ShelleySanchonetWallet = makeCardanoWallet(networkManagers[Chain.Network.Sancho], 'cardano-cip1852', SANCHONET) +const ShelleyPreviewWallet = makeCardanoWallet(networkManagers[Chain.Network.Preview], 'cardano-cip1852', SANCHONET) const ByronWallet = makeCardanoWallet(networkManagers[Chain.Network.Mainnet], 'cardano-bip44', MAINNET) const ByronWalletTestnet = makeCardanoWallet(networkManagers[Chain.Network.Preprod], 'cardano-bip44', TESTNET) const ByronSanchonetWallet = makeCardanoWallet(networkManagers[Chain.Network.Sancho], 'cardano-bip44', SANCHONET) +const ByronPreviewWallet = makeCardanoWallet(networkManagers[Chain.Network.Preview], 'cardano-bip44', SANCHONET) /** * Retrieves the wallet factory based on the network and implementation ID @@ -45,6 +47,10 @@ export function getWalletFactory({ 'cardano-cip1852': ShelleySanchonetWallet, 'cardano-bip44': ByronSanchonetWallet, }, + [Chain.Network.Preview]: /* cardano preview */ { + 'cardano-cip1852': ShelleyPreviewWallet, + 'cardano-bip44': ByronPreviewWallet, + }, } as const) const networkImplementations = walletMap[network] diff --git a/apps/wallet-mobile/src/features/WalletManager/network-manager/network-manager.ts b/apps/wallet-mobile/src/features/WalletManager/network-manager/network-manager.ts index 025d90b278..9d58ccf886 100644 --- a/apps/wallet-mobile/src/features/WalletManager/network-manager/network-manager.ts +++ b/apps/wallet-mobile/src/features/WalletManager/network-manager/network-manager.ts @@ -109,15 +109,17 @@ export const networkConfigs: Readonly > = { - mainnet: { + [Chain.Network.Mainnet]: { root: 'https://zero.yoroiwallet.com', }, - preprod: { + [Chain.Network.Preprod]: { root: 'https://yoroi-backend-zero-preprod.emurgornd.com', }, - sancho: { + [Chain.Network.Sancho]: { root: 'https://yoroi-backend-zero-sanchonet.emurgornd.com', }, + [Chain.Network.Preview]: { + root: 'https://yoroi-backend-zero-preview.emurgornd.com', + }, } as const diff --git a/packages/dapp-connector/src/adapters/api.test.ts b/packages/dapp-connector/src/adapters/api.test.ts index 71eb720bbd..79cfad55af 100644 --- a/packages/dapp-connector/src/adapters/api.test.ts +++ b/packages/dapp-connector/src/adapters/api.test.ts @@ -92,7 +92,7 @@ describe('dappConnectorApiMaker', () => { const fakeResult = {tag: 'right' as const, value: {data: await managerMock.getDAppList()}} as const const fakeFetchData = () => Promise.resolve(fakeResult) await expect(() => - dappConnectorApiMaker({request: fakeFetchData as any}).getDApps({network: Chain.Network.Preview} as any), + dappConnectorApiMaker({request: fakeFetchData as any}).getDApps({network: Chain.Network.Testnet} as any), ).rejects.toThrow() }) }) diff --git a/packages/dapp-connector/src/adapters/api.ts b/packages/dapp-connector/src/adapters/api.ts index 13871207bc..d5822535c9 100644 --- a/packages/dapp-connector/src/adapters/api.ts +++ b/packages/dapp-connector/src/adapters/api.ts @@ -4,11 +4,12 @@ import {AxiosRequestConfig} from 'axios' import {z} from 'zod' import {Chain} from '@yoroi/types' -const dappListHosts = { - mainnet: 'https://daehx1qv45z7c.cloudfront.net/data.json', - preprod: 'https://daehx1qv45z7c.cloudfront.net/preprod.json', - sancho: 'https://daehx1qv45z7c.cloudfront.net/sancho.json', -} as const +const dappListHosts: Readonly> = freeze({ + [Chain.Network.Mainnet]: 'https://daehx1qv45z7c.cloudfront.net/data.json', + [Chain.Network.Preprod]: 'https://daehx1qv45z7c.cloudfront.net/preprod.json', + [Chain.Network.Sancho]: 'https://daehx1qv45z7c.cloudfront.net/sancho.json', + [Chain.Network.Preview]: 'https://daehx1qv45z7c.cloudfront.net/preview.json', +}) const initialDeps = freeze({request: fetchData}, true) diff --git a/packages/explorers/README.md b/packages/explorers/README.md index 71a7a1a996..dd4410302d 100644 --- a/packages/explorers/README.md +++ b/packages/explorers/README.md @@ -1 +1,125 @@ -# Explorer package for Yoroi +# @yoroi/explorers + +## Overview + +The `@yoroi/explorers` is a TypeScript package designed to manage and interact with various blockchain explorers supported by the Yoroi Wallet. The package provides a consistent interface for generating URLs for different blockchain networks and explorers. + +## Installation + +To install the package, you can use npm or yarn: + +```bash +npm install @yoroi/explorers +``` + +or + +```bash +yarn add @yoroi/explorers +``` + +## Usage + +To use `@yoroi/explorers`, you can import the necessary types and functions to generate URLs for tokens, addresses, transactions, pools, and stake keys. + +Example + +```typescript +import {Chain, Explorers} from '@yoroi/types' +import {explorerManager} from '@yoroi/explorers' + +// Build the manager +const mainnetExplorer = explorerManager[Chain.Network.Mainnet] + +// Generate URLs using CardanoScan explorer +const tokenUrl = mainnetExplorer[Explorers.Explorer.CardanoScan].token('fingerprint') +const addressUrl = mainnetExplorer[Explorers.Explorer.CardanoScan].address('address') +const txUrl = mainnetExplorer[Explorers.Explorer.CardanoScan].tx('txHash') +const poolUrl = mainnetExplorer[Explorers.Explorer.CardanoScan].pool('poolId') +const stakeUrl = mainnetExplorer[Explorers.Explorer.CardanoScan].stake('stakeAddress') + +console.log(tokenUrl) // Output: https://cardanoscan.io/token/fingerprint +console.log(addressUrl) // Output: https://cardanoscan.io/address/address +console.log(txUrl) // Output: https://cardanoscan.io/transaction/txHash +console.log(poolUrl) // Output: https://cardanoscan.io/pool/poolId +console.log(stakeUrl) // Output: https://cardanoscan.io/stakeKey/stakeAddress +``` + +This example shows how to use the explorerManager object to generate URLs for different entities on the Mainnet using the CardanoScan explorer. + +## About Supported Networks and Explorers + +The following networks and explorers are supported: + +Networks: + +1. Mainnet: The live network for Cardano. +2. Preprod: The pre-production network for testing. +3. Sancho: The temporary Conway test network for governance. +4. Preview: A preview network for new features. + +Explorers: + +1. CardanoScan: A popular Cardano blockchain explorer. + 1. [Twitter ![X](https://img.icons8.com/ios-filled/12/000000/x.png)](https://twitter.com/cardanoscan.io) + 2. [Discord ![Discord](https://img.icons8.com/ios-filled/12/000000/discord-logo.png)](https://discord.gg/WQFPHNXcz8) + 3. [Explorer](https://cardanoscan.io) + +2. CExplorer: Another Cardano blockchain explorer. + 1. [Explorer](https://cexplorer.io) + +## URL Generation + +For each network and explorer, the following URL generation methods are available: + +`token(fingerprint: string)` + +`address(address: string)` + +`tx(txHash: string)` + +`pool(poolId: string)` + +`stake(stakeAddress: string)` + +## Adding a New Explorer + +If you are a developer working on a new Cardano explorer and want to add support for it in Yoroi, you can do so by following these steps: + +1. Fork the Repository + Start by forking the `@yoroi/explorers` repository on GitHub. + +2. Add Your Explorer URLs + In the codebase, navigate to the `explorer-manager.ts` file. Add your explorer under the appropriate network with the URL generation methods (token, address, tx, pool, stake, etc). + + For example: + + ```typescript + [Chain.Network.Mainnet]: { + [Explorers.Explorer.YourExplorerName]: { + token: (fingerprint: string) => `https://yourexplorer.io/token/${fingerprint}`, + address: (address: string) => `https://yourexplorer.io/address/${address}`, + tx: (txHash: string) => `https://yourexplorer.io/transaction/${txHash}`, + pool: (poolId: string) => `https://yourexplorer.io/pool/${poolId}`, + stake: (stakeAddress: string) => `https://yourexplorer.io/stake/${stakeAddress}`, + }, + }, + ``` + +3. Test Your Implementation + Write unit tests to ensure that the URLs generated for your explorer are correct. You can follow the existing test patterns in the explorerManager test suite, 100% coverage is expected. + + Running Tests + + ```bash + yarn test + ``` + + This will run the unit tests to ensure that everything is working as expected. + +4. Submit a Pull Request (PR) + Once you've implemented and tested your explorer integration, submit a PR to the repository. The Yoroi development team will review your submission. + +## Contributing + +We welcome contributions from the community! If you find a bug or have a feature request, please open an issue or submit a pull request. diff --git a/packages/explorers/package.json b/packages/explorers/package.json index a8289b7ad7..ab4ae19393 100644 --- a/packages/explorers/package.json +++ b/packages/explorers/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/explorers", - "version": "1.0.0", + "version": "1.0.1", "description": "The Explorers package of Yoroi SDK", "keywords": [ "yoroi", diff --git a/packages/explorers/src/explorer-manager.test.ts b/packages/explorers/src/explorer-manager.test.ts index abe4f52d02..e8f000f5d6 100644 --- a/packages/explorers/src/explorer-manager.test.ts +++ b/packages/explorers/src/explorer-manager.test.ts @@ -11,12 +11,14 @@ describe('explorerManager', () => { address: expect.any(Function), tx: expect.any(Function), pool: expect.any(Function), + stake: expect.any(Function), }, [Explorers.Explorer.CExplorer]: { token: expect.any(Function), address: expect.any(Function), tx: expect.any(Function), pool: expect.any(Function), + stake: expect.any(Function), }, }, [Chain.Network.Preprod]: { @@ -25,12 +27,14 @@ describe('explorerManager', () => { address: expect.any(Function), tx: expect.any(Function), pool: expect.any(Function), + stake: expect.any(Function), }, [Explorers.Explorer.CExplorer]: { token: expect.any(Function), address: expect.any(Function), tx: expect.any(Function), pool: expect.any(Function), + stake: expect.any(Function), }, }, [Chain.Network.Sancho]: { @@ -39,12 +43,30 @@ describe('explorerManager', () => { address: expect.any(Function), tx: expect.any(Function), pool: expect.any(Function), + stake: expect.any(Function), }, [Explorers.Explorer.CExplorer]: { token: expect.any(Function), address: expect.any(Function), tx: expect.any(Function), pool: expect.any(Function), + stake: expect.any(Function), + }, + }, + [Chain.Network.Preview]: { + [Explorers.Explorer.CardanoScan]: { + token: expect.any(Function), + address: expect.any(Function), + tx: expect.any(Function), + pool: expect.any(Function), + stake: expect.any(Function), + }, + [Explorers.Explorer.CExplorer]: { + token: expect.any(Function), + address: expect.any(Function), + tx: expect.any(Function), + pool: expect.any(Function), + stake: expect.any(Function), }, }, }) @@ -64,6 +86,9 @@ describe('explorerManager', () => { expect(mainnetExplorer[Explorers.Explorer.CardanoScan].pool('poolId')).toBe( 'https://cardanoscan.io/pool/poolId', ) + expect( + mainnetExplorer[Explorers.Explorer.CardanoScan].stake('stakeAddress'), + ).toBe('https://cardanoscan.io/stakeKey/stakeAddress') expect( mainnetExplorer[Explorers.Explorer.CExplorer].token('fingerprint'), @@ -77,6 +102,9 @@ describe('explorerManager', () => { expect(mainnetExplorer[Explorers.Explorer.CExplorer].pool('poolId')).toBe( 'https://cexplorer.io/pool/poolId', ) + expect( + mainnetExplorer[Explorers.Explorer.CExplorer].stake('stakeAddress'), + ).toBe('https://cexplorer.io/stake/stakeAddress') }) it('should generate the correct URLs for Preprod', () => { @@ -93,6 +121,9 @@ describe('explorerManager', () => { expect(preprodExplorer[Explorers.Explorer.CardanoScan].pool('poolId')).toBe( 'https://preprod.cardanoscan.io/pool/poolId', ) + expect( + preprodExplorer[Explorers.Explorer.CardanoScan].stake('stakeAddress'), + ).toBe('https://preprod.cardanoscan.io/stakeKey/stakeAddress') expect( preprodExplorer[Explorers.Explorer.CExplorer].token('fingerprint'), @@ -106,34 +137,78 @@ describe('explorerManager', () => { expect(preprodExplorer[Explorers.Explorer.CExplorer].pool('poolId')).toBe( 'https://preprod.cexplorer.io/pool/poolId', ) + expect( + preprodExplorer[Explorers.Explorer.CExplorer].stake('stakeAddress'), + ).toBe('https://preprod.cexplorer.io/stake/stakeAddress') }) it('should generate the correct URLs for Sancho', () => { const sanchoExplorer = explorerManager[Chain.Network.Sancho] expect( sanchoExplorer[Explorers.Explorer.CardanoScan].token('fingerprint'), - ).toBe('https://cardanoscan.io/token/fingerprint') + ).toBe('https://sancho.cardanoscan.io/token/fingerprint') expect( sanchoExplorer[Explorers.Explorer.CardanoScan].address('address'), - ).toBe('https://cardanoscan.io/address/address') + ).toBe('https://sancho.cardanoscan.io/address/address') expect(sanchoExplorer[Explorers.Explorer.CardanoScan].tx('txHash')).toBe( - 'https://cardanoscan.io/transaction/txHash', + 'https://sancho.cardanoscan.io/transaction/txHash', ) expect(sanchoExplorer[Explorers.Explorer.CardanoScan].pool('poolId')).toBe( - 'https://cardanoscan.io/pool/poolId', + 'https://sancho.cardanoscan.io/pool/poolId', ) + expect( + sanchoExplorer[Explorers.Explorer.CardanoScan].stake('stakeAddress'), + ).toBe('https://sancho.cardanoscan.io/stakeKey/stakeAddress') expect( sanchoExplorer[Explorers.Explorer.CExplorer].token('fingerprint'), - ).toBe('https://cexplorer.io/asset/fingerprint') + ).toBe('https://sancho.cexplorer.io/asset/fingerprint') expect( sanchoExplorer[Explorers.Explorer.CExplorer].address('address'), - ).toBe('https://cexplorer.io/address/address') + ).toBe('https://sancho.cexplorer.io/address/address') expect(sanchoExplorer[Explorers.Explorer.CExplorer].tx('txHash')).toBe( - 'https://cexplorer.io/tx/txHash', + 'https://sancho.cexplorer.io/tx/txHash', ) expect(sanchoExplorer[Explorers.Explorer.CExplorer].pool('poolId')).toBe( - 'https://cexplorer.io/pool/poolId', + 'https://sancho.cexplorer.io/pool/poolId', + ) + expect( + sanchoExplorer[Explorers.Explorer.CExplorer].stake('stakeAddress'), + ).toBe('https://sancho.cexplorer.io/stake/stakeAddress') + }) + + it('should generate the correct URLs for Preview', () => { + const previewExplorer = explorerManager[Chain.Network.Preview] + expect( + previewExplorer[Explorers.Explorer.CardanoScan].token('fingerprint'), + ).toBe('https://preview.cardanoscan.io/token/fingerprint') + expect( + previewExplorer[Explorers.Explorer.CardanoScan].address('address'), + ).toBe('https://preview.cardanoscan.io/address/address') + expect(previewExplorer[Explorers.Explorer.CardanoScan].tx('txHash')).toBe( + 'https://preview.cardanoscan.io/transaction/txHash', + ) + expect(previewExplorer[Explorers.Explorer.CardanoScan].pool('poolId')).toBe( + 'https://preview.cardanoscan.io/pool/poolId', + ) + expect( + previewExplorer[Explorers.Explorer.CardanoScan].stake('stakeAddress'), + ).toBe('https://preview.cardanoscan.io/stakeKey/stakeAddress') + + expect( + previewExplorer[Explorers.Explorer.CExplorer].token('fingerprint'), + ).toBe('https://preview.cexplorer.io/asset/fingerprint') + expect( + previewExplorer[Explorers.Explorer.CExplorer].address('address'), + ).toBe('https://preview.cexplorer.io/address/address') + expect(previewExplorer[Explorers.Explorer.CExplorer].tx('txHash')).toBe( + 'https://preview.cexplorer.io/tx/txHash', ) + expect(previewExplorer[Explorers.Explorer.CExplorer].pool('poolId')).toBe( + 'https://preview.cexplorer.io/pool/poolId', + ) + expect( + previewExplorer[Explorers.Explorer.CExplorer].stake('stakeAddress'), + ).toBe('https://preview.cexplorer.io/stake/stakeAddress') }) }) diff --git a/packages/explorers/src/explorer-manager.ts b/packages/explorers/src/explorer-manager.ts index c2c902718f..eb57658abb 100644 --- a/packages/explorers/src/explorer-manager.ts +++ b/packages/explorers/src/explorer-manager.ts @@ -13,12 +13,15 @@ export const explorerManager: Readonly< address: (address) => `https://cardanoscan.io/address/${address}`, tx: (txHash) => `https://cardanoscan.io/transaction/${txHash}`, pool: (poolId) => `https://cardanoscan.io/pool/${poolId}`, + stake: (stakeAddress) => + `https://cardanoscan.io/stakeKey/${stakeAddress}`, }, [Explorers.Explorer.CExplorer]: { token: (fingerprint) => `https://cexplorer.io/asset/${fingerprint}`, address: (address) => `https://cexplorer.io/address/${address}`, tx: (txHash) => `https://cexplorer.io/tx/${txHash}`, pool: (poolId) => `https://cexplorer.io/pool/${poolId}`, + stake: (stakeAddress) => `https://cexplorer.io/stake/${stakeAddress}`, }, }, [Chain.Network.Preprod]: { @@ -28,6 +31,8 @@ export const explorerManager: Readonly< address: (address) => `https://preprod.cardanoscan.io/address/${address}`, tx: (txHash) => `https://preprod.cardanoscan.io/transaction/${txHash}`, pool: (poolId) => `https://preprod.cardanoscan.io/pool/${poolId}`, + stake: (stakeAddress) => + `https://preprod.cardanoscan.io/stakeKey/${stakeAddress}`, }, [Explorers.Explorer.CExplorer]: { token: (fingerprint) => @@ -35,20 +40,48 @@ export const explorerManager: Readonly< address: (address) => `https://preprod.cexplorer.io/address/${address}`, tx: (txHash) => `https://preprod.cexplorer.io/tx/${txHash}`, pool: (poolId) => `https://preprod.cexplorer.io/pool/${poolId}`, + stake: (stakeAddress) => + `https://preprod.cexplorer.io/stake/${stakeAddress}`, }, }, [Chain.Network.Sancho]: { [Explorers.Explorer.CardanoScan]: { - token: (fingerprint) => `https://cardanoscan.io/token/${fingerprint}`, - address: (address) => `https://cardanoscan.io/address/${address}`, - tx: (txHash) => `https://cardanoscan.io/transaction/${txHash}`, - pool: (poolId) => `https://cardanoscan.io/pool/${poolId}`, + token: (fingerprint) => + `https://sancho.cardanoscan.io/token/${fingerprint}`, + address: (address) => `https://sancho.cardanoscan.io/address/${address}`, + tx: (txHash) => `https://sancho.cardanoscan.io/transaction/${txHash}`, + pool: (poolId) => `https://sancho.cardanoscan.io/pool/${poolId}`, + stake: (stakeAddress) => + `https://sancho.cardanoscan.io/stakeKey/${stakeAddress}`, }, [Explorers.Explorer.CExplorer]: { - token: (fingerprint) => `https://cexplorer.io/asset/${fingerprint}`, - address: (address) => `https://cexplorer.io/address/${address}`, - tx: (txHash) => `https://cexplorer.io/tx/${txHash}`, - pool: (poolId) => `https://cexplorer.io/pool/${poolId}`, + token: (fingerprint) => + `https://sancho.cexplorer.io/asset/${fingerprint}`, + address: (address) => `https://sancho.cexplorer.io/address/${address}`, + tx: (txHash) => `https://sancho.cexplorer.io/tx/${txHash}`, + pool: (poolId) => `https://sancho.cexplorer.io/pool/${poolId}`, + stake: (stakeAddress) => + `https://sancho.cexplorer.io/stake/${stakeAddress}`, + }, + }, + [Chain.Network.Preview]: { + [Explorers.Explorer.CardanoScan]: { + token: (fingerprint) => + `https://preview.cardanoscan.io/token/${fingerprint}`, + address: (address) => `https://preview.cardanoscan.io/address/${address}`, + tx: (txHash) => `https://preview.cardanoscan.io/transaction/${txHash}`, + pool: (poolId) => `https://preview.cardanoscan.io/pool/${poolId}`, + stake: (stakeAddress) => + `https://preview.cardanoscan.io/stakeKey/${stakeAddress}`, + }, + [Explorers.Explorer.CExplorer]: { + token: (fingerprint) => + `https://preview.cexplorer.io/asset/${fingerprint}`, + address: (address) => `https://preview.cexplorer.io/address/${address}`, + tx: (txHash) => `https://preview.cexplorer.io/tx/${txHash}`, + pool: (poolId) => `https://preview.cexplorer.io/pool/${poolId}`, + stake: (stakeAddress) => + `https://preview.cexplorer.io/stake/${stakeAddress}`, }, }, }) diff --git a/packages/portfolio/src/adapters/dullahan-api/api-maker.ts b/packages/portfolio/src/adapters/dullahan-api/api-maker.ts index 2dd5d3e43d..6e15bb8bb8 100644 --- a/packages/portfolio/src/adapters/dullahan-api/api-maker.ts +++ b/packages/portfolio/src/adapters/dullahan-api/api-maker.ts @@ -300,7 +300,7 @@ export const portfolioApiMaker = ({ export const apiConfig: ApiConfig = freeze( { - mainnet: { + [Chain.Network.Mainnet]: { tokenDiscovery: 'https://zero.yoroiwallet.com/tokens/discovery', tokenInfo: 'https://zero.yoroiwallet.com/tokens/info', tokenInfos: 'https://zero.yoroiwallet.com/tokens/info/multi', @@ -309,7 +309,7 @@ export const apiConfig: ApiConfig = freeze( tokenPriceHistory: 'https://add50d9d-76d7-47b7-b17f-e34021f63a02.mock.pstmn.io/v1/token-price-history', }, - preprod: { + [Chain.Network.Preprod]: { tokenDiscovery: 'https://yoroi-backend-zero-preprod.emurgornd.com/tokens/discovery', tokenInfo: 'https://yoroi-backend-zero-preprod.emurgornd.com/tokens/info', @@ -322,7 +322,7 @@ export const apiConfig: ApiConfig = freeze( tokenPriceHistory: 'https://add50d9d-76d7-47b7-b17f-e34021f63a02.mock.pstmn.io/v1/token-price-history', }, - sancho: { + [Chain.Network.Sancho]: { tokenDiscovery: 'https://yoroi-backend-zero-sanchonet.emurgornd.com/tokens/discovery', tokenInfo: @@ -336,6 +336,19 @@ export const apiConfig: ApiConfig = freeze( tokenPriceHistory: 'https://add50d9d-76d7-47b7-b17f-e34021f63a02.mock.pstmn.io/v1/token-price-history', }, + [Chain.Network.Preview]: { + tokenDiscovery: + 'https://yoroi-backend-zero-preview.emurgornd.com/tokens/discovery', + tokenInfo: 'https://yoroi-backend-zero-preview.emurgornd.com/tokens/info', + tokenInfos: + 'https://yoroi-backend-zero-preview.emurgornd.com/tokens/info/multi', + tokenTraits: + 'https://yoroi-backend-zero-preview.emurgornd.com/tokens/nft/traits', + tokenActivityUpdates: + 'https://yoroi-backend-zero-preview.emurgornd.com/defi/token-activity', + tokenPriceHistory: + 'https://add50d9d-76d7-47b7-b17f-e34021f63a02.mock.pstmn.io/v1/token-price-history', + }, }, true, ) diff --git a/packages/staking/src/governance/config.ts b/packages/staking/src/governance/config.ts index c1e309080c..aa6f799bfb 100644 --- a/packages/staking/src/governance/config.ts +++ b/packages/staking/src/governance/config.ts @@ -9,21 +9,27 @@ export const GOVERNANCE_ENDPOINTS: Readonly< } > > = { - mainnet: { + [Chain.Network.Mainnet]: { getStakeKeyState: 'https://zero.yoroiwallet.com/stakekeys/{{STAKE_KEY_HASH}}/state', getDRepById: 'https://zero.yoroiwallet.com/dreps/{{DREP_ID}}/state', }, - preprod: { + [Chain.Network.Preprod]: { getStakeKeyState: 'https://yoroi-backend-zero-preprod.emurgornd.com/stakekeys/{{STAKE_KEY_HASH}}/state', getDRepById: 'https://yoroi-backend-zero-preprod.emurgornd.com/dreps/{{DREP_ID}}/state', }, - sancho: { + [Chain.Network.Sancho]: { getStakeKeyState: 'https://yoroi-backend-zero-sanchonet.emurgornd.com/stakekeys/{{STAKE_KEY_HASH}}/state', getDRepById: 'https://yoroi-backend-zero-sanchonet.emurgornd.com/dreps/{{DREP_ID}}/state', }, + [Chain.Network.Preview]: { + getStakeKeyState: + 'https://yoroi-backend-zero-preview.emurgornd.com/stakekeys/{{STAKE_KEY_HASH}}/state', + getDRepById: + 'https://yoroi-backend-zero-preview.emurgornd.com/dreps/{{DREP_ID}}/state', + }, } as const diff --git a/packages/types/src/chain/network.ts b/packages/types/src/chain/network.ts index 28112d38a5..26d2b0fd75 100644 --- a/packages/types/src/chain/network.ts +++ b/packages/types/src/chain/network.ts @@ -10,3 +10,4 @@ export type ChainSupportedNetworks = | ChainNetwork.Mainnet | ChainNetwork.Preprod | ChainNetwork.Sancho + | ChainNetwork.Preview diff --git a/packages/types/src/explorers/manager.ts b/packages/types/src/explorers/manager.ts index b9e41913c0..abd0768846 100644 --- a/packages/types/src/explorers/manager.ts +++ b/packages/types/src/explorers/manager.ts @@ -3,4 +3,5 @@ export type ExplorersManager = Readonly<{ address: (address: string) => string tx: (txHash: string) => string pool: (poolId: string) => string + stake: (stakeAddress: string) => string }>