Skip to content

Commit 93d8c28

Browse files
authored
feat: v1 alignment (#525)
1 parent 34ed2e4 commit 93d8c28

31 files changed

+1121
-707
lines changed

packages/site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
]
3030
},
3131
"dependencies": {
32-
"@metamask/keyring-api": "^20.0.0",
32+
"@metamask/keyring-api": "^20.1.1",
3333
"@metamask/providers": "^22.1.0",
3434
"react": "^18.2.0",
3535
"react-dom": "^18.2.0",

packages/site/src/components/Buttons.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ export const SendBitcoinButton = (
123123
return <Button {...props}>Send txn</Button>;
124124
};
125125

126+
export const SignMessageButton = (
127+
props: ComponentPropsWithoutRef<'button'>,
128+
) => {
129+
return <Button {...props}>Sign message</Button>;
130+
};
131+
126132
export const EstimateFeeButton = (
127133
props: ComponentPropsWithoutRef<'button'>,
128134
) => {

packages/site/src/components/EstimateFeeCard.tsx

Lines changed: 0 additions & 57 deletions
This file was deleted.

packages/site/src/components/GetBalancesCard.tsx

Lines changed: 0 additions & 60 deletions
This file was deleted.

packages/site/src/components/GetMaxSpendableBalanceCard.tsx

Lines changed: 0 additions & 40 deletions
This file was deleted.

packages/site/src/components/GetTransactionStatusCard.tsx

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,78 @@
1+
import type { KeyringAccount } from '@metamask/keyring-api';
12
import { BtcMethod } from '@metamask/keyring-api';
3+
import { useState } from 'react';
24
import { v4 as uuidV4 } from 'uuid';
35

46
import { Card, SendBitcoinButton } from '.';
57
import { useInvokeKeyring } from '../hooks';
68

7-
export const SendBitcoinCard = ({
8-
enabled,
9-
fullWidth,
10-
scope,
11-
account,
12-
address,
13-
}: {
14-
enabled: boolean;
15-
fullWidth: boolean;
16-
scope: string;
17-
account: string;
18-
address: string;
19-
}) => {
9+
export const SendBitcoinCard = ({ account }: { account: KeyringAccount }) => {
2010
const invokeKeyring = useInvokeKeyring();
11+
const [address, setAddress] = useState(
12+
'bc1q4degm5k044n9xv3ds7d8l6hfavydte6wn6sesw',
13+
);
14+
const [amount, setAmount] = useState('0.00000500');
2115

2216
const handleClick = async () => {
23-
await invokeKeyring({
17+
const response = (await invokeKeyring({
2418
method: 'keyring_submitRequest',
2519
params: {
26-
account,
20+
account: account.id,
2721
id: uuidV4(),
28-
scope,
22+
scope: account.scopes[0],
23+
origin: 'http://localhost:3000',
2924
request: {
30-
method: `${BtcMethod.SendBitcoin}`,
25+
method: `${BtcMethod.SendTransfer}`,
3126
params: {
32-
recipients: {
33-
[address]: '0.00000500',
34-
},
35-
replaceable: true,
36-
dryrun: true,
27+
recipients: [
28+
{
29+
amount,
30+
address,
31+
},
32+
],
3733
},
3834
},
3935
},
40-
});
36+
})) as { result: { txid: string } };
37+
38+
console.log(response.result.txid);
4139
};
4240

4341
return (
4442
<Card
4543
content={{
46-
title: 'Send Btc',
47-
description: `Send Btc`,
48-
button: <SendBitcoinButton onClick={handleClick} disabled={!enabled} />,
44+
title: 'Send BTC',
45+
description: (
46+
<div>
47+
From: {account.address}
48+
<br />
49+
Scope: {account.scopes[0]}
50+
<br />
51+
<br />
52+
<label>
53+
To:
54+
<input
55+
type="text"
56+
value={address}
57+
onChange={(changeEvent) => setAddress(changeEvent.target.value)}
58+
style={{ marginLeft: '10px', width: '400px' }}
59+
/>
60+
</label>
61+
<br />
62+
<label>
63+
Amount:
64+
<input
65+
type="text"
66+
value={amount}
67+
onChange={(changeEvent) => setAmount(changeEvent.target.value)}
68+
style={{ marginLeft: '10px' }}
69+
/>
70+
</label>
71+
</div>
72+
),
73+
button: <SendBitcoinButton onClick={handleClick} />,
4974
}}
50-
disabled={!enabled}
51-
fullWidth={fullWidth}
75+
fullWidth
5276
/>
5377
);
5478
};

0 commit comments

Comments
 (0)