Skip to content

Commit

Permalink
Merge branch 'dev' into feat/price-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKheops committed Dec 10, 2024
2 parents 5b25914 + 9880d9f commit 6bc2496
Show file tree
Hide file tree
Showing 147 changed files with 3,067 additions and 1,743 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-wombats-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@talismn/balances": patch
---

rename "direct staking" => "delegated staking"
5 changes: 5 additions & 0 deletions .changeset/loud-maps-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@talismn/util": patch
---

added formatTokenDecimals util fn
5 changes: 5 additions & 0 deletions .changeset/slimy-moons-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@talismn/chaindata-provider": patch
---

Update init data
5 changes: 4 additions & 1 deletion apps/extension/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# TEST_MNEMONIC=blarg blarg blarg blarg blarg blarg blarg blarg blarg blarg blarg blarg

# for dev only, Coingecko api settings
# # with a paid api key, use url https://pro-api.coingecko.com
# # with a paid api key, use url https://pro-api.coingecko.com
# COINGECKO_API_URL=https://api.coingecko.com
# # with a paid api key, use header name x-cg-pro-api-key
# COINGECKO_API_KEY_NAME=x-cg-demo-api-key
Expand All @@ -25,3 +25,6 @@
# Talisman core dev team setup for tx analysis :
# BLOWFISH_API_KEY=<PASSWORD_FOR_DEVMODE>
# BLOWFISH_QA_API_KEY=<PASSWORD_FOR_QA_BUILDS> # optional : only used for canary, ci & qa builds

# TAOSTATS_BASE_PATH=https://taostats-api-proxy.talismn.workers.dev
# TAOSTATS_API_KEY=<YOUR_OWN_API_KEY>
2 changes: 1 addition & 1 deletion apps/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "extension",
"version": "2.1.1",
"version": "2.2.0",
"private": true,
"license": "GPL-3.0-or-later",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { classNames } from "@talismn/util"
import React, { MouseEvent, TouchEvent, useEffect, useRef, useState } from "react"

type ScrollContainerDraggableHorizontalProps = {
children?: React.ReactNode
className?: string
}

export const ScrollContainerDraggableHorizontal = ({
children,
className,
}: ScrollContainerDraggableHorizontalProps) => {
const containerRef = useRef<HTMLDivElement>(null)

// State to track dragging
const [isDragging, setIsDragging] = useState<boolean>(false)
const [startPosition, setStartPosition] = useState<number>(0)
const [scrollLeft, setScrollLeft] = useState<number>(0)

// State to track if there's more content to the left or right
const [more, setMore] = useState<{ left: boolean; right: boolean }>({
left: false,
right: false,
})

useEffect(() => {
const scrollable = containerRef.current
if (!scrollable) return

const handleDetectScroll = () => {
setMore({
left: scrollable.scrollLeft > 0,
right: scrollable.scrollWidth - scrollable.scrollLeft > scrollable.clientWidth,
})
}

// Attach event listeners
scrollable.addEventListener("scroll", handleDetectScroll)
window.addEventListener("resize", handleDetectScroll)

// Initial detection
handleDetectScroll()

// Fix for initial load when scrollWidth might not be calculated yet
setTimeout(handleDetectScroll, 50)

// Cleanup
return () => {
scrollable.removeEventListener("scroll", handleDetectScroll)
window.removeEventListener("resize", handleDetectScroll)
}
}, [])

const handleDragStart = (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => {
e.preventDefault()
setIsDragging(true)
containerRef.current?.classList.add("cursor-grabbing")
const pageX = "touches" in e ? e.touches[0].pageX : e.pageX
setStartPosition(pageX)
setScrollLeft(containerRef.current?.scrollLeft || 0)
}

const handleDragEnd = () => {
setIsDragging(false)
containerRef.current?.classList.remove("cursor-grabbing")
}

const handleDragMove = (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => {
if (!isDragging) return
e.preventDefault()
const pageX = "touches" in e ? e.touches[0].pageX : e.pageX
const distance = pageX - startPosition
if (containerRef.current) {
containerRef.current.scrollLeft = scrollLeft - distance
}
}

return (
<div className="relative z-0 overflow-hidden">
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
<div
ref={containerRef}
className={classNames(
"no-scrollbar flex cursor-grab select-none overflow-x-auto",
className,
)}
onMouseDown={handleDragStart}
onMouseUp={handleDragEnd}
onMouseLeave={handleDragEnd}
onMouseMove={handleDragMove}
onTouchStart={handleDragStart}
onTouchEnd={handleDragEnd}
onTouchMove={handleDragMove}
>
{children}
</div>
{/* Left gradient overlay */}
<div
className={`pointer-events-none absolute left-0 top-0 h-full w-12 bg-gradient-to-r from-black to-transparent transition-opacity duration-300 ${
more.left ? "opacity-100" : "opacity-0"
}`}
></div>
{/* Right gradient overlay */}
<div
className={`pointer-events-none absolute right-0 top-0 h-full w-12 bg-gradient-to-l from-black to-transparent transition-opacity duration-300 ${
more.right ? "opacity-100" : "opacity-0"
}`}
></div>
</div>
)
}
4 changes: 2 additions & 2 deletions apps/extension/src/ui/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ export const api: MessageTypes = {
}),

// asset discovery
assetDiscoveryStartScan: (mode, addresses) =>
messageService.sendMessage("pri(assetDiscovery.scan.start)", { mode, addresses }),
assetDiscoveryStartScan: (scope) =>
messageService.sendMessage("pri(assetDiscovery.scan.start)", scope),
assetDiscoveryStopScan: () => messageService.sendMessage("pri(assetDiscovery.scan.stop)", null),

// nfts
Expand Down
6 changes: 3 additions & 3 deletions apps/extension/src/ui/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { KeyringPair$Json } from "@polkadot/keyring/types"
import type { HexString } from "@polkadot/util/types"
import { KeypairType } from "@polkadot/util-crypto/types"
import { Address, BalanceJson } from "@talismn/balances"
import { BalanceJson } from "@talismn/balances"
import {
Chain,
ChainId,
Expand All @@ -25,7 +25,7 @@ import {
AddressesByChain,
AnalyticsCaptureRequest,
AnyEthRequestChainId,
AssetDiscoveryMode,
AssetDiscoveryScanScope,
AssetTransferMethod,
AuthorisedSiteUpdate,
AuthorizedSite,
Expand Down Expand Up @@ -335,7 +335,7 @@ export default interface MessageTypes {
blockHash?: HexString,
) => Promise<MetadataDef | undefined>

assetDiscoveryStartScan: (mode: AssetDiscoveryMode, addresses?: Address[]) => Promise<boolean>
assetDiscoveryStartScan: (scope: AssetDiscoveryScanScope) => Promise<boolean>
assetDiscoveryStopScan: () => Promise<boolean>

nftsSubscribe: (cb: (data: NftData) => void) => UnsubscribeFn
Expand Down
2 changes: 0 additions & 2 deletions apps/extension/src/ui/apps/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { FullScreenLocked } from "@talisman/components/FullScreenLocked"
import { NavigateWithQuery } from "@talisman/components/NavigateWithQuery"
import { SuspenseTracker } from "@talisman/components/SuspenseTracker"
import { api } from "@ui/api"
import { AssetDiscoveryDashboardAlert } from "@ui/domains/AssetDiscovery/AssetDiscoveryDashboardAlert"
import { DatabaseErrorAlert } from "@ui/domains/Settings/DatabaseErrorAlert"
import { useLoginCheck } from "@ui/hooks/useLoginCheck"
import { useModalSubscription } from "@ui/hooks/useModalSubscription"
Expand Down Expand Up @@ -181,7 +180,6 @@ const Dashboard = () => (
<DashboardInner />
</LoginChecker>
<DatabaseErrorAlert container="fullscreen" />
<AssetDiscoveryDashboardAlert />
</PreventPhishing>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { BuyTokensModal } from "@ui/domains/Asset/Buy/BuyTokensModal"
import { CopyAddressModal } from "@ui/domains/CopyAddress"
import { GetStartedModals } from "@ui/domains/Portfolio/GetStarted/GetStartedModals"
import { MigratePasswordModal } from "@ui/domains/Settings/MigratePassword/MigratePasswordModal"
import { NomPoolBondModal } from "@ui/domains/Staking/NomPoolBond/NomPoolBondModal"
import { NomPoolUnbondModal } from "@ui/domains/Staking/NomPoolUnbond/NomPoolUnbondModal"
import { BondModal } from "@ui/domains/Staking/Bond/BondModal"
import { NomPoolWithdrawModal } from "@ui/domains/Staking/NomPoolWithdraw/NomPoolWithdrawModal"
import { UnbondModal } from "@ui/domains/Staking/Unbond/UnbondModal"
import { ExplorerNetworkPickerModal } from "@ui/domains/ViewOnExplorer"

import DashboardNotifications from "."
Expand Down Expand Up @@ -49,8 +49,8 @@ export const DashboardNotificationsAndModals = () => {
<ExplorerNetworkPickerModal />
<MigratePasswordModal />
<OnboardingToast />
<NomPoolBondModal />
<NomPoolUnbondModal />
<BondModal />
<UnbondModal />
<NomPoolWithdrawModal />
<GetStartedModals />
</Suspense>
Expand Down
Loading

0 comments on commit 6bc2496

Please sign in to comment.