forked from tact-lang/tact
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
484 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#include "echo_Echo.headers.fc"; | ||
#include "echo_Echo.stdlib.fc"; | ||
#include "echo_Echo.constants.fc"; | ||
#include "echo_Echo.storage.fc"; | ||
|
||
;; | ||
;; Contract Echo functions | ||
;; | ||
|
||
tuple $Echo$_contract_init(int $a) impure inline_ref { | ||
tuple $self = null(); | ||
return $self; | ||
} | ||
|
||
(tuple, slice) $Echo$_fun_hello(tuple $self, slice $src) impure inline_ref { | ||
var ($self) = $self; | ||
tuple $builder = __tact_string_builder_start_string(); | ||
$builder~__tact_string_builder_append(__gen_slice_string_f370faf8638967dd9ace3fe077417700dc2370082f3795482bcb6285b962df24()); | ||
$builder~__tact_string_builder_append($src); | ||
return ($self, __tact_string_builder_end_slice($builder)); | ||
} | ||
|
||
;; | ||
;; Receivers of a Contract Echo | ||
;; | ||
|
||
((tuple), ()) $Echo$_internal_binary_EchoMessage(tuple $self, tuple $msg) impure inline { | ||
var $self = $self; | ||
var $msg = $msg; | ||
$self~$Echo$_fun_reply($EchoMessage$_store_cell($msg)); | ||
return ($self, ()); | ||
} | ||
|
||
(tuple, ()) $Echo$_internal_any_text(tuple $self, slice $msg) impure inline { | ||
var $self = $self; | ||
$self~$Echo$_fun_reply($String$_fun_asComment($msg)); | ||
return ($self, ()); | ||
} | ||
|
||
(tuple, ()) $Echo$_internal_any(tuple $self, slice $msg) impure inline { | ||
var $self = $self; | ||
$self~$Echo$_fun_reply($Slice$_fun_asCell($msg)); | ||
return ($self, ()); | ||
} | ||
|
||
;; | ||
;; Get methods of a Contract Echo | ||
;; | ||
|
||
_ %hello(slice $$src) method_id(115554) { | ||
slice $src = $$src; | ||
var self = $Echo$_contract_load(); | ||
var res = self~$Echo$_fun_hello($src); | ||
return res; | ||
} | ||
|
||
_ supported_interfaces() method_id { | ||
return ( | ||
"org.ton.introspection.v0"H >> 128, | ||
"org.ton.abi.ipfs.v0"H >> 128, | ||
"org.ton.deploy.lazy.v0"H >> 128, | ||
"org.ton.chain.workchain.v0"H >> 128 | ||
); | ||
} | ||
|
||
_ get_abi_ipfs() method_id { | ||
return "ipfs://QmXa2PZRMKJz3A9tGDdANBWoKAAeiyhrVE4CRz2aitkj1z"; | ||
} | ||
|
||
_ lazy_deployment_completed() method_id { | ||
return get_data().begin_parse().load_int(1); | ||
} | ||
|
||
;; | ||
;; Routing of a Contract Echo | ||
;; | ||
|
||
(tuple, int) $Echo$_contract_router_internal(tuple self, int msg_bounced, slice in_msg) impure inline_ref { | ||
;; Handle bounced messages | ||
if (msg_bounced) { | ||
return (self, true); | ||
} | ||
|
||
;; Parse incoming message | ||
int op = 0; | ||
if (slice_bits(in_msg) >= 32) { | ||
op = in_msg.preload_uint(32); | ||
} | ||
|
||
|
||
;; Receive EchoMessage message | ||
if (op == 2074217921) { | ||
var msg = in_msg~$EchoMessage$_load(); | ||
self~$Echo$_internal_binary_EchoMessage(msg); | ||
return (self, true); | ||
} | ||
|
||
;; Text Receivers | ||
if (op == 0) { | ||
if (slice_bits(in_msg) >= 32) { | ||
self~$Echo$_internal_any_text(in_msg.skip_bits(32)); | ||
return (self, true); | ||
} | ||
} | ||
|
||
;; Receiver fallback | ||
self~$Echo$_internal_any(in_msg); | ||
return (self, true); | ||
} | ||
|
||
() recv_internal(int msg_value, cell in_msg_cell, slice in_msg) impure { | ||
|
||
;; Context | ||
var cs = in_msg_cell.begin_parse(); | ||
var msg_flags = cs~load_uint(4); | ||
var msg_bounced = -(msg_flags & 1); | ||
slice msg_sender_addr = __tact_verify_address(cs~load_msg_addr()); | ||
__tact_context = (msg_bounced, msg_sender_addr, msg_value, cs); | ||
__tact_context_sender = msg_sender_addr; | ||
|
||
;; Load contract data | ||
var self = $Echo$_contract_load(); | ||
|
||
;; Handle operation | ||
int handled = self~$Echo$_contract_router_internal(msg_bounced, in_msg); | ||
|
||
;; Throw if not handled | ||
throw_unless(130, handled); | ||
|
||
;; Persist state | ||
$Echo$_contract_store(self); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
;; String "Hello, " | ||
slice __gen_slice_string_f370faf8638967dd9ace3fe077417700dc2370082f3795482bcb6285b962df24() asm "B{b5ee9c7241010101000900000e48656c6c6f2c20e8d197d2} B>boc <s PUSHSLICE"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#pragma version =0.4.3; | ||
#pragma allow-post-modification; | ||
#pragma compute-asm-ltr; | ||
|
||
;; | ||
;; Header files for Echo | ||
;; NOTE: declarations are sorted for optimal order | ||
;; | ||
|
||
;; __tact_verify_address | ||
slice __tact_verify_address(slice address) inline; | ||
|
||
;; __tact_store_address | ||
builder __tact_store_address(builder b, slice address) inline; | ||
|
||
;; __tact_my_balance | ||
int __tact_my_balance() inline; | ||
|
||
;; __tact_not_null | ||
forall X -> X __tact_not_null(X x) inline; | ||
|
||
;; __tact_context_get | ||
(int, slice, int, slice) __tact_context_get() inline; | ||
|
||
;; __tact_context_get_sender | ||
slice __tact_context_get_sender() inline; | ||
|
||
;; __tact_store_bool | ||
builder __tact_store_bool(builder b, int v) inline; | ||
|
||
;; __tact_string_builder_start | ||
tuple __tact_string_builder_start(builder b) inline; | ||
|
||
;; __tact_string_builder_start_comment | ||
tuple __tact_string_builder_start_comment() inline; | ||
|
||
;; __tact_string_builder_start_string | ||
tuple __tact_string_builder_start_string() inline; | ||
|
||
;; __tact_string_builder_end | ||
cell __tact_string_builder_end(tuple builders) inline; | ||
|
||
;; __tact_string_builder_end_slice | ||
slice __tact_string_builder_end_slice(tuple builders) inline; | ||
|
||
;; __tact_string_builder_append | ||
((tuple), ()) __tact_string_builder_append(tuple builders, slice sc) inline_ref; | ||
|
||
;; $EchoMessage$_store | ||
builder $EchoMessage$_store(builder build_0, tuple v) inline; | ||
|
||
;; $EchoMessage$_store_cell | ||
cell $EchoMessage$_store_cell(tuple v) inline; | ||
|
||
;; $EchoMessage$_load | ||
(slice, (tuple)) $EchoMessage$_load(slice sc_0) inline; | ||
|
||
;; $StateInit$_not_null | ||
((cell, cell)) $StateInit$_not_null(tuple v) inline; | ||
|
||
;; $Echo$init$_load | ||
(slice, ((int))) $Echo$init$_load(slice sc_0) inline; | ||
|
||
;; $Echo$_contract_init | ||
tuple $Echo$_contract_init(int $a) impure inline_ref; | ||
|
||
;; $Echo$_contract_load | ||
tuple $Echo$_contract_load() impure inline_ref; | ||
|
||
;; $Echo$_contract_store | ||
() $Echo$_contract_store(tuple v) impure inline; | ||
|
||
;; $global_send | ||
() $global_send((int, slice, int, int, cell, cell, cell) $params) impure inline_ref; | ||
|
||
;; $Slice$_fun_asCell | ||
cell $Slice$_fun_asCell(slice $self) impure inline; | ||
|
||
;; $String$_fun_asComment | ||
cell $String$_fun_asComment(slice $self) impure inline_ref; | ||
|
||
;; $Echo$_fun_hello | ||
(tuple, slice) $Echo$_fun_hello(tuple $self, slice $src) impure inline_ref; | ||
|
||
;; $SendParameters$_constructor_bounce_to_value_mode_body_code_data | ||
((int, slice, int, int, cell, cell, cell)) $SendParameters$_constructor_bounce_to_value_mode_body_code_data(int bounce, slice to, int value, int mode, cell body, cell code, cell data) inline; | ||
|
||
;; $Echo$_fun_forward | ||
(tuple, ()) $Echo$_fun_forward(tuple $self, slice $to, cell $body, int $bounce, tuple $init) impure inline_ref; | ||
|
||
;; $Echo$_fun_reply | ||
(tuple, ()) $Echo$_fun_reply(tuple $self, cell $body) impure inline; |
Oops, something went wrong.