Closed alexbarnsley closed 5 years ago
boiled it down to senderId, as running the above queries without it doesn't seem to respond with the template model
this.database.manager.findByAddress()
might be caching upon conversion from senderId
to senderPublicKey
public findByAddress(address) {
if (!this.byAddress[address]) {
this.byAddress[address] = new Wallet(address);
}
return this.byAddress[address];
}
Then on subsequent round would not create a new wallet, but return the newly created wallet?
Btw, this is definitely cached behaviour as I tried with the address you provided and is was not found
after running the second command but only with senderId, the third command indeed returns a
{
"account": {
"address": "DLWeBuwSBFYtUFj8kFB8CFswfvN2ht3yKn",
"publicKey": null,
"secondPublicKey": null,
"username": null,
"balance": "0",
"unconfirmedBalance": "0",
"multisignatures": [],
"u_multisignatures": [],
"unconfirmedSignature": 0,
"secondSignature": 0
},
"success": true
}
So, from what I can tell: querying legacy with senderId triggers the creation of a Wallet object in this.byAddress of core-database/wallet-manager set to a default. Then, a query to accounts?address=COLD will database.wallets.findById() it and return the empty object, but not before transforming it to fit the v1 spec.
I could be miles off in any of these statements, this is some preliminary detective work for the team.
Get transactions: https://github.com/ArkEcosystem/core/blob/develop/packages/core-api/src/versions/1/transactions/methods.ts#L5
FindAllLegacy: https://github.com/ArkEcosystem/core/blob/develop/packages/core-api/src/repositories/transactions.ts#L70
PublicKeyFromAddress: https://github.com/ArkEcosystem/core/blob/develop/packages/core-api/src/repositories/transactions.ts#L486
FindByAddress (caches new crypto model): https://github.com/ArkEcosystem/core/blob/develop/packages/core-database/src/wallet-manager.ts#L70
Crypto Model: https://github.com/ArkEcosystem/core/blob/develop/packages/crypto/src/models/wallet.ts#L48
FindById on v1: https://github.com/ArkEcosystem/core/blob/develop/packages/core-api/src/versions/1/accounts/methods.ts#L19
Transformer: https://github.com/ArkEcosystem/core/blob/develop/packages/core-api/src/versions/1/accounts/transformer.ts
I will not be fixing this today.
Describe the bug When querying the v1
/api/transactions
endpoint, it creates an empty wallet. I have not tested on v2 endpointsTo Reproduce Steps to reproduce the behavior:
https://dexplorer.ark.io:8443/api/accounts?address=<COLD_WALLET_ADDRESS>
- it will return "Account not found"https://dexplorer.ark.io:8443/api/transactions?recipientId=<COLD_WALLET_ADDRESS>&senderId=<COLD_WALLET_ADDRESS>&orderBy=timestamp:desc&offset=0&limit=50
https://dexplorer.ark.io:8443/api/accounts?address=<COLD_WALLET_ADDRESS>
- it will return a cold wallet object response (see below)Expected behavior The wallet should return "Account not found" still