Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added preview network #3098

Merged
merged 7 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,27 @@ const AlonzoTestnetExplorers: Array<$ReadOnly<ExplorerRow>> = [
},
];

const CardanoPreviewTestnetExplorers: Array<$ReadOnly<ExplorerRow>> = [
{
ExplorerId: 5_50,
NetworkId: networks.CardanoPreviewTestnet.NetworkId,
IsBackup: true,
Endpoints: {
address: 'https://preview.cardanoscan.io/address/',
transaction: 'https://preview.cardanoscan.io/transaction/',
pool: 'https://preview.cardanoscan.io/pool/',
stakeAddress: 'https://preview.cardanoscan.io/stakeKey/',
token: 'https://preview.cardanoscan.io/token/',
},
Name: 'CardanoScan',
},
];

export const prepackagedExplorers: Map<number, $ReadOnlyArray<$ReadOnly<ExplorerRow>>> = new Map([
[networks.CardanoMainnet.NetworkId, CardanoMainnetExplorers],
[networks.CardanoTestnet.NetworkId, CardanoTestnetExplorers],
[networks.CardanoPreprodTestnet.NetworkId, CardanoPreprodTestnetExplorers],
[networks.CardanoPreviewTestnet.NetworkId, CardanoPreviewTestnetExplorers],
[networks.JormungandrMainnet.NetworkId, JormungandrExplorers],
[networks.ErgoMainnet.NetworkId, ErgoExplorers],
[networks.AlonzoTestnet.NetworkId, AlonzoTestnetExplorers],
Expand All @@ -184,7 +201,10 @@ export const prepackagedDefaultExplorers:
CardanoTestnetExplorers.find(explorer => explorer.IsBackup)
)],
[networks.CardanoPreprodTestnet.NetworkId, getOrThrow(
CardanoTestnetExplorers.find(explorer => explorer.IsBackup)
CardanoPreprodTestnetExplorers.find(explorer => explorer.IsBackup)
)],
[networks.CardanoPreviewTestnet.NetworkId, getOrThrow(
CardanoPreviewTestnetExplorers.find(explorer => explorer.IsBackup)
)],
[networks.JormungandrMainnet.NetworkId, getOrThrow(
JormungandrExplorers.find(explorer => explorer.IsBackup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,55 @@ export const networks = Object.freeze({
CoinType: CoinTypes.CARDANO,
Fork: CardanoForks.Haskell,
}: NetworkRow),
CardanoPreviewTestnet: ({
NetworkId: 3_50,
NetworkName: 'Cardano Preview Testnet',
Backend: {
BackendService: environment.isTest()
? 'http://localhost:21000'
: 'https://preview-backend.emurgornd.com',
WebSocket: environment.isTest()
? 'ws://localhost:21000'
: 'wss://preview-backend.emurgornd.com:443',
TokenInfoService:
'https://stage-cdn.yoroiwallet.com',
},
BaseConfig: ([
Object.freeze({
StartAt: 0,
ChainNetworkId: '0',
ByronNetworkId: 2,
GenesisDate: '1666656000000',
SlotsPerEpoch: 21600,
SlotDuration: 20,
}),
Object.freeze({
StartAt: 0,
SlotsPerEpoch: 86400,
SlotDuration: 1,
PerEpochPercentageReward: 69344,
LinearFee: {
coefficient: '44',
constant: '155381',
},
CoinsPerUtxoWord: '34482',
MinimumUtxoVal: '1000000',
PoolDeposit: '500000000',
KeyDeposit: '2000000',
})
]: CardanoHaskellBaseConfig),
CoinType: CoinTypes.CARDANO,
Fork: CardanoForks.Haskell,
}: NetworkRow),
});

export function isTestnet(
network: $ReadOnly<NetworkRow>,
): boolean {
return network.NetworkId === networks.JormungandrMainnet.NetworkId
|| network.NetworkId === networks.CardanoTestnet.NetworkId
|| network.NetworkId === networks.CardanoPreprodTestnet.NetworkId;
|| network.NetworkId === networks.CardanoPreprodTestnet.NetworkId
|| network.NetworkId === networks.CardanoPreviewTestnet.NetworkId;

}

Expand Down Expand Up @@ -330,7 +371,10 @@ export const defaultAssets: Array<
policyId: PRIMARY_ASSET_CONSTANTS.Cardano,
assetName: PRIMARY_ASSET_CONSTANTS.Cardano,
ticker:
(network === networks.CardanoTestnet || network === networks.CardanoPreprodTestnet || network === networks.AlonzoTestnet)
(network === networks.CardanoTestnet
|| network === networks.CardanoPreprodTestnet
|| network === networks.CardanoPreviewTestnet
|| network === networks.AlonzoTestnet)
? 'TADA'
: 'ADA',
longName: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Props = {|
+onCardano: void => void,
+onCardanoTestnet: void => void,
+onCardanoPreprodTestnet: void => void,
+onCardanoPreviewTestnet: void => void,
+onErgo: void | (void => void),
+onAlonzoTestnet: void => void,
+onExternalLinkClick: MouseEvent => void,
Expand Down Expand Up @@ -97,6 +98,26 @@ export default class PickCurrencyOptionDialog extends Component<Props> {
/>
</>
}
{(!environment.isProduction() || environment.isNightly() || environment.isTest()) &&
<>
<OptionBlock
parentName="PickCurrencyOptionDialog"
type="cardanoTestnet"
title="Cardano Preview Testnet"
onSubmit={this.props.onCardanoPreviewTestnet}
learnMoreText={
<>
{intl.formatMessage(messages.testnetDescription)}<br />
<a
href="https://testnets.cardano.org/"
onClick={event => this.props.onExternalLinkClick(event)}
>
{intl.formatMessage(globalMessages.learnMore)}
</a>
</>}
/>
</>
}
{/* <TODO:PENDING_REMOVAL> */}
{/*{(!environment.isProduction() || environment.isNightly() || environment.isTest()) &&*/}
{/* <OptionBlock*/}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class WalletAddPage extends Component<AllProps> {
onCardano={() => actions.profile.setSelectedNetwork.trigger(networks.CardanoMainnet)}
onCardanoTestnet={() => actions.profile.setSelectedNetwork.trigger(networks.CardanoTestnet)}
onCardanoPreprodTestnet={() => actions.profile.setSelectedNetwork.trigger(networks.CardanoPreprodTestnet)}
onCardanoPreviewTestnet={() => actions.profile.setSelectedNetwork.trigger(networks.CardanoPreviewTestnet)}
onErgo={(uiDialogs.isOpen(WalletConnectHWOptionDialog) || uiDialogs.isOpen(WalletCreateOptionDialog))
? undefined
: () => actions.profile.setSelectedNetwork.trigger(networks.ErgoMainnet)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Props = {|
+onCardano: void => void,
+onCardanoTestnet: void => void,
+onCardanoPreprodTestnet: void => void,
+onCardanoPreviewTestnet: void => void,
+onErgo: void | (void => void),
+onAlonzoTestnet: void => void,
|};
Expand All @@ -25,6 +26,7 @@ export default class PickCurrencyDialogContainer extends Component<Props> {
onCardano={this.props.onCardano}
onCardanoTestnet={this.props.onCardanoTestnet}
onCardanoPreprodTestnet={this.props.onCardanoPreprodTestnet}
onCardanoPreviewTestnet={this.props.onCardanoPreviewTestnet}
onErgo={this.props.onErgo}
onAlonzoTestnet={this.props.onAlonzoTestnet}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const CARDANO_DELEGATION: TopbarCategory = registerCategory({
(environment.isTest()
|| networkId === networks.CardanoTestnet.NetworkId
|| networkId === networks.CardanoPreprodTestnet.NetworkId
|| networkId === networks.CardanoPreviewTestnet.NetworkId
);
},
});
Expand Down
1 change: 1 addition & 0 deletions packages/yoroi-extension/chrome/manifest.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default (isDebug: boolean, shouldInjectConnector: boolean): * => buildMan
additional: {
'connect-src': [
serverToPermission(Servers.Primary),
serverToPermission(Servers.Testnet),
],
'frame-src': [
POOLS_UI_URL_FOR_YOROI,
Expand Down
1 change: 1 addition & 0 deletions packages/yoroi-extension/chrome/manifest.mainnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default (isDebug: boolean, shouldInjectConnector: boolean): * => buildMan
additional: {
'connect-src': [
serverToPermission(Servers.Primary),
serverToPermission(Servers.Testnet),
],
'frame-src': [
POOLS_UI_URL_FOR_YOROI,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default (isDebug: boolean, shouldInjectConnector: boolean): * => buildMan
additional: {
'connect-src': [
serverToPermission(Servers.Primary),
serverToPermission(Servers.Testnet),
],
'frame-src': [
POOLS_UI_URL_FOR_YOROI,
Expand Down
1 change: 1 addition & 0 deletions packages/yoroi-extension/scripts/connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const Ports = {
const Servers = {
// this allows connecting to multiple different backends for different currencies
Primary: '*.yoroiwallet.com',
Testnet: '*.emurgornd.com',
};

module.exports = {
Expand Down