Skip to content

Commit

Permalink
Convert "lock" example to a "swap" example
Browse files Browse the repository at this point in the history
Performs an atomic swap leveraging Zeto, Noto, and Pente together.

Signed-off-by: Andrew Richardson <[email protected]>
  • Loading branch information
awrichar committed Jan 16, 2025
1 parent 17f2016 commit 4c12bcc
Show file tree
Hide file tree
Showing 18 changed files with 502 additions and 150 deletions.
6 changes: 0 additions & 6 deletions example/lock/scripts/abi.mjs

This file was deleted.

139 changes: 0 additions & 139 deletions example/lock/src/index.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
46 changes: 46 additions & 0 deletions example/swap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Example: Atomic Swap

This example demonstrates an atomic swap scenario on Paladin. It performs a swap between:

- a cash token implemented with Zeto
- an asset token implemented with Noto, with private hooks implemented on Pente

## 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
```
File renamed without changes.
98 changes: 95 additions & 3 deletions example/lock/package-lock.json → example/swap/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion example/lock/package.json → example/swap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"typescript": "^5.6.3"
},
"dependencies": {
"@lfdecentralizedtrust-labs/paladin-sdk": "file:../../sdk/typescript"
"@lfdecentralizedtrust-labs/paladin-sdk": "file:../../sdk/typescript",
"ethers": "^6.13.4"
}
}
16 changes: 16 additions & 0 deletions example/swap/scripts/abi.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { copyFile } from "copy-file";

await copyFile(
"../../solidity/artifacts/contracts/private/NotoTrackerERC20.sol/NotoTrackerERC20.json",
"src/abis/NotoTrackerERC20.json"
);

await copyFile(
"../../solidity/artifacts/contracts/shared/Atom.sol/AtomFactory.json",
"src/abis/AtomFactory.json"
);

await copyFile(
"../../solidity/artifacts/contracts/shared/Atom.sol/Atom.json",
"src/abis/Atom.json"
);
Loading

0 comments on commit 4c12bcc

Please sign in to comment.