codec: create codec module#435
Conversation
There was a problem hiding this comment.
These tests use packages from the main module which pollutes the go.mod. We can either leave the tests behind the main module only, or find a way to adapt them.
There was a problem hiding this comment.
we can keep them in the main module since they're technically integration-ish tests (they test CR & Indexer functionality indirectly)
There was a problem hiding this comment.
types are migrated here
There was a problem hiding this comment.
I wonder if those types belong to the top-level codec module, not a hard opinion though, I can see it working both here and in relayer/common
There was a problem hiding this comment.
Pull request overview
This PR factors Sui codec-related functionality into a new top-level Go module github.com/smartcontractkit/chainlink-sui/codec, moving the existing relayer/codec and relayer/chainreader/loop implementations there while keeping the old packages as deprecated forwarders for compatibility.
Changes:
- Introduces a new
codecmodule containing JSON decoding/type conversion, BCS conversion, encoding, and LOOP chain reader logic (plus unit/integration tests). - Converts existing
relayer/codecandrelayer/chainreader/looppackages into deprecated wrappers that forward to the new module. - Updates root and submodule
go.modfiles (andgo.mddependency diagram) to depend on/replace the newcodecmodule.
Reviewed changes
Copilot reviewed 25 out of 28 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/go.mod | Adds local replace + indirect require for the new codec module. |
| integration-tests/go.mod | Adds local replace + indirect require for the new codec module. |
| deployment/go.mod | Adds local replace + indirect require for the new codec module. |
| go.mod | Adds codec module dependency and local replace to ./codec. |
| go.md | Updates module dependency diagrams to include chainlink-sui/codec. |
| codec/go.mod | New standalone codec module definition and dependencies. |
| codec/go.sum | New codec module sums. |
| codec/types.go | New shared codec types + Sui address helpers + event structs. |
| codec/json_decoder.go | New mapstructure-based JSON return decoder. |
| codec/type_converters.go | New type-conversion registry + mapstructure decode hook. |
| codec/type_converters_test.go | Unit tests for type conversion behaviors. |
| codec/bcs_converter.go | New BCS primitive/vector conversion registry. |
| codec/bcs_converter_test.go | Unit tests for BCS converter behaviors. |
| codec/encoder.go | New encoding logic for Move/Sui argument values. |
| codec/decoder.go | New decoding utilities + execution report deserialization. |
| codec/decoder_test.go | Adjusts base64 decode test to not depend on removed shared.DecodeBase64. |
| codec/loop/loop_reader.go | New LOOP chain reader implementation under codec/loop. |
| codec/loop/loop_reader_test.go | Adds tests for LOOP reader boundary behaviors (currently build-tagged integration). |
| relayer/codec/types.go | Converts relayer codec types into aliases/forwarders to codec. |
| relayer/codec/type_converters.go | Converts relayer type converter into deprecated aliases/forwarders to codec. |
| relayer/codec/encoder.go | Converts relayer encoder into deprecated forwarder to codec. |
| relayer/codec/decoder.go | Converts relayer decoder into deprecated forwarders to codec. |
| relayer/codec/bcs_converter.go | Converts relayer BCS converter into deprecated forwarders to codec. |
| relayer/chainreader/loop/loop_reader.go | Converts relayer LOOP reader into deprecated forwarder to codec/loop. |
| relayer/chainreader/loop/loop_reader_test.go | Updates test to use codec/loop implementation directly. |
| bindings/bind/utils.go | Deprecates/forwards Sui address helpers to codec. |
| bindings/bind/json_decoder.go | Deprecates/forwards JSON return decoding to codec. |
| bindings/bind/common.go | Aliases bind.Object to codec.Object for backward compatibility. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This is much cleaner, thanks for creating the PR! Small heads up that I might make some minor changes to the codec in the next couple of days as I complete the o11y integration. |
can we merge this so your change is on top of this? |
This PR creates a separate, top-level module
codec, which contains therelayer/codecandrelayer/chainreader/looppackages. The old packages are deprecated but remain compatible by forwarding to the new module.Supports:
TODO: