Skip to content

Commit a4534a2

Browse files
committed
Fix Version handling after debug
1 parent baa53f4 commit a4534a2

File tree

2 files changed

+50
-53
lines changed

2 files changed

+50
-53
lines changed

api.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ function sendRawTransaction($rawtx,$gethRPC){
425425
$amount = hexdec(substr($tr_info,-64));
426426

427427
// get the infos
428-
$status = getAccountStatus(array($from_add, $to_add), $contract)
428+
$status = getAccountStatus(array($from_add, $to_add), $contract);
429429
$from_status = $status[$from_add];
430430
$to_status = $status[$to_add];
431431

@@ -493,7 +493,7 @@ function sendRawTransaction($rawtx,$gethRPC){
493493
if (in_my_array($funct_address, $transfert_functs)) {
494494

495495

496-
$status = getAccountStatus(array($sender, $dest), $contract)
496+
$status = getAccountStatus(array($sender, $dest), $contract);
497497
$from_status = $status[$sender];
498498
$to_status = $status[$dest];
499499

@@ -593,14 +593,14 @@ function sendRawTransaction($rawtx,$gethRPC){
593593
// We have a pledge:
594594
$trans_type = 'Pledge';
595595
$from_add = 'Admin';
596-
$to_add = $dest;
596+
$to_add = $dest;
597597

598-
$acctype = getAccType($sender, $contract);
599-
$status = getAccountStatus(array($sender), $contract)[$sender];
600-
601-
$need_pending = $acctype==2 && $status==1;
598+
$acctype = getAccType($sender, $contract);
599+
$status = getAccountStatus(array($sender), $contract);
600+
$curr_stat= $status[$sender];
601+
602+
$need_pending = $acctype==2 && $curr_stat==1;
602603
}
603-
604604
}
605605

606606

checkAdmin.php

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -107,36 +107,31 @@ function isActive($address, $contract){
107107

108108
return substr($data,-1);
109109
}
110-
111-
110+
112111
function getVersion( $contract){
113-
$url = getServerAddress()."/api.php";
114-
$ch = curl_init();
115-
$ethCall = ['to' =>$contract,
116-
'data' => '0x54fd4d50'
117-
];
118-
$fields = ['ethCall'=>$ethCall];
119-
$fields_string = http_build_query($fields);
120-
121-
curl_setopt($ch, CURLOPT_URL, $url);
122-
// Set so curl_exec returns the result instead of outputting it.
123-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
124-
curl_setopt($ch, CURLOPT_POST, count($fields));
125-
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
126-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
127-
128-
// Get the response and close the channel.
129-
$response = curl_exec($ch);
130-
curl_close($ch);
131-
132-
$json = json_decode($response);
133-
$data= $json->{'data'};
134-
135-
return pack("H*", $data);
136-
}
137-
138-
139-
112+
$url = getServerAddress()."/api.php";
113+
$ch = curl_init();
114+
$ethCall = ['to' =>$contract,
115+
'data' => '0x54fd4d50'
116+
];
117+
$fields = ['ethCall'=>$ethCall];
118+
$fields_string = http_build_query($fields);
119+
120+
curl_setopt($ch, CURLOPT_URL, $url);
121+
// Set so curl_exec returns the result instead of outputting it.
122+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
123+
curl_setopt($ch, CURLOPT_POST, count($fields));
124+
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
125+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
126+
127+
// Get the response and close the channel.
128+
$response = curl_exec($ch);
129+
curl_close($ch);
130+
131+
$json = json_decode($response);
132+
$data= $json->{'data'};
133+
134+
return $data;
140135

141136
function getNumber($address, $contract, $function){
142137
$url = getServerAddress()."/api.php";
@@ -225,23 +220,25 @@ function checkSign($dat, $signature, $caller){
225220
return $caller==personal_ecRecover($dat, $signature);
226221
}
227222

228-
229223
function getAccountStatus($addresses, $contract) {
230-
$version = getVersion($contract);
231-
$result= array($add_1=0,$add_2=0);
232-
if (strlen($version)>0) {
233-
// New Contract use isActive
234-
foreach ( $addresses as $add) {
235-
$result[$add] = isActive($add, $contract);
236-
}
237-
} else {
238-
// Old contract fallback on getAccStatus
239-
foreach ( $addresses as $add) {
240-
$result[$add] = getAccStatus($add, $contract);
241-
}
242-
}
243-
244-
return $result;
224+
$version = getVersion($contract);
225+
$result= array();
226+
foreach ( $addresses as $add) {
227+
$result[$add] = 0;
228+
}
229+
if (strlen(strval($version))>2) {
230+
// New Contract use isActive
231+
foreach ( $addresses as $add) {
232+
$result[$add] = isActive($add, $contract);
233+
}
234+
} else {
235+
// Old contract fallback on getAccStatus
236+
foreach ( $addresses as $add) {
237+
$result[$add] = getAccStatus($add, $contract);
238+
}
239+
}
240+
241+
return $result;
245242
}
246243

247244

0 commit comments

Comments
 (0)