So I have this weird thing going on. I have a simple Sophia function with following implementation:
stateful entrypoint add_wallet(wallet: address) =
only_owner()
put(state{ activeWallets[wallet] = true })
Chain.event(WalletAdded(wallet))
I called this function on testnet: th_Qthc5exifqSCHMJrgvsFPPEAvuqzfLkdiU5ogZx6oHWpqmLUT
When I decode call data I get following output:
call data decoded {
arguments: [
{
type: 'address',
value: 'ak_168AFjUnvqaSc3Ghwrair3DNhy85ohBAersvFGsvkd2UafVo1'
}
],
function: 'add_wallet'
}
And this is fine, address ak_168AFjUnvqaSc3Ghwrair3DNhy85ohBAersvFGsvkd2UafVo1
is indeed the address I provided when calling add_wallet()
function. Now here’s the thing. Add wallet function emits an event, it’s simply the same address parameter provided while calling the function.
But when I fetch tx info for this transaction I get this log data:
info.log [
{
address: 'ct_uqcLxANrQPjhMP7ejQusQkMx4MNkGpsV95u4X9EyBJCCHmwLU',
data: 'cb_Xfbg4g==',
topics: [
'10290170136087658066813070938628590437785932593845968247138772986276878049142',
'90723028085888713405399571369897167020939216238564042413234018321205193469'
]
}
]
Now I try to decode this log data using by calling Crypto.addressFromDecimal(topics[1])
(docs) and as a result I get:
ak_68AFjUnvqaSc3Ghwrair3DNhy85ohBAersvFGsvkd2VN29fH
It is different address than the one provided while calling add_wallet()
function, but I also noticed some parts of these addresses overlap and are quite similar. I’m not sure why the decoded address is different and I’d like to know this because I rely heavily on decoding event logs on the platform that we’re building, and so far it was working as expected. This is the first example where I noticed this issue.
One additional thing I noticed, this address that I get when I decode event is not a valid Aeternity address at all! I checked this using Crypto.isAddressValid(). I’d appreciate any help here really, or maybe I’m doing something wrong… Thanks