Skip to content

Commit

Permalink
feat: transfers page
Browse files Browse the repository at this point in the history
  • Loading branch information
o-az authored and cor committed Jun 8, 2024
1 parent 4db0084 commit baf4d7c
Show file tree
Hide file tree
Showing 16 changed files with 83 additions and 97 deletions.
6 changes: 3 additions & 3 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"graphql-request": "^7.0.1",
"mode-watcher": "^0.3.0",
"paneforge": "^0.0.4",
"svelte-french-toast": "^1.2.0",
"svelte-legos": "^0.2.3",
"svelte-persisted-store": "^0.11.0",
"svelte-radix": "^1.1.0",
"svelte-ux": "^0.66.5",
"svelte-sonner": "^0.3.24",
"svelte-ux": "^0.66.3",
"sveltekit-superforms": "^2.14.0",
"uint8array-extras": "^1.1.0",
"valibot": "^0.31.0",
Expand Down Expand Up @@ -93,7 +93,7 @@
"tailwindcss": "^3.4.4",
"tailwindcss-animate": "^1.0.7",
"tslib": "^2.6.3",
"tsx": "^4.12.0",
"tsx": "^4.11.2",
"typed-query-selector": "^2.11.2",
"typescript": "^5.4.5",
"unplugin-icons": "^0.19.0",
Expand Down
1 change: 1 addition & 0 deletions app/src/lib/components/ui/sonner/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Toaster } from "./sonner.svelte"
20 changes: 20 additions & 0 deletions app/src/lib/components/ui/sonner/sonner.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script lang="ts">
import { Toaster as Sonner, type ToasterProps as SonnerProps } from "svelte-sonner";
import { mode } from "mode-watcher";
type $$Props = SonnerProps;
</script>

<Sonner
theme={$mode}
class="toaster group"
toastOptions={{
classes: {
toast: "group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
description: "group-[.toast]:text-muted-foreground",
actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
cancelButton: "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
},
}}
{...$$restProps}
/>
61 changes: 18 additions & 43 deletions app/src/lib/graphql/documents/ibc-transfers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export const ibcTransfersQuery = graphql(/* GraphQL */ `
$unionAddress: String
$nonUnionAddress: String
) {
v0_cosmos_wasm_ibc_transfer(
data: v0_transfers(
limit: $limit
order_by: { height: desc }
order_by: { source_time: desc }
where: {
_or: [
{
Expand All @@ -26,48 +26,23 @@ export const ibcTransfersQuery = graphql(/* GraphQL */ `
]
}
) {
height
time
json
memo
chain_id
transaction_hash
}
}
`)
source_time
source_height
source_chain_id
source_transaction_hash
source_channel
source_sequence
source_timeout_timestamp
source_transaction_index
export const ibcTransfersSubscription = graphql(/* GraphQL */ `
subscription IBCTransfersSubscription(
$limit: Int! = 100
$unionAddress: String
$nonUnionAddress: String
) {
v0_cosmos_wasm_ibc_transfer(
limit: $limit
order_by: { height: desc }
where: {
_or: [
{
_or: [
{ sender: { _eq: $unionAddress } }
{ receiver: { _eq: $unionAddress } }
]
}
{
_or: [
{ sender: { _eq: $nonUnionAddress } }
{ receiver: { _eq: $nonUnionAddress } }
]
}
]
}
) {
height
time
json
memo
chain_id
transaction_hash
destination_time
destination_height
destination_chain_id
destination_transaction_hash
destination_channel
destination_sequence
destination_timeout_timestamp
destination_transaction_index
}
}
`)
2 changes: 1 addition & 1 deletion app/src/lib/online-status.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import toast from "svelte-french-toast"
import {toast} from "svelte-sonner"
import { readable, type Readable } from "svelte/store"
import { onlineManager } from "@tanstack/svelte-query"

Expand Down
27 changes: 0 additions & 27 deletions app/src/lib/wallet/web3-modal.ts

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import "$styles/index.css"
import { onMount } from "svelte"
import { ModeWatcher } from "mode-watcher"
import { browser } from "$app/environment"
import { Toaster } from "svelte-french-toast"
import { onNavigate } from "$app/navigation"
import { page, navigating } from "$app/stores"
import { shortcut } from "@svelte-put/shortcut"
import { cosmosStore } from "$lib/wallet/cosmos"
import Footer from "$lib/components/footer.svelte"
import { Toaster } from "$lib/components/ui/sonner"
import Header from "$lib/components/header/header.svelte"
import { updateTheme } from "$lib/utilities/update-theme.ts"
import OnlineStatus from "$lib/components/online-status.svelte"
Expand Down
10 changes: 5 additions & 5 deletions app/src/routes/faucet/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<script lang="ts">
import toast from "svelte-french-toast"
import { toast } from "svelte-sonner"
import { cn } from "$lib/utilities/shadcn.ts"
import { debounce } from "$lib/utilities/index.ts"
import LockLockedIcon from "virtual:icons/lucide/lock"
import { valibot } from "sveltekit-superforms/adapters"
import * as Form from "$lib/components/ui/form/index.ts"
import * as Card from "$lib/components/ui/card/index.ts"
import { Input } from "$lib/components/ui/input/index.ts"
import LockOpenIcon from "virtual:icons/lucide/lock-open"
import { superForm, defaults } from "sveltekit-superforms"
Expand All @@ -18,7 +19,6 @@ import ExternalLinkIcon from "virtual:icons/lucide/external-link"
import { faucetFormSchema, unionAddressRegex } from "./schema.ts"
import { Separator } from "$lib/components/ui/separator/index.ts"
import { isValidCosmosAddress } from "$/lib/wallet/utilities/validate.ts"
import * as Card from "$lib/components/ui/card/index.ts"
const debounceDelay = 3_500
let submissionStatus: "idle" | "submitting" | "submitted" | "error" = "idle"
Expand All @@ -27,7 +27,7 @@ $: {
if (submissionStatus === "submitting") {
toast.loading("Submitting faucet request 🚰", {
duration: debounceDelay - 300,
className: "text-sm p-2.5"
class: "text-sm p-2.5"
})
}
}
Expand Down Expand Up @@ -62,12 +62,12 @@ const superFormResults = superForm(
debounce(() => {
if (!event.form.valid) {
$errors.address = event.form.errors.address
return toast.error("No good", { className: "font-mono text-lg" })
return toast.error("No good", { class: "font-mono text-lg" })
}
toast.success("Faucet request submitted 🤌 Check wallet for $U in a few moments", {
duration: 5_000,
className: "text-sm p-2.5"
class: "text-sm p-2.5"
})
}, debounceDelay)(),
delayMs: 7_500,
Expand Down
2 changes: 1 addition & 1 deletion app/src/routes/transfer/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { onMount } from "svelte"
import { page } from "$app/stores"
import toast from "svelte-french-toast"
import { toast } from "svelte-sonner"
import { debounce } from "$lib/utilities"
import { UnionClient } from "@union/client"
import type { PageData } from "./$types.ts"
Expand Down
Binary file modified typescript-sdk/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion typescript-sdk/jsr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://jsr.io/schema/config-file.v1.json",
"exports": "./src/mod.ts",
"name": "@union/client",
"version": "0.0.1-rc.10",
"version": "0.0.1-rc.11",
"publish": {
"include": ["./src/**/*.ts", "./jsr.json"]
}
Expand Down
6 changes: 3 additions & 3 deletions typescript-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@cosmjs/encoding": "^0.32.3",
"@cosmjs/stargate": "0.32.3",
"@cosmjs/tendermint-rpc": "0.32.3",
"viem": "^2.13.1"
"viem": "^2.13.3"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.15.3",
Expand All @@ -29,11 +29,11 @@
"@scure/base": "^1.1.6",
"@total-typescript/ts-reset": "^0.5.1",
"@types/bun": "^1.1.3",
"@types/node": "^20.12.13",
"@types/node": "^20.14.0",
"consola": "^3.2.3",
"cosmjs-types": "^0.9.0",
"patch-package": "^8.0.0",
"tsx": "^4.11.0",
"tsx": "^4.11.2",
"typescript": "^5.4.5",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
Expand Down
22 changes: 16 additions & 6 deletions typescript-sdk/scripts/sepolia-to-union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { sepolia } from "viem/chains"
import { parseArgs } from "node:util"
import { UnionClient } from "#/mod.ts"
import { privateKeyToAccount } from "viem/accounts"
import { http, erc20Abi, publicActions, createWalletClient } from "viem"

import { http, erc20Abi, publicActions, createWalletClient, fallback } from "viem"
import { ucs01RelayAbi } from "#/abi"
import { unionToEvmAddress } from "#/convert"
import { CHAINS } from "#/constants/testnet"
/* `bun scripts/sepolia-to-union.ts --private-key "..."` */

const { values } = parseArgs({
Expand All @@ -20,7 +22,14 @@ const evmAccount = privateKeyToAccount(`0x${PRIVATE_KEY}`)
const evmSigner = createWalletClient({
chain: sepolia,
account: evmAccount,
transport: http(`https://eth-sepolia.g.alchemy.com/v2/SQAcneXzJzITjplR7cwQhFUqF-SU-ds4`)
// transport: http(`https://eth-sepolia.g.alchemy.com/v2/SQAcneXzJzITjplR7cwQhFUqF-SU-ds4`)
// transport: http(`https://rpc2.sepolia.org`)
transport: fallback([
http(`https://rpc2.sepolia.org`)
// http(
// `https://special-summer-film.ethereum-sepolia.quiknode.pro/3e6a917b56620f854de771c23f8f7a8ed973cf7e/`
// )
])
}).extend(publicActions)

const unionClient = await UnionClient.connectWithSecret({
Expand All @@ -44,7 +53,7 @@ const approve = await evmSigner.writeContract({
functionName: "approve",
chain: sepolia,
args: [
"0x3d0eb16ad2619666dbde1921282cd885b58eeefe", // spender - SEPOLIA_UCS01_ADDRESS
"0xD0081080Ae8493cf7340458Eaf4412030df5FEEb",
10n // amount
]
})
Expand All @@ -56,8 +65,9 @@ const linkFromSepoliaToUnion = await unionClient.transferEvmAsset({
receiver: "union14qemq0vw6y3gc3u3e0aty2e764u4gs5lnxk4rv",
denomAddress: LINK_CONTRACT_ADDRESS,
amount: 1n,
sourceChannel: "channel-8",
contractAddress: "0x3d0eb16ad2619666dbde1921282cd885b58eeefe", // SEPOLIA_UCS01_ADDRESS
sourceChannel: "channel-1",
contractAddress: "0xD0081080Ae8493cf7340458Eaf4412030df5FEEb",
simulate: true
})

console.log(linkFromSepoliaToUnion)
9 changes: 7 additions & 2 deletions typescript-sdk/src/constants/testnet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
export const TESTNET_CHAINS = {
sepolia: "11155111",
import contracts from '~root/versions/contracts.json'

export const CHAINS = {
sepolia: {
chainId: "11155111",
contracts: contracts[0]?.sepolia
},
osmosis: "osmo-test-5",
stargaze: "elgafar-1"
}
5 changes: 2 additions & 3 deletions typescript-sdk/src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,8 @@ export class UnionClient implements IUnionClient {
sourceChannel,
unionToEvmAddress(receiver),
[{ denom: denomAddress, amount }],
{ revision_number: 9n, revision_height: 10_000_000_000n },
// BigInt(Date.now()) + 7n * 24n * 60n * 60n * 1000n // now + 7 days
999_999_999_999_999n
{ revision_number: 9n, revision_height: 9999999999n },
0n
]
} as const
if (!simulate) return await signer.writeContract(writeContractParameters)
Expand Down
5 changes: 4 additions & 1 deletion typescript-sdk/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"noPropertyAccessFromIndexSignature": true,
"types": ["node", "bun"],
"paths": {
"#/*": ["src/*"]
"#/*": ["src/*"],
"~root/*": [
"../*"
],
}
},
"include": ["src", "scripts", "test"],
Expand Down

0 comments on commit baf4d7c

Please sign in to comment.