Skip to content

Commit

Permalink
Merge pull request #260 from yours-org/lock-fix
Browse files Browse the repository at this point in the history
Lock fix
  • Loading branch information
danwag06 authored Dec 18, 2024
2 parents 9fd9ce6 + 96b21b5 commit 0d99064
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 27 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"react-router-dom": "^6.16.0",
"react-scripts": "^5.0.1",
"replace-module-webpack-plugin": "^1.0.0",
"spv-store": "^0.1.49",
"spv-store": "^0.1.61",
"stream-browserify": "^3.0.0",
"styled-components": "^6.0.8",
"ts-loader": "^9.5.1",
Expand Down
1 change: 1 addition & 0 deletions src/components/Ordinal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const Ordinal = (props: OrdinalProps) => {
case contentType?.startsWith('image/'):
return <OrdinalWrapper size={size} selected={selected} url={url} theme={theme} onClick={onClick} />;
case contentType?.startsWith('text/'):
case contentType?.startsWith('application/op-ns'):
return (
<TextWrapper size={size} selected={selected} url={url} theme={theme} onClick={onClick}>
<OrdText theme={theme}>{inscription.origin?.data?.insc?.file?.text}</OrdText>
Expand Down
15 changes: 10 additions & 5 deletions src/components/TxHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Theme, WhiteLabelTheme } from '../theme.types';
import { useServiceContext } from '../hooks/useServiceContext';
import { useEffect, useMemo, useState } from 'react';
import { HeaderText, Text } from './Reusable';
import { BSV_DECIMAL_CONVERSION, GENERIC_TOKEN_ICON, URL_WHATSINCHAIN } from '../utils/constants';
import { BSV_DECIMAL_CONVERSION, GENERIC_NFT_ICON, GENERIC_TOKEN_ICON, URL_WHATSINCHAIN } from '../utils/constants';
import { FaTimes, FaChevronDown, FaChevronUp, FaLink, FaTag } from 'react-icons/fa'; // Import FaTag
import { TxLog } from 'spv-store';
import { Button } from './Button';
Expand Down Expand Up @@ -40,10 +40,10 @@ const HistoryRow = styled.div<WhiteLabelTheme>`
}
`;

const Icon = styled.img`
const Icon = styled.img<{ $isNFT?: boolean }>`
width: 2.25rem;
height: 2.25rem;
border-radius: 50%;
border-radius: ${({ $isNFT }) => ($isNFT ? '0.25rem' : '50%')};
`;

const TickerWrapper = styled.div`
Expand Down Expand Up @@ -194,7 +194,10 @@ export const TxHistory = (props: TxHistoryProps) => {
<Icon
src={`${gorillaPoolService.getBaseUrl(chromeStorageService.getNetwork())}/content/${icon}`}
alt="Summary Icon"
$isNFT={tag === 'origin'}
/>
) : tag === ('origin' as Tag) ? (
<Icon src={GENERIC_NFT_ICON} alt="Generic NFT Icon" />
) : (
<Icon src={GENERIC_TOKEN_ICON} alt="Generic Token Icon" />
);
Expand Down Expand Up @@ -254,8 +257,10 @@ export const TxHistory = (props: TxHistoryProps) => {
case 'bsv21':
case 'bsv20':
return amount;
case 'lock':
return amount / BSV_DECIMAL_CONVERSION + ' BSV';
default:
return amount + ' sats';
return amount.toLocaleString() + ' sats';
}
};

Expand Down Expand Up @@ -344,7 +349,7 @@ export const TxHistory = (props: TxHistoryProps) => {
margin: 0,
color: value?.amount
? value.amount > 1
? '#52C41A'
? theme.color.component.primaryButtonLeftGradient
: value.amount < -1
? theme.color.global.contrast
: 'transparent'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/BsvWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export const BsvWallet = (props: BsvWalletProps) => {
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [identityAddress, isSyncing]);
}, [identityAddress, isSyncing, lockData]);

