@@ -207,9 +207,11 @@ out:
207
207
}
208
208
209
209
var dataProofResp DataProofRPCResponse
210
+ var extIndex int
210
211
for idx , e := range block .Block .Extrinsics {
211
212
// Look for our submitted extrinsic in the block
212
213
if ext .Signature .Signature .AsEcdsa .Hex () == e .Signature .Signature .AsEcdsa .Hex () {
214
+ extIndex = idx
213
215
resp , err := http .Post ("https://goldberg.avail.tools/api" , "application/json" ,
214
216
strings .NewReader (fmt .Sprintf ("{\" id\" :1,\" jsonrpc\" :\" 2.0\" ,\" method\" :\" kate_queryDataProofV2\" ,\" params\" :[%d, \" %#x\" ]}" , idx + 1 , blockHash ))) //nolint: noctx
215
217
if err != nil {
@@ -235,15 +237,8 @@ out:
235
237
}
236
238
}
237
239
dataProof := dataProofResp .Result .DataProof
238
-
239
- extBytes , err := json .Marshal (ext )
240
- if err != nil {
241
- return nil , nil , fmt .Errorf ("cannot marshal extrinsic" , err )
242
- }
243
- // Strip string of any leading or following quotes
244
- extBytes = []byte (strings .Trim (string (extBytes ), "\" " ))
245
240
// NOTE: Substrate's BlockNumber type is an alias for u32 type, which is uint32
246
- blobID := makeID (uint32 (block .Block .Header .Number ), string ( extBytes ) )
241
+ blobID := makeID (uint32 (block .Block .Header .Number ), extIndex )
247
242
blobIDs := make ([]da.ID , 1 )
248
243
blobIDs [0 ] = blobID
249
244
@@ -313,20 +308,21 @@ func (a *DAClient) GetAccountNextIndex() (types.UCompact, error) {
313
308
var accountNextIndex AccountNextIndexRPCResponse
314
309
err = json .Unmarshal (data , & accountNextIndex )
315
310
if err != nil {
316
- return types .NewUCompactFromUInt (0 ), fmt .Errorf ("cannot unmarshal account next index" , err )
311
+ return types .NewUCompactFromUInt (0 ), fmt .Errorf ("cannot unmarshal account next index:%w Response: %s " , err , data )
317
312
}
318
313
319
314
return types .NewUCompactFromUInt (uint64 (accountNextIndex .Result )), nil
320
315
}
321
316
322
317
// makeID creates a unique ID to reference a blob on Avail
323
- func makeID (blockHeight uint32 , extHash string ) da.ID {
318
+ func makeID (blockHeight uint32 , extIndex int ) da.ID {
324
319
// Serialise height and leaf index to binary
325
320
heightLen := 4
326
321
heightBytes := make ([]byte , heightLen )
327
322
binary .LittleEndian .PutUint32 (heightBytes , blockHeight )
328
- idBytes := append (heightBytes , []byte (extHash )... )
329
- return da .ID (idBytes )
323
+ extIndexBytes := make ([]byte , 4 )
324
+ binary .LittleEndian .PutUint32 (extIndexBytes , uint32 (extIndex ))
325
+ return da .ID (append (heightBytes , extIndexBytes ... ))
330
326
}
331
327
332
328
// SplitID returns the block height and leaf index from a unique ID
0 commit comments