Explorer

definy.decode-stored-snapshot

description
Read a stored SignedEvent (Base64) as a project snapshot. none if it is not a project snapshot. Does not verify the signature (the store has only verified events). The server compiles this to wasm/commit_decoder.wasm
type
Fn(signed_event_bytes: String) -> Union{#none, #some(@definy.stored-snapshot)}
expression
fn(signed_event_bytes$0) =>
  match @std.base64-to-bytes(text: $0) {
    #none(_) =>
      #none,
    #some(bytes$1) =>
      match @definy.decode-signed-event(bytes: $1) {
        #decoded(decoded$2) =>
          match $2.content {
            #project_commit(commit$3) =>
              #some({
                account_id: @core.bytes-to-base64url(bytes: $2.account_id_bytes),
                project_name: $3.project_name,
                branch: $3.branch,
                time_ms: $2.time_ms,
                message: $3.message,
                parent_commit_hash: $3.parent_commit_hash,
                merged_commit_hash: $3.merged_commit_hash,
                modules: @core.list-map(
                  T: @core.project-snapshot-module,
                  U: @definy.stored-snapshot-module,
                  f: fn(item$4) =>
                    @definy.stored-snapshot-module-of(module: $4),
                  xs: $3.modules
                )
              }),
            _ =>
              #none
          },
        #invalid(_) =>
          #none
      }
  }
visibility
public
definy.decode-stored-snapshot (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: d16nZn4RMSH1sXbtax4z3uXZaaHypSE2O30dcY0yYIM
content hash: bwFaoY3kuYmugDUQ_H88ScmQU_T-c4W7xBgRcqsgmmc