-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1069 from novasamatech/rc/1.1.0-127
Release candidate - 1.1.0
- Loading branch information
Showing
808 changed files
with
14,231 additions
and
13,112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
Nova Spektr - Polkadot, Kusama enterprise application | ||
|
||
Copyright 2023 Novasama Technologies PTE. LTD. | ||
Copyright 2022-2023 Novasama Technologies PTE. LTD. | ||
This product includes software developed at Novasama Technologies PTE. LTD. | ||
License Rights transferred from Novasama Technologies PTE. LTD to Novasama Technologies GmbH starting from 1st of April 2023 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Effector | ||
|
||
### Sample with type guard | ||
Sometimes you need to filter `effector` result and pass it further into `target`, but TypeScript warns you that | ||
types do not align: `error: clock should extend target type`. | ||
|
||
To fix this you need to provide a `type guard` as `filter` return value. | ||
|
||
Let's say `getConfigFx` returns `XcmConfig | null` and `calculateFinalConfigFx` accepts only `XcmConfig`. | ||
To make it work we do the following: | ||
|
||
```typescript | ||
const getConfigFx = createEffect((config: XcmConfig): XcmConfig | null => { | ||
// some actions | ||
}); | ||
|
||
const calculateFinalConfigFx = createEffect((config: XcmConfig): string => { | ||
// some actions | ||
}); | ||
|
||
sample({ | ||
clock: getConfigFx.doneData, | ||
filter: (config: XcmConfig | null): config is XcmConfig => Boolean(config), | ||
target: calculateFinalConfigFx, | ||
}); | ||
``` | ||
|
||
### AppStarted event | ||
Because `effetor` is a pure JS library, it's units could be used in any part of the app. | ||
So in order to emit some important event like `appStarted` we can do the following: | ||
```typescript | ||
// index.tsx - app's entrypoint | ||
|
||
const container = document.getElementById('app'); | ||
if (!container) { | ||
throw new Error('Root container is missing in index.html'); | ||
} | ||
|
||
kernelModel.events.appStarted(); | ||
|
||
createRoot(container).render( | ||
<Router> | ||
<App /> | ||
</Router> | ||
); | ||
``` | ||
|
||
[Documentation](https://effector.dev/docs/typescript/typing-effector/#filter--fn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Fiat price | ||
|
||
Now fiat price feature consists of `PriceAdapter` type. Each adapter should implement two functions 1. to return price for selected crypto assets with selected currencies (fiat or crypto) and 2. return history data for selected asset, currency and time range. | ||
|
||
```typescript | ||
getPrice: (ids: AssetId[], currencies: Currency[], includeRateChange: boolean) => Promise<PriceObject>; | ||
getHistoryData: (id: AssetId, currency: Currency, from: number, to: number) => Promise<PriceRange[]>; | ||
``` | ||
|
||
And we have two util functions, which can convert `PriceObject` format to `PriceDB` format. | ||
|
||
`PriceObject` is based on coingecko format. | ||
`PriceDB` is based on IndexedDB storage object. | ||
|
||
```typescript | ||
type PriceObject = Record<AssetId, AssetPrice>; | ||
type AssetPrice = Record<Currency, PriceItem>; | ||
type PriceItem = { | ||
price: number; | ||
change: number; | ||
}; | ||
``` | ||
|
||
example | ||
|
||
```typescript | ||
const priceObject = { | ||
polkadot: { | ||
usd: { | ||
price: 4.1 | ||
change: -0.1 | ||
} | ||
} | ||
} | ||
``` | ||
|
||
```typescript | ||
type PriceDB = { | ||
assetId: AssetId; | ||
currency: Currency; | ||
price: number; | ||
change: number; | ||
}; | ||
``` | ||
|
||
example | ||
|
||
```typescript | ||
const priceArray = [{ | ||
assetId: 'polkadot', | ||
currency: 'usd', | ||
price: 4.1, | ||
change: -0.1 | ||
}] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.