The Adapter Pattern in Michelson
Translating off-chain alien data formats into compliant stack representations.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Adapter
ARCANUM SCHOOL: Transmutation // Stackmancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MICHELSON PATTERN //
parameter (int %legacy_signal);
storage (list nat);
code {
UNPAIR;
# Adapter layer: Converts legacy int to nat, handling negatives
ISNAT;
IF_NONE {
PUSH string "AdapterError: Signal must be non-negative";
FAILWITH;
} {
CONS;
};
NIL operation; PAIR
}
Runic Tags:
#structural
#adapter
#stack-based smart contracts
#michelson
#tezos