chore: logs

This commit is contained in:
Igor Sirotin 2024-07-17 09:37:18 +01:00
parent 44808424a4
commit e4f6830311
4 changed files with 30 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import std/strutils, uuids
import std/strutils, uuids, chronicles
import ./io_interface
import app/core/signals/types
@ -195,6 +195,7 @@ proc init*(self: Controller) =
self.events.on(SIGNAL_SHARED_KEYCARD_MODULE_USER_AUTHENTICATED) do(e: Args):
let args = SharedKeycarModuleArgs(e)
debug "<<< on SIGNAL_SHARED_KEYCARD_MODULE_USER_AUTHENTICATED", uniqueIdentifier = args.uniqueIdentifier
if args.uniqueIdentifier != UNIQUE_COMMUNITIES_MODULE_AUTH_IDENTIFIER:
return
self.delegate.onUserAuthenticated(args.pin, args.password, args.keyUid)
@ -209,6 +210,7 @@ proc init*(self: Controller) =
self.events.on(SIGNAL_SHARED_KEYCARD_MODULE_DATA_SIGNED) do(e: Args):
let args = SharedKeycarModuleArgs(e)
debug "<<< on SIGNAL_SHARED_KEYCARD_MODULE_DATA_SIGNED", uniqueIdentifier = args.uniqueIdentifier
if args.uniqueIdentifier != UNIQUE_COMMUNITIES_MODULE_SIGNING_IDENTIFIER:
return
self.delegate.onDataSigned(args.keyUid, args.path, args.r, args.s, args.v, args.pin)
@ -398,6 +400,7 @@ proc asyncEditSharedAddresses*(self: Controller, communityId: string, addressesT
self.communityService.asyncEditSharedAddresses(communityId, addressesToShare, airdropAddress, signatures)
proc authenticate*(self: Controller) =
debug "<<< authenticate"
let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_COMMUNITIES_MODULE_AUTH_IDENTIFIER)
self.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER, data)
@ -422,6 +425,7 @@ proc generateEditCommunityRequestsForSigning*(self: Controller, memberPubKey: st
return self.communityService.generateEditCommunityRequestsForSigning(memberPubKey, communityId, addressesToReveal)
proc signCommunityRequests*(self: Controller, communityId: string, signParams: seq[SignParamsDto]): seq[string] =
debug "<<< signCommunityRequests", communityId, signParams
return self.communityService.signCommunityRequests(communityId, signParams)
proc getKeypairByAccountAddress*(self: Controller, address: string): KeypairDto =
@ -461,11 +465,13 @@ proc cancelCurrentFlow*(self: Controller) =
self.keycardService.cancelCurrentFlow()
proc runSignFlow(self: Controller, pin, path, dataToSign: string) =
debug "<<< runSignFlow", pin, path, dataToSign
self.cancelCurrentFlow()
self.connectKeycardReponseSignal()
self.keycardService.startSignFlow(path, dataToSign, pin)
proc runSigningOnKeycard*(self: Controller, keyUid: string, path: string, dataToSign: string, pin: string) =
debug "<<< runSigningOnKeycard", keyUid, path, dataToSign, pin
var finalDataToSign = dataToSign
if finalDataToSign.startsWith("0x"):
finalDataToSign = finalDataToSign[2..^1]

View File

@ -665,6 +665,7 @@ method shareCommunityChannelUrlWithData*(self: Module, communityId: string, chat
return self.controller.shareCommunityChannelUrlWithData(communityId, chatId)
proc signRevealedAddressesForNonKeycardKeypairs(self: Module): bool =
debug "<<< signRevealedAddressesForNonKeycardKeypairs"
var signingParams: seq[SignParamsDto]
for address, details in self.joiningCommunityDetails.addressesToShare.pairs:
if details.signature.len > 0:
@ -710,6 +711,8 @@ proc anyProfileKeyPairAddressSelectedToBeRevealed(self: Module): bool =
return false
method onUserAuthenticated*(self: Module, pin: string, password: string, keyUid: string) =
debug "<<< onUserAuthenticated", pin, password, keyUid
if password == "" and pin == "":
info "unsuccesful authentication"
return
@ -728,6 +731,7 @@ method onUserAuthenticated*(self: Module, pin: string, password: string, keyUid:
self.signRevealedAddressesForNonKeycardKeypairsAndEmitSignal()
method onDataSigned*(self: Module, keyUid: string, path: string, r: string, s: string, v: string, pin: string) =
debug "<<< onDataSigned", keyUid, path, r, s, v, pin
if keyUid.len == 0 or path.len == 0 or r.len == 0 or s.len == 0 or v.len == 0 or pin.len == 0:
# being here is not an error
return
@ -746,6 +750,7 @@ method onDataSigned*(self: Module, keyUid: string, path: string, r: string, s: s
method prepareKeypairsForSigning*(self: Module, communityId, ensName: string, addresses: string,
airdropAddress: string, editMode: bool) =
debug "<<< prepareKeypairsForSigning", communityId, ensName, addresses, airdropAddress, editMode
var addressesToShare: seq[string]
try:
addressesToShare = map(parseJson(addresses).getElems(), proc(x:JsonNode):string = x.getStr())
@ -800,6 +805,7 @@ method signProfileKeypairAndAllNonKeycardKeypairs*(self: Module) =
# if pin is provided we're signing on a keycard silently
method signSharedAddressesForKeypair*(self: Module, keyUid: string, pin: string) =
debug "<<< signSharedAddressesForKeypair", keyUid, pin
let keypair = self.controller.getKeypairByKeyUid(keyUid)
if keypair.isNil:
self.communityAccessFailed(self.joiningCommunityDetails.communityId, "cannot resolve keypair for keyUid " & keyUid)
@ -843,6 +849,7 @@ method joinCommunityOrEditSharedAddresses*(self: Module) =
# The user reveals address after sending join coummunity request, before that he sees only the name of the wallet account, not the address.
self.events.emit(MARK_WALLET_ADDRESSES_AS_SHOWN, WalletAddressesArgs(addresses: addressesToShare))
return
if self.joiningCommunityDetails.action == Action.EditSharedAddresses:
self.controller.asyncEditSharedAddresses(self.joiningCommunityDetails.communityId,
addressesToShare,
@ -851,7 +858,8 @@ method joinCommunityOrEditSharedAddresses*(self: Module) =
# The user reveals address after sending edit coummunity request, before that he sees only the name of the wallet account, not the address.
self.events.emit(MARK_WALLET_ADDRESSES_AS_SHOWN, WalletAddressesArgs(addresses: addressesToShare))
return
self.communityAccessFailed(self.joiningCommunityDetails.communityId, "unexpected action")
self.communityAccessFailed(self.joiningCommunityDetails.communityId, "unexpected action: " & $self.joiningCommunityDetails.action)
method getCommunityPublicKeyFromPrivateKey*(self: Module, communityPrivateKey: string): string =
result = self.controller.getCommunityPublicKeyFromPrivateKey(communityPrivateKey)

View File

@ -755,36 +755,43 @@ QtObject {
}
onPrepareForSigning: {
console.log("<<< onPrepareForSigning")
root.rootStore.prepareKeypairsForSigning(dialogRoot.communityId, dialogRoot.name, sharedAddresses, airdropAddress, false)
dialogRoot.keypairSigningModel = root.rootStore.communitiesModuleInst.keypairsSigningModel
}
onSignProfileKeypairAndAllNonKeycardKeypairs: {
console.log("<<< onSignProfileKeypairAndAllNonNonKeycardKeypairs")
root.rootStore.signProfileKeypairAndAllNonKeycardKeypairs()
}
onSignSharedAddressesForKeypair: {
console.log("<<< onSignSharedAddressesForKeypair")
root.rootStore.signSharedAddressesForKeypair(keyUid)
}
onJoinCommunity: {
console.log("<<< onJoinCommunity")
root.rootStore.joinCommunityOrEditSharedAddresses()
}
onCancelMembershipRequest: {
console.log("<<< onCancelMembershipRequest")
root.rootStore.cancelPendingRequest(dialogRoot.communityId)
}
Connections {
target: root.communitiesStore.communitiesModuleInst
function onCommunityAccessRequested(communityId: string) {
console.log("<<< onCommunityAccessRequested:", communityId, dialogRoot.communityId)
if (communityId !== dialogRoot.communityId)
return
root.communitiesStore.spectateCommunity(communityId);
dialogRoot.close();
}
function onCommunityAccessFailed(communityId: string, error: string) {
console.log("<<< onCommunityAccessFailed:", communityId, error)
if (communityId !== dialogRoot.communityId)
return
dialogRoot.close();
@ -792,6 +799,7 @@ QtObject {
}
onSharedAddressesUpdated: {
console.log("<<< onSharedAddressesUpdated")
root.rootStore.updatePermissionsModel(dialogRoot.communityId, sharedAddresses)
}
@ -806,6 +814,8 @@ QtObject {
target: root.rootStore.communitiesModuleInst
function onAllSharedAddressesSigned() {
console.log("<<< onAllSharedAddressesSigned")
if (dialogRoot.profileProvesOwnershipOfSelectedAddresses) {
dialogRoot.joinCommunity()
dialogRoot.close()

View File

@ -208,6 +208,7 @@ StatusStackModal {
}
function proceedToSigningOrSubmitRequest(uidOfComponentThisFunctionIsCalledFrom) {
console.log("<<< proceedToSigningOrSubmitRequest")
const selected = d.getSelectedAddresses()
root.prepareForSigning(selected.airdropAddress, selected.addresses)
if (root.profileProvesOwnershipOfSelectedAddresses) {
@ -419,14 +420,17 @@ StatusStackModal {
keypairSigningModel: root.keypairSigningModel
onSignProfileKeypairAndAllNonKeycardKeypairs: {
console.log("<<< SharedAddressesSigningPanel.onSignProfileKeypairAndAllNonKeycardKeypairs")
root.signProfileKeypairAndAllNonKeycardKeypairs()
}
onSignSharedAddressesForKeypair: {
console.log("<<< SharedAddressesSigningPanel.onSignSharedAddressesForKeypair")
root.signSharedAddressesForKeypair(keyUid)
}
onJoinCommunity: {
console.log("<<< SharedAddressesSigningPanel.onJoinCommunity")
if (root.isEditMode) {
root.editRevealedAddresses()
} else {