Skip to content

Commit

Permalink
Add new ops from 11 update
Browse files Browse the repository at this point in the history
  • Loading branch information
On1x committed Aug 2, 2023
1 parent 7042685 commit d982075
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Native PHP class for VIZ Keys, Transaction, JsonRPC
## Features
- JsonRPC — native socket usage (all API methods, hostname cache, ssl flag, full result flag)
- Keys — private (sign), public (verify), shared, encoded keys support (wif, public encoded, compressed/uncompressed public key in hex representation)
- Transaction — easy workflow, multi-signature support, multi-operations support, execute by JsonRPC, support 5 most usable operations: transfer, transfer_to_vesting, withdraw_vesting, award, create_invite (other operations will be implemented later)
- Transaction — easy workflow, multi-signature support, multi-operations support, execute by JsonRPC, support all 38 operations: transfer, transfer_to_vesting, withdraw_vesting, award, create_invite, etc...
- Classes support PSR-4
- Contains modificated classes for best fit to VIZ Blockchain (all-in-one)
- Native code without additional installations (sry composer, but we need other changes in third-party classes)
Expand Down
1 change: 1 addition & 0 deletions class/VIZ/JsonRPC.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function set_header($name,$value){
'get_account_count'=>'database_api',
'get_accounts'=>'database_api',
'get_accounts_on_sale'=>'database_api',
'get_accounts_on_auction'=>'database_api',
'get_escrow'=>'database_api',
'get_expiring_vesting_delegations'=>'database_api',
'get_owner_history'=>'database_api',
Expand Down
42 changes: 42 additions & 0 deletions class/VIZ/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,32 @@ function build_award($initiator,$receiver,$energy,$custom_sequence=0,$memo='',$b
$raw.=$this->encode_array($beneficiaries,[['string','int16']]);
return [$json,$raw];
}
function build_fixed_award($initiator,$receiver,$reward_amount,$max_energy,$custom_sequence=0,$memo='',$beneficiaries=[]){
$json='["fixed_award",{';
$json.='"initiator":"'.$initiator.'"';
$json.=',"receiver":"'.$receiver.'"';
$json.=',"reward_amount":"'.$reward_amount.'"';
$json.=',"max_energy":'.$max_energy;
$json.=',"custom_sequence":'.$custom_sequence;
$json.=',"memo":"'.$memo.'"';
$json.=',"beneficiaries":[';
$beneficiaries_arr=[];
foreach($beneficiaries as $beneficiary_arr){
$beneficiaries_arr[]='{"account":"'.$beneficiary_arr[0].'","weight":'.$beneficiary_arr[1].'}';
}
$json.=implode(',',$beneficiaries_arr);
$json.=']';
$json.='}]';
$raw='3c';//operation number is 60
$raw.=$this->encode_string($initiator);
$raw.=$this->encode_string($receiver);
$raw.=$this->encode_asset($reward_amount);
$raw.=$this->encode_int($max_energy,2);
$raw.=$this->encode_int($custom_sequence,8);
$raw.=$this->encode_string($memo);
$raw.=$this->encode_array($beneficiaries,[['string','int16']]);
return [$json,$raw];
}
function build_create_invite($creator,$balance,$invite_key){
$json='["create_invite",{';
$json.='"creator":"'.$creator.'"';
Expand Down Expand Up @@ -1118,6 +1144,22 @@ function build_set_account_price($account,$account_seller,$account_offer_price,$
$raw.=$this->encode_bool($account_on_sale);
return [$json,$raw];
}
function build_target_account_sale($account,$account_seller,$target_buyer,$account_offer_price,$account_on_sale){
$json='["target_account_sale",{';
$json.='"account":"'.$account.'"';
$json.=',"account_seller":"'.$account_seller.'"';
$json.=',"target_buyer":"'.$target_buyer.'"';
$json.=',"account_offer_price":"'.$account_offer_price.'"';
$json.=',"account_on_sale":'.($account_on_sale?'true':'false').'';
$json.='}]';
$raw='3d';//operation number is 61
$raw.=$this->encode_string($account);
$raw.=$this->encode_string($account_seller);
$raw.=$this->encode_string($target_buyer);
$raw.=$this->encode_asset($account_offer_price);
$raw.=$this->encode_bool($account_on_sale);
return [$json,$raw];
}
function build_set_subaccount_price($account,$subaccount_seller,$subaccount_offer_price,$subaccount_on_sale){
$json='["set_subaccount_price",{';
$json.='"account":"'.$account.'"';
Expand Down

0 comments on commit d982075

Please sign in to comment.