1- import KYVE from "@kyve/core" ;
1+ import KYVE , { Item } from "@kyve/core" ;
22import { Signature } from "./types" ;
33import { fetchBlock , fetchBlockHash } from "./utils" ;
44import { version } from "../package.json" ;
@@ -11,14 +11,14 @@ KYVE.metrics.register.setDefaultLabels({
1111} ) ;
1212
1313class KyveBitcoin extends KYVE {
14- public async getDataItem ( key : number ) : Promise < { key : number ; value : any } > {
14+ public async getDataItem ( key : string ) : Promise < Item > {
1515 let hash : string ;
1616 let block : any ;
1717
1818 try {
1919 hash = await fetchBlockHash (
2020 this . pool . config . rpc ,
21- key ,
21+ + key ,
2222 await this . getSignature ( )
2323 ) ;
2424 } catch ( err ) {
@@ -34,16 +34,26 @@ class KyveBitcoin extends KYVE {
3434 await this . getSignature ( )
3535 ) ;
3636 } catch ( err ) {
37- this . logger . warn (
38- `⚠️ EXTERNAL ERROR: Failed to fetch block ${ key } . Retrying ...`
39- ) ;
37+ this . logger . warn ( `Failed to fetch block ${ key } . Retrying ...` ) ;
4038
4139 throw err ;
4240 }
4341
4442 return { key, value : block } ;
4543 }
4644
45+ public async getNextKey ( key : string ) : Promise < string > {
46+ if ( key ) {
47+ return ( parseInt ( key ) + 1 ) . toString ( ) ;
48+ }
49+
50+ return "0" ;
51+ }
52+
53+ public async formatValue ( value : any ) : Promise < string > {
54+ return value . hash ;
55+ }
56+
4757 private async getSignature ( ) : Promise < Signature > {
4858 const address = await this . sdk . wallet . getAddress ( ) ;
4959 const timestamp = new Date ( ) . valueOf ( ) . toString ( ) ;
0 commit comments