diff --git a/package-lock.json b/package-lock.json index a623709..c9dc363 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1854,9 +1854,9 @@ "integrity": "sha512-x9ibmsP0ZVqzyCo1Pitbw+4b6iEXRw/r1TCy3vOUR3eKrzWLnHYZMR325BkZW2r8fnuWE/V3Fp4QZOP9qYORCw==" }, "node_modules/@recordex/smartcontract": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/@recordex/smartcontract/-/smartcontract-0.1.2.tgz", - "integrity": "sha512-glpEZU0keoJgYGA1Jjt0jy/I+Mtiwd07nhPJ89rSTFMlbcj59SLp69Q305UGe8qSXZlZNAql0zWFGxs+XKnB+w==", + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@recordex/smartcontract/-/smartcontract-0.1.3.tgz", + "integrity": "sha512-mlIZ5r8nNCnjbH+Hbpvm1ZptRblP+/qwsA/rmvP9afJwZpBfut9SFlV+Pn0RsLcO5gopK8DvfHOP97YeLa9/hA==", "dependencies": { "@openzeppelin/contracts": "^5.0.0", "eslint": "^8.53.0" diff --git a/src/app/files/record/_hooks/createRecord.ts b/src/app/files/record/_hooks/createRecord.ts index 059209c..404a2e7 100644 --- a/src/app/files/record/_hooks/createRecord.ts +++ b/src/app/files/record/_hooks/createRecord.ts @@ -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})`, );