@dignetwork/chia-block-listener 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/CI.yml +36 -6
- package/README.md +23 -25
- package/index.d.ts +0 -16
- package/npm/darwin-arm64/package.json +1 -1
- package/npm/darwin-x64/package.json +1 -1
- package/npm/linux-arm64-gnu/package.json +1 -1
- package/npm/linux-x64-gnu/package.json +1 -1
- package/npm/win32-x64-msvc/package.json +1 -1
- package/package.json +6 -6
- package/scripts/post-build.js +15 -1
- package/src/event_emitter.rs +31 -29
package/.github/workflows/CI.yml
CHANGED
|
@@ -193,7 +193,7 @@ jobs:
|
|
|
193
193
|
node:
|
|
194
194
|
- '20'
|
|
195
195
|
- '22'
|
|
196
|
-
runs-on: ubuntu-
|
|
196
|
+
runs-on: ubuntu-24.04
|
|
197
197
|
steps:
|
|
198
198
|
- uses: actions/checkout@v4
|
|
199
199
|
- name: Setup node
|
|
@@ -252,18 +252,48 @@ jobs:
|
|
|
252
252
|
uses: addnab/docker-run-action@v3
|
|
253
253
|
with:
|
|
254
254
|
image: ubuntu:24.04
|
|
255
|
-
options: '--platform linux/arm64 -v ${{ github.workspace }}:/
|
|
255
|
+
options: '--platform linux/arm64 -v ${{ github.workspace }}:/workspace -w /workspace'
|
|
256
256
|
run: |
|
|
257
257
|
set -e
|
|
258
|
+
export DEBIAN_FRONTEND=noninteractive
|
|
258
259
|
apt-get update
|
|
259
|
-
apt-get install -y curl
|
|
260
|
-
|
|
261
|
-
|
|
260
|
+
apt-get install -y curl ca-certificates xz-utils
|
|
261
|
+
|
|
262
|
+
# Install Node.js using a different approach - download pre-built binary directly
|
|
263
|
+
NODE_VERSION="${{ matrix.node }}"
|
|
264
|
+
case "$NODE_VERSION" in
|
|
265
|
+
"20")
|
|
266
|
+
FULL_VERSION="20.18.0"
|
|
267
|
+
;;
|
|
268
|
+
"22")
|
|
269
|
+
FULL_VERSION="22.11.0" # Use slightly older version of 22 for stability
|
|
270
|
+
;;
|
|
271
|
+
*)
|
|
272
|
+
echo "Unsupported Node version: $NODE_VERSION"
|
|
273
|
+
exit 1
|
|
274
|
+
;;
|
|
275
|
+
esac
|
|
276
|
+
|
|
277
|
+
# Download and install Node.js binary
|
|
278
|
+
cd /tmp
|
|
279
|
+
curl -fsSL "https://nodejs.org/dist/v${FULL_VERSION}/node-v${FULL_VERSION}-linux-arm64.tar.xz" -o node.tar.xz
|
|
280
|
+
tar -xf node.tar.xz
|
|
281
|
+
cp -r "node-v${FULL_VERSION}-linux-arm64"/* /usr/local/
|
|
282
|
+
rm -rf node.tar.xz "node-v${FULL_VERSION}-linux-arm64"
|
|
283
|
+
|
|
284
|
+
# Return to workspace
|
|
285
|
+
cd /workspace
|
|
286
|
+
|
|
287
|
+
# Verify we're in the right directory and have the required files
|
|
288
|
+
pwd
|
|
289
|
+
ls -la
|
|
290
|
+
echo "Looking for package-lock.json:"
|
|
291
|
+
ls -la package-lock.json || echo "package-lock.json not found"
|
|
292
|
+
|
|
262
293
|
node --version
|
|
263
294
|
npm --version
|
|
264
295
|
npm ci
|
|
265
296
|
npm test
|
|
266
|
-
ls -la
|
|
267
297
|
|
|
268
298
|
publish:
|
|
269
299
|
name: Publish
|
package/README.md
CHANGED
|
@@ -33,11 +33,11 @@ const listener = new ChiaBlockListener()
|
|
|
33
33
|
// Listen for block events
|
|
34
34
|
listener.on('blockReceived', (block) => {
|
|
35
35
|
console.log(`New block received: ${block.height}`)
|
|
36
|
-
console.log(`Header hash: ${block.
|
|
36
|
+
console.log(`Header hash: ${block.header_hash}`)
|
|
37
37
|
console.log(`Timestamp: ${new Date(block.timestamp * 1000)}`)
|
|
38
|
-
console.log(`Coin additions: ${block.
|
|
39
|
-
console.log(`Coin removals: ${block.
|
|
40
|
-
console.log(`Coin spends: ${block.
|
|
38
|
+
console.log(`Coin additions: ${block.coin_additions.length}`)
|
|
39
|
+
console.log(`Coin removals: ${block.coin_removals.length}`)
|
|
40
|
+
console.log(`Coin spends: ${block.coin_spends.length}`)
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
// Listen for peer connection events
|
|
@@ -155,11 +155,11 @@ Fired when a peer connection is lost.
|
|
|
155
155
|
|
|
156
156
|
```typescript
|
|
157
157
|
interface BlockReceivedEvent {
|
|
158
|
-
peerId: string //
|
|
159
|
-
height: number
|
|
160
|
-
weight: string
|
|
158
|
+
peerId: string // IP address of the peer that sent this block
|
|
159
|
+
height: number // Block height
|
|
160
|
+
weight: string // Block weight as string
|
|
161
161
|
headerHash: string // Block header hash (hex)
|
|
162
|
-
timestamp: number
|
|
162
|
+
timestamp: number // Block timestamp (Unix time)
|
|
163
163
|
coinAdditions: CoinRecord[] // New coins created in this block
|
|
164
164
|
coinRemovals: CoinRecord[] // Coins spent in this block
|
|
165
165
|
coinSpends: CoinSpend[] // Detailed spend information
|
|
@@ -173,9 +173,9 @@ interface BlockReceivedEvent {
|
|
|
173
173
|
|
|
174
174
|
```typescript
|
|
175
175
|
interface PeerConnectedEvent {
|
|
176
|
-
peerId: string //
|
|
177
|
-
host: string
|
|
178
|
-
port: number
|
|
176
|
+
peerId: string // Peer IP address
|
|
177
|
+
host: string // Peer hostname/IP
|
|
178
|
+
port: number // Peer port number
|
|
179
179
|
}
|
|
180
180
|
```
|
|
181
181
|
|
|
@@ -183,7 +183,7 @@ interface PeerConnectedEvent {
|
|
|
183
183
|
|
|
184
184
|
```typescript
|
|
185
185
|
interface PeerDisconnectedEvent {
|
|
186
|
-
peerId: string
|
|
186
|
+
peerId: string // Peer IP address
|
|
187
187
|
host: string // Peer hostname/IP
|
|
188
188
|
port: number // Peer port number
|
|
189
189
|
message?: string // Optional disconnection reason
|
|
@@ -195,8 +195,8 @@ interface PeerDisconnectedEvent {
|
|
|
195
195
|
```typescript
|
|
196
196
|
interface CoinRecord {
|
|
197
197
|
parentCoinInfo: string // Parent coin ID (hex)
|
|
198
|
-
puzzleHash: string
|
|
199
|
-
amount: string
|
|
198
|
+
puzzleHash: string // Puzzle hash (hex)
|
|
199
|
+
amount: string // Coin amount as string
|
|
200
200
|
}
|
|
201
201
|
```
|
|
202
202
|
|
|
@@ -204,12 +204,10 @@ interface CoinRecord {
|
|
|
204
204
|
|
|
205
205
|
```typescript
|
|
206
206
|
interface CoinSpend {
|
|
207
|
-
coin: CoinRecord
|
|
207
|
+
coin: CoinRecord // The coin being spent
|
|
208
208
|
puzzleReveal: string // CLVM puzzle bytecode (hex)
|
|
209
|
-
solution: string
|
|
210
|
-
|
|
211
|
-
parsingMethod: string // Method used to parse the spend
|
|
212
|
-
offset: number // Offset in the generator bytecode
|
|
209
|
+
solution: string // CLVM solution bytecode (hex)
|
|
210
|
+
offset: number // Offset in the generator bytecode
|
|
213
211
|
}
|
|
214
212
|
```
|
|
215
213
|
|
|
@@ -238,14 +236,14 @@ listener.on('blockReceived', (block: BlockReceivedEvent) => {
|
|
|
238
236
|
console.log(`Block ${block.height} from peer ${block.peerId}`)
|
|
239
237
|
|
|
240
238
|
// Process coin additions
|
|
241
|
-
block.
|
|
239
|
+
block.coin_additions.forEach((coin: CoinRecord) => {
|
|
242
240
|
console.log(`New coin: ${coin.amount} mojos`)
|
|
243
241
|
})
|
|
244
242
|
|
|
245
243
|
// Process coin spends
|
|
246
|
-
block.
|
|
244
|
+
block.coin_spends.forEach((spend: CoinSpend) => {
|
|
247
245
|
console.log(`Spend: ${spend.coin.amount} mojos`)
|
|
248
|
-
console.log(`Puzzle: ${spend.
|
|
246
|
+
console.log(`Puzzle: ${spend.puzzle_reveal}`)
|
|
249
247
|
console.log(`Solution: ${spend.solution}`)
|
|
250
248
|
})
|
|
251
249
|
})
|
|
@@ -269,7 +267,7 @@ const testnetPeer = listener.addPeer('testnet-node.chia.net', 58444, 'testnet')
|
|
|
269
267
|
async function getHistoricalBlocks() {
|
|
270
268
|
try {
|
|
271
269
|
const block = listener.getBlockByHeight(mainnetPeer, 1000000)
|
|
272
|
-
console.log(`Block 1000000 hash: ${block.
|
|
270
|
+
console.log(`Block 1000000 hash: ${block.header_hash}`)
|
|
273
271
|
|
|
274
272
|
const blocks = listener.getBlocksRange(mainnetPeer, 1000000, 1000010)
|
|
275
273
|
console.log(`Retrieved ${blocks.length} blocks`)
|
|
@@ -292,8 +290,8 @@ console.log('Available events:', eventTypes)
|
|
|
292
290
|
listener.on('blockReceived', (block) => {
|
|
293
291
|
const targetPuzzleHash = '0x1234...' // Your puzzle hash
|
|
294
292
|
|
|
295
|
-
block.
|
|
296
|
-
if (spend.coin.
|
|
293
|
+
block.coin_spends.forEach((spend) => {
|
|
294
|
+
if (spend.coin.puzzle_hash === targetPuzzleHash) {
|
|
297
295
|
console.log('Found spend for our puzzle!')
|
|
298
296
|
console.log('Amount:', spend.coin.amount)
|
|
299
297
|
console.log('Solution:', spend.solution)
|
package/index.d.ts
CHANGED
|
@@ -42,8 +42,6 @@ export interface CoinSpend {
|
|
|
42
42
|
coin: CoinRecord
|
|
43
43
|
puzzleReveal: string
|
|
44
44
|
solution: string
|
|
45
|
-
realData: boolean
|
|
46
|
-
parsingMethod: string
|
|
47
45
|
offset: number
|
|
48
46
|
}
|
|
49
47
|
export declare function initTracing(): void
|
|
@@ -53,21 +51,7 @@ export declare class ChiaBlockListener {
|
|
|
53
51
|
disconnectPeer(peerId: string): boolean
|
|
54
52
|
disconnectAllPeers(): void
|
|
55
53
|
getConnectedPeers(): Array<string>
|
|
56
|
-
// Typed event method overloads
|
|
57
|
-
|
|
58
|
-
on(event: 'blockReceived', callback: (event: BlockReceivedEvent) => void): void
|
|
59
|
-
|
|
60
|
-
on(event: 'peerConnected', callback: (event: PeerConnectedEvent) => void): void
|
|
61
|
-
|
|
62
|
-
on(event: 'peerDisconnected', callback: (event: PeerDisconnectedEvent) => void): void
|
|
63
|
-
|
|
64
54
|
on(event: string, callback: (...args: any[]) => any): void
|
|
65
|
-
off(event: 'blockReceived', callback: (event: BlockReceivedEvent) => void): void
|
|
66
|
-
|
|
67
|
-
off(event: 'peerConnected', callback: (event: PeerConnectedEvent) => void): void
|
|
68
|
-
|
|
69
|
-
off(event: 'peerDisconnected', callback: (event: PeerDisconnectedEvent) => void): void
|
|
70
|
-
|
|
71
55
|
off(event: string, callback: (...args: any[]) => any): void
|
|
72
56
|
getBlockByHeight(peerId: string, height: number): BlockReceivedEvent
|
|
73
57
|
getBlocksRange(peerId: string, startHeight: number, endHeight: number): Array<BlockReceivedEvent>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dignetwork/chia-block-listener",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
},
|
|
59
59
|
"packageManager": "yarn@1.22.22",
|
|
60
60
|
"optionalDependencies": {
|
|
61
|
-
"@dignetwork/chia-block-listener-win32-x64-msvc": "0.1.
|
|
62
|
-
"@dignetwork/chia-block-listener-darwin-x64": "0.1.
|
|
63
|
-
"@dignetwork/chia-block-listener-linux-x64-gnu": "0.1.
|
|
64
|
-
"@dignetwork/chia-block-listener-darwin-arm64": "0.1.
|
|
65
|
-
"@dignetwork/chia-block-listener-linux-arm64-gnu": "0.1.
|
|
61
|
+
"@dignetwork/chia-block-listener-win32-x64-msvc": "0.1.8",
|
|
62
|
+
"@dignetwork/chia-block-listener-darwin-x64": "0.1.8",
|
|
63
|
+
"@dignetwork/chia-block-listener-linux-x64-gnu": "0.1.8",
|
|
64
|
+
"@dignetwork/chia-block-listener-darwin-arm64": "0.1.8",
|
|
65
|
+
"@dignetwork/chia-block-listener-linux-arm64-gnu": "0.1.8"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/scripts/post-build.js
CHANGED
|
@@ -3,11 +3,25 @@ const path = require('path');
|
|
|
3
3
|
|
|
4
4
|
const indexDtsPath = path.join(__dirname, '..', 'index.d.ts');
|
|
5
5
|
|
|
6
|
-
function
|
|
6
|
+
function fixFieldNames() {
|
|
7
7
|
try {
|
|
8
8
|
// Read the auto-generated index.d.ts file
|
|
9
9
|
let content = fs.readFileSync(indexDtsPath, 'utf8');
|
|
10
10
|
|
|
11
|
+
console.log('✅ Field names should now be camelCase from NAPI js_name attributes');
|
|
12
|
+
return content;
|
|
13
|
+
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error('❌ Error fixing field names:', error.message);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function addTypedOverloads() {
|
|
21
|
+
try {
|
|
22
|
+
// Read the auto-generated index.d.ts file (or use fixed content from field name correction)
|
|
23
|
+
let content = fixFieldNames();
|
|
24
|
+
|
|
11
25
|
// Check if typed overloads are already present (avoid duplicates)
|
|
12
26
|
if (content.includes('Typed event method overloads')) {
|
|
13
27
|
console.log('✅ Typed event method overloads already present in index.d.ts');
|
package/src/event_emitter.rs
CHANGED
|
@@ -83,6 +83,7 @@ enum PeerEventType {
|
|
|
83
83
|
#[napi(object)]
|
|
84
84
|
#[derive(Clone)]
|
|
85
85
|
pub struct PeerConnectedEvent {
|
|
86
|
+
#[napi(js_name = "peerId")]
|
|
86
87
|
pub peer_id: String,
|
|
87
88
|
pub host: String,
|
|
88
89
|
pub port: u32,
|
|
@@ -92,6 +93,7 @@ pub struct PeerConnectedEvent {
|
|
|
92
93
|
#[napi(object)]
|
|
93
94
|
#[derive(Clone)]
|
|
94
95
|
pub struct PeerDisconnectedEvent {
|
|
96
|
+
#[napi(js_name = "peerId")]
|
|
95
97
|
pub peer_id: String,
|
|
96
98
|
pub host: String,
|
|
97
99
|
pub port: u32,
|
|
@@ -102,23 +104,33 @@ pub struct PeerDisconnectedEvent {
|
|
|
102
104
|
#[napi(object)]
|
|
103
105
|
#[derive(Clone)]
|
|
104
106
|
pub struct BlockReceivedEvent {
|
|
107
|
+
#[napi(js_name = "peerId")]
|
|
105
108
|
pub peer_id: String,
|
|
106
109
|
pub height: u32,
|
|
107
110
|
pub weight: String,
|
|
111
|
+
#[napi(js_name = "headerHash")]
|
|
108
112
|
pub header_hash: String,
|
|
109
113
|
pub timestamp: u32,
|
|
114
|
+
#[napi(js_name = "coinAdditions")]
|
|
110
115
|
pub coin_additions: Vec<CoinRecord>,
|
|
116
|
+
#[napi(js_name = "coinRemovals")]
|
|
111
117
|
pub coin_removals: Vec<CoinRecord>,
|
|
118
|
+
#[napi(js_name = "coinSpends")]
|
|
112
119
|
pub coin_spends: Vec<CoinSpend>,
|
|
120
|
+
#[napi(js_name = "coinCreations")]
|
|
113
121
|
pub coin_creations: Vec<CoinRecord>,
|
|
122
|
+
#[napi(js_name = "hasTransactionsGenerator")]
|
|
114
123
|
pub has_transactions_generator: bool,
|
|
124
|
+
#[napi(js_name = "generatorSize")]
|
|
115
125
|
pub generator_size: u32,
|
|
116
126
|
}
|
|
117
127
|
|
|
118
128
|
#[napi(object)]
|
|
119
129
|
#[derive(Clone)]
|
|
120
130
|
pub struct CoinRecord {
|
|
131
|
+
#[napi(js_name = "parentCoinInfo")]
|
|
121
132
|
pub parent_coin_info: String,
|
|
133
|
+
#[napi(js_name = "puzzleHash")]
|
|
122
134
|
pub puzzle_hash: String,
|
|
123
135
|
pub amount: String,
|
|
124
136
|
}
|
|
@@ -127,10 +139,9 @@ pub struct CoinRecord {
|
|
|
127
139
|
#[derive(Clone)]
|
|
128
140
|
pub struct CoinSpend {
|
|
129
141
|
pub coin: CoinRecord,
|
|
142
|
+
#[napi(js_name = "puzzleReveal")]
|
|
130
143
|
pub puzzle_reveal: String,
|
|
131
144
|
pub solution: String,
|
|
132
|
-
pub real_data: bool,
|
|
133
|
-
pub parsing_method: String,
|
|
134
145
|
pub offset: u32,
|
|
135
146
|
}
|
|
136
147
|
|
|
@@ -241,7 +252,7 @@ impl ChiaBlockListener {
|
|
|
241
252
|
|
|
242
253
|
let peer_id = rt.block_on(async {
|
|
243
254
|
let mut guard = inner.write().await;
|
|
244
|
-
let peer_id =
|
|
255
|
+
let peer_id = host.clone();
|
|
245
256
|
|
|
246
257
|
guard.peers.insert(
|
|
247
258
|
peer_id.clone(),
|
|
@@ -331,7 +342,7 @@ impl ChiaBlockListener {
|
|
|
331
342
|
obj.set_named_property("height", ctx.env.create_uint32(event.height)?)?;
|
|
332
343
|
obj.set_named_property("weight", ctx.env.create_string(&event.weight)?)?;
|
|
333
344
|
obj.set_named_property(
|
|
334
|
-
"
|
|
345
|
+
"headerHash",
|
|
335
346
|
ctx.env.create_string(&event.header_hash)?,
|
|
336
347
|
)?;
|
|
337
348
|
obj.set_named_property("timestamp", ctx.env.create_uint32(event.timestamp)?)?;
|
|
@@ -343,11 +354,11 @@ impl ChiaBlockListener {
|
|
|
343
354
|
for (i, coin) in event.coin_additions.iter().enumerate() {
|
|
344
355
|
let mut coin_obj = ctx.env.create_object()?;
|
|
345
356
|
coin_obj.set_named_property(
|
|
346
|
-
"
|
|
357
|
+
"parentCoinInfo",
|
|
347
358
|
ctx.env.create_string(&coin.parent_coin_info)?,
|
|
348
359
|
)?;
|
|
349
360
|
coin_obj.set_named_property(
|
|
350
|
-
"
|
|
361
|
+
"puzzleHash",
|
|
351
362
|
ctx.env.create_string(&coin.puzzle_hash)?,
|
|
352
363
|
)?;
|
|
353
364
|
coin_obj.set_named_property(
|
|
@@ -356,7 +367,7 @@ impl ChiaBlockListener {
|
|
|
356
367
|
)?;
|
|
357
368
|
additions_array.set_element(i as u32, coin_obj)?;
|
|
358
369
|
}
|
|
359
|
-
obj.set_named_property("
|
|
370
|
+
obj.set_named_property("coinAdditions", additions_array)?;
|
|
360
371
|
|
|
361
372
|
// Coin removals array
|
|
362
373
|
let mut removals_array = ctx
|
|
@@ -365,11 +376,11 @@ impl ChiaBlockListener {
|
|
|
365
376
|
for (i, coin) in event.coin_removals.iter().enumerate() {
|
|
366
377
|
let mut coin_obj = ctx.env.create_object()?;
|
|
367
378
|
coin_obj.set_named_property(
|
|
368
|
-
"
|
|
379
|
+
"parentCoinInfo",
|
|
369
380
|
ctx.env.create_string(&coin.parent_coin_info)?,
|
|
370
381
|
)?;
|
|
371
382
|
coin_obj.set_named_property(
|
|
372
|
-
"
|
|
383
|
+
"puzzleHash",
|
|
373
384
|
ctx.env.create_string(&coin.puzzle_hash)?,
|
|
374
385
|
)?;
|
|
375
386
|
coin_obj.set_named_property(
|
|
@@ -378,7 +389,7 @@ impl ChiaBlockListener {
|
|
|
378
389
|
)?;
|
|
379
390
|
removals_array.set_element(i as u32, coin_obj)?;
|
|
380
391
|
}
|
|
381
|
-
obj.set_named_property("
|
|
392
|
+
obj.set_named_property("coinRemovals", removals_array)?;
|
|
382
393
|
|
|
383
394
|
// Coin spends array
|
|
384
395
|
let mut spends_array =
|
|
@@ -389,11 +400,11 @@ impl ChiaBlockListener {
|
|
|
389
400
|
// Create coin object
|
|
390
401
|
let mut coin_obj = ctx.env.create_object()?;
|
|
391
402
|
coin_obj.set_named_property(
|
|
392
|
-
"
|
|
403
|
+
"parentCoinInfo",
|
|
393
404
|
ctx.env.create_string(&spend.coin.parent_coin_info)?,
|
|
394
405
|
)?;
|
|
395
406
|
coin_obj.set_named_property(
|
|
396
|
-
"
|
|
407
|
+
"puzzleHash",
|
|
397
408
|
ctx.env.create_string(&spend.coin.puzzle_hash)?,
|
|
398
409
|
)?;
|
|
399
410
|
coin_obj.set_named_property(
|
|
@@ -403,27 +414,20 @@ impl ChiaBlockListener {
|
|
|
403
414
|
spend_obj.set_named_property("coin", coin_obj)?;
|
|
404
415
|
|
|
405
416
|
spend_obj.set_named_property(
|
|
406
|
-
"
|
|
417
|
+
"puzzleReveal",
|
|
407
418
|
ctx.env.create_string(&spend.puzzle_reveal)?,
|
|
408
419
|
)?;
|
|
409
420
|
spend_obj.set_named_property(
|
|
410
421
|
"solution",
|
|
411
422
|
ctx.env.create_string(&spend.solution)?,
|
|
412
423
|
)?;
|
|
413
|
-
|
|
414
|
-
"real_data",
|
|
415
|
-
ctx.env.get_boolean(spend.real_data)?,
|
|
416
|
-
)?;
|
|
417
|
-
spend_obj.set_named_property(
|
|
418
|
-
"parsing_method",
|
|
419
|
-
ctx.env.create_string(&spend.parsing_method)?,
|
|
420
|
-
)?;
|
|
424
|
+
|
|
421
425
|
spend_obj
|
|
422
426
|
.set_named_property("offset", ctx.env.create_uint32(spend.offset)?)?;
|
|
423
427
|
|
|
424
428
|
spends_array.set_element(i as u32, spend_obj)?;
|
|
425
429
|
}
|
|
426
|
-
obj.set_named_property("
|
|
430
|
+
obj.set_named_property("coinSpends", spends_array)?;
|
|
427
431
|
|
|
428
432
|
// Coin creations array
|
|
429
433
|
let mut creations_array = ctx
|
|
@@ -432,25 +436,25 @@ impl ChiaBlockListener {
|
|
|
432
436
|
for (i, coin) in event.coin_creations.iter().enumerate() {
|
|
433
437
|
let mut coin_obj = ctx.env.create_object()?;
|
|
434
438
|
coin_obj.set_named_property(
|
|
435
|
-
"
|
|
439
|
+
"parentCoinInfo",
|
|
436
440
|
ctx.env.create_string(&coin.parent_coin_info)?,
|
|
437
441
|
)?;
|
|
438
442
|
coin_obj.set_named_property(
|
|
439
|
-
"
|
|
443
|
+
"puzzleHash",
|
|
440
444
|
ctx.env.create_string(&coin.puzzle_hash)?,
|
|
441
445
|
)?;
|
|
442
446
|
coin_obj
|
|
443
447
|
.set_named_property("amount", ctx.env.create_string(&coin.amount)?)?;
|
|
444
448
|
creations_array.set_element(i as u32, coin_obj)?;
|
|
445
449
|
}
|
|
446
|
-
obj.set_named_property("
|
|
450
|
+
obj.set_named_property("coinCreations", creations_array)?;
|
|
447
451
|
|
|
448
452
|
obj.set_named_property(
|
|
449
|
-
"
|
|
453
|
+
"hasTransactionsGenerator",
|
|
450
454
|
ctx.env.get_boolean(event.has_transactions_generator)?,
|
|
451
455
|
)?;
|
|
452
456
|
obj.set_named_property(
|
|
453
|
-
"
|
|
457
|
+
"generatorSize",
|
|
454
458
|
ctx.env.create_uint32(event.generator_size)?,
|
|
455
459
|
)?;
|
|
456
460
|
|
|
@@ -734,8 +738,6 @@ impl ChiaBlockListener {
|
|
|
734
738
|
},
|
|
735
739
|
puzzle_reveal: hex::encode(&spend.puzzle_reveal),
|
|
736
740
|
solution: hex::encode(&spend.solution),
|
|
737
|
-
real_data: spend.real_data,
|
|
738
|
-
parsing_method: spend.parsing_method.clone(),
|
|
739
741
|
offset: spend.offset,
|
|
740
742
|
})
|
|
741
743
|
.collect(),
|