Pi-Squared-Inc/rust-demo-semantics

Preprocess endpoints

Closed this issue · 0 comments

For each endpoint we should add to the contract trait a wrapper function that does something like this:

fn wrap<endpointName>(b:Bytes) -> Bytes {
    let (v1, b, success) = decodeU64(b);
    if not success { Helpers::fail(); }
    let (v2, b, success) = decodeStuff(b);
    if not success { Helpers::fail(); }
    ...
    let v = endpointFunction(v1, v2, ...);
    return encodeStuff(v);
}