Skip to content
Open
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
28 changes: 13 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version: '1.23'

- uses: actions/cache@v3
with:
path: |
Expand Down Expand Up @@ -44,6 +43,19 @@ jobs:
go run .
docker stop ganache

- name: App Channel
working-directory: app-channel
run: |
docker build -t appchannel-devnet .

docker run --rm --name appchannel-devnet \
-d -p 8545:8545 \
appchannel-devnet

sleep 5
go run .
docker stop appchannel-devnet

- name: Payment Channel XLM
working-directory: payment-channel-xlm
run: |
Expand Down Expand Up @@ -82,20 +94,6 @@ jobs:
docker stop ganache
docker stop stellar

- name: App Channel
working-directory: app-channel
env:
KEY_DEPLOYER: "0x79ea8f62d97bc0591a4224c1725fca6b00de5b2cea286fe2e0bb35c5e76be46e"
KEY_ALICE: "0x1af2e950272dd403de7a5760d41c6e44d92b6d02797e51810795ff03cc2cda4f"
KEY_BOB: "0xf63d7d8e930bccd74e93cf5662fde2c28fd8be95edb70c73f1bdd863d07f412e"
BALANCE: "10000000000000000000"
run: |
docker run --rm --name ganache --detach --publish 8545:8545 ${{ env.ganache-image }} --wallet.accounts $KEY_DEPLOYER,$BALANCE $KEY_ALICE,$BALANCE $KEY_BOB,$BALANCE --b=5

sleep 5
go run .
docker stop ganache

- name: Payment Channel ICP
working-directory: payment-channel-icp
run: |
Expand Down
19 changes: 19 additions & 0 deletions app-channel/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:20-alpine

# Create app directory
WORKDIR /hardhat

# Install required dependencies
COPY ../package.json ../yarn.lock ./
RUN yarn install --frozen-lockfile

# Copy Hardhat config and scripts
COPY ../hardhat.config.js ./

# Set up environment
ENV HOST=0.0.0.0
ENV PORT=8545

EXPOSE 8545

ENTRYPOINT ["sh", "-c", "npx hardhat node --hostname 0.0.0.0 --port 8545"]
15 changes: 8 additions & 7 deletions app-channel/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,25 @@ import (

"github.com/pkg/errors"

ethchannel "github.com/perun-network/perun-eth-backend/channel"
ethwallet "github.com/perun-network/perun-eth-backend/wallet"
"perun.network/go-perun/channel"
"perun.network/go-perun/wallet"
)

// TicTacToeApp is a channel app.
type TicTacToeApp struct {
Addr wallet.Address
ID channel.AppID
}

