Update Tron.php and TransactoinBuilder.php #103
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
$receiver_address was added to the parameters of freezeBalance and unfreezeBalance. The Tron developers documentation has a section where it explains how to freeze and unfreeze TRX.
The section of FreezeBalance describes that you can freeze an amount of TRX. Will give bandwidth OR Energy and TRON Power (voting rights) to the owner of the frozen tokens. Optionally, can freeze TRX to grant Energy or Bandwidth to other users. Balance amount in the denomination of Sun. The parameter for receiver_address is the address that will receive the resource.
The section of UnfreezeBalance describes TRX that has passed the minimum freeze duration. Unfreezing will remove bandwidth and TRON Power. Returns unfrozen TRX transaction. The parameter for receiver_address is the address that will lose the resource.
Tron.php:
/**
* Freezes an amount of TRX.
* Will give bandwidth OR Energy and TRON Power(voting rights) to the owner of the frozen tokens.
*
* @param float $amount
* @param int $duration
* @param string $resource
* @param string $owner_address
* @param string $receiver_address
* @return array
* @throws TronException
*/
public function freezeBalance(float $amount = 0, int $duration = 3, string $resource = 'BANDWIDTH', string $owner_address = null, string $receiver_address = null)
{
if($owner_address == null) {
$owner_address = $this->address['hex'];
}
TransactionBuilder.php:
/**
* Freezes an amount of TRX.
* Will give bandwidth OR Energy and TRON Power(voting rights) to the owner of the frozen tokens.
*
* @param float $amount
* @param int $duration
* @param string $resource
* @param string|null $address
* @param string|null $receiver_address
* @return array
* @throws TronException
*/
public function freezeBalance(float $amount = 0, int $duration = 3, string $resource = 'BANDWIDTH', string $address, string $receiver_address)
{
if (!in_array($resource, ['BANDWIDTH', 'ENERGY'])) {
throw new TronException('Invalid resource provided: Expected "BANDWIDTH" or "ENERGY"');
}