Skip to content

Commit c3067bd

Browse files
committed
packages/core: add extra layer of hashing for contract args
1 parent c1a0a09 commit c3067bd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/core/src/Canvas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class Canvas<
135135

136136
const topicHashComponents: { args?: Uint8Array; snapshot?: Uint8Array; code?: Uint8Array } = {}
137137
if (args.length > 0) {
138-
topicHashComponents.args = cbor.encode(args)
138+
topicHashComponents.args = sha256(cbor.encode(args))
139139
}
140140
if (config.snapshot) {
141141
topicHashComponents.snapshot = sha256(cbor.encode(config.snapshot))

packages/core/test/contract.topic.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function computeTopicHash(components: { args?: any[]; code?: string; snapshot?:
1111
const topicHashComponents: { args?: Uint8Array; snapshot?: Uint8Array; code?: Uint8Array } = {}
1212

1313
if (components.args && components.args.length > 0) {
14-
topicHashComponents.args = cbor.encode(components.args)
14+
topicHashComponents.args = sha256(cbor.encode(components.args))
1515
}
1616
if (components.snapshot) {
1717
topicHashComponents.snapshot = sha256(cbor.encode(components.snapshot))

0 commit comments

Comments
 (0)