Skip to content

Commit

Permalink
fix nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ocean committed Feb 21, 2025
1 parent f0acea3 commit 858f264
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/services/Aquarius.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,14 @@ export class Aquarius {
if (!nonce || nonce === null) {
nonce = '0'
}
const newNonce = Number(nonce + 1).toString() // have to increase the previous

// same signed message as usual (did + nonce)
// the node will only validate (add his signature if there fields are present and are valid)
let signatureMessage = publisherAddress
signatureMessage += ddo.id + nonce
signatureMessage += ddo.id + newNonce
const signature = await signRequest(signer, signatureMessage)
const data = { ddo, publisherAddress, nonce, signature }
const data = { ddo, publisherAddress, newNonce, signature }
response = await fetch(path, {
method: 'POST',
body: JSON.stringify(data),
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export async function createAsset(
let flags
if (encryptDDO) {
metadata = await ProviderInstance.encrypt(ddo, chainID, providerUrl)
const validateResult = await aquariusInstance.validate(ddo)
const validateResult = await aquariusInstance.validate(ddo, owner)
metadataHash = validateResult.hash
flags = 2
} else {
Expand Down

0 comments on commit 858f264

Please sign in to comment.