From bb7e69bc0cbedb030028c7d0ed10724c9c49154b Mon Sep 17 00:00:00 2001 From: Shahar Yakir Date: Thu, 22 Dec 2022 13:23:31 +0200 Subject: [PATCH 1/4] in prog --- sources/contract.spec.ts | 4 + sources/contract.tact | 24 +++- sources/output/sample_SampleTactContract.abi | 22 +++ .../output/sample_SampleTactContract.abi.ipfs | 2 +- sources/output/sample_SampleTactContract.boc | Bin 387 -> 552 bytes sources/output/sample_SampleTactContract.fc | 88 ++++++++---- sources/output/sample_SampleTactContract.fif | 60 +++++++-- .../output/sample_SampleTactContract.rev.fif | 126 ++++++++++++++---- sources/output/sample_SampleTactContract.ts | 39 +++++- 9 files changed, 298 insertions(+), 67 deletions(-) diff --git a/sources/contract.spec.ts b/sources/contract.spec.ts index 9a97f49..139dca5 100644 --- a/sources/contract.spec.ts +++ b/sources/contract.spec.ts @@ -22,6 +22,10 @@ describe('contract', () => { // Check counter expect((await contract.getCounter()).toString()).toEqual('1'); + // Increment counter + await contract.send({ amount: toNano(1), from: nonOwner }, 'dec'); + expect((await contract.getCounter()).toString()).toEqual('0'); + // Non-owner await expect(() => contract.send({ amount: toNano(1), from: nonOwner }, 'increment')).rejects.toThrowError('Constraints error'); }); diff --git a/sources/contract.tact b/sources/contract.tact index 2f28e9e..b5d355b 100644 --- a/sources/contract.tact +++ b/sources/contract.tact @@ -2,10 +2,21 @@ message Add { amount: Int as uint32; } -contract SampleTactContract { - +trait Ownable { owner: Address; + + fun requireOwner() { + nativeThrowUnless(132, context().sender == self.owner); + } + + get fun owner(): Address { + return self.owner; + } +} + +contract SampleTactContract with Ownable { counter: Int as uint32; + owner: Address; init(owner: Address) { self.owner = owner; @@ -13,7 +24,6 @@ contract SampleTactContract { } fun add(v: Int) { - // Check sender let ctx: Context = context(); require(ctx.sender == self.owner); @@ -30,7 +40,15 @@ contract SampleTactContract { self.add(1); } + receive("dec") { + self.counter = self.counter - 1; + } + get fun counter(): Int { return self.counter; } + + get fun balance(): Int { + return myBalance(); + } } \ No newline at end of file diff --git a/sources/output/sample_SampleTactContract.abi b/sources/output/sample_SampleTactContract.abi index a2b1aa1..2317acf 100644 --- a/sources/output/sample_SampleTactContract.abi +++ b/sources/output/sample_SampleTactContract.abi @@ -334,6 +334,10 @@ { "kind": "internal-comment", "comment": "increment" + }, + { + "kind": "internal-comment", + "comment": "dec" } ], "getters": [ @@ -345,6 +349,24 @@ "name": "Int", "optional": false } + }, + { + "name": "balance", + "args": [], + "returns": { + "kind": "ref", + "name": "Int", + "optional": false + } + }, + { + "name": "owner", + "args": [], + "returns": { + "kind": "ref", + "name": "Address", + "optional": false + } } ], "dependsOn": {}, diff --git a/sources/output/sample_SampleTactContract.abi.ipfs b/sources/output/sample_SampleTactContract.abi.ipfs index dda36a9..93416a5 100644 --- a/sources/output/sample_SampleTactContract.abi.ipfs +++ b/sources/output/sample_SampleTactContract.abi.ipfs @@ -1 +1 @@ -{"version":"0.0.1","name":"SampleTactContract","structs":[{"name":"StateInit","header":0,"fields":[{"name":"code","type":{"kind":"ref","name":"Cell","optional":false}},{"name":"data","type":{"kind":"ref","name":"Cell","optional":false}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":0,"refs":1},"kind":"cell"},{"index":1,"size":{"bits":0,"refs":1},"kind":"cell"}],"next":null,"size":{"bits":0,"refs":2}}}},{"name":"Context","header":0,"fields":[{"name":"bounced","type":{"kind":"ref","name":"Bool","optional":false}},{"name":"sender","type":{"kind":"ref","name":"Address","optional":false}},{"name":"value","type":{"kind":"ref","name":"Int","optional":false}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":1,"refs":0},"kind":"int","bits":1},{"index":1,"size":{"bits":267,"refs":0},"kind":"address"},{"index":2,"size":{"bits":257,"refs":0},"kind":"int","bits":257}],"next":null,"size":{"bits":525,"refs":0}}}},{"name":"SendParameters","header":0,"fields":[{"name":"bounce","type":{"kind":"ref","name":"Bool","optional":false}},{"name":"to","type":{"kind":"ref","name":"Address","optional":false}},{"name":"value","type":{"kind":"ref","name":"Int","optional":false}},{"name":"mode","type":{"kind":"ref","name":"Int","optional":false}},{"name":"body","type":{"kind":"ref","name":"Cell","optional":true}},{"name":"code","type":{"kind":"ref","name":"Cell","optional":true}},{"name":"data","type":{"kind":"ref","name":"Cell","optional":true}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":1,"refs":0},"kind":"int","bits":1},{"index":1,"size":{"bits":267,"refs":0},"kind":"address"},{"index":2,"size":{"bits":257,"refs":0},"kind":"int","bits":257},{"index":3,"size":{"bits":257,"refs":0},"kind":"int","bits":257},{"index":4,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":4,"size":{"bits":0,"refs":1},"kind":"cell"}},{"index":5,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":5,"size":{"bits":0,"refs":1},"kind":"cell"}},{"index":6,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":6,"size":{"bits":0,"refs":1},"kind":"cell"}}],"next":null,"size":{"bits":785,"refs":3}}}},{"name":"Add","header":0,"fields":[{"name":"amount","type":{"kind":"ref","name":"Int","optional":false}}],"allocation":{"prefix":3310826759,"root":{"fields":[{"index":0,"size":{"bits":32,"refs":0},"kind":"uint","bits":32}],"next":null,"size":{"bits":32,"refs":0}}}}],"init":{"name":"init_SampleTactContract","args":[{"name":"owner","type":{"kind":"ref","name":"Address","optional":false}}]},"receivers":[{"kind":"internal-binary","type":"Add"},{"kind":"internal-comment","comment":"increment"}],"getters":[{"name":"counter","args":[],"returns":{"kind":"ref","name":"Int","optional":false}}],"dependsOn":{},"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"}}} \ No newline at end of file +{"version":"0.0.1","name":"SampleTactContract","structs":[{"name":"StateInit","header":0,"fields":[{"name":"code","type":{"kind":"ref","name":"Cell","optional":false}},{"name":"data","type":{"kind":"ref","name":"Cell","optional":false}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":0,"refs":1},"kind":"cell"},{"index":1,"size":{"bits":0,"refs":1},"kind":"cell"}],"next":null,"size":{"bits":0,"refs":2}}}},{"name":"Context","header":0,"fields":[{"name":"bounced","type":{"kind":"ref","name":"Bool","optional":false}},{"name":"sender","type":{"kind":"ref","name":"Address","optional":false}},{"name":"value","type":{"kind":"ref","name":"Int","optional":false}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":1,"refs":0},"kind":"int","bits":1},{"index":1,"size":{"bits":267,"refs":0},"kind":"address"},{"index":2,"size":{"bits":257,"refs":0},"kind":"int","bits":257}],"next":null,"size":{"bits":525,"refs":0}}}},{"name":"SendParameters","header":0,"fields":[{"name":"bounce","type":{"kind":"ref","name":"Bool","optional":false}},{"name":"to","type":{"kind":"ref","name":"Address","optional":false}},{"name":"value","type":{"kind":"ref","name":"Int","optional":false}},{"name":"mode","type":{"kind":"ref","name":"Int","optional":false}},{"name":"body","type":{"kind":"ref","name":"Cell","optional":true}},{"name":"code","type":{"kind":"ref","name":"Cell","optional":true}},{"name":"data","type":{"kind":"ref","name":"Cell","optional":true}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":1,"refs":0},"kind":"int","bits":1},{"index":1,"size":{"bits":267,"refs":0},"kind":"address"},{"index":2,"size":{"bits":257,"refs":0},"kind":"int","bits":257},{"index":3,"size":{"bits":257,"refs":0},"kind":"int","bits":257},{"index":4,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":4,"size":{"bits":0,"refs":1},"kind":"cell"}},{"index":5,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":5,"size":{"bits":0,"refs":1},"kind":"cell"}},{"index":6,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":6,"size":{"bits":0,"refs":1},"kind":"cell"}}],"next":null,"size":{"bits":785,"refs":3}}}},{"name":"Add","header":0,"fields":[{"name":"amount","type":{"kind":"ref","name":"Int","optional":false}}],"allocation":{"prefix":3310826759,"root":{"fields":[{"index":0,"size":{"bits":32,"refs":0},"kind":"uint","bits":32}],"next":null,"size":{"bits":32,"refs":0}}}}],"init":{"name":"init_SampleTactContract","args":[{"name":"owner","type":{"kind":"ref","name":"Address","optional":false}}]},"receivers":[{"kind":"internal-binary","type":"Add"},{"kind":"internal-comment","comment":"increment"},{"kind":"internal-comment","comment":"dec"}],"getters":[{"name":"counter","args":[],"returns":{"kind":"ref","name":"Int","optional":false}},{"name":"balance","args":[],"returns":{"kind":"ref","name":"Int","optional":false}},{"name":"owner","args":[],"returns":{"kind":"ref","name":"Address","optional":false}}],"dependsOn":{},"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"}}} \ No newline at end of file diff --git a/sources/output/sample_SampleTactContract.boc b/sources/output/sample_SampleTactContract.boc index 9e028ed34f2471cc44f680bb7c0e0f74cfa7b297..d001e8caae8420a5eb871de8146845cee0a45ab5 100644 GIT binary patch delta 415 zcmZo>Ucq9t_1&BzMkWPD1|}H>Mv?yvUzP}e+4JcHHzN~c5)(5M(`gn~CPoDbNg%<- z4ipm-o~Yr#E;i%;B?gYk6AQ#t``ix+@FkrPi}=A;vCThgIU55@XS+oHG!_vKpdK!6 z#z#LH6(+7!saH05>vG`=r;G2%Y%h#CRr>>9joKd9jmkLv9;BX!>w3 zo&Q}=n2=r!f&Ke*78#%u zczA&XAAdcN6cA*PlwsIpEatH3_<`c1n-Umg?F6DvoZ<11cL)8weFm90Rj~P00DOZ0TllL^rRE?yz __tact_context_get PROCINLINE:<{ __tact_context GETGLOB UNTRIPLE @@ -45,15 +55,15 @@ PROGRAM{ SWAP }> __gen_write_SampleTactContract PROCINLINE:<{ - -ROT - __tact_store_address INLINECALLDICT + s0 s2 XCHG 32 STU + SWAP + __tact_store_address INLINECALLDICT }> __gen_read_SampleTactContract PROCINLINE:<{ - __tact_load_address INLINECALLDICT - SWAP 32 LDU - -ROT + __tact_load_address INLINECALLDICT + s1 s2 XCHG }> __gen_load_SampleTactContract PROCINLINE:<{ c4 PUSH @@ -82,7 +92,7 @@ PROGRAM{ s0 s2 XCHG NEWC STREF - s0 s2 XCHG + -ROT __gen_write_SampleTactContract INLINECALLDICT ENDC }> @@ -90,18 +100,35 @@ PROGRAM{ __tact_context_get INLINECALLDICT DROP NIP - s3 PUSH + s2 PUSH __tact_address_eq INLINECALLDICT require CALLDICT + s1 s2 XCHG ADD + SWAP }> __gen_SampleTactContract_counter PROC:<{ - NIP + DROP }> __gen_get_counter PROC:<{ __gen_load_SampleTactContract INLINECALLDICT __gen_SampleTactContract_counter CALLDICT }> + __gen_SampleTactContract_balance PROC:<{ + 2DROP + __tact_my_balance INLINECALLDICT + }> + __gen_get_balance PROC:<{ + __gen_load_SampleTactContract INLINECALLDICT + __gen_SampleTactContract_balance CALLDICT + }> + __gen_SampleTactContract_owner PROC:<{ + NIP + }> + __gen_get_owner PROC:<{ + __gen_load_SampleTactContract INLINECALLDICT + __gen_SampleTactContract_owner CALLDICT + }> __gen_SampleTactContract_receive_Add PROC:<{ __gen_SampleTactContract_add CALLDICT }> @@ -109,6 +136,11 @@ PROGRAM{ 1 PUSHINT __gen_SampleTactContract_add CALLDICT }> + __gen_SampleTactContract_receive_comment_de670fee8c5612197d3fd2b409468ac62a0804f9c19613ac4bd324771e908c78 PROC:<{ + SWAP + DEC + SWAP + }> recv_internal PROC:<{ SAMEALTSAVE 0 PUSHINT @@ -158,14 +190,24 @@ PROGRAM{ 0 EQINT IF:<{ HASHSU + DUP 89092981215441470209245890604563109773385607357076622359718516871332286001838 PUSHINT EQUAL IFJMP:<{ + DROP __gen_load_SampleTactContract INLINECALLDICT __gen_SampleTactContract_receive_comment_c4f8d72312edfdef5b7bec7833bdbb162d1511bd78a912aed0f2637af65572ae CALLDICT __gen_store_SampleTactContract INLINECALLDICT RETALT }> + 100595547590598948711597982087367633970071360142702224366101845453322392210552 PUSHINT + EQUAL + IFJMP:<{ + __gen_load_SampleTactContract INLINECALLDICT + __gen_SampleTactContract_receive_comment_de670fee8c5612197d3fd2b409468ac62a0804f9c19613ac4bd324771e908c78 CALLDICT + __gen_store_SampleTactContract INLINECALLDICT + RETALT + }> }>ELSE<{ DROP }> @@ -179,6 +221,6 @@ PROGRAM{ 209801025412363888721030803524359905849 PUSHINT }> get_abi_ipfs PROC:<{ - x{697066733a2f2f516d5275716b625546376a70684338347862574c6b646538775746463877783869654c46485a4e4d503142524776} PUSHSLICE + x{697066733a2f2f516d61345947654a724c4c65483742535333696a614568446777594a6b507854525a5463646f59514b4b43466863} PUSHSLICE }> }END>c diff --git a/sources/output/sample_SampleTactContract.rev.fif b/sources/output/sample_SampleTactContract.rev.fif index 6c30ece..fc43ae9 100644 --- a/sources/output/sample_SampleTactContract.rev.fif +++ b/sources/output/sample_SampleTactContract.rev.fif @@ -47,11 +47,10 @@ SETCP0 LDREF s0 s1 XCHG 2 SETGLOBVAR + 32 LDU LDMSGADDR s0 s1 XCHG - s0 s1 XCHG - 32 LDU - ROTREV + s1 s2 XCHG 1 2 BLKDROP2 s0 s2 XCHG 32 LDU @@ -63,15 +62,16 @@ SETCP0 s0 s1 XCHG s1 POP s1 s2 XCHG - 14 CALLDICT + 17 CALLDICT NEWC 2 GETGLOBVAR s0 s1 XCHG STREF ROTREV - ROTREV - STSLICER + s0 s2 XCHG 32 STU + s0 s1 XCHG + STSLICER ENDC c4 POP }> PUSHCONT @@ -82,87 +82,157 @@ SETCP0 }> PUSHCONT <{ HASHSU + s0 PUSH 89092981215441470209245890604563109773385607357076622359718516871332286001838 PUSHINT EQUAL <{ + s0 POP c4 PUSH CTOS LDREF s0 s1 XCHG 2 SETGLOBVAR + 32 LDU LDMSGADDR s0 s1 XCHG - s0 s1 XCHG - 32 LDU - ROTREV + s1 s2 XCHG 1 2 BLKDROP2 - 15 CALLDICT + 18 CALLDICT NEWC 2 GETGLOBVAR s0 s1 XCHG STREF ROTREV - ROTREV - STSLICER + s0 s2 XCHG 32 STU + s0 s1 XCHG + STSLICER ENDC c4 POP RETALT }> PUSHCONT IFJMP + 100595547590598948711597982087367633970071360142702224366101845453322392210552 PUSHINT + EQUAL + <{ + c4 PUSH + CTOS + LDREF + s0 s1 XCHG + 2 SETGLOBVAR + 32 LDU + LDMSGADDR + s0 s1 XCHG + s1 s2 XCHG + 1 2 BLKDROP2 + 19 CALLDICT + NEWC + 2 GETGLOBVAR + s0 s1 XCHG + STREF + ROTREV + s0 s2 XCHG + 32 STU + s0 s1 XCHG + STSLICER + ENDC + c4 POP + RETALT + }> IFJMPREF }> IFREFELSE 130 THROW - 10: + 11: 131 THROWIFNOT - 11: + 12: 0 PUSHINT s0 s2 XCHG NEWC STREF - s0 s2 XCHG ROTREV - STSLICER + s0 s2 XCHG 32 STU + s0 s1 XCHG + STSLICER ENDC - 12: + 13: 1 GETGLOBVAR 3 UNTUPLE s0 POP s1 POP - s3 PUSH + s2 PUSH SDEQ - 10 CALLDICT + 11 CALLDICT + s1 s2 XCHG ADD - - 13: - s1 POP + s0 s1 XCHG 14: - 12 CALLDICT + s0 POP 15: + 2DROP + BALANCE + 0 INDEX + + 16: + s1 POP + + 17: + 13 CALLDICT + + 18: 1 PUSHINT - 12 CALLDICT + 13 CALLDICT + + 19: + s0 s1 XCHG + DEC + s0 s1 XCHG 78809: - 11 CALLDICT + 12 CALLDICT - 104984: + owner: c4 PUSH CTOS LDREF s0 s1 XCHG 2 SETGLOBVAR + 32 LDU LDMSGADDR s0 s1 XCHG + s1 s2 XCHG + 1 2 BLKDROP2 + 16 CALLDICT + + 104128: + c4 PUSH + CTOS + LDREF s0 s1 XCHG + 2 SETGLOBVAR 32 LDU - ROTREV + LDMSGADDR + s0 s1 XCHG + s1 s2 XCHG 1 2 BLKDROP2 - 13 CALLDICT + 15 CALLDICT + + 104984: + c4 PUSH + CTOS + LDREF + s0 s1 XCHG + 2 SETGLOBVAR + 32 LDU + LDMSGADDR + s0 s1 XCHG + s1 s2 XCHG + 1 2 BLKDROP2 + 14 CALLDICT 113617: 123515602279859691144772641439386770278 PUSHINT diff --git a/sources/output/sample_SampleTactContract.ts b/sources/output/sample_SampleTactContract.ts index 9b12f96..eb5cfc7 100644 --- a/sources/output/sample_SampleTactContract.ts +++ b/sources/output/sample_SampleTactContract.ts @@ -213,7 +213,7 @@ export function unpackTupleAdd(slice: TupleSlice4): Add { return { $$type: 'Add', amount: amount }; } export async function SampleTactContract_init(owner: Address) { - const __code = 'te6ccgECFQEAAXcAART/APSkE/S88sgLAQIBYgIDAgLMBAUCASAREgHp32/bgQ66ThD8qYEGuFj+8BaGmBgLjYYADIv8i4cQD9IBgqIIq3gfwwgUit8BBBCGKrmoPdRxoYdqJoagD8MX0gAIDpj6y2CQFpj4DBCGKrmoPdeXBA6Y+AmIl4B2R8IQDmLKzni2WP5PaqcGAASJhxhvlgQUBgIBIAcIAJT5AYLwxPjXIxLt/e9be+x4M727Fi0VEb14qRKu0PJjevZVcq66jiLtRNDUAfhi+kABAdMfWWwS8A/I+EIBzFlZzxbLH8ntVNsx4AIBWAkKAgEgCwwABzy4IOAAFxwAsjMAlnPFssfyYAIBIA0OAgEgDxAAGT4QW8jMDEjxwXwCqCAAAwxgAAU8AyAABxx8AyAACb2ez4BcAgFIExQAKbdDHaiaGoA/DF9IACA6Y+stgl4BsABNt3owTgudh6ullc9j0J2HOslQo2zQThO6xqWlbI+WZFp15b++LEcw'; + const __code = 'te6ccgECIAEAAhwAART/APSkE/S88sgLAQIBYgIDAgLLBAUCASAYGQIBIAYHAgFiEhMB6d9v24EOuk4Q/KmBBrhY/vAWhpgYC42GAAyL/IuHEA/SAYKiCKt4H8MIFIrfAQQQhiq5qD3UcaGHaiaGoA/DFpj/0gAIk2CQFpj4DBCGKrmoPdeXBA6Y+AmIl4COR8IQDmLIFlj4Dni2T2qnBgAEiYcYb5YEFAgCASAKCwHi+QEggvDE+NcjEu3971t77HgzvbsWLRURvXipEq7Q8mN69lVyrrqOIzDtRNDUAfhi0x/6QAESbBLwEsj4QgHMWQLLHwHPFsntVNsx4ILw3mcP7oxWEhl9P9K0CUaKxioIBPnBlhOsS9Mkdx6QjHi64wIJAETtRNDUAfhi0x/6QAESbBLwE8j4QgHMWQLLHwHPFsntVNsxAAf3lwQcAgEgDA0CASAODwIBIBARABkcALIzFkCyx8BzxbJgAB0+EFvIzAxIscF8AsSoAGAAAwwgAAsW/gnbxCACASAUFQIBIBYXAAMMYAAFPANgAAccfANgAAcAaUBgAgEgGhsCAUgcHQAJuz2fAMgAJ7hR3tRNDUAfhi0x/6QAESbBLwEIAgFYHh8ATbd6ME4LnYerpZXPY9CdhzrJUKNs0E4TusalpWyPlmRadeW/vixHMAAnr2B2omhqAPwxaY/9IACJNgl4B8AAJ60MdqJoagD8MWmP/SAAiTYJeAdA'; const depends = new Map(); let systemCell = beginCell().storeDict(null).endCell(); let __stack: StackItem[] = []; @@ -255,7 +255,7 @@ export class SampleTactContract { readonly executor: ContractExecutor; constructor(executor: ContractExecutor) { this.executor = executor; } - async send(args: { amount: BN, from?: Address, debug?: boolean }, message: Add | 'increment') { + async send(args: { amount: BN, from?: Address, debug?: boolean }, message: Add | 'increment' | 'dec') { let body: Cell | null = null; if (message && typeof message === 'object' && !(message instanceof Slice) && message.$$type === 'Add') { body = packAdd(message); @@ -263,6 +263,9 @@ export class SampleTactContract { if (message === 'increment') { body = beginCell().storeUint(0, 32).storeBuffer(Buffer.from(message)).endCell(); } + if (message === 'dec') { + body = beginCell().storeUint(0, 32).storeBuffer(Buffer.from(message)).endCell(); + } if (body === null) { throw new Error('Invalid message type'); } try { let r = await this.executor.internal(new InternalMessage({ @@ -301,4 +304,36 @@ export class SampleTactContract { throw e; } } + async getBalance() { + try { + let __stack: StackItem[] = []; + let result = await this.executor.get('balance', __stack, { debug: true }); + if (result.debugLogs.length > 0) { console.warn(result.debugLogs); } + return result.stack.readBigNumber(); + } catch (e) { + if (e instanceof ExecuteError) { + if (e.debugLogs.length > 0) { console.warn(e.debugLogs); } + if (SampleTactContract_errors[e.exitCode.toString()]) { + throw new Error(SampleTactContract_errors[e.exitCode.toString()]); + } + } + throw e; + } + } + async getOwner() { + try { + let __stack: StackItem[] = []; + let result = await this.executor.get('owner', __stack, { debug: true }); + if (result.debugLogs.length > 0) { console.warn(result.debugLogs); } + return result.stack.readAddress(); + } catch (e) { + if (e instanceof ExecuteError) { + if (e.debugLogs.length > 0) { console.warn(e.debugLogs); } + if (SampleTactContract_errors[e.exitCode.toString()]) { + throw new Error(SampleTactContract_errors[e.exitCode.toString()]); + } + } + throw e; + } + } } \ No newline at end of file From 807bf10571ab4b5c49545f998e4f80d27836bc5f Mon Sep 17 00:00:00 2001 From: Shahar Yakir Date: Thu, 22 Dec 2022 13:37:59 +0200 Subject: [PATCH 2/4] in prog --- sources/contract.spec.ts | 50 ++++++++++----- sources/contract.tact | 21 ++----- sources/output/sample_SampleTactContract.abi | 9 +++ .../output/sample_SampleTactContract.abi.ipfs | 2 +- sources/output/sample_SampleTactContract.boc | Bin 552 -> 591 bytes sources/output/sample_SampleTactContract.fc | 31 +++++++--- sources/output/sample_SampleTactContract.fif | 37 +++++++---- .../output/sample_SampleTactContract.rev.fif | 58 ++++++++++++------ sources/output/sample_SampleTactContract.ts | 18 +++++- 9 files changed, 156 insertions(+), 70 deletions(-) diff --git a/sources/contract.spec.ts b/sources/contract.spec.ts index 139dca5..e184fc8 100644 --- a/sources/contract.spec.ts +++ b/sources/contract.spec.ts @@ -1,18 +1,26 @@ -import { toNano } from 'ton'; -import { createExecutorFromCode } from 'ton-nodejs'; +import { toNano, Cell } from 'ton'; +import { ContractExecutor, createExecutorFromCode } from 'ton-nodejs'; import { SampleTactContract, SampleTactContract_init } from './output/sample_SampleTactContract'; import { randomAddress } from './utils/randomAddress'; +import BN from 'bn.js'; describe('contract', () => { + let owner = randomAddress(0, 'some-owner'); + let nonOwner = randomAddress(0, 'some-non-owner'); + let init: { + code: Cell + data: Cell + } + let executor: ContractExecutor; + let contract: SampleTactContract; + + beforeEach(async () => { + init = await SampleTactContract_init(owner); + executor = await createExecutorFromCode(init); + contract = new SampleTactContract(executor); + }) + it('should deploy correctly', async () => { - - // Create stateinit - let owner = randomAddress(0, 'some-owner'); - let nonOwner = randomAddress(0, 'some-non-owner'); - let init = await SampleTactContract_init(owner); - let executor = await createExecutorFromCode(init); - let contract = new SampleTactContract(executor); - // Check counter expect((await contract.getCounter()).toString()).toEqual('0'); @@ -22,11 +30,23 @@ describe('contract', () => { // Check counter expect((await contract.getCounter()).toString()).toEqual('1'); - // Increment counter - await contract.send({ amount: toNano(1), from: nonOwner }, 'dec'); - expect((await contract.getCounter()).toString()).toEqual('0'); - // Non-owner - await expect(() => contract.send({ amount: toNano(1), from: nonOwner }, 'increment')).rejects.toThrowError('Constraints error'); + await expect(() => contract.send({ amount: toNano(1), from: nonOwner }, 'increment')).rejects.toThrowError('Access denied'); }); + + it('should get meaning of life', async() => { + expect((await contract.getMeaningOfLife()).toString()).toEqual('42'); + }) + + it('should increment counter', async() => { + await contract.send( + { amount: toNano(1), from: owner }, + { + $$type: "Add", + amount: new BN(13) + } + ); + await contract.send({ amount: toNano(1), from: nonOwner }, 'dec'); + expect((await contract.getCounter()).toString()).toEqual('12'); + }) }); \ No newline at end of file diff --git a/sources/contract.tact b/sources/contract.tact index b5d355b..fa7cb66 100644 --- a/sources/contract.tact +++ b/sources/contract.tact @@ -2,19 +2,8 @@ message Add { amount: Int as uint32; } -trait Ownable { - owner: Address; - - fun requireOwner() { - nativeThrowUnless(132, context().sender == self.owner); - } - - get fun owner(): Address { - return self.owner; - } -} -contract SampleTactContract with Ownable { +contract SampleTactContract with OwnableTransferable { counter: Int as uint32; owner: Address; @@ -24,9 +13,7 @@ contract SampleTactContract with Ownable { } fun add(v: Int) { - // Check sender - let ctx: Context = context(); - require(ctx.sender == self.owner); + self.requireOwner(); // Update counter self.counter = (self.counter + v); @@ -51,4 +38,8 @@ contract SampleTactContract with Ownable { get fun balance(): Int { return myBalance(); } + + get fun meaning_of_life(): Int { + return 42; + } } \ No newline at end of file diff --git a/sources/output/sample_SampleTactContract.abi b/sources/output/sample_SampleTactContract.abi index 2317acf..8109b64 100644 --- a/sources/output/sample_SampleTactContract.abi +++ b/sources/output/sample_SampleTactContract.abi @@ -359,6 +359,15 @@ "optional": false } }, + { + "name": "meaning_of_life", + "args": [], + "returns": { + "kind": "ref", + "name": "Int", + "optional": false + } + }, { "name": "owner", "args": [], diff --git a/sources/output/sample_SampleTactContract.abi.ipfs b/sources/output/sample_SampleTactContract.abi.ipfs index 93416a5..27a2941 100644 --- a/sources/output/sample_SampleTactContract.abi.ipfs +++ b/sources/output/sample_SampleTactContract.abi.ipfs @@ -1 +1 @@ -{"version":"0.0.1","name":"SampleTactContract","structs":[{"name":"StateInit","header":0,"fields":[{"name":"code","type":{"kind":"ref","name":"Cell","optional":false}},{"name":"data","type":{"kind":"ref","name":"Cell","optional":false}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":0,"refs":1},"kind":"cell"},{"index":1,"size":{"bits":0,"refs":1},"kind":"cell"}],"next":null,"size":{"bits":0,"refs":2}}}},{"name":"Context","header":0,"fields":[{"name":"bounced","type":{"kind":"ref","name":"Bool","optional":false}},{"name":"sender","type":{"kind":"ref","name":"Address","optional":false}},{"name":"value","type":{"kind":"ref","name":"Int","optional":false}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":1,"refs":0},"kind":"int","bits":1},{"index":1,"size":{"bits":267,"refs":0},"kind":"address"},{"index":2,"size":{"bits":257,"refs":0},"kind":"int","bits":257}],"next":null,"size":{"bits":525,"refs":0}}}},{"name":"SendParameters","header":0,"fields":[{"name":"bounce","type":{"kind":"ref","name":"Bool","optional":false}},{"name":"to","type":{"kind":"ref","name":"Address","optional":false}},{"name":"value","type":{"kind":"ref","name":"Int","optional":false}},{"name":"mode","type":{"kind":"ref","name":"Int","optional":false}},{"name":"body","type":{"kind":"ref","name":"Cell","optional":true}},{"name":"code","type":{"kind":"ref","name":"Cell","optional":true}},{"name":"data","type":{"kind":"ref","name":"Cell","optional":true}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":1,"refs":0},"kind":"int","bits":1},{"index":1,"size":{"bits":267,"refs":0},"kind":"address"},{"index":2,"size":{"bits":257,"refs":0},"kind":"int","bits":257},{"index":3,"size":{"bits":257,"refs":0},"kind":"int","bits":257},{"index":4,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":4,"size":{"bits":0,"refs":1},"kind":"cell"}},{"index":5,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":5,"size":{"bits":0,"refs":1},"kind":"cell"}},{"index":6,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":6,"size":{"bits":0,"refs":1},"kind":"cell"}}],"next":null,"size":{"bits":785,"refs":3}}}},{"name":"Add","header":0,"fields":[{"name":"amount","type":{"kind":"ref","name":"Int","optional":false}}],"allocation":{"prefix":3310826759,"root":{"fields":[{"index":0,"size":{"bits":32,"refs":0},"kind":"uint","bits":32}],"next":null,"size":{"bits":32,"refs":0}}}}],"init":{"name":"init_SampleTactContract","args":[{"name":"owner","type":{"kind":"ref","name":"Address","optional":false}}]},"receivers":[{"kind":"internal-binary","type":"Add"},{"kind":"internal-comment","comment":"increment"},{"kind":"internal-comment","comment":"dec"}],"getters":[{"name":"counter","args":[],"returns":{"kind":"ref","name":"Int","optional":false}},{"name":"balance","args":[],"returns":{"kind":"ref","name":"Int","optional":false}},{"name":"owner","args":[],"returns":{"kind":"ref","name":"Address","optional":false}}],"dependsOn":{},"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"}}} \ No newline at end of file +{"version":"0.0.1","name":"SampleTactContract","structs":[{"name":"StateInit","header":0,"fields":[{"name":"code","type":{"kind":"ref","name":"Cell","optional":false}},{"name":"data","type":{"kind":"ref","name":"Cell","optional":false}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":0,"refs":1},"kind":"cell"},{"index":1,"size":{"bits":0,"refs":1},"kind":"cell"}],"next":null,"size":{"bits":0,"refs":2}}}},{"name":"Context","header":0,"fields":[{"name":"bounced","type":{"kind":"ref","name":"Bool","optional":false}},{"name":"sender","type":{"kind":"ref","name":"Address","optional":false}},{"name":"value","type":{"kind":"ref","name":"Int","optional":false}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":1,"refs":0},"kind":"int","bits":1},{"index":1,"size":{"bits":267,"refs":0},"kind":"address"},{"index":2,"size":{"bits":257,"refs":0},"kind":"int","bits":257}],"next":null,"size":{"bits":525,"refs":0}}}},{"name":"SendParameters","header":0,"fields":[{"name":"bounce","type":{"kind":"ref","name":"Bool","optional":false}},{"name":"to","type":{"kind":"ref","name":"Address","optional":false}},{"name":"value","type":{"kind":"ref","name":"Int","optional":false}},{"name":"mode","type":{"kind":"ref","name":"Int","optional":false}},{"name":"body","type":{"kind":"ref","name":"Cell","optional":true}},{"name":"code","type":{"kind":"ref","name":"Cell","optional":true}},{"name":"data","type":{"kind":"ref","name":"Cell","optional":true}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":1,"refs":0},"kind":"int","bits":1},{"index":1,"size":{"bits":267,"refs":0},"kind":"address"},{"index":2,"size":{"bits":257,"refs":0},"kind":"int","bits":257},{"index":3,"size":{"bits":257,"refs":0},"kind":"int","bits":257},{"index":4,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":4,"size":{"bits":0,"refs":1},"kind":"cell"}},{"index":5,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":5,"size":{"bits":0,"refs":1},"kind":"cell"}},{"index":6,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":6,"size":{"bits":0,"refs":1},"kind":"cell"}}],"next":null,"size":{"bits":785,"refs":3}}}},{"name":"Add","header":0,"fields":[{"name":"amount","type":{"kind":"ref","name":"Int","optional":false}}],"allocation":{"prefix":3310826759,"root":{"fields":[{"index":0,"size":{"bits":32,"refs":0},"kind":"uint","bits":32}],"next":null,"size":{"bits":32,"refs":0}}}}],"init":{"name":"init_SampleTactContract","args":[{"name":"owner","type":{"kind":"ref","name":"Address","optional":false}}]},"receivers":[{"kind":"internal-binary","type":"Add"},{"kind":"internal-comment","comment":"increment"},{"kind":"internal-comment","comment":"dec"}],"getters":[{"name":"counter","args":[],"returns":{"kind":"ref","name":"Int","optional":false}},{"name":"balance","args":[],"returns":{"kind":"ref","name":"Int","optional":false}},{"name":"meaning_of_life","args":[],"returns":{"kind":"ref","name":"Int","optional":false}},{"name":"owner","args":[],"returns":{"kind":"ref","name":"Address","optional":false}}],"dependsOn":{},"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"}}} \ No newline at end of file diff --git a/sources/output/sample_SampleTactContract.boc b/sources/output/sample_SampleTactContract.boc index d001e8caae8420a5eb871de8146845cee0a45ab5..b5bd5477f11dca78ee06b8eeab596d77479ef199 100644 GIT binary patch delta 295 zcmZ3%a-M~I>$^Ecj7%zw3{1`wxutoeq?s5M*w~pEJp=?N8pSfsn>ay+F=FCcTSk$I zuf6I;PyBFVJQK-uTAuN|*vYpcw+(^Hd3b>YA3uYn48ta4F^5gZ4-_BWl)xZqClGz& z439_Q!I~Y43JknrHOvkx7!nwmc@%)^g@l22NJs)%BBDS-Oq_vR>>uatBMJ=cVh^|$ z097S0u-Y&$U|^T20g()u4hc-0j0!TcKz(xZlQ%NTsA@1VMkpu(bt@?|sIN~bTa=N- z@W(K-|E~f=rx|AjhXaH9TAoQvBDS0DtOHF<8R{gq9RD|g!DTkf9+m_K-%Vc<=7?MK mhkI+!JHF7GuXNHvx0?&*sF(J7d)<`RIkDyS>H3<8z61d4%2bj7 delta 274 zcmX@lvVw(s>$^Ecj7$oQ3`{Z;xutm|B$*f$*w~pElZ1pP8pSg9O`IUZs4#J@Eu+xH z*IxC)Cw@3Fo{3~SEzfvf?Bv^!+lCD6->0+405$RO0tr5TAR!>gASuJJ$ym%`)A0kv zM>i!f$l3`+pE$$gvGHIH(~%Vn2@K3U3Jlz0|2S_SQ2=TX5d{)r;y}>^238y91O|4Q z8W72l>5u@Fk&u67{rhy>4H(qdCzLJ9$YS_onA!hVfuYlkvx5BqgZf$?3{eLF D0LoK1 diff --git a/sources/output/sample_SampleTactContract.fc b/sources/output/sample_SampleTactContract.fc index cc1c9d5..41a68ed 100644 --- a/sources/output/sample_SampleTactContract.fc +++ b/sources/output/sample_SampleTactContract.fc @@ -40,6 +40,11 @@ builder __gen_write_SampleTactContract(builder build_0, (int, slice) v) inline { return (sc_0, (v'counter, v'owner)); } +_ __gen_Context_get_sender((int, slice, int) v) inline { + var (v'bounced, v'sender, v'value) = v; + return v'sender; +} + (int, slice) __gen_load_SampleTactContract() inline { slice sc = get_data().begin_parse(); __tact_context_sys = sc~load_ref(); @@ -53,10 +58,6 @@ builder __gen_write_SampleTactContract(builder build_0, (int, slice) v) inline { set_data(b.end_cell()); } -() require(int $condition) impure { - throw_unless(131, $condition); -} - cell __gen_SampleTactContract_init(cell sys', slice $owner) { var (($self'counter, $self'owner)) = (null(), null()); $self'owner = $owner; @@ -67,10 +68,15 @@ cell __gen_SampleTactContract_init(cell sys', slice $owner) { return b'.end_cell(); } +((int, slice), ()) __gen_SampleTactContract_requireOwner((int, slice) $self) impure { + var (($self'counter, $self'owner)) = $self; + throw_unless(132, __tact_address_eq(__gen_Context_get_sender(__tact_context_get()), $self'owner)); + return (($self'counter, $self'owner), ()); +} + ((int, slice), ()) __gen_SampleTactContract_add((int, slice) $self, int $v) impure { var (($self'counter, $self'owner)) = $self; - var ($ctx'bounced, $ctx'sender, $ctx'value) = __tact_context_get(); - require(__tact_address_eq($ctx'sender, $self'owner)); + ($self'counter, $self'owner)~__gen_SampleTactContract_requireOwner(); $self'counter = ($self'counter + $v); return (($self'counter, $self'owner), ()); } @@ -97,6 +103,17 @@ _ __gen_get_balance() method_id(104128) { return res; } +int __gen_SampleTactContract_meaning_of_life((int, slice) $self) impure { + var (($self'counter, $self'owner)) = $self; + return 42; +} + +_ __gen_get_meaning_of_life() method_id(109816) { + var self = __gen_load_SampleTactContract(); + var res = __gen_SampleTactContract_meaning_of_life(self); + return res; +} + slice __gen_SampleTactContract_owner((int, slice) $self) impure { var (($self'counter, $self'owner)) = $self; return $self'owner; @@ -191,5 +208,5 @@ _ supported_interfaces() method_id { } _ get_abi_ipfs() { - return "ipfs://Qma4YGeJrLLeH7BSS3ijaEhDgwYJkPxTRZTcdoYQKKCFhc"; + return "ipfs://QmQmT97WfcHnnaLxmApnhWR2S9Qtbnywx98uGoAKBVTERP"; } \ No newline at end of file diff --git a/sources/output/sample_SampleTactContract.fif b/sources/output/sample_SampleTactContract.fif index b391705..3fdecd8 100644 --- a/sources/output/sample_SampleTactContract.fif +++ b/sources/output/sample_SampleTactContract.fif @@ -7,15 +7,18 @@ PROGRAM{ DECLPROC __gen_read_Add DECLPROC __gen_write_SampleTactContract DECLPROC __gen_read_SampleTactContract + DECLPROC __gen_Context_get_sender DECLPROC __gen_load_SampleTactContract DECLPROC __gen_store_SampleTactContract - DECLPROC require DECLPROC __gen_SampleTactContract_init + DECLPROC __gen_SampleTactContract_requireOwner DECLPROC __gen_SampleTactContract_add DECLPROC __gen_SampleTactContract_counter 104984 DECLMETHOD __gen_get_counter DECLPROC __gen_SampleTactContract_balance 104128 DECLMETHOD __gen_get_balance + DECLPROC __gen_SampleTactContract_meaning_of_life + 109816 DECLMETHOD __gen_get_meaning_of_life DECLPROC __gen_SampleTactContract_owner 83229 DECLMETHOD __gen_get_owner DECLPROC __gen_SampleTactContract_receive_Add @@ -65,6 +68,10 @@ PROGRAM{ __tact_load_address INLINECALLDICT s1 s2 XCHG }> + __gen_Context_get_sender PROCINLINE:<{ + DROP + NIP + }> __gen_load_SampleTactContract PROCINLINE:<{ c4 PUSH CTOS @@ -84,9 +91,6 @@ PROGRAM{ ENDC c4 POP }> - require PROC:<{ - 131 THROWIFNOT - }> __gen_SampleTactContract_init PROC:<{ 0 PUSHINT s0 s2 XCHG @@ -96,14 +100,17 @@ PROGRAM{ __gen_write_SampleTactContract INLINECALLDICT ENDC }> - __gen_SampleTactContract_add PROC:<{ + __gen_SampleTactContract_requireOwner PROC:<{ __tact_context_get INLINECALLDICT - DROP - NIP - s2 PUSH + __gen_Context_get_sender INLINECALLDICT + OVER __tact_address_eq INLINECALLDICT - require CALLDICT - s1 s2 XCHG + 132 THROWIFNOT + }> + __gen_SampleTactContract_add PROC:<{ + -ROT + __gen_SampleTactContract_requireOwner CALLDICT + s0 s2 XCHG ADD SWAP }> @@ -122,6 +129,14 @@ PROGRAM{ __gen_load_SampleTactContract INLINECALLDICT __gen_SampleTactContract_balance CALLDICT }> + __gen_SampleTactContract_meaning_of_life PROC:<{ + 2DROP + 42 PUSHINT + }> + __gen_get_meaning_of_life PROC:<{ + __gen_load_SampleTactContract INLINECALLDICT + __gen_SampleTactContract_meaning_of_life CALLDICT + }> __gen_SampleTactContract_owner PROC:<{ NIP }> @@ -221,6 +236,6 @@ PROGRAM{ 209801025412363888721030803524359905849 PUSHINT }> get_abi_ipfs PROC:<{ - x{697066733a2f2f516d61345947654a724c4c65483742535333696a614568446777594a6b507854525a5463646f59514b4b43466863} PUSHSLICE + x{697066733a2f2f516d516d543937576663486e6e614c786d41706e6857523253395174626e797778393875476f414b425654455250} PUSHSLICE }> }END>c diff --git a/sources/output/sample_SampleTactContract.rev.fif b/sources/output/sample_SampleTactContract.rev.fif index fc43ae9..3d1d796 100644 --- a/sources/output/sample_SampleTactContract.rev.fif +++ b/sources/output/sample_SampleTactContract.rev.fif @@ -62,7 +62,7 @@ SETCP0 s0 s1 XCHG s1 POP s1 s2 XCHG - 17 CALLDICT + 19 CALLDICT NEWC 2 GETGLOBVAR s0 s1 XCHG @@ -97,7 +97,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 18 CALLDICT + 20 CALLDICT NEWC 2 GETGLOBVAR s0 s1 XCHG @@ -125,7 +125,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 19 CALLDICT + 21 CALLDICT NEWC 2 GETGLOBVAR s0 s1 XCHG @@ -142,9 +142,6 @@ SETCP0 }> IFREFELSE 130 THROW - 11: - 131 THROWIFNOT - 12: 0 PUSHINT s0 s2 XCHG @@ -162,32 +159,40 @@ SETCP0 3 UNTUPLE s0 POP s1 POP - s2 PUSH + s1 PUSH SDEQ - 11 CALLDICT - s1 s2 XCHG + 132 THROWIFNOT + + 14: + ROTREV + 13 CALLDICT + s0 s2 XCHG ADD s0 s1 XCHG - 14: + 15: s0 POP - 15: + 16: 2DROP BALANCE 0 INDEX - 16: - s1 POP - 17: - 13 CALLDICT + 2DROP + 42 PUSHINT 18: - 1 PUSHINT - 13 CALLDICT + s1 POP 19: + 14 CALLDICT + + 20: + 1 PUSHINT + 14 CALLDICT + + 21: s0 s1 XCHG DEC s0 s1 XCHG @@ -206,7 +211,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 16 CALLDICT + 18 CALLDICT 104128: c4 PUSH @@ -219,7 +224,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 15 CALLDICT + 16 CALLDICT 104984: c4 PUSH @@ -232,7 +237,20 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 14 CALLDICT + 15 CALLDICT + + 109816: + c4 PUSH + CTOS + LDREF + s0 s1 XCHG + 2 SETGLOBVAR + 32 LDU + LDMSGADDR + s0 s1 XCHG + s1 s2 XCHG + 1 2 BLKDROP2 + 17 CALLDICT 113617: 123515602279859691144772641439386770278 PUSHINT diff --git a/sources/output/sample_SampleTactContract.ts b/sources/output/sample_SampleTactContract.ts index eb5cfc7..a97bf9d 100644 --- a/sources/output/sample_SampleTactContract.ts +++ b/sources/output/sample_SampleTactContract.ts @@ -213,7 +213,7 @@ export function unpackTupleAdd(slice: TupleSlice4): Add { return { $$type: 'Add', amount: amount }; } export async function SampleTactContract_init(owner: Address) { - const __code = 'te6ccgECIAEAAhwAART/APSkE/S88sgLAQIBYgIDAgLLBAUCASAYGQIBIAYHAgFiEhMB6d9v24EOuk4Q/KmBBrhY/vAWhpgYC42GAAyL/IuHEA/SAYKiCKt4H8MIFIrfAQQQhiq5qD3UcaGHaiaGoA/DFpj/0gAIk2CQFpj4DBCGKrmoPdeXBA6Y+AmIl4COR8IQDmLIFlj4Dni2T2qnBgAEiYcYb5YEFAgCASAKCwHi+QEggvDE+NcjEu3971t77HgzvbsWLRURvXipEq7Q8mN69lVyrrqOIzDtRNDUAfhi0x/6QAESbBLwEsj4QgHMWQLLHwHPFsntVNsx4ILw3mcP7oxWEhl9P9K0CUaKxioIBPnBlhOsS9Mkdx6QjHi64wIJAETtRNDUAfhi0x/6QAESbBLwE8j4QgHMWQLLHwHPFsntVNsxAAf3lwQcAgEgDA0CASAODwIBIBARABkcALIzFkCyx8BzxbJgAB0+EFvIzAxIscF8AsSoAGAAAwwgAAsW/gnbxCACASAUFQIBIBYXAAMMYAAFPANgAAccfANgAAcAaUBgAgEgGhsCAUgcHQAJuz2fAMgAJ7hR3tRNDUAfhi0x/6QAESbBLwEIAgFYHh8ATbd6ME4LnYerpZXPY9CdhzrJUKNs0E4TusalpWyPlmRadeW/vixHMAAnr2B2omhqAPwxaY/9IACJNgl4B8AAJ60MdqJoagD8MWmP/SAAiTYJeAdA'; + const __code = 'te6ccgECJAEAAkMAART/APSkE/S88sgLAQIBYgIDAgLLBAUCASAaGwIBIAYHAgFIEBEB6d9v24EOuk4Q/KmBBrhY/vAWhpgYC42GAAyL/IuHEA/SAYKiCKt4H8MIFIrfAQQQhiq5qD3UcaGHaiaGoA/DFpj/0gAIk2CQFpj4DBCGKrmoPdeXBA6Y+AmIl4CeR8IQDmLIFlj4Dni2T2qnBgAEiYcYb5YEFAgCAVgKCwHi+QEggvDE+NcjEu3971t77HgzvbsWLRURvXipEq7Q8mN69lVyrrqOIzDtRNDUAfhi0x/6QAESbBLwFMj4QgHMWQLLHwHPFsntVNsx4ILw3mcP7oxWEhl9P9K0CUaKxioIBPnBlhOsS9Mkdx6QjHi64wIJAETtRNDUAfhi0x/6QAESbBLwFcj4QgHMWQLLHwHPFsntVNsxAgEgDA0CASAODwAZHACyMxZAssfAc8WyYAAZPhBbyMwMSHHBfLghIAANFnwDQKgAYAADDCACASASEwIBSBgZAgEgFBUCASAWFwALFv4J28QgAAcW4AqgAAMMYAAFPAOgAAccfAOgAAcAaUBgAgEgHB0CAUgeHwAJuz2fAMgAJ7hR3tRNDUAfhi0x/6QAESbBLwEoAgFYICECASAiIwAnr2B2omhqAPwxaY/9IACJNgl4CEAAJ60MdqJoagD8MWmP/SAAiTYJeAfAACezPjtRNDUAfhi0x/6QAESbBLwEYABNsvRgnBc7D1dLK57HoTsOdZKhRtmgnCd1jUtK2R8syLTry398WI5g'; const depends = new Map(); let systemCell = beginCell().storeDict(null).endCell(); let __stack: StackItem[] = []; @@ -320,6 +320,22 @@ export class SampleTactContract { throw e; } } + async getMeaningOfLife() { + try { + let __stack: StackItem[] = []; + let result = await this.executor.get('meaning_of_life', __stack, { debug: true }); + if (result.debugLogs.length > 0) { console.warn(result.debugLogs); } + return result.stack.readBigNumber(); + } catch (e) { + if (e instanceof ExecuteError) { + if (e.debugLogs.length > 0) { console.warn(e.debugLogs); } + if (SampleTactContract_errors[e.exitCode.toString()]) { + throw new Error(SampleTactContract_errors[e.exitCode.toString()]); + } + } + throw e; + } + } async getOwner() { try { let __stack: StackItem[] = []; From 0ed2390f2950184a025a0844db9e27d660bcf384 Mon Sep 17 00:00:00 2001 From: Shahar Yakir Date: Thu, 22 Dec 2022 14:07:53 +0200 Subject: [PATCH 3/4] tonstarter functionality --- sources/contract.spec.ts | 45 ++- sources/contract.tact | 15 + sources/output/sample_SampleTactContract.abi | 77 +++++ .../output/sample_SampleTactContract.abi.ipfs | 2 +- sources/output/sample_SampleTactContract.boc | Bin 591 -> 974 bytes sources/output/sample_SampleTactContract.fc | 106 ++++++- sources/output/sample_SampleTactContract.fif | 194 ++++++++++++- .../output/sample_SampleTactContract.rev.fif | 271 ++++++++++++++++-- sources/output/sample_SampleTactContract.ts | 70 ++++- 9 files changed, 750 insertions(+), 30 deletions(-) diff --git a/sources/contract.spec.ts b/sources/contract.spec.ts index e184fc8..acb476b 100644 --- a/sources/contract.spec.ts +++ b/sources/contract.spec.ts @@ -7,6 +7,7 @@ import BN from 'bn.js'; describe('contract', () => { let owner = randomAddress(0, 'some-owner'); let nonOwner = randomAddress(0, 'some-non-owner'); + let newOwner = randomAddress(0, 'new-owner'); let init: { code: Cell data: Cell @@ -16,7 +17,7 @@ describe('contract', () => { beforeEach(async () => { init = await SampleTactContract_init(owner); - executor = await createExecutorFromCode(init); + executor = await createExecutorFromCode({...init, balance: toNano(1)}); contract = new SampleTactContract(executor); }) @@ -36,7 +37,7 @@ describe('contract', () => { it('should get meaning of life', async() => { expect((await contract.getMeaningOfLife()).toString()).toEqual('42'); - }) + }); it('should increment counter', async() => { await contract.send( @@ -48,5 +49,43 @@ describe('contract', () => { ); await contract.send({ amount: toNano(1), from: nonOwner }, 'dec'); expect((await contract.getCounter()).toString()).toEqual('12'); - }) + }); + + it('should deny changing owner', async() => { + await expect(contract.send( + { amount: toNano(1), from: nonOwner }, + {$$type: "ChangeOwner", newOwner} + )).rejects.toThrowError('Access denied'); + }); + + it('should change owner', async() => { + await contract.send( + { amount: toNano(1), from: owner }, + {$$type: "ChangeOwner", newOwner} + ) + expect((await contract.getOwner()).toFriendly()).toEqual(newOwner.toFriendly()); + }); + + it('should withdraw', async() => { + await contract.send( + { amount: toNano(1), from: owner }, + {$$type: "Withdraw", amount: toNano(0.5)} + ) + + // TODO tx-emulator supports balances + }); + + it('should not be able to withdraw over balance', async() => { + await expect( contract.send( + { amount: toNano(1), from: owner }, + {$$type: "Withdraw", amount: toNano(1.5)} + )).rejects.toThrowError('Exit code: 478'); + }); + + it('should not be able to withdraw from non-owner', async() => { + await expect( contract.send( + { amount: toNano(1), from: nonOwner }, + {$$type: "Withdraw", amount: toNano(0.5)} + )).rejects.toThrowError('Access denied'); + }); }); \ No newline at end of file diff --git a/sources/contract.tact b/sources/contract.tact index fa7cb66..4053d2c 100644 --- a/sources/contract.tact +++ b/sources/contract.tact @@ -1,7 +1,12 @@ +import "@stdlib/ownable"; + message Add { amount: Int as uint32; } +message Withdraw { + amount: Int; +} contract SampleTactContract with OwnableTransferable { counter: Int as uint32; @@ -23,6 +28,16 @@ contract SampleTactContract with OwnableTransferable { self.add(msg.amount); } + receive(msg: Withdraw) { + self.requireOwner(); + nativeThrowUnless(478, myBalance() > msg.amount); + send(SendParameters{ + to: self.owner, + value: msg.amount, + bounce: false + }); + } + receive("increment") { self.add(1); } diff --git a/sources/output/sample_SampleTactContract.abi b/sources/output/sample_SampleTactContract.abi index 8109b64..79e2a35 100644 --- a/sources/output/sample_SampleTactContract.abi +++ b/sources/output/sample_SampleTactContract.abi @@ -277,6 +277,40 @@ } } }, + { + "name": "ChangeOwner", + "header": 0, + "fields": [ + { + "name": "newOwner", + "type": { + "kind": "ref", + "name": "Address", + "optional": false + } + } + ], + "allocation": { + "prefix": 3067051791, + "root": { + "fields": [ + { + "index": 0, + "size": { + "bits": 267, + "refs": 0 + }, + "kind": "address" + } + ], + "next": null, + "size": { + "bits": 267, + "refs": 0 + } + } + } + }, { "name": "Add", "header": 0, @@ -311,6 +345,41 @@ } } } + }, + { + "name": "Withdraw", + "header": 0, + "fields": [ + { + "name": "amount", + "type": { + "kind": "ref", + "name": "Int", + "optional": false + } + } + ], + "allocation": { + "prefix": 1286094280, + "root": { + "fields": [ + { + "index": 0, + "size": { + "bits": 257, + "refs": 0 + }, + "kind": "int", + "bits": 257 + } + ], + "next": null, + "size": { + "bits": 257, + "refs": 0 + } + } + } } ], "init": { @@ -331,6 +400,10 @@ "kind": "internal-binary", "type": "Add" }, + { + "kind": "internal-binary", + "type": "Withdraw" + }, { "kind": "internal-comment", "comment": "increment" @@ -338,6 +411,10 @@ { "kind": "internal-comment", "comment": "dec" + }, + { + "kind": "internal-binary", + "type": "ChangeOwner" } ], "getters": [ diff --git a/sources/output/sample_SampleTactContract.abi.ipfs b/sources/output/sample_SampleTactContract.abi.ipfs index 27a2941..2febe05 100644 --- a/sources/output/sample_SampleTactContract.abi.ipfs +++ b/sources/output/sample_SampleTactContract.abi.ipfs @@ -1 +1 @@ -{"version":"0.0.1","name":"SampleTactContract","structs":[{"name":"StateInit","header":0,"fields":[{"name":"code","type":{"kind":"ref","name":"Cell","optional":false}},{"name":"data","type":{"kind":"ref","name":"Cell","optional":false}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":0,"refs":1},"kind":"cell"},{"index":1,"size":{"bits":0,"refs":1},"kind":"cell"}],"next":null,"size":{"bits":0,"refs":2}}}},{"name":"Context","header":0,"fields":[{"name":"bounced","type":{"kind":"ref","name":"Bool","optional":false}},{"name":"sender","type":{"kind":"ref","name":"Address","optional":false}},{"name":"value","type":{"kind":"ref","name":"Int","optional":false}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":1,"refs":0},"kind":"int","bits":1},{"index":1,"size":{"bits":267,"refs":0},"kind":"address"},{"index":2,"size":{"bits":257,"refs":0},"kind":"int","bits":257}],"next":null,"size":{"bits":525,"refs":0}}}},{"name":"SendParameters","header":0,"fields":[{"name":"bounce","type":{"kind":"ref","name":"Bool","optional":false}},{"name":"to","type":{"kind":"ref","name":"Address","optional":false}},{"name":"value","type":{"kind":"ref","name":"Int","optional":false}},{"name":"mode","type":{"kind":"ref","name":"Int","optional":false}},{"name":"body","type":{"kind":"ref","name":"Cell","optional":true}},{"name":"code","type":{"kind":"ref","name":"Cell","optional":true}},{"name":"data","type":{"kind":"ref","name":"Cell","optional":true}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":1,"refs":0},"kind":"int","bits":1},{"index":1,"size":{"bits":267,"refs":0},"kind":"address"},{"index":2,"size":{"bits":257,"refs":0},"kind":"int","bits":257},{"index":3,"size":{"bits":257,"refs":0},"kind":"int","bits":257},{"index":4,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":4,"size":{"bits":0,"refs":1},"kind":"cell"}},{"index":5,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":5,"size":{"bits":0,"refs":1},"kind":"cell"}},{"index":6,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":6,"size":{"bits":0,"refs":1},"kind":"cell"}}],"next":null,"size":{"bits":785,"refs":3}}}},{"name":"Add","header":0,"fields":[{"name":"amount","type":{"kind":"ref","name":"Int","optional":false}}],"allocation":{"prefix":3310826759,"root":{"fields":[{"index":0,"size":{"bits":32,"refs":0},"kind":"uint","bits":32}],"next":null,"size":{"bits":32,"refs":0}}}}],"init":{"name":"init_SampleTactContract","args":[{"name":"owner","type":{"kind":"ref","name":"Address","optional":false}}]},"receivers":[{"kind":"internal-binary","type":"Add"},{"kind":"internal-comment","comment":"increment"},{"kind":"internal-comment","comment":"dec"}],"getters":[{"name":"counter","args":[],"returns":{"kind":"ref","name":"Int","optional":false}},{"name":"balance","args":[],"returns":{"kind":"ref","name":"Int","optional":false}},{"name":"meaning_of_life","args":[],"returns":{"kind":"ref","name":"Int","optional":false}},{"name":"owner","args":[],"returns":{"kind":"ref","name":"Address","optional":false}}],"dependsOn":{},"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"}}} \ No newline at end of file +{"version":"0.0.1","name":"SampleTactContract","structs":[{"name":"StateInit","header":0,"fields":[{"name":"code","type":{"kind":"ref","name":"Cell","optional":false}},{"name":"data","type":{"kind":"ref","name":"Cell","optional":false}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":0,"refs":1},"kind":"cell"},{"index":1,"size":{"bits":0,"refs":1},"kind":"cell"}],"next":null,"size":{"bits":0,"refs":2}}}},{"name":"Context","header":0,"fields":[{"name":"bounced","type":{"kind":"ref","name":"Bool","optional":false}},{"name":"sender","type":{"kind":"ref","name":"Address","optional":false}},{"name":"value","type":{"kind":"ref","name":"Int","optional":false}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":1,"refs":0},"kind":"int","bits":1},{"index":1,"size":{"bits":267,"refs":0},"kind":"address"},{"index":2,"size":{"bits":257,"refs":0},"kind":"int","bits":257}],"next":null,"size":{"bits":525,"refs":0}}}},{"name":"SendParameters","header":0,"fields":[{"name":"bounce","type":{"kind":"ref","name":"Bool","optional":false}},{"name":"to","type":{"kind":"ref","name":"Address","optional":false}},{"name":"value","type":{"kind":"ref","name":"Int","optional":false}},{"name":"mode","type":{"kind":"ref","name":"Int","optional":false}},{"name":"body","type":{"kind":"ref","name":"Cell","optional":true}},{"name":"code","type":{"kind":"ref","name":"Cell","optional":true}},{"name":"data","type":{"kind":"ref","name":"Cell","optional":true}}],"allocation":{"prefix":null,"root":{"fields":[{"index":0,"size":{"bits":1,"refs":0},"kind":"int","bits":1},{"index":1,"size":{"bits":267,"refs":0},"kind":"address"},{"index":2,"size":{"bits":257,"refs":0},"kind":"int","bits":257},{"index":3,"size":{"bits":257,"refs":0},"kind":"int","bits":257},{"index":4,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":4,"size":{"bits":0,"refs":1},"kind":"cell"}},{"index":5,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":5,"size":{"bits":0,"refs":1},"kind":"cell"}},{"index":6,"size":{"bits":1,"refs":1},"kind":"optional","inner":{"index":6,"size":{"bits":0,"refs":1},"kind":"cell"}}],"next":null,"size":{"bits":785,"refs":3}}}},{"name":"ChangeOwner","header":0,"fields":[{"name":"newOwner","type":{"kind":"ref","name":"Address","optional":false}}],"allocation":{"prefix":3067051791,"root":{"fields":[{"index":0,"size":{"bits":267,"refs":0},"kind":"address"}],"next":null,"size":{"bits":267,"refs":0}}}},{"name":"Add","header":0,"fields":[{"name":"amount","type":{"kind":"ref","name":"Int","optional":false}}],"allocation":{"prefix":3310826759,"root":{"fields":[{"index":0,"size":{"bits":32,"refs":0},"kind":"uint","bits":32}],"next":null,"size":{"bits":32,"refs":0}}}},{"name":"Withdraw","header":0,"fields":[{"name":"amount","type":{"kind":"ref","name":"Int","optional":false}}],"allocation":{"prefix":1286094280,"root":{"fields":[{"index":0,"size":{"bits":257,"refs":0},"kind":"int","bits":257}],"next":null,"size":{"bits":257,"refs":0}}}}],"init":{"name":"init_SampleTactContract","args":[{"name":"owner","type":{"kind":"ref","name":"Address","optional":false}}]},"receivers":[{"kind":"internal-binary","type":"Add"},{"kind":"internal-binary","type":"Withdraw"},{"kind":"internal-comment","comment":"increment"},{"kind":"internal-comment","comment":"dec"},{"kind":"internal-binary","type":"ChangeOwner"}],"getters":[{"name":"counter","args":[],"returns":{"kind":"ref","name":"Int","optional":false}},{"name":"balance","args":[],"returns":{"kind":"ref","name":"Int","optional":false}},{"name":"meaning_of_life","args":[],"returns":{"kind":"ref","name":"Int","optional":false}},{"name":"owner","args":[],"returns":{"kind":"ref","name":"Address","optional":false}}],"dependsOn":{},"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"}}} \ No newline at end of file diff --git a/sources/output/sample_SampleTactContract.boc b/sources/output/sample_SampleTactContract.boc index b5bd5477f11dca78ee06b8eeab596d77479ef199..b7c7eade6013737313d310f36be5eccb2d0d7dcc 100644 GIT binary patch delta 806 zcmZvaQA|>C6vog0-b;X75Kut`<6;6@q7bbf!eZtF59xH7vv7;mOFC->u57WmT64La z#H5!-$;vj@D3h&nwmE3Av|O~*^`I*@H($~uU&2D`&wSE)`EBPr-}!cScH-0ruHgCi zfD;iW1mtURY;w5)^>v9~ z#68(#ef$2OfSbDPOazX_^Qvw0i3s?N3&Pb%7wsE9hzfk)4tRu6y=|GKa@*LP2_I7| z!B8_8(i{v$0Y+{fhCCnr+^e!W*#?v*=fTPPkt^nh4K@JIyS%y3q&>8B#(OGFuBt5L zyoH=ph8A%ZwSXU)wVoQlTB>J@xTys!WMm*sM#7C|ZSPd18QX5!LyKxGxq)?Q>5LM# zI%J?wLD(#_hTle9v9JTE-vEk3V*A7tZMztCk7^hY%G?w?1P;8fQiV~t6G)l?fy}eP zpL@dqSC+^MVku+L6oKGVob|CZE_M}TXm!A`Pzf;OlyU6mtyo4c2cTJLw?$`dN;d@# z;Huo%!G#uUCZlvWe!V?qz<*Uafbu~>A~4nNSj)` z>kRbl=XYd9K>vjPN455giCl^kgggBuguXaX!tu82>dViyKCXK9h!vn$^Ecj7%zw3{1`wxuxr+q?s5M*w~pEJp=?9U*6BZ-N?7gPvFnWMz$Rh z|2~Md&5+>kZDZi+{?pwqz<-IcX%WZj3i-nvB3<_xSp?d&cCN6!Qn;`^ORa4I|6#Ei z|1U9cOiq{}Hsc2mMDqG{7QPujI6I~{%yT~^z?XDFEaC@W#Ww$} X __tact_not_null(X x) { throw_if(128, null?(x)); return x; } + global (int, slice, int) __tact_context; global cell __tact_context_sys; @@ -21,12 +23,24 @@ int __tact_address_eq(slice a, slice b) inline { return equal_slice_bits(a, b); } +(slice, ((slice))) __gen_read_ChangeOwner(slice sc_0) inline { + throw_unless(129, sc_0~load_uint(32) == 3067051791); + var v'newOwner = sc_0~__tact_load_address(); + return (sc_0, (v'newOwner)); +} + (slice, ((int))) __gen_read_Add(slice sc_0) inline { throw_unless(129, sc_0~load_uint(32) == 3310826759); var v'amount = sc_0~load_uint(32); return (sc_0, (v'amount)); } +(slice, ((int))) __gen_read_Withdraw(slice sc_0) inline { + throw_unless(129, sc_0~load_uint(32) == 1286094280); + var v'amount = sc_0~load_int(257); + return (sc_0, (v'amount)); +} + builder __gen_write_SampleTactContract(builder build_0, (int, slice) v) inline { var (v'counter, v'owner) = v; build_0 = store_uint(build_0, v'counter, 32); @@ -58,6 +72,57 @@ _ __gen_Context_get_sender((int, slice, int) v) inline { set_data(b.end_cell()); } +builder storeBool(builder $s, int $value) impure { + if ($value) { + return store_int($s, (- 1), 1); + } else { + return store_int($s, 0, 1); + } +} + +() send((int, slice, int, int, cell, cell, cell) $params) impure { + 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 = storeBool($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)) | (~ null?($params'data)))) { + $b = storeBool($b, true); + builder $bc = begin_cell(); + $bc = storeBool($bc, false); + $bc = storeBool($bc, false); + if ((~ null?($params'code))) { + $bc = storeBool($bc, true); + $bc = store_ref($bc, __tact_not_null($params'code)); + } else { + $bc = storeBool($bc, false); + } + if ((~ null?($params'data))) { + $bc = storeBool($bc, true); + $bc = store_ref($bc, __tact_not_null($params'data)); + } else { + $bc = storeBool($bc, false); + } + $bc = storeBool($bc, false); + $b = storeBool($b, true); + $b = store_ref($b, end_cell($bc)); + } else { + $b = storeBool($b, false); + } + cell $body = $params'body; + if ((~ null?($body))) { + $b = storeBool($b, true); + $b = store_ref($b, __tact_not_null($body)); + } else { + $b = storeBool($b, false); + } + cell $c = end_cell($b); + send_raw_message($c, $params'mode); +} + cell __gen_SampleTactContract_init(cell sys', slice $owner) { var (($self'counter, $self'owner)) = (null(), null()); $self'owner = $owner; @@ -132,6 +197,15 @@ _ __gen_get_owner() method_id(83229) { return (($self'counter, $self'owner), ()); } +(((int, slice)), ()) __gen_SampleTactContract_receive_Withdraw((int, slice) $self, (int) $msg) impure { + var ($self'counter, $self'owner) = $self; + var ($msg'amount) = $msg; + ($self'counter, $self'owner)~__gen_SampleTactContract_requireOwner(); + throw_unless(478, (__tact_my_balance() > $msg'amount)); + send((false, $self'owner, $msg'amount, 0, null(), null(), null())); + return (($self'counter, $self'owner), ()); +} + ((int, slice), ()) __gen_SampleTactContract_receive_comment_c4f8d72312edfdef5b7bec7833bdbb162d1511bd78a912aed0f2637af65572ae((int, slice) $self) impure { var ($self'counter, $self'owner) = $self; ($self'counter, $self'owner)~__gen_SampleTactContract_add(1); @@ -144,6 +218,14 @@ _ __gen_get_owner() method_id(83229) { return (($self'counter, $self'owner), ()); } +(((int, slice)), ()) __gen_SampleTactContract_receive_ChangeOwner((int, slice) $self, (slice) $msg) impure { + var ($self'counter, $self'owner) = $self; + var ($msg'newOwner) = $msg; + ($self'counter, $self'owner)~__gen_SampleTactContract_requireOwner(); + $self'owner = $msg'newOwner; + return (($self'counter, $self'owner), ()); +} + () recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure { @@ -172,6 +254,24 @@ _ __gen_get_owner() method_id(83229) { return (); } + ;; Receive Withdraw message + if (op == 1286094280) { + var self = __gen_load_SampleTactContract(); + var msg = in_msg~__gen_read_Withdraw(); + self~__gen_SampleTactContract_receive_Withdraw(msg); + __gen_store_SampleTactContract(self); + return (); + } + + ;; Receive ChangeOwner message + if (op == 3067051791) { + var self = __gen_load_SampleTactContract(); + var msg = in_msg~__gen_read_ChangeOwner(); + self~__gen_SampleTactContract_receive_ChangeOwner(msg); + __gen_store_SampleTactContract(self); + return (); + } + ;; Text Receivers if (op == 0) { var text_op = slice_hash(in_msg); @@ -203,10 +303,12 @@ cell init_SampleTactContract(cell sys', slice owner) method_id { _ supported_interfaces() method_id { return ( "org.ton.introspection.v0"H >> 128, - "org.ton.abi.ipfs.v0"H >> 128 + "org.ton.abi.ipfs.v0"H >> 128, + "org.ton.ownable.transferable"H >> 128, + "org.ton.ownable"H >> 128 ); } _ get_abi_ipfs() { - return "ipfs://QmQmT97WfcHnnaLxmApnhWR2S9Qtbnywx98uGoAKBVTERP"; + return "ipfs://QmP6NPYC9UpdDFbXebYayxt72okf63nm6N4nG2U7qkvPbn"; } \ No newline at end of file diff --git a/sources/output/sample_SampleTactContract.fif b/sources/output/sample_SampleTactContract.fif index 3fdecd8..8e82277 100644 --- a/sources/output/sample_SampleTactContract.fif +++ b/sources/output/sample_SampleTactContract.fif @@ -1,15 +1,20 @@ PROGRAM{ DECLPROC __tact_my_balance + DECLPROC __tact_not_null DECLPROC __tact_context_get DECLPROC __tact_load_address DECLPROC __tact_store_address DECLPROC __tact_address_eq + DECLPROC __gen_read_ChangeOwner DECLPROC __gen_read_Add + DECLPROC __gen_read_Withdraw DECLPROC __gen_write_SampleTactContract DECLPROC __gen_read_SampleTactContract DECLPROC __gen_Context_get_sender DECLPROC __gen_load_SampleTactContract DECLPROC __gen_store_SampleTactContract + DECLPROC storeBool + DECLPROC send DECLPROC __gen_SampleTactContract_init DECLPROC __gen_SampleTactContract_requireOwner DECLPROC __gen_SampleTactContract_add @@ -22,8 +27,10 @@ PROGRAM{ DECLPROC __gen_SampleTactContract_owner 83229 DECLMETHOD __gen_get_owner DECLPROC __gen_SampleTactContract_receive_Add + DECLPROC __gen_SampleTactContract_receive_Withdraw DECLPROC __gen_SampleTactContract_receive_comment_c4f8d72312edfdef5b7bec7833bdbb162d1511bd78a912aed0f2637af65572ae DECLPROC __gen_SampleTactContract_receive_comment_de670fee8c5612197d3fd2b409468ac62a0804f9c19613ac4bd324771e908c78 + DECLPROC __gen_SampleTactContract_receive_ChangeOwner DECLPROC recv_internal 78809 DECLMETHOD init_SampleTactContract 113617 DECLMETHOD supported_interfaces @@ -34,6 +41,11 @@ PROGRAM{ BALANCE FIRST }> + __tact_not_null PROC:<{ + DUP + ISNULL + 128 THROWIF + }> __tact_context_get PROCINLINE:<{ __tact_context GETGLOB UNTRIPLE @@ -48,6 +60,14 @@ PROGRAM{ __tact_address_eq PROCINLINE:<{ SDEQ }> + __gen_read_ChangeOwner PROCINLINE:<{ + 32 LDU + SWAP + 3067051791 PUSHINT + EQUAL + 129 THROWIFNOT + __tact_load_address INLINECALLDICT + }> __gen_read_Add PROCINLINE:<{ 32 LDU SWAP @@ -57,6 +77,16 @@ PROGRAM{ 32 LDU SWAP }> + __gen_read_Withdraw PROCINLINE:<{ + 32 LDU + SWAP + 1286094280 PUSHINT + EQUAL + 129 THROWIFNOT + 257 PUSHINT + LDIX + SWAP + }> __gen_write_SampleTactContract PROCINLINE:<{ s0 s2 XCHG 32 STU @@ -91,6 +121,115 @@ PROGRAM{ ENDC c4 POP }> + storeBool PROC:<{ + IFJMP:<{ + -1 PUSHINT + SWAP + 1 STI + }> + 0 PUSHINT + SWAP + 1 STI + }> + send PROC:<{ + NEWC + 1 PUSHINT + SWAP + 2 STI + s0 s7 XCHG2 + storeBool CALLDICT + 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 + s5 PUSH + ISNULL + NOT + OR + IF:<{ + TRUE + storeBool CALLDICT + NEWC + FALSE + storeBool CALLDICT + FALSE + storeBool CALLDICT + s4 PUSH + ISNULL + NOT + IF:<{ + TRUE + storeBool CALLDICT + s0 s4 XCHG + __tact_not_null CALLDICT + s0 s4 XCHG2 + STREF + }>ELSE<{ + s4 POP + s0 s3 XCHG + FALSE + storeBool CALLDICT + }> + s4 PUSH + ISNULL + NOT + IF:<{ + TRUE + storeBool CALLDICT + s0 s4 XCHG + __tact_not_null CALLDICT + s0 s4 XCHG2 + STREF + }>ELSE<{ + s4 POP + s0 s3 XCHG + FALSE + storeBool CALLDICT + }> + FALSE + storeBool CALLDICT + s0 s2 XCHG + TRUE + storeBool CALLDICT + s0 s2 XCHG + ENDC + ROT + STREF + }>ELSE<{ + s3 POP + s3 POP + SWAP + FALSE + storeBool CALLDICT + }> + OVER + ISNULL + NOT + IF:<{ + TRUE + storeBool CALLDICT + SWAP + __tact_not_null CALLDICT + SWAP + STREF + }>ELSE<{ + NIP + FALSE + storeBool CALLDICT + }> + ENDC + SWAP + SENDRAWMSG + }> __gen_SampleTactContract_init PROC:<{ 0 PUSHINT s0 s2 XCHG @@ -147,6 +286,25 @@ PROGRAM{ __gen_SampleTactContract_receive_Add PROC:<{ __gen_SampleTactContract_add CALLDICT }> + __gen_SampleTactContract_receive_Withdraw PROC:<{ + -ROT + __gen_SampleTactContract_requireOwner CALLDICT + __tact_my_balance INLINECALLDICT + s3 PUSH + GREATER + 478 THROWIFNOT + FALSE + SWAP + 0 PUSHINT + PUSHNULL + PUSHNULL + s3 PUSH + s0 s7 XCHG + 3 -ROLL + PUSHNULL + send CALLDICT + SWAP + }> __gen_SampleTactContract_receive_comment_c4f8d72312edfdef5b7bec7833bdbb162d1511bd78a912aed0f2637af65572ae PROC:<{ 1 PUSHINT __gen_SampleTactContract_add CALLDICT @@ -156,6 +314,12 @@ PROGRAM{ DEC SWAP }> + __gen_SampleTactContract_receive_ChangeOwner PROC:<{ + -ROT + __gen_SampleTactContract_requireOwner CALLDICT + DROP + SWAP + }> recv_internal PROC:<{ SAMEALTSAVE 0 PUSHINT @@ -202,6 +366,32 @@ PROGRAM{ __gen_SampleTactContract_receive_Add CALLDICT __gen_store_SampleTactContract INLINECALLDICT }> + DUP + 1286094280 PUSHINT + EQUAL + IFJMP:<{ + DROP + __gen_load_SampleTactContract INLINECALLDICT + s0 s2 XCHG + __gen_read_Withdraw INLINECALLDICT + NIP + s1 s2 XCHG + __gen_SampleTactContract_receive_Withdraw CALLDICT + __gen_store_SampleTactContract INLINECALLDICT + }> + DUP + 3067051791 PUSHINT + EQUAL + IFJMP:<{ + DROP + __gen_load_SampleTactContract INLINECALLDICT + s0 s2 XCHG + __gen_read_ChangeOwner INLINECALLDICT + NIP + s1 s2 XCHG + __gen_SampleTactContract_receive_ChangeOwner CALLDICT + __gen_store_SampleTactContract INLINECALLDICT + }> 0 EQINT IF:<{ HASHSU @@ -234,8 +424,10 @@ PROGRAM{ supported_interfaces PROC:<{ 123515602279859691144772641439386770278 PUSHINT 209801025412363888721030803524359905849 PUSHINT + 212791963610352222038671851416501365766 PUSHINT + 86142586315491086060343270784266291122 PUSHINT }> get_abi_ipfs PROC:<{ - x{697066733a2f2f516d516d543937576663486e6e614c786d41706e6857523253395174626e797778393875476f414b425654455250} PUSHSLICE + x{697066733a2f2f516d50364e50594339557064444662586562596179787437326f6b6636336e6d364e346e47325537716b7650626e} PUSHSLICE }> }END>c diff --git a/sources/output/sample_SampleTactContract.rev.fif b/sources/output/sample_SampleTactContract.rev.fif index 3d1d796..4608d2c 100644 --- a/sources/output/sample_SampleTactContract.rev.fif +++ b/sources/output/sample_SampleTactContract.rev.fif @@ -62,7 +62,85 @@ SETCP0 s0 s1 XCHG s1 POP s1 s2 XCHG - 19 CALLDICT + 24 CALLDICT + NEWC + 2 GETGLOBVAR + s0 s1 XCHG + STREF + ROTREV + s0 s2 XCHG + 32 STU + s0 s1 XCHG + STSLICER + ENDC + c4 POP + }> PUSHCONT + IFJMP + s0 PUSH + 1286094280 PUSHINT + EQUAL + <{ + s0 POP + c4 PUSH + CTOS + LDREF + s0 s1 XCHG + 2 SETGLOBVAR + 32 LDU + LDMSGADDR + s0 s1 XCHG + s1 s2 XCHG + 1 2 BLKDROP2 + s0 s2 XCHG + 32 LDU + s0 s1 XCHG + 1286094280 PUSHINT + EQUAL + 129 THROWIFNOT + 257 PUSHINT + LDI + s0 s1 XCHG + s1 POP + s1 s2 XCHG + 25 CALLDICT + NEWC + 2 GETGLOBVAR + s0 s1 XCHG + STREF + ROTREV + s0 s2 XCHG + 32 STU + s0 s1 XCHG + STSLICER + ENDC + c4 POP + }> IFJMPREF + s0 PUSH + 3067051791 PUSHINT + EQUAL + <{ + s0 POP + c4 PUSH + CTOS + LDREF + s0 s1 XCHG + 2 SETGLOBVAR + 32 LDU + LDMSGADDR + s0 s1 XCHG + s1 s2 XCHG + 1 2 BLKDROP2 + s0 s2 XCHG + 32 LDU + s0 s1 XCHG + 3067051791 PUSHINT + EQUAL + 129 THROWIFNOT + LDMSGADDR + s0 s1 XCHG + s1 POP + s1 s2 XCHG + 28 CALLDICT NEWC 2 GETGLOBVAR s0 s1 XCHG @@ -97,7 +175,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 20 CALLDICT + 26 CALLDICT NEWC 2 GETGLOBVAR s0 s1 XCHG @@ -125,7 +203,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 21 CALLDICT + 27 CALLDICT NEWC 2 GETGLOBVAR s0 s1 XCHG @@ -142,7 +220,130 @@ SETCP0 }> IFREFELSE 130 THROW - 12: + 2: + s0 PUSH + ISNULL + 128 THROWIF + + 15: + <{ + -1 PUSHINT + s0 s1 XCHG + 1 STI + }> PUSHCONT + IFJMP + 0 PUSHINT + s0 s1 XCHG + 1 STI + + 16: + NEWC + 1 PUSHINT + s0 s1 XCHG + 2 STI + s0 s7 XCHG2 + 15 CALLDICT + 0 PUSHINT + s0 s1 XCHG + 3 STI + s0 s5 XCHG2 + STSLICER + s0 s3 XCHG2 + STGRAMS + 0 PUSHINT + s0 s1 XCHG + 105 STI + s3 PUSH + ISNULL + NOT + s5 PUSH + ISNULL + NOT + OR + <{ + -1 PUSHINT + 15 CALLDICT + NEWC + 0 PUSHINT + 15 CALLDICT + 0 PUSHINT + 15 CALLDICT + s4 PUSH + ISNULL + NOT + <{ + -1 PUSHINT + 15 CALLDICT + s0 s4 XCHG + 2 CALLDICT + s0 s4 XCHG2 + STREF + }> PUSHCONT + <{ + s4 POP + s0 s3 XCHG + 0 PUSHINT + 15 CALLDICT + }> PUSHCONT + IFELSE + s4 PUSH + ISNULL + NOT + <{ + -1 PUSHINT + 15 CALLDICT + s0 s4 XCHG + 2 CALLDICT + s0 s4 XCHG2 + STREF + }> PUSHCONT + <{ + s4 POP + s0 s3 XCHG + 0 PUSHINT + 15 CALLDICT + }> PUSHCONT + IFELSE + 0 PUSHINT + 15 CALLDICT + s0 s2 XCHG + -1 PUSHINT + 15 CALLDICT + s0 s2 XCHG + ENDC + ROT + STREF + }> PUSHCONT + <{ + s3 POP + s3 POP + s0 s1 XCHG + 0 PUSHINT + 15 CALLDICT + }> PUSHCONT + IFELSE + s1 PUSH + ISNULL + NOT + <{ + -1 PUSHINT + 15 CALLDICT + s0 s1 XCHG + 2 CALLDICT + s0 s1 XCHG + STREF + }> PUSHCONT + <{ + s1 POP + 0 PUSHINT + 15 CALLDICT + }> PUSHCONT + IFELSE + ENDC + s0 s1 XCHG + SENDRAWMSG + + 17: 0 PUSHINT s0 s2 XCHG NEWC @@ -154,7 +355,7 @@ SETCP0 STSLICER ENDC - 13: + 18: 1 GETGLOBVAR 3 UNTUPLE s0 POP @@ -163,42 +364,68 @@ SETCP0 SDEQ 132 THROWIFNOT - 14: + 19: ROTREV - 13 CALLDICT + 18 CALLDICT s0 s2 XCHG ADD s0 s1 XCHG - 15: + 20: s0 POP - 16: + 21: 2DROP BALANCE 0 INDEX - 17: + 22: 2DROP 42 PUSHINT - 18: + 23: s1 POP - 19: - 14 CALLDICT + 24: + 19 CALLDICT - 20: + 25: + ROTREV + 18 CALLDICT + BALANCE + 0 INDEX + s3 PUSH + GREATER + 478 THROWIFNOT + 0 PUSHINT + s0 s1 XCHG + 0 PUSHINT + PUSHNULL + PUSHNULL + s3 PUSH + s0 s7 XCHG + 3 1 BLKSWAP + PUSHNULL + 16 CALLDICT + s0 s1 XCHG + + 26: 1 PUSHINT - 14 CALLDICT + 19 CALLDICT - 21: + 27: s0 s1 XCHG DEC s0 s1 XCHG + 28: + ROTREV + 18 CALLDICT + s0 POP + s0 s1 XCHG + 78809: - 12 CALLDICT + 17 CALLDICT owner: c4 PUSH @@ -211,7 +438,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 18 CALLDICT + 23 CALLDICT 104128: c4 PUSH @@ -224,7 +451,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 16 CALLDICT + 21 CALLDICT 104984: c4 PUSH @@ -237,7 +464,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 15 CALLDICT + 20 CALLDICT 109816: c4 PUSH @@ -250,11 +477,13 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 17 CALLDICT + 22 CALLDICT 113617: 123515602279859691144772641439386770278 PUSHINT 209801025412363888721030803524359905849 PUSHINT + 212791963610352222038671851416501365766 PUSHINT + 86142586315491086060343270784266291122 PUSHINT ) 19 DICTPUSHCONST DICTIGETJMPZ 11 THROWARG diff --git a/sources/output/sample_SampleTactContract.ts b/sources/output/sample_SampleTactContract.ts index a97bf9d..8cc6268 100644 --- a/sources/output/sample_SampleTactContract.ts +++ b/sources/output/sample_SampleTactContract.ts @@ -182,6 +182,36 @@ export function unpackTupleSendParameters(slice: TupleSlice4): SendParameters { const data = slice.readCellOpt(); return { $$type: 'SendParameters', bounce: bounce, to: to, value: value, mode: mode, body: body, code: code, data: data }; } +export type ChangeOwner = { + $$type: 'ChangeOwner'; + newOwner: Address; +} + +export function packChangeOwner(src: ChangeOwner): Cell { + let b_0 = new Builder(); + b_0 = b_0.storeUint(3067051791, 32); + b_0 = b_0.storeAddress(src.newOwner); + return b_0.endCell(); +} + +export function packStackChangeOwner(src: ChangeOwner, __stack: StackItem[]) { + __stack.push({ type: 'slice', cell: beginCell().storeAddress(src.newOwner).endCell() }); +} + +export function packTupleChangeOwner(src: ChangeOwner): StackItem[] { + let __stack: StackItem[] = []; + __stack.push({ type: 'slice', cell: beginCell().storeAddress(src.newOwner).endCell() }); + return __stack; +} + +export function unpackStackChangeOwner(slice: TupleSlice4): ChangeOwner { + const newOwner = slice.readAddress(); + return { $$type: 'ChangeOwner', newOwner: newOwner }; +} +export function unpackTupleChangeOwner(slice: TupleSlice4): ChangeOwner { + const newOwner = slice.readAddress(); + return { $$type: 'ChangeOwner', newOwner: newOwner }; +} export type Add = { $$type: 'Add'; amount: BN; @@ -212,8 +242,38 @@ export function unpackTupleAdd(slice: TupleSlice4): Add { const amount = slice.readBigNumber(); return { $$type: 'Add', amount: amount }; } +export type Withdraw = { + $$type: 'Withdraw'; + amount: BN; +} + +export function packWithdraw(src: Withdraw): Cell { + let b_0 = new Builder(); + b_0 = b_0.storeUint(1286094280, 32); + b_0 = b_0.storeInt(src.amount, 257); + return b_0.endCell(); +} + +export function packStackWithdraw(src: Withdraw, __stack: StackItem[]) { + __stack.push({ type: 'int', value: src.amount }); +} + +export function packTupleWithdraw(src: Withdraw): StackItem[] { + let __stack: StackItem[] = []; + __stack.push({ type: 'int', value: src.amount }); + return __stack; +} + +export function unpackStackWithdraw(slice: TupleSlice4): Withdraw { + const amount = slice.readBigNumber(); + return { $$type: 'Withdraw', amount: amount }; +} +export function unpackTupleWithdraw(slice: TupleSlice4): Withdraw { + const amount = slice.readBigNumber(); + return { $$type: 'Withdraw', amount: amount }; +} export async function SampleTactContract_init(owner: Address) { - const __code = 'te6ccgECJAEAAkMAART/APSkE/S88sgLAQIBYgIDAgLLBAUCASAaGwIBIAYHAgFIEBEB6d9v24EOuk4Q/KmBBrhY/vAWhpgYC42GAAyL/IuHEA/SAYKiCKt4H8MIFIrfAQQQhiq5qD3UcaGHaiaGoA/DFpj/0gAIk2CQFpj4DBCGKrmoPdeXBA6Y+AmIl4CeR8IQDmLIFlj4Dni2T2qnBgAEiYcYb5YEFAgCAVgKCwHi+QEggvDE+NcjEu3971t77HgzvbsWLRURvXipEq7Q8mN69lVyrrqOIzDtRNDUAfhi0x/6QAESbBLwFMj4QgHMWQLLHwHPFsntVNsx4ILw3mcP7oxWEhl9P9K0CUaKxioIBPnBlhOsS9Mkdx6QjHi64wIJAETtRNDUAfhi0x/6QAESbBLwFcj4QgHMWQLLHwHPFsntVNsxAgEgDA0CASAODwAZHACyMxZAssfAc8WyYAAZPhBbyMwMSHHBfLghIAANFnwDQKgAYAADDCACASASEwIBSBgZAgEgFBUCASAWFwALFv4J28QgAAcW4AqgAAMMYAAFPAOgAAccfAOgAAcAaUBgAgEgHB0CAUgeHwAJuz2fAMgAJ7hR3tRNDUAfhi0x/6QAESbBLwEoAgFYICECASAiIwAnr2B2omhqAPwxaY/9IACJNgl4CEAAJ60MdqJoagD8MWmP/SAAiTYJeAfAACezPjtRNDUAfhi0x/6QAESbBLwEYABNsvRgnBc7D1dLK57HoTsOdZKhRtmgnCd1jUtK2R8syLTry398WI5g'; + const __code = 'te6ccgECMQEAA8IAART/APSkE/S88sgLAQIBYgIDAgLLBAUCASAnKAIBIAYHAgEgDg8CAUgICQAV/KP4DlAHA4AOUAQC7U7ftwIddJwh+VMCDXCx/eAtDTAwFxsMABkX+RcOIB+kAwVEEVbwP4YQKRW+AgghDFVzUHuo40MO1E0NQB+GLTH/pAARJsEgLTHwGCEMVXNQe68uCB0x8BMRLwGMj4QgHMWQLLHwHPFsntVOAgghBMqD3IuuMCIICgsAC0IG7y0ICABuMO1E0NQB+GLTH/pAARJsEgLTHwGCEEyoPci68uCBgQEB1wABMRLwGcj4QgHMWQLLHwHPFsntVAGOghC2z38Puo40MO1E0NQB+GLTH/pAARJsEgLTHwGCELbPfw+68uCB+kABMRLwHMj4QgHMWQLLHwHPFsntVODAAJEw4w3ywIIMAeL5ASCC8MT41yMS7f3vW3vseDO9uxYtFRG9eKkSrtDyY3r2VXKuuo4jMO1E0NQB+GLTH/pAARJsEvAayPhCAcxZAssfAc8Wye1U2zHggvDeZw/ujFYSGX0/0rQJRorGKggE+cGWE6xL0yR3HpCMeLrjAg0ARO1E0NQB+GLTH/pAARJsEvAbyPhCAcxZAssfAc8Wye1U2zECASAQEQIBIB8gAgEgEhMCASAZGgIBIBQVAgEgFxgB9zIcQHKAVAH8A9wAcoCUAXPFlAD+gJwAcpoI26zJW6zsY49f/APyHDwD3DwDyRus5l/8A8E8AJQBMyVNANw8A/iJG6zmX/wDwTwAlAEzJU0A3DwD+Jw8A8Cf/APAslYzJYzMwFw8A/iIW6zmH/wDwHwAgHMlDFw8A/iyQGAWABkcALIzFkCyx8BzxbJgAAT7AAAZPhBbyMwMSHHBfLghIAANFnwEgKgAYAIBIBscAgEgHR4AAwwgAAsW/gnbxCAABxbgCqAAAwxgAgEgISIAC9LPgJGADAIBICMkAgEgJSYABTwE4AAzFnwEvgnbxAjvPLh3nABcG1tIwdVIG3wEAGAABxx8BOAABwBpQGACASApKgIBSCssAAm7PZ8BGAAnuFHe1E0NQB+GLTH/pAARJsEvAXgCAVgtLgIBIC8wACevYHaiaGoA/DFpj/0gAIk2CXgKwAAnrQx2omhqAPwxaY/9IACJNgl4CkAAJ7M+O1E0NQB+GLTH/pAARJsEvAWgAJWy9GCcFzsPV0srnsehOw51kqFG2aCcJ3WNS0rZHyzItOvLf3xYjmCcKAWPdCZRLm1qqkKwpYALAaCcEDOdWnnFfnSULAdYW4mR7KA='; const depends = new Map(); let systemCell = beginCell().storeDict(null).endCell(); let __stack: StackItem[] = []; @@ -255,17 +315,23 @@ export class SampleTactContract { readonly executor: ContractExecutor; constructor(executor: ContractExecutor) { this.executor = executor; } - async send(args: { amount: BN, from?: Address, debug?: boolean }, message: Add | 'increment' | 'dec') { + async send(args: { amount: BN, from?: Address, debug?: boolean }, message: Add | Withdraw | 'increment' | 'dec' | ChangeOwner) { let body: Cell | null = null; if (message && typeof message === 'object' && !(message instanceof Slice) && message.$$type === 'Add') { body = packAdd(message); } + if (message && typeof message === 'object' && !(message instanceof Slice) && message.$$type === 'Withdraw') { + body = packWithdraw(message); + } if (message === 'increment') { body = beginCell().storeUint(0, 32).storeBuffer(Buffer.from(message)).endCell(); } if (message === 'dec') { body = beginCell().storeUint(0, 32).storeBuffer(Buffer.from(message)).endCell(); } + if (message && typeof message === 'object' && !(message instanceof Slice) && message.$$type === 'ChangeOwner') { + body = packChangeOwner(message); + } if (body === null) { throw new Error('Invalid message type'); } try { let r = await this.executor.internal(new InternalMessage({ From 37e14640c9b6a8bfb8565f67176afa8b2c4e29b3 Mon Sep 17 00:00:00 2001 From: Shahar Yakir Date: Thu, 22 Dec 2022 14:44:32 +0200 Subject: [PATCH 4/4] added tests --- package.json | 2 +- sources/contract.spec.ts | 9 +- sources/contract.tact | 2 +- sources/output/sample_SampleTactContract.boc | Bin 974 -> 984 bytes sources/output/sample_SampleTactContract.fc | 6 +- sources/output/sample_SampleTactContract.fif | 6 +- .../output/sample_SampleTactContract.rev.fif | 61 +++--- sources/output/sample_SampleTactContract.ts | 2 +- yarn.lock | 178 +++++++++--------- 9 files changed, 143 insertions(+), 123 deletions(-) diff --git a/package.json b/package.json index 244dafd..1ac2ad6 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "jest": "^29.3.1", "prando": "^6.0.1", "qs": "^6.11.0", - "ton": "^12.3.2", + "ton": "12.3.2", "ton-contract-executor": "^0.6.0", "ton-crypto": "^3.2.0", "ton-nodejs": "^1.4.3", diff --git a/sources/contract.spec.ts b/sources/contract.spec.ts index acb476b..74db0b8 100644 --- a/sources/contract.spec.ts +++ b/sources/contract.spec.ts @@ -21,7 +21,7 @@ describe('contract', () => { contract = new SampleTactContract(executor); }) - it('should deploy correctly', async () => { + it('should increment counter', async () => { // Check counter expect((await contract.getCounter()).toString()).toEqual('0'); @@ -30,7 +30,9 @@ describe('contract', () => { // Check counter expect((await contract.getCounter()).toString()).toEqual('1'); - + }); + + it('should disallow increment from non-owner', async () => { // Non-owner await expect(() => contract.send({ amount: toNano(1), from: nonOwner }, 'increment')).rejects.toThrowError('Access denied'); }); @@ -71,7 +73,6 @@ describe('contract', () => { { amount: toNano(1), from: owner }, {$$type: "Withdraw", amount: toNano(0.5)} ) - // TODO tx-emulator supports balances }); @@ -79,7 +80,7 @@ describe('contract', () => { await expect( contract.send( { amount: toNano(1), from: owner }, {$$type: "Withdraw", amount: toNano(1.5)} - )).rejects.toThrowError('Exit code: 478'); + )).rejects.toThrowError('Constraints error'); }); it('should not be able to withdraw from non-owner', async() => { diff --git a/sources/contract.tact b/sources/contract.tact index 4053d2c..952f3ea 100644 --- a/sources/contract.tact +++ b/sources/contract.tact @@ -30,7 +30,7 @@ contract SampleTactContract with OwnableTransferable { receive(msg: Withdraw) { self.requireOwner(); - nativeThrowUnless(478, myBalance() > msg.amount); + require(myBalance() > msg.amount); send(SendParameters{ to: self.owner, value: msg.amount, diff --git a/sources/output/sample_SampleTactContract.boc b/sources/output/sample_SampleTactContract.boc index b7c7eade6013737313d310f36be5eccb2d0d7dcc..da37a5793993cb8c9fcf2e17b78922520e354c11 100644 GIT binary patch delta 316 zcmX@deuJHR>$^Ecj7-Li49sUHa!WI5YE9IrWSlc`ksqVf#E*82vXc!MLnmKg6q-Dp z(UMVS@5MVO3x-1nL7R=6G+zBEt|P9qn=Os)uw9i$el~3cE}VPz5_fCXmAoRCk6U z0jOJB2WXhC9s}oY+xd(dljWI3eLI*KBlHb`a)w3>>gyBA7G-2H{4vbz|Es{zX~tQ> p?ZBYEmIqyw>i~oLW;^RZ6H|sdi7m(fO<-`D&9aB}!Q@6}UjPx`SL*-( delta 306 zcmcb?evX}c>$^Ecj7)}%49tfna!WI*YfRLrWbB!^$d6HS;zv71naKu>p^Q?K+Zeqj zw=xP%e#9s@nT@HTUQ&i(ld+h?rsD^Sk8Vm}VEN6!AZaHMec}v{N8!Pm9f}GJyka#h z4J#NDm>3nLWq^dN90N0t0t2_$KhE1n6d2gW9&jxHih$%5l^D1$oo|@fzystcs{jdA zH3n82mIn;RKtuKc)pNYJ*-<`+Ax1jd6$PWh6Dz7nHr!Hc7{v`kRh5{OpG4d zIt-k$`)m0G5j&i w?EkC4&}qh5!F6DAJhP~{1B3czJL^CbQ-(T;Eyw>&U~rkuvWIoS $msg'amount)); + require((__tact_my_balance() > $msg'amount)); send((false, $self'owner, $msg'amount, 0, null(), null(), null())); return (($self'counter, $self'owner), ()); } diff --git a/sources/output/sample_SampleTactContract.fif b/sources/output/sample_SampleTactContract.fif index 8e82277..827f2ce 100644 --- a/sources/output/sample_SampleTactContract.fif +++ b/sources/output/sample_SampleTactContract.fif @@ -14,6 +14,7 @@ PROGRAM{ DECLPROC __gen_load_SampleTactContract DECLPROC __gen_store_SampleTactContract DECLPROC storeBool + DECLPROC require DECLPROC send DECLPROC __gen_SampleTactContract_init DECLPROC __gen_SampleTactContract_requireOwner @@ -131,6 +132,9 @@ PROGRAM{ SWAP 1 STI }> + require PROC:<{ + 131 THROWIFNOT + }> send PROC:<{ NEWC 1 PUSHINT @@ -292,7 +296,7 @@ PROGRAM{ __tact_my_balance INLINECALLDICT s3 PUSH GREATER - 478 THROWIFNOT + require CALLDICT FALSE SWAP 0 PUSHINT diff --git a/sources/output/sample_SampleTactContract.rev.fif b/sources/output/sample_SampleTactContract.rev.fif index 4608d2c..eeb9660 100644 --- a/sources/output/sample_SampleTactContract.rev.fif +++ b/sources/output/sample_SampleTactContract.rev.fif @@ -62,7 +62,7 @@ SETCP0 s0 s1 XCHG s1 POP s1 s2 XCHG - 24 CALLDICT + 25 CALLDICT NEWC 2 GETGLOBVAR s0 s1 XCHG @@ -102,7 +102,7 @@ SETCP0 s0 s1 XCHG s1 POP s1 s2 XCHG - 25 CALLDICT + 26 CALLDICT NEWC 2 GETGLOBVAR s0 s1 XCHG @@ -140,7 +140,7 @@ SETCP0 s0 s1 XCHG s1 POP s1 s2 XCHG - 28 CALLDICT + 29 CALLDICT NEWC 2 GETGLOBVAR s0 s1 XCHG @@ -175,7 +175,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 26 CALLDICT + 27 CALLDICT NEWC 2 GETGLOBVAR s0 s1 XCHG @@ -203,7 +203,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 27 CALLDICT + 28 CALLDICT NEWC 2 GETGLOBVAR s0 s1 XCHG @@ -237,6 +237,9 @@ SETCP0 1 STI 16: + 131 THROWIFNOT + + 17: NEWC 1 PUSHINT s0 s1 XCHG @@ -343,7 +346,7 @@ SETCP0 s0 s1 XCHG SENDRAWMSG - 17: + 18: 0 PUSHINT s0 s2 XCHG NEWC @@ -355,7 +358,7 @@ SETCP0 STSLICER ENDC - 18: + 19: 1 GETGLOBVAR 3 UNTUPLE s0 POP @@ -364,39 +367,39 @@ SETCP0 SDEQ 132 THROWIFNOT - 19: + 20: ROTREV - 18 CALLDICT + 19 CALLDICT s0 s2 XCHG ADD s0 s1 XCHG - 20: + 21: s0 POP - 21: + 22: 2DROP BALANCE 0 INDEX - 22: + 23: 2DROP 42 PUSHINT - 23: - s1 POP - 24: - 19 CALLDICT + s1 POP 25: + 20 CALLDICT + + 26: ROTREV - 18 CALLDICT + 19 CALLDICT BALANCE 0 INDEX s3 PUSH GREATER - 478 THROWIFNOT + 16 CALLDICT 0 PUSHINT s0 s1 XCHG 0 PUSHINT @@ -406,26 +409,26 @@ SETCP0 s0 s7 XCHG 3 1 BLKSWAP PUSHNULL - 16 CALLDICT + 17 CALLDICT s0 s1 XCHG - 26: + 27: 1 PUSHINT - 19 CALLDICT + 20 CALLDICT - 27: + 28: s0 s1 XCHG DEC s0 s1 XCHG - 28: + 29: ROTREV - 18 CALLDICT + 19 CALLDICT s0 POP s0 s1 XCHG 78809: - 17 CALLDICT + 18 CALLDICT owner: c4 PUSH @@ -438,7 +441,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 23 CALLDICT + 24 CALLDICT 104128: c4 PUSH @@ -451,7 +454,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 21 CALLDICT + 22 CALLDICT 104984: c4 PUSH @@ -464,7 +467,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 20 CALLDICT + 21 CALLDICT 109816: c4 PUSH @@ -477,7 +480,7 @@ SETCP0 s0 s1 XCHG s1 s2 XCHG 1 2 BLKDROP2 - 22 CALLDICT + 23 CALLDICT 113617: 123515602279859691144772641439386770278 PUSHINT diff --git a/sources/output/sample_SampleTactContract.ts b/sources/output/sample_SampleTactContract.ts index 8cc6268..ede1d76 100644 --- a/sources/output/sample_SampleTactContract.ts +++ b/sources/output/sample_SampleTactContract.ts @@ -273,7 +273,7 @@ export function unpackTupleWithdraw(slice: TupleSlice4): Withdraw { return { $$type: 'Withdraw', amount: amount }; } export async function SampleTactContract_init(owner: Address) { - const __code = 'te6ccgECMQEAA8IAART/APSkE/S88sgLAQIBYgIDAgLLBAUCASAnKAIBIAYHAgEgDg8CAUgICQAV/KP4DlAHA4AOUAQC7U7ftwIddJwh+VMCDXCx/eAtDTAwFxsMABkX+RcOIB+kAwVEEVbwP4YQKRW+AgghDFVzUHuo40MO1E0NQB+GLTH/pAARJsEgLTHwGCEMVXNQe68uCB0x8BMRLwGMj4QgHMWQLLHwHPFsntVOAgghBMqD3IuuMCIICgsAC0IG7y0ICABuMO1E0NQB+GLTH/pAARJsEgLTHwGCEEyoPci68uCBgQEB1wABMRLwGcj4QgHMWQLLHwHPFsntVAGOghC2z38Puo40MO1E0NQB+GLTH/pAARJsEgLTHwGCELbPfw+68uCB+kABMRLwHMj4QgHMWQLLHwHPFsntVODAAJEw4w3ywIIMAeL5ASCC8MT41yMS7f3vW3vseDO9uxYtFRG9eKkSrtDyY3r2VXKuuo4jMO1E0NQB+GLTH/pAARJsEvAayPhCAcxZAssfAc8Wye1U2zHggvDeZw/ujFYSGX0/0rQJRorGKggE+cGWE6xL0yR3HpCMeLrjAg0ARO1E0NQB+GLTH/pAARJsEvAbyPhCAcxZAssfAc8Wye1U2zECASAQEQIBIB8gAgEgEhMCASAZGgIBIBQVAgEgFxgB9zIcQHKAVAH8A9wAcoCUAXPFlAD+gJwAcpoI26zJW6zsY49f/APyHDwD3DwDyRus5l/8A8E8AJQBMyVNANw8A/iJG6zmX/wDwTwAlAEzJU0A3DwD+Jw8A8Cf/APAslYzJYzMwFw8A/iIW6zmH/wDwHwAgHMlDFw8A/iyQGAWABkcALIzFkCyx8BzxbJgAAT7AAAZPhBbyMwMSHHBfLghIAANFnwEgKgAYAIBIBscAgEgHR4AAwwgAAsW/gnbxCAABxbgCqAAAwxgAgEgISIAC9LPgJGADAIBICMkAgEgJSYABTwE4AAzFnwEvgnbxAjvPLh3nABcG1tIwdVIG3wEAGAABxx8BOAABwBpQGACASApKgIBSCssAAm7PZ8BGAAnuFHe1E0NQB+GLTH/pAARJsEvAXgCAVgtLgIBIC8wACevYHaiaGoA/DFpj/0gAIk2CXgKwAAnrQx2omhqAPwxaY/9IACJNgl4CkAAJ7M+O1E0NQB+GLTH/pAARJsEvAWgAJWy9GCcFzsPV0srnsehOw51kqFG2aCcJ3WNS0rZHyzItOvLf3xYjmCcKAWPdCZRLm1qqkKwpYALAaCcEDOdWnnFfnSULAdYW4mR7KA='; + const __code = 'te6ccgECMwEAA8wAART/APSkE/S88sgLAQIBYgIDAgLLBAUCASApKgIBIAYHAgEgDg8CAUgICQAV/KP4DlAHA4AOUAQC7U7ftwIddJwh+VMCDXCx/eAtDTAwFxsMABkX+RcOIB+kAwVEEVbwP4YQKRW+AgghDFVzUHuo40MO1E0NQB+GLTH/pAARJsEgLTHwGCEMVXNQe68uCB0x8BMRLwGcj4QgHMWQLLHwHPFsntVOAgghBMqD3IuuMCIICgsAC0IG7y0ICABuMO1E0NQB+GLTH/pAARJsEgLTHwGCEEyoPci68uCBgQEB1wABMRLwGsj4QgHMWQLLHwHPFsntVAGOghC2z38Puo40MO1E0NQB+GLTH/pAARJsEgLTHwGCELbPfw+68uCB+kABMRLwHcj4QgHMWQLLHwHPFsntVODAAJEw4w3ywIIMAeL5ASCC8MT41yMS7f3vW3vseDO9uxYtFRG9eKkSrtDyY3r2VXKuuo4jMO1E0NQB+GLTH/pAARJsEvAbyPhCAcxZAssfAc8Wye1U2zHggvDeZw/ujFYSGX0/0rQJRorGKggE+cGWE6xL0yR3HpCMeLrjAg0ARO1E0NQB+GLTH/pAARJsEvAcyPhCAcxZAssfAc8Wye1U2zECASAQEQIBIB8gAgEgEhMCASAZGgIBIBQVAgEgFxgABzy4IOAB9zIcQHKAVAH8A9wAcoCUAXPFlAD+gJwAcpoI26zJW6zsY49f/APyHDwD3DwDyRus5l/8A8E8AJQBMyVNANw8A/iJG6zmX/wDwTwAlAEzJU0A3DwD+Jw8A8Cf/APAslYzJYzMwFw8A/iIW6zmH/wDwHwAgHMlDFw8A/iyQGAWAAT7AAAZHACyMxZAssfAc8WyYAAZPhBbyMwMSHHBfLghIAIBIBscAgEgHR4ADRZ8BMCoAGAAAwwgAAsW/gnbxCAABxbgCqACASAhIgIBSCcoAgEgIyQCASAlJgADDGAABTwFIAAxFnwE/gnbxAjvPAQcAFwbW0jB1UgbfARAYAAHHHwFIAAHAGlAYAALFnwEzABgAgEgKywCAUgtLgAJuz2fASgAJ7hR3tRNDUAfhi0x/6QAESbBLwGIAgFYLzACASAxMgAnr2B2omhqAPwxaY/9IACJNgl4C0AAJ60MdqJoagD8MWmP/SAAiTYJeArAACezPjtRNDUAfhi0x/6QAESbBLwF4ACVsvRgnBc7D1dLK57HoTsOdZKhRtmgnCd1jUtK2R8syLTry398WI5gnCgFj3QmUS5taqpCsKWACwGgnBAznVp5xX50lCwHWFuJkeyg'; const depends = new Map(); let systemCell = beginCell().storeDict(null).endCell(); let __stack: StackItem[] = []; diff --git a/yarn.lock b/yarn.lock index bc36371..4af2057 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,49 +22,50 @@ dependencies: "@babel/highlight" "^7.18.6" -"@babel/compat-data@^7.20.0": +"@babel/compat-data@^7.20.5": version "7.20.5" resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.5.tgz#86f172690b093373a933223b4745deeb6049e733" integrity sha512-KZXo2t10+/jxmkhNXc7pZTqRvSOIvVv/+lJwHS+B2rErwOyjuVRh60yVpb7liQ1U5t7lLJ1bz+t8tSypUZdm0g== "@babel/core@^7.11.6", "@babel/core@^7.12.3": - version "7.20.5" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.5.tgz#45e2114dc6cd4ab167f81daf7820e8fa1250d113" - integrity sha512-UdOWmk4pNWTm/4DlPUl/Pt4Gz4rcEMb7CY0Y3eJl5Yz1vI8ZJGmHWaVE55LoxRjdpx0z259GE9U5STA9atUinQ== + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.7.tgz#37072f951bd4d28315445f66e0ec9f6ae0c8c35f" + integrity sha512-t1ZjCluspe5DW24bn2Rr1CDb2v9rn/hROtg9a2tmd0+QYf4bsloYfLQzjG4qHPNMhWtKdGC33R5AxGR2Af2cBw== dependencies: "@ampproject/remapping" "^2.1.0" "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.20.5" - "@babel/helper-compilation-targets" "^7.20.0" - "@babel/helper-module-transforms" "^7.20.2" - "@babel/helpers" "^7.20.5" - "@babel/parser" "^7.20.5" - "@babel/template" "^7.18.10" - "@babel/traverse" "^7.20.5" - "@babel/types" "^7.20.5" + "@babel/generator" "^7.20.7" + "@babel/helper-compilation-targets" "^7.20.7" + "@babel/helper-module-transforms" "^7.20.7" + "@babel/helpers" "^7.20.7" + "@babel/parser" "^7.20.7" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.20.7" + "@babel/types" "^7.20.7" convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.2" json5 "^2.2.1" semver "^6.3.0" -"@babel/generator@^7.20.5", "@babel/generator@^7.7.2": - version "7.20.5" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.20.5.tgz#cb25abee3178adf58d6814b68517c62bdbfdda95" - integrity sha512-jl7JY2Ykn9S0yj4DQP82sYvPU+T3g0HFcWTqDLqiuA9tGRNIj9VfbtXGAYTTkyNEnQk1jkMGOdYka8aG/lulCA== +"@babel/generator@^7.20.7", "@babel/generator@^7.7.2": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.20.7.tgz#f8ef57c8242665c5929fe2e8d82ba75460187b4a" + integrity sha512-7wqMOJq8doJMZmP4ApXTzLxSr7+oO2jroJURrVEp6XShrQUObV8Tq/D0NCcoYg2uHqUrjzO0zwBjoYzelxK+sw== dependencies: - "@babel/types" "^7.20.5" + "@babel/types" "^7.20.7" "@jridgewell/gen-mapping" "^0.3.2" jsesc "^2.5.1" -"@babel/helper-compilation-targets@^7.20.0": - version "7.20.0" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.0.tgz#6bf5374d424e1b3922822f1d9bdaa43b1a139d0a" - integrity sha512-0jp//vDGp9e8hZzBc6N/KwA5ZK3Wsm/pfm4CrY7vzegkVxc65SgSn6wYOnwHe9Js9HRQ1YTCKLGPzDtaS3RoLQ== +"@babel/helper-compilation-targets@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.7.tgz#a6cd33e93629f5eb473b021aac05df62c4cd09bb" + integrity sha512-4tGORmfQcrc+bvrjb5y3dG9Mx1IOZjsHqQVUz7XCNHO+iTmqxWnVg3KRygjGmpRLJGdQSKuvFinbIb0CnZwHAQ== dependencies: - "@babel/compat-data" "^7.20.0" + "@babel/compat-data" "^7.20.5" "@babel/helper-validator-option" "^7.18.6" browserslist "^4.21.3" + lru-cache "^5.1.1" semver "^6.3.0" "@babel/helper-environment-visitor@^7.18.9": @@ -94,19 +95,19 @@ dependencies: "@babel/types" "^7.18.6" -"@babel/helper-module-transforms@^7.20.2": - version "7.20.2" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.2.tgz#ac53da669501edd37e658602a21ba14c08748712" - integrity sha512-zvBKyJXRbmK07XhMuujYoJ48B5yvvmM6+wcpv6Ivj4Yg6qO7NOZOSnvZN9CRl1zz1Z4cKf8YejmCMh8clOoOeA== +"@babel/helper-module-transforms@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.7.tgz#7a6c9a1155bef55e914af574153069c9d9470c43" + integrity sha512-FNdu7r67fqMUSVuQpFQGE6BPdhJIhitoxhGzDbAXNcA07uoVG37fOiMk3OSV8rEICuyG6t8LGkd9EE64qIEoIA== dependencies: "@babel/helper-environment-visitor" "^7.18.9" "@babel/helper-module-imports" "^7.18.6" "@babel/helper-simple-access" "^7.20.2" "@babel/helper-split-export-declaration" "^7.18.6" "@babel/helper-validator-identifier" "^7.19.1" - "@babel/template" "^7.18.10" - "@babel/traverse" "^7.20.1" - "@babel/types" "^7.20.2" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.20.7" + "@babel/types" "^7.20.7" "@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.19.0", "@babel/helper-plugin-utils@^7.8.0": version "7.20.2" @@ -142,14 +143,14 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz#bf0d2b5a509b1f336099e4ff36e1a63aa5db4db8" integrity sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw== -"@babel/helpers@^7.20.5": - version "7.20.6" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.20.6.tgz#e64778046b70e04779dfbdf924e7ebb45992c763" - integrity sha512-Pf/OjgfgFRW5bApskEz5pvidpim7tEDPlFtKcNRXWmfHGn9IEI2W2flqRQXTFb7gIPTyK++N6rVHuwKut4XK6w== +"@babel/helpers@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.20.7.tgz#04502ff0feecc9f20ecfaad120a18f011a8e6dce" + integrity sha512-PBPjs5BppzsGaxHQCDKnZ6Gd9s6xl8bBCluz3vEInLGRJmnZan4F6BYCeqtyXqkk4W5IlPmjK4JlOuZkpJ3xZA== dependencies: - "@babel/template" "^7.18.10" - "@babel/traverse" "^7.20.5" - "@babel/types" "^7.20.5" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.20.7" + "@babel/types" "^7.20.7" "@babel/highlight@^7.18.6": version "7.18.6" @@ -160,10 +161,10 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.18.10", "@babel/parser@^7.20.5": - version "7.20.5" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.5.tgz#7f3c7335fe417665d929f34ae5dceae4c04015e8" - integrity sha512-r27t/cy/m9uKLXQNWWebeCUHgnAZq0CpG1OwKRxzJMP1vpSU4bSIK2hq+/cp0bQxetkXx38n09rNu8jVkcK/zA== +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.7.tgz#66fe23b3c8569220817d5feb8b9dcdc95bb4f71b" + integrity sha512-T3Z9oHybU+0vZlY9CiDSJQTD5ZapcW18ZctFMi0MOAl/4BjFF4ul7NVSARLdbGO5vDqy9eQiGTV0LtKfvCYvcg== "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -263,35 +264,35 @@ dependencies: "@babel/helper-plugin-utils" "^7.19.0" -"@babel/template@^7.18.10", "@babel/template@^7.3.3": - version "7.18.10" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.18.10.tgz#6f9134835970d1dbf0835c0d100c9f38de0c5e71" - integrity sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA== +"@babel/template@^7.18.10", "@babel/template@^7.20.7", "@babel/template@^7.3.3": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.20.7.tgz#a15090c2839a83b02aa996c0b4994005841fd5a8" + integrity sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw== dependencies: "@babel/code-frame" "^7.18.6" - "@babel/parser" "^7.18.10" - "@babel/types" "^7.18.10" + "@babel/parser" "^7.20.7" + "@babel/types" "^7.20.7" -"@babel/traverse@^7.20.1", "@babel/traverse@^7.20.5", "@babel/traverse@^7.7.2": - version "7.20.5" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.5.tgz#78eb244bea8270fdda1ef9af22a5d5e5b7e57133" - integrity sha512-WM5ZNN3JITQIq9tFZaw1ojLU3WgWdtkxnhM1AegMS+PvHjkM5IXjmYEGY7yukz5XS4sJyEf2VzWjI8uAavhxBQ== +"@babel/traverse@^7.20.7", "@babel/traverse@^7.7.2": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.7.tgz#114f992fa989a390896ea72db5220780edab509c" + integrity sha512-xueOL5+ZKX2dJbg8z8o4f4uTRTqGDRjilva9D1hiRlayJbTY8jBRL+Ph67IeRTIE439/VifHk+Z4g0SwRtQE0A== dependencies: "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.20.5" + "@babel/generator" "^7.20.7" "@babel/helper-environment-visitor" "^7.18.9" "@babel/helper-function-name" "^7.19.0" "@babel/helper-hoist-variables" "^7.18.6" "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/parser" "^7.20.5" - "@babel/types" "^7.20.5" + "@babel/parser" "^7.20.7" + "@babel/types" "^7.20.7" debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.18.10", "@babel/types@^7.18.6", "@babel/types@^7.19.0", "@babel/types@^7.20.2", "@babel/types@^7.20.5", "@babel/types@^7.3.0", "@babel/types@^7.3.3": - version "7.20.5" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.5.tgz#e206ae370b5393d94dfd1d04cd687cace53efa84" - integrity sha512-c9fst/h2/dcF7H+MJKZ2T0KjEQ8hY/BNnDk/H3XY8C4Aw/eWQXWn/lWntHF9ooUBnGmEvbfGrTgLWc+um0YDUg== +"@babel/types@^7.0.0", "@babel/types@^7.18.6", "@babel/types@^7.19.0", "@babel/types@^7.20.2", "@babel/types@^7.20.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.7.tgz#54ec75e252318423fc07fb644dc6a58a64c09b7f" + integrity sha512-69OnhBxSSgK0OzTJai4kyPDiKTIe3j+ctaHdIGVbRahTLAT7L3R9oeXHC2aVSuGYt3cVnoAMDmOCgJ2yaiLMvg== dependencies: "@babel/helper-string-parser" "^7.19.4" "@babel/helper-validator-identifier" "^7.19.1" @@ -756,20 +757,15 @@ resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== -"@types/node@*", "@types/node@^18.11.14": - version "18.11.14" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.14.tgz#a8571b25f3a31e9ded14e3ab9488509adef831d8" - integrity sha512-0KXV57tENYmmJMl+FekeW9V3O/rlcqGQQJ/hNh9r8pKIj304pskWuEd8fCyNT86g/TpO0gcOTiLzsHLEURFMIQ== - -"@types/node@>=13.7.0": - version "18.11.15" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.15.tgz#de0e1fbd2b22b962d45971431e2ae696643d3f5d" - integrity sha512-VkhBbVo2+2oozlkdHXLrb3zjsRkpdnaU2bXmX8Wgle3PUi569eLRaHGlgETQHR7lLL1w7GiG3h9SnePhxNDecw== +"@types/node@*", "@types/node@>=13.7.0", "@types/node@^18.11.14": + version "18.11.17" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.17.tgz#5c009e1d9c38f4a2a9d45c0b0c493fe6cdb4bcb5" + integrity sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng== "@types/prettier@^2.1.5": - version "2.7.1" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.1.tgz#dfd20e2dc35f027cdd6c1908e80a5ddc7499670e" - integrity sha512-ri0UmynRRvZiiUJdiz38MmIblKK+oH30MztdBVR95dv/Ubw6neWSb8u1XpRb72L4qsZOhz+L+z9JD40SJmfWow== + version "2.7.2" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.2.tgz#6c2324641cc4ba050a8c710b2b251b377581fbf0" + integrity sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg== "@types/qs@^6.9.7": version "6.9.7" @@ -1063,9 +1059,9 @@ camelcase@^6.2.0: integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== caniuse-lite@^1.0.30001400: - version "1.0.30001439" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001439.tgz#ab7371faeb4adff4b74dad1718a6fd122e45d9cb" - integrity sha512-1MgUzEkoMO6gKfXflStpYgZDlFM7M/ck/bgfVCACO5vnAf0fXoNVHdWtqGU+MYca+4bL9Z5bpOVmR33cWW9G2A== + version "1.0.30001441" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001441.tgz#987437b266260b640a23cd18fbddb509d7f69f3e" + integrity sha512-OyxRR4Vof59I3yGWXws6i908EtGbMzVUi3ganaZQHmydk1iwDhRnvaPG2WaR0KcqrDFKrxVZHULT396LEPhXfg== capital-case@^1.0.4: version "1.0.4" @@ -2124,9 +2120,9 @@ json-parse-even-better-errors@^2.3.0: integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== json5@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" - integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== + version "2.2.2" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.2.tgz#64471c5bdcc564c18f7c1d4df2e2297f2457c5ab" + integrity sha512-46Tk9JiOL2z7ytNQWFLpj99RZkVgeHf87yGQKsIkaPz1qSH9UczKH1rO7K3wgRselo0tYMUNfecYpm/p1vC7tQ== jssha@3.2.0: version "3.2.0" @@ -2180,6 +2176,13 @@ lower-case@^2.0.2: dependencies: tslib "^2.0.3" +lru-cache@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" + integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== + dependencies: + yallist "^3.0.2" + lru-cache@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" @@ -2284,9 +2287,9 @@ node-int64@^0.4.0: integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw== node-releases@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503" - integrity sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg== + version "2.0.8" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.8.tgz#0f349cdc8fcfa39a92ac0be9bc48b7706292b9ae" + integrity sha512-dFSmB8fFHEH/s81Xi+Y/15DQY6VHW81nXRj86EMSL3lmuTmK1e+aT4wrFCkTbm+gSwkw4KpX+rT/pMM2c1mF+A== normalize-path@^3.0.0: version "3.0.0" @@ -2314,9 +2317,9 @@ object-inspect@^1.9.0: integrity sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ== ohm-js@^16.4.0: - version "16.4.0" - resolved "https://registry.yarnpkg.com/ohm-js/-/ohm-js-16.4.0.tgz#d0df8a2bcf32298e153b684a5630d4623e86a5de" - integrity sha512-u1QI5h2w29I4838+/m32rzqfNNH1Qej9L6O1MTZZMx7bVOu09orc/TO0HRVeYh5jStieZ3INszM7oqbCdx2x7A== + version "16.6.0" + resolved "https://registry.yarnpkg.com/ohm-js/-/ohm-js-16.6.0.tgz#a54508b002161b35d4feec2f628d5ab4e07d2f29" + integrity sha512-X9P4koSGa7swgVQ0gt71UCYtkAQGOjciJPJAz74kDxWt8nXbH5HrDOQG6qBDH7SR40ktNv4x61BwpTDE9q4lRA== once@^1.3.0: version "1.4.0" @@ -2807,9 +2810,9 @@ ton-compiler@^2.0.0: tmp "^0.2.1" ton-contract-executor@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/ton-contract-executor/-/ton-contract-executor-0.6.0.tgz#23502e144d66b9e138b9001db55f6b0ed5b22945" - integrity sha512-9qZj3ttvckxhDHPFIj7KV6CN2UVjVl07Wwg3hdEyWKrits6BXMLRTsXZKcTYY+2n+rGyri1B7o+8sGwFFgRNpw== + version "0.6.2" + resolved "https://registry.yarnpkg.com/ton-contract-executor/-/ton-contract-executor-0.6.2.tgz#07ad85795f932d4bcfe831655d834fbfcacb8825" + integrity sha512-liG3VODJiWQbpEFzmy6nO1XrWkeIKarM+cWIapasP4BzBHBzzAuO7Rb6PY+ow2RFo3TS+XzGUEAP86DDVx3WFg== dependencies: bn.js "^5.2.0" @@ -2867,7 +2870,7 @@ ton-tact@^0.4.0: tvm-disassembler "^1.2.1" zod "^3.20.2" -ton@12.3.2, ton@^12.3.2, ton@^9.3.1: +ton@12.3.2, ton@^9.3.1: version "12.3.2" resolved "https://registry.yarnpkg.com/ton/-/ton-12.3.2.tgz#f7e64fae287d7a43a9d8140a85cb5fd9d5b414b9" integrity sha512-F8e2ocX29uY+EiH+ORjZfIbcWu6KtUDGtaX4PX9ETVXVz8P+3KFtyvlsNHOMAlvfb4woaHSO6NElpyLcotniQg== @@ -3064,6 +3067,11 @@ y18n@^5.0.5: resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== +yallist@^3.0.2: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" + integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== + yallist@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"