Skip to content

Commit b04955e

Browse files
committed
Add SIMP definition
1 parent 139a647 commit b04955e

File tree

4 files changed

+47
-14
lines changed

4 files changed

+47
-14
lines changed

src/Data/Transaction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export class TransactionModel extends TransactionNodeModel implements HasKeys {
7979
return {
8080
color: u.getOptions().color,
8181
label: u.getOptions().name,
82+
simp: {},
8283
};
8384
}),
8485
};

src/UX/ContractCreator/SapioPluginPicker/PluginForm.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React from 'react';
2-
import { MuiForm5 as Form } from '@rjsf/material-ui';
32

4-
import { ISubmitEvent } from '@rjsf/core';
3+
import Form, { ISubmitEvent } from '@rjsf/core';
54
import { logo_image, Plugin } from './PluginTile';
65
import { create_contract_of_type, switch_showing } from '../../../AppSlice';
76
import { useDispatch } from 'react-redux';
87
import { show_apis } from '../ContractCreatorSlice';
98
import './PluginForm.css';
9+
import { Button } from '@mui/material';
1010

1111
interface PluginFormProps {
1212
app: Plugin;
@@ -21,12 +21,19 @@ export function PluginForm(props: PluginFormProps) {
2121
);
2222
dispatch(show_apis(false));
2323
};
24+
const [data, set_data] = React.useState({});
25+
const handleClick = async () => {
26+
const s = await navigator.clipboard.readText();
27+
set_data(JSON.parse(s));
28+
};
2429
return (
2530
<div className="PluginForm">
2631
<div></div>
2732
<div>
2833
{logo_image(props.app)}
34+
<Button onClick={handleClick}>Paste</Button>
2935
<Form
36+
formData={data}
3037
schema={props.app.api}
3138
onSubmit={(e: ISubmitEvent<any>) =>
3239
handleSubmit(e, props.app.key)

src/UX/Entity/Detail/UTXODetail.tsx

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ import Hex, { ASM } from './Hex';
4040
import { OutpointDetail } from './OutpointDetail';
4141
import './UTXODetail.css';
4242
import { selectContinuation } from '../../ContractCreator/ContractCreatorSlice';
43-
import { MuiForm5 as Form } from '@rjsf/material-ui';
44-
import { FormValidation, ISubmitEvent } from '@rjsf/core';
43+
import Form, { FormValidation, ISubmitEvent } from '@rjsf/core';
4544
import {
4645
add_effect_to_contract,
4746
recreate_contract,
@@ -200,6 +199,9 @@ function OutputMetadataTable(props: { metadata: UTXOFormatData }) {
200199
return (
201200
<>
202201
<Typography variant="h5">Metadata</Typography>
202+
<SIMPNeg12345
203+
simp_neg_12345={props.metadata.simp[-12345]}
204+
></SIMPNeg12345>
203205
<table>
204206
<thead>
205207
<tr>
@@ -208,22 +210,44 @@ function OutputMetadataTable(props: { metadata: UTXOFormatData }) {
208210
</tr>
209211
</thead>
210212
<tbody>
211-
{Object.entries(props.metadata).map(([k, v]) => (
212-
<tr key={k}>
213-
<td>
214-
<Typography>{k}</Typography>
215-
</td>
216-
<td>
217-
<Typography>{v}</Typography>
218-
</td>
219-
</tr>
220-
))}
213+
{Object.entries(props.metadata)
214+
.filter(([k, _]) => k !== 'simp')
215+
.map(([k, v]) => (
216+
<tr key={k}>
217+
<td>
218+
<Typography>{k}</Typography>
219+
</td>
220+
<td>
221+
<Typography>
222+
{typeof v === 'string'
223+
? v
224+
: JSON.stringify(v)}
225+
</Typography>
226+
</td>
227+
</tr>
228+
))}
221229
</tbody>
222230
</table>
223231
</>
224232
);
225233
}
226234

235+
function SIMPNeg12345(props: { simp_neg_12345?: any }) {
236+
let nft = null;
237+
if (props.simp_neg_12345) {
238+
nft = (
239+
<div>
240+
<img
241+
style={{ maxWidth: '50%' }}
242+
src={`https://${props.simp_neg_12345.cid}.ipfs.nftstorage.link`}
243+
></img>
244+
</div>
245+
);
246+
}
247+
248+
return nft;
249+
}
250+
227251
function ContinuationOption(props: { v: Continuation }) {
228252
const [is_open, setOpen] = React.useState(false);
229253
const name = props.v.path.substr(props.v.path.lastIndexOf('/') + 1);

src/common/preload_interface.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export type TransactionData = {
6161
export type UTXOFormatData = {
6262
color: string;
6363
label: string;
64+
simp: Record<number, any>;
6465
} & Record<string, any>;
6566

6667
export type ContinuationTable = Record<string, Record<APIPath, Continuation>>;

0 commit comments

Comments
 (0)