Skip to content

Commit

Permalink
Explicitly define tokens per ParaTime
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Apr 15, 2024
1 parent a48aea3 commit 7e67c66
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
1 change: 1 addition & 0 deletions .changelog/1376.trivial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove unused local layer configs and explicitly define tokens per ParaTime
4 changes: 2 additions & 2 deletions src/app/components/logo/SmallTokenLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import euroELogo from '../../../../public/euroe.png'

export const SmallTokenLogo: FC<{ ticker: Ticker }> = ({ ticker }) => {
switch (ticker) {
case 'ROSE':
case Ticker.ROSE:
return <SmallOasisLogo />
case 'EUROe':
case Ticker.EUROe:
return <img src={euroELogo} width={25} alt={ticker} />
default:
return null
Expand Down
36 changes: 25 additions & 11 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// We get this from the generated code to avoid circular imports
// eslint-disable-next-line no-restricted-imports
import { Layer } from './oasis-nexus/generated/api'
import { getTokenForNetwork, NativeToken, NativeTokenInfo } from './types/ticker'
import { NativeToken, NativeTokenInfo } from './types/ticker'
import { SearchScope } from './types/searchScope'

export const consensusDecimals = 9
Expand All @@ -19,11 +19,11 @@ type LayerNetwork = {
runtimeId: string | undefined

/**
* What are the native tokens on this layer?
*
* (If not given, the network's default token will be used.)
* What are the tokens on this layer?
* Note: native token must be the first on the list. Others are just incorrectly named "Native"
* See terminology in https://github.com/oasisprotocol/oasis-sdk/blob/5bec25f/client-sdk/go/config/default.go#L109-L120
*/
tokens?: NativeTokenInfo[]
tokens: [NativeTokenInfo, ...NativeTokenInfo[]]

/**
* What fiat currency should we use for displaying value?
Expand All @@ -44,6 +44,15 @@ export enum RuntimeTypes {
}

// consensusConfig: max_block_size = 22020096, max_block_gas = unlimited right now
export const consensusConfig = {
mainnet: {
tokens: [NativeToken.ROSE],
},
testnet: {
tokens: [NativeToken.TEST],
},
decimals: consensusDecimals,
}

const emeraldConfig: LayerConfig = {
mainnet: {
Expand All @@ -52,12 +61,14 @@ const emeraldConfig: LayerConfig = {
// Match max_batch_gas https://github.com/oasisprotocol/emerald-paratime/blob/5a36a646b989e510fadc0029178fe96a24cad101/src/lib.rs#L112-L112
blockGasLimit: 10_000_000,
runtimeId: '000000000000000000000000000000000000000000000000e2eaa99fc008f87f',
tokens: [NativeToken.ROSE],
},
testnet: {
activeNodes: 32,
address: 'oasis1qr629x0tg9gm5fyhedgs9lw5eh3d8ycdnsxf0run',
blockGasLimit: 30_000_000,
runtimeId: '00000000000000000000000000000000000000000000000072c8215e60d5bca7',
tokens: [NativeToken.TEST],
},
decimals: 18,
type: RuntimeTypes.Evm,
Expand All @@ -69,12 +80,14 @@ const cipherConfig: LayerConfig = {
address: 'oasis1qrnu9yhwzap7rqh6tdcdcpz0zf86hwhycchkhvt8',
blockGasLimit: undefined, // TODO: provide gas limit
runtimeId: '000000000000000000000000000000000000000000000000e199119c992377cb',
tokens: [NativeToken.ROSE],
},
testnet: {
activeNodes: 15,
address: 'oasis1qqdn25n5a2jtet2s5amc7gmchsqqgs4j0qcg5k0t',
blockGasLimit: undefined, // TODO: provide gas limit
runtimeId: '0000000000000000000000000000000000000000000000000000000000000000',
tokens: [NativeToken.TEST],
},
decimals: 9,
type: RuntimeTypes.Oasis,
Expand All @@ -87,13 +100,15 @@ const sapphireConfig: LayerConfig = {
// See max_batch_gas https://github.com/oasisprotocol/sapphire-paratime/blob/main/runtime/src/lib.rs#L166
blockGasLimit: 15_000_000,
runtimeId: '000000000000000000000000000000000000000000000000f80306c9858e7279',
tokens: [NativeToken.ROSE],
},
testnet: {
activeNodes: 21,
address: 'oasis1qqczuf3x6glkgjuf0xgtcpjjw95r3crf7y2323xd',
// See max_batch_gas https://github.com/oasisprotocol/sapphire-paratime/blob/main/runtime/src/lib.rs#L166
blockGasLimit: 15_000_000,
runtimeId: '000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c',
tokens: [NativeToken.TEST],
},
decimals: 18,
type: RuntimeTypes.Evm,
Expand All @@ -105,13 +120,13 @@ const pontusxConfig: LayerConfig = {
address: undefined,
blockGasLimit: undefined,
runtimeId: undefined,
tokens: [NativeToken.EUROe],
},
testnet: {
activeNodes: 1,
address: 'oasis1qr02702pr8ecjuff2z3es254pw9xl6z2yg9qcc6c',
blockGasLimit: 15_000_000,
runtimeId: '0000000000000000000000000000000000000000000000004febe52eb412b421',
// Kindly note, the sequence is important as src/app/utils/rpc-utils.ts will utilize the first token.
tokens: [NativeToken.EUROe, NativeToken.TEST],
fiatCurrency: 'eur',
},
Expand Down Expand Up @@ -154,13 +169,12 @@ export const getTokensForScope = (scope: SearchScope | undefined): NativeTokenIn
if (!scope) {
return []
}
const { network, layer } = scope
const networkDefault = getTokenForNetwork(network)

if (layer !== Layer.consensus) {
return paraTimesConfig[layer][network].tokens ?? [networkDefault]
if (scope.layer !== Layer.consensus) {
return paraTimesConfig[scope.layer][scope.network].tokens
} else {
return consensusConfig[scope.network].tokens
}
return [networkDefault]
}

export const getFiatCurrencyForScope = (scope: SearchScope | undefined) =>
Expand Down
8 changes: 0 additions & 8 deletions src/types/ticker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Network } from './network'
import { TFunction } from 'i18next'

export type Ticker = (typeof Ticker)[keyof typeof Ticker]
Expand Down Expand Up @@ -31,13 +30,6 @@ export const NativeToken = {
},
} as const

export const networkToken: Record<Network, NativeTokenInfo> = {
[Network.mainnet]: NativeToken.ROSE,
[Network.testnet]: NativeToken.TEST,
}

export const getTokenForNetwork = (network: Network): NativeTokenInfo => networkToken[network]

export const getNameForTicker = (_t: TFunction, ticker: string): string => {
// TODO: how do we translate ticker names?
return ticker
Expand Down

0 comments on commit 7e67c66

Please sign in to comment.