Skip to content

Commit 4432ff9

Browse files
authored
fix: match submitted ext with block ext properly (#6)
1 parent 894d104 commit 4432ff9

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

availda/availda.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,24 +210,35 @@ out:
210210
var extIndex int
211211
for idx, e := range block.Block.Extrinsics {
212212
// Look for our submitted extrinsic in the block
213-
if ext.Signature.Signature.AsEcdsa.Hex() == e.Signature.Signature.AsEcdsa.Hex() {
213+
extBytes, err := json.Marshal(ext)
214+
if err != nil {
215+
continue
216+
}
217+
extBytes = []byte(strings.Trim(string(extBytes), "\""))
218+
219+
eBytes, err := json.Marshal(e)
220+
if err != nil {
221+
continue
222+
}
223+
eBytes = []byte(strings.Trim(string(eBytes), "\""))
224+
if string(extBytes) == string(eBytes) {
214225
extIndex = idx
215226
resp, err := http.Post(a.config.HttpApiURL, "application/json",
216227
strings.NewReader(fmt.Sprintf("{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"kate_queryDataProofV2\",\"params\":[%d, \"%#x\"]}", idx+1, blockHash))) //nolint: noctx
217228
if err != nil {
218-
return nil, nil, fmt.Errorf("cannot post query request", err)
229+
break
219230
}
220231
data, err := io.ReadAll(resp.Body)
221232
if err != nil {
222-
return nil, nil, fmt.Errorf("cannot read body", err)
233+
break
223234
}
224235
err = resp.Body.Close()
225236
if err != nil {
226-
return nil, nil, fmt.Errorf("cannot close body", err)
237+
break
227238
}
228239
err = json.Unmarshal(data, &dataProofResp)
229240
if err != nil {
230-
return nil, nil, fmt.Errorf("cannot unmarshal data proof: %w", err)
241+
break
231242
}
232243

233244
if dataProofResp.Result.DataProof.Leaf == fmt.Sprintf("%#x", batchHash) {

0 commit comments

Comments
 (0)