@@ -144,13 +144,49 @@ impl MappingTriggerTrait for NearTrigger {
144144 }
145145}
146146
147+ /// Sentinel header byte returned by [`NearTrigger::to_rust_bytes`] to
148+ /// signal "unsupported chain" to any SDK that attempts to decode a NEAR
149+ /// trigger payload. Chosen as `0xFF` because it is outside the current
150+ /// TLV value-tag range (`0x00`..=`0x09`, see
151+ /// `runtime/wasm/src/rust_abi/types.rs::tags`) and therefore guarantees a
152+ /// deterministic decode failure rather than silent misinterpretation.
153+ const UNSUPPORTED_CHAIN_SENTINEL : u8 = 0xFF ;
154+
147155impl ToRustBytes for NearTrigger {
156+ /// Produce a Rust ABI payload for a NEAR trigger.
157+ ///
158+ /// NEAR triggers are **not** yet wired up to the Rust ABI. A real
159+ /// implementation would need to serialise, at minimum:
160+ ///
161+ /// - For [`NearTrigger::Block`]: the block header fields (hash,
162+ /// prev_hash, height, timestamp, author, gas_price, total_supply,
163+ /// etc.) plus any chunk metadata the SDK exposes to block handlers.
164+ /// - For [`NearTrigger::Receipt`]: the receipt id, predecessor /
165+ /// receiver account ids, the enclosing block's hash and height, the
166+ /// full action list (`CreateAccount`, `DeployContract`,
167+ /// `FunctionCall`, `Transfer`, `Stake`, `AddKey`, `DeleteKey`,
168+ /// `DeleteAccount`), and the execution outcome (status, gas burnt,
169+ /// tokens burnt, logs, emitted receipt ids).
170+ ///
171+ /// None of the above is currently serialised. Instead we emit a
172+ /// single-byte sentinel payload (`[UNSUPPORTED_CHAIN_SENTINEL]`, i.e.
173+ /// `[0xFF]`) that is guaranteed to fail decoding on the SDK side
174+ /// because `0xFF` is not a valid TLV value tag (the tag space is
175+ /// `0x00`..=`0x09`; see `runtime/wasm/src/rust_abi/types.rs::tags`).
176+ ///
177+ /// This is intentionally louder than the previous `Vec::new()` stub:
178+ /// an empty payload could be silently round-tripped as "no data", and
179+ /// a Rust subgraph targeting NEAR would index garbage without ever
180+ /// realising something was wrong. The sentinel byte forces a
181+ /// deterministic handler failure at the first byte of the payload.
182+ ///
183+ /// There is deliberately no logging call here: `to_rust_bytes` has
184+ /// no `Logger` in scope and threading one through would pollute the
185+ /// trait for every chain. Operators will see the SDK-side decode
186+ /// error surfaced as a mapping failure, which is the loud signal we
187+ /// want.
148188 fn to_rust_bytes ( & self ) -> Vec < u8 > {
149- // NEAR triggers are not yet supported by the Rust ABI.
150- // Return empty bytes rather than panicking; the handler will receive no data
151- // and can decide how to proceed. A Rust subgraph targeting NEAR would need
152- // to implement NEAR-specific serialization in a future PR.
153- Vec :: new ( )
189+ vec ! [ UNSUPPORTED_CHAIN_SENTINEL ]
154190 }
155191}
156192
0 commit comments