-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path.sensory
53 lines (53 loc) · 1.82 KB
/
.sensory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
"bmapjs-transaction": {
"prefix": ["bmap-tx", "bmaptx"],
"description": "Create a BMAP transaction from a raw transaction hex string",
"body": [
"try {",
" // First validate it's a valid transaction",
" const tx = Transaction.fromHex(${1:rawTx});",
" if (!tx) {",
" throw new Error('Invalid transaction format');",
" }",
"",
" // Parse the transaction using BOB format",
" const bob = await parse({",
" tx: { r: ${1:rawTx} },",
" split: [{ token: { op: 106 }, include: 'l' }, { token: { s: '|' } }],",
" });",
"",
" if (!bob || !bob.out || !Array.isArray(bob.out)) {",
" return {",
" data: JSON.stringify({ tx: { h: tx.hash().toString() } }, null, 2),",
" type: 'transactions',",
" name: \\`bob_\\${new Date().toISOString().replace(/[:.]/g, '-')}\\`",
" };",
" }",
"",
" // Transform BOB format to BMAP",
" const bmapTx = await TransformTx(bob as BobTx);",
" console.log({ bmapTx });",
"",
" return {",
" data: JSON.stringify(bmapTx, null, 2),",
" type: 'transactions',",
" name: \\`\\${txid}_bmap_\\${new Date().toISOString().replace(/[:.]/g, '-')}\\`",
" };",
"} catch (error) {",
" console.error('BOB parsing error:', error);",
" throw new Error(",
" \\`Failed to parse transaction: \\${",
" error instanceof Error ? error.message : String(error)",
" }. Please ensure the transaction hex is valid.\\`",
" );",
"}"
],
"scope": "typescript,javascript",
"metadata": {
"tags": ["bitcoin", "bmap", "transaction", "parsing"],
"requires": ["bmapjs", "bsv"],
"author": "Sensory Snippets",
"version": "1.0.0"
}
}
}