Skip to content

Commit

Permalink
Merge pull request #14 from mrkh995/hotfix/NftItem-forwardpayload
Browse files Browse the repository at this point in the history
Modified createTransferBody to add support for text comment as forwardpayload
  • Loading branch information
romanzaycev authored Jun 17, 2024
2 parents b1e0671 + e63d10c commit e39b5ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/Olifanton/Ton/Contracts/Nft/NftItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,18 @@ public static function createTransferBody(NftTransferOptions $options): Cell
->writeAddress($options->newOwnerAddress)
->writeAddress($options->responseAddress)
->writeBit(false)
->writeCoins($options->forwardAmount ?? BigInteger::zero())
->writeBit(false);

if ($options->forwardPayload) {
$bodyBuilder->writeBytes($options->forwardPayload);
}
->writeCoins($options->forwardAmount ?? BigInteger::zero());

if($options->forwardPayload){
if($options->forwardPayload instanceof Cell){
$bodyBuilder->writeMaybeRef($options->forwardPayload);
}else{
$bodyBuilder->writeBit(false)
->writeBytes($options->forwardPayload);
}
}else {
$bodyBuilder->writeBit(false);
}

return $bodyBuilder->cell();
// @codeCoverageIgnoreStart
Expand Down
3 changes: 2 additions & 1 deletion src/Olifanton/Ton/Contracts/Nft/NftTransferOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Brick\Math\BigInteger;
use Olifanton\Interop\Address;
use Olifanton\Interop\Boc\Cell;
use Olifanton\TypedArrays\Uint8Array;

class NftTransferOptions
Expand All @@ -12,7 +13,7 @@ public function __construct(
public readonly Address $newOwnerAddress,
public readonly ?Address $responseAddress = null,
public readonly ?BigInteger $forwardAmount = null,
public readonly ?Uint8Array $forwardPayload = null,
public readonly null|Cell|Uint8Array $forwardPayload = null,
public readonly int $queryId = 0,
) {}
}

0 comments on commit e39b5ed

Please sign in to comment.