diff --git a/contracts/task2.fc b/contracts/task2.fc index a55b153..1571714 100755 --- a/contracts/task2.fc +++ b/contracts/task2.fc @@ -50,10 +50,44 @@ } if (op == 0x7362d09c) { - (int llave, slice valor, int num) = diccionario.udict_get_min?(256); - throw_unless(122, num); + (int llave, slice valor, int num) = diccionario.udict_get_min?(256); + throw_unless(122, num); + int ts = 0; + while(num){ + ts = ts + valor~load_uint(32); + (llave, valor, num) = diccionario.udict_get_next?(256, llave); + } + (int llave, slice valor, int num) = diccionario.udict_get_min?(256); + slice dd = cin_msg~load_msg_addr(); + (int chain, int dir2) = dd.parse_std_addr(); + in_msg_body~load_uint(64); + int aguacero = in_msg_body~load_coins(); + while (num) { + int us = valor~load_uint(32); + cell payload = begin_cell() + .store_uint(0x0f8a7ea5, 32) + .store_uint(0, 64) + .store_coins(us * aguacero / ts) + .store_uint(chain, 11) + .store_uint(llave, 256) + .store_uint(chain, 11) + .store_uint(llave, 256) + .store_uint(0, 1) + .store_coins(1) + .store_uint(0, 1) + .end_cell(); + cell msg = begin_cell() + .store_uint(0x18, 6) + .store_uint(chain, 11) + .store_uint(dir2, 256) + .store_coins(20 * 1000 * 1000) + .store_uint(1, 1 + 4 + 4 + 64 + 32 + 1 + 1) + .store_ref(payload) + .end_cell(); + (llave, valor, num) = diccionario.udict_get_next?(256, llave); + send_raw_message(msg, 0); + } } - if (op == 0x68530b3) { (int llave, slice valor, int num) = diccionario.udict_get_min?(256); throw_unless(122, num);