diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 84bfd90..a6bc20f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,19 +34,19 @@ jobs: - name: Download PHP Installer run: | - php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.37.2/installer.php', 'installer.php');" + php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.38.0/installer.php', 'installer.php');" php -r "if (hash_file('sha384', 'installer.php') === '03586e200bc1c87f000c5a0eea27aa688eb451a5b946579205ca918bbffda7234359e2d0e176aa53e841c6a77b8de959') { echo 'Installer verified'; } else { echo 'Installer corrupt'; } echo PHP_EOL;" - name: Install PHP Extension (Windows) if: matrix.operating-system == 'windows-2019' - run: php installer.php -v 1.37.2 + run: php installer.php -v 1.38.0 - name: Install PHP Extension (Ubuntu/Mac) if: matrix.operating-system != 'windows-2019' - run: sudo php installer.php -v 1.37.2 + run: sudo php installer.php -v 1.38.0 - name: Test PHP Extension - run: php installer.php -v 1.37.2 -T + run: php installer.php -v 1.38.0 -T - name: Check PHP Extensions run: php -m diff --git a/README.md b/README.md index 8c2d360..644a7ba 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ Use [radianceteam/ton-client-php](https://hub.docker.com/r/radianceteam/ton-clie as a base image in your `Dockerfile`: ```bash -FROM radianceteam/ton-client-php:1.37.2-php7.4-cli +FROM radianceteam/ton-client-php:1.38.0-php7.4-cli COPY . /usr/src/myapp WORKDIR /usr/src/myapp CMD [ "php", "./your-script.php" ] @@ -149,7 +149,7 @@ CMD [ "php", "./your-script.php" ] Basically, do anything you can do with the [original PHP image](https://hub.docker.com/_/php) by just replacing `FROM php:-` with -`FROM radianceteam/ton-client-php:1.37.2-php-`. +`FROM radianceteam/ton-client-php:1.38.0-php-`. Note: only `cli`, `fpm` and `zts` variants are supported ATM. diff --git a/api.json b/api.json index 512b525..3077bd7 100644 --- a/api.json +++ b/api.json @@ -1,5 +1,5 @@ { - "version": "1.37.2", + "version": "1.38.0", "modules": [ { "name": "client", @@ -365,7 +365,7 @@ "optional_inner": { "type": "String" }, - "summary": "**This field is deprecated, but left for backward-compatibility.** DApp Server public address.", + "summary": "**This field is deprecated, but left for backward-compatibility.** Evernode endpoint.", "description": null }, { @@ -377,8 +377,8 @@ "type": "String" } }, - "summary": "List of DApp Server addresses.", - "description": "Any correct URL format can be specified, including IP addresses. This parameter is prevailing over `server_address`.\nCheck the full list of [supported network endpoints](../ton-os-api/networks.md)." + "summary": "List of Evernode endpoints.", + "description": "Any correct URL format can be specified, including IP addresses. This parameter is prevailing over `server_address`.\nCheck the full list of [supported network endpoints](https://docs.everos.dev/ever-sdk/reference/ever-os-api/networks)." }, { "name": "network_retries_count", @@ -539,8 +539,8 @@ "optional_inner": { "type": "String" }, - "summary": "Access key to GraphQL API.", - "description": "You can specify here Basic Auth secret (Evercloud project secret) in hex string\nor serialized JWT in base64 string.\nWill be passed on as Authorization: Basic ... or Authorization: Bearer ... header." + "summary": "Access key to GraphQL API (Project secret)", + "description": null } ], "summary": null, @@ -11303,6 +11303,13 @@ "value": "614", "summary": null, "description": null + }, + { + "name": "Unauthorized", + "type": "Number", + "value": "615", + "summary": null, + "description": null } ], "summary": null, diff --git a/composer.json b/composer.json index a8e8487..508cb6c 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "require": { "php": ">=7.4", "ext-json": "*", - "ext-ton_client": ">=1.37.2", + "ext-ton_client": ">=1.38.0", "psr/log": "^1.1" }, "scripts": { diff --git a/composer.lock b/composer.lock index 71b52da..2dca1e4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b4456ea3710b6128cca51fb4de5941e6", + "content-hash": "35c110ccdeb311859f33a1c84709beef", "packages": [ { "name": "psr/log", @@ -291,16 +291,16 @@ }, { "name": "nette/php-generator", - "version": "v3.6.8", + "version": "v3.6.9", "source": { "type": "git", "url": "https://github.com/nette/php-generator.git", - "reference": "9073c8ac505b5f65af3bc2d1665be7d256e2dbe3" + "reference": "d31782f7bd2ae84ad06f863391ec3fb77ca4d0a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/php-generator/zipball/9073c8ac505b5f65af3bc2d1665be7d256e2dbe3", - "reference": "9073c8ac505b5f65af3bc2d1665be7d256e2dbe3", + "url": "https://api.github.com/repos/nette/php-generator/zipball/d31782f7bd2ae84ad06f863391ec3fb77ca4d0a6", + "reference": "d31782f7bd2ae84ad06f863391ec3fb77ca4d0a6", "shasum": "" }, "require": { @@ -353,9 +353,9 @@ ], "support": { "issues": "https://github.com/nette/php-generator/issues", - "source": "https://github.com/nette/php-generator/tree/v3.6.8" + "source": "https://github.com/nette/php-generator/tree/v3.6.9" }, - "time": "2022-09-12T22:13:59+00:00" + "time": "2022-10-04T11:49:47+00:00" }, { "name": "nette/utils", @@ -611,16 +611,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.17", + "version": "9.2.18", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8" + "reference": "12fddc491826940cf9b7e88ad9664cf51f0f6d0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8", - "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/12fddc491826940cf9b7e88ad9664cf51f0f6d0a", + "reference": "12fddc491826940cf9b7e88ad9664cf51f0f6d0a", "shasum": "" }, "require": { @@ -676,7 +676,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.17" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.18" }, "funding": [ { @@ -684,7 +684,7 @@ "type": "github" } ], - "time": "2022-08-30T12:24:04+00:00" + "time": "2022-10-27T13:35:33+00:00" }, { "name": "phpunit/php-file-iterator", @@ -929,16 +929,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.24", + "version": "9.5.26", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "d0aa6097bef9fd42458a9b3c49da32c6ce6129c5" + "reference": "851867efcbb6a1b992ec515c71cdcf20d895e9d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d0aa6097bef9fd42458a9b3c49da32c6ce6129c5", - "reference": "d0aa6097bef9fd42458a9b3c49da32c6ce6129c5", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/851867efcbb6a1b992ec515c71cdcf20d895e9d2", + "reference": "851867efcbb6a1b992ec515c71cdcf20d895e9d2", "shasum": "" }, "require": { @@ -960,14 +960,14 @@ "phpunit/php-timer": "^5.0.2", "sebastian/cli-parser": "^1.0.1", "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.5", + "sebastian/comparator": "^4.0.8", "sebastian/diff": "^4.0.3", "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.3", + "sebastian/exporter": "^4.0.5", "sebastian/global-state": "^5.0.1", "sebastian/object-enumerator": "^4.0.3", "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.1", + "sebastian/type": "^3.2", "sebastian/version": "^3.0.2" }, "suggest": { @@ -1011,7 +1011,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.24" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.26" }, "funding": [ { @@ -1021,9 +1021,13 @@ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" } ], - "time": "2022-08-30T07:42:16+00:00" + "time": "2022-10-28T06:00:21+00:00" }, { "name": "sebastian/cli-parser", @@ -2048,7 +2052,7 @@ "platform": { "php": ">=7.4", "ext-json": "*", - "ext-ton_client": ">=1.37.2" + "ext-ton_client": ">=1.38.0" }, "platform-dev": { "ext-readline": "*" diff --git a/docker/7.4/cli/Dockerfile b/docker/7.4/cli/Dockerfile index 5ce2c29..d8bddcd 100644 --- a/docker/7.4/cli/Dockerfile +++ b/docker/7.4/cli/Dockerfile @@ -1,7 +1,7 @@ FROM php:7.4-cli -RUN php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.37.2/installer.php', 'installer.php');" +RUN php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.38.0/installer.php', 'installer.php');" RUN php -r "if (hash_file('sha384', 'installer.php') === '03586e200bc1c87f000c5a0eea27aa688eb451a5b946579205ca918bbffda7234359e2d0e176aa53e841c6a77b8de959') { echo 'Installer verified'; } else { echo 'Installer corrupt'; exit(1); } echo PHP_EOL;" -RUN php installer.php -v 1.37.2 -RUN php installer.php -v 1.37.2 -T +RUN php installer.php -v 1.38.0 +RUN php installer.php -v 1.38.0 -T RUN rm installer.php \ No newline at end of file diff --git a/docker/7.4/fpm/Dockerfile b/docker/7.4/fpm/Dockerfile index 8942144..a323785 100644 --- a/docker/7.4/fpm/Dockerfile +++ b/docker/7.4/fpm/Dockerfile @@ -1,7 +1,7 @@ FROM php:7.4-fpm -RUN php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.37.2/installer.php', 'installer.php');" +RUN php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.38.0/installer.php', 'installer.php');" RUN php -r "if (hash_file('sha384', 'installer.php') === '03586e200bc1c87f000c5a0eea27aa688eb451a5b946579205ca918bbffda7234359e2d0e176aa53e841c6a77b8de959') { echo 'Installer verified'; } else { echo 'Installer corrupt'; exit(1); } echo PHP_EOL;" -RUN php installer.php -v 1.37.2 -RUN php installer.php -v 1.37.2 -T +RUN php installer.php -v 1.38.0 +RUN php installer.php -v 1.38.0 -T RUN rm installer.php \ No newline at end of file diff --git a/docker/7.4/zts/Dockerfile b/docker/7.4/zts/Dockerfile index cc228c1..825767b 100644 --- a/docker/7.4/zts/Dockerfile +++ b/docker/7.4/zts/Dockerfile @@ -1,7 +1,7 @@ FROM php:7.4-zts -RUN php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.37.2/installer.php', 'installer.php');" +RUN php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.38.0/installer.php', 'installer.php');" RUN php -r "if (hash_file('sha384', 'installer.php') === '03586e200bc1c87f000c5a0eea27aa688eb451a5b946579205ca918bbffda7234359e2d0e176aa53e841c6a77b8de959') { echo 'Installer verified'; } else { echo 'Installer corrupt'; exit(1); } echo PHP_EOL;" -RUN php installer.php -v 1.37.2 -RUN php installer.php -v 1.37.2 -T +RUN php installer.php -v 1.38.0 +RUN php installer.php -v 1.38.0 -T RUN rm installer.php \ No newline at end of file diff --git a/docker/8.0/cli/Dockerfile b/docker/8.0/cli/Dockerfile index 6544b52..06000b3 100644 --- a/docker/8.0/cli/Dockerfile +++ b/docker/8.0/cli/Dockerfile @@ -1,7 +1,7 @@ FROM php:8.0-cli -RUN php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.37.2/installer.php', 'installer.php');" +RUN php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.38.0/installer.php', 'installer.php');" RUN php -r "if (hash_file('sha384', 'installer.php') === '03586e200bc1c87f000c5a0eea27aa688eb451a5b946579205ca918bbffda7234359e2d0e176aa53e841c6a77b8de959') { echo 'Installer verified'; } else { echo 'Installer corrupt'; exit(1); } echo PHP_EOL;" -RUN php installer.php -v 1.37.2 -RUN php installer.php -v 1.37.2 -T +RUN php installer.php -v 1.38.0 +RUN php installer.php -v 1.38.0 -T RUN rm installer.php \ No newline at end of file diff --git a/docker/8.0/fpm/Dockerfile b/docker/8.0/fpm/Dockerfile index 7c1f984..34905b7 100644 --- a/docker/8.0/fpm/Dockerfile +++ b/docker/8.0/fpm/Dockerfile @@ -1,7 +1,7 @@ FROM php:8.0-fpm -RUN php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.37.2/installer.php', 'installer.php');" +RUN php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.38.0/installer.php', 'installer.php');" RUN php -r "if (hash_file('sha384', 'installer.php') === '03586e200bc1c87f000c5a0eea27aa688eb451a5b946579205ca918bbffda7234359e2d0e176aa53e841c6a77b8de959') { echo 'Installer verified'; } else { echo 'Installer corrupt'; exit(1); } echo PHP_EOL;" -RUN php installer.php -v 1.37.2 -RUN php installer.php -v 1.37.2 -T +RUN php installer.php -v 1.38.0 +RUN php installer.php -v 1.38.0 -T RUN rm installer.php \ No newline at end of file diff --git a/docker/8.0/zts/Dockerfile b/docker/8.0/zts/Dockerfile index 58e92a7..a95d283 100644 --- a/docker/8.0/zts/Dockerfile +++ b/docker/8.0/zts/Dockerfile @@ -1,7 +1,7 @@ FROM php:8.0-zts -RUN php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.37.2/installer.php', 'installer.php');" +RUN php -r "copy('https://raw.githubusercontent.com/radianceteam/ton-client-php-ext/1.38.0/installer.php', 'installer.php');" RUN php -r "if (hash_file('sha384', 'installer.php') === '03586e200bc1c87f000c5a0eea27aa688eb451a5b946579205ca918bbffda7234359e2d0e176aa53e841c6a77b8de959') { echo 'Installer verified'; } else { echo 'Installer corrupt'; exit(1); } echo PHP_EOL;" -RUN php installer.php -v 1.37.2 -RUN php installer.php -v 1.37.2 -T +RUN php installer.php -v 1.38.0 +RUN php installer.php -v 1.38.0 -T RUN rm installer.php \ No newline at end of file diff --git a/src/TON/Client/NetworkConfig.php b/src/TON/Client/NetworkConfig.php index 58c3b63..13f9458 100644 --- a/src/TON/Client/NetworkConfig.php +++ b/src/TON/Client/NetworkConfig.php @@ -17,7 +17,7 @@ class NetworkConfig implements JsonSerializable /** * Any correct URL format can be specified, including IP addresses. This parameter is prevailing over `server_address`. - * Check the full list of [supported network endpoints](../ton-os-api/networks.md). + * Check the full list of [supported network endpoints](https://docs.everos.dev/ever-sdk/reference/ever-os-api/networks). */ private ?array $_endpoints; @@ -87,12 +87,6 @@ class NetworkConfig implements JsonSerializable * Must be specified in milliseconds. Default is 5000 (5 sec). */ private ?int $_nextRempStatusTimeout; - - /** - * You can specify here Basic Auth secret (Evercloud project secret) in hex string - * or serialized JWT in base64 string. - * Will be passed on as Authorization: Basic ... or Authorization: Bearer ... header. - */ private ?string $_accessKey; public function __construct(?array $dto = null) @@ -124,7 +118,7 @@ public function getServerAddress(): ?string /** * Any correct URL format can be specified, including IP addresses. This parameter is prevailing over `server_address`. - * Check the full list of [supported network endpoints](../ton-os-api/networks.md). + * Check the full list of [supported network endpoints](https://docs.everos.dev/ever-sdk/reference/ever-os-api/networks). */ public function getEndpoints(): ?array { @@ -255,11 +249,6 @@ public function getNextRempStatusTimeout(): ?int return $this->_nextRempStatusTimeout; } - /** - * You can specify here Basic Auth secret (Evercloud project secret) in hex string - * or serialized JWT in base64 string. - * Will be passed on as Authorization: Basic ... or Authorization: Bearer ... header. - */ public function getAccessKey(): ?string { return $this->_accessKey; @@ -276,7 +265,7 @@ public function setServerAddress(?string $serverAddress): self /** * Any correct URL format can be specified, including IP addresses. This parameter is prevailing over `server_address`. - * Check the full list of [supported network endpoints](../ton-os-api/networks.md). + * Check the full list of [supported network endpoints](https://docs.everos.dev/ever-sdk/reference/ever-os-api/networks). * @return self */ public function setEndpoints(?array $endpoints): self @@ -440,9 +429,6 @@ public function setNextRempStatusTimeout(?int $nextRempStatusTimeout): self } /** - * You can specify here Basic Auth secret (Evercloud project secret) in hex string - * or serialized JWT in base64 string. - * Will be passed on as Authorization: Basic ... or Authorization: Bearer ... header. * @return self */ public function setAccessKey(?string $accessKey): self diff --git a/src/TON/Net/NetErrorCode.php b/src/TON/Net/NetErrorCode.php index 472f3b0..f5a5a43 100644 --- a/src/TON/Net/NetErrorCode.php +++ b/src/TON/Net/NetErrorCode.php @@ -24,4 +24,5 @@ final class NetErrorCode public const NoEndpointsProvided = 612; public const GraphqlWebsocketInitError = 613; public const NetworkModuleResumed = 614; + public const Unauthorized = 615; } diff --git a/tests/TON/Client/ClientModuleTests.php b/tests/TON/Client/ClientModuleTests.php index 17813f1..d9d43ca 100644 --- a/tests/TON/Client/ClientModuleTests.php +++ b/tests/TON/Client/ClientModuleTests.php @@ -19,7 +19,7 @@ public function testVersion() $result = $this->_client->version(); $this->assertNotNull($result); $this->assertMatchesRegularExpression('/^\d+\.\d+\.\d+$/', $result->getVersion()); - $this->assertEquals('1.37.2', $result->getVersion()); + $this->assertEquals('1.38.0', $result->getVersion()); } public function testGetApiReference() diff --git a/tests/contracts/abi_v2/CustomReplayProtection.abi.json b/tests/contracts/abi_v2/CustomReplayProtection.abi.json new file mode 100644 index 0000000..948ea73 --- /dev/null +++ b/tests/contracts/abi_v2/CustomReplayProtection.abi.json @@ -0,0 +1,41 @@ +{ + "ABI version": 2, + "version": "2.3", + "header": ["pubkey", "time", "expire"], + "functions": [ + { + "name": "answer", + "inputs": [ + {"name":"dst","type":"address"} + ], + "outputs": [ + ] + }, + { + "name": "getData", + "inputs": [ + ], + "outputs": [ + {"name":"value0","type":"uint64"}, + {"name":"value1","type":"uint32"} + ] + }, + { + "name": "constructor", + "inputs": [ + ], + "outputs": [ + ] + } + ], + "data": [ + ], + "events": [ + ], + "fields": [ + {"name":"_pubkey","type":"uint256"}, + {"name":"_constructorFlag","type":"bool"}, + {"name":"m_timestamp","type":"uint64"}, + {"name":"m_expire","type":"uint32"} + ] +} diff --git a/tests/contracts/abi_v2/CustomReplayProtection.sol b/tests/contracts/abi_v2/CustomReplayProtection.sol new file mode 100644 index 0000000..a2f22d5 --- /dev/null +++ b/tests/contracts/abi_v2/CustomReplayProtection.sol @@ -0,0 +1,31 @@ +pragma ton-solidity ^0.65.0; +pragma AbiHeader time; +pragma AbiHeader pubkey; +pragma AbiHeader expire; + +import "testDebot20.sol"; + +contract RollingIdsTest + { + uint64 m_timestamp; + uint32 m_expire; + + function answer(address dst) public view externalMsg { + tvm.accept(); + ARecieverDebot(dst).headerCalback(m_timestamp,m_expire); + } + + function afterSignatureCheck(TvmSlice body, TvmCell message) private inline returns (TvmSlice) { + //msgId = timestamp + message; + (uint64 msgId,uint32 exp) = body.decode(uint64, uint32); + require(msgId>m_timestamp,302); + m_timestamp = msgId; + m_expire = exp; + return body; + } + + function getData() external view returns (uint64,uint32) { + return (m_timestamp,m_expire); + } +} diff --git a/tests/contracts/abi_v2/CustomReplayProtection.tvc b/tests/contracts/abi_v2/CustomReplayProtection.tvc new file mode 100644 index 0000000..07d6917 Binary files /dev/null and b/tests/contracts/abi_v2/CustomReplayProtection.tvc differ diff --git a/tests/contracts/abi_v2/testDebot20.abi.json b/tests/contracts/abi_v2/testDebot20.abi.json new file mode 100644 index 0000000..05f6ec5 --- /dev/null +++ b/tests/contracts/abi_v2/testDebot20.abi.json @@ -0,0 +1,196 @@ +{ + "ABI version": 2, + "version": "2.3", + "header": ["pubkey", "time", "expire"], + "functions": [ + { + "name": "getData", + "inputs": [ + ], + "outputs": [ + {"name":"value0","type":"uint64"}, + {"name":"value1","type":"uint32"} + ] + }, + { + "name": "setRollingId", + "inputs": [ + {"name":"a","type":"address"} + ], + "outputs": [ + ] + }, + { + "name": "headerCalback", + "inputs": [ + {"name":"timestamp","type":"uint64"}, + {"name":"expire","type":"uint32"} + ], + "outputs": [ + ] + }, + { + "name": "start", + "inputs": [ + ], + "outputs": [ + ] + }, + { + "name": "setRandom", + "inputs": [ + {"name":"buffer","type":"bytes"} + ], + "outputs": [ + ] + }, + { + "name": "setBoxHandle", + "inputs": [ + {"name":"handle","type":"uint32"} + ], + "outputs": [ + ] + }, + { + "name": "transferError", + "inputs": [ + {"name":"sdkError","type":"uint32"}, + {"name":"exitCode","type":"uint32"} + ], + "outputs": [ + ] + }, + { + "name": "transferSuccess", + "inputs": [ + {"name":"id","type":"uint256"} + ], + "outputs": [ + ] + }, + { + "name": "onFoo", + "inputs": [ + {"name":"addr","type":"address"} + ], + "outputs": [ + ] + }, + { + "name": "printQueryStatus", + "inputs": [ + {"name":"status","type":"uint8"} + ], + "outputs": [ + ] + }, + { + "name": "waitTransactionResult", + "inputs": [ + {"name":"status","type":"uint8"}, + {"components":[{"name":"kind","type":"uint8"},{"name":"value","type":"cell"},{"name":"object","type":"map(uint256,cell)"},{"components":[{"name":"cell","type":"cell"}],"name":"array","type":"tuple[]"}],"name":"object","type":"tuple"} + ], + "outputs": [ + ] + }, + { + "name": "getMsgDetails", + "inputs": [ + {"name":"value0","type":"uint64"}, + {"name":"value1","type":"uint32"} + ], + "outputs": [ + ] + }, + { + "name": "onGetMethodError", + "inputs": [ + {"name":"sdkError","type":"uint32"}, + {"name":"exitCode","type":"uint32"} + ], + "outputs": [ + ] + }, + { + "name": "getDebotInfo", + "id": "0xDEB", + "inputs": [ + ], + "outputs": [ + {"name":"name","type":"string"}, + {"name":"version","type":"string"}, + {"name":"publisher","type":"string"}, + {"name":"caption","type":"string"}, + {"name":"author","type":"string"}, + {"name":"support","type":"address"}, + {"name":"hello","type":"string"}, + {"name":"language","type":"string"}, + {"name":"dabi","type":"string"}, + {"name":"icon","type":"bytes"} + ] + }, + { + "name": "getRequiredInterfaces", + "inputs": [ + ], + "outputs": [ + {"name":"interfaces","type":"uint256[]"} + ] + }, + { + "name": "foo", + "inputs": [ + ], + "outputs": [ + {"name":"addr","type":"address"} + ] + }, + { + "name": "getDebotOptions", + "inputs": [ + ], + "outputs": [ + {"name":"options","type":"uint8"}, + {"name":"debotAbi","type":"string"}, + {"name":"targetAbi","type":"string"}, + {"name":"targetAddr","type":"address"} + ] + }, + { + "name": "setABI", + "inputs": [ + {"name":"dabi","type":"string"} + ], + "outputs": [ + ] + }, + { + "name": "constructor", + "inputs": [ + ], + "outputs": [ + ] + } + ], + "data": [ + ], + "events": [ + ], + "fields": [ + {"name":"_pubkey","type":"uint256"}, + {"name":"_timestamp","type":"uint64"}, + {"name":"_constructorFlag","type":"bool"}, + {"name":"m_options","type":"uint8"}, + {"name":"m_debotAbi","type":"optional(string)"}, + {"name":"m_targetAbi","type":"optional(string)"}, + {"name":"m_target","type":"optional(address)"}, + {"name":"m_rollingId","type":"address"}, + {"name":"m_sendMsg","type":"cell"}, + {"name":"m_timestamp","type":"uint64"}, + {"name":"m_expire","type":"uint32"}, + {"name":"m_sendTimestamp","type":"uint64"}, + {"name":"m_sendExpire","type":"uint32"}, + {"name":"m_handle","type":"uint32"} + ] +} diff --git a/tests/contracts/abi_v2/testDebot20.sol b/tests/contracts/abi_v2/testDebot20.sol new file mode 100644 index 0000000..424046d --- /dev/null +++ b/tests/contracts/abi_v2/testDebot20.sol @@ -0,0 +1,189 @@ +pragma ton-solidity ^0.65.0; +pragma AbiHeader expire; +pragma AbiHeader time; +pragma AbiHeader pubkey; +// import required DeBot interfaces and basic DeBot contract. +import "https://raw.githubusercontent.com/tonlabs/debots/main/Debot.sol"; +import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/SigningBoxInput/SigningBoxInput.sol"; +import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/Terminal/Terminal.sol"; +import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/Query/Query.sol"; +import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/Sdk/Sdk.sol"; + +abstract contract ARollingId { + function answer(address dst) public {} +} + +abstract contract ARecieverDebot { + function headerCalback(uint64 timestamp, uint32 expire) virtual public {} +} + +contract MsgTestDebot is Debot, ARecieverDebot { + + using JsonLib for JsonLib.Value; + using JsonLib for mapping(uint256 => TvmCell); + + uint8 constant OVERRIDE_TS = 1; + uint8 constant OVERRIDE_EXPT = 2; + uint8 constant ASYNC_CALL = 4; + + address m_rollingId; + TvmCell m_sendMsg; + uint64 m_timestamp; + uint32 m_expire; + uint64 m_sendTimestamp; + uint32 m_sendExpire; + uint32 m_handle; + + function _abiver(uint8 maj, uint8 min) private pure inline returns (uint8) { + return (min << 4 | maj); + } + + function getData() external view returns (uint64,uint32) { + return (m_timestamp,m_expire); + } + + function setRollingId(address a) public { + require(msg.pubkey() == tvm.pubkey(), 101); + tvm.accept(); + m_rollingId = a; + } + + function headerCalback(uint64 timestamp, uint32 expire) override public { + tvm.accept(); + m_timestamp = timestamp; + m_expire = expire; + } + + function start() public override { + Sdk.genRandom(tvm.functionId(setRandom), 2); + } + + function setRandom(bytes buffer) public { + uint16 r = buffer.toSlice().decode(uint16); + m_sendTimestamp = r+500; + m_sendExpire = r+100; + SigningBoxInput.get(tvm.functionId(setBoxHandle), "", [tvm.pubkey()]); + } + + function setBoxHandle(uint32 handle) public { + m_handle = handle; + test1(); + test2(); + } + + function test1() private view { + ARollingId(m_rollingId).answer{ + callbackId: tvm.functionId(transferSuccess), + onErrorId: tvm.functionId(transferError), + time: m_sendTimestamp, + expire: m_sendExpire, + pubkey: tvm.pubkey(), + abiVer: _abiver(2, 3), + sign: true, + signBoxHandle: m_handle, + flags: OVERRIDE_TS | OVERRIDE_EXPT | ASYNC_CALL + }(address(this)).extMsg; + } + + function test2() private view { + this.foo{ + callbackId: tvm.functionId(onFoo), + onErrorId: tvm.functionId(transferError), + time: 0, + expire: 0, + pubkey: 0, + abiVer: _abiver(2, 3), + sign: true, + signBoxHandle: m_handle + }().extMsg; + } + + + function transferError(uint32 sdkError, uint32 exitCode) public pure { + Terminal.print(0, format("Transaction failed. Sdk error = {}, Error code = {}\nDo you want to retry?", sdkError, exitCode)); + require(false, 108); + } + + function transferSuccess(uint256 id) public pure { + id; + //wait for contract call our debot + Query.waitForCollection( + tvm.functionId(waitTransactionResult), + QueryCollection.Transactions, + format("{\"account_addr\":{\"eq\": \"{}\"},\"now\":{\"ge\": {}}}",address(this),now), + "id now", + 60000 + ); + } + + function onFoo(address addr) public view { + require(m_rollingId == addr, 110); + } + + function printQueryStatus(QueryStatus status) public pure { + if (status == QueryStatus.FilterError) + require(false, 102); + else if (status == QueryStatus.NetworkError) + require(false, 103); + else if (status == QueryStatus.UnknownError) + require(false, 104); + } + + function waitTransactionResult(QueryStatus status, JsonLib.Value object) public pure { + object; + if (status == QueryStatus.Success) { + MsgTestDebot(address(this)).getData{ + callbackId: getMsgDetails, + onErrorId: onGetMethodError, + time: 0, + expire: 0, + sign: false, + pubkey: null + }().extMsg; + } else { + printQueryStatus(status); + } + } + + function getMsgDetails(uint64 value0,uint32 value1) public view { + require(value0==m_sendTimestamp, 105); + require(value1==m_sendExpire, 106); + } + + function onGetMethodError(uint32 sdkError, uint32 exitCode) public pure { + Terminal.print(0, format("Get method error. Sdk error = {}, Error code = {}",sdkError, exitCode)); + require(false, 107); + } + + /* + * Implementation of DeBot + */ + function getDebotInfo() public functionID(0xDEB) override view returns( + string name, string version, string publisher, string caption, string author, + address support, string hello, string language, string dabi, bytes icon + ) { + name = "TestDeBot20"; + version = "0.1.0"; + publisher = "EverX"; + caption = "TestDeBot20"; + author = "EverX"; + support = address(0); + hello = "TestDeBot20"; + language = "en"; + dabi = m_debotAbi.get(); + icon = ""; + } + + function getRequiredInterfaces() public view override returns (uint256[] interfaces) { + return [ SigningBoxInput.ID, Terminal.ID ]; + } + + // + // Onchain functions + // + + function foo() external view externalMsg returns (address addr) { + tvm.accept(); + addr = m_rollingId; + } +} diff --git a/tests/contracts/abi_v2/testDebot20.tvc b/tests/contracts/abi_v2/testDebot20.tvc new file mode 100644 index 0000000..5a30be1 Binary files /dev/null and b/tests/contracts/abi_v2/testDebot20.tvc differ