-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
21 changed files
with
2,028 additions
and
576 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[workspace] | ||
|
||
resolver = "1" | ||
members = ["src/greeter"] | ||
members = ["src/zkdex"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const address = '5HoA2DXwfuuJHWmbyXjosuzPyMVsiPPxAVEx6nKD5mKUcq7i' | ||
export const blockNumber = 52091772 |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
10 changes: 6 additions & 4 deletions
10
contracts/src/greeter/Cargo.toml → contracts/src/zkdex/Cargo.toml
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
[package] | ||
name = "greeter" | ||
name = "zkdex" | ||
version = "0.0.1" | ||
authors = ["Scio Labs <hello@scio.xyz>"] | ||
authors = ["AE Studio<hello@scio.xyz>"] | ||
edition = "2021" | ||
|
||
[dependencies] | ||
ink = { version = "4.3.0", default-features = false } | ||
ink_prelude = { version = "4.3.0", default-features = false } | ||
openbrush = { version = "4.0.0-beta", default-features = false } | ||
|
||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } | ||
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } | ||
|
||
[lib] | ||
path = "lib.rs" | ||
path = "zkdex.rs" | ||
|
||
[features] | ||
default = ["std"] | ||
std = ["ink/std", "scale/std", "scale-info/std"] | ||
std = ["ink/std", "scale/std", "scale-info/std", "openbrush/std", "ink_prelude/std"] | ||
ink-as-dependency = [] |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
frontend/src/components/web3/zkdex-contract-interactions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
'use client' | ||
|
||
import { FC } from 'react' | ||
|
||
import { ContractIds } from '@/deployments/deployments' | ||
import { | ||
contractQuery, | ||
decodeOutput, | ||
useInkathon, | ||
useRegisteredContract, | ||
} from '@scio-labs/use-inkathon' | ||
import toast from 'react-hot-toast' | ||
|
||
import { contractTxWithToast } from '@/utils/contract-tx-with-toast' | ||
|
||
export const ZKDexContractInteractions: FC = () => { | ||
const { api, activeAccount, activeSigner } = useInkathon() | ||
const { contract, address: contractAddress } = useRegisteredContract(ContractIds.zkdex) | ||
|
||
const fetchAllOrders = async () => { | ||
if (!contract || !api) return | ||
|
||
const result = await contractQuery(api, '', contract, 'get_all_orders') | ||
const { output, isError, decodedOutput } = decodeOutput(result, contract, 'get_all_orders') | ||
if (isError) throw new Error(decodedOutput) | ||
console.log('Get All Orders') | ||
console.log(decodedOutput) | ||
} | ||
|
||
const fetchAllClaimOrders = async () => { | ||
if (!contract || !api) return | ||
|
||
const result = await contractQuery(api, '', contract, 'get_all_orders_claim') | ||
const { output, isError, decodedOutput } = decodeOutput( | ||
result, | ||
contract, | ||
'get_all_orders_claim', | ||
) | ||
if (isError) throw new Error(decodedOutput) | ||
console.log('Get All Claim Orders') | ||
console.log(decodedOutput) | ||
} | ||
|
||
const fetchOrder = async () => { | ||
if (!activeAccount || !contract || !api) return | ||
|
||
const result = await contractQuery(api, activeAccount.address, contract, 'get_order', {}, [0]) | ||
const { output, isError, decodedOutput } = decodeOutput(result, contract, 'get_order') | ||
if (isError) throw new Error(decodedOutput) | ||
console.log('Get Order') | ||
console.log(decodedOutput) | ||
} | ||
|
||
const createOrder = async () => { | ||
if (!activeAccount || !contract || !activeSigner || !api) { | ||
toast.error('Wallet not connected. Try again…') | ||
return | ||
} | ||
|
||
await contractTxWithToast( | ||
api, | ||
activeAccount.address, | ||
contract, | ||
'create_order', | ||
{ | ||
value: 11, | ||
}, | ||
[1, 'test', 'test', 1], | ||
) | ||
} | ||
|
||
const createClaimOrder = async () => { | ||
if (!activeAccount || !contract || !activeSigner || !api) { | ||
toast.error('Wallet not connected. Try again…') | ||
return | ||
} | ||
|
||
await contractTxWithToast( | ||
api, | ||
activeAccount.address, | ||
contract, | ||
'claim_order', | ||
{}, | ||
[0, 1705475714000], | ||
) | ||
} | ||
|
||
if (!api) return null | ||
|
||
return ( | ||
<> | ||
<div className="flex max-w-[22rem] grow flex-col gap-4"> | ||
<h2 className="text-center font-mono text-gray-400">ZKDex Smart Contract</h2> | ||
|
||
<button className="w-sm rounded bg-slate-800" onClick={fetchAllOrders}> | ||
Get All Orders | ||
</button> | ||
<button className="w-sm rounded bg-slate-800" onClick={fetchAllClaimOrders}> | ||
Get All Claim Orders | ||
</button> | ||
<button className="w-sm rounded bg-slate-800" onClick={fetchOrder}> | ||
Get Order | ||
</button> | ||
<button className="w-sm rounded bg-slate-800" onClick={createOrder}> | ||
Create Liquidity Pool | ||
</button> | ||
<button className="w-sm rounded bg-slate-800" onClick={createClaimOrder}> | ||
Claim Liquidity Pool | ||
</button> | ||
|
||
{/* Contract Address */} | ||
<p className="text-center font-mono text-xs text-gray-600"> | ||
{contract ? contractAddress : 'Loading…'} | ||
</p> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters