Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/convert-viem-chain-fn-declaration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@relayprotocol/relay-sdk': patch
'@relayprotocol/relay-kit-ui': patch
'@relayprotocol/relay-kit-hooks': patch
'@relayprotocol/relay-bitcoin-wallet-adapter': patch
'@relayprotocol/relay-ethers-wallet-adapter': patch
'@relayprotocol/relay-lighter-wallet-adapter': patch
'@relayprotocol/relay-svm-wallet-adapter': patch
'@relayprotocol/relay-tron-wallet-adapter': patch
---

Convert exported arrow-function consts to function declarations across all packages (no behavior change).
4 changes: 2 additions & 2 deletions packages/hooks/src/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const fetcher = async (url: string, headers?: HeadersInit) => {

export default fetcher

export const axiosPostFetcher = async (
export async function axiosPostFetcher(
url: string,
params: any,
config?: AxiosRequestConfig
) => {
) {
const { data } = await axios.post(url, params, config)
return data
}
4 changes: 2 additions & 2 deletions packages/relay-bitcoin-wallet-adapter/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ type DynamicSignPsbtParams = {
}>
}

export const adaptBitcoinWallet = (
export function adaptBitcoinWallet(
walletAddress: string,
signPsbt: (
address: string,
psbt: bitcoin.Psbt,
dynamicParams: DynamicSignPsbtParams
) => Promise<string>,
publicKey?: string
): AdaptedWallet => {
): AdaptedWallet {
return {
vmType: 'bvm',
getChainId: async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/relay-ethers-wallet-adapter/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import {
type HttpTransport
} from 'viem'

export const adaptEthersSigner = (
export function adaptEthersSigner(
signer: Signer,
transport?: CustomTransport | HttpTransport
): AdaptedWallet => {
): AdaptedWallet {
return {
vmType: 'evm',
transport,
Expand Down
4 changes: 2 additions & 2 deletions packages/relay-lighter-wallet-adapter/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ export type AdaptLighterWalletOptions =
* dependency on `@relay-protocol/lighter-ts-sdk`.
*
*/
export const adaptLighterWallet = (
export function adaptLighterWallet(
options: AdaptLighterWalletOptions
): AdaptedWallet => {
): AdaptedWallet {
const {
l1Address,
signL1Message,
Expand Down
4 changes: 2 additions & 2 deletions packages/relay-svm-wallet-adapter/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const assertBase58TransactionSignature = (
* @param payerKey - Optional public key of the account that will pay for transaction fees (defaults to walletAddress)
* @returns An AdaptedWallet object that conforms to the Relay SDK interface
*/
export const adaptSolanaWallet = (
export function adaptSolanaWallet(
walletAddress: string,
chainId: number,
connection: Connection,
Expand All @@ -51,7 +51,7 @@ export const adaptSolanaWallet = (
signature: TransactionSignature
}>,
payerKey?: string
): AdaptedWallet => {
): AdaptedWallet {
let _chainId = chainId
const getChainId = async () => {
return _chainId
Expand Down
4 changes: 2 additions & 2 deletions packages/relay-tron-wallet-adapter/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import type { TriggerSmartContractResponse } from './types.js'
* @param tronWeb - The TronWeb instance for interacting with the Tron network
* @returns An AdaptedWallet object that conforms to the Relay SDK interface
*/
export const adaptTronWallet = (
export function adaptTronWallet(
walletAddress: string,
tronWeb: TronWeb
): AdaptedWallet => {
): AdaptedWallet {
const getChainId = async () => {
return 728126428
}
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/chain-utils/configureViemChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const viemChainMap = Object.values(viemChains).reduce(
{} as Record<number, Chain>
)

export const configureViemChain = (
export function configureViemChain(
chain: RelayAPIChain
): RelayChain & Required<Pick<RelayChain, 'viemChain'>> => {
): RelayChain & Required<Pick<RelayChain, 'viemChain'>> {
let viemChain: Chain
const overriddenChains = [999, 1337]
const staticChain = overriddenChains.includes(chain.id)
Expand Down
5 changes: 2 additions & 3 deletions packages/sdk/src/chain-utils/fetchChainConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import type { RelayChain } from '../types/index.js'
import { axios } from '../utils/axios.js'
import { isRelayApiUrl } from '../utils/apiKey.js'

export const fetchChainConfigs = async (
export async function fetchChainConfigs(
baseApiUrl: string,
referrer?: string,
apiKey?: string
): Promise<RelayChain[]> => {
): Promise<RelayChain[]> {
let queryString = ''
if (referrer) {
const queryParams = new URLSearchParams()
Expand All @@ -28,4 +28,3 @@ export const fetchChainConfigs = async (
}
throw 'No Chain Data'
}

4 changes: 2 additions & 2 deletions packages/sdk/src/constants/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const tonDeadAddress =
const eclipseId = 9286185
const zeroChainId = 543210

export const getDeadAddress = (vmType?: ChainVM, chainId?: number) => {
export function getDeadAddress(vmType?: ChainVM, chainId?: number) {
if (vmType === 'svm') {
return chainId === eclipseId ? eclipseDeadAddress : solDeadAddress
} else if (vmType === 'bvm') {
Expand All @@ -31,7 +31,7 @@ export const getDeadAddress = (vmType?: ChainVM, chainId?: number) => {
}
}

export const isDeadAddress = (address?: string) => {
export function isDeadAddress(address?: string) {
if (!address) {
return false
}
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/utils/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export type RelayAPIChain = Required<
>['0']
>

export const convertViemChainToRelayChain = (
export function convertViemChainToRelayChain(
chain: Chain
): RelayChain & Required<Pick<RelayChain, 'viemChain'>> => {
): RelayChain & Required<Pick<RelayChain, 'viemChain'>> {
return {
id: chain.id,
name: chain.name.replace(' ', '-'),
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/utils/getCurrentStepData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Execute } from '../types/index.js'

export const getCurrentStepData = (steps: Execute['steps']) => {
export function getCurrentStepData(steps: Execute['steps']) {
let currentStep: NonNullable<Execute['steps']>['0'] | null = null
let currentStepItem: NonNullable<Execute['steps'][0]['items']>[0] | undefined
let txHashes: { txHash: string; chainId: number }[] = []
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/utils/getTenderlyDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ export type TenderlyErrorInfo = {
error?: string
}

export const getTenderlyDetails = (
export function getTenderlyDetails(
chainId: number,
txHash: string
): Promise<TenderlyErrorInfo | null> => {
): Promise<TenderlyErrorInfo | null> {
return new Promise((resolve) => {
axios
.get(
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export enum LogLevel {
None = 0
}

export const log = (params: any[], level: LogLevel, currentLevel: LogLevel) => {
export function log(params: any[], level: LogLevel, currentLevel: LogLevel) {
if (currentLevel >= level) {
const data = params.reduce((params, param, i) => {
if ((i + 1) % 2) {
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/utils/viemWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export type AdaptViemWalletOptions = {
disableCapabilitiesCheck?: boolean
}

export const adaptViemWallet = (
export function adaptViemWallet(
wallet: WalletClient,
options: AdaptViemWalletOptions = {}
): AdaptedWallet => {
): AdaptedWallet {
const { disableCapabilitiesCheck } = options
return {
vmType: 'evm',
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/utils/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface TrackRequestStatusOptions<E extends WebSocketEvent> {
}

// @TODO: remove once requestId gets added to top level of quote response
export const extractDepositRequestId = (steps?: Execute['steps'] | null) => {
export function extractDepositRequestId(steps?: Execute['steps'] | null) {
if (!steps?.length) return null

// Find the first step that has a requestId
Expand Down
5 changes: 2 additions & 3 deletions packages/ui/src/components/common/BalanceDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { FC } from 'react'
import { Flex, Skeleton, Text } from '../primitives/index.js'
import { formatBN } from '../../utils/numbers.js'

Expand All @@ -15,7 +14,7 @@ type BalanceDisplayProps = {
size?: 'sm' | 'md'
}

export const BalanceDisplay: FC<BalanceDisplayProps> = ({
export function BalanceDisplay({
balance,
decimals,
symbol,
Expand All @@ -26,7 +25,7 @@ export const BalanceDisplay: FC<BalanceDisplayProps> = ({
pending,
hideBalanceLabel = false,
size = 'sm'
}) => {
}: BalanceDisplayProps) {
const compactBalance = Boolean(
balance && decimals && balance.toString().length - decimals > 4
)
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/common/CopyToClipBoard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type FC, useState } from 'react'
import { useState } from 'react'
import { Button, Text } from '../primitives/index.js'
import Tooltip from '../primitives/Tooltip.js'
import { useCopyToClipboard } from 'usehooks-ts'
Expand All @@ -10,7 +10,7 @@ type CopyToClipBoardProps = {
text: string
}

export const CopyToClipBoard: FC<CopyToClipBoardProps> = ({ text }) => {
export function CopyToClipBoard({ text }: CopyToClipBoardProps) {
const [value, copy] = useCopyToClipboard()
const [isCopied, setIsCopied] = useState(false)
const [open, setOpen] = useState(false)
Expand Down
10 changes: 4 additions & 6 deletions packages/ui/src/components/common/CustomAddressModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type FC, useState, useEffect, useMemo, useContext } from 'react'
import { useState, useEffect, useMemo, useContext } from 'react'
import { Text, Flex, Button, Input, Pill } from '../primitives/index.js'
import { Modal } from '../common/Modal.js'
import { type Address, isAddress } from 'viem'
Expand Down Expand Up @@ -46,7 +46,7 @@ type Props = {
onClear: () => void
}

export const CustomAddressModal: FC<Props> = ({
export function CustomAddressModal({
open,
toAddress,
toChain,
Expand All @@ -58,7 +58,7 @@ export const CustomAddressModal: FC<Props> = ({
onOpenChange,
onConfirmed,
onClear
}) => {
}: Props) {
const haptic = useHapticEvent()
const connectedAddress = useWalletAddress(wallet, linkedWallets)
const [address, setAddress] = useState('')
Expand Down Expand Up @@ -182,9 +182,7 @@ export const CustomAddressModal: FC<Props> = ({
>
<Text style="h6">To Address</Text>
<Flex direction="column" className="relay:gap-2 relay:relative">
<Flex
className="relay:relative relay:w-full"
>
<Flex className="relay:relative relay:w-full">
<Input
type="text"
inputMode="text"
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/common/LoadingSpinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const SpinnerSVG: FC<SVGProps<SVGSVGElement>> = (props) => {
)
}

export const LoadingSpinner: FC<{ className?: string }> = ({ className }) => {
export function LoadingSpinner({ className }: { className?: string }) {
const providerOptionsContext = useContext(ProviderOptionsContext)
if (providerOptionsContext.loader) {
return (
Expand Down
36 changes: 23 additions & 13 deletions packages/ui/src/components/common/MultiWalletDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useMemo, useState, type FC } from 'react'
import { useContext, useMemo, useState } from 'react'
import { Dropdown, DropdownMenuItem } from '../primitives/Dropdown.js'
import { Box, Button, Flex, Text } from '../primitives/index.js'
import type { LinkedWallet } from '../../types/index.js'
Expand Down Expand Up @@ -32,7 +32,7 @@ type MultiWalletDropdownProps = {
disableWalletFiltering?: boolean
}

export const MultiWalletDropdown: FC<MultiWalletDropdownProps> = ({
export function MultiWalletDropdown({
context,
wallets,
selectedWalletAddress,
Expand All @@ -44,7 +44,7 @@ export const MultiWalletDropdown: FC<MultiWalletDropdownProps> = ({
onLinkNewWallet,
setAddressModalOpen,
disableWalletFiltering = false
}) => {
}: MultiWalletDropdownProps) {
const [open, setOpen] = useState(false)
const providerOptionsContext = useContext(ProviderOptionsContext)
const connectorKeyOverrides = providerOptionsContext.vmConnectorKeyOverrides
Expand Down Expand Up @@ -157,7 +157,10 @@ export const MultiWalletDropdown: FC<MultiWalletDropdownProps> = ({
className="relay:gap-2 relay:!px-2 relay:py-1 relay:cursor-pointer relay:flex relay:content-center"
data-testid={testId}
>
<Flex align="center" className="relay:gap-1 relay:shrink relay:min-w-0">
<Flex
align="center"
className="relay:gap-1 relay:shrink relay:min-w-0"
>
{isSupportedSelectedWallet && selectedWallet?.walletLogoUrl ? (
<img
src={selectedWallet.walletLogoUrl}
Expand All @@ -172,11 +175,14 @@ export const MultiWalletDropdown: FC<MultiWalletDropdownProps> = ({
style="subtitle2"
className="relay:whitespace-nowrap relay:overflow-hidden relay:text-ellipsis"
>
<span style={{
color: !selectedWallet && selectedWalletAddress
? 'var(--relay-colors-amber11)'
: 'var(--relay-colors-primary11)'
}}>
<span
style={{
color:
!selectedWallet && selectedWalletAddress
? 'var(--relay-colors-amber11)'
: 'var(--relay-colors-primary11)'
}}
>
{isSupportedSelectedWallet &&
selectedWalletAddress &&
selectedWalletAddress != ''
Expand All @@ -191,9 +197,10 @@ export const MultiWalletDropdown: FC<MultiWalletDropdownProps> = ({
<div
className="relay:shrink-0"
style={{
color: !selectedWallet && selectedWalletAddress
? 'var(--relay-colors-amber11)'
: 'var(--relay-colors-primary11)'
color:
!selectedWallet && selectedWalletAddress
? 'var(--relay-colors-amber11)'
: 'var(--relay-colors-primary11)'
}}
>
<FontAwesomeIcon icon={faChevronDown} width={14} height={14} />
Expand All @@ -208,7 +215,10 @@ export const MultiWalletDropdown: FC<MultiWalletDropdownProps> = ({
className: 'relay:max-w-[248px] relay:p-0'
}}
>
<Flex direction="column" className="relay:rounded-[12px] relay:p-1 relay:gap-1">
<Flex
direction="column"
className="relay:rounded-[12px] relay:p-1 relay:gap-1"
>
{filteredWallets.map((wallet, idx) => {
return (
<DropdownMenuItem
Expand Down
Loading