From edf827a6c73c8b6b67463c357db759a35f2f12d0 Mon Sep 17 00:00:00 2001 From: Gusarich Date: Wed, 6 Mar 2024 00:15:22 +0300 Subject: [PATCH 1/2] add `RenounceOwnership` message to `OwnableTransferable` trait --- CHANGELOG.md | 2 + src/test/__snapshots__/bugs.spec.ts.snap | 8 +- .../feature-ownabletransferable.spec.ts.snap | 246 ++++++++ src/test/feature-ownabletransferable.spec.ts | 97 +++ ...letransferable_OwnableTransferableTest.abi | 1 + ...nsferable_OwnableTransferableTest.code.boc | Bin 0 -> 1081 bytes ...ansferable_OwnableTransferableTest.code.fc | 154 +++++ ...nsferable_OwnableTransferableTest.code.fif | 461 ++++++++++++++ ...rable_OwnableTransferableTest.code.rev.fif | 536 ++++++++++++++++ ...ferable_OwnableTransferableTest.headers.fc | 88 +++ ...bletransferable_OwnableTransferableTest.md | 73 +++ ...letransferable_OwnableTransferableTest.pkg | 1 + ...sferable_OwnableTransferableTest.stdlib.fc | 130 ++++ ...ferable_OwnableTransferableTest.storage.fc | 109 ++++ ...bletransferable_OwnableTransferableTest.ts | 587 ++++++++++++++++++ src/test/features/ownabletransferable.tact | 14 + stdlib/libs/ownable.tact | 26 +- tact.config.json | 8 + 18 files changed, 2535 insertions(+), 6 deletions(-) create mode 100644 src/test/__snapshots__/feature-ownabletransferable.spec.ts.snap create mode 100644 src/test/feature-ownabletransferable.spec.ts create mode 100644 src/test/features/output/ownabletransferable_OwnableTransferableTest.abi create mode 100644 src/test/features/output/ownabletransferable_OwnableTransferableTest.code.boc create mode 100644 src/test/features/output/ownabletransferable_OwnableTransferableTest.code.fc create mode 100644 src/test/features/output/ownabletransferable_OwnableTransferableTest.code.fif create mode 100644 src/test/features/output/ownabletransferable_OwnableTransferableTest.code.rev.fif create mode 100644 src/test/features/output/ownabletransferable_OwnableTransferableTest.headers.fc create mode 100644 src/test/features/output/ownabletransferable_OwnableTransferableTest.md create mode 100644 src/test/features/output/ownabletransferable_OwnableTransferableTest.pkg create mode 100644 src/test/features/output/ownabletransferable_OwnableTransferableTest.stdlib.fc create mode 100644 src/test/features/output/ownabletransferable_OwnableTransferableTest.storage.fc create mode 100644 src/test/features/output/ownabletransferable_OwnableTransferableTest.ts create mode 100644 src/test/features/ownabletransferable.tact diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fb250b6c..7b9918345 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- `RenounceOwnership` message was added to `OwnableTransferable` + ### Fixed ## [1.2.0] - 2024-02-29 diff --git a/src/test/__snapshots__/bugs.spec.ts.snap b/src/test/__snapshots__/bugs.spec.ts.snap index 270ddcc2d..4e480f5e3 100644 --- a/src/test/__snapshots__/bugs.spec.ts.snap +++ b/src/test/__snapshots__/bugs.spec.ts.snap @@ -12,12 +12,12 @@ exports[`bugs should deploy contract correctly 1`] = ` "$type": "received", "message": { "body": { - "cell": "x{178D45190000000000000000502540BE400801D98D6D0FE85B55D6D58229C8ED55470B1C744D6BEEAD475C27236E9908A993110016E3A425A4E75B646191AC9A34FE5D050BD101A5C490F87D01C66D885D09BC1082_}", + "cell": "x{178D45190000000000000000502540BE400800CE4011EE2C736AE0658546CE43C9BC60CABD26F9E906C2E08F91925ED24B05BD0016E3A425A4E75B646191AC9A34FE5D050BD101A5C490F87D01C66D885D09BC1082_}", "type": "cell", }, "bounce": false, - "from": "kQDsxraH9C2q62rBFOR2qqOFjjomtfdWo64TkbdMhFTJiLsN", - "to": "kQBGSDIgoUMAjGBNBXjsdBRlfPtqK5rKgQOD5N7yKFfIXeuh", + "from": "kQBnIAj3Fjm1cDLCo2ch5N4wZV6TfPSDYXBHyMkvaSWC3ggs", + "to": "kQC6Vhi16Ku_T4BWi779yF6vlbp2J37fwovTpRR8DaacynWH", "type": "internal", "value": "9.95885", }, @@ -38,7 +38,7 @@ exports[`bugs should deploy contract correctly 1`] = ` }, }, "bounce": false, - "from": "kQBGSDIgoUMAjGBNBXjsdBRlfPtqK5rKgQOD5N7yKFfIXeuh", + "from": "kQC6Vhi16Ku_T4BWi779yF6vlbp2J37fwovTpRR8DaacynWH", "to": "@treasure(treasure)", "type": "internal", "value": "9.914852826", diff --git a/src/test/__snapshots__/feature-ownabletransferable.spec.ts.snap b/src/test/__snapshots__/feature-ownabletransferable.spec.ts.snap new file mode 100644 index 000000000..4001afc78 --- /dev/null +++ b/src/test/__snapshots__/feature-ownabletransferable.spec.ts.snap @@ -0,0 +1,246 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`feature-ordering should deploy correctly 1`] = ` +[ + { + "$seq": 0, + "events": [ + { + "$type": "deploy", + }, + { + "$type": "received", + "message": { + "body": { + "text": "test", + "type": "text", + }, + "bounce": true, + "from": "@treasure(treasure)", + "to": "kQBGF0CUxwjQr65xgop8Bw8l5v1BfLn6Oey9WClezcq-HQ9z", + "type": "internal", + "value": "1", + }, + }, + { + "$type": "processed", + "gasUsed": 4870n, + }, + ], + }, +] +`; + +exports[`feature-ordering should renounce ownership correctly 1`] = ` +[ + { + "$seq": 0, + "events": [ + { + "$type": "deploy", + }, + { + "$type": "received", + "message": { + "body": { + "text": "test", + "type": "text", + }, + "bounce": true, + "from": "@treasure(treasure)", + "to": "kQBGF0CUxwjQr65xgop8Bw8l5v1BfLn6Oey9WClezcq-HQ9z", + "type": "internal", + "value": "1", + }, + }, + { + "$type": "processed", + "gasUsed": 4870n, + }, + ], + }, + { + "$seq": 1, + "events": [ + { + "$type": "storage-charged", + "amount": "0.000000006", + }, + { + "$type": "received", + "message": { + "body": { + "type": "known", + "value": { + "$$type": "ChangeOwner", + "newOwner": kQAq4dsn8XD1ot3Hg_-nHdRkM5P1PaOZAy-YLG4p3mkQ96xD, + "queryId": 0n, + }, + }, + "bounce": true, + "from": "@treasure(treasure)", + "to": "kQBGF0CUxwjQr65xgop8Bw8l5v1BfLn6Oey9WClezcq-HQ9z", + "type": "internal", + "value": "1", + }, + }, + { + "$type": "processed", + "gasUsed": 8799n, + }, + { + "$type": "sent", + "messages": [ + { + "body": { + "type": "known", + "value": { + "$$type": "ChangeOwnerOk", + "newOwner": kQAq4dsn8XD1ot3Hg_-nHdRkM5P1PaOZAy-YLG4p3mkQ96xD, + "queryId": 0n, + }, + }, + "bounce": true, + "from": "kQBGF0CUxwjQr65xgop8Bw8l5v1BfLn6Oey9WClezcq-HQ9z", + "to": "@treasure(treasure)", + "type": "internal", + "value": "0.989738", + }, + ], + }, + ], + }, + { + "$seq": 2, + "events": [ + { + "$type": "storage-charged", + "amount": "0.000000006", + }, + { + "$type": "received", + "message": { + "body": { + "type": "known", + "value": { + "$$type": "RenounceOwnership", + "queryId": 0n, + }, + }, + "bounce": true, + "from": "@treasure(anotherTreasure)", + "to": "kQBGF0CUxwjQr65xgop8Bw8l5v1BfLn6Oey9WClezcq-HQ9z", + "type": "internal", + "value": "1", + }, + }, + { + "$type": "processed", + "gasUsed": 11048n, + }, + { + "$type": "sent", + "messages": [ + { + "body": { + "type": "known", + "value": { + "$$type": "ChangeOwnerOk", + "newOwner": kQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHTW, + "queryId": 0n, + }, + }, + "bounce": true, + "from": "kQBGF0CUxwjQr65xgop8Bw8l5v1BfLn6Oey9WClezcq-HQ9z", + "to": "@treasure(anotherTreasure)", + "type": "internal", + "value": "0.987489", + }, + ], + }, + ], + }, +] +`; + +exports[`feature-ordering should transfer ownership correctly 1`] = ` +[ + { + "$seq": 0, + "events": [ + { + "$type": "deploy", + }, + { + "$type": "received", + "message": { + "body": { + "text": "test", + "type": "text", + }, + "bounce": true, + "from": "@treasure(treasure)", + "to": "kQBGF0CUxwjQr65xgop8Bw8l5v1BfLn6Oey9WClezcq-HQ9z", + "type": "internal", + "value": "1", + }, + }, + { + "$type": "processed", + "gasUsed": 4870n, + }, + ], + }, + { + "$seq": 1, + "events": [ + { + "$type": "storage-charged", + "amount": "0.000000006", + }, + { + "$type": "received", + "message": { + "body": { + "type": "known", + "value": { + "$$type": "ChangeOwner", + "newOwner": kQAq4dsn8XD1ot3Hg_-nHdRkM5P1PaOZAy-YLG4p3mkQ96xD, + "queryId": 0n, + }, + }, + "bounce": true, + "from": "@treasure(treasure)", + "to": "kQBGF0CUxwjQr65xgop8Bw8l5v1BfLn6Oey9WClezcq-HQ9z", + "type": "internal", + "value": "1", + }, + }, + { + "$type": "processed", + "gasUsed": 8799n, + }, + { + "$type": "sent", + "messages": [ + { + "body": { + "type": "known", + "value": { + "$$type": "ChangeOwnerOk", + "newOwner": kQAq4dsn8XD1ot3Hg_-nHdRkM5P1PaOZAy-YLG4p3mkQ96xD, + "queryId": 0n, + }, + }, + "bounce": true, + "from": "kQBGF0CUxwjQr65xgop8Bw8l5v1BfLn6Oey9WClezcq-HQ9z", + "to": "@treasure(treasure)", + "type": "internal", + "value": "0.989738", + }, + ], + }, + ], + }, +] +`; diff --git a/src/test/feature-ownabletransferable.spec.ts b/src/test/feature-ownabletransferable.spec.ts new file mode 100644 index 000000000..9286fb77c --- /dev/null +++ b/src/test/feature-ownabletransferable.spec.ts @@ -0,0 +1,97 @@ +import { Address, toNano } from '@ton/core'; +import { ContractSystem } from '@tact-lang/emulator'; +import { __DANGER_resetNodeId } from '../grammar/ast'; +import { OwnableTransferableTest } from './features/output/ownabletransferable_OwnableTransferableTest'; + +describe('feature-ordering', () => { + beforeEach(() => { + __DANGER_resetNodeId(); + }); + it('should deploy correctly', async () => { + // Init + const system = await ContractSystem.create(); + const treasure = system.treasure('treasure'); + const contract = system.open( + await OwnableTransferableTest.fromInit(treasure.address) + ); + const tracker = system.track(contract.address); + await contract.send(treasure, { value: toNano('1') }, 'test'); + await system.run(); + expect(tracker.collect()).toMatchSnapshot(); + expect( + (await contract.getOwner()).equals(treasure.address) + ).toBeTruthy(); + }); + + it('should transfer ownership correctly', async () => { + // Init + const system = await ContractSystem.create(); + const treasure = system.treasure('treasure'); + const contract = system.open( + await OwnableTransferableTest.fromInit(treasure.address) + ); + const tracker = system.track(contract.address); + await contract.send(treasure, { value: toNano('1') }, 'test'); + await system.run(); + const anotherTreasure = system.treasure('anotherTreasure'); + await contract.send( + treasure, + { value: toNano('1') }, + { + $$type: 'ChangeOwner', + newOwner: anotherTreasure.address, + queryId: 0n, + } + ); + await system.run(); + expect(tracker.collect()).toMatchSnapshot(); + expect( + (await contract.getOwner()).equals(anotherTreasure.address) + ).toBeTruthy(); + }); + + it('should renounce ownership correctly', async () => { + // Init + const system = await ContractSystem.create(); + const treasure = system.treasure('treasure'); + const contract = system.open( + await OwnableTransferableTest.fromInit(treasure.address) + ); + const tracker = system.track(contract.address); + await contract.send(treasure, { value: toNano('1') }, 'test'); + await system.run(); + + const anotherTreasure = system.treasure('anotherTreasure'); + await contract.send( + treasure, + { value: toNano('1') }, + { + $$type: 'ChangeOwner', + newOwner: anotherTreasure.address, + queryId: 0n, + } + ); + await system.run(); + expect( + (await contract.getOwner()).equals(anotherTreasure.address) + ).toBeTruthy(); + + await contract.send( + anotherTreasure, + { value: toNano('1') }, + { + $$type: 'RenounceOwnership', + queryId: 0n, + } + ); + await system.run(); + expect( + (await contract.getOwner()).equals( + Address.parseRaw( + '0:0000000000000000000000000000000000000000000000000000000000000000' + ) + ) + ).toBeTruthy(); + expect(tracker.collect()).toMatchSnapshot(); + }); +}); diff --git a/src/test/features/output/ownabletransferable_OwnableTransferableTest.abi b/src/test/features/output/ownabletransferable_OwnableTransferableTest.abi new file mode 100644 index 000000000..44fdd76ef --- /dev/null +++ b/src/test/features/output/ownabletransferable_OwnableTransferableTest.abi @@ -0,0 +1 @@ +{"name":"OwnableTransferableTest","types":[{"name":"StateInit","header":null,"fields":[{"name":"code","type":{"kind":"simple","type":"cell","optional":false}},{"name":"data","type":{"kind":"simple","type":"cell","optional":false}}]},{"name":"Context","header":null,"fields":[{"name":"bounced","type":{"kind":"simple","type":"bool","optional":false}},{"name":"sender","type":{"kind":"simple","type":"address","optional":false}},{"name":"value","type":{"kind":"simple","type":"int","optional":false,"format":257}},{"name":"raw","type":{"kind":"simple","type":"slice","optional":false}}]},{"name":"SendParameters","header":null,"fields":[{"name":"bounce","type":{"kind":"simple","type":"bool","optional":false}},{"name":"to","type":{"kind":"simple","type":"address","optional":false}},{"name":"value","type":{"kind":"simple","type":"int","optional":false,"format":257}},{"name":"mode","type":{"kind":"simple","type":"int","optional":false,"format":257}},{"name":"body","type":{"kind":"simple","type":"cell","optional":true}},{"name":"code","type":{"kind":"simple","type":"cell","optional":true}},{"name":"data","type":{"kind":"simple","type":"cell","optional":true}}]},{"name":"Deploy","header":2490013878,"fields":[{"name":"queryId","type":{"kind":"simple","type":"uint","optional":false,"format":64}}]},{"name":"DeployOk","header":2952335191,"fields":[{"name":"queryId","type":{"kind":"simple","type":"uint","optional":false,"format":64}}]},{"name":"FactoryDeploy","header":1829761339,"fields":[{"name":"queryId","type":{"kind":"simple","type":"uint","optional":false,"format":64}},{"name":"cashback","type":{"kind":"simple","type":"address","optional":false}}]},{"name":"ChangeOwner","header":2174598809,"fields":[{"name":"queryId","type":{"kind":"simple","type":"uint","optional":false,"format":64}},{"name":"newOwner","type":{"kind":"simple","type":"address","optional":false}}]},{"name":"ChangeOwnerOk","header":846932810,"fields":[{"name":"queryId","type":{"kind":"simple","type":"uint","optional":false,"format":64}},{"name":"newOwner","type":{"kind":"simple","type":"address","optional":false}}]},{"name":"RenounceOwnership","header":472825648,"fields":[{"name":"queryId","type":{"kind":"simple","type":"uint","optional":false,"format":64}}]}],"receivers":[{"receiver":"internal","message":{"kind":"text","text":"test"}},{"receiver":"internal","message":{"kind":"typed","type":"ChangeOwner"}},{"receiver":"internal","message":{"kind":"typed","type":"RenounceOwnership"}}],"getters":[{"name":"owner","arguments":[],"returnType":{"kind":"simple","type":"address","optional":false}}],"errors":{"2":{"message":"Stack undeflow"},"3":{"message":"Stack overflow"},"4":{"message":"Integer overflow"},"5":{"message":"Integer out of expected range"},"6":{"message":"Invalid opcode"},"7":{"message":"Type check error"},"8":{"message":"Cell overflow"},"9":{"message":"Cell underflow"},"10":{"message":"Dictionary error"},"13":{"message":"Out of gas error"},"32":{"message":"Method ID not found"},"34":{"message":"Action is invalid or not supported"},"37":{"message":"Not enough TON"},"38":{"message":"Not enough extra-currencies"},"128":{"message":"Null reference exception"},"129":{"message":"Invalid serialization prefix"},"130":{"message":"Invalid incoming message"},"131":{"message":"Constraints error"},"132":{"message":"Access denied"},"133":{"message":"Contract stopped"},"134":{"message":"Invalid argument"},"135":{"message":"Code of a contract was not found"},"136":{"message":"Invalid address"},"137":{"message":"Masterchain support is not enabled for this contract"}},"interfaces":["org.ton.introspection.v0","org.ton.abi.ipfs.v0","org.ton.deploy.lazy.v0","org.ton.debug.v0","org.ton.chain.workchain.v0","org.ton.ownable.transferable.v3","org.ton.ownable"]} \ No newline at end of file diff --git a/src/test/features/output/ownabletransferable_OwnableTransferableTest.code.boc b/src/test/features/output/ownabletransferable_OwnableTransferableTest.code.boc new file mode 100644 index 0000000000000000000000000000000000000000..f2f09e92a7f2254c290e78c6e20600fcd583f070 GIT binary patch literal 1081 zcmdn`ZcY&+lPDtti!KAB$bW_}ON77d`E-Jtk%=*hiJ9r#1;z`PnHdW=EN1-Wz^HKD zvyqW|*QW;^3fH;06dGCn@A`D1vzZel5)u&1oX_$jk?BX$ZJWs3HlH3eo%rF*c&485 z6a!w3=fzIG4dG*9VpQPaWq$Q`(c9mQlMLz~6ewQzJS0EW0BDo^J%uKL#<}}u?t07w zWXb65H`vuT)!?!`Bb4*$LE~k6M#I}S^$!j(^sW8L*!1D&PRI5#jYY=GB_C>v@J+ri z_c|(d-K+S$V!yd(ePQsKva7EZsQk9!gNX)@3Rv0LnQlSM16u<&kAQ!La)g*}+ZZUG zh-?xts@C=jU_LE>+MbY4e>gGL=K?Ke=VUs>2-IGnaH5FuG-CndX$GNF?5F>qynru^ zNmDJv&cPt`!zoDMIP0eeEsR-Yxs;R9DmPatZ}ZG(g}hG}8uFDGCmKBxP$^($X>bZq zzHP(Bc{j`y;)u;RS#gu2L zGqJ`n?qDmk^m*F6>PbbhC-bhXKw?ZyjUrrmVQ z>+(=%`=C41ych z?+!FEX<$fTDBYCz*g0%ETe|V0PhZ8ZvYTvaE>>=CZxbzTxt_A5xovX0*q5?p?#^Y) XMAO_t!b3u~rn@c)U)pNUoS^^!F5TJ2 literal 0 HcmV?d00001 diff --git a/src/test/features/output/ownabletransferable_OwnableTransferableTest.code.fc b/src/test/features/output/ownabletransferable_OwnableTransferableTest.code.fc new file mode 100644 index 000000000..99f015eb6 --- /dev/null +++ b/src/test/features/output/ownabletransferable_OwnableTransferableTest.code.fc @@ -0,0 +1,154 @@ +#pragma version =0.4.3; +#pragma allow-post-modification; +#pragma compute-asm-ltr; + +#include "ownabletransferable_OwnableTransferableTest.headers.fc"; +#include "ownabletransferable_OwnableTransferableTest.stdlib.fc"; +#include "ownabletransferable_OwnableTransferableTest.storage.fc"; + +;; +;; Contract OwnableTransferableTest functions +;; + +(slice) $OwnableTransferableTest$_contract_init(slice $owner) impure inline_ref { + var (($self'owner)) = (null()); + $self'owner = $owner; + return ($self'owner); +} + +((slice), ()) $OwnableTransferableTest$_fun_requireOwner((slice) $self) impure inline_ref { + var (($self'owner)) = $self; + throw_unless(132, ( __tact_slice_eq_bits($self'owner, __tact_context_get_sender()) )); + return (($self'owner), ()); +} + +((slice), slice) $OwnableTransferableTest$_fun_owner((slice) $self) impure inline_ref { + var (($self'owner)) = $self; + return (($self'owner), $self'owner); +} + +;; +;; Receivers of a Contract OwnableTransferableTest +;; + +((slice), ()) $OwnableTransferableTest$_internal_text_f9b941877628a233a719e129140e93df1eeb5a65aeea5fbd16fb0b9af4004c94((slice) $self) impure inline { + var ($self'owner) = $self; + ($self'owner)~$OwnableTransferableTest$_fun_requireOwner(); + return (($self'owner), ()); +} + +(((slice)), ()) $OwnableTransferableTest$_internal_binary_ChangeOwner((slice) $self, (int, slice) $msg) impure inline { + var ($self'owner) = $self; + var ($msg'queryId, $msg'newOwner) = $msg; + ($self'owner)~$OwnableTransferableTest$_fun_requireOwner(); + $self'owner = $msg'newOwner; + ($self'owner)~$OwnableTransferableTest$_fun_reply($ChangeOwnerOk$_store_cell($ChangeOwnerOk$_constructor_queryId_newOwner($msg'queryId, $msg'newOwner))); + return (($self'owner), ()); +} + +(((slice)), ()) $OwnableTransferableTest$_internal_binary_RenounceOwnership((slice) $self, (int) $msg) impure inline { + var ($self'owner) = $self; + var ($msg'queryId) = $msg; + ($self'owner)~$OwnableTransferableTest$_fun_requireOwner(); + $self'owner = __tact_create_address(0, 0); + ($self'owner)~$OwnableTransferableTest$_fun_reply($ChangeOwnerOk$_store_cell($ChangeOwnerOk$_constructor_queryId_newOwner($msg'queryId, __tact_create_address(0, 0)))); + return (($self'owner), ()); +} + +;; +;; Get methods of a Contract OwnableTransferableTest +;; + +_ %owner() method_id(83229) { + var self = $OwnableTransferableTest$_contract_load(); + var res = self~$OwnableTransferableTest$_fun_owner(); + return res; +} + +_ supported_interfaces() method_id { + return ( + "org.ton.introspection.v0"H >> 128, + "org.ton.abi.ipfs.v0"H >> 128, + "org.ton.deploy.lazy.v0"H >> 128, + "org.ton.debug.v0"H >> 128, + "org.ton.chain.workchain.v0"H >> 128, + "org.ton.ownable.transferable.v3"H >> 128, + "org.ton.ownable"H >> 128 + ); +} + +_ get_abi_ipfs() method_id { + return "ipfs://QmPsKH7288xaWXMvJH8i8qoGjdt7jaVdeEuEKVtZEzXSp6"; +} + +_ lazy_deployment_completed() method_id { + return get_data().begin_parse().load_int(1); +} + +;; +;; Routing of a Contract OwnableTransferableTest +;; + +((slice), int) $OwnableTransferableTest$_contract_router_internal((slice) self, int msg_bounced, slice in_msg) impure inline_ref { + ;; Handle bounced messages + if (msg_bounced) { + return (self, true); + } + + ;; Parse incoming message + int op = 0; + if (slice_bits(in_msg) >= 32) { + op = in_msg.preload_uint(32); + } + + + ;; Receive ChangeOwner message + if (op == 2174598809) { + var msg = in_msg~$ChangeOwner$_load(); + self~$OwnableTransferableTest$_internal_binary_ChangeOwner(msg); + return (self, true); + } + + ;; Receive RenounceOwnership message + if (op == 472825648) { + var msg = in_msg~$RenounceOwnership$_load(); + self~$OwnableTransferableTest$_internal_binary_RenounceOwnership(msg); + return (self, true); + } + + ;; Text Receivers + if (op == 0) { + var text_op = slice_hash(in_msg); + + ;; Receive "test" message + if (text_op == 0xf9b941877628a233a719e129140e93df1eeb5a65aeea5fbd16fb0b9af4004c94) { + self~$OwnableTransferableTest$_internal_text_f9b941877628a233a719e129140e93df1eeb5a65aeea5fbd16fb0b9af4004c94(); + return (self, true); + } + } + + return (self, false); +} + +() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure { + + ;; Context + var cs = in_msg_cell.begin_parse(); + var msg_flags = cs~load_uint(4); + var msg_bounced = -(msg_flags & 1); + slice msg_sender_addr = __tact_verify_address(cs~load_msg_addr()); + __tact_context = (msg_bounced, msg_sender_addr, msg_value, cs); + __tact_context_sender = msg_sender_addr; + + ;; Load contract data + var self = $OwnableTransferableTest$_contract_load(); + + ;; Handle operation + int handled = self~$OwnableTransferableTest$_contract_router_internal(msg_bounced, in_msg); + + ;; Throw if not handled + throw_unless(130, handled); + + ;; Persist state + $OwnableTransferableTest$_contract_store(self); +} diff --git a/src/test/features/output/ownabletransferable_OwnableTransferableTest.code.fif b/src/test/features/output/ownabletransferable_OwnableTransferableTest.code.fif new file mode 100644 index 000000000..133a32361 --- /dev/null +++ b/src/test/features/output/ownabletransferable_OwnableTransferableTest.code.fif @@ -0,0 +1,461 @@ +PROGRAM{ + DECLPROC __tact_verify_address + DECLPROC __tact_load_address + DECLPROC __tact_store_address + DECLPROC __tact_create_address + DECLPROC __tact_my_balance + DECLPROC __tact_not_null + DECLPROC __tact_context_get + DECLPROC __tact_context_get_sender + DECLPROC __tact_store_bool + DECLPROC __tact_slice_eq_bits + DECLPROC $ChangeOwner$_load + DECLPROC $ChangeOwnerOk$_store + DECLPROC $ChangeOwnerOk$_store_cell + DECLPROC $RenounceOwnership$_load + DECLPROC $OwnableTransferableTest$_store + DECLPROC $OwnableTransferableTest$_load + DECLPROC $StateInit$_not_null + DECLPROC $OwnableTransferableTest$init$_load + DECLPROC $OwnableTransferableTest$_contract_init + DECLPROC $OwnableTransferableTest$_contract_load + DECLPROC $OwnableTransferableTest$_contract_store + DECLPROC $global_send + DECLPROC $SendParameters$_constructor_bounce_to_value_mode_body_code_data + DECLPROC $OwnableTransferableTest$_fun_forward + DECLPROC $OwnableTransferableTest$_fun_reply + DECLPROC $OwnableTransferableTest$_fun_requireOwner + DECLPROC $OwnableTransferableTest$_fun_owner + DECLPROC $ChangeOwnerOk$_constructor_queryId_newOwner + DECLPROC $OwnableTransferableTest$_internal_text_f9b941877628a233a719e129140e93df1eeb5a65aeea5fbd16fb0b9af4004c94 + DECLPROC $OwnableTransferableTest$_internal_binary_ChangeOwner + DECLPROC $OwnableTransferableTest$_internal_binary_RenounceOwnership + 83229 DECLMETHOD %owner + 113617 DECLMETHOD supported_interfaces + 121275 DECLMETHOD get_abi_ipfs + 115390 DECLMETHOD lazy_deployment_completed + DECLPROC $OwnableTransferableTest$_contract_router_internal + DECLPROC recv_internal + DECLGLOBVAR __tact_context + DECLGLOBVAR __tact_context_sender + DECLGLOBVAR __tact_context_sys + DECLGLOBVAR __tact_randomized + __tact_verify_address PROCINLINE:<{ + DUP + SBITS + 267 PUSHINT + EQUAL + 136 THROWIFNOT + DUP + 11 PLDU + DUP + 1279 PUSHINT + EQUAL + 137 THROWIF + 10 PUSHPOW2 + EQUAL + 136 THROWIFNOT + }> + __tact_load_address PROCINLINE:<{ + LDMSGADDR + SWAP + __tact_verify_address INLINECALLDICT + }> + __tact_store_address PROCINLINE:<{ + __tact_verify_address INLINECALLDICT + STSLICER + }> + __tact_create_address PROCINLINE:<{ + NEWC + 2 PUSHINT + SWAP + 2 STU + 0 PUSHINT + SWAP + 1 STU + s1 s2 XCHG + 8 STI + 256 STU + ENDC + CTOS + __tact_verify_address INLINECALLDICT + }> + __tact_my_balance PROCINLINE:<{ + BALANCE + FIRST + }> + __tact_not_null PROCINLINE:<{ + DUP + ISNULL + 128 THROWIF + }> + __tact_context_get PROCINLINE:<{ + __tact_context GETGLOB + 4 UNTUPLE + }> + __tact_context_get_sender PROCINLINE:<{ + __tact_context_sender GETGLOB + }> + __tact_store_bool PROCINLINE:<{ + SWAP + 1 STI + }> + __tact_slice_eq_bits PROCINLINE:<{ + SDEQ + }> + $ChangeOwner$_load PROCINLINE:<{ + 32 LDU + SWAP + 2174598809 PUSHINT + EQUAL + 129 THROWIFNOT + 64 LDU + __tact_load_address INLINECALLDICT + s1 s2 XCHG + }> + $ChangeOwnerOk$_store PROCINLINE:<{ + 846932810 PUSHINT + s0 s3 XCHG2 + 32 STU + 64 STU + SWAP + __tact_store_address INLINECALLDICT + }> + $ChangeOwnerOk$_store_cell PROCINLINE:<{ + NEWC + -ROT + $ChangeOwnerOk$_store INLINECALLDICT + ENDC + }> + $RenounceOwnership$_load PROCINLINE:<{ + 32 LDU + SWAP + 472825648 PUSHINT + EQUAL + 129 THROWIFNOT + 64 LDU + SWAP + }> + $OwnableTransferableTest$_store PROCINLINE:<{ + __tact_store_address INLINECALLDICT + }> + $OwnableTransferableTest$_load PROCINLINE:<{ + __tact_load_address INLINECALLDICT + }> + $StateInit$_not_null PROCINLINE:<{ + DUP + ISNULL + 128 THROWIF + 2 UNTUPLE + }> + $OwnableTransferableTest$init$_load PROCINLINE:<{ + __tact_load_address INLINECALLDICT + }> + $OwnableTransferableTest$_contract_init PROCREF:<{ + }> + $OwnableTransferableTest$_contract_load PROCREF:<{ + c4 PUSH + CTOS + LDREF + SWAP + __tact_context_sys SETGLOB + 1 LDI + SWAP + IFJMP:<{ + $OwnableTransferableTest$_load INLINECALLDICT + NIP + }> + MYADDR + 11 PLDU + 10 PUSHPOW2 + EQUAL + 137 THROWIFNOT + $OwnableTransferableTest$init$_load INLINECALLDICT + SWAP + ENDS + $OwnableTransferableTest$_contract_init INLINECALLDICT + }> + $OwnableTransferableTest$_contract_store PROCINLINE:<{ + NEWC + __tact_context_sys GETGLOB + SWAP + STREF + TRUE + SWAP + 1 STI + SWAP + $OwnableTransferableTest$_store INLINECALLDICT + ENDC + c4 POP + }> + $global_send PROCREF:<{ + NEWC + 1 PUSHINT + SWAP + 2 STI + s0 s7 XCHG2 + __tact_store_bool INLINECALLDICT + 0 PUSHINT + SWAP + 3 STI + s0 s5 XCHG2 + __tact_store_address INLINECALLDICT + s0 s3 XCHG2 + STGRAMS + 0 PUSHINT + SWAP + 105 STI + s3 PUSH + ISNULL + NOT + IF:<{ + TRUE + }>ELSE<{ + s4 PUSH + ISNULL + NOT + }> + IF:<{ + TRUE + __tact_store_bool INLINECALLDICT + NEWC + FALSE + __tact_store_bool INLINECALLDICT + FALSE + __tact_store_bool INLINECALLDICT + s4 PUSH + ISNULL + NOT + IF:<{ + TRUE + __tact_store_bool INLINECALLDICT + s0 s4 XCHG + __tact_not_null INLINECALLDICT + s0 s4 XCHG2 + STREF + }>ELSE<{ + s4 POP + s0 s3 XCHG + FALSE + __tact_store_bool INLINECALLDICT + }> + s4 PUSH + ISNULL + NOT + IF:<{ + TRUE + __tact_store_bool INLINECALLDICT + s0 s4 XCHG + __tact_not_null INLINECALLDICT + s0 s4 XCHG2 + STREF + }>ELSE<{ + s4 POP + s0 s3 XCHG + FALSE + __tact_store_bool INLINECALLDICT + }> + FALSE + __tact_store_bool INLINECALLDICT + s0 s2 XCHG + TRUE + __tact_store_bool INLINECALLDICT + s0 s2 XCHG + ENDC + ROT + STREF + }>ELSE<{ + s3 POP + s3 POP + SWAP + FALSE + __tact_store_bool INLINECALLDICT + }> + OVER + ISNULL + NOT + IF:<{ + TRUE + __tact_store_bool INLINECALLDICT + SWAP + __tact_not_null INLINECALLDICT + SWAP + STREF + }>ELSE<{ + NIP + FALSE + __tact_store_bool INLINECALLDICT + }> + ENDC + SWAP + SENDRAWMSG + }> + $SendParameters$_constructor_bounce_to_value_mode_body_code_data PROCINLINE:<{ + }> + $OwnableTransferableTest$_fun_forward PROCREF:<{ + PUSHNULL + PUSHNULL + s2 PUSH + ISNULL + NOT + IF:<{ + 2DROP + $StateInit$_not_null INLINECALLDICT + SWAP + }>ELSE<{ + s2 POP + }> + s2 s4 XCHG + 0 PUSHINT + s0 s3 XCHG + s0 s4 XCHG + 66 PUSHINT + s2 s3 XCHG2 + $SendParameters$_constructor_bounce_to_value_mode_body_code_data INLINECALLDICT + $global_send INLINECALLDICT + }> + $OwnableTransferableTest$_fun_reply PROCINLINE:<{ + __tact_context_get_sender INLINECALLDICT + SWAP + TRUE + PUSHNULL + $OwnableTransferableTest$_fun_forward INLINECALLDICT + }> + $OwnableTransferableTest$_fun_requireOwner PROCREF:<{ + __tact_context_get_sender INLINECALLDICT + s1 s(-1) PUXC + __tact_slice_eq_bits INLINECALLDICT + 132 THROWIFNOT + }> + $OwnableTransferableTest$_fun_owner PROCREF:<{ + DUP + }> + $ChangeOwnerOk$_constructor_queryId_newOwner PROCINLINE:<{ + }> + $OwnableTransferableTest$_internal_text_f9b941877628a233a719e129140e93df1eeb5a65aeea5fbd16fb0b9af4004c94 PROCINLINE:<{ + $OwnableTransferableTest$_fun_requireOwner INLINECALLDICT + }> + $OwnableTransferableTest$_internal_binary_ChangeOwner PROCINLINE:<{ + s0 s2 XCHG + $OwnableTransferableTest$_fun_requireOwner INLINECALLDICT + DROP + OVER + $ChangeOwnerOk$_constructor_queryId_newOwner INLINECALLDICT + $ChangeOwnerOk$_store_cell INLINECALLDICT + $OwnableTransferableTest$_fun_reply INLINECALLDICT + }> + $OwnableTransferableTest$_internal_binary_RenounceOwnership PROCINLINE:<{ + SWAP + $OwnableTransferableTest$_fun_requireOwner INLINECALLDICT + DROP + 0 PUSHINT + DUP + __tact_create_address INLINECALLDICT + 0 PUSHINT + DUP + __tact_create_address INLINECALLDICT + s1 s2 XCHG + $ChangeOwnerOk$_constructor_queryId_newOwner INLINECALLDICT + $ChangeOwnerOk$_store_cell INLINECALLDICT + $OwnableTransferableTest$_fun_reply INLINECALLDICT + }> + %owner PROC:<{ + $OwnableTransferableTest$_contract_load INLINECALLDICT + $OwnableTransferableTest$_fun_owner INLINECALLDICT + NIP + }> + supported_interfaces PROC:<{ + 123515602279859691144772641439386770278 PUSHINT + 209801025412363888721030803524359905849 PUSHINT + 42980537499636128163026532310500881091 PUSHINT + 36993126140238121407019133875791708966 PUSHINT + 209474421377847335869795010607481022628 PUSHINT + 148742796757272343909467377803502087808 PUSHINT + 86142586315491086060343270784266291122 PUSHINT + }> + get_abi_ipfs PROC:<{ + x{697066733a2f2f516d50734b4837323838786157584d764a48386938716f476a6474376a615664654575454b56745a457a58537036} PUSHSLICE + }> + lazy_deployment_completed PROC:<{ + c4 PUSH + CTOS + 1 LDI + SWAP + }> + $OwnableTransferableTest$_contract_router_internal PROCREF:<{ + c2 SAVE + SAMEALTSAVE + SWAP + IFJMP:<{ + DROP + TRUE + }> + 0 PUSHINT + OVER + SBITS + 31 GTINT + IF:<{ + DROP + DUP + 32 PLDU + }> + DUP + 2174598809 PUSHINT + EQUAL + IFJMP:<{ + DROP + $ChangeOwner$_load INLINECALLDICT + 1 2 BLKDROP2 + $OwnableTransferableTest$_internal_binary_ChangeOwner INLINECALLDICT + TRUE + }> + DUP + 472825648 PUSHINT + EQUAL + IFJMP:<{ + DROP + $RenounceOwnership$_load INLINECALLDICT + NIP + $OwnableTransferableTest$_internal_binary_RenounceOwnership INLINECALLDICT + TRUE + }> + 0 EQINT + IF:<{ + HASHSU + 112953218269766239368568806868099996543351823903886692441276002410189996182676 PUSHINT + EQUAL + IFJMP:<{ + $OwnableTransferableTest$_internal_text_f9b941877628a233a719e129140e93df1eeb5a65aeea5fbd16fb0b9af4004c94 INLINECALLDICT + TRUE + RETALT + }> + }>ELSE<{ + DROP + }> + FALSE + }> + recv_internal PROC:<{ + SWAP + CTOS + 4 LDU + SWAP + 1 PUSHINT + AND + NEGATE + SWAP + LDMSGADDR + SWAP + __tact_verify_address INLINECALLDICT + s0 s4 s2 PUXCPU + s0 s3 XCHG + 4 TUPLE + __tact_context SETGLOB + s0 s2 XCHG + __tact_context_sender SETGLOB + $OwnableTransferableTest$_contract_load INLINECALLDICT + -ROT + $OwnableTransferableTest$_contract_router_internal INLINECALLDICT + 130 THROWIFNOT + $OwnableTransferableTest$_contract_store INLINECALLDICT + }> +}END>c diff --git a/src/test/features/output/ownabletransferable_OwnableTransferableTest.code.rev.fif b/src/test/features/output/ownabletransferable_OwnableTransferableTest.code.rev.fif new file mode 100644 index 000000000..3d1e0db24 --- /dev/null +++ b/src/test/features/output/ownabletransferable_OwnableTransferableTest.code.rev.fif @@ -0,0 +1,536 @@ +PROGRAM{ + DECLPROC recv_internal; + DECLPROC owner; + DECLPROC supported_interfaces; + DECLPROC lazy_deployment_completed; + DECLPROC get_abi_ipfs; + DECLPROC ?fun_ref_40d98146a47dbe3b; + DECLPROC ?fun_ref_5b04ea3c5a05dfa7; + DECLPROC ?fun_ref_b93b9862cda1783c; + DECLPROC ?fun_ref_ddedd9ef5a577d75; + DECLPROC ?fun_ref_e31d986f279fa0fb; + DECLPROC ?fun_ref_ed0c6f0c0e19c38a; + DECLPROC ?fun_ref_f171cd1f30aaaa1c; + recv_internal PROC:<{ + s0 s1 XCHG + CTOS + 4 LDU + s0 s1 XCHG + 1 PUSHINT + AND + -1 MULCONST + s0 s1 XCHG + LDMSGADDR + s0 s1 XCHG + s0 PUSH + SBITS + 267 PUSHINT + EQUAL + 136 THROWIFNOT + s0 PUSH + 11 PLDU + s0 PUSH + 1279 PUSHINT + EQUAL + 137 THROWIF + 10 PUSHPOW2 + EQUAL + 136 THROWIFNOT + s0 s6 s4 PUXCPU + s0 s3 XCHG + 4 TUPLE + 1 SETGLOBVAR + s0 s2 XCHG + 2 SETGLOBVAR + ?fun_ref_ed0c6f0c0e19c38a INLINECALLDICT + ROTREV + ?fun_ref_5b04ea3c5a05dfa7 INLINECALLDICT + 130 THROWIFNOT + NEWC + 3 GETGLOBVAR + s0 s1 XCHG + STREF + -1 PUSHINT + s0 s1 XCHG + 1 STI + s0 s1 XCHG + s0 PUSH + SBITS + 267 PUSHINT + EQUAL + 136 THROWIFNOT + s0 PUSH + 11 PLDU + s0 PUSH + 1279 PUSHINT + EQUAL + 137 THROWIF + 10 PUSHPOW2 + EQUAL + 136 THROWIFNOT + STSLICER + ENDC + c4 POP + }> + owner PROC:<{ + ?fun_ref_ed0c6f0c0e19c38a INLINECALLDICT + ?fun_ref_40d98146a47dbe3b INLINECALLDICT + s1 POP + }> + supported_interfaces PROC:<{ + 123515602279859691144772641439386770278 PUSHINT + 209801025412363888721030803524359905849 PUSHINT + 42980537499636128163026532310500881091 PUSHINT + 36993126140238121407019133875791708966 PUSHINT + 209474421377847335869795010607481022628 PUSHINT + 148742796757272343909467377803502087808 PUSHINT + 86142586315491086060343270784266291122 PUSHINT + }> + lazy_deployment_completed PROC:<{ + c4 PUSH + CTOS + 1 LDI + s0 s1 XCHG + }> + get_abi_ipfs PROC:<{ + x{697066733A2F2F516D50734B4837323838786157584D764A48386938716F476A6474376A615664654575454B56745A457A5853703682_} PUSHSLICE + }> + ?fun_ref_40d98146a47dbe3b PROCREF:<{ + s0 PUSH + }> + ?fun_ref_5b04ea3c5a05dfa7 PROCREF:<{ + 2 SAVE + SAMEALTSAVE + s0 s1 XCHG + <{ + s0 POP + -1 PUSHINT + }> PUSHCONT + IFJMP + 0 PUSHINT + s1 PUSH + SBITS + 31 GTINT + <{ + s0 POP + s0 PUSH + 32 PLDU + }> PUSHCONT + IF + s0 PUSH + 2174598809 PUSHINT + EQUAL + <{ + s0 POP + 32 LDU + s0 s1 XCHG + 2174598809 PUSHINT + EQUAL + 129 THROWIFNOT + 64 LDU + LDMSGADDR + s0 s1 XCHG + s0 PUSH + SBITS + 267 PUSHINT + EQUAL + 136 THROWIFNOT + s0 PUSH + 11 PLDU + s0 PUSH + 1279 PUSHINT + EQUAL + 137 THROWIF + 10 PUSHPOW2 + EQUAL + 136 THROWIFNOT + s1 s2 XCHG + 1 2 BLKDROP2 + s0 s2 XCHG + ?fun_ref_f171cd1f30aaaa1c INLINECALLDICT + s0 POP + s1 PUSH + NEWC + ROTREV + 846932810 PUSHINT + s0 s3 XCHG2 + 32 STU + 64 STU + s0 s1 XCHG + s0 PUSH + SBITS + 267 PUSHINT + EQUAL + 136 THROWIFNOT + s0 PUSH + 11 PLDU + s0 PUSH + 1279 PUSHINT + EQUAL + 137 THROWIF + 10 PUSHPOW2 + EQUAL + 136 THROWIFNOT + STSLICER + ENDC + 2 GETGLOBVAR + s0 s1 XCHG + -1 PUSHINT + NULL + ?fun_ref_e31d986f279fa0fb INLINECALLDICT + -1 PUSHINT + }> IFJMPREF + s0 PUSH + 472825648 PUSHINT + EQUAL + <{ + s0 POP + 32 LDU + s0 s1 XCHG + 472825648 PUSHINT + EQUAL + 129 THROWIFNOT + 64 LDU + s0 s1 XCHG + s1 POP + ?fun_ref_ddedd9ef5a577d75 INLINECALLDICT + -1 PUSHINT + }> PUSHCONT + IFJMP + 0 EQINT + <{ + HASHSU + 112953218269766239368568806868099996543351823903886692441276002410189996182676 PUSHINT + EQUAL + <{ + ?fun_ref_f171cd1f30aaaa1c INLINECALLDICT + -1 PUSHINT + RETFALSE + }> PUSHCONT + IFJMP + }> PUSHCONT + <{ + s0 POP + }> PUSHCONT + IFELSE + 0 PUSHINT + }> + ?fun_ref_b93b9862cda1783c PROCREF:<{ + NEWC + 1 PUSHINT + s0 s1 XCHG + 2 STI + s0 s7 XCHG2 + s0 s1 XCHG + 1 STI + 0 PUSHINT + s0 s1 XCHG + 3 STI + s0 s5 XCHG2 + s0 PUSH + SBITS + 267 PUSHINT + EQUAL + 136 THROWIFNOT + s0 PUSH + 11 PLDU + s0 PUSH + 1279 PUSHINT + EQUAL + 137 THROWIF + 10 PUSHPOW2 + EQUAL + 136 THROWIFNOT + STSLICER + s0 s3 XCHG2 + STGRAMS + 0 PUSHINT + s0 s1 XCHG + 105 STI + s3 PUSH + ISNULL + NOT + <{ + -1 PUSHINT + }> PUSHCONT + <{ + s4 PUSH + ISNULL + NOT + }> PUSHCONT + IFELSE + <{ + s3 POP + s3 POP + s0 s1 XCHG + 0 PUSHINT + s0 s1 XCHG + 1 STI + }> PUSHCONT + <{ + -1 PUSHINT + s0 s1 XCHG + 1 STI + NEWC + 0 PUSHINT + s0 s1 XCHG + 1 STI + 0 PUSHINT + s0 s1 XCHG + 1 STI + s4 PUSH + ISNULL + NOT + <{ + -1 PUSHINT + s0 s1 XCHG + 1 STI + s0 s4 XCHG + s0 PUSH + ISNULL + 128 THROWIF + s0 s4 XCHG2 + STREF + }> PUSHCONT + <{ + s4 POP + s0 s3 XCHG + 0 PUSHINT + s0 s1 XCHG + 1 STI + }> PUSHCONT + IFELSE + s4 PUSH + ISNULL + NOT + <{ + -1 PUSHINT + s0 s1 XCHG + 1 STI + s0 s4 XCHG + s0 PUSH + ISNULL + 128 THROWIF + s0 s4 XCHG2 + STREF + }> PUSHCONT + <{ + s4 POP + s0 s3 XCHG + 0 PUSHINT + s0 s1 XCHG + 1 STI + }> PUSHCONT + IFELSE + 0 PUSHINT + s0 s1 XCHG + 1 STI + s0 s2 XCHG + -1 PUSHINT + s0 s1 XCHG + 1 STI + s0 s2 XCHG + ENDC + ROT + STREF + }> IFREFELSE + s1 PUSH + ISNULL + NOT + <{ + -1 PUSHINT + s0 s1 XCHG + 1 STI + s0 s1 XCHG + s0 PUSH + ISNULL + 128 THROWIF + s0 s1 XCHG + STREF + }> PUSHCONT + <{ + s1 POP + 0 PUSHINT + s0 s1 XCHG + 1 STI + }> PUSHCONT + IFELSE + ENDC + s0 s1 XCHG + SENDRAWMSG + }> + ?fun_ref_ddedd9ef5a577d75 PROCREF:<{ + s0 s1 XCHG + ?fun_ref_f171cd1f30aaaa1c INLINECALLDICT + s0 POP + 0 PUSHINT + s0 PUSH + NEWC + 2 PUSHINT + s0 s1 XCHG + 2 STU + 0 PUSHINT + s0 s1 XCHG + 1 STU + s1 s2 XCHG + 8 STI + 256 STU + ENDC + CTOS + s0 PUSH + SBITS + 267 PUSHINT + EQUAL + 136 THROWIFNOT + s0 PUSH + 11 PLDU + s0 PUSH + 1279 PUSHINT + EQUAL + 137 THROWIF + 10 PUSHPOW2 + EQUAL + 136 THROWIFNOT + 0 PUSHINT + s0 PUSH + NEWC + 2 PUSHINT + s0 s1 XCHG + 2 STU + 0 PUSHINT + s0 s1 XCHG + 1 STU + s1 s2 XCHG + 8 STI + 256 STU + ENDC + CTOS + s0 PUSH + SBITS + 267 PUSHINT + EQUAL + 136 THROWIFNOT + s0 PUSH + 11 PLDU + s0 PUSH + 1279 PUSHINT + EQUAL + 137 THROWIF + 10 PUSHPOW2 + EQUAL + 136 THROWIFNOT + s1 s2 XCHG + NEWC + ROTREV + 846932810 PUSHINT + s0 s3 XCHG2 + 32 STU + 64 STU + s0 s1 XCHG + s0 PUSH + SBITS + 267 PUSHINT + EQUAL + 136 THROWIFNOT + s0 PUSH + 11 PLDU + s0 PUSH + 1279 PUSHINT + EQUAL + 137 THROWIF + 10 PUSHPOW2 + EQUAL + 136 THROWIFNOT + STSLICER + ENDC + 2 GETGLOBVAR + s0 s1 XCHG + -1 PUSHINT + NULL + ?fun_ref_e31d986f279fa0fb INLINECALLDICT + }> + ?fun_ref_e31d986f279fa0fb PROCREF:<{ + NULL + NULL + s2 PUSH + ISNULL + NOT + <{ + DROP2 + s0 PUSH + ISNULL + 128 THROWIF + 2 UNTUPLE + s0 s1 XCHG + }> PUSHCONT + <{ + s2 POP + }> PUSHCONT + IFELSE + s2 s4 XCHG + 0 PUSHINT + s0 s3 XCHG + s0 s4 XCHG + 66 PUSHINT + s2 s3 XCHG2 + ?fun_ref_b93b9862cda1783c INLINECALLDICT + }> + ?fun_ref_ed0c6f0c0e19c38a PROCREF:<{ + c4 PUSH + CTOS + LDREF + s0 s1 XCHG + 3 SETGLOBVAR + 1 LDI + s0 s1 XCHG + <{ + LDMSGADDR + s0 s1 XCHG + s0 PUSH + SBITS + 267 PUSHINT + EQUAL + 136 THROWIFNOT + s0 PUSH + 11 PLDU + s0 PUSH + 1279 PUSHINT + EQUAL + 137 THROWIF + 10 PUSHPOW2 + EQUAL + 136 THROWIFNOT + s1 POP + }> PUSHCONT + IFJMP + MYADDR + 11 PLDU + 10 PUSHPOW2 + EQUAL + 137 THROWIFNOT + LDMSGADDR + s0 s1 XCHG + s0 PUSH + SBITS + 267 PUSHINT + EQUAL + 136 THROWIFNOT + s0 PUSH + 11 PLDU + s0 PUSH + 1279 PUSHINT + EQUAL + 137 THROWIF + 10 PUSHPOW2 + EQUAL + 136 THROWIFNOT + s0 s1 XCHG + ENDS + }> + ?fun_ref_f171cd1f30aaaa1c PROCREF:<{ + 2 GETGLOBVAR + s1 s1 PUXC + SDEQ + 132 THROWIFNOT + }> +}END>c \ No newline at end of file diff --git a/src/test/features/output/ownabletransferable_OwnableTransferableTest.headers.fc b/src/test/features/output/ownabletransferable_OwnableTransferableTest.headers.fc new file mode 100644 index 000000000..0e31366bb --- /dev/null +++ b/src/test/features/output/ownabletransferable_OwnableTransferableTest.headers.fc @@ -0,0 +1,88 @@ +;; +;; Header files for OwnableTransferableTest +;; NOTE: declarations are sorted for optimal order +;; + +;; __tact_verify_address +slice __tact_verify_address(slice address) inline; + +;; __tact_load_address +(slice, slice) __tact_load_address(slice cs) inline; + +;; __tact_store_address +builder __tact_store_address(builder b, slice address) inline; + +;; __tact_create_address +slice __tact_create_address(int chain, int hash) inline; + +;; __tact_my_balance +int __tact_my_balance() inline; + +;; __tact_not_null +forall X -> X __tact_not_null(X x) inline; + +;; __tact_context_get +(int, slice, int, slice) __tact_context_get() inline; + +;; __tact_context_get_sender +slice __tact_context_get_sender() inline; + +;; __tact_store_bool +builder __tact_store_bool(builder b, int v) inline; + +;; __tact_slice_eq_bits +int __tact_slice_eq_bits(slice a, slice b) inline; + +;; $ChangeOwner$_load +(slice, ((int, slice))) $ChangeOwner$_load(slice sc_0) inline; + +;; $ChangeOwnerOk$_store +builder $ChangeOwnerOk$_store(builder build_0, (int, slice) v) inline; + +;; $ChangeOwnerOk$_store_cell +cell $ChangeOwnerOk$_store_cell((int, slice) v) inline; + +;; $RenounceOwnership$_load +(slice, ((int))) $RenounceOwnership$_load(slice sc_0) inline; + +;; $OwnableTransferableTest$_store +builder $OwnableTransferableTest$_store(builder build_0, (slice) v) inline; + +;; $OwnableTransferableTest$_load +(slice, ((slice))) $OwnableTransferableTest$_load(slice sc_0) inline; + +;; $StateInit$_not_null +((cell, cell)) $StateInit$_not_null(tuple v) inline; + +;; $OwnableTransferableTest$init$_load +(slice, ((slice))) $OwnableTransferableTest$init$_load(slice sc_0) inline; + +;; $OwnableTransferableTest$_contract_init +(slice) $OwnableTransferableTest$_contract_init(slice $owner) impure inline_ref; + +;; $OwnableTransferableTest$_contract_load +(slice) $OwnableTransferableTest$_contract_load() impure inline_ref; + +;; $OwnableTransferableTest$_contract_store +() $OwnableTransferableTest$_contract_store((slice) v) impure inline; + +;; $global_send +() $global_send((int, slice, int, int, cell, cell, cell) $params) impure inline_ref; + +;; $SendParameters$_constructor_bounce_to_value_mode_body_code_data +((int, slice, int, int, cell, cell, cell)) $SendParameters$_constructor_bounce_to_value_mode_body_code_data(int bounce, slice to, int value, int mode, cell body, cell code, cell data) inline; + +;; $OwnableTransferableTest$_fun_forward +((slice), ()) $OwnableTransferableTest$_fun_forward((slice) $self, slice $to, cell $body, int $bounce, tuple $init) impure inline_ref; + +;; $OwnableTransferableTest$_fun_reply +((slice), ()) $OwnableTransferableTest$_fun_reply((slice) $self, cell $body) impure inline; + +;; $OwnableTransferableTest$_fun_requireOwner +((slice), ()) $OwnableTransferableTest$_fun_requireOwner((slice) $self) impure inline_ref; + +;; $OwnableTransferableTest$_fun_owner +((slice), slice) $OwnableTransferableTest$_fun_owner((slice) $self) impure inline_ref; + +;; $ChangeOwnerOk$_constructor_queryId_newOwner +((int, slice)) $ChangeOwnerOk$_constructor_queryId_newOwner(int queryId, slice newOwner) inline; diff --git a/src/test/features/output/ownabletransferable_OwnableTransferableTest.md b/src/test/features/output/ownabletransferable_OwnableTransferableTest.md new file mode 100644 index 000000000..378f27331 --- /dev/null +++ b/src/test/features/output/ownabletransferable_OwnableTransferableTest.md @@ -0,0 +1,73 @@ +# TACT Compilation Report +Contract: OwnableTransferableTest +BOC Size: 1081 bytes + +# Types +Total Types: 9 + +## StateInit +TLB: `_ code:^cell data:^cell = StateInit` +Signature: `StateInit{code:^cell,data:^cell}` + +## Context +TLB: `_ bounced:bool sender:address value:int257 raw:^slice = Context` +Signature: `Context{bounced:bool,sender:address,value:int257,raw:^slice}` + +## SendParameters +TLB: `_ bounce:bool to:address value:int257 mode:int257 body:Maybe ^cell code:Maybe ^cell data:Maybe ^cell = SendParameters` +Signature: `SendParameters{bounce:bool,to:address,value:int257,mode:int257,body:Maybe ^cell,code:Maybe ^cell,data:Maybe ^cell}` + +## Deploy +TLB: `deploy#946a98b6 queryId:uint64 = Deploy` +Signature: `Deploy{queryId:uint64}` + +## DeployOk +TLB: `deploy_ok#aff90f57 queryId:uint64 = DeployOk` +Signature: `DeployOk{queryId:uint64}` + +## FactoryDeploy +TLB: `factory_deploy#6d0ff13b queryId:uint64 cashback:address = FactoryDeploy` +Signature: `FactoryDeploy{queryId:uint64,cashback:address}` + +## ChangeOwner +TLB: `change_owner#819dbe99 queryId:uint64 newOwner:address = ChangeOwner` +Signature: `ChangeOwner{queryId:uint64,newOwner:address}` + +## ChangeOwnerOk +TLB: `change_owner_ok#327b2b4a queryId:uint64 newOwner:address = ChangeOwnerOk` +Signature: `ChangeOwnerOk{queryId:uint64,newOwner:address}` + +## RenounceOwnership +TLB: `renounce_ownership#1c2ebf30 queryId:uint64 = RenounceOwnership` +Signature: `RenounceOwnership{queryId:uint64}` + +# Get Methods +Total Get Methods: 1 + +## owner + +# Error Codes +2: Stack undeflow +3: Stack overflow +4: Integer overflow +5: Integer out of expected range +6: Invalid opcode +7: Type check error +8: Cell overflow +9: Cell underflow +10: Dictionary error +13: Out of gas error +32: Method ID not found +34: Action is invalid or not supported +37: Not enough TON +38: Not enough extra-currencies +128: Null reference exception +129: Invalid serialization prefix +130: Invalid incoming message +131: Constraints error +132: Access denied +133: Contract stopped +134: Invalid argument +135: Code of a contract was not found +136: Invalid address +137: Masterchain support is not enabled for this contract \ No newline at end of file diff --git a/src/test/features/output/ownabletransferable_OwnableTransferableTest.pkg b/src/test/features/output/ownabletransferable_OwnableTransferableTest.pkg new file mode 100644 index 000000000..33f893262 --- /dev/null +++ b/src/test/features/output/ownabletransferable_OwnableTransferableTest.pkg @@ -0,0 +1 @@ +{"name":"OwnableTransferableTest","code":"te6ccgECFQEABC0AART/APSkE/S88sgLAQIBYgIDAs7QAdDTAwFxsKMB+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiFRQUwNvBPhhAvhi2zxZ2zzy4ILI+EMBzH8BygABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiM8Wye1UDgQCASAMDQPq7aLt+wGSMH/gcCHXScIflTAg1wsf3iCCEIGdvpm64wIgghAcLr8wuo6VMNMfAYIQHC6/MLry4IHTPwEx2zx/4MAAjq35AYLw+blBh3YoojOnGeEpFA6T3x7rWmWu6l+9FvsLmvQATJS6joXbPH/bMeCRMOJwBQYHAtow0x8BghCBnb6ZuvLggdM/+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiBJsEgLbPDAhyFmCEDJ7K0pQA8sfyz8BINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiM8WyfhCAX9t2zx/BwkCwgHbPDBwIMhyAcsBcAHLABLKB8v/ydAg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIcCDIcgHLAXABywASygfL/8nQINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiBIHCAAS+EJSEMcF8uCEAWrIWYIQMnsrSlADyx/LPwEg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIzxbJ+EIBf23bPAkBOm1tIm6zmVsgbvLQgG8iAZEy4hAkcAMEgEJQI9s8CgHKyHEBygFQBwHKAHABygJQBSDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IjPFlAD+gJwAcpoI26zkX+TJG6z4pczMwFwAcoA4w0hbrOcfwHKAAEgbvLQgAHMlTFwAcoA4skB+wALAJh/AcoAyHABygBwAcoAJG6znX8BygAEIG7y0IBQBMyWNANwAcoA4iRus51/AcoABCBu8tCAUATMljQDcAHKAOJwAcoAAn8BygACyVjMAg++KO7Z5tnhjA4PAgEgEBEAsu1E0NQB+GPSAAGOIPpAASDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4Igx4Pgo1wsKgwm68uCJ+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiAHRAAIgAd27vRgnBc7D1dLK57HoTsOdZKhRtmgnCd1jUtK2R8syLTry398WI5gnAgVcAbgGdjlM5YOq5HJbLDgnAb1J3vlUWW8cdT094FWcMmgnCdl05as07LczoOlm2UZuikgnBv5tIUuIMJMrmbjtmQGO6AgSAgFIExQAJIJwQM51aecV+dJQsB1hbiZHsgARsK+7UTQ0gABgAHWybuNDVpcGZzOi8vUW1Qc0tINzI4OHhhV1hNdkpIOGk4cW9HamR0N2phVmRlRXVFS1Z0WkV6WFNwNoIA==","abi":"{\"name\":\"OwnableTransferableTest\",\"types\":[{\"name\":\"StateInit\",\"header\":null,\"fields\":[{\"name\":\"code\",\"type\":{\"kind\":\"simple\",\"type\":\"cell\",\"optional\":false}},{\"name\":\"data\",\"type\":{\"kind\":\"simple\",\"type\":\"cell\",\"optional\":false}}]},{\"name\":\"Context\",\"header\":null,\"fields\":[{\"name\":\"bounced\",\"type\":{\"kind\":\"simple\",\"type\":\"bool\",\"optional\":false}},{\"name\":\"sender\",\"type\":{\"kind\":\"simple\",\"type\":\"address\",\"optional\":false}},{\"name\":\"value\",\"type\":{\"kind\":\"simple\",\"type\":\"int\",\"optional\":false,\"format\":257}},{\"name\":\"raw\",\"type\":{\"kind\":\"simple\",\"type\":\"slice\",\"optional\":false}}]},{\"name\":\"SendParameters\",\"header\":null,\"fields\":[{\"name\":\"bounce\",\"type\":{\"kind\":\"simple\",\"type\":\"bool\",\"optional\":false}},{\"name\":\"to\",\"type\":{\"kind\":\"simple\",\"type\":\"address\",\"optional\":false}},{\"name\":\"value\",\"type\":{\"kind\":\"simple\",\"type\":\"int\",\"optional\":false,\"format\":257}},{\"name\":\"mode\",\"type\":{\"kind\":\"simple\",\"type\":\"int\",\"optional\":false,\"format\":257}},{\"name\":\"body\",\"type\":{\"kind\":\"simple\",\"type\":\"cell\",\"optional\":true}},{\"name\":\"code\",\"type\":{\"kind\":\"simple\",\"type\":\"cell\",\"optional\":true}},{\"name\":\"data\",\"type\":{\"kind\":\"simple\",\"type\":\"cell\",\"optional\":true}}]},{\"name\":\"Deploy\",\"header\":2490013878,\"fields\":[{\"name\":\"queryId\",\"type\":{\"kind\":\"simple\",\"type\":\"uint\",\"optional\":false,\"format\":64}}]},{\"name\":\"DeployOk\",\"header\":2952335191,\"fields\":[{\"name\":\"queryId\",\"type\":{\"kind\":\"simple\",\"type\":\"uint\",\"optional\":false,\"format\":64}}]},{\"name\":\"FactoryDeploy\",\"header\":1829761339,\"fields\":[{\"name\":\"queryId\",\"type\":{\"kind\":\"simple\",\"type\":\"uint\",\"optional\":false,\"format\":64}},{\"name\":\"cashback\",\"type\":{\"kind\":\"simple\",\"type\":\"address\",\"optional\":false}}]},{\"name\":\"ChangeOwner\",\"header\":2174598809,\"fields\":[{\"name\":\"queryId\",\"type\":{\"kind\":\"simple\",\"type\":\"uint\",\"optional\":false,\"format\":64}},{\"name\":\"newOwner\",\"type\":{\"kind\":\"simple\",\"type\":\"address\",\"optional\":false}}]},{\"name\":\"ChangeOwnerOk\",\"header\":846932810,\"fields\":[{\"name\":\"queryId\",\"type\":{\"kind\":\"simple\",\"type\":\"uint\",\"optional\":false,\"format\":64}},{\"name\":\"newOwner\",\"type\":{\"kind\":\"simple\",\"type\":\"address\",\"optional\":false}}]},{\"name\":\"RenounceOwnership\",\"header\":472825648,\"fields\":[{\"name\":\"queryId\",\"type\":{\"kind\":\"simple\",\"type\":\"uint\",\"optional\":false,\"format\":64}}]}],\"receivers\":[{\"receiver\":\"internal\",\"message\":{\"kind\":\"text\",\"text\":\"test\"}},{\"receiver\":\"internal\",\"message\":{\"kind\":\"typed\",\"type\":\"ChangeOwner\"}},{\"receiver\":\"internal\",\"message\":{\"kind\":\"typed\",\"type\":\"RenounceOwnership\"}}],\"getters\":[{\"name\":\"owner\",\"arguments\":[],\"returnType\":{\"kind\":\"simple\",\"type\":\"address\",\"optional\":false}}],\"errors\":{\"2\":{\"message\":\"Stack undeflow\"},\"3\":{\"message\":\"Stack overflow\"},\"4\":{\"message\":\"Integer overflow\"},\"5\":{\"message\":\"Integer out of expected range\"},\"6\":{\"message\":\"Invalid opcode\"},\"7\":{\"message\":\"Type check error\"},\"8\":{\"message\":\"Cell overflow\"},\"9\":{\"message\":\"Cell underflow\"},\"10\":{\"message\":\"Dictionary error\"},\"13\":{\"message\":\"Out of gas error\"},\"32\":{\"message\":\"Method ID not found\"},\"34\":{\"message\":\"Action is invalid or not supported\"},\"37\":{\"message\":\"Not enough TON\"},\"38\":{\"message\":\"Not enough extra-currencies\"},\"128\":{\"message\":\"Null reference exception\"},\"129\":{\"message\":\"Invalid serialization prefix\"},\"130\":{\"message\":\"Invalid incoming message\"},\"131\":{\"message\":\"Constraints error\"},\"132\":{\"message\":\"Access denied\"},\"133\":{\"message\":\"Contract stopped\"},\"134\":{\"message\":\"Invalid argument\"},\"135\":{\"message\":\"Code of a contract was not found\"},\"136\":{\"message\":\"Invalid address\"},\"137\":{\"message\":\"Masterchain support is not enabled for this contract\"}},\"interfaces\":[\"org.ton.introspection.v0\",\"org.ton.abi.ipfs.v0\",\"org.ton.deploy.lazy.v0\",\"org.ton.debug.v0\",\"org.ton.chain.workchain.v0\",\"org.ton.ownable.transferable.v3\",\"org.ton.ownable\"]}","init":{"kind":"direct","args":[{"name":"owner","type":{"kind":"simple","type":"address","optional":false}}],"prefix":{"bits":1,"value":0},"deployment":{"kind":"system-cell","system":"te6cckECFwEABDcAAQHAAQEFoVeRAgEU/wD0pBP0vPLICwMCAWINBAIBIAsFAgEgCQYCAUgIBwB1sm7jQ1aXBmczovL1FtUHNLSDcyODh4YVdYTXZKSDhpOHFvR2pkdDdqYVZkZUV1RUtWdFpFelhTcDaCAAEbCvu1E0NIAAYAHdu70YJwXOw9XSyuex6E7DnWSoUbZoJwndY1LStkfLMi068t/fFiOYJwIFXAG4BnY5TOWDquRyWyw4JwG9Sd75VFlvHHU9PeBVnDJoJwnZdOWrNOy3M6DpZtlGbopIJwb+bSFLiDCTK5m47ZkBjugICgAkgnBAznVp5xX50lCwHWFuJkeyAg++KO7Z5tnhjBYMAAIgAs7QAdDTAwFxsKMB+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiFRQUwNvBPhhAvhi2zxZ2zzy4ILI+EMBzH8BygABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiM8Wye1UFg4D6u2i7fsBkjB/4HAh10nCH5UwINcLH94gghCBnb6ZuuMCIIIQHC6/MLqOlTDTHwGCEBwuvzC68uCB0z8BMds8f+DAAI6t+QGC8Pm5QYd2KKIzpxnhKRQOk98e61plrupfvRb7C5r0AEyUuo6F2zx/2zHgkTDicBEPFQLCAds8MHAgyHIBywFwAcsAEsoHy//J0CDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IhwIMhyAcsBcAHLABLKB8v/ydAg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIEhUQAWrIWYIQMnsrSlADyx/LPwEg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIzxbJ+EIBf23bPBIC2jDTHwGCEIGdvpm68uCB0z/6QAEg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIEmwSAts8MCHIWYIQMnsrSlADyx/LPwEg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIzxbJ+EIBf23bPH8VEgE6bW0ibrOZWyBu8tCAbyIBkTLiECRwAwSAQlAj2zwTAcrIcQHKAVAHAcoAcAHKAlAFINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiM8WUAP6AnABymgjbrORf5MkbrPilzMzAXABygDjDSFus5x/AcoAASBu8tCAAcyVMXABygDiyQH7ABQAmH8BygDIcAHKAHABygAkbrOdfwHKAAQgbvLQgFAEzJY0A3ABygDiJG6znX8BygAEIG7y0IBQBMyWNANwAcoA4nABygACfwHKAALJWMwAEvhCUhDHBfLghACy7UTQ1AH4Y9IAAY4g+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiDHg+CjXCwqDCbry4In6QAEg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIAdF2iEKh"}},"sources":{"src/test/features/ownabletransferable.tact":"aW1wb3J0ICJAc3RkbGliL2RlcGxveSI7CmltcG9ydCAiQHN0ZGxpYi9vd25hYmxlIjsKCmNvbnRyYWN0IE93bmFibGVUcmFuc2ZlcmFibGVUZXN0IHdpdGggT3duYWJsZVRyYW5zZmVyYWJsZSB7CiAgICBvd25lcjogQWRkcmVzczsKCiAgICBpbml0KG93bmVyOiBBZGRyZXNzKSB7CiAgICAgICAgc2VsZi5vd25lciA9IG93bmVyOwogICAgfQoKICAgIHJlY2VpdmUoInRlc3QiKSB7CiAgICAgICAgc2VsZi5yZXF1aXJlT3duZXIoKTsKICAgIH0KfQ=="},"compiler":{"name":"tact","version":"invalid","parameters":"{\"entrypoint\":\"./src/test/features/ownabletransferable.tact\",\"options\":{\"debug\":true}}"}} \ No newline at end of file diff --git a/src/test/features/output/ownabletransferable_OwnableTransferableTest.stdlib.fc b/src/test/features/output/ownabletransferable_OwnableTransferableTest.stdlib.fc new file mode 100644 index 000000000..65d3ca52a --- /dev/null +++ b/src/test/features/output/ownabletransferable_OwnableTransferableTest.stdlib.fc @@ -0,0 +1,130 @@ +global (int, slice, int, slice) __tact_context; +global slice __tact_context_sender; +global cell __tact_context_sys; +global int __tact_randomized; + +slice __tact_verify_address(slice address) inline { + throw_unless(136, address.slice_bits() == 267); + var h = address.preload_uint(11); + throw_if(137, h == 1279); + throw_unless(136, h == 1024); + return address; +} + +(slice, slice) __tact_load_address(slice cs) inline { + slice raw = cs~load_msg_addr(); + return (cs, __tact_verify_address(raw)); +} + +builder __tact_store_address(builder b, slice address) inline { + return b.store_slice(__tact_verify_address(address)); +} + +slice __tact_create_address(int chain, int hash) inline { + var b = begin_cell(); + b = b.store_uint(2, 2); + b = b.store_uint(0, 1); + b = b.store_int(chain, 8); + b = b.store_uint(hash, 256); + var addr = b.end_cell().begin_parse(); + return __tact_verify_address(addr); +} + +int __tact_my_balance() inline { + return pair_first(get_balance()); +} + +forall X -> X __tact_not_null(X x) inline { + throw_if(128, null?(x)); return x; +} + +(int, slice, int, slice) __tact_context_get() inline { + return __tact_context; +} + +slice __tact_context_get_sender() inline { + return __tact_context_sender; +} + +builder __tact_store_bool(builder b, int v) inline { + return b.store_int(v, 1); +} + +int __tact_slice_eq_bits(slice a, slice b) inline { + return equal_slice_bits(a, b); +} + +forall X0, X1 -> (X0, X1) __tact_tuple_destroy_2(tuple v) asm "2 UNTUPLE"; + +() $global_send((int, slice, int, int, cell, cell, cell) $params) impure inline_ref { + var (($params'bounce, $params'to, $params'value, $params'mode, $params'body, $params'code, $params'data)) = $params; + builder $b = begin_cell(); + $b = store_int($b, 1, 2); + $b = __tact_store_bool($b, $params'bounce); + $b = store_int($b, 0, 3); + $b = __tact_store_address($b, $params'to); + $b = store_coins($b, $params'value); + $b = store_int($b, 0, ((((1 + 4) + 4) + 64) + 32)); + if (( ((~ null?($params'code))) ? (true) : ((~ null?($params'data))) )) { + $b = __tact_store_bool($b, true); + builder $bc = begin_cell(); + $bc = __tact_store_bool($bc, false); + $bc = __tact_store_bool($bc, false); + if ((~ null?($params'code))) { + $bc = __tact_store_bool($bc, true); + $bc = store_ref($bc, __tact_not_null($params'code)); + } else { + $bc = __tact_store_bool($bc, false); + } + if ((~ null?($params'data))) { + $bc = __tact_store_bool($bc, true); + $bc = store_ref($bc, __tact_not_null($params'data)); + } else { + $bc = __tact_store_bool($bc, false); + } + $bc = __tact_store_bool($bc, false); + $b = __tact_store_bool($b, true); + $b = store_ref($b, end_cell($bc)); + } else { + $b = __tact_store_bool($b, false); + } + cell $body = $params'body; + if ((~ null?($body))) { + $b = __tact_store_bool($b, true); + $b = store_ref($b, __tact_not_null($body)); + } else { + $b = __tact_store_bool($b, false); + } + cell $c = end_cell($b); + send_raw_message($c, $params'mode); +} + +((slice), ()) $OwnableTransferableTest$_fun_forward((slice) $self, slice $to, cell $body, int $bounce, tuple $init) impure inline_ref { + var (($self'owner)) = $self; + var ($init) = $init; + cell $code = null(); + cell $data = null(); + if ((~ null?($init))) { + var ($init2'code, $init2'data) = $StateInit$_not_null($init); + $code = $init2'code; + $data = $init2'data; + } + if ((0 > 0)) { + var ($ctx'bounced, $ctx'sender, $ctx'value, $ctx'raw) = __tact_context_get(); + int $balance = __tact_my_balance(); + int $balanceBeforeMessage = ($balance - $ctx'value); + if (($balanceBeforeMessage < 0)) { + raw_reserve(0, 0); + $global_send($SendParameters$_constructor_bounce_to_value_mode_body_code_data($bounce, $to, 0, (128 + 2), $body, $code, $data)); + return (($self'owner), ()); + } + } + $global_send($SendParameters$_constructor_bounce_to_value_mode_body_code_data($bounce, $to, 0, (64 + 2), $body, $code, $data)); + return (($self'owner), ()); +} + +((slice), ()) $OwnableTransferableTest$_fun_reply((slice) $self, cell $body) impure inline { + var (($self'owner)) = $self; + ($self'owner)~$OwnableTransferableTest$_fun_forward(__tact_context_get_sender(), $body, true, null()); + return (($self'owner), ()); +} \ No newline at end of file diff --git a/src/test/features/output/ownabletransferable_OwnableTransferableTest.storage.fc b/src/test/features/output/ownabletransferable_OwnableTransferableTest.storage.fc new file mode 100644 index 000000000..9d0a4f2d8 --- /dev/null +++ b/src/test/features/output/ownabletransferable_OwnableTransferableTest.storage.fc @@ -0,0 +1,109 @@ +;; +;; Type: StateInit +;; TLB: _ code:^cell data:^cell = StateInit +;; + +((cell, cell)) $StateInit$_not_null(tuple v) inline { + throw_if(128, null?(v)); + var (cell vvv'code, cell vvv'data) = __tact_tuple_destroy_2(v); + return (vvv'code, vvv'data); +} + +;; +;; Type: SendParameters +;; TLB: _ bounce:bool to:address value:int257 mode:int257 body:Maybe ^cell code:Maybe ^cell data:Maybe ^cell = SendParameters +;; + +((int, slice, int, int, cell, cell, cell)) $SendParameters$_constructor_bounce_to_value_mode_body_code_data(int bounce, slice to, int value, int mode, cell body, cell code, cell data) inline { + return (bounce, to, value, mode, body, code, data); +} + +;; +;; Type: ChangeOwner +;; Header: 0x819dbe99 +;; TLB: change_owner#819dbe99 queryId:uint64 newOwner:address = ChangeOwner +;; + +(slice, ((int, slice))) $ChangeOwner$_load(slice sc_0) inline { + throw_unless(129, sc_0~load_uint(32) == 2174598809); + var v'queryId = sc_0~load_uint(64); + var v'newOwner = sc_0~__tact_load_address(); + return (sc_0, (v'queryId, v'newOwner)); +} + +;; +;; Type: ChangeOwnerOk +;; Header: 0x327b2b4a +;; TLB: change_owner_ok#327b2b4a queryId:uint64 newOwner:address = ChangeOwnerOk +;; + +builder $ChangeOwnerOk$_store(builder build_0, (int, slice) v) inline { + var (v'queryId, v'newOwner) = v; + build_0 = store_uint(build_0, 846932810, 32); + build_0 = build_0.store_uint(v'queryId, 64); + build_0 = __tact_store_address(build_0, v'newOwner); + return build_0; +} + +cell $ChangeOwnerOk$_store_cell((int, slice) v) inline { + return $ChangeOwnerOk$_store(begin_cell(), v).end_cell(); +} + +((int, slice)) $ChangeOwnerOk$_constructor_queryId_newOwner(int queryId, slice newOwner) inline { + return (queryId, newOwner); +} + +;; +;; Type: RenounceOwnership +;; Header: 0x1c2ebf30 +;; TLB: renounce_ownership#1c2ebf30 queryId:uint64 = RenounceOwnership +;; + +(slice, ((int))) $RenounceOwnership$_load(slice sc_0) inline { + throw_unless(129, sc_0~load_uint(32) == 472825648); + var v'queryId = sc_0~load_uint(64); + return (sc_0, (v'queryId)); +} + +;; +;; Type: OwnableTransferableTest +;; + +builder $OwnableTransferableTest$_store(builder build_0, (slice) v) inline { + var (v'owner) = v; + build_0 = __tact_store_address(build_0, v'owner); + return build_0; +} + +(slice, ((slice))) $OwnableTransferableTest$_load(slice sc_0) inline { + var v'owner = sc_0~__tact_load_address(); + return (sc_0, (v'owner)); +} + +(slice, ((slice))) $OwnableTransferableTest$init$_load(slice sc_0) inline { + var v'owner = sc_0~__tact_load_address(); + return (sc_0, (v'owner)); +} + +(slice) $OwnableTransferableTest$_contract_load() impure inline_ref { + slice $sc = get_data().begin_parse(); + __tact_context_sys = $sc~load_ref(); + int $loaded = $sc~load_int(1); + if ($loaded) { + return $sc~$OwnableTransferableTest$_load(); + } else { + ;; Allow only workchain deployments + throw_unless(137, my_address().preload_uint(11) == 1024); + (slice owner) = $sc~$OwnableTransferableTest$init$_load(); + $sc.end_parse(); + return $OwnableTransferableTest$_contract_init(owner); + } +} + +() $OwnableTransferableTest$_contract_store((slice) v) impure inline { + builder b = begin_cell(); + b = b.store_ref(__tact_context_sys); + b = b.store_int(true, 1); + b = $OwnableTransferableTest$_store(b, v); + set_data(b.end_cell()); +} \ No newline at end of file diff --git a/src/test/features/output/ownabletransferable_OwnableTransferableTest.ts b/src/test/features/output/ownabletransferable_OwnableTransferableTest.ts new file mode 100644 index 000000000..fb76e0c0b --- /dev/null +++ b/src/test/features/output/ownabletransferable_OwnableTransferableTest.ts @@ -0,0 +1,587 @@ +import { + Cell, + Slice, + Address, + Builder, + beginCell, + ComputeError, + TupleItem, + TupleReader, + Dictionary, + contractAddress, + ContractProvider, + Sender, + Contract, + ContractABI, + ABIType, + ABIGetter, + ABIReceiver, + TupleBuilder, + DictionaryValue +} from '@ton/core'; + +export type StateInit = { + $$type: 'StateInit'; + code: Cell; + data: Cell; +} + +export function storeStateInit(src: StateInit) { + return (builder: Builder) => { + let b_0 = builder; + b_0.storeRef(src.code); + b_0.storeRef(src.data); + }; +} + +export function loadStateInit(slice: Slice) { + let sc_0 = slice; + let _code = sc_0.loadRef(); + let _data = sc_0.loadRef(); + return { $$type: 'StateInit' as const, code: _code, data: _data }; +} + +function loadTupleStateInit(source: TupleReader) { + let _code = source.readCell(); + let _data = source.readCell(); + return { $$type: 'StateInit' as const, code: _code, data: _data }; +} + +function storeTupleStateInit(source: StateInit) { + let builder = new TupleBuilder(); + builder.writeCell(source.code); + builder.writeCell(source.data); + return builder.build(); +} + +function dictValueParserStateInit(): DictionaryValue { + return { + serialize: (src, buidler) => { + buidler.storeRef(beginCell().store(storeStateInit(src)).endCell()); + }, + parse: (src) => { + return loadStateInit(src.loadRef().beginParse()); + } + } +} + +export type Context = { + $$type: 'Context'; + bounced: boolean; + sender: Address; + value: bigint; + raw: Cell; +} + +export function storeContext(src: Context) { + return (builder: Builder) => { + let b_0 = builder; + b_0.storeBit(src.bounced); + b_0.storeAddress(src.sender); + b_0.storeInt(src.value, 257); + b_0.storeRef(src.raw); + }; +} + +export function loadContext(slice: Slice) { + let sc_0 = slice; + let _bounced = sc_0.loadBit(); + let _sender = sc_0.loadAddress(); + let _value = sc_0.loadIntBig(257); + let _raw = sc_0.loadRef(); + return { $$type: 'Context' as const, bounced: _bounced, sender: _sender, value: _value, raw: _raw }; +} + +function loadTupleContext(source: TupleReader) { + let _bounced = source.readBoolean(); + let _sender = source.readAddress(); + let _value = source.readBigNumber(); + let _raw = source.readCell(); + return { $$type: 'Context' as const, bounced: _bounced, sender: _sender, value: _value, raw: _raw }; +} + +function storeTupleContext(source: Context) { + let builder = new TupleBuilder(); + builder.writeBoolean(source.bounced); + builder.writeAddress(source.sender); + builder.writeNumber(source.value); + builder.writeSlice(source.raw); + return builder.build(); +} + +function dictValueParserContext(): DictionaryValue { + return { + serialize: (src, buidler) => { + buidler.storeRef(beginCell().store(storeContext(src)).endCell()); + }, + parse: (src) => { + return loadContext(src.loadRef().beginParse()); + } + } +} + +export type SendParameters = { + $$type: 'SendParameters'; + bounce: boolean; + to: Address; + value: bigint; + mode: bigint; + body: Cell | null; + code: Cell | null; + data: Cell | null; +} + +export function storeSendParameters(src: SendParameters) { + return (builder: Builder) => { + let b_0 = builder; + b_0.storeBit(src.bounce); + b_0.storeAddress(src.to); + b_0.storeInt(src.value, 257); + b_0.storeInt(src.mode, 257); + if (src.body !== null && src.body !== undefined) { b_0.storeBit(true).storeRef(src.body); } else { b_0.storeBit(false); } + if (src.code !== null && src.code !== undefined) { b_0.storeBit(true).storeRef(src.code); } else { b_0.storeBit(false); } + if (src.data !== null && src.data !== undefined) { b_0.storeBit(true).storeRef(src.data); } else { b_0.storeBit(false); } + }; +} + +export function loadSendParameters(slice: Slice) { + let sc_0 = slice; + let _bounce = sc_0.loadBit(); + let _to = sc_0.loadAddress(); + let _value = sc_0.loadIntBig(257); + let _mode = sc_0.loadIntBig(257); + let _body = sc_0.loadBit() ? sc_0.loadRef() : null; + let _code = sc_0.loadBit() ? sc_0.loadRef() : null; + let _data = sc_0.loadBit() ? sc_0.loadRef() : null; + return { $$type: 'SendParameters' as const, bounce: _bounce, to: _to, value: _value, mode: _mode, body: _body, code: _code, data: _data }; +} + +function loadTupleSendParameters(source: TupleReader) { + let _bounce = source.readBoolean(); + let _to = source.readAddress(); + let _value = source.readBigNumber(); + let _mode = source.readBigNumber(); + let _body = source.readCellOpt(); + let _code = source.readCellOpt(); + let _data = source.readCellOpt(); + return { $$type: 'SendParameters' as const, bounce: _bounce, to: _to, value: _value, mode: _mode, body: _body, code: _code, data: _data }; +} + +function storeTupleSendParameters(source: SendParameters) { + let builder = new TupleBuilder(); + builder.writeBoolean(source.bounce); + builder.writeAddress(source.to); + builder.writeNumber(source.value); + builder.writeNumber(source.mode); + builder.writeCell(source.body); + builder.writeCell(source.code); + builder.writeCell(source.data); + return builder.build(); +} + +function dictValueParserSendParameters(): DictionaryValue { + return { + serialize: (src, buidler) => { + buidler.storeRef(beginCell().store(storeSendParameters(src)).endCell()); + }, + parse: (src) => { + return loadSendParameters(src.loadRef().beginParse()); + } + } +} + +export type Deploy = { + $$type: 'Deploy'; + queryId: bigint; +} + +export function storeDeploy(src: Deploy) { + return (builder: Builder) => { + let b_0 = builder; + b_0.storeUint(2490013878, 32); + b_0.storeUint(src.queryId, 64); + }; +} + +export function loadDeploy(slice: Slice) { + let sc_0 = slice; + if (sc_0.loadUint(32) !== 2490013878) { throw Error('Invalid prefix'); } + let _queryId = sc_0.loadUintBig(64); + return { $$type: 'Deploy' as const, queryId: _queryId }; +} + +function loadTupleDeploy(source: TupleReader) { + let _queryId = source.readBigNumber(); + return { $$type: 'Deploy' as const, queryId: _queryId }; +} + +function storeTupleDeploy(source: Deploy) { + let builder = new TupleBuilder(); + builder.writeNumber(source.queryId); + return builder.build(); +} + +function dictValueParserDeploy(): DictionaryValue { + return { + serialize: (src, buidler) => { + buidler.storeRef(beginCell().store(storeDeploy(src)).endCell()); + }, + parse: (src) => { + return loadDeploy(src.loadRef().beginParse()); + } + } +} + +export type DeployOk = { + $$type: 'DeployOk'; + queryId: bigint; +} + +export function storeDeployOk(src: DeployOk) { + return (builder: Builder) => { + let b_0 = builder; + b_0.storeUint(2952335191, 32); + b_0.storeUint(src.queryId, 64); + }; +} + +export function loadDeployOk(slice: Slice) { + let sc_0 = slice; + if (sc_0.loadUint(32) !== 2952335191) { throw Error('Invalid prefix'); } + let _queryId = sc_0.loadUintBig(64); + return { $$type: 'DeployOk' as const, queryId: _queryId }; +} + +function loadTupleDeployOk(source: TupleReader) { + let _queryId = source.readBigNumber(); + return { $$type: 'DeployOk' as const, queryId: _queryId }; +} + +function storeTupleDeployOk(source: DeployOk) { + let builder = new TupleBuilder(); + builder.writeNumber(source.queryId); + return builder.build(); +} + +function dictValueParserDeployOk(): DictionaryValue { + return { + serialize: (src, buidler) => { + buidler.storeRef(beginCell().store(storeDeployOk(src)).endCell()); + }, + parse: (src) => { + return loadDeployOk(src.loadRef().beginParse()); + } + } +} + +export type FactoryDeploy = { + $$type: 'FactoryDeploy'; + queryId: bigint; + cashback: Address; +} + +export function storeFactoryDeploy(src: FactoryDeploy) { + return (builder: Builder) => { + let b_0 = builder; + b_0.storeUint(1829761339, 32); + b_0.storeUint(src.queryId, 64); + b_0.storeAddress(src.cashback); + }; +} + +export function loadFactoryDeploy(slice: Slice) { + let sc_0 = slice; + if (sc_0.loadUint(32) !== 1829761339) { throw Error('Invalid prefix'); } + let _queryId = sc_0.loadUintBig(64); + let _cashback = sc_0.loadAddress(); + return { $$type: 'FactoryDeploy' as const, queryId: _queryId, cashback: _cashback }; +} + +function loadTupleFactoryDeploy(source: TupleReader) { + let _queryId = source.readBigNumber(); + let _cashback = source.readAddress(); + return { $$type: 'FactoryDeploy' as const, queryId: _queryId, cashback: _cashback }; +} + +function storeTupleFactoryDeploy(source: FactoryDeploy) { + let builder = new TupleBuilder(); + builder.writeNumber(source.queryId); + builder.writeAddress(source.cashback); + return builder.build(); +} + +function dictValueParserFactoryDeploy(): DictionaryValue { + return { + serialize: (src, buidler) => { + buidler.storeRef(beginCell().store(storeFactoryDeploy(src)).endCell()); + }, + parse: (src) => { + return loadFactoryDeploy(src.loadRef().beginParse()); + } + } +} + +export type ChangeOwner = { + $$type: 'ChangeOwner'; + queryId: bigint; + newOwner: Address; +} + +export function storeChangeOwner(src: ChangeOwner) { + return (builder: Builder) => { + let b_0 = builder; + b_0.storeUint(2174598809, 32); + b_0.storeUint(src.queryId, 64); + b_0.storeAddress(src.newOwner); + }; +} + +export function loadChangeOwner(slice: Slice) { + let sc_0 = slice; + if (sc_0.loadUint(32) !== 2174598809) { throw Error('Invalid prefix'); } + let _queryId = sc_0.loadUintBig(64); + let _newOwner = sc_0.loadAddress(); + return { $$type: 'ChangeOwner' as const, queryId: _queryId, newOwner: _newOwner }; +} + +function loadTupleChangeOwner(source: TupleReader) { + let _queryId = source.readBigNumber(); + let _newOwner = source.readAddress(); + return { $$type: 'ChangeOwner' as const, queryId: _queryId, newOwner: _newOwner }; +} + +function storeTupleChangeOwner(source: ChangeOwner) { + let builder = new TupleBuilder(); + builder.writeNumber(source.queryId); + builder.writeAddress(source.newOwner); + return builder.build(); +} + +function dictValueParserChangeOwner(): DictionaryValue { + return { + serialize: (src, buidler) => { + buidler.storeRef(beginCell().store(storeChangeOwner(src)).endCell()); + }, + parse: (src) => { + return loadChangeOwner(src.loadRef().beginParse()); + } + } +} + +export type ChangeOwnerOk = { + $$type: 'ChangeOwnerOk'; + queryId: bigint; + newOwner: Address; +} + +export function storeChangeOwnerOk(src: ChangeOwnerOk) { + return (builder: Builder) => { + let b_0 = builder; + b_0.storeUint(846932810, 32); + b_0.storeUint(src.queryId, 64); + b_0.storeAddress(src.newOwner); + }; +} + +export function loadChangeOwnerOk(slice: Slice) { + let sc_0 = slice; + if (sc_0.loadUint(32) !== 846932810) { throw Error('Invalid prefix'); } + let _queryId = sc_0.loadUintBig(64); + let _newOwner = sc_0.loadAddress(); + return { $$type: 'ChangeOwnerOk' as const, queryId: _queryId, newOwner: _newOwner }; +} + +function loadTupleChangeOwnerOk(source: TupleReader) { + let _queryId = source.readBigNumber(); + let _newOwner = source.readAddress(); + return { $$type: 'ChangeOwnerOk' as const, queryId: _queryId, newOwner: _newOwner }; +} + +function storeTupleChangeOwnerOk(source: ChangeOwnerOk) { + let builder = new TupleBuilder(); + builder.writeNumber(source.queryId); + builder.writeAddress(source.newOwner); + return builder.build(); +} + +function dictValueParserChangeOwnerOk(): DictionaryValue { + return { + serialize: (src, buidler) => { + buidler.storeRef(beginCell().store(storeChangeOwnerOk(src)).endCell()); + }, + parse: (src) => { + return loadChangeOwnerOk(src.loadRef().beginParse()); + } + } +} + +export type RenounceOwnership = { + $$type: 'RenounceOwnership'; + queryId: bigint; +} + +export function storeRenounceOwnership(src: RenounceOwnership) { + return (builder: Builder) => { + let b_0 = builder; + b_0.storeUint(472825648, 32); + b_0.storeUint(src.queryId, 64); + }; +} + +export function loadRenounceOwnership(slice: Slice) { + let sc_0 = slice; + if (sc_0.loadUint(32) !== 472825648) { throw Error('Invalid prefix'); } + let _queryId = sc_0.loadUintBig(64); + return { $$type: 'RenounceOwnership' as const, queryId: _queryId }; +} + +function loadTupleRenounceOwnership(source: TupleReader) { + let _queryId = source.readBigNumber(); + return { $$type: 'RenounceOwnership' as const, queryId: _queryId }; +} + +function storeTupleRenounceOwnership(source: RenounceOwnership) { + let builder = new TupleBuilder(); + builder.writeNumber(source.queryId); + return builder.build(); +} + +function dictValueParserRenounceOwnership(): DictionaryValue { + return { + serialize: (src, buidler) => { + buidler.storeRef(beginCell().store(storeRenounceOwnership(src)).endCell()); + }, + parse: (src) => { + return loadRenounceOwnership(src.loadRef().beginParse()); + } + } +} + + type OwnableTransferableTest_init_args = { + $$type: 'OwnableTransferableTest_init_args'; + owner: Address; +} + +function initOwnableTransferableTest_init_args(src: OwnableTransferableTest_init_args) { + return (builder: Builder) => { + let b_0 = builder; + b_0.storeAddress(src.owner); + }; +} + +async function OwnableTransferableTest_init(owner: Address) { + const __code = Cell.fromBase64('te6ccgECFQEABC0AART/APSkE/S88sgLAQIBYgIDAs7QAdDTAwFxsKMB+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiFRQUwNvBPhhAvhi2zxZ2zzy4ILI+EMBzH8BygABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiM8Wye1UDgQCASAMDQPq7aLt+wGSMH/gcCHXScIflTAg1wsf3iCCEIGdvpm64wIgghAcLr8wuo6VMNMfAYIQHC6/MLry4IHTPwEx2zx/4MAAjq35AYLw+blBh3YoojOnGeEpFA6T3x7rWmWu6l+9FvsLmvQATJS6joXbPH/bMeCRMOJwBQYHAtow0x8BghCBnb6ZuvLggdM/+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiBJsEgLbPDAhyFmCEDJ7K0pQA8sfyz8BINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiM8WyfhCAX9t2zx/BwkCwgHbPDBwIMhyAcsBcAHLABLKB8v/ydAg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIcCDIcgHLAXABywASygfL/8nQINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiBIHCAAS+EJSEMcF8uCEAWrIWYIQMnsrSlADyx/LPwEg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIzxbJ+EIBf23bPAkBOm1tIm6zmVsgbvLQgG8iAZEy4hAkcAMEgEJQI9s8CgHKyHEBygFQBwHKAHABygJQBSDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IjPFlAD+gJwAcpoI26zkX+TJG6z4pczMwFwAcoA4w0hbrOcfwHKAAEgbvLQgAHMlTFwAcoA4skB+wALAJh/AcoAyHABygBwAcoAJG6znX8BygAEIG7y0IBQBMyWNANwAcoA4iRus51/AcoABCBu8tCAUATMljQDcAHKAOJwAcoAAn8BygACyVjMAg++KO7Z5tnhjA4PAgEgEBEAsu1E0NQB+GPSAAGOIPpAASDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4Igx4Pgo1wsKgwm68uCJ+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiAHRAAIgAd27vRgnBc7D1dLK57HoTsOdZKhRtmgnCd1jUtK2R8syLTry398WI5gnAgVcAbgGdjlM5YOq5HJbLDgnAb1J3vlUWW8cdT094FWcMmgnCdl05as07LczoOlm2UZuikgnBv5tIUuIMJMrmbjtmQGO6AgSAgFIExQAJIJwQM51aecV+dJQsB1hbiZHsgARsK+7UTQ0gABgAHWybuNDVpcGZzOi8vUW1Qc0tINzI4OHhhV1hNdkpIOGk4cW9HamR0N2phVmRlRXVFS1Z0WkV6WFNwNoIA=='); + const __system = Cell.fromBase64('te6cckECFwEABDcAAQHAAQEFoVeRAgEU/wD0pBP0vPLICwMCAWINBAIBIAsFAgEgCQYCAUgIBwB1sm7jQ1aXBmczovL1FtUHNLSDcyODh4YVdYTXZKSDhpOHFvR2pkdDdqYVZkZUV1RUtWdFpFelhTcDaCAAEbCvu1E0NIAAYAHdu70YJwXOw9XSyuex6E7DnWSoUbZoJwndY1LStkfLMi068t/fFiOYJwIFXAG4BnY5TOWDquRyWyw4JwG9Sd75VFlvHHU9PeBVnDJoJwnZdOWrNOy3M6DpZtlGbopIJwb+bSFLiDCTK5m47ZkBjugICgAkgnBAznVp5xX50lCwHWFuJkeyAg++KO7Z5tnhjBYMAAIgAs7QAdDTAwFxsKMB+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiFRQUwNvBPhhAvhi2zxZ2zzy4ILI+EMBzH8BygABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiM8Wye1UFg4D6u2i7fsBkjB/4HAh10nCH5UwINcLH94gghCBnb6ZuuMCIIIQHC6/MLqOlTDTHwGCEBwuvzC68uCB0z8BMds8f+DAAI6t+QGC8Pm5QYd2KKIzpxnhKRQOk98e61plrupfvRb7C5r0AEyUuo6F2zx/2zHgkTDicBEPFQLCAds8MHAgyHIBywFwAcsAEsoHy//J0CDXSYEBC7ry4Igg1wsKIIEE/7ry0ImDCbry4IhwIMhyAcsBcAHLABLKB8v/ydAg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIEhUQAWrIWYIQMnsrSlADyx/LPwEg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIzxbJ+EIBf23bPBIC2jDTHwGCEIGdvpm68uCB0z/6QAEg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIEmwSAts8MCHIWYIQMnsrSlADyx/LPwEg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIzxbJ+EIBf23bPH8VEgE6bW0ibrOZWyBu8tCAbyIBkTLiECRwAwSAQlAj2zwTAcrIcQHKAVAHAcoAcAHKAlAFINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiM8WUAP6AnABymgjbrORf5MkbrPilzMzAXABygDjDSFus5x/AcoAASBu8tCAAcyVMXABygDiyQH7ABQAmH8BygDIcAHKAHABygAkbrOdfwHKAAQgbvLQgFAEzJY0A3ABygDiJG6znX8BygAEIG7y0IBQBMyWNANwAcoA4nABygACfwHKAALJWMwAEvhCUhDHBfLghACy7UTQ1AH4Y9IAAY4g+kABINdJgQELuvLgiCDXCwoggQT/uvLQiYMJuvLgiDHg+CjXCwqDCbry4In6QAEg10mBAQu68uCIINcLCiCBBP+68tCJgwm68uCIAdF2iEKh'); + let builder = beginCell(); + builder.storeRef(__system); + builder.storeUint(0, 1); + initOwnableTransferableTest_init_args({ $$type: 'OwnableTransferableTest_init_args', owner })(builder); + const __data = builder.endCell(); + return { code: __code, data: __data }; +} + +const OwnableTransferableTest_errors: { [key: number]: { message: string } } = { + 2: { message: `Stack undeflow` }, + 3: { message: `Stack overflow` }, + 4: { message: `Integer overflow` }, + 5: { message: `Integer out of expected range` }, + 6: { message: `Invalid opcode` }, + 7: { message: `Type check error` }, + 8: { message: `Cell overflow` }, + 9: { message: `Cell underflow` }, + 10: { message: `Dictionary error` }, + 13: { message: `Out of gas error` }, + 32: { message: `Method ID not found` }, + 34: { message: `Action is invalid or not supported` }, + 37: { message: `Not enough TON` }, + 38: { message: `Not enough extra-currencies` }, + 128: { message: `Null reference exception` }, + 129: { message: `Invalid serialization prefix` }, + 130: { message: `Invalid incoming message` }, + 131: { message: `Constraints error` }, + 132: { message: `Access denied` }, + 133: { message: `Contract stopped` }, + 134: { message: `Invalid argument` }, + 135: { message: `Code of a contract was not found` }, + 136: { message: `Invalid address` }, + 137: { message: `Masterchain support is not enabled for this contract` }, +} + +const OwnableTransferableTest_types: ABIType[] = [ + {"name":"StateInit","header":null,"fields":[{"name":"code","type":{"kind":"simple","type":"cell","optional":false}},{"name":"data","type":{"kind":"simple","type":"cell","optional":false}}]}, + {"name":"Context","header":null,"fields":[{"name":"bounced","type":{"kind":"simple","type":"bool","optional":false}},{"name":"sender","type":{"kind":"simple","type":"address","optional":false}},{"name":"value","type":{"kind":"simple","type":"int","optional":false,"format":257}},{"name":"raw","type":{"kind":"simple","type":"slice","optional":false}}]}, + {"name":"SendParameters","header":null,"fields":[{"name":"bounce","type":{"kind":"simple","type":"bool","optional":false}},{"name":"to","type":{"kind":"simple","type":"address","optional":false}},{"name":"value","type":{"kind":"simple","type":"int","optional":false,"format":257}},{"name":"mode","type":{"kind":"simple","type":"int","optional":false,"format":257}},{"name":"body","type":{"kind":"simple","type":"cell","optional":true}},{"name":"code","type":{"kind":"simple","type":"cell","optional":true}},{"name":"data","type":{"kind":"simple","type":"cell","optional":true}}]}, + {"name":"Deploy","header":2490013878,"fields":[{"name":"queryId","type":{"kind":"simple","type":"uint","optional":false,"format":64}}]}, + {"name":"DeployOk","header":2952335191,"fields":[{"name":"queryId","type":{"kind":"simple","type":"uint","optional":false,"format":64}}]}, + {"name":"FactoryDeploy","header":1829761339,"fields":[{"name":"queryId","type":{"kind":"simple","type":"uint","optional":false,"format":64}},{"name":"cashback","type":{"kind":"simple","type":"address","optional":false}}]}, + {"name":"ChangeOwner","header":2174598809,"fields":[{"name":"queryId","type":{"kind":"simple","type":"uint","optional":false,"format":64}},{"name":"newOwner","type":{"kind":"simple","type":"address","optional":false}}]}, + {"name":"ChangeOwnerOk","header":846932810,"fields":[{"name":"queryId","type":{"kind":"simple","type":"uint","optional":false,"format":64}},{"name":"newOwner","type":{"kind":"simple","type":"address","optional":false}}]}, + {"name":"RenounceOwnership","header":472825648,"fields":[{"name":"queryId","type":{"kind":"simple","type":"uint","optional":false,"format":64}}]}, +] + +const OwnableTransferableTest_getters: ABIGetter[] = [ + {"name":"owner","arguments":[],"returnType":{"kind":"simple","type":"address","optional":false}}, +] + +const OwnableTransferableTest_receivers: ABIReceiver[] = [ + {"receiver":"internal","message":{"kind":"text","text":"test"}}, + {"receiver":"internal","message":{"kind":"typed","type":"ChangeOwner"}}, + {"receiver":"internal","message":{"kind":"typed","type":"RenounceOwnership"}}, +] + +export class OwnableTransferableTest implements Contract { + + static async init(owner: Address) { + return await OwnableTransferableTest_init(owner); + } + + static async fromInit(owner: Address) { + const init = await OwnableTransferableTest_init(owner); + const address = contractAddress(0, init); + return new OwnableTransferableTest(address, init); + } + + static fromAddress(address: Address) { + return new OwnableTransferableTest(address); + } + + readonly address: Address; + readonly init?: { code: Cell, data: Cell }; + readonly abi: ContractABI = { + types: OwnableTransferableTest_types, + getters: OwnableTransferableTest_getters, + receivers: OwnableTransferableTest_receivers, + errors: OwnableTransferableTest_errors, + }; + + private constructor(address: Address, init?: { code: Cell, data: Cell }) { + this.address = address; + this.init = init; + } + + async send(provider: ContractProvider, via: Sender, args: { value: bigint, bounce?: boolean| null | undefined }, message: 'test' | ChangeOwner | RenounceOwnership) { + + let body: Cell | null = null; + if (message === 'test') { + body = beginCell().storeUint(0, 32).storeStringTail(message).endCell(); + } + if (message && typeof message === 'object' && !(message instanceof Slice) && message.$$type === 'ChangeOwner') { + body = beginCell().store(storeChangeOwner(message)).endCell(); + } + if (message && typeof message === 'object' && !(message instanceof Slice) && message.$$type === 'RenounceOwnership') { + body = beginCell().store(storeRenounceOwnership(message)).endCell(); + } + if (body === null) { throw new Error('Invalid message type'); } + + await provider.internal(via, { ...args, body: body }); + + } + + async getOwner(provider: ContractProvider) { + let builder = new TupleBuilder(); + let source = (await provider.get('owner', builder.build())).stack; + let result = source.readAddress(); + return result; + } + +} \ No newline at end of file diff --git a/src/test/features/ownabletransferable.tact b/src/test/features/ownabletransferable.tact new file mode 100644 index 000000000..f00242508 --- /dev/null +++ b/src/test/features/ownabletransferable.tact @@ -0,0 +1,14 @@ +import "@stdlib/deploy"; +import "@stdlib/ownable"; + +contract OwnableTransferableTest with OwnableTransferable { + owner: Address; + + init(owner: Address) { + self.owner = owner; + } + + receive("test") { + self.requireOwner(); + } +} \ No newline at end of file diff --git a/stdlib/libs/ownable.tact b/stdlib/libs/ownable.tact index 907c9ed95..0d1b9994d 100644 --- a/stdlib/libs/ownable.tact +++ b/stdlib/libs/ownable.tact @@ -8,6 +8,10 @@ message ChangeOwnerOk { newOwner: Address; } +message RenounceOwnership { + queryId: Int as uint64; +} + @interface("org.ton.ownable") trait Ownable { owner: Address; @@ -21,7 +25,7 @@ trait Ownable { } } -@interface("org.ton.ownable.transferable.v2") +@interface("org.ton.ownable.transferable.v3") trait OwnableTransferable with Ownable { owner: Address; @@ -35,6 +39,24 @@ trait OwnableTransferable with Ownable { self.owner = msg.newOwner; // Reply result - self.reply(ChangeOwnerOk{ queryId: msg.queryId, newOwner:msg.newOwner }.toCell()); + self.reply(ChangeOwnerOk{ + queryId: msg.queryId, + newOwner: msg.newOwner + }.toCell()); + } + + receive(msg: RenounceOwnership) { + + // Check if the sender is the owner + self.requireOwner(); + + // Update owner + self.owner = newAddress(0, 0); + + // Reply result + self.reply(ChangeOwnerOk{ + queryId: msg.queryId, + newOwner: newAddress(0, 0) + }.toCell()); } } \ No newline at end of file diff --git a/tact.config.json b/tact.config.json index e0ffabaf2..b50a87fac 100644 --- a/tact.config.json +++ b/tact.config.json @@ -172,6 +172,14 @@ "debug": true } }, + { + "name": "ownabletransferable", + "path": "./src/test/features/ownabletransferable.tact", + "output": "./src/test/features/output", + "options": { + "debug": true + } + }, { "name": "deep", "path": "./src/test/features/deep-sequence.tact", From 1b02a154d43c4cfd91537e8d9f25614274bf7172 Mon Sep 17 00:00:00 2001 From: Daniil Sedov <42098239+Gusarich@users.noreply.github.com> Date: Fri, 15 Mar 2024 15:55:11 +0300 Subject: [PATCH 2/2] Update CHANGELOG.md Co-authored-by: Anton Trunov --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b9918345..619338cde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- `RenounceOwnership` message was added to `OwnableTransferable` +- The `RenounceOwnership` message and its corresponding receiver were added to the `OwnableTransferable` trait allowing to transfer ownership to nobody ### Fixed