Skip to content

Commit

Permalink
Add example with more advanced Noto lock/unlock logic
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
  • Loading branch information
awrichar committed Jan 25, 2025
1 parent 8912233 commit c000cc5
Show file tree
Hide file tree
Showing 18 changed files with 1,081 additions and 3 deletions.
3 changes: 3 additions & 0 deletions example/lockcontroller/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
build/
src/abis/*.json
13 changes: 13 additions & 0 deletions example/lockcontroller/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Run",
"runtimeExecutable": "npm",
"args": ["run", "start"],
"request": "launch",
"type": "node",
"outputCapture": "std"
}
]
}
47 changes: 47 additions & 0 deletions example/lockcontroller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Example: Lock Controller

This example demonstrates programmable lock + unlock logic on Noto. Each user that locks some of their
Noto tokens can specify a base ledger contract to handle the lock + unlock. In this example, the base
ledger contract deploys an ERC20 representing the value of the lock. The owner may transfer those
ERC20 tokens as they wish, and the recipients of the ERC20 tokens may then unlock the value to claim
it back as Noto.

## Pre-requisites

Requires a local 3-node Paladin cluster running on `localhost:31548`, `localhost:31648`, and `localhost:31748`.

## Run standalone

Compile [Solidity contracts](../../solidity):

```shell
cd ../../solidity
npm install
npm run compile
```

Build [TypeScript SDK](../../sdk/typescript):

```shell
cd ../../sdk/typescript
npm install
npm run abi
npm run build
```

Run example:

```shell
npm install
npm run abi
npm run start
```

## Run with Gradle

The following will perform all pre-requisites and then run the example:

```shell
../../gradlew build
npm run start
```
73 changes: 73 additions & 0 deletions example/lockcontroller/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright © 2024 Kaleido, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

configurations {
// Resolvable configurations
contractCompile {
canBeConsumed = false
canBeResolved = true
}
buildSDK {
canBeConsumed = false
canBeResolved = true
}
}

dependencies {
contractCompile project(path: ':solidity', configuration: 'compiledContracts')
buildSDK project(path: ':sdk:typescript', configuration: 'buildSDK')
}

task install(type: Exec) {
executable 'npm'
args 'install'

inputs.files(configurations.buildSDK)
inputs.files('package.json')
outputs.files('package-lock.json')
outputs.dir('node_modules')
}

task copyABI(type: Exec, dependsOn: install) {
executable 'npm'
args 'run'
args 'abi'

inputs.files(configurations.contractCompile)
inputs.dir('scripts')
outputs.dir('src/abis')
}

task build(type: Exec, dependsOn: [install, copyABI]) {
executable 'npm'
args 'run'
args 'build'

inputs.dir('src')
outputs.dir('build')
}

task e2e(type: Exec, dependsOn: [build]) {
dependsOn ':operator:deploy'

executable 'npm'
args 'run'
args 'start'
}

task clean(type: Delete) {
delete 'node_modules'
delete 'build'
}
Loading

0 comments on commit c000cc5

Please sign in to comment.