-
Notifications
You must be signed in to change notification settings - Fork 375
feat: bitcoin #568
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
Merged
Merged
feat: bitcoin #568
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
82db93d
feat: implements bitcoin signet support in example dapp
c5f4506
feat: implements bitcoin signet in example wallet
9e0d289
fix: prettier
d31e96f
fix: adds tiny-secp256k1 to packages
da5794e
chore: cleanup console logs
ganchoradkov d69b6bd
chore: cleanup
ganchoradkov 1a0ce01
chore: rm console log
ganchoradkov 8cde77e
Merge branch 'main' into feat/bitcoin
ganchoradkov 2d52557
chore: dapp rework with btc specs
ganchoradkov cc3de20
chore: parse addreses result
ganchoradkov ded7f4d
chore: sets bifrost wallet link
ganchoradkov 2b6bfec
feat: lists all addresses on getaccountAddresses response
ganchoradkov cc06cff
feat: implements new btc spec
ganchoradkov 692e3aa
feat: adds ordninals address handling
ganchoradkov 3f2ce58
feat: sets addresses in session props
ganchoradkov d793db5
fix: types
ganchoradkov 0803e08
refactor: cleanup
ganchoradkov 9eecbbd
fix: build
ganchoradkov 36205bd
feat: added btc mainnet
ganchoradkov 2a51c5e
Merge branch 'main' into feat/bitcoin
ganchoradkov f7bdf12
fix: explorer mainnet & testnet urls
ganchoradkov 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
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 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,28 @@ | ||
import { NamespaceMetadata, ChainMetadata, ChainsMap } from "../helpers"; | ||
|
||
export const BtcChainData: ChainsMap = { | ||
"000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943": { | ||
id: "bip122:000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943", | ||
name: "BTC Signet", | ||
rpc: ["https://api.devnet.solana.com"], | ||
slip44: 501, | ||
testnet: true, | ||
}, | ||
}; | ||
|
||
export const BtcMetadata: NamespaceMetadata = { | ||
// Solana Devnet | ||
"000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943": { | ||
logo: "/assets/btc-testnet.png", | ||
rgb: "247, 147, 25", | ||
}, | ||
}; | ||
|
||
export function getChainMetadata(chainId: string): ChainMetadata { | ||
const reference = chainId.split(":")[1]; | ||
const metadata = BtcMetadata[reference]; | ||
if (typeof metadata === "undefined") { | ||
throw new Error(`No chain metadata found for chainId: ${chainId}`); | ||
} | ||
return metadata; | ||
} |
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
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,25 @@ | ||
export async function apiGetBip122AccountBalance( | ||
address: string, | ||
chainId: string | ||
) { | ||
const utxo = await apiGetAddressUtxos(address, chainId); | ||
const balanceInSatoshis = getAvailableBalanceFromUtxos(utxo); | ||
const balanceInBtc = balanceInSatoshis * 0.00000001; | ||
|
||
console.log("utxo for address", address, utxo); | ||
console.log("balance", balanceInBtc); | ||
return { balance: balanceInBtc.toString(), symbol: "BTC", name: "BTC" }; | ||
} | ||
|
||
export async function apiGetAddressUtxos(address: string, chainId: string) { | ||
return await ( | ||
await fetch(`https://mempool.space/signet/api/address/${address}/utxo`) | ||
).json(); | ||
} | ||
|
||
export function getAvailableBalanceFromUtxos(utxos: any[]) { | ||
ganchoradkov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!utxos || !utxos.length) { | ||
return 0; | ||
} | ||
return utxos.reduce((acc, { value }) => acc + value, 0); | ||
} |
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
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.