From 39467c198b19d051e55a8545e26d4ff2e655c0e7 Mon Sep 17 00:00:00 2001 From: Keisuke Ishigami <62370522+kei01234kei@users.noreply.github.com> Date: Wed, 17 Jan 2024 18:31:53 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E8=A8=98=E9=8C=B2=E3=83=88=E3=83=A9=E3=83=B3=E3=82=B6=E3=82=AF?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=AB=E3=83=96=E3=83=AD=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=83=81=E3=82=A7=E3=83=BC=E3=83=B3=E3=81=AB=E8=A8=98?= =?UTF-8?q?=E9=8C=B2=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8B=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E3=81=AE=E3=83=88=E3=83=A9=E3=83=B3=E3=82=B6=E3=82=AF?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E5=90=AB=E3=82=81=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= =?UTF-8?q?=20(#8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Keisuke Ishigami --- package-lock.json | 6 +++--- src/app/files/record/_hooks/createRecord.ts | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) 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})`, );