Skip to content

Instantly share code, notes, and snippets.

View da-blog's full-sized avatar

da-blog

View GitHub Profile
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
daml 1.2
module FlexibleControllers where
template FeatureAssignment with
employee : Party
sponsor : Party
description : Text
"test": "react-scripts test",
"eject": "react-scripts eject"
},
+ "proxy": "http://localhost:4000",
"dependencies": {
"@auth0/auth0-spa-js": "^1.0.2",
"@fortawesome/fontawesome-svg-core": "^1.2.17",
const TestLedgerApi = () => {
const [apiResult, setApiResult] = useState({});
const { getTokenSilently } = useAuth0();
const callLedgerApi = async () => {
try {
// Get the access token from auth0
const audienceOptions = {
audience: 'https://daml.com/ledger-api'
};
<Auth0Provider
domain={config.domain}
client_id={config.clientId}
redirect_uri={window.location.origin}
onRedirectCallback={onRedirectCallback}
+ audience={config.audience}
>
<App />
</Auth0Provider>,
{
"domain": "dev-uswtyz53.eu.auth0.com",
- "clientId": "<auth0 client id>"
+ "clientId": "<auth0 client id>",
+ "audience": "https://daml.com/ledger-api"
}
function (user, context, callback) {
// Hardcoded constants
var ledgerId = 'daml-auth0-example-ledger';
var applicationId = 'daml-auth0-example';
// Read the DAML party identifier from the app metadata
var actAs = [];
if (user.app_metadata && user.app_metadata.daml_ledger_api) {
actAs = [user.app_metadata.daml_ledger_api.partyIdentifier];
}
function (user, context, callback) {
// Only support users with a verified email address
if (!user.email || !user.email_verified) {
return callback(null, user, context);
}
// Only onboard the user to the ledger once
if (user.app_metadata && user.app_metadata.daml_ledger_api) {
return callback(null, user, context);
do
assetCid <- create Asset with
owner
amount = 5.0
asset1 <- fetch assetCid
let
asset2 = Asset with
owner
amount = 5.0
asset1 === asset2
compareAssetRecords: Party -> Decimal -> Bool
compareAssetRecords owner amount = do
let
asset1 = Asset with ..
let
asset2 = Asset with ..
asset1 == asset2
asset <- fetch assetCid
transferAsset asset newOwner