Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/boilerplate/common/backup-encrypted-data-listener.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ export default class BackupEncryptedDataEventListener {
await storeCommitment({
hash: newCommitment,
name,
transactionHash: eventData.transactionHash || null,
mappingKey: mappingKey?.integer,
type: commitmentType,
typeNames: structTypeNames,
Expand Down
1 change: 1 addition & 0 deletions src/boilerplate/common/commitment-storage.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function formatCommitment(commitment) {
_id: commitment.hash.hex(32),
name: commitment.name,
source: commitment.source,
transactionHash: commitment.transactionHash ?? null,
type: commitment.type ?? null,
typeNames: Array.isArray(commitment.typeNames)
? commitment.typeNames
Expand Down
9 changes: 7 additions & 2 deletions src/boilerplate/common/encrypted-data-listener.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,13 @@ export default class EncryptedDataEventListener {
.flatMap(e => e.returnValues.nullifiers)
return Promise.all(
backupEvents
.map(e => decrypt(e.returnValues.cipherText, this.publicKey, this.secretKey))
.map(decodeCommitmentData)
.map(e => {
const commitment = decodeCommitmentData(
decrypt(e.returnValues.cipherText, this.publicKey, this.secretKey),
);
if (commitment) commitment.transactionHash = e.transactionHash;
return commitment;
})
.filter(c => c)
.map(formatCommitment)
.map(c => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,9 @@ sendTransaction = {
isConstructor
}): string[] {
let value;
const transactionHash = isConstructor
? `null`
Comment thread
Wei-257 marked this conversation as resolved.
: `encBackupEvent?.[0]?.transactionHash || null`;
const commitmentType = !Array.isArray(valueType) && ['bytes20', 'address'].includes(valueType)
? `\n type: '${valueType}',`
: '';
Expand All @@ -708,6 +711,7 @@ sendTransaction = {
\nawait storeCommitment({
hash: ${stateName}_newCommitment,
name: '${mappingName}',
transactionHash: ${transactionHash},
mappingKey: ${mappingKey === `` ? `null` : `${mappingKey}`},
${commitmentType}
${commitmentTypeNames}
Expand All @@ -729,6 +733,7 @@ sendTransaction = {
\nawait storeCommitment({
hash: ${stateName}_2_newCommitment,
name: '${mappingName}',
transactionHash: ${transactionHash},
mappingKey: ${mappingKey === `` ? `null` : `${mappingKey}`},
${commitmentType}
${commitmentTypeNames}
Expand All @@ -755,6 +760,7 @@ sendTransaction = {
\nawait storeCommitment({
hash: ${stateName}_newCommitment,
name: '${mappingName}',
transactionHash: ${transactionHash},
mappingKey: ${mappingKey === `` ? `null` : `${mappingKey}`},
${commitmentType}
${commitmentTypeNames}
Expand Down
4 changes: 4 additions & 0 deletions src/codeGenerators/orchestration/files/toOrchestration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ node.stateVariables?.forEach(
hash: newCommitment,
name: '${variable.name}',
source: 'encrypted data',
transactionHash: eventData.transactionHash || null,
mappingKey: stateVarId.integer,
preimage: {
stateVarId,
Expand Down Expand Up @@ -358,6 +359,7 @@ node.stateVariables?.forEach(
hash: newCommitment,
name: '${variable.name}',
source: 'encrypted data',
transactionHash: eventData.transactionHash || null,
mappingKey: stateVarId.integer,
preimage: {
stateVarId,
Expand Down Expand Up @@ -811,6 +813,7 @@ const prepareBackupVariable = (node: any) => {
await storeCommitment({
hash: newCommitment,
name: name,
transactionHash: log.transactionHash || null,
mappingKey: mappingKey?.integer,
type: commitmentType,
typeNames: structTypeNames,
Expand Down Expand Up @@ -1045,6 +1048,7 @@ const prepareBackupDataRetriever = (node: any) => {
await storeCommitment({
hash: newCommitment,
name: name,
transactionHash: log.transactionHash || null,
mappingKey: mappingKey?.integer,
type: commitmentType,
typeNames: structTypeNames,
Expand Down
Loading