From 050586cd1d25f4ce0ce98128f519e390303834ee Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Tue, 8 Oct 2024 09:45:31 -0400 Subject: [PATCH 1/3] fix: get coin state to the right folder --- src/utils/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/config.ts b/src/utils/config.ts index 33fa406..38826aa 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -81,7 +81,7 @@ export const getCoinState = ( description: string; }; } => { - const stateFile = path.join(STORE_PATH, `${storeId}.json`); + const stateFile = path.join(USER_DIR_PATH, `${storeId}.json`); if (!fs.existsSync(stateFile)) { return { metadata: { rootHash: "", bytes: "", label: "", description: "" }, From dc704ad32390de2a9252206b4a6dc38e110319dc Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Tue, 8 Oct 2024 16:09:20 -0400 Subject: [PATCH 2/3] fix: wait for confirmation --- src/blockchain/FullNodePeer.ts | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/src/blockchain/FullNodePeer.ts b/src/blockchain/FullNodePeer.ts index a400a53..7187de3 100644 --- a/src/blockchain/FullNodePeer.ts +++ b/src/blockchain/FullNodePeer.ts @@ -293,10 +293,7 @@ export class FullNodePeer { private static initializePeerWeights(peerIPs: string[]): void { for (const ip of peerIPs) { if (!FullNodePeer.peerWeights.has(ip)) { - if ( - ip === LOCALHOST || - ip === FullNodePeer.getTrustedFullNode() - ) { + if (ip === LOCALHOST || ip === FullNodePeer.getTrustedFullNode()) { FullNodePeer.peerWeights.set(ip, 5); // Higher weight for prioritized peers } else { FullNodePeer.peerWeights.set(ip, 1); // Default weight @@ -518,40 +515,19 @@ export class FullNodePeer { parentCoinInfo: Buffer ): Promise { const spinner = createSpinner("Waiting for confirmation...").start(); - let peer: Peer; - - try { - peer = await FullNodePeer.connect(); - } catch (error: any) { - spinner.error({ text: "Failed to connect to a fullnode peer." }); - console.error(`waitForConfirmation connection error: ${error.message}`); - throw error; - } - - // Extract peer IP to access the corresponding limiter - const peerIP = FullNodePeer.extractPeerIP(peer); - if (!peerIP) { - spinner.error({ text: "Failed to extract fullnode peer IP." }); - throw new Error("Failed to extract peer IP."); - } + const peer = await FullNodePeer.connect(); try { while (true) { // Schedule the isCoinSpent method call through the limiter - const confirmed = await peer.isCoinSpent( + await peer.waitForCoinToBeSpent( parentCoinInfo, MIN_HEIGHT, Buffer.from(MIN_HEIGHT_HEADER_HASH, "hex") ); - if (confirmed) { - spinner.success({ text: "Coin confirmed!" }); - return true; - } - - // Wait for 5 seconds before the next check - await new Promise((resolve) => setTimeout(resolve, 5000)); + spinner.success({ text: "Coin confirmed!" }); } } catch (error: any) { spinner.error({ text: "Error while waiting for confirmation." }); From 5a900d5b7702b97d6d70079e72d0f0bab55f977a Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Tue, 8 Oct 2024 16:10:18 -0400 Subject: [PATCH 3/3] chore(release): 0.0.1-alpha.166 --- CHANGELOG.md | 8 ++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 138236c..ca12587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [0.0.1-alpha.166](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.165...v0.0.1-alpha.166) (2024-10-08) + + +### Bug Fixes + +* get coin state to the right folder ([050586c](https://github.com/DIG-Network/dig-chia-sdk/commit/050586cd1d25f4ce0ce98128f519e390303834ee)) +* wait for confirmation ([dc704ad](https://github.com/DIG-Network/dig-chia-sdk/commit/dc704ad32390de2a9252206b4a6dc38e110319dc)) + ### [0.0.1-alpha.165](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.164...v0.0.1-alpha.165) (2024-10-08) diff --git a/package-lock.json b/package-lock.json index 00ea1ef..c2d6395 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dignetwork/dig-sdk", - "version": "0.0.1-alpha.165", + "version": "0.0.1-alpha.166", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@dignetwork/dig-sdk", - "version": "0.0.1-alpha.165", + "version": "0.0.1-alpha.166", "license": "ISC", "dependencies": { "@dignetwork/datalayer-driver": "^0.1.29", diff --git a/package.json b/package.json index 1d9af6f..ff6ec1b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dignetwork/dig-sdk", - "version": "0.0.1-alpha.165", + "version": "0.0.1-alpha.166", "description": "", "type": "commonjs", "main": "./dist/index.js",