Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BN-623 Completed first version of Java/Scala processors #3

Merged
merged 5 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions daml/Main.daml
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,42 @@ import DA.Optional

initialize : Script [Party]
initialize = do
operator <- allocateParty "Operator"
operatorId <- validateUserId "operator"
alice <- allocateParty "Alice"
aliceId <- validateUserId "alice"
bob <- allocateParty "Bob"
bobId <- validateUserId "bob"
eve <- allocateParty "Eve"
eveId <- validateUserId "eve"
operatorCid <- submit operator do
createCmd Operator with operator = operator, address = ""
orgCid <- submit operator do
exerciseCmd operatorCid Operator_CreateOrganization
with orgName = "Topl"
membershipOfferCid <- submit operator do
exerciseCmd orgCid Organization_InviteMember
with
invitee = alice
membershipAcceptance <- submit alice do
exerciseCmd membershipOfferCid Membershp_Accept
submit operator do
exerciseCmd membershipAcceptance AddUserToOrganization
someOrg <- queryContractKey @Organization operator (operator, "Topl")
membershipOfferCid <- submit operator do
exerciseCmd (fromSome someOrg)._1 Organization_InviteMember
with invitee = bob
membershipAcceptance <- submit bob do
exerciseCmd membershipOfferCid Membershp_Accept
submit operator do
exerciseCmd membershipAcceptance AddUserToOrganization
userInvitationCid <- submit operator do
exerciseCmd operatorCid Operator_InviteUser
with user = alice
aliceUserCid <- submit alice do
exerciseCmd userInvitationCid UserInvitation_Accept
createUser (Daml.Script.User aliceId (Some alice)) [CanActAs alice]
createUser (Daml.Script.User operatorId (Some operator)) [CanActAs operator]
createUser (Daml.Script.User bobId (Some bob)) [CanActAs bob]
createUser (Daml.Script.User eveId (Some eve)) [CanActAs eve]
pure [alice]
-- operator <- allocateParty "operator"
-- operatorId <- validateUserId "operator"
-- alice <- allocateParty "Alice"
-- aliceId <- validateUserId "alice"
-- bob <- allocateParty "Bob"
-- bobId <- validateUserId "bob"
-- eve <- allocateParty "Eve"
-- eveId <- validateUserId "eve"
-- operatorCid <- submit operator do
-- createCmd Operator with operator = operator, address = "AUANVY6RqbJtTnQS1AFTQBjXMFYDknhV8NEixHFLmeZynMxVbp64"
mundacho marked this conversation as resolved.
Show resolved Hide resolved
-- orgCid <- submit operator do
-- exerciseCmd operatorCid Operator_CreateOrganization
-- with orgName = "Topl"
-- membershipOfferCid <- submit operator do
-- exerciseCmd orgCid Organization_InviteMember
-- with
-- invitee = alice
-- membershipAcceptance <- submit alice do
-- exerciseCmd membershipOfferCid Membershp_Accept
-- submit operator do
-- exerciseCmd membershipAcceptance AddUserToOrganization
-- someOrg <- queryContractKey @Organization operator (operator, "Topl")
-- membershipOfferCid <- submit operator do
-- exerciseCmd (fromSome someOrg)._1 Organization_InviteMember
-- with invitee = bob
-- membershipAcceptance <- submit bob do
-- exerciseCmd membershipOfferCid Membershp_Accept
-- submit operator do
-- exerciseCmd membershipAcceptance AddUserToOrganization
-- userInvitationCid <- submit operator do
-- exerciseCmd operatorCid Operator_InviteUser
-- with user = alice
-- aliceUserCid <- submit alice do
-- exerciseCmd userInvitationCid UserInvitation_Accept
-- createUser (Daml.Script.User aliceId (Some alice)) [CanActAs alice]
-- createUser (Daml.Script.User operatorId (Some operator)) [CanActAs operator]
-- createUser (Daml.Script.User bobId (Some bob)) [CanActAs bob]
-- createUser (Daml.Script.User eveId (Some eve)) [CanActAs eve]
pure []
3 changes: 2 additions & 1 deletion daml/Tests/Asset.daml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ module Tests.Asset where
exerciseCmd orgId Organization_CreateAsset with
requestor = alice
version = 1
issuerAddress = org.address
shortName = "Wheat"
return (operator, alice, bob, org)
-- now we create an asset creator
Expand All @@ -40,6 +39,7 @@ module Tests.Asset where
unsignedAssetMintingCid <- submit operator do
exerciseCmd assetMintingRequestCid MintingRequest_Accept with
txToSign = "ZZZZ"
boxNonce = 123
signedAssetMintingCreated <- submit operator do
exerciseCmd unsignedAssetMintingCid UnsignedMinting_Sign with
signedMintTx = "WWWWW"
Expand Down Expand Up @@ -75,6 +75,7 @@ module Tests.Asset where
unsignedAssetTransferCid <- submit operator do
exerciseCmd assetTransferRequestCid AssetTransferRequest_Accept with
txToSign = "ZZZZ"
newBoxNonce = 1234
signedAssetTransferCreated <- submit operator do
exerciseCmd unsignedAssetTransferCid UnsignedAssetTransfer_Sign with
signedTx = "WWWWW"
Expand Down
13 changes: 13 additions & 0 deletions daml/Topl/Asset.daml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module Topl.Asset where

