-
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.
* refactor: kudos * build: update deps * feat: add logic comparison * revert: reintroduce example * fix: naming * docs: improve comment
- Loading branch information
1 parent
d82e7d8
commit e5807f4
Showing
10 changed files
with
115 additions
and
288 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 |
---|---|---|
@@ -1,26 +1,16 @@ | ||
module Example; | ||
|
||
import Anoma open; | ||
import Kudos open; | ||
import Stdlib.Prelude open; | ||
|
||
--- The originator's private key | ||
privKey : Nat := | ||
0xddd315c76991f8e058760cacdd19c21bf6a12c72bc229a60ad6aaa314fa07ac11662fc6e7829efcb0f4500827d49bb699af7b5475cef5220fd600ebbf9709a58; | ||
|
||
--- The originator's public key | ||
pubKey : PublicKey := | ||
0xddd315c76991f8e058760cacdd19c21bf6a12c72bc229a60ad6aaa314fa07ac1; | ||
|
||
-- TODO: These should use different keypairs | ||
commitmentKeyPair : KeyPair := mkKeyPair pubKey privKey; | ||
import Kudos open; | ||
|
||
originatorKeyPair : KeyPair := commitmentKeyPair; | ||
alice : KeyPair := mkKeyPair@{ | ||
pubKey := 0xddd315c76991f8e058760cacdd19c21bf6a12c72bc229a60ad6aaa314fa07ac1; | ||
privKey := 0xddd315c76991f8e058760cacdd19c21bf6a12c72bc229a60ad6aaa314fa07ac11662fc6e7829efcb0f4500827d49bb699af7b5475cef5220fd600ebbf9709a58; | ||
}; | ||
|
||
owner : Owner := mkOwner pubKey; | ||
bob : PublicKey := 0x7d59c5623dd40a74aa4d5a32ac645d3b3f95daeae4c22be25476dd6a486f7382; | ||
|
||
--- After this transaction is verified there is a resource in the commitment | ||
--- tree that represents 10 Kudos of the originator's kind that are owned by the | ||
--- specified owner. | ||
main : Transaction := | ||
instantiate commitmentKeyPair owner originatorKeyPair 10; | ||
--- Create 10 Kudo tokens as Alice (the originator) for Bob (the owner). | ||
main : Transaction := create@{self := alice; amount := 10; receiver := bob}; |
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 |
---|---|---|
@@ -1,5 +1,38 @@ | ||
module Kudos; | ||
|
||
import Kudos.Types open public; | ||
import Kudos.Logic open public; | ||
import Kudos.Instantiate open public; | ||
import Stdlib.Prelude open; | ||
import Anoma open; | ||
import Token.Transaction open; | ||
import Token.Logic open; | ||
|
||
import Label open; | ||
|
||
--- Creates an amount of Kudo tokens to a receiver. | ||
create | ||
(self : KeyPair) | ||
(amount : Nat) | ||
(receiver : PublicKey) | ||
: Transaction := | ||
let | ||
kudoLabel : Label := mkKudoLabel (KeyPair.pubKey self); | ||
in Token.Transaction.mint self kudoLabel amount receiver; | ||
|
||
--- Sends an amount of Kudo tokens to a receiver. | ||
--- If the token ;Resource; has no Kudos ;Label; this function returns nothing. | ||
--- If the token logic function differs from the current implementation, this function returns nothing, | ||
--- If the calling ;KeyPair; is not the owner, this function returns nothing. | ||
send | ||
(self : KeyPair) | ||
(token : Resource) | ||
(amount : Nat) | ||
(receiver : PublicKey) | ||
: Maybe Transaction := | ||
let | ||
isKudo (r : Resource) : Bool := | ||
getSymbol r == "Kudos" | ||
&& getDecimals r == 18 | ||
&& anomaEncode(Resource.logic r) == anomaEncode(tokenLogic); | ||
in if | ||
| isKudo token := | ||
Token.Transaction.send self token amount receiver | ||
| else := nothing; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,15 @@ | ||
module Label; | ||
|
||
import Anoma open; | ||
|
||
import Token.Label open public; | ||
|
||
mkKudoLabel (originator : PublicKey) : Label := | ||
mkLabel@{ | ||
name := originator; | ||
symbol := "Kudos"; | ||
decimals := 18 | ||
}; | ||
|
||
getOriginator (r : Resource) : PublicKey := | ||
Label.name (anomaDecode (Resource.label r)); |
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
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.