-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4106 from hirosystems/release/broadcast-psbts
Release/broadcast psbts
- Loading branch information
Showing
58 changed files
with
806 additions
and
255 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
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
28 changes: 3 additions & 25 deletions
28
src/app/components/bitcoin-transaction-item/bitcoin-transaction-icon.tsx
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
68 changes: 68 additions & 0 deletions
68
src/app/components/bitcoin-transaction-item/bitcoin-transaction-inscription-icon.tsx
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,68 @@ | ||
import { Box, Circle, Flex, color } from '@stacks/ui'; | ||
|
||
import { SupportedInscription } from '@shared/models/inscription.model'; | ||
import { BitcoinTx } from '@shared/models/transactions/bitcoin-transaction.model'; | ||
|
||
import { OrdinalIcon } from '../icons/ordinal-icon'; | ||
import { IconForTx, colorFromTx } from './utils'; | ||
|
||
interface BitcoinTransactionInscriptionIconProps { | ||
inscription: SupportedInscription; | ||
transaction: BitcoinTx; | ||
btcAddress: string; | ||
} | ||
|
||
function InscriptionIcon({ inscription, ...rest }: { inscription: SupportedInscription }) { | ||
switch (inscription.type) { | ||
case 'image': | ||
return ( | ||
<Circle | ||
bg={color('accent')} | ||
color={color('bg')} | ||
flexShrink={0} | ||
position="relative" | ||
size="36px" | ||
{...rest} | ||
> | ||
<img | ||
src={inscription.src} | ||
style={{ | ||
width: '100%', | ||
height: '100%', | ||
aspectRatio: '1 / 1', | ||
objectFit: 'cover', | ||
borderRadius: '6px', | ||
}} | ||
/> | ||
</Circle> | ||
); | ||
default: | ||
return <OrdinalIcon />; | ||
} | ||
} | ||
|
||
export function BitcoinTransactionInscriptionIcon({ | ||
inscription, | ||
transaction, | ||
btcAddress, | ||
...rest | ||
}: BitcoinTransactionInscriptionIconProps) { | ||
return ( | ||
<Flex position="relative"> | ||
<InscriptionIcon inscription={inscription} /> | ||
<Circle | ||
bottom="-2px" | ||
right="-9px" | ||
position="absolute" | ||
size="21px" | ||
bg={color(colorFromTx(transaction))} | ||
color={color('bg')} | ||
border="2px solid" | ||
borderColor={color('bg')} | ||
{...rest} | ||
> | ||
<Box size="13px" as={IconForTx(btcAddress, transaction)} /> | ||
</Circle> | ||
</Flex> | ||
); | ||
} |
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,33 @@ | ||
import { FiArrowDown as IconArrowDown, FiArrowUp as IconArrowUp } from 'react-icons/fi'; | ||
|
||
import { ColorsStringLiteral } from '@stacks/ui-theme'; | ||
|
||
import { BitcoinTx } from '@shared/models/transactions/bitcoin-transaction.model'; | ||
|
||
import { isBitcoinTxInbound } from '@app/common/transactions/bitcoin/utils'; | ||
|
||
type BtcTxStatus = 'pending' | 'success'; | ||
type BtcStatusColorMap = Record<BtcTxStatus, ColorsStringLiteral>; | ||
|
||
const statusFromTx = (tx: BitcoinTx): BtcTxStatus => { | ||
if (tx.status.confirmed) return 'success'; | ||
return 'pending'; | ||
}; | ||
|
||
export const colorFromTx = (tx: BitcoinTx): ColorsStringLiteral => { | ||
const colorMap: BtcStatusColorMap = { | ||
pending: 'feedback-alert', | ||
success: 'brand', | ||
}; | ||
|
||
return colorMap[statusFromTx(tx)] ?? 'feedback-error'; | ||
}; | ||
|
||
export function IconForTx(address: string, tx: BitcoinTx) { | ||
if (isBitcoinTxInbound(address, tx)) return IconArrowDown; | ||
return IconArrowUp; | ||
} | ||
|
||
export function containsTaprootInput(tx: BitcoinTx) { | ||
return tx.vin.some(input => input.prevout.scriptpubkey_type === 'v1_p2tr'); | ||
} |
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,19 +1,29 @@ | ||
export function OrdinalIcon() { | ||
return ( | ||
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<circle cx="18" cy="18" r="18" fill="#0C0C0D" /> | ||
<circle cx="18" cy="18" r="12.375" fill="white" /> | ||
<rect x="7.32143" y="7.32143" width="21.3571" height="21.3571" rx="10.6786" fill="white" /> | ||
<circle cx="18.0001" cy="18" r="4.57143" fill="#0C0C0D" /> | ||
<rect | ||
x="7.32143" | ||
y="7.32143" | ||
width="21.3571" | ||
height="21.3571" | ||
rx="10.6786" | ||
stroke="#0C0C0D" | ||
strokeWidth="1.14286" | ||
/> | ||
<g clipPath="url(#clip0_1_5)"> | ||
<path | ||
d="M18 36C27.9411 36 36 27.9411 36 18C36 8.05888 27.9411 0 18 0C8.05888 0 0 8.05888 0 18C0 27.9411 8.05888 36 18 36Z" | ||
fill="#0C0C0D" | ||
/> | ||
<path | ||
d="M18 31.5C25.4558 31.5 31.5 25.4558 31.5 18C31.5 10.5442 25.4558 4.5 18 4.5C10.5442 4.5 4.5 10.5442 4.5 18C4.5 25.4558 10.5442 31.5 18 31.5Z" | ||
fill="white" | ||
/> | ||
<path | ||
d="M18 24.75C21.7279 24.75 24.75 21.7279 24.75 18C24.75 14.2721 21.7279 11.25 18 11.25C14.2721 11.25 11.25 14.2721 11.25 18C11.25 21.7279 14.2721 24.75 18 24.75Z" | ||
fill="#0C0C0D" | ||
/> | ||
<path | ||
d="M36 18C36 8.05888 27.9411 0 18 0C8.05888 0 0 8.05888 0 18C0 27.9411 8.05888 36 18 36C27.9411 36 36 27.9411 36 18Z" | ||
stroke="white" | ||
/> | ||
</g> | ||
<defs> | ||
<clipPath id="clip0_1_5"> | ||
<rect width="36" height="36" fill="white" /> | ||
</clipPath> | ||
</defs> | ||
</svg> | ||
); | ||
} |
Oops, something went wrong.