-
Notifications
You must be signed in to change notification settings - Fork 50
Resolve: "Get rid of chaosnet in type Network in favour of using mainnet only" #1524
Conversation
@@ -65,7 +65,7 @@ export type ApiUrl = { | |||
openExternal: (url: string) => Promise<void> | |||
} | |||
|
|||
export type Network = 'testnet' | 'chaosnet' | 'mainnet' | |||
export type Network = 'testnet' | 'mainnet' |
There was a problem hiding this comment.
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: [], |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
mainnet: A.empty, | ||
chaosnet: A.empty, | ||
testnet: A.empty | ||
mainnet: [], |
There was a problem hiding this comment.
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
Closes #1522