Skip to content

Commit

Permalink
Merge pull request #54 from DIG-Network/release/v0.0.1-alpha.57
Browse files Browse the repository at this point in the history
Release/v0.0.1 alpha.57
  • Loading branch information
MichaelTaylor3D authored Sep 22, 2024
2 parents 17565cc + 9cd5121 commit 8ffc4f7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

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.57](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.56...v0.0.1-alpha.57) (2024-09-22)


### Bug Fixes

* wallet sig verification ([5fc99da](https://github.com/DIG-Network/dig-chia-sdk/commit/5fc99dad2c56a8a5fb51ffb74e41508d4c992ab6))

### [0.0.1-alpha.56](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.55...v0.0.1-alpha.56) (2024-09-22)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dignetwork/dig-sdk",
"version": "0.0.1-alpha.56",
"version": "0.0.1-alpha.57",
"description": "",
"type": "commonjs",
"main": "./dist/index.js",
Expand Down
29 changes: 15 additions & 14 deletions src/DigNetwork/PropagationServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class PropagationServer {
*/
async initializeWallet() {
this.wallet = await Wallet.load("default");
this.publicKey = await this.wallet.getPrivateSyntheticKey();
this.publicKey = await this.wallet.getPublicSyntheticKey().toString('hex');
}

/**
Expand Down Expand Up @@ -86,7 +86,7 @@ export class PropagationServer {
httpsAgent: this.createHttpsAgent(),
};

let url = `https://${this.ipAddress}:${PropagationServer.port}/stores/${this.storeId}`;
let url = `https://${this.ipAddress}:${PropagationServer.port}/${this.storeId}`;
if (rootHash) {
url += `?hasRootHash=${rootHash}`;
}
Expand All @@ -98,9 +98,9 @@ export class PropagationServer {
const rootHashExists = response.headers["x-has-root-hash"] === "true";

if (storeExists) {
spinner.success({ text: green(`Store ${this.storeId} exists!`) });
spinner.success({ text: green(`Store ${this.storeId} exists on peer!`) });
} else {
spinner.error({ text: red(`Store ${this.storeId} does not exist.`) });
spinner.error({ text: red(`Store ${this.storeId} does not exist. Credentials will be required to push.`) });
}

if (rootHash) {
Expand All @@ -118,7 +118,7 @@ export class PropagationServer {
return { storeExists, rootHashExists };
} catch (error: any) {
spinner.error({ text: red("Error checking if store exists:") });
console.error(red(error));
console.error(red(error.message));
throw error;
}
}
Expand Down Expand Up @@ -158,7 +158,7 @@ export class PropagationServer {
});
} catch (error: any) {
spinner.error({ text: red("Error starting upload session:") });
console.error(red(error));
console.error(red(error.message));
throw error;
}
}
Expand All @@ -177,10 +177,10 @@ export class PropagationServer {
const nonce = response.headers["x-nonce"];
console.log(blue(`Nonce received for file ${filename}: ${nonce}`));
return nonce;
} catch (error) {
} catch (error: any) {
console.error(
red(`Error generating nonce for file ${filename}:`),
error
error.message
);
throw error;
}
Expand All @@ -193,9 +193,10 @@ export class PropagationServer {
async uploadFile(filePath: string) {
const filename = path.basename(filePath);
const nonce = await this.getFileNonce(filename);
const keyOwnershipSig = await this.wallet.createKeyOwnershipSignature(
nonce
);
const wallet = await Wallet.load("default");
const keyOwnershipSig = await wallet.createKeyOwnershipSignature(nonce);
const publicKey = await wallet.getPublicSyntheticKey();


const formData = new FormData();
formData.append("file", fs.createReadStream(filePath));
Expand All @@ -214,7 +215,7 @@ export class PropagationServer {
headers: {
"Content-Type": "multipart/form-data",
"x-nonce": nonce,
"x-public-key": this.publicKey,
"x-public-key": publicKey.toString("hex"),
"x-key-ownership-sig": keyOwnershipSig,
...formData.getHeaders(),
},
Expand All @@ -238,8 +239,8 @@ export class PropagationServer {
progressBar.stop();

return response.data;
} catch (error) {
console.error(red(`✖ Error uploading file ${filename}:`), error);
} catch (error: any) {
console.error(red(`✖ Error uploading file ${filename}:`), error.message);
progressBar.stop(); // Stop the progress bar in case of error
throw error;
}
Expand Down
2 changes: 1 addition & 1 deletion src/blockchain/Wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class Wallet {
return signature.toString("hex");
}

public async verifyKeyOwnershipSignature(
public static async verifyKeyOwnershipSignature(
nonce: string,
signature: string,
publicKey: string
Expand Down

0 comments on commit 8ffc4f7

Please sign in to comment.