From 8527635a4062dd90dbf734d909442774ff180e54 Mon Sep 17 00:00:00 2001 From: imajindev Date: Sun, 11 Aug 2024 17:21:45 +0800 Subject: [PATCH 1/3] use offline attestation and use resolver for validation --- apps/contract/scripts/deploy-ticket-redeem.js | 3 +- apps/contract/src/PuchaseTicket.sol | 40 -- apps/contract/src/RedeemResolver.sol | 83 ++- apps/haus/public/RedeemResolver.json | 587 ++++++++++++++++++ apps/haus/src/config/events.ts | 48 +- 5 files changed, 686 insertions(+), 75 deletions(-) delete mode 100644 apps/contract/src/PuchaseTicket.sol create mode 100644 apps/haus/public/RedeemResolver.json diff --git a/apps/contract/scripts/deploy-ticket-redeem.js b/apps/contract/scripts/deploy-ticket-redeem.js index ca8a979..d6448d3 100644 --- a/apps/contract/scripts/deploy-ticket-redeem.js +++ b/apps/contract/scripts/deploy-ticket-redeem.js @@ -18,8 +18,7 @@ async function main() { // if (deployerBalance === '0') return // deployment will fail const RedeemResolver = await ethers.getContractFactory('RedeemResolver') - const redeemResolver = await RedeemResolver.deploy('0x4200000000000000000000000000000000000021') - await redeemResolver.deployed() + const redeemResolver = await RedeemResolver.deploy('0x4200000000000000000000000000000000000021', '0xcDbFCE45c57b31Dc8B196aB58F74E2b8e478fc7e') console.log('RedeemResolver deployed to:', redeemResolver.address) console.log('RedeemResolver details:', redeemResolver) diff --git a/apps/contract/src/PuchaseTicket.sol b/apps/contract/src/PuchaseTicket.sol deleted file mode 100644 index a19b089..0000000 --- a/apps/contract/src/PuchaseTicket.sol +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -contract PurchaseTicket { - error AlreadyPurchased(); - error AlreadyIssued(); - - address private paymentAddress; - - mapping(string => mapping(string => uint256)) private prices; - mapping(string => mapping(string => bool)) private proofs; - mapping(string => mapping(string => bool)) private tickets; - - constructor(address _paymentAddress) { - paymentAddress = _paymentAddress; - } - - function purchase( - string memory eventId, - string memory uniqueEventId, - string memory seat, - string memory ticketType, - string memory worldProof - ) external payable { - bool purchased = proofs[uniqueEventId][worldProof]; - if (purchased == true) { - revert AlreadyPurchased(); - } - - bool issued = tickets[uniqueEventId][seat]; - if (issued == true) { - revert AlreadyIssued(); - } - - uint256 price = prices[eventId][ticketType]; - proofs[uniqueEventId][worldProof] = true; - tickets[uniqueEventId][seat] = true; - payable(paymentAddress).transfer(price); - } -} diff --git a/apps/contract/src/RedeemResolver.sol b/apps/contract/src/RedeemResolver.sol index c55769e..8718dd1 100644 --- a/apps/contract/src/RedeemResolver.sol +++ b/apps/contract/src/RedeemResolver.sol @@ -5,25 +5,90 @@ pragma solidity 0.8.20; import { SchemaResolver } from "@ethereum-attestation-service/eas-contracts/contracts/resolver/SchemaResolver.sol"; import { IEAS, Attestation } from "@ethereum-attestation-service/eas-contracts/contracts/IEAS.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; +import { Address } from "@openzeppelin/contracts/utils/Address.sol"; + +contract RedeemResolver is SchemaResolver, Ownable { + using Address for address payable; -contract RedeemResolver is SchemaResolver { error OutOfBounds(); + error AlreadyPurchased(); + error AlreadyIssued(); + error Duplicate(); + error Insufficient(); + + address private paymentAddress; mapping(bytes32 => bool) private redeemedMap; + mapping(string => mapping(string => uint256)) private prices; + mapping(string => mapping(string => bool)) private proofs; + mapping(string => mapping(string => bool)) private ticketSeats; + mapping(address => mapping(string => bool)) private ticketRecipients; + mapping(address => string[]) private ticketRecipientsArr; - constructor(IEAS eas) SchemaResolver(eas) { + constructor(IEAS eas, address _paymentAddress) SchemaResolver(eas) Ownable(msg.sender) { + paymentAddress = _paymentAddress; } - function onAttest(Attestation calldata attestation, uint256 /*value*/) internal override returns (bool) { - bytes32 uid = _toBytes32(attestation.data, 0); + function isPayable() public pure override returns (bool) { + return true; + } + + function setPrice(string memory eventId, string memory ticketType, uint256 price) external onlyOwner { + prices[eventId][ticketType] = price; + } + + function getPrice(string memory eventId, string memory ticketType) public view returns (uint256) { + return prices[eventId][ticketType]; + } - bool redeemed = redeemedMap[uid]; - if (redeemed == true) { - return false; + function getTickets() public view returns (string[] memory) { + return ticketRecipientsArr[msg.sender]; + } + + function purchase( + string memory eventId, + string memory seat, + string memory ticketType, + string memory worldProof, + string memory attestationId + ) external payable { + bool purchased = proofs[eventId][worldProof]; + if (purchased == true) { + revert AlreadyPurchased(); } - redeemedMap[uid] = true; - return true; + bool issued = ticketSeats[eventId][seat]; + if (issued == true) { + revert AlreadyIssued(); + } + + bool recipient = ticketRecipients[msg.sender][attestationId]; + if (recipient == true) { + revert Duplicate(); + } + + uint256 price = prices[eventId][ticketType]; + if (msg.value < price) { + revert Insufficient(); + } + + proofs[eventId][worldProof] = true; + ticketSeats[eventId][seat] = true; + ticketRecipients[msg.sender][attestationId] = true; + ticketRecipientsArr[msg.sender].push(attestationId); + payable(paymentAddress).transfer(msg.value); + } + + function onAttest(Attestation calldata attestation, uint256 /*value*/) internal view override returns (bool) { + bytes32 uid = _toBytes32(attestation.data, 0); + string memory uidStr = string(abi.encodePacked(uid)); + bool exist = ticketRecipients[attestation.recipient][uidStr]; + if (exist == true) { + return true; + } + + return false; } function onRevoke(Attestation calldata /*attestation*/, uint256 /*value*/) internal pure override returns (bool) { diff --git a/apps/haus/public/RedeemResolver.json b/apps/haus/public/RedeemResolver.json new file mode 100644 index 0000000..82d2dd2 --- /dev/null +++ b/apps/haus/public/RedeemResolver.json @@ -0,0 +1,587 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "RedeemResolver", + "sourceName": "src/RedeemResolver.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IEAS", + "name": "eas", + "type": "address" + }, + { + "internalType": "address", + "name": "_paymentAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AccessDenied", + "type": "error" + }, + { + "inputs": [], + "name": "AlreadyIssued", + "type": "error" + }, + { + "inputs": [], + "name": "AlreadyPurchased", + "type": "error" + }, + { + "inputs": [], + "name": "Duplicate", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientValue", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidEAS", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "NotPayable", + "type": "error" + }, + { + "inputs": [], + "name": "OutOfBounds", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "uid", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "schema", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "time", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "expirationTime", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "revocationTime", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "refUID", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "address", + "name": "attester", + "type": "address" + }, + { + "internalType": "bool", + "name": "revocable", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Attestation", + "name": "attestation", + "type": "tuple" + } + ], + "name": "attest", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "eventId", + "type": "string" + }, + { + "internalType": "string", + "name": "ticketType", + "type": "string" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTickets", + "outputs": [ + { + "internalType": "string[]", + "name": "", + "type": "string[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isPayable", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "uid", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "schema", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "time", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "expirationTime", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "revocationTime", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "refUID", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "address", + "name": "attester", + "type": "address" + }, + { + "internalType": "bool", + "name": "revocable", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Attestation[]", + "name": "attestations", + "type": "tuple[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "name": "multiAttest", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "uid", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "schema", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "time", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "expirationTime", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "revocationTime", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "refUID", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "address", + "name": "attester", + "type": "address" + }, + { + "internalType": "bool", + "name": "revocable", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Attestation[]", + "name": "attestations", + "type": "tuple[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "name": "multiRevoke", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "eventId", + "type": "string" + }, + { + "internalType": "string", + "name": "seat", + "type": "string" + }, + { + "internalType": "string", + "name": "ticketType", + "type": "string" + }, + { + "internalType": "string", + "name": "worldProof", + "type": "string" + }, + { + "internalType": "string", + "name": "attestationId", + "type": "string" + } + ], + "name": "purchase", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "uid", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "schema", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "time", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "expirationTime", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "revocationTime", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "refUID", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "address", + "name": "attester", + "type": "address" + }, + { + "internalType": "bool", + "name": "revocable", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Attestation", + "name": "attestation", + "type": "tuple" + } + ], + "name": "revoke", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "eventId", + "type": "string" + }, + { + "internalType": "string", + "name": "ticketType", + "type": "string" + }, + { + "internalType": "uint256", + "name": "price", + "type": "uint256" + } + ], + "name": "setPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "start", + "type": "uint256" + } + ], + "name": "toBytes32", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "bytecode": "0x6101006040523480156200001257600080fd5b50604051620015733803806200157383398101604081905262000035916200013f565b6001608052600360a052600060c05233826001600160a01b0381166200006e576040516341bc07ff60e11b815260040160405180910390fd5b6001600160a01b0390811660e0528116620000a357604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b620000ae81620000d6565b50600180546001600160a01b0319166001600160a01b0392909216919091179055506200017e565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146200013c57600080fd5b50565b600080604083850312156200015357600080fd5b8251620001608162000126565b6020840151909250620001738162000126565b809150509250929050565b60805160a05160c05160e0516113bb620001b86000396000610a91015260006106c50152600061069c0152600061067301526113bb6000f3fe6080604052600436106100e15760003560e01c806391db0b7e1161007f578063ce46e04611610059578063ce46e04614610243578063e49617e114610257578063e60c35051461026a578063f2fde38b1461027d57600080fd5b806391db0b7e146101f057806399dd9bd714610203578063b11128851461022357600080fd5b806354fd4d50116100bb57806354fd4d501461016e578063715018a61461019057806388e5b2d9146101a55780638da5cb5b146101c857600080fd5b806313c191b0146101065780633d0f34da146101195780634ed026221461014c57600080fd5b3661010157604051631574f9f360e01b815260040160405180910390fd5b005b600080fd5b6100ff610114366004610d74565b61029d565b34801561012557600080fd5b50610139610134366004610e46565b610542565b6040519081526020015b60405180910390f35b34801561015857600080fd5b50610161610588565b6040516101439190610efa565b34801561017a57600080fd5b5061018361066c565b6040516101439190610f5c565b34801561019c57600080fd5b506100ff61070f565b6101b86101b3366004610fbb565b610723565b6040519015158152602001610143565b3480156101d457600080fd5b506000546040516001600160a01b039091168152602001610143565b6101b86101fe366004610fbb565b6107f2565b34801561020f57600080fd5b5061013961021e366004611027565b6108b1565b34801561022f57600080fd5b506100ff61023e366004611080565b6108c4565b34801561024f57600080fd5b5060006101b8565b6101b86102653660046110ed565b61090e565b6101b86102783660046110ed565b61091f565b34801561028957600080fd5b506100ff610298366004611129565b610933565b60006004866040516102af9190611152565b9081526020016040518091039020836040516102cb9190611152565b9081526040519081900360200190205460ff16905080151560010361030357604051630cd9ed5560e21b815260040160405180910390fd5b60006005876040516103159190611152565b9081526020016040518091039020866040516103319190611152565b9081526040519081900360200190205460ff1690508015156001036103695760405163031a394360e61b815260040160405180910390fd5b336000908152600660205260408082209051610386908690611152565b9081526040519081900360200190205460ff1690508015156001036103be576040516306ca7a9d60e21b815260040160405180910390fd5b60006003896040516103d09190611152565b9081526020016040518091039020876040516103ec9190611152565b9081526020016040518091039020549050600160048a60405161040f9190611152565b90815260200160405180910390208760405161042b9190611152565b908152604051908190036020018120805492151560ff199093169290921790915560019060059061045d908c90611152565b9081526020016040518091039020896040516104799190611152565b9081526040805160209281900383018120805460ff191694151594909417909355336000908152600690925290206001916104b5908890611152565b9081526040805160209281900383019020805460ff1916931515939093179092553360009081526007825291822080546001810182559083529120016104fb86826111f7565b506001546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610536573d6000803e3d6000fd5b50505050505050505050565b60006003836040516105549190611152565b9081526020016040518091039020826040516105709190611152565b90815260200160405180910390205490505b92915050565b336000908152600760209081526040808320805482518185028101850190935280835260609492939192909184015b828210156106635783829060005260206000200180546105d69061116e565b80601f01602080910402602001604051908101604052809291908181526020018280546106029061116e565b801561064f5780601f106106245761010080835404028352916020019161064f565b820191906000526020600020905b81548152906001019060200180831161063257829003601f168201915b5050505050815260200190600101906105b7565b50505050905090565b60606106977f0000000000000000000000000000000000000000000000000000000000000000610976565b6106c07f0000000000000000000000000000000000000000000000000000000000000000610976565b6106e97f0000000000000000000000000000000000000000000000000000000000000000610976565b6040516020016106fb939291906112b7565b604051602081830303815290604052905090565b610717610a09565b6107216000610a36565b565b600061072d610a86565b8382811461074e5760405163251f56a160e21b815260040160405180910390fd5b3460005b828110156107e257600086868381811061076e5761076e611311565b905060200201359050828111156107985760405163044044a560e21b815260040160405180910390fd5b6107c58989848181106107ad576107ad611311565b90506020028101906107bf9190611327565b50600190565b6107d65760009450505050506107ea565b90910390600101610752565b506001925050505b949350505050565b60006107fc610a86565b8382811461081d5760405163251f56a160e21b815260040160405180910390fd5b3460005b828110156107e257600086868381811061083d5761083d611311565b905060200201359050828111156108675760405163044044a560e21b815260040160405180910390fd5b61089489898481811061087c5761087c611311565b905060200281019061088e9190611327565b82610acf565b6108a55760009450505050506107ea565b90910390600101610821565b60006108bd8383610bc0565b9392505050565b6108cc610a09565b806003846040516108dd9190611152565b9081526020016040518091039020836040516108f99190611152565b90815260405190819003602001902055505050565b6000610918610a86565b6001610582565b6000610929610a86565b6105828234610acf565b61093b610a09565b6001600160a01b03811661096a57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61097381610a36565b50565b6060600061098383610bf0565b600101905060008167ffffffffffffffff8111156109a3576109a3610cc8565b6040519080825280601f01601f1916602001820160405280156109cd576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846109d757509392505050565b6000546001600160a01b031633146107215760405163118cdaa760e01b8152336004820152602401610961565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461072157604051634ca8886760e01b815260040160405180910390fd5b600080610b1d610ae361012086018661133e565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509250610bc0915050565b9050600081604051602001610b3491815260200190565b60408051601f1981840301815291905290506000600681610b5b60e0890160c08a01611129565b6001600160a01b03166001600160a01b0316815260200190815260200160002082604051610b899190611152565b9081526040519081900360200190205460ff169050801515600103610bb45760019350505050610582565b50600095945050505050565b60008160200183511015610be757604051632d0483c560e21b815260040160405180910390fd5b50016020015190565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310610c2f5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310610c5b576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310610c7957662386f26fc10000830492506010015b6305f5e1008310610c91576305f5e100830492506008015b6127108310610ca557612710830492506004015b60648310610cb7576064830492506002015b600a83106105825760010192915050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115610cf957610cf9610cc8565b604051601f8501601f19908116603f01168101908282118183101715610d2157610d21610cc8565b81604052809350858152868686011115610d3a57600080fd5b858560208301376000602087830101525050509392505050565b600082601f830112610d6557600080fd5b6108bd83833560208501610cde565b600080600080600060a08688031215610d8c57600080fd5b853567ffffffffffffffff80821115610da457600080fd5b610db089838a01610d54565b96506020880135915080821115610dc657600080fd5b610dd289838a01610d54565b95506040880135915080821115610de857600080fd5b610df489838a01610d54565b94506060880135915080821115610e0a57600080fd5b610e1689838a01610d54565b93506080880135915080821115610e2c57600080fd5b50610e3988828901610d54565b9150509295509295909350565b60008060408385031215610e5957600080fd5b823567ffffffffffffffff80821115610e7157600080fd5b610e7d86838701610d54565b93506020850135915080821115610e9357600080fd5b50610ea085828601610d54565b9150509250929050565b60005b83811015610ec5578181015183820152602001610ead565b50506000910152565b60008151808452610ee6816020860160208601610eaa565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015610f4f57603f19888603018452610f3d858351610ece565b94509285019290850190600101610f21565b5092979650505050505050565b6020815260006108bd6020830184610ece565b60008083601f840112610f8157600080fd5b50813567ffffffffffffffff811115610f9957600080fd5b6020830191508360208260051b8501011115610fb457600080fd5b9250929050565b60008060008060408587031215610fd157600080fd5b843567ffffffffffffffff80821115610fe957600080fd5b610ff588838901610f6f565b9096509450602087013591508082111561100e57600080fd5b5061101b87828801610f6f565b95989497509550505050565b6000806040838503121561103a57600080fd5b823567ffffffffffffffff81111561105157600080fd5b8301601f8101851361106257600080fd5b61107185823560208401610cde565b95602094909401359450505050565b60008060006060848603121561109557600080fd5b833567ffffffffffffffff808211156110ad57600080fd5b6110b987838801610d54565b945060208601359150808211156110cf57600080fd5b506110dc86828701610d54565b925050604084013590509250925092565b6000602082840312156110ff57600080fd5b813567ffffffffffffffff81111561111657600080fd5b820161014081850312156108bd57600080fd5b60006020828403121561113b57600080fd5b81356001600160a01b03811681146108bd57600080fd5b60008251611164818460208701610eaa565b9190910192915050565b600181811c9082168061118257607f821691505b6020821081036111a257634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156111f257600081815260208120601f850160051c810160208610156111cf5750805b601f850160051c820191505b818110156111ee578281556001016111db565b5050505b505050565b815167ffffffffffffffff81111561121157611211610cc8565b6112258161121f845461116e565b846111a8565b602080601f83116001811461125a57600084156112425750858301515b600019600386901b1c1916600185901b1785556111ee565b600085815260208120601f198616915b828110156112895788860151825594840194600190910190840161126a565b50858210156112a75787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600084516112c9818460208901610eaa565b8083019050601760f91b80825285516112e9816001850160208a01610eaa565b60019201918201528351611304816002840160208801610eaa565b0160020195945050505050565b634e487b7160e01b600052603260045260246000fd5b6000823561013e1983360301811261116457600080fd5b6000808335601e1984360301811261135557600080fd5b83018035915067ffffffffffffffff82111561137057600080fd5b602001915036819003821315610fb457600080fdfea26469706673582212207df81908b70bc1f92222fe21ea96f59a89f4ce154614c4d5832d233518b7b5f364736f6c63430008140033", + "deployedBytecode": "0x6080604052600436106100e15760003560e01c806391db0b7e1161007f578063ce46e04611610059578063ce46e04614610243578063e49617e114610257578063e60c35051461026a578063f2fde38b1461027d57600080fd5b806391db0b7e146101f057806399dd9bd714610203578063b11128851461022357600080fd5b806354fd4d50116100bb57806354fd4d501461016e578063715018a61461019057806388e5b2d9146101a55780638da5cb5b146101c857600080fd5b806313c191b0146101065780633d0f34da146101195780634ed026221461014c57600080fd5b3661010157604051631574f9f360e01b815260040160405180910390fd5b005b600080fd5b6100ff610114366004610d74565b61029d565b34801561012557600080fd5b50610139610134366004610e46565b610542565b6040519081526020015b60405180910390f35b34801561015857600080fd5b50610161610588565b6040516101439190610efa565b34801561017a57600080fd5b5061018361066c565b6040516101439190610f5c565b34801561019c57600080fd5b506100ff61070f565b6101b86101b3366004610fbb565b610723565b6040519015158152602001610143565b3480156101d457600080fd5b506000546040516001600160a01b039091168152602001610143565b6101b86101fe366004610fbb565b6107f2565b34801561020f57600080fd5b5061013961021e366004611027565b6108b1565b34801561022f57600080fd5b506100ff61023e366004611080565b6108c4565b34801561024f57600080fd5b5060006101b8565b6101b86102653660046110ed565b61090e565b6101b86102783660046110ed565b61091f565b34801561028957600080fd5b506100ff610298366004611129565b610933565b60006004866040516102af9190611152565b9081526020016040518091039020836040516102cb9190611152565b9081526040519081900360200190205460ff16905080151560010361030357604051630cd9ed5560e21b815260040160405180910390fd5b60006005876040516103159190611152565b9081526020016040518091039020866040516103319190611152565b9081526040519081900360200190205460ff1690508015156001036103695760405163031a394360e61b815260040160405180910390fd5b336000908152600660205260408082209051610386908690611152565b9081526040519081900360200190205460ff1690508015156001036103be576040516306ca7a9d60e21b815260040160405180910390fd5b60006003896040516103d09190611152565b9081526020016040518091039020876040516103ec9190611152565b9081526020016040518091039020549050600160048a60405161040f9190611152565b90815260200160405180910390208760405161042b9190611152565b908152604051908190036020018120805492151560ff199093169290921790915560019060059061045d908c90611152565b9081526020016040518091039020896040516104799190611152565b9081526040805160209281900383018120805460ff191694151594909417909355336000908152600690925290206001916104b5908890611152565b9081526040805160209281900383019020805460ff1916931515939093179092553360009081526007825291822080546001810182559083529120016104fb86826111f7565b506001546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610536573d6000803e3d6000fd5b50505050505050505050565b60006003836040516105549190611152565b9081526020016040518091039020826040516105709190611152565b90815260200160405180910390205490505b92915050565b336000908152600760209081526040808320805482518185028101850190935280835260609492939192909184015b828210156106635783829060005260206000200180546105d69061116e565b80601f01602080910402602001604051908101604052809291908181526020018280546106029061116e565b801561064f5780601f106106245761010080835404028352916020019161064f565b820191906000526020600020905b81548152906001019060200180831161063257829003601f168201915b5050505050815260200190600101906105b7565b50505050905090565b60606106977f0000000000000000000000000000000000000000000000000000000000000000610976565b6106c07f0000000000000000000000000000000000000000000000000000000000000000610976565b6106e97f0000000000000000000000000000000000000000000000000000000000000000610976565b6040516020016106fb939291906112b7565b604051602081830303815290604052905090565b610717610a09565b6107216000610a36565b565b600061072d610a86565b8382811461074e5760405163251f56a160e21b815260040160405180910390fd5b3460005b828110156107e257600086868381811061076e5761076e611311565b905060200201359050828111156107985760405163044044a560e21b815260040160405180910390fd5b6107c58989848181106107ad576107ad611311565b90506020028101906107bf9190611327565b50600190565b6107d65760009450505050506107ea565b90910390600101610752565b506001925050505b949350505050565b60006107fc610a86565b8382811461081d5760405163251f56a160e21b815260040160405180910390fd5b3460005b828110156107e257600086868381811061083d5761083d611311565b905060200201359050828111156108675760405163044044a560e21b815260040160405180910390fd5b61089489898481811061087c5761087c611311565b905060200281019061088e9190611327565b82610acf565b6108a55760009450505050506107ea565b90910390600101610821565b60006108bd8383610bc0565b9392505050565b6108cc610a09565b806003846040516108dd9190611152565b9081526020016040518091039020836040516108f99190611152565b90815260405190819003602001902055505050565b6000610918610a86565b6001610582565b6000610929610a86565b6105828234610acf565b61093b610a09565b6001600160a01b03811661096a57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61097381610a36565b50565b6060600061098383610bf0565b600101905060008167ffffffffffffffff8111156109a3576109a3610cc8565b6040519080825280601f01601f1916602001820160405280156109cd576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846109d757509392505050565b6000546001600160a01b031633146107215760405163118cdaa760e01b8152336004820152602401610961565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461072157604051634ca8886760e01b815260040160405180910390fd5b600080610b1d610ae361012086018661133e565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509250610bc0915050565b9050600081604051602001610b3491815260200190565b60408051601f1981840301815291905290506000600681610b5b60e0890160c08a01611129565b6001600160a01b03166001600160a01b0316815260200190815260200160002082604051610b899190611152565b9081526040519081900360200190205460ff169050801515600103610bb45760019350505050610582565b50600095945050505050565b60008160200183511015610be757604051632d0483c560e21b815260040160405180910390fd5b50016020015190565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310610c2f5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310610c5b576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310610c7957662386f26fc10000830492506010015b6305f5e1008310610c91576305f5e100830492506008015b6127108310610ca557612710830492506004015b60648310610cb7576064830492506002015b600a83106105825760010192915050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115610cf957610cf9610cc8565b604051601f8501601f19908116603f01168101908282118183101715610d2157610d21610cc8565b81604052809350858152868686011115610d3a57600080fd5b858560208301376000602087830101525050509392505050565b600082601f830112610d6557600080fd5b6108bd83833560208501610cde565b600080600080600060a08688031215610d8c57600080fd5b853567ffffffffffffffff80821115610da457600080fd5b610db089838a01610d54565b96506020880135915080821115610dc657600080fd5b610dd289838a01610d54565b95506040880135915080821115610de857600080fd5b610df489838a01610d54565b94506060880135915080821115610e0a57600080fd5b610e1689838a01610d54565b93506080880135915080821115610e2c57600080fd5b50610e3988828901610d54565b9150509295509295909350565b60008060408385031215610e5957600080fd5b823567ffffffffffffffff80821115610e7157600080fd5b610e7d86838701610d54565b93506020850135915080821115610e9357600080fd5b50610ea085828601610d54565b9150509250929050565b60005b83811015610ec5578181015183820152602001610ead565b50506000910152565b60008151808452610ee6816020860160208601610eaa565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015610f4f57603f19888603018452610f3d858351610ece565b94509285019290850190600101610f21565b5092979650505050505050565b6020815260006108bd6020830184610ece565b60008083601f840112610f8157600080fd5b50813567ffffffffffffffff811115610f9957600080fd5b6020830191508360208260051b8501011115610fb457600080fd5b9250929050565b60008060008060408587031215610fd157600080fd5b843567ffffffffffffffff80821115610fe957600080fd5b610ff588838901610f6f565b9096509450602087013591508082111561100e57600080fd5b5061101b87828801610f6f565b95989497509550505050565b6000806040838503121561103a57600080fd5b823567ffffffffffffffff81111561105157600080fd5b8301601f8101851361106257600080fd5b61107185823560208401610cde565b95602094909401359450505050565b60008060006060848603121561109557600080fd5b833567ffffffffffffffff808211156110ad57600080fd5b6110b987838801610d54565b945060208601359150808211156110cf57600080fd5b506110dc86828701610d54565b925050604084013590509250925092565b6000602082840312156110ff57600080fd5b813567ffffffffffffffff81111561111657600080fd5b820161014081850312156108bd57600080fd5b60006020828403121561113b57600080fd5b81356001600160a01b03811681146108bd57600080fd5b60008251611164818460208701610eaa565b9190910192915050565b600181811c9082168061118257607f821691505b6020821081036111a257634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156111f257600081815260208120601f850160051c810160208610156111cf5750805b601f850160051c820191505b818110156111ee578281556001016111db565b5050505b505050565b815167ffffffffffffffff81111561121157611211610cc8565b6112258161121f845461116e565b846111a8565b602080601f83116001811461125a57600084156112425750858301515b600019600386901b1c1916600185901b1785556111ee565b600085815260208120601f198616915b828110156112895788860151825594840194600190910190840161126a565b50858210156112a75787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600084516112c9818460208901610eaa565b8083019050601760f91b80825285516112e9816001850160208a01610eaa565b60019201918201528351611304816002840160208801610eaa565b0160020195945050505050565b634e487b7160e01b600052603260045260246000fd5b6000823561013e1983360301811261116457600080fd5b6000808335601e1984360301811261135557600080fd5b83018035915067ffffffffffffffff82111561137057600080fd5b602001915036819003821315610fb457600080fdfea26469706673582212207df81908b70bc1f92222fe21ea96f59a89f4ce154614c4d5832d233518b7b5f364736f6c63430008140033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/apps/haus/src/config/events.ts b/apps/haus/src/config/events.ts index 0645893..78f36f2 100644 --- a/apps/haus/src/config/events.ts +++ b/apps/haus/src/config/events.ts @@ -10,17 +10,17 @@ export const EVENTS = [ tickets: [ { type: 'VVIP', - price: 0.08, + price: 0.0008, available_tickets: 10, }, { type: 'VIP', - price: 0.06, + price: 0.0006, available_tickets: 50, }, { type: 'General', - price: 0.05, + price: 0.0005, available_tickets: 40, }, ], @@ -37,17 +37,17 @@ export const EVENTS = [ tickets: [ { type: 'VVIP', - price: 0.03, + price: 0.0003, available_tickets: 10, }, { type: 'VIP', - price: 0.02, + price: 0.0002, available_tickets: 50, }, { type: 'General', - price: 0.01, + price: 0.0001, available_tickets: 40, }, ], @@ -64,17 +64,17 @@ export const EVENTS = [ tickets: [ { type: 'VVIP', - price: 0.04, + price: 0.0004, available_tickets: 10, }, { type: 'VIP', - price: 0.03, + price: 0.0003, available_tickets: 50, }, { type: 'General', - price: 0.02, + price: 0.0002, available_tickets: 40, }, ], @@ -91,17 +91,17 @@ export const EVENTS = [ tickets: [ { type: 'VVIP', - price: 0.09, + price: 0.0009, available_tickets: 10, }, { type: 'VIP', - price: 0.08, + price: 0.0008, available_tickets: 50, }, { type: 'General', - price: 0.07, + price: 0.0007, available_tickets: 40, }, ], @@ -118,17 +118,17 @@ export const EVENTS = [ tickets: [ { type: 'VVIP', - price: 0.03, + price: 0.0003, available_tickets: 10, }, { type: 'VIP', - price: 0.02, + price: 0.0002, available_tickets: 50, }, { type: 'General', - price: 0.01, + price: 0.0001, available_tickets: 40, }, ], @@ -145,17 +145,17 @@ export const EVENTS = [ tickets: [ { type: 'VVIP', - price: 0.05, + price: 0.0005, available_tickets: 10, }, { type: 'VIP', - price: 0.04, + price: 0.0004, available_tickets: 50, }, { type: 'General', - price: 0.03, + price: 0.0003, available_tickets: 40, }, ], @@ -172,17 +172,17 @@ export const EVENTS = [ tickets: [ { type: 'VVIP', - price: 0.07, + price: 0.0007, available_tickets: 10, }, { type: 'VIP', - price: 0.06, + price: 0.0006, available_tickets: 50, }, { type: 'General', - price: 0.05, + price: 0.0005, available_tickets: 40, }, ], @@ -200,17 +200,17 @@ export const EVENTS = [ tickets: [ { type: 'VVIP', - price: 0.03, + price: 0.0003, available_tickets: 10, }, { type: 'VIP', - price: 0.02, + price: 0.0002, available_tickets: 50, }, { type: 'General', - price: 0.01, + price: 0.0001, available_tickets: 40, }, ], From 80954b84da5c453d39ffea8a5e01bdbe175cee93 Mon Sep 17 00:00:00 2001 From: imajindev Date: Sun, 11 Aug 2024 20:29:51 +0800 Subject: [PATCH 2/3] update to offline attestation logic flow --- apps/haus/public/RedeemResolver.json | 587 ------------------ apps/haus/src/abi/redeem-resolver.ts | 228 +++++++ .../src/components/confirm-ticket/index.tsx | 155 +++-- apps/haus/src/components/provider/wagmi.ts | 2 +- apps/haus/src/utils/ethers.ts | 27 + tsconfig.base.json | 2 +- 6 files changed, 375 insertions(+), 626 deletions(-) delete mode 100644 apps/haus/public/RedeemResolver.json create mode 100644 apps/haus/src/abi/redeem-resolver.ts create mode 100644 apps/haus/src/utils/ethers.ts diff --git a/apps/haus/public/RedeemResolver.json b/apps/haus/public/RedeemResolver.json deleted file mode 100644 index 82d2dd2..0000000 --- a/apps/haus/public/RedeemResolver.json +++ /dev/null @@ -1,587 +0,0 @@ -{ - "_format": "hh-sol-artifact-1", - "contractName": "RedeemResolver", - "sourceName": "src/RedeemResolver.sol", - "abi": [ - { - "inputs": [ - { - "internalType": "contract IEAS", - "name": "eas", - "type": "address" - }, - { - "internalType": "address", - "name": "_paymentAddress", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "AccessDenied", - "type": "error" - }, - { - "inputs": [], - "name": "AlreadyIssued", - "type": "error" - }, - { - "inputs": [], - "name": "AlreadyPurchased", - "type": "error" - }, - { - "inputs": [], - "name": "Duplicate", - "type": "error" - }, - { - "inputs": [], - "name": "InsufficientValue", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidEAS", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidLength", - "type": "error" - }, - { - "inputs": [], - "name": "NotPayable", - "type": "error" - }, - { - "inputs": [], - "name": "OutOfBounds", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "OwnableInvalidOwner", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "OwnableUnauthorizedAccount", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "uid", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "schema", - "type": "bytes32" - }, - { - "internalType": "uint64", - "name": "time", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "expirationTime", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "revocationTime", - "type": "uint64" - }, - { - "internalType": "bytes32", - "name": "refUID", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "address", - "name": "attester", - "type": "address" - }, - { - "internalType": "bool", - "name": "revocable", - "type": "bool" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "internalType": "struct Attestation", - "name": "attestation", - "type": "tuple" - } - ], - "name": "attest", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "eventId", - "type": "string" - }, - { - "internalType": "string", - "name": "ticketType", - "type": "string" - } - ], - "name": "getPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getTickets", - "outputs": [ - { - "internalType": "string[]", - "name": "", - "type": "string[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "isPayable", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "uid", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "schema", - "type": "bytes32" - }, - { - "internalType": "uint64", - "name": "time", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "expirationTime", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "revocationTime", - "type": "uint64" - }, - { - "internalType": "bytes32", - "name": "refUID", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "address", - "name": "attester", - "type": "address" - }, - { - "internalType": "bool", - "name": "revocable", - "type": "bool" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "internalType": "struct Attestation[]", - "name": "attestations", - "type": "tuple[]" - }, - { - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - } - ], - "name": "multiAttest", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "uid", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "schema", - "type": "bytes32" - }, - { - "internalType": "uint64", - "name": "time", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "expirationTime", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "revocationTime", - "type": "uint64" - }, - { - "internalType": "bytes32", - "name": "refUID", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "address", - "name": "attester", - "type": "address" - }, - { - "internalType": "bool", - "name": "revocable", - "type": "bool" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "internalType": "struct Attestation[]", - "name": "attestations", - "type": "tuple[]" - }, - { - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - } - ], - "name": "multiRevoke", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "eventId", - "type": "string" - }, - { - "internalType": "string", - "name": "seat", - "type": "string" - }, - { - "internalType": "string", - "name": "ticketType", - "type": "string" - }, - { - "internalType": "string", - "name": "worldProof", - "type": "string" - }, - { - "internalType": "string", - "name": "attestationId", - "type": "string" - } - ], - "name": "purchase", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "uid", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "schema", - "type": "bytes32" - }, - { - "internalType": "uint64", - "name": "time", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "expirationTime", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "revocationTime", - "type": "uint64" - }, - { - "internalType": "bytes32", - "name": "refUID", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "address", - "name": "attester", - "type": "address" - }, - { - "internalType": "bool", - "name": "revocable", - "type": "bool" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "internalType": "struct Attestation", - "name": "attestation", - "type": "tuple" - } - ], - "name": "revoke", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "eventId", - "type": "string" - }, - { - "internalType": "string", - "name": "ticketType", - "type": "string" - }, - { - "internalType": "uint256", - "name": "price", - "type": "uint256" - } - ], - "name": "setPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - }, - { - "internalType": "uint256", - "name": "start", - "type": "uint256" - } - ], - "name": "toBytes32", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "version", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } - ], - "bytecode": "0x6101006040523480156200001257600080fd5b50604051620015733803806200157383398101604081905262000035916200013f565b6001608052600360a052600060c05233826001600160a01b0381166200006e576040516341bc07ff60e11b815260040160405180910390fd5b6001600160a01b0390811660e0528116620000a357604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b620000ae81620000d6565b50600180546001600160a01b0319166001600160a01b0392909216919091179055506200017e565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146200013c57600080fd5b50565b600080604083850312156200015357600080fd5b8251620001608162000126565b6020840151909250620001738162000126565b809150509250929050565b60805160a05160c05160e0516113bb620001b86000396000610a91015260006106c50152600061069c0152600061067301526113bb6000f3fe6080604052600436106100e15760003560e01c806391db0b7e1161007f578063ce46e04611610059578063ce46e04614610243578063e49617e114610257578063e60c35051461026a578063f2fde38b1461027d57600080fd5b806391db0b7e146101f057806399dd9bd714610203578063b11128851461022357600080fd5b806354fd4d50116100bb57806354fd4d501461016e578063715018a61461019057806388e5b2d9146101a55780638da5cb5b146101c857600080fd5b806313c191b0146101065780633d0f34da146101195780634ed026221461014c57600080fd5b3661010157604051631574f9f360e01b815260040160405180910390fd5b005b600080fd5b6100ff610114366004610d74565b61029d565b34801561012557600080fd5b50610139610134366004610e46565b610542565b6040519081526020015b60405180910390f35b34801561015857600080fd5b50610161610588565b6040516101439190610efa565b34801561017a57600080fd5b5061018361066c565b6040516101439190610f5c565b34801561019c57600080fd5b506100ff61070f565b6101b86101b3366004610fbb565b610723565b6040519015158152602001610143565b3480156101d457600080fd5b506000546040516001600160a01b039091168152602001610143565b6101b86101fe366004610fbb565b6107f2565b34801561020f57600080fd5b5061013961021e366004611027565b6108b1565b34801561022f57600080fd5b506100ff61023e366004611080565b6108c4565b34801561024f57600080fd5b5060006101b8565b6101b86102653660046110ed565b61090e565b6101b86102783660046110ed565b61091f565b34801561028957600080fd5b506100ff610298366004611129565b610933565b60006004866040516102af9190611152565b9081526020016040518091039020836040516102cb9190611152565b9081526040519081900360200190205460ff16905080151560010361030357604051630cd9ed5560e21b815260040160405180910390fd5b60006005876040516103159190611152565b9081526020016040518091039020866040516103319190611152565b9081526040519081900360200190205460ff1690508015156001036103695760405163031a394360e61b815260040160405180910390fd5b336000908152600660205260408082209051610386908690611152565b9081526040519081900360200190205460ff1690508015156001036103be576040516306ca7a9d60e21b815260040160405180910390fd5b60006003896040516103d09190611152565b9081526020016040518091039020876040516103ec9190611152565b9081526020016040518091039020549050600160048a60405161040f9190611152565b90815260200160405180910390208760405161042b9190611152565b908152604051908190036020018120805492151560ff199093169290921790915560019060059061045d908c90611152565b9081526020016040518091039020896040516104799190611152565b9081526040805160209281900383018120805460ff191694151594909417909355336000908152600690925290206001916104b5908890611152565b9081526040805160209281900383019020805460ff1916931515939093179092553360009081526007825291822080546001810182559083529120016104fb86826111f7565b506001546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610536573d6000803e3d6000fd5b50505050505050505050565b60006003836040516105549190611152565b9081526020016040518091039020826040516105709190611152565b90815260200160405180910390205490505b92915050565b336000908152600760209081526040808320805482518185028101850190935280835260609492939192909184015b828210156106635783829060005260206000200180546105d69061116e565b80601f01602080910402602001604051908101604052809291908181526020018280546106029061116e565b801561064f5780601f106106245761010080835404028352916020019161064f565b820191906000526020600020905b81548152906001019060200180831161063257829003601f168201915b5050505050815260200190600101906105b7565b50505050905090565b60606106977f0000000000000000000000000000000000000000000000000000000000000000610976565b6106c07f0000000000000000000000000000000000000000000000000000000000000000610976565b6106e97f0000000000000000000000000000000000000000000000000000000000000000610976565b6040516020016106fb939291906112b7565b604051602081830303815290604052905090565b610717610a09565b6107216000610a36565b565b600061072d610a86565b8382811461074e5760405163251f56a160e21b815260040160405180910390fd5b3460005b828110156107e257600086868381811061076e5761076e611311565b905060200201359050828111156107985760405163044044a560e21b815260040160405180910390fd5b6107c58989848181106107ad576107ad611311565b90506020028101906107bf9190611327565b50600190565b6107d65760009450505050506107ea565b90910390600101610752565b506001925050505b949350505050565b60006107fc610a86565b8382811461081d5760405163251f56a160e21b815260040160405180910390fd5b3460005b828110156107e257600086868381811061083d5761083d611311565b905060200201359050828111156108675760405163044044a560e21b815260040160405180910390fd5b61089489898481811061087c5761087c611311565b905060200281019061088e9190611327565b82610acf565b6108a55760009450505050506107ea565b90910390600101610821565b60006108bd8383610bc0565b9392505050565b6108cc610a09565b806003846040516108dd9190611152565b9081526020016040518091039020836040516108f99190611152565b90815260405190819003602001902055505050565b6000610918610a86565b6001610582565b6000610929610a86565b6105828234610acf565b61093b610a09565b6001600160a01b03811661096a57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61097381610a36565b50565b6060600061098383610bf0565b600101905060008167ffffffffffffffff8111156109a3576109a3610cc8565b6040519080825280601f01601f1916602001820160405280156109cd576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846109d757509392505050565b6000546001600160a01b031633146107215760405163118cdaa760e01b8152336004820152602401610961565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461072157604051634ca8886760e01b815260040160405180910390fd5b600080610b1d610ae361012086018661133e565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509250610bc0915050565b9050600081604051602001610b3491815260200190565b60408051601f1981840301815291905290506000600681610b5b60e0890160c08a01611129565b6001600160a01b03166001600160a01b0316815260200190815260200160002082604051610b899190611152565b9081526040519081900360200190205460ff169050801515600103610bb45760019350505050610582565b50600095945050505050565b60008160200183511015610be757604051632d0483c560e21b815260040160405180910390fd5b50016020015190565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310610c2f5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310610c5b576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310610c7957662386f26fc10000830492506010015b6305f5e1008310610c91576305f5e100830492506008015b6127108310610ca557612710830492506004015b60648310610cb7576064830492506002015b600a83106105825760010192915050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115610cf957610cf9610cc8565b604051601f8501601f19908116603f01168101908282118183101715610d2157610d21610cc8565b81604052809350858152868686011115610d3a57600080fd5b858560208301376000602087830101525050509392505050565b600082601f830112610d6557600080fd5b6108bd83833560208501610cde565b600080600080600060a08688031215610d8c57600080fd5b853567ffffffffffffffff80821115610da457600080fd5b610db089838a01610d54565b96506020880135915080821115610dc657600080fd5b610dd289838a01610d54565b95506040880135915080821115610de857600080fd5b610df489838a01610d54565b94506060880135915080821115610e0a57600080fd5b610e1689838a01610d54565b93506080880135915080821115610e2c57600080fd5b50610e3988828901610d54565b9150509295509295909350565b60008060408385031215610e5957600080fd5b823567ffffffffffffffff80821115610e7157600080fd5b610e7d86838701610d54565b93506020850135915080821115610e9357600080fd5b50610ea085828601610d54565b9150509250929050565b60005b83811015610ec5578181015183820152602001610ead565b50506000910152565b60008151808452610ee6816020860160208601610eaa565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015610f4f57603f19888603018452610f3d858351610ece565b94509285019290850190600101610f21565b5092979650505050505050565b6020815260006108bd6020830184610ece565b60008083601f840112610f8157600080fd5b50813567ffffffffffffffff811115610f9957600080fd5b6020830191508360208260051b8501011115610fb457600080fd5b9250929050565b60008060008060408587031215610fd157600080fd5b843567ffffffffffffffff80821115610fe957600080fd5b610ff588838901610f6f565b9096509450602087013591508082111561100e57600080fd5b5061101b87828801610f6f565b95989497509550505050565b6000806040838503121561103a57600080fd5b823567ffffffffffffffff81111561105157600080fd5b8301601f8101851361106257600080fd5b61107185823560208401610cde565b95602094909401359450505050565b60008060006060848603121561109557600080fd5b833567ffffffffffffffff808211156110ad57600080fd5b6110b987838801610d54565b945060208601359150808211156110cf57600080fd5b506110dc86828701610d54565b925050604084013590509250925092565b6000602082840312156110ff57600080fd5b813567ffffffffffffffff81111561111657600080fd5b820161014081850312156108bd57600080fd5b60006020828403121561113b57600080fd5b81356001600160a01b03811681146108bd57600080fd5b60008251611164818460208701610eaa565b9190910192915050565b600181811c9082168061118257607f821691505b6020821081036111a257634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156111f257600081815260208120601f850160051c810160208610156111cf5750805b601f850160051c820191505b818110156111ee578281556001016111db565b5050505b505050565b815167ffffffffffffffff81111561121157611211610cc8565b6112258161121f845461116e565b846111a8565b602080601f83116001811461125a57600084156112425750858301515b600019600386901b1c1916600185901b1785556111ee565b600085815260208120601f198616915b828110156112895788860151825594840194600190910190840161126a565b50858210156112a75787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600084516112c9818460208901610eaa565b8083019050601760f91b80825285516112e9816001850160208a01610eaa565b60019201918201528351611304816002840160208801610eaa565b0160020195945050505050565b634e487b7160e01b600052603260045260246000fd5b6000823561013e1983360301811261116457600080fd5b6000808335601e1984360301811261135557600080fd5b83018035915067ffffffffffffffff82111561137057600080fd5b602001915036819003821315610fb457600080fdfea26469706673582212207df81908b70bc1f92222fe21ea96f59a89f4ce154614c4d5832d233518b7b5f364736f6c63430008140033", - "deployedBytecode": "0x6080604052600436106100e15760003560e01c806391db0b7e1161007f578063ce46e04611610059578063ce46e04614610243578063e49617e114610257578063e60c35051461026a578063f2fde38b1461027d57600080fd5b806391db0b7e146101f057806399dd9bd714610203578063b11128851461022357600080fd5b806354fd4d50116100bb57806354fd4d501461016e578063715018a61461019057806388e5b2d9146101a55780638da5cb5b146101c857600080fd5b806313c191b0146101065780633d0f34da146101195780634ed026221461014c57600080fd5b3661010157604051631574f9f360e01b815260040160405180910390fd5b005b600080fd5b6100ff610114366004610d74565b61029d565b34801561012557600080fd5b50610139610134366004610e46565b610542565b6040519081526020015b60405180910390f35b34801561015857600080fd5b50610161610588565b6040516101439190610efa565b34801561017a57600080fd5b5061018361066c565b6040516101439190610f5c565b34801561019c57600080fd5b506100ff61070f565b6101b86101b3366004610fbb565b610723565b6040519015158152602001610143565b3480156101d457600080fd5b506000546040516001600160a01b039091168152602001610143565b6101b86101fe366004610fbb565b6107f2565b34801561020f57600080fd5b5061013961021e366004611027565b6108b1565b34801561022f57600080fd5b506100ff61023e366004611080565b6108c4565b34801561024f57600080fd5b5060006101b8565b6101b86102653660046110ed565b61090e565b6101b86102783660046110ed565b61091f565b34801561028957600080fd5b506100ff610298366004611129565b610933565b60006004866040516102af9190611152565b9081526020016040518091039020836040516102cb9190611152565b9081526040519081900360200190205460ff16905080151560010361030357604051630cd9ed5560e21b815260040160405180910390fd5b60006005876040516103159190611152565b9081526020016040518091039020866040516103319190611152565b9081526040519081900360200190205460ff1690508015156001036103695760405163031a394360e61b815260040160405180910390fd5b336000908152600660205260408082209051610386908690611152565b9081526040519081900360200190205460ff1690508015156001036103be576040516306ca7a9d60e21b815260040160405180910390fd5b60006003896040516103d09190611152565b9081526020016040518091039020876040516103ec9190611152565b9081526020016040518091039020549050600160048a60405161040f9190611152565b90815260200160405180910390208760405161042b9190611152565b908152604051908190036020018120805492151560ff199093169290921790915560019060059061045d908c90611152565b9081526020016040518091039020896040516104799190611152565b9081526040805160209281900383018120805460ff191694151594909417909355336000908152600690925290206001916104b5908890611152565b9081526040805160209281900383019020805460ff1916931515939093179092553360009081526007825291822080546001810182559083529120016104fb86826111f7565b506001546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610536573d6000803e3d6000fd5b50505050505050505050565b60006003836040516105549190611152565b9081526020016040518091039020826040516105709190611152565b90815260200160405180910390205490505b92915050565b336000908152600760209081526040808320805482518185028101850190935280835260609492939192909184015b828210156106635783829060005260206000200180546105d69061116e565b80601f01602080910402602001604051908101604052809291908181526020018280546106029061116e565b801561064f5780601f106106245761010080835404028352916020019161064f565b820191906000526020600020905b81548152906001019060200180831161063257829003601f168201915b5050505050815260200190600101906105b7565b50505050905090565b60606106977f0000000000000000000000000000000000000000000000000000000000000000610976565b6106c07f0000000000000000000000000000000000000000000000000000000000000000610976565b6106e97f0000000000000000000000000000000000000000000000000000000000000000610976565b6040516020016106fb939291906112b7565b604051602081830303815290604052905090565b610717610a09565b6107216000610a36565b565b600061072d610a86565b8382811461074e5760405163251f56a160e21b815260040160405180910390fd5b3460005b828110156107e257600086868381811061076e5761076e611311565b905060200201359050828111156107985760405163044044a560e21b815260040160405180910390fd5b6107c58989848181106107ad576107ad611311565b90506020028101906107bf9190611327565b50600190565b6107d65760009450505050506107ea565b90910390600101610752565b506001925050505b949350505050565b60006107fc610a86565b8382811461081d5760405163251f56a160e21b815260040160405180910390fd5b3460005b828110156107e257600086868381811061083d5761083d611311565b905060200201359050828111156108675760405163044044a560e21b815260040160405180910390fd5b61089489898481811061087c5761087c611311565b905060200281019061088e9190611327565b82610acf565b6108a55760009450505050506107ea565b90910390600101610821565b60006108bd8383610bc0565b9392505050565b6108cc610a09565b806003846040516108dd9190611152565b9081526020016040518091039020836040516108f99190611152565b90815260405190819003602001902055505050565b6000610918610a86565b6001610582565b6000610929610a86565b6105828234610acf565b61093b610a09565b6001600160a01b03811661096a57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61097381610a36565b50565b6060600061098383610bf0565b600101905060008167ffffffffffffffff8111156109a3576109a3610cc8565b6040519080825280601f01601f1916602001820160405280156109cd576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846109d757509392505050565b6000546001600160a01b031633146107215760405163118cdaa760e01b8152336004820152602401610961565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461072157604051634ca8886760e01b815260040160405180910390fd5b600080610b1d610ae361012086018661133e565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509250610bc0915050565b9050600081604051602001610b3491815260200190565b60408051601f1981840301815291905290506000600681610b5b60e0890160c08a01611129565b6001600160a01b03166001600160a01b0316815260200190815260200160002082604051610b899190611152565b9081526040519081900360200190205460ff169050801515600103610bb45760019350505050610582565b50600095945050505050565b60008160200183511015610be757604051632d0483c560e21b815260040160405180910390fd5b50016020015190565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310610c2f5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310610c5b576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310610c7957662386f26fc10000830492506010015b6305f5e1008310610c91576305f5e100830492506008015b6127108310610ca557612710830492506004015b60648310610cb7576064830492506002015b600a83106105825760010192915050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115610cf957610cf9610cc8565b604051601f8501601f19908116603f01168101908282118183101715610d2157610d21610cc8565b81604052809350858152868686011115610d3a57600080fd5b858560208301376000602087830101525050509392505050565b600082601f830112610d6557600080fd5b6108bd83833560208501610cde565b600080600080600060a08688031215610d8c57600080fd5b853567ffffffffffffffff80821115610da457600080fd5b610db089838a01610d54565b96506020880135915080821115610dc657600080fd5b610dd289838a01610d54565b95506040880135915080821115610de857600080fd5b610df489838a01610d54565b94506060880135915080821115610e0a57600080fd5b610e1689838a01610d54565b93506080880135915080821115610e2c57600080fd5b50610e3988828901610d54565b9150509295509295909350565b60008060408385031215610e5957600080fd5b823567ffffffffffffffff80821115610e7157600080fd5b610e7d86838701610d54565b93506020850135915080821115610e9357600080fd5b50610ea085828601610d54565b9150509250929050565b60005b83811015610ec5578181015183820152602001610ead565b50506000910152565b60008151808452610ee6816020860160208601610eaa565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015610f4f57603f19888603018452610f3d858351610ece565b94509285019290850190600101610f21565b5092979650505050505050565b6020815260006108bd6020830184610ece565b60008083601f840112610f8157600080fd5b50813567ffffffffffffffff811115610f9957600080fd5b6020830191508360208260051b8501011115610fb457600080fd5b9250929050565b60008060008060408587031215610fd157600080fd5b843567ffffffffffffffff80821115610fe957600080fd5b610ff588838901610f6f565b9096509450602087013591508082111561100e57600080fd5b5061101b87828801610f6f565b95989497509550505050565b6000806040838503121561103a57600080fd5b823567ffffffffffffffff81111561105157600080fd5b8301601f8101851361106257600080fd5b61107185823560208401610cde565b95602094909401359450505050565b60008060006060848603121561109557600080fd5b833567ffffffffffffffff808211156110ad57600080fd5b6110b987838801610d54565b945060208601359150808211156110cf57600080fd5b506110dc86828701610d54565b925050604084013590509250925092565b6000602082840312156110ff57600080fd5b813567ffffffffffffffff81111561111657600080fd5b820161014081850312156108bd57600080fd5b60006020828403121561113b57600080fd5b81356001600160a01b03811681146108bd57600080fd5b60008251611164818460208701610eaa565b9190910192915050565b600181811c9082168061118257607f821691505b6020821081036111a257634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156111f257600081815260208120601f850160051c810160208610156111cf5750805b601f850160051c820191505b818110156111ee578281556001016111db565b5050505b505050565b815167ffffffffffffffff81111561121157611211610cc8565b6112258161121f845461116e565b846111a8565b602080601f83116001811461125a57600084156112425750858301515b600019600386901b1c1916600185901b1785556111ee565b600085815260208120601f198616915b828110156112895788860151825594840194600190910190840161126a565b50858210156112a75787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600084516112c9818460208901610eaa565b8083019050601760f91b80825285516112e9816001850160208a01610eaa565b60019201918201528351611304816002840160208801610eaa565b0160020195945050505050565b634e487b7160e01b600052603260045260246000fd5b6000823561013e1983360301811261116457600080fd5b6000808335601e1984360301811261135557600080fd5b83018035915067ffffffffffffffff82111561137057600080fd5b602001915036819003821315610fb457600080fdfea26469706673582212207df81908b70bc1f92222fe21ea96f59a89f4ce154614c4d5832d233518b7b5f364736f6c63430008140033", - "linkReferences": {}, - "deployedLinkReferences": {} -} diff --git a/apps/haus/src/abi/redeem-resolver.ts b/apps/haus/src/abi/redeem-resolver.ts new file mode 100644 index 0000000..2cddda9 --- /dev/null +++ b/apps/haus/src/abi/redeem-resolver.ts @@ -0,0 +1,228 @@ +export const abi = [ + { + inputs: [ + { internalType: 'contract IEAS', name: 'eas', type: 'address' }, + { internalType: 'address', name: '_paymentAddress', type: 'address' }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { inputs: [], name: 'AccessDenied', type: 'error' }, + { inputs: [], name: 'AlreadyIssued', type: 'error' }, + { inputs: [], name: 'AlreadyPurchased', type: 'error' }, + { inputs: [], name: 'Duplicate', type: 'error' }, + { inputs: [], name: 'Insufficient', type: 'error' }, + { inputs: [], name: 'InsufficientValue', type: 'error' }, + { inputs: [], name: 'InvalidEAS', type: 'error' }, + { inputs: [], name: 'InvalidLength', type: 'error' }, + { inputs: [], name: 'NotPayable', type: 'error' }, + { inputs: [], name: 'OutOfBounds', type: 'error' }, + { + inputs: [{ internalType: 'address', name: 'owner', type: 'address' }], + name: 'OwnableInvalidOwner', + type: 'error', + }, + { + inputs: [{ internalType: 'address', name: 'account', type: 'address' }], + name: 'OwnableUnauthorizedAccount', + type: 'error', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'previousOwner', type: 'address' }, + { indexed: true, internalType: 'address', name: 'newOwner', type: 'address' }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, + { + inputs: [ + { + components: [ + { internalType: 'bytes32', name: 'uid', type: 'bytes32' }, + { internalType: 'bytes32', name: 'schema', type: 'bytes32' }, + { internalType: 'uint64', name: 'time', type: 'uint64' }, + { internalType: 'uint64', name: 'expirationTime', type: 'uint64' }, + { internalType: 'uint64', name: 'revocationTime', type: 'uint64' }, + { internalType: 'bytes32', name: 'refUID', type: 'bytes32' }, + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'address', name: 'attester', type: 'address' }, + { internalType: 'bool', name: 'revocable', type: 'bool' }, + { internalType: 'bytes', name: 'data', type: 'bytes' }, + ], + internalType: 'struct Attestation', + name: 'attestation', + type: 'tuple', + }, + ], + name: 'attest', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { internalType: 'string', name: 'eventId', type: 'string' }, + { internalType: 'string', name: 'ticketType', type: 'string' }, + ], + name: 'getPrice', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getTickets', + outputs: [{ internalType: 'string[]', name: '', type: 'string[]' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'isPayable', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'bytes32', name: 'uid', type: 'bytes32' }, + { internalType: 'bytes32', name: 'schema', type: 'bytes32' }, + { internalType: 'uint64', name: 'time', type: 'uint64' }, + { internalType: 'uint64', name: 'expirationTime', type: 'uint64' }, + { internalType: 'uint64', name: 'revocationTime', type: 'uint64' }, + { internalType: 'bytes32', name: 'refUID', type: 'bytes32' }, + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'address', name: 'attester', type: 'address' }, + { internalType: 'bool', name: 'revocable', type: 'bool' }, + { internalType: 'bytes', name: 'data', type: 'bytes' }, + ], + internalType: 'struct Attestation[]', + name: 'attestations', + type: 'tuple[]', + }, + { internalType: 'uint256[]', name: 'values', type: 'uint256[]' }, + ], + name: 'multiAttest', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'bytes32', name: 'uid', type: 'bytes32' }, + { internalType: 'bytes32', name: 'schema', type: 'bytes32' }, + { internalType: 'uint64', name: 'time', type: 'uint64' }, + { internalType: 'uint64', name: 'expirationTime', type: 'uint64' }, + { internalType: 'uint64', name: 'revocationTime', type: 'uint64' }, + { internalType: 'bytes32', name: 'refUID', type: 'bytes32' }, + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'address', name: 'attester', type: 'address' }, + { internalType: 'bool', name: 'revocable', type: 'bool' }, + { internalType: 'bytes', name: 'data', type: 'bytes' }, + ], + internalType: 'struct Attestation[]', + name: 'attestations', + type: 'tuple[]', + }, + { internalType: 'uint256[]', name: 'values', type: 'uint256[]' }, + ], + name: 'multiRevoke', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'string', name: 'eventId', type: 'string' }, + { internalType: 'string', name: 'seat', type: 'string' }, + { internalType: 'string', name: 'ticketType', type: 'string' }, + { internalType: 'string', name: 'worldProof', type: 'string' }, + { internalType: 'string', name: 'attestationId', type: 'string' }, + ], + name: 'purchase', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'renounceOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'bytes32', name: 'uid', type: 'bytes32' }, + { internalType: 'bytes32', name: 'schema', type: 'bytes32' }, + { internalType: 'uint64', name: 'time', type: 'uint64' }, + { internalType: 'uint64', name: 'expirationTime', type: 'uint64' }, + { internalType: 'uint64', name: 'revocationTime', type: 'uint64' }, + { internalType: 'bytes32', name: 'refUID', type: 'bytes32' }, + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'address', name: 'attester', type: 'address' }, + { internalType: 'bool', name: 'revocable', type: 'bool' }, + { internalType: 'bytes', name: 'data', type: 'bytes' }, + ], + internalType: 'struct Attestation', + name: 'attestation', + type: 'tuple', + }, + ], + name: 'revoke', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { internalType: 'string', name: 'eventId', type: 'string' }, + { internalType: 'string', name: 'ticketType', type: 'string' }, + { internalType: 'uint256', name: 'price', type: 'uint256' }, + ], + name: 'setPrice', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'bytes', name: 'data', type: 'bytes' }, + { internalType: 'uint256', name: 'start', type: 'uint256' }, + ], + name: 'toBytes32', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'version', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + { stateMutability: 'payable', type: 'receive' }, +] diff --git a/apps/haus/src/components/confirm-ticket/index.tsx b/apps/haus/src/components/confirm-ticket/index.tsx index 6d59f2f..5a3b385 100644 --- a/apps/haus/src/components/confirm-ticket/index.tsx +++ b/apps/haus/src/components/confirm-ticket/index.tsx @@ -1,9 +1,10 @@ 'use client' -import React, { useContext } from 'react' +import React, { useContext, useEffect } from 'react' import Image from 'next/image' import { useParams, useRouter } from 'next/navigation' -import { useAccount, useEnsName } from 'wagmi' +import { useAccount, useWriteContract, useEnsName } from 'wagmi' +import { EAS, SchemaEncoder } from '@ethereum-attestation-service/eas-sdk' import Typography from '@mui/material/Typography' import Stack from '@mui/material/Stack' import IconButton from '@mui/material/IconButton' @@ -13,12 +14,21 @@ import Box from '@mui/material/Box' import ArrowBackIcon from '@mui/icons-material/ArrowBack' import LocationOnIcon from '@mui/icons-material/LocationOn' import EventIcon from '@mui/icons-material/Event' -import { useMutation } from '@tanstack/react-query' +// import { useMutation } from '@tanstack/react-query' import { getEventById } from '@/utils/helper' import { TicketContext } from '@/store/ticket' -import api from '@/services/api' +// import api from '@/services/api' +import { abi } from '@/abi/redeem-resolver' + import VerifyWorldId from '../verify-world-id' +import { useEthersSigner } from '@/utils/ethers' + +// const chainId = process.env.NEXT_PUBLIC_CHAIN_ID || 11155420 +const resolverAddress = process.env.NEXT_PUBLIC_RESOLVER_ADDRESS +const EAS_ADDRESS = process.env.NEXT_PUBLIC_EAS_CONTRACT_ADDRESS +const SCHEMA_UID = process.env.NEXT_PUBLIC_SCHEMA_TICKET_UID +// const PROVIDER = process.env.NEXT_PUBLIC_EAS_PROVIDER_URL || 'https://sepolia.optimism.io' function generateSeatNumber() { const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' @@ -31,28 +41,104 @@ function ConfirmTicket({ setStep }: { setStep: (step: number) => void }) { const { id } = useParams<{ id: string }>() const event = getEventById(id) const context = useContext(TicketContext) + const signer = useEthersSigner() // const { connectors, connect } = useConnect() // const { address, connector, isConnected } = useAccount() + const { address } = useAccount() const { data: ensName } = useEnsName({ address }) + + const { data: hash, writeContract } = useWriteContract() + const router = useRouter() - const { mutateAsync: confirmOrder } = useMutation({ - mutationFn: (payload: { - id: string - eventId: string - worldProof: string - holderName: string - type: string - seatNumber: string - entryFor: number - recipient: string - }) => { - return api.post<{ attestation_id: string }>(`/attestation/`, payload) - }, - onSuccess: () => { - router.push(`/event/${id}/complete`) - }, - }) + + // const { mutateAsync: confirmOrder } = useMutation({ + // mutationFn: (payload: { + // id: string + // eventId: string + // worldProof: string + // holderName: string + // type: string + // seatNumber: string + // entryFor: number + // recipient: string + // }) => { + // return api.post<{ attestation_id: string }>(`/attestation/`, payload) + // }, + // onSuccess: () => { + // router.push(`/event/${id}/complete`) + // }, + // }) + + const createOfflineAttest = async (payload: any) => { + if (!signer) return + + console.log('EAS_ADDRESS', EAS_ADDRESS) + // Initialize the sdk with the address of the EAS Schema contract address + const easInstance = new EAS(EAS_ADDRESS as string, { signer }) + + // Use eas offchain + const offchain = await easInstance.getOffchain() + + // Connects an ethers style provider/signingProvider to perform read/write functions. + easInstance.connect(signer) + + // Initialize SchemaEncoder with the schema string + const schemaEncoder = new SchemaEncoder( + 'string id,string event_id,string world_proof,string holder_name,string type,string seat_number,uint8 entry_for', + ) + const encodedData = schemaEncoder.encodeData([ + { name: 'id', value: payload.id, type: 'string' }, + { name: 'event_id', value: payload.eventId, type: 'string' }, + { name: 'world_proof', value: payload.worldProof, type: 'string' }, + { name: 'holder_name', value: payload.holderName, type: 'string' }, + { name: 'type', value: payload.type, type: 'string' }, + { name: 'seat_number', value: payload.seatNumber, type: 'string' }, + { name: 'entry_for', value: payload.entryFor, type: 'uint8' }, + ]) + + console.log('SCHEMA_UID', SCHEMA_UID) + + const offchainAttestation = await offchain.signOffchainAttestation( + { + recipient: address as `0x${string}`, + // Unix timestamp of when attestation expires. (0 for no expiration) + expirationTime: 0n, + // Unix timestamp of current time + time: BigInt(Math.floor(Date.now() / 1000)), + revocable: true, // Be aware that if your schema is not revocable, this MUST be false + schema: SCHEMA_UID as string, + refUID: '0x0000000000000000000000000000000000000000000000000000000000000000', + data: encodedData, + }, + signer, + ) + + console.log('offchainAttestation', offchainAttestation) + return offchainAttestation + } + + const purchaseTicket = async (payload: any) => { + if (!resolverAddress) return + await writeContract({ + address: resolverAddress as '0x${string}', + abi, + functionName: 'purchase', + args: [ + payload.eventId, + payload.seatNumber, + payload.type, + payload.worldProof, + payload.attestationId, + ], + }) + } + + useEffect(() => { + if (!hash) return + router.push(`/event/${id}/complete`) + }, [hash, router, id]) + return ( void }) { { - // console.log('success', item) - console.log({ - id: event?.id || '', - eventId: event?.id || '', - worldProof: item.proof, - holderName: ensName || '', - type: event?.tickets[0].type || '', - seatNumber: generateSeatNumber(), - entryFor: 1, - recipient: address || '', - }) - // connect({ connector: connectors[0] }) - const { data } = await confirmOrder({ + const seatNumber = generateSeatNumber() + console.log(item) + const payload = { id: event?.id || '', eventId: event?.id || '', worldProof: item.proof, holderName: ensName || 'Anonymous', type: event?.tickets[0].type || '', - seatNumber: generateSeatNumber(), + seatNumber, entryFor: 1, recipient: address || '', - }) + } + console.log(payload) + + const attestation = await createOfflineAttest(payload) + if (!attestation) return - console.log('attestation_id: ', data?.attestation_id) + await purchaseTicket({ ...payload, attestationId: attestation.uid }) }} onError={console.error} /> + {hash && Transaction Hash: {hash}} diff --git a/apps/haus/src/components/provider/wagmi.ts b/apps/haus/src/components/provider/wagmi.ts index c6468e8..12f0db5 100644 --- a/apps/haus/src/components/provider/wagmi.ts +++ b/apps/haus/src/components/provider/wagmi.ts @@ -4,7 +4,7 @@ import { coinbaseWallet } from 'wagmi/connectors' export const connectorCoinBaseWallet = coinbaseWallet({ appName: 'Haus', - preference: 'smartWalletOnly', // set this to `all` to use EOAs as well + preference: 'all', // set this to `all` to use EOAs as well version: '4', }) diff --git a/apps/haus/src/utils/ethers.ts b/apps/haus/src/utils/ethers.ts new file mode 100644 index 0000000..b9dc103 --- /dev/null +++ b/apps/haus/src/utils/ethers.ts @@ -0,0 +1,27 @@ +import { BrowserProvider, JsonRpcSigner } from 'ethers' +import { useMemo } from 'react' +import type { Account, Chain, Client, Transport } from 'viem' +import { type Config, useConnectorClient } from 'wagmi' + +export function clientToSigner(client: Client) { + const { account, chain, transport } = client + const network = { + chainId: chain.id, + name: chain.name, + ensAddress: chain.contracts?.ensRegistry?.address, + } + console.log('transport', transport) + console.log('network', network) + console.log('account', account) + const provider = new BrowserProvider(transport, network) + console.log('provider', provider) + const signer = new JsonRpcSigner(provider, account.address) + console.log('signer', signer) + return signer +} + +/** Hook to convert a viem Wallet Client to an ethers.js Signer. */ +export function useEthersSigner({ chainId }: { chainId?: number } = {}) { + const { data: client } = useConnectorClient({ chainId }) + return useMemo(() => (client ? clientToSigner(client) : undefined), [client]) +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 98e1325..942397e 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -9,7 +9,7 @@ "importHelpers": true, "target": "ES2020", "module": "esnext", - "moduleResolution": "node", + "moduleResolution": "bundler", "lib": ["DOM", "DOM.Iterable", "esnext", "esnext.bigint"], "skipLibCheck": true, "skipDefaultLibCheck": true, From cd77802f954df4e926a9892bd53c0417f509045c Mon Sep 17 00:00:00 2001 From: imajindev Date: Sun, 11 Aug 2024 22:13:37 +0800 Subject: [PATCH 3/3] add purchase and ticket redeem flow --- .../scripts/deploy-purchase-ticket.js | 26 +++ .../scripts/deploy-ticket-redeem-v2.js | 26 +++ apps/contract/scripts/deploy-ticket-redeem.js | 8 +- apps/contract/src/PurchaseTicket.sol | 59 ++++++ apps/contract/src/RedeemResolver.sol | 85 +------- apps/contract/src/RedeemResolverV2.sol | 116 +++++++++++ apps/haus/src/abi/purchase-ticket.ts | 182 ++++++++++++++++++ .../{redeem-ticket => [id]/redeem}/route.ts | 19 +- .../src/components/confirm-ticket/index.tsx | 178 +++++++---------- .../src/components/loading-page/index.tsx | 2 +- apps/haus/src/components/tickets/index.tsx | 113 ++++++++--- apps/haus/src/components/tickets/lottie.tsx | 47 +++++ apps/haus/src/components/tickets/success.json | 1 + apps/haus/src/utils/helper.ts | 2 +- package-lock.json | 25 ++- package.json | 1 + 16 files changed, 666 insertions(+), 224 deletions(-) create mode 100644 apps/contract/scripts/deploy-purchase-ticket.js create mode 100644 apps/contract/scripts/deploy-ticket-redeem-v2.js create mode 100644 apps/contract/src/PurchaseTicket.sol create mode 100644 apps/contract/src/RedeemResolverV2.sol create mode 100644 apps/haus/src/abi/purchase-ticket.ts rename apps/haus/src/app/api/attestation/{redeem-ticket => [id]/redeem}/route.ts (76%) create mode 100644 apps/haus/src/components/tickets/lottie.tsx create mode 100644 apps/haus/src/components/tickets/success.json diff --git a/apps/contract/scripts/deploy-purchase-ticket.js b/apps/contract/scripts/deploy-purchase-ticket.js new file mode 100644 index 0000000..88f9f42 --- /dev/null +++ b/apps/contract/scripts/deploy-purchase-ticket.js @@ -0,0 +1,26 @@ +// We require the Hardhat Runtime Environment explicitly here. This is optional +// but useful for running the script in a standalone fashion through `node