-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/bitcoin-network' into 'dev'
feat(rosen-app): add bitcoin network Closes #252 and #251 See merge request ergo/rosen-bridge/ui!179
- Loading branch information
Showing
20 changed files
with
137 additions
and
24 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@rosen-bridge/icons': minor | ||
--- | ||
|
||
add Bitcoin icon |
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,5 @@ | ||
--- | ||
'@rosen-ui/xdefi-wallet': minor | ||
--- | ||
|
||
export some types from sats-connect |
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,5 @@ | ||
--- | ||
'@rosen-bridge/rosen-app': minor | ||
--- | ||
|
||
add Bitcoin network |
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,10 +1,12 @@ | ||
export const Networks = { | ||
ergo: 'ergo', | ||
cardano: 'cardano', | ||
bitcoin: 'bitcoin', | ||
} as const; | ||
|
||
export const feeConfigTokenId = process.env.NEXT_PUBLIC_FEE_CONFIG_TOKEN_ID!; | ||
|
||
export const CARDANO_BASE_TX_URL = 'https://cardanoscan.io/transaction/'; | ||
export const ERGO_BASE_TX_URL = | ||
'https://explorer.ergoplatform.com/transactions/'; | ||
export const ERGO_EXPLORER_URL = 'https://api.ergoplatform.com/'; |
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,90 @@ | ||
import { BitcoinIcon } from '@rosen-bridge/icons'; | ||
import { RosenChainToken } from '@rosen-bridge/tokens'; | ||
import getXdefiWallet, { | ||
AddressPurpose, | ||
BitcoinNetworkType, | ||
walletInfo as XdefiWalletInfo, | ||
isXdefiAvailable, | ||
} from '@rosen-ui/xdefi-wallet'; | ||
import { validateDecimalPlaces } from '@rosen-ui/utils'; | ||
import { Wallet } from '@rosen-ui/wallet-api'; | ||
|
||
import { compact } from 'lodash-es'; | ||
|
||
import { convertNumberToBigint } from '@/_utils'; | ||
|
||
import { Networks } from '@/_constants'; | ||
|
||
import { Network } from '@/_types/network'; | ||
|
||
/** | ||
* the main object for Bitcoin network | ||
* providing access to network info and wallets and network specific | ||
* functionality | ||
*/ | ||
const BitcoinNetwork: Network<Wallet> = { | ||
name: Networks.bitcoin, | ||
label: 'Bitcoin', | ||
supportedWallets: [XdefiWalletInfo], | ||
availableWallets: compact([ | ||
isXdefiAvailable() && { | ||
...getXdefiWallet(), | ||
getBalance: (token) => | ||
new Promise((resolve, reject) => { | ||
getXdefiWallet().api.getAddress({ | ||
payload: { | ||
message: '', | ||
network: { | ||
type: BitcoinNetworkType.Mainnet, | ||
}, | ||
purposes: [AddressPurpose.Payment], | ||
}, | ||
onFinish: ({ addresses }) => { | ||
/** | ||
* TODO: Complete getBalance | ||
* local:ergo/rosen-bridge/ui#236 | ||
*/ | ||
throw new Error('Not implemented'); | ||
}, | ||
onCancel: () => { | ||
reject(); | ||
}, | ||
}); | ||
}), | ||
transfer: async ( | ||
token: RosenChainToken, | ||
decimalAmount: number, | ||
toChain: string, | ||
toAddress: string, | ||
decimalBridgeFee: number, | ||
decimalNetworkFee: number, | ||
lockAddress: string, | ||
) => { | ||
validateDecimalPlaces(decimalAmount, token.decimals); | ||
validateDecimalPlaces(decimalBridgeFee, token.decimals); | ||
validateDecimalPlaces(decimalNetworkFee, token.decimals); | ||
|
||
const amount = convertNumberToBigint( | ||
decimalAmount * 10 ** token.decimals, | ||
); | ||
const bridgeFee = convertNumberToBigint( | ||
decimalBridgeFee * 10 ** token.decimals, | ||
); | ||
const networkFee = convertNumberToBigint( | ||
decimalNetworkFee * 10 ** token.decimals, | ||
); | ||
|
||
/** | ||
* TODO: Complete transfer | ||
* local:ergo/rosen-bridge/ui#236 | ||
*/ | ||
throw new Error('Not implemented'); | ||
}, | ||
}, | ||
]), | ||
logo: BitcoinIcon, | ||
nextHeightInterval: 1, | ||
lockAddress: process.env.NEXT_PUBLIC_BITCOIN_LOCK_ADDRESS!, | ||
}; | ||
|
||
export default BitcoinNetwork; |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,2 +1,3 @@ | ||
export { ReactComponent as BitcoinIcon } from './bitcoin.svg'; | ||
export { ReactComponent as CardanoIcon } from './cardano.svg'; | ||
export { ReactComponent as ErgoIcon } from './ergo.svg'; |
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