From efc1d5eafe6b461dd14458c94a21a2bf3d2cb665 Mon Sep 17 00:00:00 2001 From: maksaid Date: Wed, 17 Jan 2024 21:52:35 +0300 Subject: [PATCH] fix: post hash --- Comment/comment.go | 2 +- Post/post_contract.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Comment/comment.go b/Comment/comment.go index bc8b85b..d66b15c 100755 --- a/Comment/comment.go +++ b/Comment/comment.go @@ -35,7 +35,7 @@ func _deploy(data interface{}, isUpdate bool) { }) if len(args.commentHash) != interop.Hash160Len { - panic("invalid hash of player contrast") + panic("invalid hash") } ctx := storage.GetContext() diff --git a/Post/post_contract.go b/Post/post_contract.go index 158e9f9..3008357 100755 --- a/Post/post_contract.go +++ b/Post/post_contract.go @@ -22,9 +22,27 @@ const ( lastIndex = "user_post_index" id = "current_post_id" comment_prefix = "comment_" + post_hash = "post_hash" gas_decimals = 1_0000_0000 ) +func _deploy(data interface{}, isUpdate bool) { + if isUpdate { + return + } + + args := data.(struct { + postHash interop.Hash160 + }) + + if len(args.postHash) != interop.Hash160Len { + panic("invalid hash") + } + + ctx := storage.GetContext() + storage.Put(ctx, post_hash, args.postHash) +} + func NewPost(login string, text string, postName string) { ctx := storage.GetContext() updatePostId()