refactor(setups): create setups module#308
Conversation
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Reviewer's GuideRefactors configuration types into a new setups module that models on-chain setup records and prepares environment-specific setups, while simplifying nsui exports. Class diagram for new setups module configuration typesclassDiagram
class NbtcCfg {
+string nbtc_pkg
+string nbtc_contract
+string sui_fallback_addr
}
class BtcLCCfg {
+string lc_pkg
+string lc_contract
}
class Setup {
+number id
+BtcNet btc_network
+SuiNet sui_network
+number is_active
}
class orgSetups {
+Record~string, Setup[]~ setups
}
Setup --|> NbtcCfg
Setup --|> BtcLCCfg
orgSetups --> Setup
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
| const storage = new D1Storage(env.DB); | ||
| const activeNetworks = await storage.getActiveNetworks(); | ||
| const storage = new D1Storage(env.DB, env.SETUP_ENV); | ||
| const activeNetworks = storage.getSuiNetworks(); |
There was a problem hiding this comment.
why did we remove the await here? Since the method is still async and returns Promise<SuiNet[]>.
There was a problem hiding this comment.
because it's stored in TS files, not in DB. We had a few discussions about it during our planning.
packages/sui-indexer/src/storage.ts
Outdated
|
|
||
| getSuiNetworks(): SuiNet[] { | ||
| const l: SuiNet[] = []; | ||
| for (const [_, s] of this.activeSetups) { |
There was a problem hiding this comment.
this.activeSetups is an array why are iterating as keu value pairs?
There was a problem hiding this comment.
it was a mapping in my previous iteration, I didn't fix all bugs yet.
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
| lc_contract: string; | ||
| } | ||
|
|
||
| // This types uses only SQLite types and all structures form that types. |
There was a problem hiding this comment.
i thought we removed the table
| } | ||
|
|
||
| // TODO: should be by setup_id | ||
| async getBroadcastedRedeemTxIds(btcNet: string): Promise<string[]> { |
There was a problem hiding this comment.
it should stay by netowrk, we can have 3 setups all pointing to the same bitcoin network
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
Summary by Sourcery
Introduce a dedicated setups module to centralize configuration for NBTC and BTC light client setups across Sui networks.
New Features:
Enhancements: