Skip to content

Commit

Permalink
full end-to-end withdrawal flow working
Browse files Browse the repository at this point in the history
  • Loading branch information
willemolding committed May 16, 2024
1 parent 74071ae commit e2320d6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
6 changes: 3 additions & 3 deletions bridge-frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ init({
rpcUrl: v.rpcUrl,
})),
appMetadata: {
name: "Cartesi Rollups Test DApp",
name: "CarteZcash Testnet",
icon: "<svg><svg/>",
description: "Demo app for Cartesi Rollups",
description: "Cartesi shielded pool using ZCash",
recommendedInjectedWallets: [
{ name: "MetaMask", url: "https://metamask.io" },
],
Expand All @@ -54,7 +54,7 @@ init({

const App: FC = () => {
const [{ connectedChain }] = useSetChain();
const [dappAddress, setDappAddress] = useState<string>("unknown");
const [dappAddress, setDappAddress] = useState<string>(config["0x7a69"].DAppAddress);

const [{ wallet, connecting }, connect] = useConnectWallet();

Expand Down
5 changes: 3 additions & 2 deletions bridge-frontend/src/Vouchers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const Vouchers: React.FC<IVoucherPropos> = (propos) => {
const rollups = useRollups(propos.dappAddress);

const getProof = async (voucher: Voucher) => {
console.log("getProof called with voucher: ",voucher);
setVoucherToFetch([voucher.index,voucher.input.index]);
reexecuteVoucherQuery({ requestPolicy: 'network-only' });
};
Expand All @@ -59,6 +60,7 @@ export const Vouchers: React.FC<IVoucherPropos> = (propos) => {

const newVoucherToExecute = {...voucher};
try {
console.log("calling execute voucher with voucher: ",voucher);
const tx = await rollups.dappContract.executeVoucher( voucher.destination,voucher.payload,voucher.proof);
const receipt = await tx.wait();
newVoucherToExecute.msg = `voucher executed! (tx="${tx.hash}")`;
Expand Down Expand Up @@ -219,7 +221,6 @@ export const Vouchers: React.FC<IVoucherPropos> = (propos) => {
{/* <td>{voucherToExecute.proof}</td> */}
{/* <Td>{voucherToExecute.input.payload}</Td> */}
{/* <Td>{voucherToExecute.msg}</Td> */}
<br /> <br />
</Tr>
</Tbody>
</Table> : <Text></Text>}
Expand Down Expand Up @@ -247,7 +248,7 @@ export const Vouchers: React.FC<IVoucherPropos> = (propos) => {
<Td>{n.index}</Td>
<Td>{n.destination}</Td> */}
<Td>
<Button size='sm' onClick={() => getProof(n)}>Info</Button>
<Button size='sm' onClick={() => getProof(n)}>Show Detail</Button>
</Td>
{/* <td>{n.input.payload}</td> */}
<Td color={'grey'}>{n.payload}</Td>
Expand Down
8 changes: 4 additions & 4 deletions bridge-frontend/src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@
"rpcUrl": "http://localhost:8545",
"graphqlAPIURL" : "http://localhost:8080",
"inspectAPIURL":"http://localhost:8080",
"RollupExitAddress": "u1k7ant55p6u5lgwhf9ss4qurcz35pjeav398lw0e0xmqqdm0aksvhrpa2gtnmv83lggean4pm8n7tgtr9ssnrpevkyrgw9y5e4ck23j6g",
"DAppRelayAddress":"0xF5DE34d6BbC0446E2a45719E718efEbaaE179daE",
"InputBoxAddress":"0x59b22D57D4f067708AB0c00552767405926dc768",
"EtherPortalAddress":"0xFfdbe43d4c855BF7e0f105c400A50857f53AB044",
"Erc20PortalAddress":"0x9C21AEb2093C32DDbC53eEF24B873BDCd1aDa1DB",
"Erc721PortalAddress":"0x237F8DD094C0e47f4236f12b4Fa01d6Dae89fb87",
"Erc1155SinglePortalAddress":"0x7CFB0193Ca87eB6e48056885E026552c3A941FC4",
"Erc1155BatchPortalAddress":"0xedB53860A6B52bbb7561Ad596416ee9965B055Aa",
"RollupExitAddress": "t1Hsc1LR8yKnbbe3twRp88p6vFfC5t7DLbs",
"DAppAddress": "0x237F8DD094C0e47f4236f12b4Fa01d6Dae89fb87"
"DAppAddress": "0xab7528bb862fB57E8A2BCd567a2e929a0Be56a5e"
},
"0xaa36a7":{
"token": "SepETH",
"label": "Sepolia Test Network",
"rpcUrl": "https://eth-goerli.g.alchemy.com/v2/demo",
"graphqlAPIURL" : "https://cartezcash.fly.dev",
"inspectAPIURL":"https://cartezcash.fly.dev",
"RollupExitAddress": "u1k7ant55p6u5lgwhf9ss4qurcz35pjeav398lw0e0xmqqdm0aksvhrpa2gtnmv83lggean4pm8n7tgtr9ssnrpevkyrgw9y5e4ck23j6g",
"DAppRelayAddress":"0xF5DE34d6BbC0446E2a45719E718efEbaaE179daE",
"InputBoxAddress":"0x59b22D57D4f067708AB0c00552767405926dc768",
"EtherPortalAddress":"0xFfdbe43d4c855BF7e0f105c400A50857f53AB044",
"Erc20PortalAddress":"0x9C21AEb2093C32DDbC53eEF24B873BDCd1aDa1DB",
"Erc721PortalAddress":"0x237F8DD094C0e47f4236f12b4Fa01d6Dae89fb87",
"Erc1155SinglePortalAddress":"0x7CFB0193Ca87eB6e48056885E026552c3A941FC4",
"Erc1155BatchPortalAddress":"0xedB53860A6B52bbb7561Ad596416ee9965B055Aa",
"RollupExitAddress": "t1Hsc1LR8yKnbbe3twRp88p6vFfC5t7DLbs",
"DAppAddress": "0x237F8DD094C0e47f4236f12b4Fa01d6Dae89fb87"
"DAppAddress": "0xab7528bb862fB57E8A2BCd567a2e929a0Be56a5e"
}
}
1 change: 1 addition & 0 deletions bridge-frontend/src/useRollups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export const useRollups = (dAddress: string): RollupsContracts | undefined => {
alert(`No erc1155 batch portal address defined for chain ${chain.id}`);
}
// dapp contract
console.log("dappAddress", dappAddress);
const dappContract = CartesiDApp__factory.connect(dappAddress, signer);

// relay contract
Expand Down
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ run-fullnode:
cargo run --no-default-features --features listen-graphql,lightwalletd

sunodo-nobackend:
sunodo run --no-backend
sunodo run --no-backend --epoch-duration=10

##### Docker

Expand All @@ -36,7 +36,7 @@ run-fullnode-docker:
execute_voucher:
cast send 0xab7528bb862fB57E8A2BCd567a2e929a0Be56a5e "executeVoucher(address, bytes, struct Proof _proof)"

send_address:
send-address:
sunodo send dapp-address --rpc-url=http://127.0.0.1:8545 --chain-id=31337 --dapp=0xab7528bb862fB57E8A2BCd567a2e929a0Be56a5e

##### wallet related commands
Expand Down
5 changes: 4 additions & 1 deletion src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ impl From<tiny_cash::service::Response> for Response {
.burns
.iter()
.map(|(amount, memo)| {
let addres_bytes = hex::decode(&memo.0[0..40]) // expect unicode hex no 0x prefix (inefficient). skip the version byte at the start
.expect("failed to decode memo");

(
ethereum_types::Address::from_slice(&memo.0[..20]),
ethereum_types::Address::from_slice(&addres_bytes),
ethereum_types::U256::from(amount.zatoshis()),
)
})
Expand Down

0 comments on commit e2320d6

Please sign in to comment.