Skip to content

Instantly share code, notes, and snippets.

@mightybyte
Created June 3, 2019 21:08
Show Gist options
  • Save mightybyte/f795fd59cb9d1a42fd09bff1d75c2c6c to your computer and use it in GitHub Desktop.
Save mightybyte/f795fd59cb9d1a42fd09bff1d75c2c6c to your computer and use it in GitHub Desktop.

Revisions

  1. mightybyte created this gist Jun 3, 2019.
    32 changes: 32 additions & 0 deletions type-error.pact
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    ; Simplified example of a token implementation.
    ; When I run `(typecheck "my-token")` I get the error:
    ; > Typecheck my-token: Unable to resolve all types

    (module my-token GOVERNANCE

    (defschema accounts-schema
    balance:integer
    guard:guard
    )

    (deftable accounts-table:{accounts-schema})

    (defcap GOVERNANCE ()
    true
    )

    (defcap NULL_GUARD ()
    "Used as a placeholder when calling with-default-read."
    false
    )

    (defun get-balance:integer (accountId:string)
    (with-default-read accounts-table accountId
    { "balance" : 0, "guard" : NULL_GUARD }
    { "balance" := balance }
    balance
    )
    )
    )

    (create-table accounts-table)