-
-
Save SuddenlyHazel/0f0ea39d258e1d41955ccbb0c1d277cb to your computer and use it in GitHub Desktop.
Motoko Event Example
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
actor { | |
public type NotifyArgs = { | |
callback : shared (Text) -> async (); | |
transaction_id : Nat; | |
metadata : Text; | |
}; | |
public type TransferError = { | |
#InsufficientBalance; | |
#AmountTooLarge; | |
#CallFailed; | |
#Unknown; | |
}; | |
public type TransferResult = { | |
#Ok : Nat; | |
#Err : TransferError | |
}; | |
public type TransferRequest = { | |
from : ?Principal; | |
to : Principal; | |
amount : Nat; | |
notify : ?NotifyArgs; | |
}; | |
public shared func transfer(transferRequest : TransferRequest) : async TransferResult { | |
// Transfer logic above... | |
switch (transferRequest.notify) { | |
case (?v) { | |
ignore v.callback(v.metadata); | |
}; | |
case (null){}; | |
}; | |
return #Ok(0); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment