From 40578638130f916e90fd332d43ef4114407df948 Mon Sep 17 00:00:00 2001 From: Sebastian Coronel Date: Sun, 9 Oct 2022 12:36:04 -0500 Subject: [PATCH] update polygon and optimism --- src/components/AppConfig.tsx | 2 +- src/config/index.ts | 2 +- src/eth-sdk/abis/goerli/allyu.json | 222 +---------------- src/eth-sdk/abis/goerli/dai.json | 277 +-------------------- src/eth-sdk/abis/optimismGoerli/allyu.json | 1 - src/eth-sdk/abis/optimismGoerli/dai.json | 1 - src/eth-sdk/config.ts | 4 + src/hooks/useEthereum.ts | 24 +- src/pages/bill/[id].tsx | 6 +- 9 files changed, 31 insertions(+), 508 deletions(-) delete mode 100644 src/eth-sdk/abis/optimismGoerli/allyu.json delete mode 100644 src/eth-sdk/abis/optimismGoerli/dai.json diff --git a/src/components/AppConfig.tsx b/src/components/AppConfig.tsx index 100bfbc..94d29b8 100644 --- a/src/components/AppConfig.tsx +++ b/src/components/AppConfig.tsx @@ -1,4 +1,4 @@ -import { getDefaultWallets, lightTheme, RainbowKitProvider, Theme } from '@rainbow-me/rainbowkit' +import { getDefaultWallets, lightTheme, RainbowKitProvider } from '@rainbow-me/rainbowkit' import '@rainbow-me/rainbowkit/styles.css' import { INFURA_ID } from 'config' import { ReactElement } from 'react' diff --git a/src/config/index.ts b/src/config/index.ts index 840f7a1..48781c7 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -1,2 +1,2 @@ -export const INFURA_ID = '2717afb6bf164045b5d5468031b93f87' +export const INFURA_ID = '7624b6b795d248809eabd3dd3eaaf9f7' export const ETHERSCAN_URL = 'https://goerli.etherscan.io' diff --git a/src/eth-sdk/abis/goerli/allyu.json b/src/eth-sdk/abis/goerli/allyu.json index 64dd1da..924c5df 100644 --- a/src/eth-sdk/abis/goerli/allyu.json +++ b/src/eth-sdk/abis/goerli/allyu.json @@ -1,221 +1 @@ -[ - { - "inputs": [ - { "internalType": "uint256", "name": "feePerBill", "type": "uint256" }, - { "internalType": "address", "name": "daiContractAddress", "type": "address" } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { "inputs": [], "name": "CryptoMoney__FeeNotMet", "type": "error" }, - { "inputs": [], "name": "CryptoMoney__InvalidCode", "type": "error" }, - { "inputs": [], "name": "CryptoMoney__InvalidWord", "type": "error" }, - { "inputs": [], "name": "CryptoMoney__NoFeesToWithdraw", "type": "error" }, - { "inputs": [], "name": "CryptoMoney__NotApproved", "type": "error" }, - { "inputs": [], "name": "CryptoMoney__TransferFailed", "type": "error" }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "internalType": "uint256", "name": "billId", "type": "uint256" }, - { "indexed": true, "internalType": "address", "name": "funder", "type": "address" }, - { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } - ], - "name": "BillFunded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "internalType": "uint256", "name": "billId", "type": "uint256" }, - { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } - ], - "name": "BillIssued", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "internalType": "uint256", "name": "billId", "type": "uint256" }, - { "indexed": true, "internalType": "address", "name": "redeemer", "type": "address" }, - { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } - ], - "name": "BillRedeemed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "internalType": "uint256", "name": "requestId", "type": "uint256" }, - { "indexed": true, "internalType": "address", "name": "requester", "type": "address" }, - { "indexed": false, "internalType": "uint256", "name": "amountPerBill", "type": "uint256" }, - { "indexed": false, "internalType": "uint256", "name": "billCount", "type": "uint256" } - ], - "name": "NewRequest", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, - { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "inputs": [], - "name": "claimFees", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "billId", "type": "uint256" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" }, - { "internalType": "bytes", "name": "wordHash", "type": "bytes" } - ], - "name": "fund", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "getDaiContract", - "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getFeePerBill", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getNextBillId", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getNextRequestId", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "billId", "type": "uint256" }], - "name": "getOneBillFromBillId", - "outputs": [ - { - "components": [ - { "internalType": "uint256", "name": "id", "type": "uint256" }, - { "internalType": "uint256", "name": "value", "type": "uint256" }, - { "internalType": "bytes32", "name": "wordHash", "type": "bytes32" }, - { "internalType": "bytes32", "name": "codeHash", "type": "bytes32" }, - { "internalType": "bool", "name": "isFunded", "type": "bool" }, - { "internalType": "bool", "name": "isRedeemed", "type": "bool" } - ], - "internalType": "struct CryptoMoney.Bill", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "requestId", "type": "uint256" }], - "name": "getOneRequest", - "outputs": [ - { - "components": [ - { "internalType": "uint256", "name": "amountPerBill", "type": "uint256" }, - { "internalType": "uint256", "name": "billCount", "type": "uint256" }, - { "internalType": "bool", "name": "isIssued", "type": "bool" }, - { "internalType": "address", "name": "requester", "type": "address" } - ], - "internalType": "struct CryptoMoney.Request", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "requestId", "type": "uint256" }, - { "internalType": "bytes[]", "name": "codeHash", "type": "bytes[]" } - ], - "name": "issueBills", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "billId", "type": "uint256" }, - { "internalType": "string", "name": "code", "type": "string" }, - { "internalType": "string", "name": "word", "type": "string" }, - { "internalType": "address", "name": "redeemAddress", "type": "address" } - ], - "name": "redeem", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountPerBill", "type": "uint256" }, - { "internalType": "uint256", "name": "billCount", "type": "uint256" } - ], - "name": "requestBills", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "updatedFee", "type": "uint256" }], - "name": "updateFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "billId", "type": "uint256" }, - { "internalType": "string", "name": "word", "type": "string" } - ], - "name": "verifyWord", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - } -] +[{"inputs":[{"internalType":"uint256","name":"feePerBill","type":"uint256"},{"internalType":"address","name":"daiContractAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CryptoMoney__FeeNotMet","type":"error"},{"inputs":[],"name":"CryptoMoney__InvalidCode","type":"error"},{"inputs":[],"name":"CryptoMoney__InvalidWord","type":"error"},{"inputs":[],"name":"CryptoMoney__NoFeesToWithdraw","type":"error"},{"inputs":[],"name":"CryptoMoney__NotApproved","type":"error"},{"inputs":[],"name":"CryptoMoney__TransferFailed","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"billId","type":"uint256"},{"indexed":true,"internalType":"address","name":"funder","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"BillFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"billId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"BillIssued","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"billId","type":"uint256"},{"indexed":true,"internalType":"address","name":"redeemer","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"BillRedeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"address","name":"requester","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountPerBill","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"billCount","type":"uint256"}],"name":"NewRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"claimFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"billId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"wordHash","type":"bytes"}],"name":"fund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDaiContract","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFeePerBill","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextBillId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextRequestId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"billId","type":"uint256"}],"name":"getOneBillFromBillId","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes32","name":"wordHash","type":"bytes32"},{"internalType":"bytes32","name":"codeHash","type":"bytes32"},{"internalType":"bool","name":"isFunded","type":"bool"},{"internalType":"bool","name":"isRedeemed","type":"bool"}],"internalType":"struct CryptoMoney.Bill","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"getOneRequest","outputs":[{"components":[{"internalType":"uint256","name":"amountPerBill","type":"uint256"},{"internalType":"uint256","name":"billCount","type":"uint256"},{"internalType":"bool","name":"isIssued","type":"bool"},{"internalType":"address","name":"requester","type":"address"}],"internalType":"struct CryptoMoney.Request","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"bytes[]","name":"codeHash","type":"bytes[]"}],"name":"issueBills","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"billId","type":"uint256"},{"internalType":"string","name":"code","type":"string"},{"internalType":"string","name":"word","type":"string"},{"internalType":"address","name":"redeemAddress","type":"address"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountPerBill","type":"uint256"},{"internalType":"uint256","name":"billCount","type":"uint256"}],"name":"requestBills","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"updatedFee","type":"uint256"}],"name":"updateFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"billId","type":"uint256"},{"internalType":"string","name":"word","type":"string"}],"name":"verifyWord","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}] \ No newline at end of file diff --git a/src/eth-sdk/abis/goerli/dai.json b/src/eth-sdk/abis/goerli/dai.json index e5cbf9a..6330135 100644 --- a/src/eth-sdk/abis/goerli/dai.json +++ b/src/eth-sdk/abis/goerli/dai.json @@ -1,276 +1 @@ -[ - { - "inputs": [{ "internalType": "uint256", "name": "chainId_", "type": "uint256" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "internalType": "address", "name": "src", "type": "address" }, - { "indexed": true, "internalType": "address", "name": "guy", "type": "address" }, - { "indexed": false, "internalType": "uint256", "name": "wad", "type": "uint256" } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": true, - "inputs": [ - { "indexed": true, "internalType": "bytes4", "name": "sig", "type": "bytes4" }, - { "indexed": true, "internalType": "address", "name": "usr", "type": "address" }, - { "indexed": true, "internalType": "bytes32", "name": "arg1", "type": "bytes32" }, - { "indexed": true, "internalType": "bytes32", "name": "arg2", "type": "bytes32" }, - { "indexed": false, "internalType": "bytes", "name": "data", "type": "bytes" } - ], - "name": "LogNote", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "internalType": "address", "name": "src", "type": "address" }, - { "indexed": true, "internalType": "address", "name": "dst", "type": "address" }, - { "indexed": false, "internalType": "uint256", "name": "wad", "type": "uint256" } - ], - "name": "Transfer", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "DOMAIN_SEPARATOR", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "PERMIT_TYPEHASH", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "internalType": "address", "name": "", "type": "address" }, - { "internalType": "address", "name": "", "type": "address" } - ], - "name": "allowance", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "usr", "type": "address" }, - { "internalType": "uint256", "name": "wad", "type": "uint256" } - ], - "name": "approve", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "internalType": "address", "name": "", "type": "address" }], - "name": "balanceOf", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "usr", "type": "address" }, - { "internalType": "uint256", "name": "wad", "type": "uint256" } - ], - "name": "burn", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [{ "internalType": "address", "name": "guy", "type": "address" }], - "name": "deny", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "usr", "type": "address" }, - { "internalType": "uint256", "name": "wad", "type": "uint256" } - ], - "name": "mint", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "src", "type": "address" }, - { "internalType": "address", "name": "dst", "type": "address" }, - { "internalType": "uint256", "name": "wad", "type": "uint256" } - ], - "name": "move", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [{ "internalType": "string", "name": "", "type": "string" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "internalType": "address", "name": "", "type": "address" }], - "name": "nonces", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "holder", "type": "address" }, - { "internalType": "address", "name": "spender", "type": "address" }, - { "internalType": "uint256", "name": "nonce", "type": "uint256" }, - { "internalType": "uint256", "name": "expiry", "type": "uint256" }, - { "internalType": "bool", "name": "allowed", "type": "bool" }, - { "internalType": "uint8", "name": "v", "type": "uint8" }, - { "internalType": "bytes32", "name": "r", "type": "bytes32" }, - { "internalType": "bytes32", "name": "s", "type": "bytes32" } - ], - "name": "permit", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "usr", "type": "address" }, - { "internalType": "uint256", "name": "wad", "type": "uint256" } - ], - "name": "pull", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "usr", "type": "address" }, - { "internalType": "uint256", "name": "wad", "type": "uint256" } - ], - "name": "push", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [{ "internalType": "address", "name": "guy", "type": "address" }], - "name": "rely", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [{ "internalType": "string", "name": "", "type": "string" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "dst", "type": "address" }, - { "internalType": "uint256", "name": "wad", "type": "uint256" } - ], - "name": "transfer", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "src", "type": "address" }, - { "internalType": "address", "name": "dst", "type": "address" }, - { "internalType": "uint256", "name": "wad", "type": "uint256" } - ], - "name": "transferFrom", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "version", - "outputs": [{ "internalType": "string", "name": "", "type": "string" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "internalType": "address", "name": "", "type": "address" }], - "name": "wards", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - } -] +[{"inputs":[{"internalType":"uint256","name":"chainId_","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"src","type":"address"},{"indexed":true,"internalType":"address","name":"guy","type":"address"},{"indexed":false,"internalType":"uint256","name":"wad","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":true,"inputs":[{"indexed":true,"internalType":"bytes4","name":"sig","type":"bytes4"},{"indexed":true,"internalType":"address","name":"usr","type":"address"},{"indexed":true,"internalType":"bytes32","name":"arg1","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"arg2","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"LogNote","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"src","type":"address"},{"indexed":true,"internalType":"address","name":"dst","type":"address"},{"indexed":false,"internalType":"uint256","name":"wad","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"guy","type":"address"}],"name":"deny","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"mint","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"move","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"bool","name":"allowed","type":"bool"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"pull","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"push","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"guy","type":"address"}],"name":"rely","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"wards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}] \ No newline at end of file diff --git a/src/eth-sdk/abis/optimismGoerli/allyu.json b/src/eth-sdk/abis/optimismGoerli/allyu.json deleted file mode 100644 index 924c5df..0000000 --- a/src/eth-sdk/abis/optimismGoerli/allyu.json +++ /dev/null @@ -1 +0,0 @@ -[{"inputs":[{"internalType":"uint256","name":"feePerBill","type":"uint256"},{"internalType":"address","name":"daiContractAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CryptoMoney__FeeNotMet","type":"error"},{"inputs":[],"name":"CryptoMoney__InvalidCode","type":"error"},{"inputs":[],"name":"CryptoMoney__InvalidWord","type":"error"},{"inputs":[],"name":"CryptoMoney__NoFeesToWithdraw","type":"error"},{"inputs":[],"name":"CryptoMoney__NotApproved","type":"error"},{"inputs":[],"name":"CryptoMoney__TransferFailed","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"billId","type":"uint256"},{"indexed":true,"internalType":"address","name":"funder","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"BillFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"billId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"BillIssued","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"billId","type":"uint256"},{"indexed":true,"internalType":"address","name":"redeemer","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"BillRedeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"address","name":"requester","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountPerBill","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"billCount","type":"uint256"}],"name":"NewRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"claimFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"billId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"wordHash","type":"bytes"}],"name":"fund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDaiContract","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFeePerBill","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextBillId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextRequestId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"billId","type":"uint256"}],"name":"getOneBillFromBillId","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes32","name":"wordHash","type":"bytes32"},{"internalType":"bytes32","name":"codeHash","type":"bytes32"},{"internalType":"bool","name":"isFunded","type":"bool"},{"internalType":"bool","name":"isRedeemed","type":"bool"}],"internalType":"struct CryptoMoney.Bill","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"getOneRequest","outputs":[{"components":[{"internalType":"uint256","name":"amountPerBill","type":"uint256"},{"internalType":"uint256","name":"billCount","type":"uint256"},{"internalType":"bool","name":"isIssued","type":"bool"},{"internalType":"address","name":"requester","type":"address"}],"internalType":"struct CryptoMoney.Request","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"bytes[]","name":"codeHash","type":"bytes[]"}],"name":"issueBills","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"billId","type":"uint256"},{"internalType":"string","name":"code","type":"string"},{"internalType":"string","name":"word","type":"string"},{"internalType":"address","name":"redeemAddress","type":"address"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountPerBill","type":"uint256"},{"internalType":"uint256","name":"billCount","type":"uint256"}],"name":"requestBills","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"updatedFee","type":"uint256"}],"name":"updateFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"billId","type":"uint256"},{"internalType":"string","name":"word","type":"string"}],"name":"verifyWord","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}] \ No newline at end of file diff --git a/src/eth-sdk/abis/optimismGoerli/dai.json b/src/eth-sdk/abis/optimismGoerli/dai.json deleted file mode 100644 index 75d999d..0000000 --- a/src/eth-sdk/abis/optimismGoerli/dai.json +++ /dev/null @@ -1 +0,0 @@ -[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"forceFail","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxApproveFail","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"permit","type":"bool"}],"name":"permitMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"permitted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_forceFail","type":"bool"}],"name":"setForceFail","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_maxApproveFail","type":"bool"}],"name":"setMaxApprovalFail","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file diff --git a/src/eth-sdk/config.ts b/src/eth-sdk/config.ts index 9666297..3e33c8e 100644 --- a/src/eth-sdk/config.ts +++ b/src/eth-sdk/config.ts @@ -1,6 +1,10 @@ import { defineConfig } from '@dethcrypto/eth-sdk' export default defineConfig({ + rpc: { + polygonMumbai: 'https://polygon-testnet.public.blastapi.io', + optimism: 'https://mainnet.optimism.io' + }, contracts: { goerli: { dai: '0x11fE4B6AE13d2a6055C8D9cF65c55bac32B5d844', diff --git a/src/hooks/useEthereum.ts b/src/hooks/useEthereum.ts index 950c6d2..2309c4b 100644 --- a/src/hooks/useEthereum.ts +++ b/src/hooks/useEthereum.ts @@ -1,16 +1,28 @@ -import { getGoerliSdk } from '@dethcrypto/eth-sdk-client' -import { useProvider, useSigner } from 'wagmi' +import { getGoerliSdk, getOptimismSdk, getPolygonMumbaiSdk } from '@dethcrypto/eth-sdk-client' +import { useNetwork, useProvider, useSigner } from 'wagmi' export default function useEthereum() { const provider = useProvider() + const { chain } = useNetwork() const { data: signer } = useSigner() const signerOrProvider = signer || provider + const isConnected = !!signerOrProvider - const { dai, allyu } = getGoerliSdk(signerOrProvider) + const goerliSdk = getGoerliSdk(signerOrProvider) + const optimismSdk = getOptimismSdk(signerOrProvider) + const polygonMumbaiSdk = getPolygonMumbaiSdk(signerOrProvider) + + const sdk = chain?.id + ? { + [5]: goerliSdk, + [10]: optimismSdk, + [80001]: polygonMumbaiSdk + }[chain.id] || goerliSdk + : goerliSdk return { - isConnected: !!signerOrProvider, - dai, - allyu + isConnected, + dai: sdk.dai, + allyu: sdk.allyu } } diff --git a/src/pages/bill/[id].tsx b/src/pages/bill/[id].tsx index cd57a52..6e14960 100644 --- a/src/pages/bill/[id].tsx +++ b/src/pages/bill/[id].tsx @@ -5,6 +5,7 @@ import Image from 'next/image' import { useRouter } from 'next/router' import { useEffect, useState } from 'react' import { getBillImage } from 'utils/images' +import { useProvider } from 'wagmi' import FundModal from '../../components/bill/FundModal' import RedeemModal from '../../components/bill/RedeemModal' import Button from '../../components/ui/Button' @@ -20,6 +21,7 @@ const BillPage: NextPage = () => { const [isFundModalOpen, setIsFundModalOpen] = useState(false) const [error, setError] = useState(null) const [isLoading, setIsLoading] = useState(true) + const provider = useProvider() useEffect(() => { const fetch = async () => { @@ -114,7 +116,9 @@ const BillPage: NextPage = () => {
- bill + {bill.value && ( + bill + )}