func NewTicTacToeApp(addr wallet.Address) *TicTacToeApp {
func NewTicTacToeApp(addr *ethwallet.Address) *TicTacToeApp {
return &TicTacToeApp{
Addr: addr,
ID: &ethchannel.AppID{addr},
}
}

// Def returns the app address.
func (a *TicTacToeApp) Def() wallet.Address {
return a.Addr
// Def returns the app identifier as definition.
func (a *TicTacToeApp) Def() channel.AppID {
return a.ID
}

func (a *TicTacToeApp) NewData() channel.Data {
Expand Down
28 changes: 15 additions & 13 deletions app-channel/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
ethchannel "github.com/perun-network/perun-eth-backend/channel"
ethwallet "github.com/perun-network/perun-eth-backend/wallet"
swallet "github.com/perun-network/perun-eth-backend/wallet/simple"
ethwire "github.com/perun-network/perun-eth-backend/wire"

"perun.network/go-perun/channel"
"perun.network/go-perun/client"
Expand All @@ -42,9 +41,9 @@ const (

// AppClient is an app channel client.
type AppClient struct {
perunClient *client.Client // The core Perun client.
account wallet.Address // The account we use for on-chain and off-chain transactions.
waddress wire.Address
perunClient *client.Client // The core Perun client.
account map[wallet.BackendID]wallet.Address // The account we use for on-chain and off-chain transactions.
waddress map[wallet.BackendID]wire.Address
currency channel.Asset // The currency we expect to get paid in.
stake channel.Bal // The amount we put at stake.
app *app.TicTacToeApp // The app definition.
Expand All @@ -56,6 +55,7 @@ func SetupAppClient(
bus wire.Bus, // bus is used of off-chain communication.
w *swallet.Wallet, // w is the wallet used for signing transactions.
acc common.Address, // acc is the address of the account to be used for signing transactions.
waddr wire.Address, // waddr is the address of the account to be used for off-chain communication.
eaddress *ethwallet.Address, // eaddress is the address of the Ethereum account to be used for signing transactions.
nodeURL string, // nodeURL is the URL of the blockchain node.
chainID uint64, // chainID is the identifier of the blockchain.
Expand All @@ -82,13 +82,13 @@ func SetupAppClient(

// Setup funder.
funder := ethchannel.NewFunder(cb)
dep := ethchannel.NewETHDepositor()
dep := ethchannel.NewETHDepositor(50000)
ethAcc := accounts.Account{Address: acc}
asset := ethchannel.NewAsset(big.NewInt(int64(chainID)), common.Address(assetaddr))
funder.RegisterAsset(*asset, dep, ethAcc)

// Setup adjudicator.
adj := ethchannel.NewAdjudicator(cb, adjudicator, acc, ethAcc)
adj := ethchannel.NewAdjudicator(cb, adjudicator, acc, ethAcc, 1000000)

// Setup dispute watcher.
watcher, err := local.NewWatcher(adj)
Expand All @@ -97,17 +97,19 @@ func SetupAppClient(
}

// Setup Perun client.
waddr := &ethwire.Address{Address: eaddress}
perunClient, err := client.New(waddr, bus, funder, adj, w, watcher)
wireAddrs := map[wallet.BackendID]wire.Address{ethwallet.BackendID: waddr}
perunClient, err := client.New(wireAddrs, bus, funder, adj, map[wallet.BackendID]wallet.Wallet{ethwallet.BackendID: w}, watcher)
if err != nil {
return nil, errors.WithMessage(err, "creating client")
}

eAddrs := map[wallet.BackendID]wallet.Address{ethwallet.BackendID: eaddress}

// Create client and start request handler.
c := &AppClient{
perunClient: perunClient,
account: eaddress,
waddress: waddr,
account: eAddrs,
waddress: wireAddrs,
currency: asset,
stake: stake,
app: app,
Expand All @@ -121,11 +123,11 @@ func SetupAppClient(
}

// OpenAppChannel opens a new app channel with the specified peer.
func (c *AppClient) OpenAppChannel(peer wire.Address) *TicTacToeChannel {
participants := []wire.Address{c.waddress, peer}
func (c *AppClient) OpenAppChannel(peer map[wallet.BackendID]wire.Address) *TicTacToeChannel {
participants := []map[wallet.BackendID]wire.Address{c.waddress, peer}

// We create an initial allocation which defines the starting balances.
initAlloc := channel.NewAllocation(2, c.currency)
initAlloc := channel.NewAllocation(2, []wallet.BackendID{ethwallet.BackendID}, c.currency)
initAlloc.SetAssetBalances(c.currency, []channel.Bal{
c.stake, // Our initial balance.
c.stake, // Peer's initial balance.
Expand Down
5 changes: 3 additions & 2 deletions app-channel/client/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package client
import (
"math/big"

"perun.network/go-perun/wallet"
"perun.network/go-perun/wire"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -46,11 +47,11 @@ func CreateContractBackend(

// WalletAddress returns the wallet address of the client.
func (c *AppClient) WalletAddress() common.Address {
return common.Address(*c.account.(*ethwallet.Address))
return common.Address(*c.account[ethwallet.BackendID].(*ethwallet.Address))
}

// WireAddress returns the wire address of the client.
func (c *AppClient) WireAddress() wire.Address {
func (c *AppClient) WireAddress() map[wallet.BackendID]wire.Address {
return c.waddress
}

Expand Down
5 changes: 3 additions & 2 deletions app-channel/contracts/TicTacToeApp.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 - See NOTICE file for copyright holders.
// Copyright 2025 - See NOTICE file for copyright holders.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,8 @@

// SPDX-License-Identifier: Apache-2.0

pragma solidity ^0.8.0;
pragma solidity ^0.8.15;
pragma abicoder v2;

import "./perun-eth-contracts/contracts/App.sol";

Expand Down
Loading
Loading