useEffect(() => {
if (isOrdRequest) {
Expand Down
8 changes: 4 additions & 4 deletions src/pages/OrdWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ export const OrdWallet = () => {
<Ordinal
theme={theme}
inscription={ordinal as OrdinalType}
url={`${gorillaPoolService.getBaseUrl(network)}/content/${ordinal.origin?.outpoint}`}
url={`${gorillaPoolService.getBaseUrl(network)}/content/${ordinal.origin?.outpoint}?outpoint=${ordinal?.outpoint}`}
isTransfer
size="3rem"
/>
Expand Down Expand Up @@ -525,7 +525,7 @@ export const OrdWallet = () => {
<Ordinal
theme={theme}
inscription={selectedOrdinals[0] as OrdinalType}
url={`${gorillaPoolService.getBaseUrl(network)}/content/${selectedOrdinals[0]?.origin?.outpoint}`}
url={`${gorillaPoolService.getBaseUrl(network)}/content/${selectedOrdinals[0]?.origin?.outpoint}?outpoint=${selectedOrdinals[0]?.outpoint}`}
selected
isTransfer
/>
Expand Down Expand Up @@ -563,7 +563,7 @@ export const OrdWallet = () => {
theme={theme}
inscription={ord}
key={ord.origin?.outpoint}
url={`${gorillaPoolService.getBaseUrl(network)}/content/${ord.origin?.outpoint}`}
url={`${gorillaPoolService.getBaseUrl(network)}/content/${ord.origin?.outpoint}?outpoint=${ord?.outpoint}`}
selected={selectedOrdinals.some((selected) => selected.outpoint === ord.outpoint)}
onClick={() => toggleOrdinalSelection(ord)}
/>
Expand Down Expand Up @@ -637,7 +637,7 @@ export const OrdWallet = () => {
<Ordinal
theme={theme}
inscription={selectedOrdinals[0] as OrdinalType}
url={`${gorillaPoolService.getBaseUrl(network)}/content/${selectedOrdinals[0]?.origin?.outpoint}`}
url={`${gorillaPoolService.getBaseUrl(network)}/content/${selectedOrdinals[0]?.origin?.outpoint}?outpoint=${selectedOrdinals[0]?.outpoint}`}
selected
isTransfer
/>
Expand Down
33 changes: 22 additions & 11 deletions src/services/Contract.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,28 @@ export class ContractService {
for (const lock of locks) {
const pk = pkMap.get(lock.owner || '');
if (!pk) continue;
const input = fromUtxo(
{
txid: lock.outpoint.txid,
vout: lock.outpoint.vout,
satoshis: Number(lock.satoshis),
script: Utils.toHex([...lock.script]),
},
new LockTemplate().unlock(pk, 'all', false, Number(lock.satoshis), Script.fromBinary(lock.script)),
);
input.sequence = 0;
tx.addInput(input);
// const input = fromUtxo(
// {
// txid: lock.outpoint.txid,
// vout: lock.outpoint.vout,
// satoshis: Number(lock.satoshis),
// script: Utils.toHex([...lock.script]),
// },
// new LockTemplate().unlock(pk, 'all', false, Number(lock.satoshis), Script.fromBinary(lock.script)),
// );
// input.sequence = 0;
tx.addInput({
sourceTransaction: await this.oneSatSPV.getTx(lock.outpoint.txid),
sourceOutputIndex: lock.outpoint.vout,
sequence: 0,
unlockingScriptTemplate: new LockTemplate().unlock(
pk,
'all',
false,
Number(lock.satoshis),
Script.fromBinary(lock.script),
),
});
}

await tx.fee();
Expand Down
1 change: 1 addition & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const PROVIDER_DOCS_URL = 'https://yours-wallet.gitbook.io/provider-api/i
export const ONE_SAT_MARKET_URL = 'https://1sat.market/market';
export const GENERIC_TOKEN_ICON =
'https://static-00.iconduck.com/assets.00/generic-cryptocurrency-icon-2048x2029-vzaeox5w.png';
export const GENERIC_NFT_ICON = 'https://cdn-icons-png.flaticon.com/512/6228/6228867.png';
export const KNOWN_BURN_ADDRESSES = ['1111111111111111111114oLvT2', '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'];

export const DEFAULT_WALLET_PATH = "m/44'/236'/0'/1/0";
Expand Down
3 changes: 2 additions & 1 deletion src/utils/providerHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export function mapOrdinal(t: Txo): Ordinal {
size: Number(t.data.origin.data.insc.file.size),
hash: t.data.origin.data.insc.file.hash,
text:
t.data.origin?.data?.insc?.file?.type.startsWith('text') &&
(t.data.origin?.data?.insc?.file?.type.startsWith('text') ||
t.data.origin?.data?.insc?.file?.type.startsWith('application/op-ns')) &&
t.data.origin.data.insc?.file?.content &&
Utils.toUTF8(t.data.origin.data.insc.file.content),
json:
Expand Down

0 comments on commit 0d99064

Please sign in to comment.