Skip to content

Commit

Permalink
chore: ファイル記録トランザクションにブロックチェーンに記録されている最新のトランザクションを含めるようにしました (#8)
Browse files Browse the repository at this point in the history
Co-authored-by: Keisuke Ishigami <[email protected]>
  • Loading branch information
kei01234kei and kei01234kei authored Jan 17, 2024
1 parent e84026e commit 39467c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

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

12 changes: 11 additions & 1 deletion src/app/files/record/_hooks/createRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@ export const createRecord = async (
signer,
);
const recordContract = recordFactory.connect(signer);
const addFile = await recordContract.addFile(file.name, fileHash);
// ブロックチェーンに記録されている最新のファイルハッシュ値を取得
const fileMetaDataHistory =
await recordContract.getFileMetadataHistory(fileHash);
const newestFileHash =
fileMetaDataHistory[fileMetaDataHistory.length - 1].hash;
// ブロックチェーンにファイルのハッシュ値を記録
const addFile = await recordContract.addFile(
file.name,
fileHash,
newestFileHash,
);
console.log(
`トランザクションの送信に成功しました。network -> ${signer.provider._network.name}, transactionHash -> ${addFile.hash})`,
);
Expand Down

0 comments on commit 39467c1

Please sign in to comment.