Commit 9d683ce9 authored by rlgy's avatar rlgy

国盾锁仓-TOKEN资产查询

parent e20581b5
......@@ -28,13 +28,10 @@ class Chain33Business
$result = $service->getAccountTokenAssets($address, $token);
if ($result['code'] == 0) {
$result = $result['result'];
if (isset($result['tokenAssets'])) {
$tokenAssets = $result['tokenAssets'];
$tokenAssets = array_column($tokenAssets, null, 'symbol');
if (isset($tokenAssets[$token])) {
return ['code' => 0, 'amount' => $tokenAssets[$token]['account']['balance']];
}
return ['code' => -1, 'msg' => "$token 不存在"];
$result = array_column($result, null, 'addr');
if (isset($result[$address])) {
$tokenAssets = $result[$address]['balance'];
return ['code' => 0, 'amount' => $tokenAssets];
}
return ['code' => -1, 'msg' => '资产信息不存在'];
}
......
......@@ -65,21 +65,21 @@ class Chain33Service
/**
* 获取地址下的所有token资产
*
* @param string $address
* @param string $symbol
* @param string|array $address
* @param string $symbol
* @return array
*/
public function getAccountTokenAssets($address, $symbol)
{
if (!is_array($address)) {
$address = [$address];
}
$params = [
"execer" => "token",
"funcName" => "GetAccountTokenAssets",
"payload" => [
"address" => $address,
"execer" => "user.p.guodun.token",
],
"addresses" => $address,
"execer" => "user.p.guodun.token",
"tokenSymbol" => $symbol
];
return $this->send($params);
return $this->send($params, 'Chain33.GetTokenBalance');
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment