universal-wallet-contract/contracts/signature_mem_contract.fc

59 lines
2.0 KiB
Plaintext

;; Signature Mem Contract
;; github.com/delpydoc | t.me/delpydoc
;;
;; Scheme
;; storage#_ issuer:MsgAddress query_id:uint256 = Storage;
;; status_new#BACA10 query_id:uint256 forward_payload:^InternalMsgBody = InternalMsgBody;
;; status_exist#BACA20 query_id:uint256 forward_payload:^InternalMsgBody = InternalMsgBody;
#include "imports/stdlib.fc";
const int opcode::status_new = 0xBACA10;
const int opcode::status_exist = 0xBACA20;
() recv_internal(int my_balance, int msg_value, cell in_msg_full, slice in_msg_body) impure {
var cs = in_msg_full.begin_parse();
cs~skip_bits(4); ;; int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
slice ctx::sender = cs~load_msg_addr();
cs~load_msg_addr(); ;; skip dst
cs~load_coins(); ;; skip value
cs~skip_bits(1); ;; skip extracurrency collection
cs~load_coins(); ;; skip ihr_fee
raw_reserve(cs~load_coins(), 0);
slice ds = get_data().begin_parse();
(slice c4::issuer, int c4::query_id) = (ds~load_msg_addr(), ds~load_uint(256));
int ret_op = opcode::status_exist;
if (ds.slice_bits() == 0) {
ret_op = opcode::status_new;
}
slice ret_address = in_msg_body~load_msg_addr();
cell forward_payload = in_msg_body~load_ref();
send_raw_message(
(
begin_cell()
.store_uint(0x10, 6)
.store_slice(c4::issuer)
.store_coins(0)
.store_uint(1, 1 + 4 + 4 + 32 + 64 + 1 + 1)
.store_ref(
begin_cell()
.store_uint(ret_op, 32)
.store_uint(c4::query_id, 256)
.store_slice(ret_address)
.store_ref(forward_payload)
.end_cell()
)
.end_cell()
), 128 + 2 ;; carry remaining gas + ignore errors
);
set_data(
begin_cell()
.store_slice(c4::issuer)
.store_uint(c4::query_id, 256)
.store_int(true, 1)
.end_cell()
);
return ();
}