From e2810a26306dbbe216bb7628a2a7deccd2dbbbb5 Mon Sep 17 00:00:00 2001 From: oscux Date: Tue, 16 Dec 2025 05:25:37 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20mermaid.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mermaid.md | 1603 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1603 insertions(+) create mode 100644 mermaid.md diff --git a/mermaid.md b/mermaid.md new file mode 100644 index 0000000..f6d5472 --- /dev/null +++ b/mermaid.md @@ -0,0 +1,1603 @@ +# Asterizm + Jetton bridge (TON/TVM) — Mermaid схемы контрактов, сообщений и данных + +Документ предназначен для аудита/ревью: в нём собраны **схемы взаимодействий всех контрактов, всех сообщений и структуры данных**, которые фигурируют в сообщениях/ивентах. + +Build stamp: STRICT_MERMAID_NO_EDGE_LABELS_2025_12_15 + +## Ограничения Mermaid (максимальная совместимость) + +Чтобы диаграммы работали в «привередливых» интерпретаторах Mermaid, ниже используется только базовый синтаксис: + +- `graph TD` +- `sequenceDiagram` + +Не используются: `subgraph`, стили (`classDef`, `style`), `stateDiagram`, `C4`, `gantt`, `journey`, HTML-лейблы, многострочные лейблы. + +### Если Mermaid падает с parse error + +Если вы видите ошибку вида `got 'PS'` рядом с фрагментами вида `A --> edgeLabel --> B` или с `name:type` / `foo(bar)` внутри подписи стрелки — это почти всегда означает, что рендерится **устаревшая/закэшированная версия** файла, потому что в текущей версии: + +- В `graph TD` **нет подписей на ребрах** (edge labels). Вместо этого все сообщения показаны отдельными узлами `MSG_*`. +- В `graph TD` **нет** скобок `()` и двоеточий `:` на линиях графа. + +Быстрая проверка в репозитории: + +```sh +rg -n -- 'MSG_' MERMAID_INTERACTIONS.md +``` + +Также можно сделать поиск по подписи ребра в виде `A --> edgeLabel --> B` — в актуальной версии внутри ` ```mermaid ` блоков такого быть не должно. + +## Нотация + +- `Actor_*` — внешняя роль (EOA/кошелёк/сервер/релэйер). +- `C_*` — контракт. +- В лейблах сообщений: + - Для `ton-solidity` параметры показаны как `name:type`. + - Для `FunC`/Jetton — как TL‑B поля + опкод (`op:uint32`). +- `cell`/`TvmCell` — TVM cell. +- `MsgAddress` / `address` — адрес (тип зависит от среды: FunC vs ton-solidity ABI). + +--- + +# 1) Asterizm Core — энд-ту-энд взаимодействие + +## 1.1 Топология (контракты и офчейн роли) + +```mermaid +graph TD + Actor_User[User External caller] + Actor_Owner[Owner admin] + Actor_ClientServer[Client Server Offchain processor] + Actor_Relayer[Relayer authorized by Translator] + Actor_ExternalRelay[External relay contract ITranslator] + + C_Client[AsterizmClient base deploy as derived] + C_Initializer[AsterizmInitializer] + C_Translator[AsterizmTranslator] + C_ClientTransfer[AsterizmClientTransfer per transferHash inbound outbound] + C_InitTransfer[AsterizmInitializerTransfer per transferHash] + + MSG_1_1[calls app methods] + Actor_User --> MSG_1_1 + MSG_1_1 --> C_Client + MSG_1_2[admin config calls] + Actor_Owner --> MSG_1_2 + MSG_1_2 --> C_Initializer + MSG_1_3[admin config calls] + Actor_Owner --> MSG_1_3 + MSG_1_3 --> C_Translator + + MSG_1_4[initTransfer dto IzIninTransferRequestDto] + C_Client --> MSG_1_4 + MSG_1_4 --> C_Initializer + MSG_1_5[sendMessage dto TrSendMessageRequestDto] + C_Initializer --> MSG_1_5 + MSG_1_5 --> C_Translator + + MSG_1_6[event SendMessageEvent feeValue uint128 payload cell] + C_Translator --> MSG_1_6 + MSG_1_6 --> Actor_Relayer + MSG_1_7[transferMessage gasLimit uint payload cell] + Actor_Relayer --> MSG_1_7 + MSG_1_7 --> C_Translator + MSG_1_8[receivePayload dto IzReceivePayloadRequestDto] + C_Translator --> MSG_1_8 + MSG_1_8 --> C_Initializer + MSG_1_9[asterizmIzReceive dto IzAsterizmReceiveRequestDto] + C_Initializer --> MSG_1_9 + MSG_1_9 --> C_Client + + MSG_1_10[deploy initialize] + C_Initializer --> MSG_1_10 + MSG_1_10 --> C_InitTransfer + MSG_1_11[deploy initialize] + C_Client --> MSG_1_11 + MSG_1_11 --> C_ClientTransfer + + MSG_1_12[event InitiateTransferEvent _dstChainId uint64 _dstAddress uint256 _txId uint256 _transferHash uint256 _payload cell] + C_Client --> MSG_1_12 + MSG_1_12 --> Actor_ClientServer + MSG_1_13[event PayloadReceivedEvent _srcChainId uint64 _srcAddress uint256 _txId uint256 _transferHash uint256] + C_Client --> MSG_1_13 + MSG_1_13 --> Actor_ClientServer + MSG_1_14[initAsterizmTransfer dstChainId txId transferHash fee] + Actor_ClientServer --> MSG_1_14 + MSG_1_14 --> C_Client + MSG_1_15[asterizmClReceive srcChainId srcAddress txId transferHash payload] + Actor_ClientServer --> MSG_1_15 + MSG_1_15 --> C_Client + + MSG_1_16[logExternalMessage externalRelay dto] + C_Initializer --> MSG_1_16 + MSG_1_16 --> C_Translator + MSG_1_17[sendMessage dto] + C_Initializer --> MSG_1_17 + MSG_1_17 --> Actor_ExternalRelay +``` + +## 1.2 Кроссчейн перевод (payload переносится офчейн, на чейне — только transferHash и «шапка») + +Ключевой момент архитектуры: **пользовательский `payload` не пересылается через `Translator`/`Initializer` между сетями**. Межсетевой перенос делает офчейн‑сервер по событиям, а целевой контракт верифицирует payload по `transferHash`. + +```mermaid +sequenceDiagram + participant User as User + participant ClientSrc as Client src + participant InitSrc as Initializer src + participant TrSrc as Translator src + participant Relayer as Relayer/Server + participant TrDst as Translator dst + participant InitDst as Initializer dst + participant ClientDst as Client dst + + User->>ClientSrc: app method example calls _initAsterizmTransferEvent dstChainId uint64 payload cell + ClientSrc->>ClientSrc: txId txId 1 + ClientSrc->>ClientSrc: transferHash hash srcChainId srcAddress dstChainId dstAddress txId payload + ClientSrc->>ClientSrc: deploy AsterizmClientTransfer hash transferHash type false initialize + ClientSrc->>Relayer: event InitiateTransferEvent dstChainId uint64 dstAddress uint txId uint transferHash uint payload cell + + Relayer->>ClientSrc: initAsterizmTransfer _dstChainId uint64 _txId uint256 _transferHash uint256 _transferFeeValue uint128 + ClientSrc->>ClientSrc: check outbound transfer exists executed via AsterizmClientTransfer.isExists isExecuted + ClientSrc->>InitSrc: initTransfer _dto dstChainId uint64 dstAddress uint256 transferHash uint256 txId uint256 dstFeeAmount uint128 relay address transferResultNotifyFlag bool + + InitSrc->>TrSrc: sendMessage _dto srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 transferHash uint256 dstFeeAmount uint128 transferResultNotifyFlag bool + TrSrc->>Relayer: event SendMessageEvent feeValue uint128 payload cell srcChainId uint64 srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 transferResultNotifyFlag bool transferHash uint256 + + Relayer->>TrDst: transferMessage _gasLimit uint256 _payload cell srcChainId uint64 srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 transferResultNotifyFlag bool transferHash uint256 + TrDst->>InitDst: receivePayload _dto srcChainId uint64 srcAddress uint256 dstChainId uint64 dstAddress uint256 gasLimit uint256 txId uint256 transferHash uint256 payload cell + InitDst->>InitDst: deploy AsterizmInitializerTransfer hash transferHash initialize + InitDst->>ClientDst: asterizmIzReceive _dto srcChainId uint64 srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 transferHash uint256 + ClientDst->>ClientDst: deploy AsterizmClientTransfer hash transferHash type true initialize + ClientDst->>Relayer: event PayloadReceivedEvent srcChainId uint64 srcAddress uint256 txId uint256 transferHash uint256 + + Relayer->>ClientDst: asterizmClReceive _srcChainId uint64 _srcAddress uint256 _txId uint256 _transferHash uint256 _payload cell + ClientDst->>ClientDst: verify transferHash hash srcChainId srcAddress dstChainId dstAddress txId payload + ClientDst->>ClientDst: check inbound via ClientTransfer.isExists isExecuted InitializerTransfer.isExists + ClientDst->>ClientDst: _asterizmReceive dto ClAsterizmReceiveRequestDto app-specific + ClientDst->>ClientDst: mark executed via ClientTransfer.executeTransfer smallTransferHash uint128 +``` + +## 1.3 Same-chain перевод (без релэйера) + +```mermaid +sequenceDiagram + participant Client as Client + participant Init as Initializer + participant Tr as Translator + + Client->>Init: initTransfer _dto dstChainId uint64 dstAddress uint256 transferHash uint256 txId uint256 dstFeeAmount uint128 relay address transferResultNotifyFlag bool + Init->>Tr: sendMessage _dto srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 transferHash uint256 dstFeeAmount uint128 transferResultNotifyFlag bool + Tr->>Tr: if dstChainId localChainId - _baseTransferMessage dto gasLimit uint payload cell + Tr->>Init: receivePayload _dto srcChainId uint64 srcAddress uint256 dstChainId uint64 dstAddress uint256 gasLimit uint256 txId uint256 transferHash uint256 payload cell + Init->>Client: asterizmIzReceive _dto srcChainId uint64 srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 transferHash uint256 +``` + +## 1.4 Resend + уведомление о статусе отправки + +```mermaid +sequenceDiagram + participant Client as Client + participant Init as Initializer + participant Tr as Translator + participant Relayer as Relayer/Owner + + Client->>Init: resendTransfer _transferHash uint256 _feeAmount uint128 _relay address + Init->>Tr: resendMessage _transferHash uint256 _senderAddress uint256 _feeAmount uint128 + Tr->>Relayer: event ResendFailedTransferEvent _transferHash uint256 _senderAddress uint256 _feeAmount uint128 + + Relayer->>Tr: transferSendingResultNotification _targetAddress address _transferHash uint256 _statusCode uint8 + Tr->>Init: transferSendingResultNotification _targetAddress address _transferHash uint256 _statusCode uint8 + Init->>Client: transferSendingResultNotification _transferHash uint256 _statusCode uint8 + Client->>Client: optional emit TransferSendingResultNotification if notifyTransferSendingResult_ true +``` + +## 1.5 External relay режим (инициатор отправляет через внешний контракт-релэйер) + +```mermaid +sequenceDiagram + participant Client as Client + participant Init as Initializer + participant Tr as Translator + participant ExtRelay as ExternalRelay ITranslator + participant Offchain as Offchain/Watcher + + Client->>Init: initTransfer _dto dstChainId uint64 dstAddress uint256 transferHash uint256 txId uint256 dstFeeAmount uint128 relay address ExtRelay transferResultNotifyFlag bool + Init->>Init: config getRelayData ExtRelay - ConfigDataResponseDto externalRelayExists externalRelayFee systemFee + Init->>Tr: logExternalMessage _externalRelayAddress address ExtRelay _dto srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 transferHash uint256 dstFeeAmount uint128 transferResultNotifyFlag bool + Tr->>Offchain: event LogExternalMessageEvent _feeValue uint _externalRelayAddress address _payload cell + Init->>ExtRelay: sendMessage _dto srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 transferHash uint256 dstFeeAmount uint128 transferResultNotifyFlag bool +``` + +--- + +# 2) Asterizm — структуры данных (DTO / payload) + +## 2.1 DTO: IAsterizmStructs / IAsterizmReceiveStructs + +```mermaid +graph TD + DTO_AsterizmChain[AsterizmChain] + DTO_AsterizmChain --> DTO_AsterizmChain_exists[exists bool] + DTO_AsterizmChain --> DTO_AsterizmChain_chainType[chainType uint8] +``` + +```mermaid +graph TD + DTO_TrSendMessageRequestDto[TrSendMessageRequestDto] + DTO_TrSendMessageRequestDto --> DTO_TrSendMessageRequestDto_srcAddress[srcAddress uint256] + DTO_TrSendMessageRequestDto --> DTO_TrSendMessageRequestDto_dstChainId[dstChainId uint64] + DTO_TrSendMessageRequestDto --> DTO_TrSendMessageRequestDto_dstAddress[dstAddress uint256] + DTO_TrSendMessageRequestDto --> DTO_TrSendMessageRequestDto_txId[txId uint256] + DTO_TrSendMessageRequestDto --> DTO_TrSendMessageRequestDto_transferHash[transferHash uint256] + DTO_TrSendMessageRequestDto --> DTO_TrSendMessageRequestDto_dstFeeAmount[dstFeeAmount uint128] + DTO_TrSendMessageRequestDto --> DTO_TrSendMessageRequestDto_transferResultNotifyFlag[transferResultNotifyFlag bool] +``` + +```mermaid +graph TD + DTO_IzIninTransferRequestDto[IzIninTransferRequestDto] + DTO_IzIninTransferRequestDto --> DTO_IzIninTransferRequestDto_dstChainId[dstChainId uint64] + DTO_IzIninTransferRequestDto --> DTO_IzIninTransferRequestDto_dstAddress[dstAddress uint256] + DTO_IzIninTransferRequestDto --> DTO_IzIninTransferRequestDto_transferHash[transferHash uint256] + DTO_IzIninTransferRequestDto --> DTO_IzIninTransferRequestDto_txId[txId uint256] + DTO_IzIninTransferRequestDto --> DTO_IzIninTransferRequestDto_dstFeeAmount[dstFeeAmount uint128] + DTO_IzIninTransferRequestDto --> DTO_IzIninTransferRequestDto_relay[relay address] + DTO_IzIninTransferRequestDto --> DTO_IzIninTransferRequestDto_transferResultNotifyFlag[transferResultNotifyFlag bool] +``` + +```mermaid +graph TD + DTO_IzReceivePayloadRequestDto[IzReceivePayloadRequestDto] + DTO_IzReceivePayloadRequestDto --> DTO_IzReceivePayloadRequestDto_srcChainId[srcChainId uint64] + DTO_IzReceivePayloadRequestDto --> DTO_IzReceivePayloadRequestDto_srcAddress[srcAddress uint256] + DTO_IzReceivePayloadRequestDto --> DTO_IzReceivePayloadRequestDto_dstChainId[dstChainId uint64] + DTO_IzReceivePayloadRequestDto --> DTO_IzReceivePayloadRequestDto_dstAddress[dstAddress uint256] + DTO_IzReceivePayloadRequestDto --> DTO_IzReceivePayloadRequestDto_gasLimit[gasLimit uint256] + DTO_IzReceivePayloadRequestDto --> DTO_IzReceivePayloadRequestDto_txId[txId uint256] + DTO_IzReceivePayloadRequestDto --> DTO_IzReceivePayloadRequestDto_transferHash[transferHash uint256] + DTO_IzReceivePayloadRequestDto --> DTO_IzReceivePayloadRequestDto_payload[payload cell] +``` + +```mermaid +graph TD + DTO_IzAsterizmReceiveRequestDto[IzAsterizmReceiveRequestDto] + DTO_IzAsterizmReceiveRequestDto --> DTO_IzAsterizmReceiveRequestDto_srcChainId[srcChainId uint64] + DTO_IzAsterizmReceiveRequestDto --> DTO_IzAsterizmReceiveRequestDto_srcAddress[srcAddress uint256] + DTO_IzAsterizmReceiveRequestDto --> DTO_IzAsterizmReceiveRequestDto_dstChainId[dstChainId uint64] + DTO_IzAsterizmReceiveRequestDto --> DTO_IzAsterizmReceiveRequestDto_dstAddress[dstAddress uint256] + DTO_IzAsterizmReceiveRequestDto --> DTO_IzAsterizmReceiveRequestDto_txId[txId uint256] + DTO_IzAsterizmReceiveRequestDto --> DTO_IzAsterizmReceiveRequestDto_transferHash[transferHash uint256] +``` + +```mermaid +graph TD + DTO_ClAsterizmReceiveRequestDto[ClAsterizmReceiveRequestDto] + DTO_ClAsterizmReceiveRequestDto --> DTO_ClAsterizmReceiveRequestDto_srcChainId[srcChainId uint64] + DTO_ClAsterizmReceiveRequestDto --> DTO_ClAsterizmReceiveRequestDto_srcAddress[srcAddress uint256] + DTO_ClAsterizmReceiveRequestDto --> DTO_ClAsterizmReceiveRequestDto_dstChainId[dstChainId uint64] + DTO_ClAsterizmReceiveRequestDto --> DTO_ClAsterizmReceiveRequestDto_dstAddress[dstAddress uint256] + DTO_ClAsterizmReceiveRequestDto --> DTO_ClAsterizmReceiveRequestDto_txId[txId uint256] + DTO_ClAsterizmReceiveRequestDto --> DTO_ClAsterizmReceiveRequestDto_transferHash[transferHash uint256] + DTO_ClAsterizmReceiveRequestDto --> DTO_ClAsterizmReceiveRequestDto_payload[payload cell] +``` + +```mermaid +graph TD + DTO_ConfigDataResponseDto[ConfigDataResponseDto] + DTO_ConfigDataResponseDto --> DTO_ConfigDataResponseDto_externalRelayExists[externalRelayExists bool] + DTO_ConfigDataResponseDto --> DTO_ConfigDataResponseDto_externalRelayFee[externalRelayFee uint128] + DTO_ConfigDataResponseDto --> DTO_ConfigDataResponseDto_systemFee[systemFee uint128] +``` + +## 2.2 TransferHash (как формируется) + +```mermaid +graph TD + H[transferHash uint256] + H --> H_srcChainId[srcChainId uint64] + H --> H_srcAddress[srcAddress uint256] + H --> H_dstChainId[dstChainId uint64] + H --> H_dstAddress[dstAddress uint256] + H --> H_txId[txId uint256] + H --> H_payload[payload cell bytes payload.toSlice] +``` + +--- + +# 3) Asterizm — ABI карты сообщений (артефакты `contracts/artifacts/*.abi.json`) + +Ниже — «полные» карты ABI для контрактов, которые имеют артефакты в репозитории. Эти схемы показывают **все функции и все события** вместе с типами аргументов. + +## ABI: AsterizmClientTransfer +```mermaid +graph TD + Actor_Any[Any caller Any listener] + C_AsterizmClientTransfer[AsterizmClientTransfer] + + MSG_10_1[constructor] + Actor_Any --> MSG_10_1 + MSG_10_1 --> C_AsterizmClientTransfer + MSG_10_2[initialize] + Actor_Any --> MSG_10_2 + MSG_10_2 --> C_AsterizmClientTransfer + MSG_10_3[isExists answerId uint32 _smallTransferHash uint128 - value0 uint256 value1 bool value2 uint8] + Actor_Any --> MSG_10_3 + MSG_10_3 --> C_AsterizmClientTransfer + MSG_10_4[isExecuted answerId uint32 _smallTransferHash uint128 - value0 uint256 value1 bool value2 uint8] + Actor_Any --> MSG_10_4 + MSG_10_4 --> C_AsterizmClientTransfer + MSG_10_5[executeTransfer _smallTransferHash uint128] + Actor_Any --> MSG_10_5 + MSG_10_5 --> C_AsterizmClientTransfer + MSG_10_6[event DeployClientTransferContractEvent _selfAddress address] + C_AsterizmClientTransfer --> MSG_10_6 + MSG_10_6 --> Actor_Any + MSG_10_7[event ExecuteTransferEvent] + C_AsterizmClientTransfer --> MSG_10_7 + MSG_10_7 --> Actor_Any +``` + +## ABI: AsterizmInitializer +```mermaid +graph TD + Actor_Any[Any caller Any listener] + C_AsterizmInitializer[AsterizmInitializer] + + MSG_11_1[constructor] + Actor_Any --> MSG_11_1 + MSG_11_1 --> C_AsterizmInitializer + MSG_11_2[addBlockAddress _chainId uint64 _address address] + Actor_Any --> MSG_11_2 + MSG_11_2 --> C_AsterizmInitializer + MSG_11_3[removeBlockAddress _chainId uint64 _address address] + Actor_Any --> MSG_11_3 + MSG_11_3 --> C_AsterizmInitializer + MSG_11_4[updateChainsList] + Actor_Any --> MSG_11_4 + MSG_11_4 --> C_AsterizmInitializer + MSG_11_5[onUpdateChainsListCallback _chains map uint64 tuple exists bool chainType uint8] + Actor_Any --> MSG_11_5 + MSG_11_5 --> C_AsterizmInitializer + MSG_11_6[updateLocalChainId] + Actor_Any --> MSG_11_6 + MSG_11_6 --> C_AsterizmInitializer + MSG_11_7[onUpdateLocalChainIdCallback _localChainId uint64] + Actor_Any --> MSG_11_7 + MSG_11_7 --> C_AsterizmInitializer + MSG_11_8[getLocalChainId answerId uint32 - value0 uint64] + Actor_Any --> MSG_11_8 + MSG_11_8 --> C_AsterizmInitializer + MSG_11_9[getInitializerTransferCode answerId uint32 - value0 cell] + Actor_Any --> MSG_11_9 + MSG_11_9 --> C_AsterizmInitializer + MSG_11_10[getClientTransferCode answerId uint32 - value0 cell] + Actor_Any --> MSG_11_10 + MSG_11_10 --> C_AsterizmInitializer + MSG_11_11[getChainsList answerId uint32 - value0 map uint64 tuple] + Actor_Any --> MSG_11_11 + MSG_11_11 --> C_AsterizmInitializer + MSG_11_12[initTransfer _dto dstChainId uint64 dstAddress uint256 transferHash uint256 txId uint256 dstFeeAmount uint128 relay address transferResultNotifyFlag bool] + Actor_Any --> MSG_11_12 + MSG_11_12 --> C_AsterizmInitializer + MSG_11_13[resendTransfer _transferHash uint256 _feeAmount uint128 _relay address] + Actor_Any --> MSG_11_13 + MSG_11_13 --> C_AsterizmInitializer + MSG_11_14[transferSendingResultNotification _targetAddress address _transferHash uint256 _statusCode uint8] + Actor_Any --> MSG_11_14 + MSG_11_14 --> C_AsterizmInitializer + MSG_11_15[receivePayload _dto srcChainId uint64 srcAddress uint256 dstChainId uint64 dstAddress uint256 gasLimit uint256 txId uint256 transferHash uint256 payload cell] + Actor_Any --> MSG_11_15 + MSG_11_15 --> C_AsterizmInitializer + MSG_11_16[manageTrustedRelay _relayAddress address _fee uint128 _systemFee uint128] + Actor_Any --> MSG_11_16 + MSG_11_16 --> C_AsterizmInitializer + MSG_11_17[updateTrustedRelayFee _fee uint128] + Actor_Any --> MSG_11_17 + MSG_11_17 --> C_AsterizmInitializer + MSG_11_18[removeTrustedRelay _relayAddress address] + Actor_Any --> MSG_11_18 + MSG_11_18 --> C_AsterizmInitializer + MSG_11_19[getRelayData _relayAddress address - value0 tuple] + Actor_Any --> MSG_11_19 + MSG_11_19 --> C_AsterizmInitializer + MSG_11_20[blockAddresses - blockAddresses map uint64 map uint256 bool] + Actor_Any --> MSG_11_20 + MSG_11_20 --> C_AsterizmInitializer + MSG_11_21[event SetTranslatorEvent _translatorAddress address] + C_AsterizmInitializer --> MSG_11_21 + MSG_11_21 --> Actor_Any + MSG_11_22[event AddBlockAddressEvent _chainId uint64 _address uint256] + C_AsterizmInitializer --> MSG_11_22 + MSG_11_22 --> Actor_Any + MSG_11_23[event RemoveBlockAddressEvent _chainId uint64 _address uint256] + C_AsterizmInitializer --> MSG_11_23 + MSG_11_23 --> Actor_Any + MSG_11_24[event TransferHashContractDeployEvent _transferHash uint256 _address address] + C_AsterizmInitializer --> MSG_11_24 + MSG_11_24 --> Actor_Any + MSG_11_25[event InitTransferSuccessfullyEvent _transferHash uint256] + C_AsterizmInitializer --> MSG_11_25 + MSG_11_25 --> Actor_Any + MSG_11_26[event UpdateChainsListEvent] + C_AsterizmInitializer --> MSG_11_26 + MSG_11_26 --> Actor_Any + MSG_11_27[event SentPayloadEvent _transferHash uint256 _dstAddress address] + C_AsterizmInitializer --> MSG_11_27 + MSG_11_27 --> Actor_Any + MSG_11_28[event TransferErrorEvent _errorCode uint16] + C_AsterizmInitializer --> MSG_11_28 + MSG_11_28 --> Actor_Any + MSG_11_29[event SetInitializerEvent _address address] + C_AsterizmInitializer --> MSG_11_29 + MSG_11_29 --> Actor_Any + MSG_11_30[event TrustedRelayEvent _initializer address _relayAddress address _fee uint128 _systemFee uint128] + C_AsterizmInitializer --> MSG_11_30 + MSG_11_30 --> Actor_Any + MSG_11_31[event RemoveTrustedRelayEvent _relayAddress address] + C_AsterizmInitializer --> MSG_11_31 + MSG_11_31 --> Actor_Any +``` + +## ABI: AsterizmInitializerTransfer +```mermaid +graph TD + Actor_Any[Any caller Any listener] + C_AsterizmInitializerTransfer[AsterizmInitializerTransfer] + + MSG_12_1[constructor] + Actor_Any --> MSG_12_1 + MSG_12_1 --> C_AsterizmInitializerTransfer + MSG_12_2[initialize] + Actor_Any --> MSG_12_2 + MSG_12_2 --> C_AsterizmInitializerTransfer + MSG_12_3[isExists answerId uint32 _smallTransferHash uint128 - value0 uint256 value1 bool value2 uint8] + Actor_Any --> MSG_12_3 + MSG_12_3 --> C_AsterizmInitializerTransfer + MSG_12_4[event DeployInitializerTransferContractEvent _selfAddress address] + C_AsterizmInitializerTransfer --> MSG_12_4 + MSG_12_4 --> Actor_Any +``` + +## ABI: AsterizmRefundTransfer +```mermaid +graph TD + Actor_Any[Any caller Any listener] + C_AsterizmRefundTransfer[AsterizmRefundTransfer] + + MSG_13_1[constructor] + Actor_Any --> MSG_13_1 + MSG_13_1 --> C_AsterizmRefundTransfer + MSG_13_2[setData _userAddress address _amount uint256 _tokenAddress address] + Actor_Any --> MSG_13_2 + MSG_13_2 --> C_AsterizmRefundTransfer + MSG_13_3[getData answerId uint32 _sender address - value0 uint256 value1 address value2 uint256 value3 address value4 address] + Actor_Any --> MSG_13_3 + MSG_13_3 --> C_AsterizmRefundTransfer + MSG_13_4[event DeployRefundTransferContractEvent _selfAddress address] + C_AsterizmRefundTransfer --> MSG_13_4 + MSG_13_4 --> Actor_Any + MSG_13_5[event SetRefundDataEvent _userAddress address _amount uint256 _tokenAddress address] + C_AsterizmRefundTransfer --> MSG_13_5 + MSG_13_5 --> Actor_Any +``` + +## ABI: AsterizmRefundRequest +```mermaid +graph TD + Actor_Any[Any caller Any listener] + C_AsterizmRefundRequest[AsterizmRefundRequest] + + MSG_14_1[constructor] + Actor_Any --> MSG_14_1 + MSG_14_1 --> C_AsterizmRefundRequest + MSG_14_2[setData _userAddress address _amount uint256 _tokenAddress address] + Actor_Any --> MSG_14_2 + MSG_14_2 --> C_AsterizmRefundRequest + MSG_14_3[getData answerId uint32 _status bool - value0 uint256 value1 address value2 uint256 value3 address value4 bool value5 bool value6 bool value7 bool] + Actor_Any --> MSG_14_3 + MSG_14_3 --> C_AsterizmRefundRequest + MSG_14_4[executeRequest answerId uint32 _status bool - value0 uint256 value1 address value2 uint256 value3 address value4 bool value5 bool value6 bool value7 bool] + Actor_Any --> MSG_14_4 + MSG_14_4 --> C_AsterizmRefundRequest + MSG_14_5[event DeployRefundRequestContractEvent _selfAddress address] + C_AsterizmRefundRequest --> MSG_14_5 + MSG_14_5 --> Actor_Any + MSG_14_6[event SetRefundDataEvent _userAddress address _amount uint256 _tokenAddress address] + C_AsterizmRefundRequest --> MSG_14_6 + MSG_14_6 --> Actor_Any + MSG_14_7[event ExecuteRefundRequestEvent _transferHash uint256 _status bool] + C_AsterizmRefundRequest --> MSG_14_7 + MSG_14_7 --> Actor_Any +``` + +## ABI: AsterizmRefundConfirmation +```mermaid +graph TD + Actor_Any[Any caller Any listener] + C_AsterizmRefundConfirmation[AsterizmRefundConfirmation] + + MSG_15_1[constructor] + Actor_Any --> MSG_15_1 + MSG_15_1 --> C_AsterizmRefundConfirmation + MSG_15_2[isExists answerId uint32 _transferHash uint128 - value0 uint256 value1 bool] + Actor_Any --> MSG_15_2 + MSG_15_2 --> C_AsterizmRefundConfirmation + MSG_15_3[event DeployRefundConfirmationContractEvent _selfAddress address] + C_AsterizmRefundConfirmation --> MSG_15_3 + MSG_15_3 --> Actor_Any +``` + +## ABI: AsterizmTranslator +```mermaid +graph TD + Actor_Any[Any caller Any listener] + C_AsterizmTranslator[AsterizmTranslator] + + MSG_16_1[constructor] + Actor_Any --> MSG_16_1 + MSG_16_1 --> C_AsterizmTranslator + MSG_16_2[addRelayer _relayer address] + Actor_Any --> MSG_16_2 + MSG_16_2 --> C_AsterizmTranslator + MSG_16_3[removeRelayer _relayer address] + Actor_Any --> MSG_16_3 + MSG_16_3 --> C_AsterizmTranslator + MSG_16_4[setInitializer _initializerReceiver address] + Actor_Any --> MSG_16_4 + MSG_16_4 --> C_AsterizmTranslator + MSG_16_5[addChain _chainId uint64 _chainType uint8] + Actor_Any --> MSG_16_5 + MSG_16_5 --> C_AsterizmTranslator + MSG_16_6[addChains chainIds uint64 array chainTypes uint8 array] + Actor_Any --> MSG_16_6 + MSG_16_6 --> C_AsterizmTranslator + MSG_16_7[removeChainById _chainId uint64] + Actor_Any --> MSG_16_7 + MSG_16_7 --> C_AsterizmTranslator + MSG_16_8[updateTrustedRelayFee _fee uint128] + Actor_Any --> MSG_16_8 + MSG_16_8 --> C_AsterizmTranslator + MSG_16_9[getLocalChainId answerId uint32 - value0 uint64] + Actor_Any --> MSG_16_9 + MSG_16_9 --> C_AsterizmTranslator + MSG_16_10[getChainsList answerId uint32 - value0 map uint64 tuple] + Actor_Any --> MSG_16_10 + MSG_16_10 --> C_AsterizmTranslator + MSG_16_11[sendMessage _dto srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 transferHash uint256 dstFeeAmount uint128 transferResultNotifyFlag bool] + Actor_Any --> MSG_16_11 + MSG_16_11 --> C_AsterizmTranslator + MSG_16_12[logExternalMessage _externalRelayAddress address _dto srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 transferHash uint256 dstFeeAmount uint128 transferResultNotifyFlag bool] + Actor_Any --> MSG_16_12 + MSG_16_12 --> C_AsterizmTranslator + MSG_16_13[resendMessage _transferHash uint256 _senderAddress uint256 _feeAmount uint128] + Actor_Any --> MSG_16_13 + MSG_16_13 --> C_AsterizmTranslator + MSG_16_14[transferSendingResultNotification _targetAddress address _transferHash uint256 _statusCode uint8] + Actor_Any --> MSG_16_14 + MSG_16_14 --> C_AsterizmTranslator + MSG_16_15[transferMessage _gasLimit uint256 _payload cell] + Actor_Any --> MSG_16_15 + MSG_16_15 --> C_AsterizmTranslator + MSG_16_16[chains - chains map uint64 tuple] + Actor_Any --> MSG_16_16 + MSG_16_16 --> C_AsterizmTranslator + MSG_16_17[event SetInitializerEvent _initializerAddress address] + C_AsterizmTranslator --> MSG_16_17 + MSG_16_17 --> Actor_Any + MSG_16_18[event AddRelayerEvent _relayerAddress address] + C_AsterizmTranslator --> MSG_16_18 + MSG_16_18 --> Actor_Any + MSG_16_19[event RemoveRelayerEvent _relayerAddress address] + C_AsterizmTranslator --> MSG_16_19 + MSG_16_19 --> Actor_Any + MSG_16_20[event AddChainEvent _chainId uint64] + C_AsterizmTranslator --> MSG_16_20 + MSG_16_20 --> Actor_Any + MSG_16_21[event RemoveChainEvent _chainId uint64] + C_AsterizmTranslator --> MSG_16_21 + MSG_16_21 --> Actor_Any + MSG_16_22[event SetLocalChainEvent _chainId uint64 _chainType uint8] + C_AsterizmTranslator --> MSG_16_22 + MSG_16_22 --> Actor_Any + MSG_16_23[event SendMessageEvent _feeValue uint128 _payload cell] + C_AsterizmTranslator --> MSG_16_23 + MSG_16_23 --> Actor_Any + MSG_16_24[event SuccessTransferEvent _transferHash uint256] + C_AsterizmTranslator --> MSG_16_24 + MSG_16_24 --> Actor_Any + MSG_16_25[event LogExternalMessageEvent _feeValue uint256 _externalRelayAddress address _payload cell] + C_AsterizmTranslator --> MSG_16_25 + MSG_16_25 --> Actor_Any + MSG_16_26[event TransferSendEvent _srcChainId uint64 _srcAddress uint256 _dstAddress uint256 _transferHash uint256] + C_AsterizmTranslator --> MSG_16_26 + MSG_16_26 --> Actor_Any + MSG_16_27[event ResendFailedTransferEvent _transferHash uint256 _senderAddress uint256 _feeAmount uint128] + C_AsterizmTranslator --> MSG_16_27 + MSG_16_27 --> Actor_Any +``` + +## ABI: ChainMock +```mermaid +graph TD + Actor_Any[Any caller Any listener] + C_ChainMock[ChainMock] + + MSG_17_1[buildTransferHash _srcChainId uint64 _srcAddress uint256 _dstChainId uint64 _dstAddress uint256 _txId uint256 _payload cell - value0 uint256] + Actor_Any --> MSG_17_1 + MSG_17_1 --> C_ChainMock + MSG_17_2[buildPayload dstAddress uint256 value uint256] + Actor_Any --> MSG_17_2 + MSG_17_2 --> C_ChainMock + MSG_17_3[buildTrTransferMessageRequestDto srcChainId uint64 srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 b bool transferHash uint256] + Actor_Any --> MSG_17_3 + MSG_17_3 --> C_ChainMock + MSG_17_4[setVersion _version uint8] + Actor_Any --> MSG_17_4 + MSG_17_4 --> C_ChainMock + MSG_17_5[constructor] + Actor_Any --> MSG_17_5 + MSG_17_5 --> C_ChainMock + MSG_17_6[version - version uint8] + Actor_Any --> MSG_17_6 + MSG_17_6 --> C_ChainMock + MSG_17_7[h - h uint256] + Actor_Any --> MSG_17_7 + MSG_17_7 --> C_ChainMock + MSG_17_8[payload - payload cell] + Actor_Any --> MSG_17_8 + MSG_17_8 --> C_ChainMock +``` + +## Дополнения из исходников (не отражены в текущих ABI артефактах) + +В репозитории есть функции/хендлеры, присутствующие в `.tsol`, но отсутствующие в `contracts/artifacts/*.abi.json` (артефакты выглядят не полностью синхронизированными с исходниками). + +```mermaid +graph TD + Actor_Owner[Owner] + C_AsterizmInitializer_src[AsterizmInitializer source] + C_AsterizmTranslator_src[AsterizmTranslator source] + + MSG_18_1[withdrawCoins] + Actor_Owner --> MSG_18_1 + MSG_18_1 --> C_AsterizmInitializer_src + MSG_18_2[withdrawCoins] + Actor_Owner --> MSG_18_2 + MSG_18_2 --> C_AsterizmTranslator_src +``` + +```mermaid +graph TD + Actor_Any[Any sender bounce source] + C_AsterizmInitializer_bounce[AsterizmInitializer source] + MSG_19_1[onBounce TvmSlice _slice functionId uint32 remaining params] + Actor_Any --> MSG_19_1 + MSG_19_1 --> C_AsterizmInitializer_bounce +``` + +--- + +# 4) Asterizm — базовые контракты (source-derived, без ABI артефактов) + +## 4.1 AsterizmClient (база для приложений) + +```mermaid +graph TD + Actor_Owner[Owner] + Actor_Sender[Sender authorized in AsterizmSender] + Actor_Init[Initializer contract] + Actor_Offchain[Client server Offchain] + C_Client[AsterizmClient abstract] + + MSG_20_1[initialize] + Actor_Owner --> MSG_20_1 + MSG_20_1 --> C_Client + MSG_20_2[setExternalRelay _externalRelay address] + Actor_Owner --> MSG_20_2 + MSG_20_2 --> C_Client + MSG_20_3[addTrustedAddress _chainId uint64 _trustedAddress uint256] + Actor_Owner --> MSG_20_3 + MSG_20_3 --> C_Client + MSG_20_4[addTrustedAddresses chainIds uint64 array trustedAddresses uint256 array] + Actor_Owner --> MSG_20_4 + MSG_20_4 --> C_Client + MSG_20_5[removeTrustedSourceAddress _chainId uint64] + Actor_Owner --> MSG_20_5 + MSG_20_5 --> C_Client + MSG_20_6[updateChainsList] + Actor_Owner --> MSG_20_6 + MSG_20_6 --> C_Client + + MSG_20_7[initAsterizmTransfer _dstChainId uint64 _txId uint256 _transferHash uint256 _transferFeeValue uint128] + Actor_Sender --> MSG_20_7 + MSG_20_7 --> C_Client + MSG_20_8[resendAsterizmTransfer _transferHash uint256 _feeAmount uint128] + Actor_Sender --> MSG_20_8 + MSG_20_8 --> C_Client + MSG_20_9[asterizmClReceive _srcChainId uint64 _srcAddress uint256 _txId uint256 _transferHash uint256 _payload cell] + Actor_Sender --> MSG_20_9 + MSG_20_9 --> C_Client + + MSG_20_10[asterizmIzReceive _dto srcChainId uint64 srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 transferHash uint256] + Actor_Init --> MSG_20_10 + MSG_20_10 --> C_Client + MSG_20_11[transferSendingResultNotification _transferHash uint256 _statusCode uint8] + Actor_Init --> MSG_20_11 + MSG_20_11 --> C_Client + + MSG_20_12[event InitiateTransferEvent dstChainId dstAddress txId transferHash payload] + C_Client --> MSG_20_12 + MSG_20_12 --> Actor_Offchain + MSG_20_13[event PayloadReceivedEvent srcChainId srcAddress txId transferHash] + C_Client --> MSG_20_13 + MSG_20_13 --> Actor_Offchain +``` + +### AsterizmClient — полный список входящих сообщений/коллбеков (по `contracts/base/AsterizmClient.tsol`) + +```mermaid +graph TD + Actor_Owner[Owner] + Actor_Sender[Sender onlySender] + Actor_Initializer[Initializer] + Actor_Any[Any external caller getter caller] + C_ClientTransferCaller[AsterizmClientTransfer caller] + C_InitTransferCaller[AsterizmInitializerTransfer caller] + C_Client[AsterizmClient] + + MSG_21_1[constructor deploy] + Actor_Owner --> MSG_21_1 + MSG_21_1 --> C_Client + MSG_21_2[onBounce _slice TvmSlice] + Actor_Any --> MSG_21_2 + MSG_21_2 --> C_Client + + MSG_21_3[initialize] + Actor_Owner --> MSG_21_3 + MSG_21_3 --> C_Client + MSG_21_4[onUpdateLocalChainIdCallback _localChainId uint64] + Actor_Initializer --> MSG_21_4 + MSG_21_4 --> C_Client + MSG_21_5[onUpdateInitializerTransferCodeCallback _code cell] + Actor_Initializer --> MSG_21_5 + MSG_21_5 --> C_Client + MSG_21_6[onUpdateClientTransferCodeCallback _code cell] + Actor_Initializer --> MSG_21_6 + MSG_21_6 --> C_Client + MSG_21_7[onUpdateChainsListCallback _chains map uint64 tuple exists bool chainType uint8] + Actor_Initializer --> MSG_21_7 + MSG_21_7 --> C_Client + + MSG_21_8[setExternalRelay _externalRelay address] + Actor_Owner --> MSG_21_8 + MSG_21_8 --> C_Client + MSG_21_9[getExternalRelay - address] + Actor_Any --> MSG_21_9 + MSG_21_9 --> C_Client + + MSG_21_10[addTrustedAddress _chainId uint64 _trustedAddress uint256] + Actor_Owner --> MSG_21_10 + MSG_21_10 --> C_Client + MSG_21_11[addTrustedAddresses chainIds uint64 array trustedAddresses uint256 array] + Actor_Owner --> MSG_21_11 + MSG_21_11 --> C_Client + MSG_21_12[removeTrustedSourceAddress _chainId uint64] + Actor_Owner --> MSG_21_12 + MSG_21_12 --> C_Client + MSG_21_13[updateChainsList] + Actor_Owner --> MSG_21_13 + MSG_21_13 --> C_Client + + MSG_21_14[getInitializerAddress - address] + Actor_Any --> MSG_21_14 + MSG_21_14 --> C_Client + MSG_21_15[getTrustedAddresses _chainId uint64 - uint256] + Actor_Any --> MSG_21_15 + MSG_21_15 --> C_Client + MSG_21_16[getDisableHashValidation - bool] + Actor_Any --> MSG_21_16 + MSG_21_16 --> C_Client + MSG_21_17[getNotifyTransferSendingResult - bool] + Actor_Any --> MSG_21_17 + MSG_21_17 --> C_Client + MSG_21_18[withdrawCoins] + Actor_Owner --> MSG_21_18 + MSG_21_18 --> C_Client + + MSG_21_19[initAsterizmTransfer _dstChainId uint64 _txId uint256 _transferHash uint256 _transferFeeValue uint128] + Actor_Sender --> MSG_21_19 + MSG_21_19 --> C_Client + MSG_21_20[onInitAsterizmTransferCallback _transferHash uint256 _flag bool _method uint8] + C_ClientTransferCaller --> MSG_21_20 + MSG_21_20 --> C_Client + + MSG_21_21[resendAsterizmTransfer _transferHash uint256 _feeAmount uint128] + Actor_Sender --> MSG_21_21 + MSG_21_21 --> C_Client + + MSG_21_22[transferSendingResultNotification _transferHash uint256 _statusCode uint8] + Actor_Initializer --> MSG_21_22 + MSG_21_22 --> C_Client + MSG_21_23[asterizmIzReceive _dto IzAsterizmReceiveRequestDto] + Actor_Initializer --> MSG_21_23 + MSG_21_23 --> C_Client + + MSG_21_24[asterizmClReceive _srcChainId uint64 _srcAddress uint256 _txId uint256 _transferHash uint256 _payload cell] + Actor_Sender --> MSG_21_24 + MSG_21_24 --> C_Client + MSG_21_25[onAsterizmReceiveCallback _transferHash uint256 _flag bool _method uint8] + C_ClientTransferCaller --> MSG_21_25 + MSG_21_25 --> C_Client + MSG_21_26[onAsterizmReceiveCallback _transferHash uint256 _flag bool _method uint8] + C_InitTransferCaller --> MSG_21_26 + MSG_21_26 --> C_Client +``` + +### AsterizmClient — события (по `contracts/base/AsterizmClient.tsol`) + +```mermaid +graph TD + Actor_Any[Any listener] + C_Client[AsterizmClient] + + MSG_22_1[event SetInitializerEvent _initializerAddress address] + C_Client --> MSG_22_1 + MSG_22_1 --> Actor_Any + MSG_22_2[event SetExternalRelayEvent _externalRelayAddress address] + C_Client --> MSG_22_2 + MSG_22_2 --> Actor_Any + MSG_22_3[event SetLocalChainIdEvent _localChainId uint64] + C_Client --> MSG_22_3 + MSG_22_3 --> Actor_Any + MSG_22_4[event InitiateTransferEvent _dstChainId uint64 _dstAddress uint256 _txId uint256 _transferHash uint256 _payload cell] + C_Client --> MSG_22_4 + MSG_22_4 --> Actor_Any + MSG_22_5[event PayloadReceivedEvent _srcChainId uint64 _srcAddress uint256 _txId uint256 _transferHash uint256] + C_Client --> MSG_22_5 + MSG_22_5 --> Actor_Any + MSG_22_6[event AddTrustedSourceAddressEvent _chainId uint64 _address uint256] + C_Client --> MSG_22_6 + MSG_22_6 --> Actor_Any + MSG_22_7[event RemoveTrustedSourceAddressEvent _chainId uint64 _address uint256] + C_Client --> MSG_22_7 + MSG_22_7 --> Actor_Any + MSG_22_8[event SetUseEncryptionEvent _flag bool] + C_Client --> MSG_22_8 + MSG_22_8 --> Actor_Any + MSG_22_9[event SetNotifyTransferSendingResultEvent _flag bool] + C_Client --> MSG_22_9 + MSG_22_9 --> Actor_Any + MSG_22_10[event SetDisableHashValidationEvent _flag bool] + C_Client --> MSG_22_10 + MSG_22_10 --> Actor_Any + MSG_22_11[event TransferContractDeployEvent _address address] + C_Client --> MSG_22_11 + MSG_22_11 --> Actor_Any + MSG_22_12[event TransferErrorEvent _transferHash uint256 _errorCode uint16] + C_Client --> MSG_22_12 + MSG_22_12 --> Actor_Any + MSG_22_13[event UpdateChainsListEvent] + C_Client --> MSG_22_13 + MSG_22_13 --> Actor_Any + MSG_22_14[event SuccessTransferExecutedEvent _transferHash uint256] + C_Client --> MSG_22_14 + MSG_22_14 --> Actor_Any + MSG_22_15[event ErrorTransferExecutedEvent _transferHash uint256 _errorCode uint16] + C_Client --> MSG_22_15 + MSG_22_15 --> Actor_Any + MSG_22_16[event ResendAsterizmTransferEvent _transferHash uint256 _feeAmount uint128] + C_Client --> MSG_22_16 + MSG_22_16 --> Actor_Any + MSG_22_17[event TransferSendingResultNotification _transferHash uint256 _statusCode uint8] + C_Client --> MSG_22_17 + MSG_22_17 --> Actor_Any +``` + +## 4.2 AsterizmRefund (refund-модуль, используется в MultichainToken) + +```mermaid +graph TD + Actor_User[User] + Actor_OwnerOrSender[Owner or Sender] + C_RefundLogic[AsterizmRefund mixin] + C_RefundTransfer[AsterizmRefundTransfer per transferHash] + C_RefundRequest[AsterizmRefundRequest per transferHash] + C_RefundConfirm[AsterizmRefundConfirmation per transferHash] + + MSG_23_1[addRefundRequest _transferHash uint256] + Actor_User --> MSG_23_1 + MSG_23_1 --> C_RefundLogic + MSG_23_2[getData _sender address - transferHash userAddress amount tokenAddress sender] + C_RefundLogic --> MSG_23_2 + MSG_23_2 --> C_RefundTransfer + MSG_23_3[setData userAddress amount tokenAddress] + C_RefundLogic --> MSG_23_3 + MSG_23_3 --> C_RefundRequest + + MSG_23_4[processRefundRequest _transferHash uint256 _status bool] + Actor_OwnerOrSender --> MSG_23_4 + MSG_23_4 --> C_RefundLogic + MSG_23_5[getData _status bool - transferHash userAddress amount tokenAddress isExecuted isSuccess isReject status] + C_RefundLogic --> MSG_23_5 + MSG_23_5 --> C_RefundRequest + MSG_23_6[executeRequest _status bool - transferHash uint256 userAddress address amount uint256 tokenAddress address isExecutedFlag bool isSuccessProcessFlag bool isRejectProcessFlag bool status bool] + C_RefundLogic --> MSG_23_6 + MSG_23_6 --> C_RefundRequest + + MSG_23_7[confirmRefund _transferHash uint256] + Actor_OwnerOrSender --> MSG_23_7 + MSG_23_7 --> C_RefundLogic + MSG_23_8[deploy] + C_RefundLogic --> MSG_23_8 + MSG_23_8 --> C_RefundConfirm +``` + +### AsterizmRefund — полный список сообщений/коллбеков (по `contracts/base/AsterizmRefund.tsol`) + +```mermaid +graph TD + Actor_User[User] + Actor_OwnerOrSender[Owner or Sender] + C_RefundTransferCaller[AsterizmRefundTransfer caller] + C_RefundRequestCaller[AsterizmRefundRequest caller] + C_RefundConfirmCaller[AsterizmRefundConfirmation caller] + C_Refund[AsterizmRefund] + + MSG_24_1[addRefundRequest _transferHash uint256] + Actor_User --> MSG_24_1 + MSG_24_1 --> C_Refund + MSG_24_2[onAddRefundRequestCallback _transferHash uint256 _userAddress address _amount uint256 _tokenAddress address _sender address] + C_RefundTransferCaller --> MSG_24_2 + MSG_24_2 --> C_Refund + + MSG_24_3[processRefundRequest _transferHash uint256 _status bool] + Actor_OwnerOrSender --> MSG_24_3 + MSG_24_3 --> C_Refund + MSG_24_4[onProcessRefundRequestCallback _transferHash uint256 _userAddress address _amount uint256 _tokenAddress address _isExecutedFlag bool _isSuccessProcessFlag bool _isRejectProcessFlag bool _status bool] + C_RefundRequestCaller --> MSG_24_4 + MSG_24_4 --> C_Refund + MSG_24_5[onExecuteRequestCallback _transferHash uint256 _userAddress address _amount uint256 _tokenAddress address _isExecutedFlag bool _isSuccessProcessFlag bool _isRejectProcessFlag bool _status bool] + C_RefundRequestCaller --> MSG_24_5 + MSG_24_5 --> C_Refund + + MSG_24_6[confirmRefund _transferHash uint256] + Actor_OwnerOrSender --> MSG_24_6 + MSG_24_6 --> C_Refund + MSG_24_7[onCheckRefundConfirmationCallback _transferHash uint256 _exists bool] + C_RefundConfirmCaller --> MSG_24_7 + MSG_24_7 --> C_Refund +``` + +### AsterizmRefund — события (по `contracts/base/AsterizmRefund.tsol`) + +```mermaid +graph TD + Actor_Any[Any listener] + C_Refund[AsterizmRefund] + + MSG_25_1[event AddRefundTransferEvent _transferHash uint256 _userAddress address _amount uint256 _tokenAddress address] + C_Refund --> MSG_25_1 + MSG_25_1 --> Actor_Any + MSG_25_2[event RefundTransferContractDeployEvent _transferHash uint256 _contractAddress address] + C_Refund --> MSG_25_2 + MSG_25_2 --> Actor_Any + MSG_25_3[event RefundRequestContractDeployEvent _transferHash uint256 _contractAddress address] + C_Refund --> MSG_25_3 + MSG_25_3 --> Actor_Any + MSG_25_4[event RefundConfirmationContractDeployEvent _transferHash uint256 _contractAddress address] + C_Refund --> MSG_25_4 + MSG_25_4 --> Actor_Any + MSG_25_5[event AddRefundRequestEvent _transferHash uint256 _userAddress address _amount uint256 _tokenAddress address] + C_Refund --> MSG_25_5 + MSG_25_5 --> Actor_Any + MSG_25_6[event ProcessRefundRequestEvent _transferHash uint256 _status bool _userAddress address _amount uint256 _tokenAddress address] + C_Refund --> MSG_25_6 + MSG_25_6 --> Actor_Any + MSG_25_7[event ConfirmRefundEvent _transferHash uint256 _confirmContractAddress address] + C_Refund --> MSG_25_7 + MSG_25_7 --> Actor_Any + MSG_25_8[event TransferWasRefundedEvent _transferHash uint256] + C_Refund --> MSG_25_8 + MSG_25_8 --> Actor_Any +``` + +## 4.3 AsterizmSender (роль Sender) + +```mermaid +graph TD + Actor_Owner[Owner] + C_Sender[AsterizmSender mixin] + MSG_26_1[addSender _sender address] + Actor_Owner --> MSG_26_1 + MSG_26_1 --> C_Sender + MSG_26_2[removeSender _sender address] + Actor_Owner --> MSG_26_2 + MSG_26_2 --> C_Sender +``` + +```mermaid +graph TD + Actor_Any[Any listener] + C_Sender[AsterizmSender mixin] + MSG_27_1[event AddSenderEvent _sender address] + C_Sender --> MSG_27_1 + MSG_27_1 --> Actor_Any + MSG_27_2[event RemoveSenderEvent _sender address] + C_Sender --> MSG_27_2 + MSG_27_2 --> Actor_Any +``` + +## 4.4 AsterizmConfig (trusted relays registry) + +`AsterizmConfig` используется внутри `AsterizmInitializer` и отвечает за список доверенных «внешних релэйеров» и их комиссий. + +```mermaid +graph TD + Actor_Owner[Owner] + Actor_TrustedRelay[Trusted relay onlyTrustedRelay] + Actor_Any[Any caller] + C_Config[AsterizmConfig mixin] + + MSG_28_1[manageTrustedRelay _relayAddress address _fee uint128 _systemFee uint128] + Actor_Owner --> MSG_28_1 + MSG_28_1 --> C_Config + MSG_28_2[updateTrustedRelayFee _fee uint128] + Actor_TrustedRelay --> MSG_28_2 + MSG_28_2 --> C_Config + MSG_28_3[removeTrustedRelay _relayAddress address] + Actor_Owner --> MSG_28_3 + MSG_28_3 --> C_Config + MSG_28_4[getRelayData _relayAddress address - ConfigDataResponseDto] + Actor_Any --> MSG_28_4 + MSG_28_4 --> C_Config +``` + +```mermaid +graph TD + Actor_Any[Any listener] + C_Config[AsterizmConfig mixin] + MSG_29_1[event TrustedRelayEvent _initializer address _relayAddress address _fee uint128 _systemFee uint128] + C_Config --> MSG_29_1 + MSG_29_1 --> Actor_Any + MSG_29_2[event RemoveTrustedRelayEvent _relayAddress address] + C_Config --> MSG_29_2 + MSG_29_2 --> Actor_Any +``` + +## 4.5 AsterizmNonce (отдельный контракт, не используется в текущих вызовах core) + +```mermaid +graph TD + Actor_Owner[Owner of Nonce contract] + C_Nonce[AsterizmNonce] + MSG_30_1[getNonce answerId uint32 - nonce uint] + Actor_Owner --> MSG_30_1 + MSG_30_1 --> C_Nonce + MSG_30_2[increaseNonce answerId uint32 _transferHash uint256 - transferHash uint256 nonce uint] + Actor_Owner --> MSG_30_2 + MSG_30_2 --> C_Nonce + MSG_30_3[increaseNonceWithValidation answerId uint32 _transferHash uint256 _nonce uint256 - transferHash uint256 nonce uint] + Actor_Owner --> MSG_30_3 + MSG_30_3 --> C_Nonce +``` + +```mermaid +graph TD + Actor_Any[Any listener] + C_Nonce[AsterizmNonce] + MSG_31_1[event DeployContractEvent] + C_Nonce --> MSG_31_1 + MSG_31_1 --> Actor_Any + MSG_31_2[event NonceIncreacementEvent _nonce uint] + C_Nonce --> MSG_31_2 + MSG_31_2 --> Actor_Any +``` + +--- + +# 4.5 Demo контракты (примеры интеграции) + +## AsterizmDemo (`contracts/demo/AsterizmDemo.tsol`) + +`AsterizmDemo` наследует `AsterizmClient` и добавляет только «прикладной» метод `sendMessage`. + +```mermaid +graph TD + Actor_User[User] + Actor_Any[Any listener] + C_AsterizmDemo[AsterizmDemo] + + MSG_32_1[sendMessage _dstChainId uint64 _message string] + Actor_User --> MSG_32_1 + MSG_32_1 --> C_AsterizmDemo + MSG_32_2[event InitiateTransferEvent dstChainId dstAddress txId transferHash payload abi.encode _message] + C_AsterizmDemo --> MSG_32_2 + MSG_32_2 --> Actor_Any + MSG_32_3[event SetChainMessageEvent _message string] + C_AsterizmDemo --> MSG_32_3 + MSG_32_3 --> Actor_Any +``` + +## AsterizmTest (`contracts/demo/AsterizmTest.tsol`) + +```mermaid +graph TD + Actor_User[User] + Actor_Any[Any listener] + C_AsterizmTest[AsterizmTest] + + MSG_33_1[sendMessage _dstChainId uint64 _uint24Data uint24 _uint72Data uint72 _int24Data int24 _int72Data int72] + Actor_User --> MSG_33_1 + MSG_33_1 --> C_AsterizmTest + MSG_33_2[event InitiateTransferEvent dstChainId dstAddress txId transferHash payload abi.encode uint24 uint72 int24 int72] + C_AsterizmTest --> MSG_33_2 + MSG_33_2 --> Actor_Any + MSG_33_3[event SetChainMessageEvent uint24Data uint24 uint72Data uint72 int24Data int24 int72Data int72] + C_AsterizmTest --> MSG_33_3 + MSG_33_3 --> Actor_Any +``` + +# 5) Projects — MultichainToken / MultichainTokenWR (Jetton <-> Asterizm) + +## 5.1 Jetton transfer_notification -> кроссчейн (fallback в MultichainToken) + +`MultichainToken` ожидает входящее сообщение от `baseTokenWallet` с `op=0x7362d09c` (Jetton `transfer_notification`). + +```mermaid +sequenceDiagram + participant JettonWallet as JettonWallet baseTokenWallet + participant MCT as MultichainToken + participant Relayer as Offchain + participant Init as Initializer + participant Tr as Translator + + JettonWallet->>MCT: transfer_notification op 0x7362d09c query_id uint64 amount VarUInteger from MsgAddress forward_payload Either Cell Cell + MCT->>MCT: if forward_payload is ref with 320 bits chainId uint64 target uint256 + MCT->>MCT: crossChainTransfer dstChainId uint64 from address to uint256 amount uint + MCT->>Relayer: event InitiateTransferEvent dstChainId dstAddress txId transferHash payload abi.encode to amount txId + Relayer->>MCT: initAsterizmTransfer dstChainId txId transferHash fee + MCT->>Init: initTransfer _dto dstChainId uint64 dstAddress uint256 transferHash uint256 txId uint256 dstFeeAmount uint128 relay address transferResultNotifyFlag bool + Init->>Tr: sendMessage _dto srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 transferHash uint256 dstFeeAmount uint128 transferResultNotifyFlag bool +``` + +## 5.2 Исходящее Jetton transfer (как собирается body) + +В `MultichainToken.sendBaseToken()` формируется тело Jetton `transfer` вручную (`op=0xf8a7ea5`). + +```mermaid +graph TD + Msg_JettonTransfer[Jetton transfer op 0xf8a7ea5] + Msg_JettonTransfer --> F_query_id[query_id uint64 0] + Msg_JettonTransfer --> F_amount[amount VarUInteger16 stored as 120-bit in code] + Msg_JettonTransfer --> F_destination[destination MsgAddress _to] + Msg_JettonTransfer --> F_response_destination[response_destination MsgAddress addr_none 2 zero bits] + Msg_JettonTransfer --> F_custom_payload[custom_payload Maybe Cell null] + Msg_JettonTransfer --> F_forward_ton_amount[forward_ton_amount VarUInteger16 0] + Msg_JettonTransfer --> F_forward_payload[forward_payload Either Cell Cell empty single 0 bit] +``` + +## 5.3 Сообщения MultichainToken (уникальная часть поверх AsterizmClient) + +`MultichainToken` и `MultichainTokenWR` наследуют весь публичный API `AsterizmClient` (см. раздел 4.1) и добавляют: + +```mermaid +graph TD + Actor_Owner[Owner] + Actor_JettonWallet[JettonWallet baseTokenWallet] + Actor_Any[Any listener] + C_MultichainToken[MultichainToken MultichainTokenWR] + + MSG_35_1[setBaseTokenWallet _baseTokenAddress address] + Actor_Owner --> MSG_35_1 + MSG_35_1 --> C_MultichainToken + MSG_35_2[transfer_notification op 0x7362d09c query_id uint64 amount Coins from MsgAddress forward_payload Either] + Actor_JettonWallet --> MSG_35_2 + MSG_35_2 --> C_MultichainToken + MSG_35_3[event InitiateTransferEvent _dstChainId uint64 _dstAddress uint256 _txId uint256 _transferHash uint256 _payload cell from AsterizmClient] + C_MultichainToken --> MSG_35_3 + MSG_35_3 --> Actor_Any +``` + +--- + +# 6) Projects — GasStation (TIP-3 stablecoin -> gas via Asterizm) + +## 6.1 Стаблкоин transfer callback -> инициирование газовых переводов + +```mermaid +sequenceDiagram + participant StableWallet as TIP3 TokenWallet stable coin + participant Gas as GasStation + participant Offchain as Offchain + participant Init as Initializer + participant Tr as Translator + + StableWallet->>Gas: onAcceptTokensTransfer tokenRoot address amount uint128 sender address senderWallet address remainingGasTo address payload cell + Gas->>Gas: payload decode - chainIds uint64 amounts uint receivers uint + Gas->>StableWallet: transfer amount sum to owner deployWalletValue 0 remainingGasTo Gas notifyReceiver false payload empty + Gas->>Gas: for each i payload_i abi.encode receivers i amounts i txId tokenRootUint decimals + Gas->>Offchain: event InitiateTransferEvent dstChainId dstAddress txId transferHash payload_i repeated per i + Gas->>Offchain: event GasSendEvent dstChainId txId payload_i repeated per i + Offchain->>Gas: initAsterizmTransfer dstChainId txId transferHash fee repeated per i + Gas->>Init: initTransfer _dto dstChainId uint64 dstAddress uint256 transferHash uint256 txId uint256 dstFeeAmount uint128 relay address transferResultNotifyFlag bool repeated per i + Init->>Tr: sendMessage _dto srcAddress uint256 dstChainId uint64 dstAddress uint256 txId uint256 transferHash uint256 dstFeeAmount uint128 transferResultNotifyFlag bool repeated per i +``` + +## 6.2 Payload для GasStation (получение на целевой сети) + +В `GasStation._asterizmReceive()` ожидается payload с дополнительным `stableRate` (не входит в hash-проверку). + +```mermaid +graph TD + GasPayload[GasStation payload ClAsterizmReceiveRequestDto.payload] + GasPayload --> GP_dstAddressUint[dstAddressUint uint] + GasPayload --> GP_amount[amount uint] + GasPayload --> GP_txId[txId uint] + GasPayload --> GP_tokenAddressUint[tokenAddressUint uint token root] + GasPayload --> GP_decimals[decimals uint8] + GasPayload --> GP_stableRate[stableRate uint used for amountToSend amount stableRate 10 decimals] +``` + +## 6.3 Сообщения и события GasStation (по исходнику `contracts/projects/gas/GasStation.tsol`) + +```mermaid +graph TD + Actor_Owner[Owner] + Actor_Any[Any listener] + Actor_Tip3Wallet[TIP-3 TokenWallet stable coin wallet] + C_GasStation[GasStation] + + MSG_37_1[withdrawCoins _target address _amount uint128] + Actor_Owner --> MSG_37_1 + MSG_37_1 --> C_GasStation + MSG_37_2[withdrawTokens _tokenRoot ITokenRoot _target address _amount uint128] + Actor_Owner --> MSG_37_2 + MSG_37_2 --> C_GasStation + MSG_37_3[setMinUsdAmount _amount uint] + Actor_Owner --> MSG_37_3 + MSG_37_3 --> C_GasStation + MSG_37_4[setMaxUsdAmount _amount uint] + Actor_Owner --> MSG_37_4 + MSG_37_4 --> C_GasStation + MSG_37_5[setMinUsdAmountPerChain _amount uint] + Actor_Owner --> MSG_37_5 + MSG_37_5 --> C_GasStation + MSG_37_6[setMaxUsdAmountPerChain _amount uint] + Actor_Owner --> MSG_37_6 + MSG_37_6 --> C_GasStation + MSG_37_7[addStableCoin _tokenRoot ITokenRoot _decimals uint8] + Actor_Owner --> MSG_37_7 + MSG_37_7 --> C_GasStation + MSG_37_8[removeStableCoin _tokenAddress address] + Actor_Owner --> MSG_37_8 + MSG_37_8 --> C_GasStation + + MSG_37_9[buildGasPayload chainIds uint64 array amounts uint array receivers uint array] + Actor_Any --> MSG_37_9 + MSG_37_9 --> C_GasStation + MSG_37_10[onAcceptTokensTransfer _tokenRoot address _amount uint128 _sender address _senderWallet address _remainingGasTo address _payload cell] + Actor_Tip3Wallet --> MSG_37_10 + MSG_37_10 --> C_GasStation + + MSG_37_11[event CoinsReceivedEvent _amount uint _transactionId uint _dstAddress address] + C_GasStation --> MSG_37_11 + MSG_37_11 --> Actor_Any + MSG_37_12[event GasSendEvent _dstChainId uint64 _transactionId uint _payload cell] + C_GasStation --> MSG_37_12 + MSG_37_12 --> Actor_Any + MSG_37_13[event AddStableCoinEvent _rootAddress address _walletAddress address] + C_GasStation --> MSG_37_13 + MSG_37_13 --> Actor_Any + MSG_37_14[event RemoveStableCoinEvent _address address] + C_GasStation --> MSG_37_14 + MSG_37_14 --> Actor_Any + MSG_37_15[event SetMinUsdAmountEvent _amount uint] + C_GasStation --> MSG_37_15 + MSG_37_15 --> Actor_Any + MSG_37_16[event SetMaxUsdAmountEvent _amount uint] + C_GasStation --> MSG_37_16 + MSG_37_16 --> Actor_Any + MSG_37_17[event SetMinUsdAmountPerChainEvent _amount uint] + C_GasStation --> MSG_37_17 + MSG_37_17 --> Actor_Any + MSG_37_18[event SetMaxUsdAmountPerChainEvent _amount uint] + C_GasStation --> MSG_37_18 + MSG_37_18 --> Actor_Any + MSG_37_19[event WithdrawCoinsEvent _target address _amount uint128] + C_GasStation --> MSG_37_19 + MSG_37_19 --> Actor_Any + MSG_37_20[event WithdrawTokensEvent _token address _target address _amount uint] + C_GasStation --> MSG_37_20 + MSG_37_20 --> Actor_Any + MSG_37_21[event WithdrawNotExistsTokensEvent _token address _target address _amount uint] + C_GasStation --> MSG_37_21 + MSG_37_21 --> Actor_Any + MSG_37_22[event BuildGasPayloadEvent _payload cell] + C_GasStation --> MSG_37_22 + MSG_37_22 --> Actor_Any +``` + +--- + +# 7) FunC / Jetton стандарт (contracts-fc/*) + +## 7.1 Jetton wallet message bodies (op-codes из `contracts-fc/op-codes.fc`) + +```mermaid +graph TD + JW_transfer[transfer op 0xf8a7ea5] + JW_transfer --> JW_t_query[query_id uint64] + JW_transfer --> JW_t_amount[amount Coins VarUInteger 16] + JW_transfer --> JW_t_destination[destination MsgAddress] + JW_transfer --> JW_t_response[response_destination MsgAddress] + JW_transfer --> JW_t_custom[custom_payload Maybe Cell] + JW_transfer --> JW_t_fwdTon[forward_ton_amount Coins VarUInteger 16] + JW_transfer --> JW_t_fwdPayload[forward_payload Either Cell Cell] +``` + +```mermaid +graph TD + JW_internal[internal_transfer op 0x178d4519] + JW_internal --> JW_i_query[query_id uint64] + JW_internal --> JW_i_amount[amount Coins VarUInteger 16] + JW_internal --> JW_i_from[from MsgAddress] + JW_internal --> JW_i_response[response_address MsgAddress] + JW_internal --> JW_i_fwdTon[forward_ton_amount Coins VarUInteger 16] + JW_internal --> JW_i_fwdPayload[forward_payload Either Cell Cell] +``` + +```mermaid +graph TD + JW_notify[transfer_notification op 0x7362d09c] + JW_notify --> JW_n_query[query_id uint64] + JW_notify --> JW_n_amount[amount Coins VarUInteger 16] + JW_notify --> JW_n_from[from MsgAddress] + JW_notify --> JW_n_payload[forward_payload Either Cell Cell copied from internal_transfer] +``` + +```mermaid +graph TD + JW_excess[excesses op 0xd53276db] + JW_excess --> JW_ex_query[query_id uint64] +``` + +```mermaid +graph TD + JW_burn[burn op 0x595f07bc] + JW_burn --> JW_b_query[query_id uint64] + JW_burn --> JW_b_amount[amount Coins VarUInteger 16] + JW_burn --> JW_b_resp[response_destination MsgAddress] + JW_burn --> JW_b_custom[custom_payload Maybe Cell] +``` + +```mermaid +graph TD + JW_burn_notif[burn_notification op 0x7bdd97de] + JW_burn_notif --> JW_bn_query[query_id uint64] + JW_burn_notif --> JW_bn_amount[amount Coins VarUInteger 16] + JW_burn_notif --> JW_bn_owner[owner_address MsgAddress] + JW_burn_notif --> JW_bn_resp[response_address MsgAddress] +``` + +## 7.2 Jetton transfer flow (wallet -> wallet) + +```mermaid +sequenceDiagram + participant OwnerA as Owner A + participant WalletA as JettonWallet A + participant WalletB as JettonWallet B + participant OwnerB as Owner B + participant Resp as response_destination + + OwnerA->>WalletA: transfer op 0xf8a7ea5 query_id amount destination response_destination custom_payload forward_ton_amount forward_payload + WalletA->>WalletB: internal_transfer op 0x178d4519 query_id amount from OwnerA response_address response_destination forward_ton_amount forward_payload + WalletB->>OwnerB: transfer_notification op 0x7362d09c query_id amount from OwnerA forward_payload + WalletB->>Resp: excesses op 0xd53276db query_id +``` + +## 7.3 Jetton burn flow (wallet -> minter) + +```mermaid +sequenceDiagram + participant Owner as Owner + participant Wallet as JettonWallet + participant Minter as JettonMinter + participant Resp as response_destination + + Owner->>Wallet: burn op 0x595f07bc query_id amount response_destination custom_payload + Wallet->>Minter: burn_notification op 0x7bdd97de query_id amount owner_address response_address response_destination + Minter->>Resp: excesses op 0xd53276db query_id +``` + +## 7.4 Jetton discovery (provide_wallet_address / take_wallet_address) + +```mermaid +graph TD + Disc_provide[provide_wallet_address op 0x2c76b973] + Disc_provide --> Disc_p_query[query_id uint64] + Disc_provide --> Disc_p_owner[owner_address MsgAddress] + Disc_provide --> Disc_p_include[include_address Bool] +``` + +```mermaid +graph TD + Disc_take[take_wallet_address op 0xd1735400] + Disc_take --> Disc_t_query[query_id uint64] + Disc_take --> Disc_t_wallet[wallet_address MsgAddress or addr_none] + Disc_take --> Disc_t_included[included_address Maybe Cell containing owner_address if requested] +``` + +```mermaid +sequenceDiagram + participant Caller as Caller + participant Discovery as JettonDiscovery + + Caller->>Discovery: provide_wallet_address op 0x2c76b973 query_id owner_address include_address + Discovery->>Caller: take_wallet_address op 0xd1735400 query_id wallet_address maybe_included_owner_address +``` + +## 7.5 Jetton mint (admin mint) и ICO-покупка (empty body) + +```mermaid +graph TD + JM_mint[mint op 21] + JM_mint --> JM_m_query[query_id uint64] + JM_mint --> JM_m_to[to_address MsgAddress] + JM_mint --> JM_m_amount[amount Coins TON value for deploy msg] + JM_mint --> JM_m_master[master_msg Cell internal_transfer op 0x178d4519 query_id uint64 amount Coins from MsgAddress response_address MsgAddress forward_ton_amount Coins forward_payload Either] +``` + +```mermaid +graph TD + JM_change_admin[change_admin op 3] + JM_change_admin --> JM_ca_query[query_id uint64] + JM_change_admin --> JM_ca_new[new_admin_address MsgAddress] +``` + +```mermaid +graph TD + JM_change_content[change_content op 4] + JM_change_content --> JM_cc_query[query_id uint64] + JM_change_content --> JM_cc_content[content Cell] +``` + +```mermaid +sequenceDiagram + participant Admin as Admin + participant Minter as JettonMinter + participant Wallet as JettonWallet to + + Admin->>Minter: mint op 21 query_id uint64 to_address MsgAddress amount Coins master_msg Cell internal_transfer op 0x178d4519 query_id uint64 amount Coins from MsgAddress response_address MsgAddress forward_ton_amount Coins forward_payload Either + Minter->>Wallet: deploy internal msg state_init master_msg +``` + +```mermaid +sequenceDiagram + participant Buyer as Buyer + participant IcoMinter as JettonMinter_ICO + participant BuyerWallet as JettonWallet Buyer + + Buyer->>IcoMinter: empty body buy with msg_value + IcoMinter->>BuyerWallet: deploy internal msg internal_transfer master_msg +``` + +## 7.6 Jetton get-методы (offchain read) + +```mermaid +graph TD + JW_get[JettonWallet.get_wallet_data method_id] + JW_get --> JW_get_balance[returns balance Coins] + JW_get --> JW_get_owner[returns owner_address MsgAddress] + JW_get --> JW_get_master[returns jetton_master_address MsgAddress] + JW_get --> JW_get_code[returns jetton_wallet_code Cell] +``` + +```mermaid +graph TD + JM_get_data[JettonMinter.get_jetton_data method_id] + JM_get_data --> JM_gd_supply[returns total_supply Coins] + JM_get_data --> JM_gd_mintable[returns mintable int -1 in reference impl] + JM_get_data --> JM_gd_admin[returns admin_address MsgAddress] + JM_get_data --> JM_gd_content[returns content Cell] + JM_get_data --> JM_gd_wallet_code[returns jetton_wallet_code Cell] +``` + +```mermaid +graph TD + JM_get_wallet[JettonMinter.get_wallet_address owner_address MsgAddress method_id] + JM_get_wallet --> JM_gw_wallet[returns wallet_address MsgAddress] +``` + +--- + +# 8) FunC — Granter (contracts/granter/granter.fc) + +## 8.1 Сообщения Granter + +```mermaid +graph TD + G_set[set_address op 0x15eb8d35] + G_set --> G_set_wallet[new_wallet MsgAddress] +``` + +```mermaid +graph TD + G_grant[grant op 0x30c3eaa8] + G_grant --> G_grant_to[recipient msg.sender] + G_grant --> G_grant_amount[jetton_amount Coins 100000000000] + G_grant --> G_grant_body[sends Jetton transfer op 0xf8a7ea5 query_id 0 amount 100000000000 destination recipient response_destination recipient custom_payload null forward_ton_amount 0 forward_payload empty to g_wallet] +``` + +```mermaid +graph TD + G_get[get_state_variables method_id] + G_get --> G_get_owner[returns g_owner MsgAddress] + G_get --> G_get_wallet[returns g_wallet MsgAddress] +``` + +## 8.2 Grant flow + +```mermaid +sequenceDiagram + participant User as User + participant Granter as Granter + participant JettonWallet as JettonWallet g_wallet + + User->>Granter: grant op 0x30c3eaa8 + Granter->>JettonWallet: transfer op 0xf8a7ea5 query_id 0 amount 100000000000 destination User response_destination User custom_payload null forward_ton_amount 0 forward_payload empty +``` + +--- + +# 9) FunC — Notifier (contracts-fc/notifier.fc) + +## 9.1 Сообщения Notifier + +```mermaid +graph TD + N_increase[increase op 0x7e8764ef] + N_increase --> N_inc_by[increase_by uint32 parsed immediately after op] + N_increase --> N_inc_note[NOTE notifier.fc does NOT load query_id uint64 for increase] +``` + +```mermaid +graph TD + N_transfer[transfer op 0xf8a7ea5] + N_transfer --> N_tr_query[query_id uint64] + N_transfer --> N_tr_amount[amount Coins VarUInteger 16] + N_transfer --> N_tr_destination[destination MsgAddress] + N_transfer --> N_tr_response[response_destination MsgAddress] + N_transfer --> N_tr_custom[custom_payload Maybe Cell] + N_transfer --> N_tr_fwdTon[forward_ton_amount Coins VarUInteger 16] + N_transfer --> N_tr_fwdPayload[forward_payload Either Cell Cell] + N_transfer --> N_tr_effect[effect ctx_counter jetton_amount] +``` + +```mermaid +graph TD + N_notify[notify op 0xbb620d9c] + N_notify --> N_notify_target[owner_address MsgAddress target] + N_notify --> N_notify_from[from_address MsgAddress] + N_notify --> N_notify_payload[forward_payload remaining slice example chainId uint64 dst MsgAddress] +``` + +```mermaid +graph TD + N_get_counter[get_counter method_id] + N_get_counter --> N_get_counter_ret[returns int ctx_counter] + N_get_id[get_id method_id] + N_get_id --> N_get_id_ret[returns int ctx_id] +``` + +## 9.2 notify -> transfer_notification (outgoing) + +```mermaid +sequenceDiagram + participant Caller as Caller + participant Notifier as Notifier + participant Target as Target owner_address + + Caller->>Notifier: notify op 0xbb620d9c owner_address MsgAddress from_address MsgAddress chainId uint64 dst MsgAddress + Notifier->>Target: transfer_notification op 0x7362d09c query_id 1 amount 756 from from_address forward_payload_slice chainId uint64 dst MsgAddress +```