-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
329 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ on: | |
workflow_dispatch: | ||
|
||
jobs: | ||
tests: | ||
name: Run test suite | ||
kudos-tests: | ||
name: Kudos | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
|
@@ -19,13 +19,34 @@ jobs: | |
- name: Download latest nightly Juvix binary | ||
uses: jaxxstorm/[email protected] | ||
with: | ||
repo: anoma/juvix-nightly-builds | ||
repo: anoma/juvix | ||
cache: enable | ||
- name: Clean | ||
run: juvix clean --global && juvix clean && juvix dependencies update | ||
- name: Type Check | ||
run: juvix typecheck | ||
- name: Format Check | ||
run: juvix format | ||
#- name: Run Example | ||
# run: juvix eval Example.juvix | ||
|
||
hello-world-tests: | ||
name: Hello World | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: HelloWorld | ||
steps: | ||
- name: checkout code | ||
uses: actions/checkout@v3 | ||
- name: Download latest nightly Juvix binary | ||
uses: jaxxstorm/[email protected] | ||
with: | ||
repo: anoma/juvix | ||
cache: enable | ||
- name: Clean | ||
run: juvix clean --global && juvix clean && juvix dependencies update | ||
- name: Type Check | ||
run: juvix typecheck | ||
- name: Format Check | ||
run: juvix format | ||
- name: Run Example | ||
run: juvix eval Example.juvix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
.history | ||
*.nockma | ||
.DS_Store | ||
|
||
|
||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
module Interface.Transaction; | ||
|
||
import Stdlib.Prelude open; | ||
import Stdlib.Data.Set as Set open using {Set}; | ||
import Stdlib.Data.Map as Map open using {Map}; | ||
import Anoma open; | ||
import Applib open; | ||
import Resource open; | ||
|
||
transferHello | ||
(standardInputs : StandardInputs) | ||
(existingHello : Resource) | ||
(receiver : ExternalIdentity) | ||
: Transaction := | ||
let | ||
nonce := generateNonce (StandardInputs.randSeed standardInputs); | ||
in prepareTransaction@{ | ||
standardInputs; | ||
consumed := Set.singleton existingHello; | ||
created := | ||
Set.singleton | ||
mkHelloResource@{ | ||
owner := receiver; | ||
nonce; | ||
}; | ||
}; | ||
|
||
helloWorldIntent | ||
(standardInputs : StandardInputs) | ||
(existingHello : Resource) | ||
(receiver : ExternalIdentity) | ||
: Transaction := | ||
prepareTransaction@{ | ||
standardInputs; | ||
consumed := Set.singleton existingHello; | ||
created := | ||
Set.singleton | ||
mkWorldResource@{ | ||
owner := Identity.external (StandardInputs.caller standardInputs); | ||
nonce := generateNonce (StandardInputs.randSeed standardInputs); | ||
}; | ||
}; | ||
|
||
prepareTransaction | ||
(standardInputs : StandardInputs) | ||
(consumed created : Set Resource) | ||
: Transaction := | ||
let | ||
-- Put maps into the custom inputs that map: | ||
-- - nullifiers to consumed resources | ||
-- - commitments to created resources | ||
tagsAndCustomInputs := | ||
computeTagsAndCustomInputs@{ | ||
consumed; | ||
created; | ||
}; | ||
|
||
tags := TagsAndCustomInputs.tags tagsAndCustomInputs; | ||
pair := tagsToPair tags; | ||
nullifiers := fst pair; | ||
commitments := snd pair; | ||
|
||
-- Put signed messages and signatures from the caller in the app data. | ||
-- The signed messages link back to the original consumed resources, where the signature verification is part of the resource logic requiring the commitments of created resources to be part of the action. | ||
appData := | ||
Set.map (nullifier in nullifiers) { | ||
mkResourceRelationshipAppDataEntry@{ | ||
signer := Identity.internal (StandardInputs.caller standardInputs); | ||
origin := Consumed nullifier; | ||
mustBeConsumed := Set.empty; | ||
mustBeCreated := commitments; | ||
} | ||
} | ||
|> Map.fromSet; | ||
in mkTransactionHelper@{ | ||
roots := Set.singleton (StandardInputs.currentRoot standardInputs); | ||
actions := | ||
Set.singleton | ||
mkActionHelper@{ | ||
consumed; | ||
created; | ||
tags := TagsAndCustomInputs.tags tagsAndCustomInputs; | ||
appData; | ||
customInputs := | ||
TagsAndCustomInputs.customInputs tagsAndCustomInputs; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Package; | ||
|
||
import PackageDescription.V2 open; | ||
|
||
package : Package := | ||
defaultPackage@?{ | ||
name := "hello-world"; | ||
dependencies := | ||
[ | ||
github "anoma" "juvix-stdlib" "v0.8.0"; | ||
github "anoma" "juvix-arm-specs" "v2.0.0-transparent-alpha.1"; | ||
github "anoma" "anoma-app-lib" "v0.6.1"; | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
module Resource; | ||
|
||
import Stdlib.Prelude open; | ||
import Anoma open; | ||
import Anoma.Builtin.System open; | ||
import Applib open; | ||
import Applib.Authorization.Check open public; | ||
import Applib.Authorization.Check open public; | ||
import Applib.Authorization.Message open public; | ||
|
||
logic (publicInputs : Logic.Instance) (privateInputs : Logic.Witness) : Bool := | ||
let | ||
tag := Logic.Instance.tag publicInputs; | ||
customInputs := Logic.Witness.customInputs privateInputs; | ||
in case tag of | ||
| Consumed nullifier := | ||
case lookupResource nullifier customInputs of { | ||
| nothing := false | ||
| just self := | ||
isAuthorizedBy@{ | ||
signer := HasOwner.get self; | ||
origin := tag; | ||
publicInputs; | ||
} | ||
} | ||
| Created commitment := true; | ||
|
||
-- You don't need to change anything below this point. | ||
mkLabelledResource | ||
(label : String) | ||
(owner : ExternalIdentity) | ||
(nonce : Nonce) | ||
{ephemeral : Bool := false} | ||
: Resource := | ||
mkResource@{ | ||
logicRef := BindingReference.compute logic; | ||
labelRef := BindingReference.compute (mkLabel (anomaEncode label)); | ||
valueRef := BindingReference.compute (mkValue (anomaEncode owner)); | ||
quantity := 1; | ||
nonce; | ||
ephemeral; | ||
randSeed := UnusedRandSeed; | ||
nullifierKeyCommitment := Universal.nullifierKeyCommitment; | ||
}; | ||
|
||
mkHelloResource (owner : ExternalIdentity) (nonce : Nonce) : Resource := | ||
mkLabelledResource@{ | ||
label := "Hello"; | ||
owner; | ||
nonce; | ||
}; | ||
|
||
mkWorldResource (owner : ExternalIdentity) (nonce : Nonce) : Resource := | ||
mkLabelledResource@{ | ||
label := "World"; | ||
owner; | ||
nonce; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# This file was autogenerated by Juvix version 0.6.8. | ||
# Do not edit this file manually. | ||
|
||
version: 2 | ||
checksum: 7e1503c9e6c5f62bedadd6b6637bc55e25372a26fe9628bbf5f4026fd1ad34a5 | ||
dependencies: | ||
- git: | ||
name: anoma_juvix-stdlib | ||
ref: 0080b1183ab55e5180e69bfc3987e4cd6edbc230 | ||
url: https://github.com/anoma/juvix-stdlib | ||
dependencies: [] | ||
- git: | ||
name: anoma_juvix-arm-specs | ||
ref: dc691b9e17b4b8136296904d433c946f81588157 | ||
url: https://github.com/anoma/juvix-arm-specs | ||
dependencies: | ||
- git: | ||
name: anoma_juvix-stdlib | ||
ref: 0080b1183ab55e5180e69bfc3987e4cd6edbc230 | ||
url: https://github.com/anoma/juvix-stdlib | ||
dependencies: [] | ||
- git: | ||
name: anoma_anoma-app-lib | ||
ref: a6c4993f203d759051ef4a31c0c6c7fde0a9e9a2 | ||
url: https://github.com/anoma/anoma-app-lib | ||
dependencies: | ||
- git: | ||
name: anoma_juvix-stdlib | ||
ref: 0080b1183ab55e5180e69bfc3987e4cd6edbc230 | ||
url: https://github.com/anoma/juvix-stdlib | ||
dependencies: [] | ||
- git: | ||
name: anoma_juvix-arm-specs | ||
ref: dc691b9e17b4b8136296904d433c946f81588157 | ||
url: https://github.com/anoma/juvix-arm-specs | ||
dependencies: | ||
- git: | ||
name: anoma_juvix-stdlib | ||
ref: 0080b1183ab55e5180e69bfc3987e4cd6edbc230 | ||
url: https://github.com/anoma/juvix-stdlib | ||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.