-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure PoS and PoW Nimiq SDKs can live together on the same page
To do this, we load the PoW SDK first, as it automatically sets a global `Nimiq` variable. Then in the loader for the PoS SDK, we check for that variable and store it as `NimiqPoW`, overwriting `Nimiq` with the PoS SDK.
- Loading branch information
Showing
5 changed files
with
22 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
// @ts-expect-error Cannot read types | ||
import * as Nimiq from '../../node_modules/@nimiq/albatross-wasm/web/index.js'; | ||
// @ts-expect-error window.Nimiq is not defined (because we already define Albatross as a global) | ||
window.Nimiq = Nimiq; | ||
import * as NimiqPoS from '../../node_modules/@nimiq/albatross-wasm/web/index.js'; | ||
|
||
// Move any defined `Nimiq` global to `NimiqPoW` | ||
// @ts-expect-error window.NimiqPoW is not defined | ||
window.NimiqPoW = window.Nimiq; | ||
|
||
// Overwrite the global `Nimiq` with the PoS version | ||
// @ts-expect-error window.Nimiq is not defined | ||
window.Nimiq = NimiqPoS; |
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