Skip to content

Commit

Permalink
update code hash computation to buffer output
Browse files Browse the repository at this point in the history
  • Loading branch information
michavie committed Nov 17, 2023
1 parent 6a87354 commit f4b91cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/smartcontracts/code.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe("Code Class Tests", function() {
const code = Code.fromHex(sampleHex);
const hash = code.computeHash();

assert.instanceOf(hash, Hash);
assert.instanceOf(hash, Buffer);
assert.equal(hash.toString('hex'), 'ac86b78afd9bdda3641a47a4aff2a7ee26acd40cc534d63655e9dfbf3f890a02')
});
});
6 changes: 3 additions & 3 deletions src/smartcontracts/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export class Code {
return Buffer.from(this.hex, "hex");
}

computeHash(): Hash {
computeHash(): Buffer {
const hash = createHasher(CODE_HASH_LENGTH)
.update(this.valueOf())
.digest('hex')
.digest();

return new Hash(hash)
return Buffer.from(hash)
}
}

0 comments on commit f4b91cd

Please sign in to comment.