From f05763ec8a9d62024ade0a8d859b1808bf35e9e1 Mon Sep 17 00:00:00 2001 From: Bekket Date: Tue, 18 Oct 2022 09:33:49 +0400 Subject: [PATCH 1/4] appendix and menu buttons --- main.go | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index f5b98b2..e3f3273 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,12 @@ var yesNoKeyboard = tgbotapi.NewReplyKeyboard( tgbotapi.NewKeyboardButton("No")), ) +var optionKeyboard = tgbotapi.NewReplyKeyboard( + tgbotapi.NewKeyboardButtonRow( + tgbotapi.NewKeyboardButton("WhoIs"), + tgbotapi.NewKeyboardButton("WhoTrust")), +) + var mainKeyboard = tgbotapi.NewReplyKeyboard( tgbotapi.NewKeyboardButtonRow( tgbotapi.NewKeyboardButton("Verify personal wallet")), @@ -76,7 +82,9 @@ func main() { msgTemplates["hello"] = "Hey, this bot is attaching personal wallets to telegram user & collective wallets to chat id" msgTemplates["case0"] = "Go to link and attach your tg_id to your metamask wallet" msgTemplates["await"] = "Awaiting for verification" - msgTemplates["case1"] = "You have successfully authorized your wallet to your account" + msgTemplates["case1"] = "You have successfully authorized your wallet to your account. Now you can use additional functions" + msgTemplates["who_is"] = "Input wallet address to know it's associated telegram nickname" + msgTemplates["who_trust"] = "Input telegram nickname to know who trust and who is untrust to this user" //var baseURL = "http://localhost:3000/" //var baseURL = "https://ikytest-gw0gy01is-s0lidarnost.vercel.app/" @@ -226,10 +234,33 @@ func main() { case 1: if updateDb, ok := userDatabase[update.Message.From.ID]; ok { - //updateDb.dialog_status = 2 msg := tgbotapi.NewMessage(userDatabase[update.Message.From.ID].tgid, msgTemplates["case1"]) + msg.ReplyMarkup = optionKeyboard bot.Send(msg) + updateDb.dialog_status = 2 userDatabase[update.Message.From.ID] = updateDb + + } + + case 2: + if updateDb, ok := userDatabase[update.Message.From.ID]; ok { + if update.Message.Text == "WhoIs" { + msg := tgbotapi.NewMessage(userDatabase[update.Message.From.ID].tgid, msgTemplates["who_is"]) + msg.ReplyMarkup = optionKeyboard + bot.Send(msg) + updateDb.dialog_status = 3 + userDatabase[update.Message.From.ID] = updateDb + } else if update.Message.Text == "WhoTrust" { + msg := tgbotapi.NewMessage(userDatabase[update.Message.From.ID].tgid, msgTemplates["who_trust"]) + msg.ReplyMarkup = optionKeyboard + bot.Send(msg) + updateDb.dialog_status = 4 + userDatabase[update.Message.From.ID] = updateDb + } + + + + } } From 89cdc37fc7e4c8e09337afc483a99e25e1179ab6 Mon Sep 17 00:00:00 2001 From: Bekket Date: Tue, 18 Oct 2022 09:54:42 +0400 Subject: [PATCH 2/4] func for whois --- main.go | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index e3f3273..ba7f1f4 100644 --- a/main.go +++ b/main.go @@ -257,12 +257,27 @@ func main() { updateDb.dialog_status = 4 userDatabase[update.Message.From.ID] = updateDb } + } - - + // whois + case 3: + if updateDb, ok := userDatabase[update.Message.From.ID]; ok { + var address_to_check_string = update.Message.Text + var address_to_check = common.HexToAddress(address_to_check_string) + tg_nickname,err := WhoIsAddress(session, address_to_check) + if err != nil { + log.Println("error with getting nickname associated with eth wallet, probably not registred yet") + } + msg := tgbotapi.NewMessage(userDatabase[update.Message.From.ID].tgid,tg_nickname ) + bot.Send(msg) + updateDb.dialog_status = 2 + userDatabase[update.Message.From.ID] = updateDb } + // trust @todo: add functionality for trust + case 4: + } } } @@ -345,12 +360,23 @@ func DeclinePassport(auth *bind.TransactOpts, pc *passport.Passport, user_addres Context: context.Background(), }, user_address, ) - if err != nil { log.Println("cant send DECLINING reques to contract: ") log.Print(err) } - fmt.Printf("transaction for DECLINING passport sent! Please wait for tx %s to be confirmed. \n", tx_to_approve.Hash().Hex()) - } + + +// allow bot to get tg nickname associated with this eth wallet +func WhoIsAddress(session *passport.PassportSession,address_to_check common.Address) (string,error){ + passport, err := session.GetPassportByAddress(address_to_check) + if err != nil { + log.Println("cant get passport associated with this address, possible it's not registred yet: ") + log.Print(err) + return "error",err + } + nickname := passport.UserName + return nickname,nil + +} \ No newline at end of file From ac15ec8608fff9db2c30da9ea265c668c3a0f78a Mon Sep 17 00:00:00 2001 From: Bekket Date: Tue, 18 Oct 2022 11:05:29 +0400 Subject: [PATCH 3/4] artifacts v0.0.10 --- artifacts/TGPassport/TGPassport.go | 75 +++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/artifacts/TGPassport/TGPassport.go b/artifacts/TGPassport/TGPassport.go index 8b0d205..156a0f0 100644 --- a/artifacts/TGPassport/TGPassport.go +++ b/artifacts/TGPassport/TGPassport.go @@ -39,7 +39,7 @@ type TGPassportPassport struct { // PassportMetaData contains all meta data concerning the Passport contract. var PassportMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"int64\",\"name\":\"applyerTg\",\"type\":\"int64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"wallet_address\",\"type\":\"address\"}],\"name\":\"passportApplied\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"int64\",\"name\":\"applyerTg\",\"type\":\"int64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"wallet_address\",\"type\":\"address\"}],\"name\":\"passportAppliedIndexed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"int64\",\"name\":\"applyerTg\",\"type\":\"int64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"wallet_address\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"issuer\",\"type\":\"address\"}],\"name\":\"passportApproved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"int64\",\"name\":\"applyerTg\",\"type\":\"int64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"wallet\",\"type\":\"address\"}],\"name\":\"passportDenied\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"int64\",\"name\":\"from\",\"type\":\"int64\"},{\"indexed\":true,\"internalType\":\"int64\",\"name\":\"to\",\"type\":\"int64\"}],\"name\":\"trustedIndexed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"int64\",\"name\":\"from\",\"type\":\"int64\"},{\"indexed\":true,\"internalType\":\"int64\",\"name\":\"to\",\"type\":\"int64\"}],\"name\":\"untrustedIndexed\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"applyerTg\",\"type\":\"int64\"},{\"internalType\":\"string\",\"name\":\"user_name_\",\"type\":\"string\"}],\"name\":\"ApplyForPassport\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"passportToApprove\",\"type\":\"address\"}],\"name\":\"ApprovePassport\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"passportToDecline\",\"type\":\"address\"}],\"name\":\"DeclinePassport\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"passportToDecline\",\"type\":\"address\"}],\"name\":\"DeletePassport\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GetOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user_wallet\",\"type\":\"address\"}],\"name\":\"GetPassportByAddress\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"int64\",\"name\":\"tgId\",\"type\":\"int64\"},{\"internalType\":\"bool\",\"name\":\"valid\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"userName\",\"type\":\"string\"}],\"internalType\":\"structTGPassport.Passport\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"user_name_\",\"type\":\"string\"}],\"name\":\"GetPassportByNickName\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"int64\",\"name\":\"tgId\",\"type\":\"int64\"},{\"internalType\":\"bool\",\"name\":\"valid\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"userName\",\"type\":\"string\"}],\"internalType\":\"structTGPassport.Passport\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GetPassportFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"tgId_\",\"type\":\"int64\"}],\"name\":\"GetPassportWalletByID\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user_wallet\",\"type\":\"address\"}],\"name\":\"GetTgIdByAddress\",\"outputs\":[{\"internalType\":\"int64\",\"name\":\"tgid\",\"type\":\"int64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"from\",\"type\":\"int64\"},{\"internalType\":\"int64\",\"name\":\"to\",\"type\":\"int64\"}],\"name\":\"GetTrust\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"user_name_\",\"type\":\"string\"}],\"name\":\"GetWalletByNickName\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"enemy_address\",\"type\":\"address\"}],\"name\":\"INOTTrustAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"my_username\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"enemy_name\",\"type\":\"string\"}],\"name\":\"INOTTrustUsername\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"friend_address\",\"type\":\"address\"}],\"name\":\"ITrustAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"my_username\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"friend_name\",\"type\":\"string\"}],\"name\":\"ITrustUsername\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"passportFee_\",\"type\":\"uint256\"}],\"name\":\"SetPassportFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"new_user_name_\",\"type\":\"string\"}],\"name\":\"UpdateUserName\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"\",\"type\":\"int64\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"opinion_changed\",\"outputs\":[{\"internalType\":\"int64\",\"name\":\"\",\"type\":\"int64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"passports\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"int64\",\"name\":\"tgId\",\"type\":\"int64\"},{\"internalType\":\"bool\",\"name\":\"valid\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"userName\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"\",\"type\":\"int64\"}],\"name\":\"tgIdToAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"\",\"type\":\"int64\"},{\"internalType\":\"int64\",\"name\":\"\",\"type\":\"int64\"}],\"name\":\"trust_global\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"name\":\"username_wallets\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"int64\",\"name\":\"applyerTg\",\"type\":\"int64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"wallet_address\",\"type\":\"address\"}],\"name\":\"passportApplied\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"int64\",\"name\":\"applyerTg\",\"type\":\"int64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"wallet_address\",\"type\":\"address\"}],\"name\":\"passportAppliedIndexed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"int64\",\"name\":\"applyerTg\",\"type\":\"int64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"wallet_address\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"issuer\",\"type\":\"address\"}],\"name\":\"passportApproved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"int64\",\"name\":\"applyerTg\",\"type\":\"int64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"wallet\",\"type\":\"address\"}],\"name\":\"passportDenied\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"int64\",\"name\":\"from\",\"type\":\"int64\"},{\"indexed\":true,\"internalType\":\"int64\",\"name\":\"to\",\"type\":\"int64\"}],\"name\":\"trustedIndexed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"int64\",\"name\":\"from\",\"type\":\"int64\"},{\"indexed\":true,\"internalType\":\"int64\",\"name\":\"to\",\"type\":\"int64\"}],\"name\":\"untrustedIndexed\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"applyerTg\",\"type\":\"int64\"},{\"internalType\":\"string\",\"name\":\"user_name_\",\"type\":\"string\"}],\"name\":\"ApplyForPassport\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"passportToApprove\",\"type\":\"address\"}],\"name\":\"ApprovePassport\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"passportToDecline\",\"type\":\"address\"}],\"name\":\"DeclinePassport\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"passportToDecline\",\"type\":\"address\"}],\"name\":\"DeletePassport\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GetOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user_wallet\",\"type\":\"address\"}],\"name\":\"GetPassportByAddress\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"int64\",\"name\":\"tgId\",\"type\":\"int64\"},{\"internalType\":\"bool\",\"name\":\"valid\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"userName\",\"type\":\"string\"}],\"internalType\":\"structTGPassport.Passport\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"user_name_\",\"type\":\"string\"}],\"name\":\"GetPassportByNickName\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"int64\",\"name\":\"tgId\",\"type\":\"int64\"},{\"internalType\":\"bool\",\"name\":\"valid\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"userName\",\"type\":\"string\"}],\"internalType\":\"structTGPassport.Passport\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"tgId_\",\"type\":\"int64\"}],\"name\":\"GetPassportByTgId\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"int64\",\"name\":\"tgId\",\"type\":\"int64\"},{\"internalType\":\"bool\",\"name\":\"valid\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"userName\",\"type\":\"string\"}],\"internalType\":\"structTGPassport.Passport\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GetPassportFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"tgId_\",\"type\":\"int64\"}],\"name\":\"GetPassportWalletByID\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user_wallet\",\"type\":\"address\"}],\"name\":\"GetTgIdByAddress\",\"outputs\":[{\"internalType\":\"int64\",\"name\":\"tgid\",\"type\":\"int64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"from\",\"type\":\"int64\"},{\"internalType\":\"int64\",\"name\":\"to\",\"type\":\"int64\"}],\"name\":\"GetTrust\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"user_name_\",\"type\":\"string\"}],\"name\":\"GetWalletByNickName\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"enemy_address\",\"type\":\"address\"}],\"name\":\"INOTTrustAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"my_username\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"enemy_name\",\"type\":\"string\"}],\"name\":\"INOTTrustUsername\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"from\",\"type\":\"int64\"},{\"internalType\":\"int64\",\"name\":\"to\",\"type\":\"int64\"}],\"name\":\"INotTrustID\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"friend_address\",\"type\":\"address\"}],\"name\":\"ITrustAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"from\",\"type\":\"int64\"},{\"internalType\":\"int64\",\"name\":\"to\",\"type\":\"int64\"}],\"name\":\"ITrustID\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"my_username\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"friend_name\",\"type\":\"string\"}],\"name\":\"ITrustUsername\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"passportFee_\",\"type\":\"uint256\"}],\"name\":\"SetPassportFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"new_user_name_\",\"type\":\"string\"}],\"name\":\"UpdateUserName\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"\",\"type\":\"int64\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"opinion_changed\",\"outputs\":[{\"internalType\":\"int64\",\"name\":\"\",\"type\":\"int64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"passports\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"internalType\":\"int64\",\"name\":\"tgId\",\"type\":\"int64\"},{\"internalType\":\"bool\",\"name\":\"valid\",\"type\":\"bool\"},{\"internalType\":\"address\",\"name\":\"validatorAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"userName\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"\",\"type\":\"int64\"}],\"name\":\"tgIdToAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int64\",\"name\":\"\",\"type\":\"int64\"},{\"internalType\":\"int64\",\"name\":\"\",\"type\":\"int64\"}],\"name\":\"trust_global\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"name\":\"username_wallets\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // PassportABI is the input ABI used to generate the binding from. @@ -281,6 +281,37 @@ func (_Passport *PassportCallerSession) GetPassportByNickName(user_name_ string) return _Passport.Contract.GetPassportByNickName(&_Passport.CallOpts, user_name_) } +// GetPassportByTgId is a free data retrieval call binding the contract method 0x65a5637e. +// +// Solidity: function GetPassportByTgId(int64 tgId_) view returns((address,int64,bool,address,string)) +func (_Passport *PassportCaller) GetPassportByTgId(opts *bind.CallOpts, tgId_ int64) (TGPassportPassport, error) { + var out []interface{} + err := _Passport.contract.Call(opts, &out, "GetPassportByTgId", tgId_) + + if err != nil { + return *new(TGPassportPassport), err + } + + out0 := *abi.ConvertType(out[0], new(TGPassportPassport)).(*TGPassportPassport) + + return out0, err + +} + +// GetPassportByTgId is a free data retrieval call binding the contract method 0x65a5637e. +// +// Solidity: function GetPassportByTgId(int64 tgId_) view returns((address,int64,bool,address,string)) +func (_Passport *PassportSession) GetPassportByTgId(tgId_ int64) (TGPassportPassport, error) { + return _Passport.Contract.GetPassportByTgId(&_Passport.CallOpts, tgId_) +} + +// GetPassportByTgId is a free data retrieval call binding the contract method 0x65a5637e. +// +// Solidity: function GetPassportByTgId(int64 tgId_) view returns((address,int64,bool,address,string)) +func (_Passport *PassportCallerSession) GetPassportByTgId(tgId_ int64) (TGPassportPassport, error) { + return _Passport.Contract.GetPassportByTgId(&_Passport.CallOpts, tgId_) +} + // GetPassportFee is a free data retrieval call binding the contract method 0x48dc1561. // // Solidity: function GetPassportFee() view returns(uint256) @@ -777,6 +808,27 @@ func (_Passport *PassportTransactorSession) INOTTrustUsername(my_username string return _Passport.Contract.INOTTrustUsername(&_Passport.TransactOpts, my_username, enemy_name) } +// INotTrustID is a paid mutator transaction binding the contract method 0x5c962dfc. +// +// Solidity: function INotTrustID(int64 from, int64 to) returns() +func (_Passport *PassportTransactor) INotTrustID(opts *bind.TransactOpts, from int64, to int64) (*types.Transaction, error) { + return _Passport.contract.Transact(opts, "INotTrustID", from, to) +} + +// INotTrustID is a paid mutator transaction binding the contract method 0x5c962dfc. +// +// Solidity: function INotTrustID(int64 from, int64 to) returns() +func (_Passport *PassportSession) INotTrustID(from int64, to int64) (*types.Transaction, error) { + return _Passport.Contract.INotTrustID(&_Passport.TransactOpts, from, to) +} + +// INotTrustID is a paid mutator transaction binding the contract method 0x5c962dfc. +// +// Solidity: function INotTrustID(int64 from, int64 to) returns() +func (_Passport *PassportTransactorSession) INotTrustID(from int64, to int64) (*types.Transaction, error) { + return _Passport.Contract.INotTrustID(&_Passport.TransactOpts, from, to) +} + // ITrustAddress is a paid mutator transaction binding the contract method 0xe5122bab. // // Solidity: function ITrustAddress(address friend_address) returns() @@ -798,6 +850,27 @@ func (_Passport *PassportTransactorSession) ITrustAddress(friend_address common. return _Passport.Contract.ITrustAddress(&_Passport.TransactOpts, friend_address) } +// ITrustID is a paid mutator transaction binding the contract method 0xdca28884. +// +// Solidity: function ITrustID(int64 from, int64 to) returns() +func (_Passport *PassportTransactor) ITrustID(opts *bind.TransactOpts, from int64, to int64) (*types.Transaction, error) { + return _Passport.contract.Transact(opts, "ITrustID", from, to) +} + +// ITrustID is a paid mutator transaction binding the contract method 0xdca28884. +// +// Solidity: function ITrustID(int64 from, int64 to) returns() +func (_Passport *PassportSession) ITrustID(from int64, to int64) (*types.Transaction, error) { + return _Passport.Contract.ITrustID(&_Passport.TransactOpts, from, to) +} + +// ITrustID is a paid mutator transaction binding the contract method 0xdca28884. +// +// Solidity: function ITrustID(int64 from, int64 to) returns() +func (_Passport *PassportTransactorSession) ITrustID(from int64, to int64) (*types.Transaction, error) { + return _Passport.Contract.ITrustID(&_Passport.TransactOpts, from, to) +} + // ITrustUsername is a paid mutator transaction binding the contract method 0x68789cea. // // Solidity: function ITrustUsername(string my_username, string friend_name) returns() From b2441d9e7230b67362c5dba5437364a88216d9cc Mon Sep 17 00:00:00 2001 From: Bekket Date: Tue, 18 Oct 2022 11:18:48 +0400 Subject: [PATCH 4/4] trust link appendix --- main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main.go b/main.go index ba7f1f4..65c66d3 100644 --- a/main.go +++ b/main.go @@ -379,4 +379,19 @@ func WhoIsAddress(session *passport.PassportSession,address_to_check common.Addr nickname := passport.UserName return nickname,nil +} + +// generate link to trust page +func TrustUserLink(tgid_string string, friend_tg_id string, friend_username string) (string) { + //http://localhost:3000/trust?user_tg_id=1337&friend_tg_id=1997&friend_user_name=sbekket + loadEnv() + baseURL_ := myenv["BASEURL"] + trustURL := "/trust" + tg_id_query_trust := "?user_tg_id=" +// tg_username_query_trust := "&user_tg_name=" + to_id_query:= "&friend_tg_id=" + to_username_query := "&friend_user_name=" + link := baseURL_ + trustURL + tg_id_query_trust + tgid_string + to_id_query + friend_tg_id + to_username_query + "@" + friend_username + return link + } \ No newline at end of file