-
Notifications
You must be signed in to change notification settings - Fork 16
feat: add Firo network support #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
reubenyap
wants to merge
10
commits into
rosen-bridge:dev
Choose a base branch
from
reubenyap:cursor/-bc-2b025ca2-9368-47a2-ac62-6845cce1b479-2154
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
910d66d
feat: add Firo network support
cursoragent d28d22f
fix: address review feedback on Firo integration
cursoragent ed5812b
fix(firo): remove unused tsx devDependency
cursoragent e561b34
fix(rosen-service2): narrow chain types to exclude firo
claude 3ff5f09
Merge branch 'dev' into cursor/-bc-2b025ca2-9368-47a2-ac62-6845cce1b4…
reubenyap ea7ac2d
fix(firo-wallet): use isConnected in performConnect; add changeset
claude 9a596cf
Revert "fix(rosen-service2): narrow chain types to exclude firo"
reubenyap 5c28730
chore(changeset): split firo-network-support into per-package entries
reubenyap 5c1238a
chore: fix lint-staged knip workspace path on Windows
reubenyap 8da43ef
fix(rosen-service2): narrow chain types so firo doesn't break tsc
reubenyap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,18 @@ | ||
| --- | ||
| '@rosen-bridge/rosen-app': minor | ||
| '@rosen-network/firo': minor | ||
| '@rosen-ui/firo-wallet': minor | ||
| '@rosen-ui/constants': minor | ||
| '@rosen-bridge/icons': minor | ||
| '@rosen-ui/utils': patch | ||
| '@rosen-bridge/rosen-service': patch | ||
| '@rosen-bridge/rosen-service2': patch | ||
| --- | ||
|
|
||
| Add Firo network support across the bridge UI. | ||
|
|
||
| - Introduce `@rosen-network/firo` and `@rosen-ui/firo-wallet` packages. | ||
| - Register Firo in `@rosen-ui/constants`, icons, and address/tx URL helpers. | ||
| - Wire Firo into the rosen app (networks, wallets, env). | ||
| - Skip unconfigured chains gracefully in `rosen-service` commitment extractor registration. | ||
| - Narrow `createChainSpecificDataAdapter` to `keyof Chains` and index `configs.chains` with the same narrower type in `rosen-service2` so the switch remains exhaustive once Firo is added to `NETWORKS_KEYS`. |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,12 @@ | ||
| import { FiroNetwork } from '@rosen-network/firo/dist/client'; | ||
|
|
||
| import { unwrapFromObject } from '@/safeServerAction'; | ||
|
|
||
| import { LOCK_ADDRESSES } from '../../../configs'; | ||
| import * as actions from './server'; | ||
|
|
||
| export const firo = new FiroNetwork({ | ||
| lockAddress: LOCK_ADDRESSES.firo, | ||
| nextHeightInterval: 10, | ||
| ...unwrapFromObject(actions), | ||
| }); |
This file contains hidden or 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 @@ | ||
| export * from './client'; |
This file contains hidden or 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,50 @@ | ||
| 'use server'; | ||
|
|
||
| import { validateAddress as validateAddressCore } from '@rosen-network/base'; | ||
| import { | ||
| calculateFee as calculateFeeCore, | ||
| generateOpReturnData as generateOpReturnDataCore, | ||
| generateUnsignedTx as generateUnsignedTxCore, | ||
| getAddressBalance as getAddressBalanceCore, | ||
| getMaxTransferCreator as getMaxTransferCore, | ||
| getMinTransferCreator, | ||
| submitTransaction as submitTransactionCore, | ||
| } from '@rosen-network/firo'; | ||
|
|
||
| import { wrap } from '@/safeServerAction'; | ||
| import { getTokenMap } from '@/tokenMap/getServerTokenMap'; | ||
|
|
||
| export const calculateFee = wrap(calculateFeeCore, { | ||
| cache: 10 * 60 * 1000, | ||
| traceKey: 'firo:calculateFee', | ||
| }); | ||
|
|
||
| export const generateOpReturnData = wrap(generateOpReturnDataCore, { | ||
| traceKey: 'firo:generateOpReturnData', | ||
| }); | ||
|
|
||
| export const generateUnsignedTx = wrap(generateUnsignedTxCore(getTokenMap), { | ||
| traceKey: 'firo:generateUnsignedTx', | ||
| }); | ||
|
|
||
| export const getAddressBalance = wrap(getAddressBalanceCore, { | ||
| cache: 3000, | ||
| traceKey: 'firo:getAddressBalance', | ||
| }); | ||
|
|
||
| export const getMaxTransfer = wrap(getMaxTransferCore(getTokenMap), { | ||
| traceKey: 'firo:getMaxTransfer', | ||
| }); | ||
|
|
||
| export const getMinTransfer = wrap(getMinTransferCreator(getTokenMap), { | ||
| traceKey: 'firo:getMinTransfer', | ||
| }); | ||
|
|
||
| export const submitTransaction = wrap(submitTransactionCore, { | ||
| traceKey: 'firo:submitTransaction', | ||
| }); | ||
|
|
||
| export const validateAddress = wrap(validateAddressCore, { | ||
| cache: Infinity, | ||
| traceKey: 'firo:validateAddress', | ||
| }); |
This file contains hidden or 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 hidden or 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,9 @@ | ||
| import { FiroWallet } from '@rosen-ui/firo-wallet'; | ||
|
|
||
| import { firo } from '@/networks'; | ||
| import { getTokenMap } from '@/tokenMap/getClientTokenMap'; | ||
|
|
||
| export const firoWallet = new FiroWallet({ | ||
| networks: [firo], | ||
| getTokenMap, | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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,37 @@ | ||
| { | ||
| "name": "@rosen-network/firo", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "description": "This is a private package utilized within Rosen Bridge UI app", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/rosen-bridge/ui.git" | ||
| }, | ||
| "license": "MIT", | ||
| "type": "module", | ||
| "main": "dist/index.js", | ||
| "types": "dist/index.d.ts", | ||
| "scripts": { | ||
| "build": "tsc --build", | ||
| "lint": "eslint --fix . && npm run prettify", | ||
| "lint:check": "eslint . && npm run prettify:check", | ||
| "prettify": "prettier --write . --ignore-path ../../.gitignore", | ||
| "prettify:check": "prettier --check . --ignore-path ../../.gitignore", | ||
| "type-check": "tsc --noEmit" | ||
| }, | ||
| "dependencies": { | ||
| "@rosen-bridge/address-codec": "^1.2.0", | ||
| "@rosen-bridge/bitcoin-utxo-selection": "^2.0.3", | ||
| "@rosen-bridge/icons": "^3.5.0", | ||
| "@rosen-bridge/tokens": "^6.0.0", | ||
| "@rosen-network/base": "^0.5.2", | ||
| "@rosen-ui/constants": "^1.0.0", | ||
| "@rosen-ui/types": "^0.4.1", | ||
| "axios": "^1.7.2", | ||
| "bitcoinjs-lib": "^6.1.6" | ||
| }, | ||
| "engines": { | ||
| "node": ">=22.18.0", | ||
| "npm": "11.6.2" | ||
| } | ||
| } |
This file contains hidden or 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,78 @@ | ||
| import { Firo as FiroIcon } from '@rosen-bridge/icons'; | ||
| import { Network, NetworkConfig } from '@rosen-network/base'; | ||
| import { NETWORKS } from '@rosen-ui/constants'; | ||
|
|
||
| import type { generateUnsignedTx } from './generateUnsignedTx'; | ||
| import type { | ||
| generateOpReturnData, | ||
| getAddressBalance, | ||
| submitTransaction, | ||
| } from './utils'; | ||
|
|
||
| type FiroNetworkConfig = NetworkConfig & { | ||
| generateOpReturnData: typeof generateOpReturnData; | ||
| generateUnsignedTx: ReturnType<typeof generateUnsignedTx>; | ||
| getAddressBalance: typeof getAddressBalance; | ||
| submitTransaction: typeof submitTransaction; | ||
| }; | ||
|
|
||
| export class FiroNetwork implements Network { | ||
| public label = NETWORKS.firo.label; | ||
|
|
||
| public lockAddress: string; | ||
|
|
||
| public logo = FiroIcon; | ||
|
|
||
| public name = NETWORKS.firo.key; | ||
|
|
||
| public nextHeightInterval: number; | ||
|
|
||
| constructor(protected config: FiroNetworkConfig) { | ||
| this.nextHeightInterval = config.nextHeightInterval; | ||
| this.lockAddress = config.lockAddress; | ||
| } | ||
|
|
||
| public calculateFee: FiroNetworkConfig['calculateFee'] = (...args) => { | ||
| return this.config.calculateFee(...args); | ||
| }; | ||
|
|
||
| public generateOpReturnData: FiroNetworkConfig['generateOpReturnData'] = ( | ||
| ...args | ||
| ) => { | ||
| return this.config.generateOpReturnData(...args); | ||
| }; | ||
|
|
||
| public generateUnsignedTx: FiroNetworkConfig['generateUnsignedTx'] = ( | ||
| ...args | ||
| ) => { | ||
| return this.config.generateUnsignedTx(...args); | ||
| }; | ||
|
|
||
| public getAddressBalance: FiroNetworkConfig['getAddressBalance'] = ( | ||
| ...args | ||
| ) => { | ||
| return this.config.getAddressBalance(...args); | ||
| }; | ||
|
|
||
| public getMaxTransfer: FiroNetworkConfig['getMaxTransfer'] = (...args) => { | ||
| return this.config.getMaxTransfer(...args); | ||
| }; | ||
|
|
||
| public getMinTransfer: FiroNetworkConfig['getMinTransfer'] = (...args) => { | ||
| return this.config.getMinTransfer(...args); | ||
| }; | ||
|
|
||
| public submitTransaction: FiroNetworkConfig['submitTransaction'] = ( | ||
| ...args | ||
| ) => { | ||
| return this.config.submitTransaction(...args); | ||
| }; | ||
|
|
||
| public toSafeAddress = (address: string): string => { | ||
| return address; | ||
| }; | ||
|
|
||
| public validateAddress = (walletAddress: string): Promise<boolean> => { | ||
| return this.config.validateAddress(this.name, walletAddress); | ||
| }; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| export const CONFIRMATION_TARGET = 10; | ||
| export const FIRO_TX_BASE_SIZE = 10; | ||
| export const FIRO_INPUT_SIZE = 148; | ||
| export const FIRO_OUTPUT_SIZE = 34; | ||
| export const MINIMUM_UTXO_VALUE = 500000; // 0.005 FIRO in sats | ||
| export const FIRO_NETWORK = { | ||
| messagePrefix: '\x18Firo Signed Message:\n', | ||
| bech32: 'firo', | ||
| bip32: { | ||
| public: 0x0488b21e, | ||
| private: 0x0488ade4, | ||
| }, | ||
| pubKeyHash: 0x52, | ||
| scriptHash: 0x07, | ||
| wif: 0xd2, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.