Skip to content

Commit

Permalink
Merge pull request #9 from olifanton/develop
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
romanzaycev committed Dec 14, 2023
2 parents 19626ea + bfa609e commit abca1a4
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 32 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- develop
paths-ignore:
- '.gitattributes'
- '.gitignore'
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"require": {
"php": ">=8.1",
"ext-json": "*",
"olifanton/interop": "^1.0",
"olifanton/interop": "^1.1",
"olifanton/mnemonic": "^1.0",
"php-http/client-common": "^2.0",
"php-http/discovery": "^1.0",
Expand Down
2 changes: 2 additions & 0 deletions examples/wallets/send-transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
new Transfer(
dest: new Address("EQCrrSblmeNMAw27AXbchzG6MUja9iac7PHjyK3Xn8EMeqbG"),
amount: Units::toNano("0.012"),
payload: "Very long message string. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur aut consectetur et explicabo fuga in incidunt laboriosam minima nemo nulla obcaecati placeat praesentium quam quisquam sint, sunt voluptatibus? Ad, vel?",
sendMode: \Olifanton\Ton\SendMode::PAY_GAS_SEPARATELY,
),
],
new TransferOptions(
Expand Down
16 changes: 7 additions & 9 deletions src/Olifanton/Ton/Contracts/Jetton/JettonMinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Olifanton\Ton\Helpers\AddressHelper;
use Olifanton\Ton\Helpers\OffchainHelper;
use Olifanton\Ton\Transport;
use function Olifanton\Ton\Marshalling\Tvm\slice;

class JettonMinter extends AbstractContract
{
Expand Down Expand Up @@ -170,15 +171,12 @@ public function getJettonWalletAddress(Transport $transport, Address $ownerAddre
$this,
"get_wallet_address",
[
[
"tvm.Slice",
Bytes::bytesToBase64(
(new Builder())
->writeAddress($ownerAddress)
->cell()
->toBoc(false),
),
]
slice(
(new Builder())
->writeAddress($ownerAddress)
->cell()
->beginParse()
),
]
);
$cell = $stack->currentCell();
Expand Down
3 changes: 2 additions & 1 deletion src/Olifanton/Ton/Contracts/Nft/NftCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Olifanton\Ton\Helpers\AddressHelper;
use Olifanton\Ton\Helpers\OffchainHelper;
use Olifanton\Ton\Transport;
use function Olifanton\Ton\Marshalling\Tvm\num;

class NftCollection extends AbstractContract
{
Expand Down Expand Up @@ -246,7 +247,7 @@ public function getNftItemAddress(Transport $transport, int $itemIndex): Address
$this,
"get_nft_address_by_index",
[
["num", "0x" . dechex($itemIndex)]
num($itemIndex),
]
);

Expand Down
11 changes: 5 additions & 6 deletions src/Olifanton/Ton/Contracts/Wallets/AbstractWallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Olifanton\Interop\Boc\Builder;
use Olifanton\Interop\Boc\Cell;
use Olifanton\Interop\Boc\Exceptions\BitStringException;
use Olifanton\Interop\Boc\SnakeString;
use Olifanton\Ton\Contracts\AbstractContract;
use Olifanton\Ton\Contracts\Exceptions\ContractException;
use Olifanton\Ton\Contracts\Messages\Exceptions\MessageException;
Expand Down Expand Up @@ -187,14 +188,12 @@ protected function createData(): Cell
*/
protected function createTxtPayload(string $textMessage): Cell
{
$payload = new Builder();
$len = strlen($textMessage);

if (strlen($textMessage) > 0) {
$payload
->writeUint(0, 32)
->writeString($textMessage);
if (!$len) {
return new Cell();
}

return $payload->cell();
return SnakeString::fromString($textMessage)->cell(true);
}
}
12 changes: 4 additions & 8 deletions src/Olifanton/Ton/Contracts/Wallets/V4/WalletV4R2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Olifanton\Ton\Contracts\Wallets\V4;

use Brick\Math\BigInteger;
use Olifanton\Interop\Address;
use Olifanton\Interop\Boc\Cell;
use Olifanton\Interop\Boc\Exceptions\BitStringException;
Expand All @@ -13,6 +14,7 @@
use Olifanton\Ton\Contracts\Messages\MessageData;
use Olifanton\Ton\Contracts\Wallets\Exceptions\WalletException;
use Olifanton\Ton\Transport;
use function Olifanton\Ton\Marshalling\Tvm\num;

class WalletV4R2 extends WalletV4
{
Expand Down Expand Up @@ -87,14 +89,8 @@ public function isPluginInstalled(Transport $transport, Address $pluginAddress):
$this,
"is_plugin_installed",
[
[
"num",
$pluginAddress->getWorkchain(),
],
[
"num",
"0x" . Bytes::bytesToHexString($pluginAddress->getHashPart()),
]
num($pluginAddress->getWorkchain()),
num(BigInteger::fromBase(Bytes::bytesToHexString($pluginAddress->getHashPart()), 16)),
]
);

Expand Down
6 changes: 2 additions & 4 deletions src/Olifanton/Ton/Dns/DnsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Psr\Log\LoggerAwareTrait;
use Psr\SimpleCache\CacheException;
use Psr\SimpleCache\CacheInterface;
use function Olifanton\Ton\Marshalling\Tvm\num;

class DnsClient implements LoggerAwareInterface
{
Expand Down Expand Up @@ -105,10 +106,7 @@ protected final function resolveInner(Uint8Array $rawDomain,
"tvm.Slice",
$domainCellBoc,
],
[
"num",
"0x0",
]
num(0),
]
);
$this->cacheSmcGetterResponse($domainCellBoc, $responseStack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ public static function serialize(array $stack): array
foreach ($stack as $idx => $entry) {
if ($entry instanceof TvmStackEntry) {
if ($entry instanceof Cell) {
$entry[] = self::serializeCell($entry);
$result[] = self::serializeCell($entry);
continue;
}

if ($entry instanceof Slice) {
$entry[] = self::serializeSlice($entry);
$result[] = self::serializeSlice($entry);
continue;
}

if ($entry instanceof Number) {
$entry[] = self::serializeNumber($entry);
$result[] = self::serializeNumber($entry);
continue;
}

throw new \RuntimeException("Not implemented serializer for " . $entry::class);
Expand Down

0 comments on commit abca1a4

Please sign in to comment.