Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces foundational TON (The Open Network) support across the omni stack by adding a TON locker implementation (Tolk + TS wrappers/scripts/tests) and wiring TON into the NEAR-side types, parsing, and routing layers.
Changes:
- Added a TON locker implementation in
ton/(Tolk contracts, TS wrappers, scripts, and a comprehensive sandbox test suite). - Extended
near/omni-typesto supportChainKind::Ton, TON address encoding/decoding, and TON event parsing. - Integrated TON into NEAR bridge/prover/test plumbing and added a dedicated GitHub Actions workflow for TON checks.
Reviewed changes
Copilot reviewed 45 out of 46 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
ton/wrappers/OmniBridge.ts |
TS wrapper + payload encoding helpers for the TON locker contract. |
ton/wrappers/OmniBridge.compile.ts |
Blueprint compile config for OmniBridge Tolk contract. |
ton/wrappers/BridgeJettonWallet.ts |
TS wrapper for bridge jetton wallet contract. |
ton/wrappers/BridgeJettonWallet.compile.ts |
Blueprint compile config for BridgeJettonWallet. |
ton/wrappers/BridgeJettonMaster.ts |
TS wrapper for bridge jetton master contract. |
ton/wrappers/BridgeJettonMaster.compile.ts |
Blueprint compile config for BridgeJettonMaster. |
ton/tsconfig.json |
TypeScript configuration for TON module. |
ton/tests/OmniBridge.spec.ts |
TON sandbox integration tests for the locker (native + jetton flows, bounces, regressions). |
ton/scripts/_argv.ts |
Shared CLI arg parsing for TON scripts. |
ton/scripts/buildPayload.ts |
Helper script to reconstruct NEAR-signed payload bytes for fin_transfer. |
ton/scripts/decodeEvent.ts |
Helper script to decode locker ext-out event BoCs. |
ton/scripts/deployJetton.ts |
Script to submit NEAR-MPC-signed metadata payload to deploy_token. |
ton/scripts/deployOmniBridge.ts |
Script to deploy the TON locker with configured MPC-derived signer. |
ton/scripts/deriveMpc.ts |
Local/dev helper to generate a mock MPC key + derived address. |
ton/scripts/finTransfer.ts |
Script to submit NEAR-MPC-signed transfer payload to fin_transfer. |
ton/scripts/formatLogMetadataEvent.ts |
Script to transform NEAR LogMetadataEvent JSON into TON deploy_token inputs. |
ton/scripts/formatSignTransferEvent.ts |
Script to transform NEAR SignTransferEvent JSON into TON fin_transfer inputs. |
ton/scripts/initTransferNative.ts |
Script to call init_transfer_native on the locker. |
ton/scripts/logMetadata.ts |
Script to initiate TEP-89 log_metadata flow. |
ton/scripts/nearPubkeyToAddress.ts |
Convert NEAR-format secp256k1 pubkey to Ethereum-style 20-byte address for locker config. |
ton/scripts/registerJetton.ts |
Admin-only script to register jettons in the locker (bypass TEP-89). |
ton/scripts/setJettonCode.ts |
Admin script to update stored jetton master/wallet code cells in locker state. |
ton/scripts/showAddress.ts |
Utility to print address encodings and basic on-chain state. |
ton/scripts/transferJetton.ts |
Script to perform a TEP-74 jetton transfer into the locker with bridge forward_payload. |
ton/scripts/upgradeCode.ts |
Admin script to hot-swap locker code via SETCODE. |
ton/scripts/verifySignature.ts |
Off-chain verifier for locker’s ECRECOVER-based signature check. |
ton/package.json |
TON module tooling deps/scripts (biome, tsc, jest, blueprint, tolk-js). |
ton/jest.config.ts |
Jest config for TON tests. |
ton/contracts/omni_bridge.tolk |
Core TON locker contract implementation. |
ton/contracts/bridge_jetton_wallet.tolk |
Jetton wallet used for bridge-minted tokens. |
ton/contracts/bridge_jetton_master.tolk |
Jetton master used for bridge-minted tokens. |
ton/blueprint.config.ts |
Blueprint project config. |
ton/biome.json |
Biome formatting/linting rules for TON module. |
ton/.gitignore |
Ignore build artifacts and local env for TON module. |
near/omni-types/src/ton/mod.rs |
Exposes TON submodules in omni-types. |
near/omni-types/src/ton/address.rs |
TON user-friendly address parsing/formatting + CRC validation. |
near/omni-types/src/ton/events.rs |
Parsers for TON locker ext-out event bodies. |
near/omni-types/src/tests/lib_test.rs |
Extends omni-types serialization/parsing tests to cover TON. |
near/omni-types/src/mpc_types.rs |
Adds TON finality and MpcFinality::Ton. |
near/omni-types/src/lib.rs |
Adds ChainKind::Ton, OmniAddress::Ton, native token address handling. |
near/omni-tests/src/helpers.rs |
Adds a TON factory address helper for tests. |
near/omni-tests/src/omni_token.rs |
Wires TON into factory address selection logic in tests. |
near/omni-prover/mpc-omni-prover/src/lib.rs |
Recognizes TON for finality defaults and parsing dispatch (proof parsing still stubbed). |
near/omni-bridge/src/lib.rs |
Allows determining TON origin chain from identifiers. |
.github/workflows/ton.yaml |
Adds CI workflow to lint/typecheck/build/test the TON module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // The tag byte is a display-level hint: bit 0x80 = testnet, | ||
| // bit 0x40 = non-bounceable, low 6 bits = 0x11. On-chain only the | ||
| // workchain + 32-byte hash matter, so accept any combination of the | ||
| // testnet / non-bounceable bits and validate the low bits only. | ||
| let flags = raw[0]; | ||
| let low_bits = flags & !(TAG_TESTNET_BIT | TAG_NON_BOUNCEABLE_BIT); | ||
| if low_bits != TAG_LOW_BITS { | ||
| return Err(format!( | ||
| "TON address: invalid flags byte {flags:#04x} (low bits {low_bits:#04x}, expected {TAG_LOW_BITS:#04x})" | ||
| )); | ||
| } |
There was a problem hiding this comment.
TonAddress::from_str currently accepts the testnet flag (0x80) even though the module docs and unit tests say testnet addresses must be rejected. As written, a kQ.../0Q... address will parse successfully as long as CRC matches.
Add an explicit check like if flags & TAG_TESTNET_BIT != 0 { return Err("TON address: testnet addresses are not supported".to_string()) } (and keep allowing bounceable vs non-bounceable).
This pull request adds foundational support for the TON blockchain across the omni-bridge, omni-types, and omni-prover modules. It introduces TON as a new chain kind, adds serialization and address handling for TON, and integrates TON into the testing framework. Additionally, a new GitHub Actions workflow is added for the TON module. While TON is now recognized throughout the codebase, full proof support is not yet implemented.
TON Chain Integration:
Tonas a new variant toChainKindand integrated it into omni-address parsing, formatting, and zero address handling innear/omni-types(ChainKind,OmniAddress,get_native_token_address, etc.) [1] [2] [3] [4] [5] [6] [7] [8]TonAddresstype and corresponding module for address parsing and validation, including user-friendly base64url format and CRC checks (near/omni-types/src/lib.rsR158-R159, F8c6b30cL8R24)TON Finality and Prover Support:
TonFinalityand included TON in theMpcFinalityenum innear/omni-types/src/mpc_types.rsBridge and Factory Integration:
Testing Enhancements:
DevOps:
.github/workflows/ton.yaml) to lint, typecheck, build, and test the TON module