| 582 | } |
| 583 | |
| 584 | void ProxyRunner::initialize_sc(std::shared_ptr<RunnerConfig> snapshot_runner_config, |
| 585 | const ton::BlockIdExt &sc_init_block_id, td::Promise<td::Unit> promise) { |
| 586 | sc_is_initializing_ = true; |
| 587 | class Cb : public ProxyContract::Callback { |
| 588 | public: |
| 589 | Cb(ProxyRunner *self) : self_(self) { |
| 590 | } |
| 591 | void on_deploy() override { |
| 592 | } |
| 593 | void on_client_update(const block::StdAddress &client_owner_address, const block::StdAddress &client_sc_address, |
| 594 | td::uint32 state, td::int64 new_balance, td::int64 new_stake, td::int64 tokens_used, |
| 595 | const td::Bits256 &secret_hash) override { |
| 596 | self_->on_client_update(client_owner_address, client_sc_address, state, new_balance, new_stake, tokens_used, |
| 597 | secret_hash); |
| 598 | } |
| 599 | void on_client_register(const block::StdAddress &client_owner_address, const block::StdAddress &client_sc_address, |
| 600 | td::uint64 nonce) override { |
| 601 | self_->on_client_register(client_owner_address, client_sc_address, nonce); |
| 602 | } |
| 603 | void on_worker_update(const block::StdAddress &worker_owner_address, const block::StdAddress &worker_sc_address, |
| 604 | td::uint32 state, td::int64 tokens) override { |
| 605 | self_->on_worker_update(worker_owner_address, worker_sc_address, state, tokens); |
| 606 | } |
| 607 | void on_worker_payout(const block::StdAddress &worker_owner_address, const block::StdAddress &worker_sc_address, |
| 608 | td::int64 tokens_delta) override { |
| 609 | } |
| 610 | void proxy_save_state(td::int32 seqno, const td::Bits256 &unique_hash) override { |
| 611 | self_->on_receive_saved_state_seqno(seqno, unique_hash); |
| 612 | } |
| 613 | void on_transaction(const block::StdAddress &src_address, td::uint32 op, td::uint64 qid) override { |
| 614 | self_->on_receive_transaction(src_address, op, qid); |
| 615 | } |
| 616 | |
| 617 | private: |
| 618 | ProxyRunner *self_; |
| 619 | }; |
| 620 | sc_ = std::make_shared<ProxyContract>(owner_address_, public_key_, std::make_unique<Cb>(this), this, |
| 621 | snapshot_runner_config); |
| 622 | sc_->set_init_block_id(sc_init_block_id); |
| 623 | sc_->subscribe_to_updates(sc_); |
| 624 | |
| 625 | cocoon_wallet_initialize_wait_for_balance_and_get_seqno( |
| 626 | wallet_private_key_->as_octet_string(), owner_address_, min_wallet_balance(), |
| 627 | [self_id = actor_id(this), addr = sc_->address().rserialize(true), |
| 628 | promise = std::move(promise)](td::Result<td::Unit> R) mutable { |
| 629 | if (R.is_error()) { |
| 630 | promise.set_error(R.move_as_error()); |
| 631 | return; |
| 632 | } |
| 633 | td::actor::send_closure(self_id, &ProxyRunner::deploy_proxy_sc, std::move(addr), std::move(promise)); |
| 634 | }); |
| 635 | } |
| 636 | |
| 637 | void ProxyRunner::deploy_proxy_sc(std::string sc_address, td::Promise<td::Unit> promise) { |
| 638 | if (!sc_ || sc_->address().rserialize(true) != sc_address) { |
nothing calls this directly
no test coverage detected