Replies: 5 comments
-
The data returned by the contract: 0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 f4 24000000000000000000000000000995737db111fd9ff272160ab7651e85c1ef2506e00000000000000000000000000000000000000000005858f6d09cd3cdcb25f32254fdeb8 073d5e20e2e00000000000000000000000000000000000000000000152d02c7e14af68000000000000000000000000000000000000000000000000000000000000063def5230000000000000000000000000000000000000000000000000000000064044f780000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000 The result is in the code bool res=param.decode (TW:: parse_hex (pEncoded), offset); Returns false. I think there is a problem with the definition of Parameters param. I don't know whether it is right or not. Please help me see how to solve this problem? thank you. |
Beta Was this translation helpful? Give feedback.
-
The result is in the code bool res=param.decode (TW:: parse_hex (pEncoded), offset); Returns false. ----------------- Sorry, there are no errors here. The returned value is true. |
Beta Was this translation helpful? Give feedback.
-
SP_ UINT64 id = (std::dynamic_pointer_castTW::Ethereum::ABI::ParamUInt64((std::dynamic_pointer_castTW::Ethereum::ABI::ParamArray(param.getParam(i)))->getParam(0)))->getVal(); -------------- The error occurred here and an exception occurred. |
Beta Was this translation helpful? Give feedback.
-
If the contract returns two locks, Data: 0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 1e 000000000000000000000000000000000000000000000000000000000000000000000000 f42400000000000000000000000000000000000 995737db111fd9ff272160ab7651e85c1ef2506e0000 000000000000000000005858f6d09cd3cdcb25f32254fdeb8073d5e20e2e00000000000000000000000000000000000000000000152d02c7e14af68000000000000000000000000000000000000000000000000000000000000063def5230000000000000000000000000000000000000000000000000000000064044f78000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000548656c6c6f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f4241000000000000000000000000995737db11 1fd9ff272160ab7651e85c1ef2506e0000000000000000000000005858f6d09cd3cdcb25f32254fdeb8073d5e20e2e00000000000000000000000000000000000000000000152d02c7e14af68000000000000000000000000000000000000000000000000000000000000063df0fe00000000000000000000000000000000000000000000000000000000064046a4100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000 |
Beta Was this translation helpful? Give feedback.
-
HI,
I was developing a DAPP based on wallet-core and encountered a problem. I didn't know how to decode the response message data of the received smart contract. The interface return value lock [] of smart contract is an array of structures, defined as follows:
struct Lock {
uint256 id;
address token;
address owner;
uint256 amount;
uint256 lockDate;
uint256 tgeDate; // TGE date for vesting locks, unlock date for normal locks
uint256 tgeBps; // In bips. Is 0 for normal locks
uint256 cycle; // Is 0 for normal locks
uint256 cycleBps; // In bips. Is 0 for normal locks
uint256 unlockedAmount;
string description;
}
function normalLocksForUser(address user)
external
view
returns (Lock[] memory)
{
uint256 length = _ userNormalLockIds[user].length();
Lock[] memory userLocks = new Lock;
for (uint256 i = 0; i < length; i++) {
userLocks[i] = getLockById(_userNormalLockIds[user].at(i));
}
return userLocks;
}
My code is as follows:
SP_ UINT32 TOKEN_ DecodeNormalLocksForUser(SP_CHAR *pEncoded)
{
auto param = TW::Ethereum::ABI::Parameters(std::vector<std::shared_ptrTW::Ethereum::ABI::ParamBase>{
std::make_ sharedTW::Ethereum::ABI::ParamArray(std::vector<std::shared_ptrTW::Ethereum::ABI::ParamBase>{
std::make_ sharedTW::Ethereum::ABI::ParamTuple(std::vector<std::shared_ptrTW::Ethereum::ABI::ParamBase>{
std::make_ sharedTW::Ethereum::ABI::ParamUInt256(), /id/
std::make_ sharedTW::Ethereum::ABI::ParamAddress(), /token/
std::make_ sharedTW::Ethereum::ABI::ParamAddress(), /owner/
std::make_ sharedTW::Ethereum::ABI::ParamUInt256(), /amount/
std::make_ sharedTW::Ethereum::ABI::ParamUInt256(), /lockDate/
std::make_ sharedTW::Ethereum::ABI::ParamUInt256(), /tgeDate/
std::make_ sharedTW::Ethereum::ABI::ParamUInt256(), /tgeBps/
std::make_ sharedTW::Ethereum::ABI::ParamUInt256(), /cycle/
std::make_ sharedTW::Ethereum::ABI::ParamUInt256(), /cycleBps/
std::make_ sharedTW::Ethereum::ABI::ParamUInt256(), /unlockedAmount/
std::make_ sharedTW::Ethereum::ABI::ParamString(), /description/
})
})
});
//((uint256,address,address,uint256,uint256,uint256,uint256,uint256,uint256,uint256,string)[])
std::string type = param.getType();
size_ t offset = 0;
bool res = param.decode(TW::parse_hex(pEncoded), offset);
if (true != res)
{
return SP_ FALSE;
}
SP_ UINT32 i;
SP_ UINT32 udwCount = param.getCount();
for (i = 0; i < udwCount; i++)
{
/*
struct Lock {
uint256 id;
address token;
address owner;
uint256 amount;
uint256 lockDate;
uint256 tgeDate; // TGE date for vesting locks, unlock date for normal locks
uint256 tgeBps; // In bips. Is 0 for normal locks
uint256 cycle; // Is 0 for normal locks
uint256 cycleBps; // In bips. Is 0 for normal locks
uint256 unlockedAmount;
string description;
}
*/
SP_ UINT64 id = (std::dynamic_pointer_castTW::Ethereum::ABI::ParamUInt64((std::dynamic_pointer_castTW::Ethereum::ABI::ParamArray(param.getParam(i)))->getParam(0)))->getVal();
std::string token = TW::hex((std::dynamic_pointer_castTW::Ethereum::ABI::ParamAddress((std::dynamic_pointer_castTW::Ethereum::ABI::ParamArray(param.getParam(i)))->getParam(1)))->getData());
}
return SP_ TRUE;
}
The data returned by the contract:
Beta Was this translation helpful? Give feedback.
All reactions