Skip to content

Commit 9ef5a45

Browse files
committed
increased version
1 parent 87f367b commit 9ef5a45

3 files changed

Lines changed: 246 additions & 194 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "@kyve/bitcoin",
3-
"version": "0.1.0",
3+
"version": "0.2.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
},
@@ -19,7 +19,7 @@
1919
"outputPath": "out"
2020
},
2121
"dependencies": {
22-
"@kyve/core": "1.1.0",
22+
"@kyve/core": "1.2.0",
2323
"axios": "^0.26.1",
2424
"nanoid": "^3.3.3"
2525
},

src/index.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import KYVE from "@kyve/core";
1+
import KYVE, { Item } from "@kyve/core";
22
import { Signature } from "./types";
33
import { fetchBlock, fetchBlockHash } from "./utils";
44
import { version } from "../package.json";
@@ -11,14 +11,14 @@ KYVE.metrics.register.setDefaultLabels({
1111
});
1212

1313
class 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

Comments
 (0)