File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @kyve/substrate" ,
3- "version" : " 0.0.3 " ,
3+ "version" : " 0.1.0 " ,
44 "license" : " MIT" ,
55 "scripts" : {
66 "build" : " rimraf dist && tsc" ,
7- "build:binaries" : " yarn build && rimraf out && pkg --output out/kyve package.json && node ./node_modules/@kyve/core/dist/src/checksum.js" ,
7+ "build:binaries" : " yarn build && rimraf out && pkg --no-bytecode --public-packages '*' -- output out/kyve package.json && node ./node_modules/@kyve/core/dist/src/checksum.js" ,
88 "start" : " node ./dist/src/index.js" ,
99 "format" : " prettier --write ."
1010 },
2222 "singleQuote" : true
2323 },
2424 "dependencies" : {
25- "@kyve/core" : " ^1.1 .0" ,
25+ "@kyve/core" : " 1.2 .0" ,
2626 "axios" : " ^0.27.2"
2727 },
2828 "devDependencies" : {
Original file line number Diff line number Diff line change 1- import KYVE from '@kyve/core' ;
1+ import KYVE , { Item } from '@kyve/core' ;
22import { Signature } from './types' ;
33import { fetchBlock , isHeightOutOfRange } from './utils' ;
44import { name , version } from '../package.json' ;
@@ -11,28 +11,38 @@ KYVE.metrics.register.setDefaultLabels({
1111} ) ;
1212
1313class KyveSubstrate extends KYVE {
14- public async getDataItem ( key : number ) : Promise < { key : number ; value : any } > {
14+ public async getDataItem ( key : string ) : Promise < Item > {
1515 let block ;
1616
1717 try {
1818 block = await fetchBlock (
1919 this . pool . config . rpc ,
20- key ,
20+ + key ,
2121 await this . getSignature ( )
2222 ) ;
2323 } catch ( err ) {
2424 if ( isHeightOutOfRange ( err ) ) throw new Error ( ) ;
2525
26- this . logger . warn (
27- `⚠️ EXTERNAL ERROR: Failed to fetch block ${ key } . Retrying ...`
28- ) ;
26+ this . logger . warn ( `Failed to fetch block ${ key } . Retrying ...` ) ;
2927
3028 throw err ;
3129 }
3230
3331 return { key, value : block } ;
3432 }
3533
34+ public async getNextKey ( key : string ) : Promise < string > {
35+ if ( key ) {
36+ return ( parseInt ( key ) + 1 ) . toString ( ) ;
37+ }
38+
39+ return '0' ;
40+ }
41+
42+ public async formatValue ( value : any ) : Promise < string > {
43+ return value . hash ;
44+ }
45+
3646 private async getSignature ( ) : Promise < Signature > {
3747 const address = await this . sdk . wallet . getAddress ( ) ;
3848 const timestamp = new Date ( ) . valueOf ( ) . toString ( ) ;
You can’t perform that action at this time.
0 commit comments