Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Resolve: "Get rid of chaosnet in type Network in favour of using mainnet only" #1524

Merged
merged 1 commit into from
Jun 9, 2021

Conversation

veado
Copy link
Collaborator

@veado veado commented Jun 9, 2021

Closes #1522

@veado veado self-assigned this Jun 9, 2021
@@ -65,7 +65,7 @@ export type ApiUrl = {
openExternal: (url: string) => Promise<void>
}

export type Network = 'testnet' | 'chaosnet' | 'mainnet'
export type Network = 'testnet' | 'mainnet'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Same type as we have with Network in xchain-client. However, I would still stick with a custom type here to be independent of xchain-* - just in case xchain-* will change it for whatever reason in the future.

mainnet: A.empty,
chaosnet: A.empty,
testnet: A.empty
mainnet: [],
Copy link
Collaborator Author

@veado veado Jun 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thatStrangeGuyThorchain BTW: fp-ts has marked A.empty as deprecated with a note Use a new [] instead., but I could never find such "new" type [] there. Any idea?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure but i suppose that means exactly what you have done:
create a new empty array...
actually seems a pointer to a single instance of an array is unsafe actually 'cuz anyone can push or smth like that to it. i mean this is a mutable object and it seems this is a reason why fp-ts deprecated it.

another safely way to use empty array from fp-ts as initial value here is to use ReadOnlyArray
so with this it will be like this:

import * as ROA from 'fp-ts/ReadOnlyArray`

export const USER_NODES_STORAGE_DEFAULT: UserNodesStorage = {
  version: USER_NODES_STORAGE_VERSION,
  mainnet: ROA.empty,
  testnet: ROA.empty
}

which is read-only and safer at type-/runtime-levels

@veado veado changed the title Resolve: "Get rid of chaosnet in type Network in favour using mainnet only" Resolve: "Get rid of chaosnet in type Network in favour of using mainnet only" Jun 9, 2021
mainnet: A.empty,
chaosnet: A.empty,
testnet: A.empty
mainnet: [],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure but i suppose that means exactly what you have done:
create a new empty array...
actually seems a pointer to a single instance of an array is unsafe actually 'cuz anyone can push or smth like that to it. i mean this is a mutable object and it seems this is a reason why fp-ts deprecated it.

another safely way to use empty array from fp-ts as initial value here is to use ReadOnlyArray
so with this it will be like this:

import * as ROA from 'fp-ts/ReadOnlyArray`

export const USER_NODES_STORAGE_DEFAULT: UserNodesStorage = {
  version: USER_NODES_STORAGE_VERSION,
  mainnet: ROA.empty,
  testnet: ROA.empty
}

which is read-only and safer at type-/runtime-levels

@veado veado merged commit d4b7bb7 into develop Jun 9, 2021
@veado veado deleted the issue-1522/remove-chaosnet branch June 9, 2021 14:26
veado added a commit that referenced this pull request Jun 9, 2021
veado added a commit that referenced this pull request Jun 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get rid of chaosnet in type Network in favour using mainnet only
2 participants