Skip to content

Commit

Permalink
backend: Use new sapphire-contracts SiweAuth
Browse files Browse the repository at this point in the history
  • Loading branch information
matevz committed Nov 12, 2024
1 parent 4bbab76 commit 34d471c
Show file tree
Hide file tree
Showing 11 changed files with 4,701 additions and 4,137 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
name: Install pnpm
id: pnpm-install
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down
218 changes: 0 additions & 218 deletions backend/contracts/DateTime.sol

This file was deleted.

13 changes: 8 additions & 5 deletions backend/contracts/MessageBox.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./SiweAuth.sol";
import "@oasisprotocol/sapphire-contracts/contracts/auth/SiweAuth.sol";

contract MessageBox is SiweAuth {
string private _message;
address public author;

modifier _authorOnly(bytes calldata bearer) {
if (authMsgSender(bearer) != author) {

modifier isAuthor(bytes calldata bearer) {
// Use msg.sender for transactions and signed calls, fallback to
// checking bearer.
if (msg.sender != author && authMsgSender(bearer) != author) {
revert("not allowed");
}
_;
Expand All @@ -22,7 +25,7 @@ contract MessageBox is SiweAuth {
author = msg.sender;
}

function message(bytes calldata bearer) external view _authorOnly(bearer) returns (string memory) {
return _message;
function message(bytes calldata bearer) external view isAuthor(bearer) returns (string memory) {
return _message;
}
}
Loading

0 comments on commit 34d471c

Please sign in to comment.