choice MintingRequest_Accept : UnsignedAssetMintingCid with
txToSign : Text
boxNonce : Int
mundacho marked this conversation as resolved.
Show resolved Hide resolved
controller operator
do
create UnsignedAssetMinting with
Expand All @@ -66,6 +67,7 @@ module Topl.Asset where
quantity : Int
someCommitRoot : Optional Text
someMetadata : Optional Text
boxNonce : Int
fee : Int
mintTxToSign : Text
where
Expand Down Expand Up @@ -99,6 +101,7 @@ module Topl.Asset where
quantity : Int
someCommitRoot : Optional Text
someMetadata : Optional Text
boxNonce : Int
fee : Int
mintTxToSign : Text
signedMintTx : Text
Expand All @@ -122,6 +125,11 @@ module Topl.Asset where
controller operator
do
return ()
choice SignedAssetMinting_Fail : SignedAssetMintingCid
with reason : Text
controller operator
do
create this with sendStatus = FailedToSend with ..
choice SignedAssetMinting_Confirm : SignedAssetMintingCid
with
txId : Text
Expand Down Expand Up @@ -150,15 +158,18 @@ module Topl.Asset where
quantity : Int
someCommitRoot : Optional Text
someMetadata : Optional Text
boxNonce : Int
fee : Int
where
signatory operator, requestor
choice AssetTransferRequest_Accept : UnsignedAssetTransferRequestCid with
txToSign : Text
newBoxNonce : Int
controller operator
do
create UnsignedAssetTransferRequest with
txToSign = txToSign
boxNonce = newBoxNonce
..
choice AssetTransferRequest_Reject : ()
controller operator
Expand All @@ -182,6 +193,7 @@ module Topl.Asset where
quantity : Int
someCommitRoot : Optional Text
someMetadata : Optional Text
boxNonce : Int
fee : Int
txToSign : Text
where
Expand Down Expand Up @@ -217,6 +229,7 @@ module Topl.Asset where
quantity : Int
someCommitRoot : Optional Text
someMetadata : Optional Text
boxNonce : Int
mundacho marked this conversation as resolved.
Show resolved Hide resolved
fee : Int
txToSign : Text
signedTx : Text
Expand Down
8 changes: 4 additions & 4 deletions daml/Topl/Organization.daml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ module Topl.Organization where
quantity = signedAssetMinting.quantity
someMetadata = signedAssetMinting.someMetadata
someCommitRoot = signedAssetMinting.someCommitRoot
boxNonce = signedAssetMinting.boxNonce
..

nonconsuming choice Organization_AddSignedAssetTransfer: AssetIouCid with
Expand All @@ -124,6 +125,7 @@ module Topl.Organization where
quantity = signedAssetTransfer.quantity
someMetadata = signedAssetTransfer.someMetadata
someCommitRoot = signedAssetTransfer.someCommitRoot
boxNonce = signedAssetTransfer.boxNonce
..


Expand Down Expand Up @@ -153,7 +155,6 @@ module Topl.Organization where
newOrg Organization_CreateAsset with
requestor = head members
version = assetCode.version
issuerAddress = assetCode.issuerAddress
shortName = assetCode.shortName)))
(create this with wouldBeMembers = [], members = members, assetCodes = [])
assetCodes
Expand All @@ -171,15 +172,13 @@ module Topl.Organization where
with
requestor : Party
version : Int
issuerAddress : Text
shortName : Text
controller requestor
do
assert (requestor `elem` members)
let asset = AssetCode
with
version = version
issuerAddress = issuerAddress
shortName = shortName
create AssetCreator with
operator = operator
Expand Down Expand Up @@ -242,7 +241,8 @@ module Topl.Organization where
quantity : Int
someMetadata : Optional Text
assetCode : AssetCode
someCommitRoot : Optional Text
someCommitRoot : Optional Text
boxNonce : Int
where
signatory operator, organization.members

Expand Down
1 change: 0 additions & 1 deletion daml/Topl/Utils.daml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ data SendStatus = New

data AssetCode = AssetCode with
version : Int
issuerAddress : Text
shortName : Text
deriving (Eq, Show)

42 changes: 38 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>co.topl.daml</groupId>
<artifactId>topl-daml-api</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<version>1.0.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -195,10 +195,10 @@
</build>
</profile>
<profile>
<id>run-alice</id>
<id>run-asset-operator</id>
<activation>
<property>
<name>alice</name>
<name>assetoperator</name>
</property>
</activation>
<build>
Expand All @@ -208,7 +208,7 @@
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<mainClass>co.topl.daml.AliceMain</mainClass>
<mainClass>co.topl.daml.AssetOperatorMain</mainClass>
<arguments>
<argument>${ledgerhost}</argument>
<argument>${ledgerport}</argument>
Expand All @@ -218,6 +218,40 @@
<argument>${keyfilepassword}</argument>
</arguments>
</configuration>
<executions>
<execution>
<id>run-demo-asset-operator</id>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>run-alice</id>
<activation>
<property>
<name>alice</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<mainClass>co.topl.daml.AliceMain</mainClass>
<arguments>
<argument>${ledgerhost}</argument>
<argument>${ledgerport}</argument>
<argument>${keyfilename}</argument>
<argument>${key1filepassword}</argument>
</arguments>
</configuration>
<executions>
<execution>
<id>run-demo-alice</id>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/co/topl/daml/AliceMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import com.daml.ledger.javaapi.data.Transaction;
import com.daml.ledger.rxjava.DamlLedgerClient;
import com.daml.ledger.rxjava.UserManagementClient;
import co.topl.daml.processors.UnsignedTransferProcessor;
import co.topl.daml.polys.processors.UnsignedTransferProcessor;
import akka.actor.ActorSystem;
import co.topl.client.Provider;
import akka.http.javadsl.model.Uri;

import io.reactivex.Flowable;
import co.topl.daml.processors.DamlAppContext;
import co.topl.daml.processors.ToplContext;
import co.topl.daml.DamlAppContext;
import co.topl.daml.ToplContext;

public class AliceMain {

Expand Down
Loading