From fb20311a81db43cabfec8fbff40c67f49c1525c0 Mon Sep 17 00:00:00 2001 From: Albert G <516972+alber70g@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:13:03 +0100 Subject: [PATCH 001/103] fix(tools): use type `balance: number | { decimal: string }` in sending funds (#2712) --- .../transactions/transfer/sender-details.tsx | 14 ++++++++++---- .../Partials/transactions/utils/balance.ts | 5 +++++ .../src/hooks/use-account-chain-details-query.ts | 2 +- .../tools/src/hooks/use-account-details-query.ts | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 packages/apps/tools/src/components/Partials/transactions/utils/balance.ts diff --git a/packages/apps/tools/src/components/Partials/transactions/transfer/sender-details.tsx b/packages/apps/tools/src/components/Partials/transactions/transfer/sender-details.tsx index f2bda1cc32..292acf0b90 100644 --- a/packages/apps/tools/src/components/Partials/transactions/transfer/sender-details.tsx +++ b/packages/apps/tools/src/components/Partials/transactions/transfer/sender-details.tsx @@ -11,6 +11,7 @@ import useTranslation from 'next-translate/useTranslation'; import type { FC } from 'react'; import React, { useEffect, useState } from 'react'; import { Controller, useFormContext } from 'react-hook-form'; +import { getBalanceFromChain } from '../utils/balance'; import type { FormData } from './sign-form'; import { defaultValues } from './sign-form'; @@ -59,7 +60,7 @@ export const SenderDetails: FC = ({ senderAccountChains.data.map((item) => ({ chainId: item.chainId, data: item.data - ? `${item.data.balance.toFixed(4)} KDA` + ? `${getBalanceFromChain(item.data.balance).toFixed(4)} KDA` : NON_EXISTING_ACCOUNT_ON_CHAIN, })), ); @@ -72,10 +73,13 @@ export const SenderDetails: FC = ({ const watchAmount = watch('amount'); const invalidAmount = - senderDataQuery.data && senderDataQuery.data.balance < watchAmount; + senderDataQuery.data && + getBalanceFromChain(senderDataQuery.data.balance) <= watchAmount; const invalidAmountMessage = senderDataQuery.data - ? `Cannot send more than ${senderDataQuery.data.balance.toFixed(4)} KDA.` + ? `Cannot send more than ${getBalanceFromChain( + senderDataQuery.data.balance, + ).toFixed(4)} KDA.` : ''; if (isLedger && !isConnected) { @@ -145,7 +149,9 @@ export const SenderDetails: FC = ({ {senderDataQuery.isFetching ? ( {t('fetching-data')} ) : senderDataQuery.data ? ( - {senderDataQuery.data?.balance.toFixed(4)} KDA + + {getBalanceFromChain(senderDataQuery.data?.balance).toFixed(4)} KDA + ) : ( {t('No funds on selected chain.')} )} diff --git a/packages/apps/tools/src/components/Partials/transactions/utils/balance.ts b/packages/apps/tools/src/components/Partials/transactions/utils/balance.ts new file mode 100644 index 0000000000..3030fdf4a8 --- /dev/null +++ b/packages/apps/tools/src/components/Partials/transactions/utils/balance.ts @@ -0,0 +1,5 @@ +export function getBalanceFromChain( + balance: number | { decimal: string }, +): number { + return typeof balance === 'number' ? balance : Number(balance.decimal); +} diff --git a/packages/apps/tools/src/hooks/use-account-chain-details-query.ts b/packages/apps/tools/src/hooks/use-account-chain-details-query.ts index dd66f0d0de..61bf7f40e2 100644 --- a/packages/apps/tools/src/hooks/use-account-chain-details-query.ts +++ b/packages/apps/tools/src/hooks/use-account-chain-details-query.ts @@ -13,7 +13,7 @@ interface IParams { const schema = z.object({ account: z.string(), - balance: z.number(), + balance: z.union([z.number(), z.object({ decimal: z.string() })]), guard: z.object({ pred: z.string(), keys: z.array(z.string()), diff --git a/packages/apps/tools/src/hooks/use-account-details-query.ts b/packages/apps/tools/src/hooks/use-account-details-query.ts index 02b6d63a5f..e1a4b5ece1 100644 --- a/packages/apps/tools/src/hooks/use-account-details-query.ts +++ b/packages/apps/tools/src/hooks/use-account-details-query.ts @@ -13,7 +13,7 @@ interface IParams { const schema = z.object({ account: z.string(), - balance: z.number(), + balance: z.union([z.object({ decimal: z.string() }), z.number()]), guard: z.object({ pred: z.string(), keys: z.array(z.string()), From f145180b5ac72059f39657cb9f6f6183c95dec7e Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 5 Dec 2024 09:22:57 +0100 Subject: [PATCH 002/103] chore(rwa): aliases for agents and investors (#2711) --- .changeset/slow-apples-think.md | 2 + .../investors/[investorAccount]/page.tsx | 22 ++- .../app/(app)/agents/[agentAccount]/page.tsx | 47 +++++++ .../components/AddAgentForm/AddAgentForm.tsx | 51 ------- .../AddInvestorForm/AddInvestorForm.tsx | 51 ------- .../src/components/AgentForm/AgentForm.tsx | 95 +++++++++++++ .../src/components/AgentInfo/AgentInfo.tsx | 28 ++++ .../src/components/AgentsList/AgentsList.tsx | 91 +++++++----- .../FreezeInvestor/FreezeInvestor.tsx | 21 ++- .../src/components/HomePage/AgentRootPage.tsx | 30 +--- .../components/HomePage/InvestorRootPage.tsx | 2 +- .../components/InvestorForm/InvestorForm.tsx | 98 +++++++++++++ .../components/InvestorInfo/InvestorInfo.tsx | 22 ++- .../components/InvestorList/InvestorList.tsx | 131 +++++++++++++----- .../TableFormatters/FormatFreeze.tsx | 19 +++ packages/apps/rwa-demo/src/hooks/addAgent.ts | 6 + .../apps/rwa-demo/src/hooks/addInvestor.ts | 8 +- packages/apps/rwa-demo/src/hooks/freeze.ts | 9 +- packages/apps/rwa-demo/src/hooks/getAgent.ts | 37 +++++ packages/apps/rwa-demo/src/hooks/getAgents.ts | 35 +++-- .../apps/rwa-demo/src/hooks/getInvestor.ts | 50 +++++++ .../apps/rwa-demo/src/hooks/getInvestors.ts | 26 +++- .../apps/rwa-demo/src/services/addAgent.ts | 3 + .../rwa-demo/src/services/registerIdentity.ts | 2 + .../src/utils/filterRemovedRecords.ts | 7 +- .../src/utils/setAliasesToAccounts.ts | 11 ++ .../apps/rwa-demo/src/utils/store/index.ts | 84 +++++++++++ .../SectionCard/SectionCard.stories.tsx | 5 +- .../SectionCard/SectionCardHeader.tsx | 2 - 29 files changed, 761 insertions(+), 234 deletions(-) create mode 100644 .changeset/slow-apples-think.md create mode 100644 packages/apps/rwa-demo/src/app/(app)/agents/[agentAccount]/page.tsx delete mode 100644 packages/apps/rwa-demo/src/components/AddAgentForm/AddAgentForm.tsx delete mode 100644 packages/apps/rwa-demo/src/components/AddInvestorForm/AddInvestorForm.tsx create mode 100644 packages/apps/rwa-demo/src/components/AgentForm/AgentForm.tsx create mode 100644 packages/apps/rwa-demo/src/components/AgentInfo/AgentInfo.tsx create mode 100644 packages/apps/rwa-demo/src/components/InvestorForm/InvestorForm.tsx create mode 100644 packages/apps/rwa-demo/src/components/TableFormatters/FormatFreeze.tsx create mode 100644 packages/apps/rwa-demo/src/hooks/getAgent.ts create mode 100644 packages/apps/rwa-demo/src/hooks/getInvestor.ts create mode 100644 packages/apps/rwa-demo/src/utils/setAliasesToAccounts.ts diff --git a/.changeset/slow-apples-think.md b/.changeset/slow-apples-think.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/slow-apples-think.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/apps/rwa-demo/src/app/(app)/(isAgent)/investors/[investorAccount]/page.tsx b/packages/apps/rwa-demo/src/app/(app)/(isAgent)/investors/[investorAccount]/page.tsx index 4ee4228475..1fdc77e149 100644 --- a/packages/apps/rwa-demo/src/app/(app)/(isAgent)/investors/[investorAccount]/page.tsx +++ b/packages/apps/rwa-demo/src/app/(app)/(isAgent)/investors/[investorAccount]/page.tsx @@ -2,12 +2,14 @@ import { DistributionForm } from '@/components/DistributionForm/DistributionForm'; import { FreezeInvestor } from '@/components/FreezeInvestor/FreezeInvestor'; +import { InvestorForm } from '@/components/InvestorForm/InvestorForm'; import { InvestorInfo } from '@/components/InvestorInfo/InvestorInfo'; import { PartiallyFreezeTokensForm } from '@/components/PartiallyFreezeTokensForm/PartiallyFreezeTokensForm'; import { SideBarBreadcrumbs } from '@/components/SideBarBreadcrumbs/SideBarBreadcrumbs'; import { useAsset } from '@/hooks/asset'; import { useFreeze } from '@/hooks/freeze'; -import { MonoAdd } from '@kadena/kode-icons'; +import { useGetInvestor } from '@/hooks/getInvestor'; +import { MonoAdd, MonoEditNote } from '@kadena/kode-icons'; import { Button, Stack } from '@kadena/kode-ui'; import { SideBarBreadcrumbsItem, useLayout } from '@kadena/kode-ui/patterns'; import { useParams } from 'next/navigation'; @@ -21,6 +23,8 @@ const InvestorPage = () => { const [hasOpenPartiallyFreezeForm, setHasOpenPartiallyFreezeForm] = useState(false); const investorAccount = decodeURIComponent(params.investorAccount as string); + + const { data: investor } = useGetInvestor({ account: investorAccount }); const { frozen } = useFreeze({ investorAccount }); const handleDistributeTokens = () => { @@ -32,6 +36,8 @@ const InvestorPage = () => { setHasOpenPartiallyFreezeForm(true); }; + if (!investor) return null; + return ( <> @@ -60,7 +66,7 @@ const InvestorPage = () => { )} - + + + } + > + Edit Investor + + } + /> diff --git a/packages/apps/rwa-demo/src/app/(app)/agents/[agentAccount]/page.tsx b/packages/apps/rwa-demo/src/app/(app)/agents/[agentAccount]/page.tsx new file mode 100644 index 0000000000..be3eb39525 --- /dev/null +++ b/packages/apps/rwa-demo/src/app/(app)/agents/[agentAccount]/page.tsx @@ -0,0 +1,47 @@ +'use client'; + +import { AgentForm } from '@/components/AgentForm/AgentForm'; +import { AgentInfo } from '@/components/AgentInfo/AgentInfo'; +import { SideBarBreadcrumbs } from '@/components/SideBarBreadcrumbs/SideBarBreadcrumbs'; +import { useAsset } from '@/hooks/asset'; +import { useGetAgent } from '@/hooks/getAgent'; +import { MonoEditNote } from '@kadena/kode-icons'; +import { Button, Stack } from '@kadena/kode-ui'; +import { SideBarBreadcrumbsItem } from '@kadena/kode-ui/patterns'; +import { useParams } from 'next/navigation'; + +const InvestorPage = () => { + const { paused } = useAsset(); + const params = useParams(); + const agentAccount = decodeURIComponent(params.agentAccount as string); + + const { data: agent } = useGetAgent({ account: agentAccount }); + + if (!agent) return null; + + return ( + <> + + + Agent + + + + + + + }> + Edit Agent + + } + /> + + + + ); +}; + +export default InvestorPage; diff --git a/packages/apps/rwa-demo/src/components/AddAgentForm/AddAgentForm.tsx b/packages/apps/rwa-demo/src/components/AddAgentForm/AddAgentForm.tsx deleted file mode 100644 index 2d97413af6..0000000000 --- a/packages/apps/rwa-demo/src/components/AddAgentForm/AddAgentForm.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { useAddAgent } from '@/hooks/addAgent'; -import type { IAddAgentProps } from '@/services/addAgent'; -import { Button, TextField } from '@kadena/kode-ui'; -import { - RightAside, - RightAsideContent, - RightAsideFooter, - RightAsideHeader, -} from '@kadena/kode-ui/patterns'; -import type { FC } from 'react'; -import { useForm } from 'react-hook-form'; - -interface IProps { - onClose: () => void; -} - -export const AddAgentForm: FC = ({ onClose }) => { - const { submit } = useAddAgent(); - const { register, handleSubmit } = useForm({ - defaultValues: { - accountName: '', - }, - }); - - const onSubmit = async (data: IAddAgentProps) => { - await submit(data); - onClose(); - }; - - return ( - <> - -
- - - - - - - - - -
- - ); -}; diff --git a/packages/apps/rwa-demo/src/components/AddInvestorForm/AddInvestorForm.tsx b/packages/apps/rwa-demo/src/components/AddInvestorForm/AddInvestorForm.tsx deleted file mode 100644 index 7f52a865cb..0000000000 --- a/packages/apps/rwa-demo/src/components/AddInvestorForm/AddInvestorForm.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { useAddInvestor } from '@/hooks/addInvestor'; -import type { IRegisterIdentityProps } from '@/services/registerIdentity'; -import { Button, TextField } from '@kadena/kode-ui'; -import { - RightAside, - RightAsideContent, - RightAsideFooter, - RightAsideHeader, -} from '@kadena/kode-ui/patterns'; -import type { FC } from 'react'; -import { useForm } from 'react-hook-form'; - -interface IProps { - onClose: () => void; -} - -export const AddInvestorForm: FC = ({ onClose }) => { - const { submit } = useAddInvestor(); - const { register, handleSubmit } = useForm({ - defaultValues: { - accountName: '', - }, - }); - - const onSubmit = async (data: IRegisterIdentityProps) => { - await submit(data); - onClose(); - }; - - return ( - <> - -
- - - - - - - - - -
- - ); -}; diff --git a/packages/apps/rwa-demo/src/components/AgentForm/AgentForm.tsx b/packages/apps/rwa-demo/src/components/AgentForm/AgentForm.tsx new file mode 100644 index 0000000000..8819a6a34c --- /dev/null +++ b/packages/apps/rwa-demo/src/components/AgentForm/AgentForm.tsx @@ -0,0 +1,95 @@ +import { useAddAgent } from '@/hooks/addAgent'; +import type { IAddAgentProps } from '@/services/addAgent'; +import type { IRecord } from '@/utils/filterRemovedRecords'; +import { Button, TextField } from '@kadena/kode-ui'; +import { + RightAside, + RightAsideContent, + RightAsideFooter, + RightAsideHeader, + useLayout, +} from '@kadena/kode-ui/patterns'; +import type { FC, ReactElement } from 'react'; +import { cloneElement, useEffect, useState } from 'react'; +import { Controller, useForm } from 'react-hook-form'; + +interface IProps { + agent?: IRecord; + onClose?: () => void; + trigger: ReactElement; +} + +export const AgentForm: FC = ({ onClose, agent, trigger }) => { + const { submit } = useAddAgent(); + const [isOpen, setIsOpen] = useState(false); + const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); + const { handleSubmit, control } = useForm({ + defaultValues: { + accountName: agent?.accountName ?? '', + alias: agent?.alias ?? '', + alreadyExists: !!agent?.accountName, + }, + }); + + const handleOpen = () => { + setIsRightAsideExpanded(true); + setIsOpen(true); + if (trigger.props.onPress) trigger.props.onPress(); + }; + + const handleOnClose = () => { + setIsOpen(false); + if (onClose) onClose(); + }; + + const onSubmit = async (data: IAddAgentProps) => { + await submit(data); + handleOnClose(); + }; + + useEffect(() => { + console.log('agent', isOpen); + }, [isOpen]); + + return ( + <> + {isRightAsideExpanded && isOpen && ( + +
+ + + ( + + )} + /> + + } + /> + + + + + + +
+ )} + + {cloneElement(trigger, { ...trigger.props, onPress: handleOpen })} + + ); +}; diff --git a/packages/apps/rwa-demo/src/components/AgentInfo/AgentInfo.tsx b/packages/apps/rwa-demo/src/components/AgentInfo/AgentInfo.tsx new file mode 100644 index 0000000000..cc3052083f --- /dev/null +++ b/packages/apps/rwa-demo/src/components/AgentInfo/AgentInfo.tsx @@ -0,0 +1,28 @@ +import type { IRecord } from '@/utils/filterRemovedRecords'; +import { Heading, Stack } from '@kadena/kode-ui'; +import type { FC } from 'react'; +import React from 'react'; +import type { IWalletAccount } from '../AccountProvider/utils'; + +interface IProps { + account: IRecord | IWalletAccount; +} + +const getAccountName = (account: IProps['account']) => { + if ('accountName' in account) return account.accountName; + return account.address; +}; + +export const AgentInfo: FC = ({ account }) => { + const accountName = getAccountName(account); + + if (!account) return null; + + return ( + + + agent: {account.alias ? account.alias : accountName} + + + ); +}; diff --git a/packages/apps/rwa-demo/src/components/AgentsList/AgentsList.tsx b/packages/apps/rwa-demo/src/components/AgentsList/AgentsList.tsx index 065d2a99f1..5d526e5221 100644 --- a/packages/apps/rwa-demo/src/components/AgentsList/AgentsList.tsx +++ b/packages/apps/rwa-demo/src/components/AgentsList/AgentsList.tsx @@ -1,7 +1,11 @@ import { useAsset } from '@/hooks/asset'; import { useGetAgents } from '@/hooks/getAgents'; import { useRemoveAgent } from '@/hooks/removeAgent'; -import { MonoDelete, MonoSupportAgent } from '@kadena/kode-icons'; +import { + MonoDelete, + MonoFindInPage, + MonoSupportAgent, +} from '@kadena/kode-icons'; import { Button } from '@kadena/kode-ui'; import { CompactTable, @@ -10,75 +14,92 @@ import { SectionCardBody, SectionCardContentBlock, SectionCardHeader, - useLayout, } from '@kadena/kode-ui/patterns'; +import { useRouter } from 'next/navigation'; import type { FC } from 'react'; -import { useState } from 'react'; -import { AddAgentForm } from '../AddAgentForm/AddAgentForm'; +import { AgentForm } from '../AgentForm/AgentForm'; import { Confirmation } from '../Confirmation/Confirmation'; export const AgentsList: FC = () => { - const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); const { paused } = useAsset(); const { data } = useGetAgents(); const { submit } = useRemoveAgent(); - const [hasOpenAgentForm, setHasOpenAgentForm] = useState(false); - - const handleAddAgent = () => { - setIsRightAsideExpanded(true); - setHasOpenAgentForm(true); - }; + const router = useRouter(); const handleDelete = async (accountName: any) => { await submit({ agent: accountName }); }; + const handleLink = async (accountName: any) => { + router.push(`/agents/${accountName}`); + }; + return ( <> - {isRightAsideExpanded && hasOpenAgentForm && ( - { - setIsRightAsideExpanded(false); - setHasOpenAgentForm(false); - }} - /> - )} All the agents for this contract} actions={ - + } + variant="outlined" + > + Add Agent + + } + /> } /> } + onPress={handleLink} + /> + ), + }), }, - { label: 'Account', key: 'accountName', width: '50%' }, - { label: 'Requestkey', key: 'requestKey', width: '30%' }, { label: '', key: 'accountName', - width: '10%', + width: '7%', render: CompactTableFormatters.FormatActions({ trigger: ( } />} + trigger={ + } > diff --git a/packages/apps/rwa-demo/src/components/HomePage/AgentRootPage.tsx b/packages/apps/rwa-demo/src/components/HomePage/AgentRootPage.tsx index 4174a36ed8..9d3017dc15 100644 --- a/packages/apps/rwa-demo/src/components/HomePage/AgentRootPage.tsx +++ b/packages/apps/rwa-demo/src/components/HomePage/AgentRootPage.tsx @@ -1,25 +1,12 @@ import { SideBarBreadcrumbs } from '@/components/SideBarBreadcrumbs/SideBarBreadcrumbs'; import { useAccount } from '@/hooks/account'; -import { useAsset } from '@/hooks/asset'; -import { MonoAdd } from '@kadena/kode-icons'; -import { Button, Stack } from '@kadena/kode-ui'; -import { useLayout } from '@kadena/kode-ui/patterns'; +import { Stack } from '@kadena/kode-ui'; import type { FC } from 'react'; -import { useState } from 'react'; -import { AddInvestorForm } from '../AddInvestorForm/AddInvestorForm'; import { InvestorList } from '../InvestorList/InvestorList'; import { PauseForm } from '../PauseForm/PauseForm'; export const AgentRootPage: FC = () => { const { isAgent, account } = useAccount(); - const { paused } = useAsset(); - const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); - const [hasOpenInvestorForm, setHasOpenInvestorForm] = useState(false); - - const handleAddInvestor = () => { - setIsRightAsideExpanded(true); - setHasOpenInvestorForm(true); - }; if (!isAgent) return null; @@ -27,23 +14,8 @@ export const AgentRootPage: FC = () => { agent: {account?.address} - {isRightAsideExpanded && hasOpenInvestorForm && ( - { - setIsRightAsideExpanded(false); - setHasOpenInvestorForm(false); - }} - /> - )} - diff --git a/packages/apps/rwa-demo/src/components/HomePage/InvestorRootPage.tsx b/packages/apps/rwa-demo/src/components/HomePage/InvestorRootPage.tsx index 3db2e5f741..f2203318fa 100644 --- a/packages/apps/rwa-demo/src/components/HomePage/InvestorRootPage.tsx +++ b/packages/apps/rwa-demo/src/components/HomePage/InvestorRootPage.tsx @@ -33,7 +33,7 @@ export const InvestorRootPage: FC = () => { )} - + + + + + + )} + + {cloneElement(trigger, { ...trigger.props, onPress: handleOpen })} + + ); +}; diff --git a/packages/apps/rwa-demo/src/components/InvestorInfo/InvestorInfo.tsx b/packages/apps/rwa-demo/src/components/InvestorInfo/InvestorInfo.tsx index 57cc0467c7..c856ef4868 100644 --- a/packages/apps/rwa-demo/src/components/InvestorInfo/InvestorInfo.tsx +++ b/packages/apps/rwa-demo/src/components/InvestorInfo/InvestorInfo.tsx @@ -1,20 +1,32 @@ import { useFreeze } from '@/hooks/freeze'; +import type { IRecord } from '@/utils/filterRemovedRecords'; import { MonoPause, MonoPlayArrow } from '@kadena/kode-icons'; import { Button, Heading, Stack } from '@kadena/kode-ui'; import type { FC } from 'react'; import React from 'react'; +import type { IWalletAccount } from '../AccountProvider/utils'; import { InvestorBalance } from '../InvestorBalance/InvestorBalance'; interface IProps { - investorAccount: string; + account: IRecord | IWalletAccount; } -export const InvestorInfo: FC = ({ investorAccount }) => { - const { frozen } = useFreeze({ investorAccount }); +const getAccountName = (account: IProps['account']) => { + if ('accountName' in account) return account.accountName; + return account.address; +}; + +export const InvestorInfo: FC = ({ account }) => { + const accountName = getAccountName(account); + const { frozen } = useFreeze({ investorAccount: accountName }); + + if (!account) return null; return ( - investor: {investorAccount} + + investor: {account.alias ? account.alias : accountName} + - + ); diff --git a/packages/apps/rwa-demo/src/components/InvestorList/InvestorList.tsx b/packages/apps/rwa-demo/src/components/InvestorList/InvestorList.tsx index 19e375dba5..4039daa642 100644 --- a/packages/apps/rwa-demo/src/components/InvestorList/InvestorList.tsx +++ b/packages/apps/rwa-demo/src/components/InvestorList/InvestorList.tsx @@ -1,53 +1,112 @@ +import { useAsset } from '@/hooks/asset'; import { useDeleteInvestor } from '@/hooks/deleteInvestor'; import { useGetInvestors } from '@/hooks/getInvestors'; -import { MonoDelete } from '@kadena/kode-icons'; -import { Button, Heading } from '@kadena/kode-ui'; -import { CompactTable, CompactTableFormatters } from '@kadena/kode-ui/patterns'; -import Link from 'next/link'; +import { MonoAdd, MonoDelete, MonoFindInPage } from '@kadena/kode-icons'; +import { Button } from '@kadena/kode-ui'; +import { + CompactTable, + CompactTableFormatters, + SectionCard, + SectionCardBody, + SectionCardContentBlock, + SectionCardHeader, +} from '@kadena/kode-ui/patterns'; +import { useRouter } from 'next/navigation'; import type { FC } from 'react'; +import { InvestorForm } from '../InvestorForm/InvestorForm'; +import { FormatFreeze } from '../TableFormatters/FormatFreeze'; export const InvestorList: FC = () => { const { data } = useGetInvestors(); + const router = useRouter(); const { submit } = useDeleteInvestor(); + const { paused } = useAsset(); const handleDelete = async (accountName: any) => { return await submit({ investor: accountName }); }; + const handleLink = async (accountName: any) => { + router.push(`/investors/${accountName}`); + }; return ( <> - Investors - } onPress={handleDelete} /> - ), - }), - }, - ]} - data={data} - /> + + + } + > + Add Investor + + } + /> + } + /> + + + } + onPress={handleLink} + /> + ), + }), + }, + { + label: '', + key: 'accountName', + width: '7%', + render: CompactTableFormatters.FormatActions({ + trigger: ( + - - + + + + onChangeMnemonic(e)} + placeholder="Enter or generate mnemonic phrase" + variant="default" + size="md" + fontType="ui" + errorMessage={hasError ? 'Mnemonic phrase cannot be empty.' : ''} + /> + + + + + ); }; diff --git a/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesRegister.tsx b/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesRegister.tsx deleted file mode 100644 index dfa437afbf..0000000000 --- a/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesRegister.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import React, { useCallback, useMemo, useState } from 'react'; -import { useAccountBalance } from '../../hooks/balances'; -import type { Account } from '../../state/wallet'; -import { useWalletState } from '../../state/wallet'; -import { NameRegistrationForm } from './NameRegistrationForm'; - -export const KadenaNamesRegister: React.FC = () => { - const wallet = useWalletState(); - const [ownerAddress, setOwnerAddress] = useState(''); - - const ownerAccount: Account = useMemo(() => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const [_, publicKey] = ownerAddress.split(':'); - return { - index: 0, - publicKey: publicKey || '', - name: ownerAddress, - }; - }, [ownerAddress]); - - const { balance, error } = useAccountBalance( - ownerAccount, - wallet.selectedNetwork, - wallet.selectedFungible, - wallet.selectedChain, - ); - - const handleOwnerAddressChange = useCallback((address: string) => { - setOwnerAddress(address); - }, []); - - return ( -
-

- Register Kadena Name -

- - {error && ( -

Error: {error.message}

- )} - - -
- ); -}; diff --git a/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx b/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx index c905900513..6d2c9e1680 100644 --- a/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx +++ b/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx @@ -1,13 +1,25 @@ +import { + Card, + ContentHeader, + Divider, + Heading, + Stack, + Text, + TextField, +} from '@kadena/kode-ui'; + +import { MonoAccountTree } from '@kadena/kode-icons'; + import React from 'react'; import { useAddressToName, useNameToAddress, } from '../../hooks/kadenaNames/kadenaNamesResolver'; - import { useWalletState } from '../../state/wallet'; export const KadenaNames: React.FC = () => { const wallet = useWalletState(); + const { name: resolvedName, error: nameError, @@ -25,54 +37,64 @@ export const KadenaNames: React.FC = () => { } = useNameToAddress(0, wallet.selectedNetwork); return ( -
-

- Kadena Address and Name Lookup -

- -
-

Address to Name

- setAddress(e.target.value)} - placeholder="Enter address" - className="bg-medium-slate border border-border-gray rounded-md py-2 px-3 text-white w-full mb-2" +
+ + } /> - {nameLoading &&

Loading...

} - {resolvedName && ( -

- Name: {resolvedName} -

- )} - {nameError && ( -

- Error: {nameError} -

- )} -
-
-

Name to Address

- setName(e.target.value)} - placeholder="Enter name" - className="bg-medium-slate border border-border-gray rounded-md py-2 px-3 text-white w-full mb-2" - /> - {addressLoading &&

Loading...

} - {resolvedAddress && ( -

- Address: {resolvedAddress} -

- )} - {addressError && ( -

- Error: {addressError} -

- )} -
+ + + + {/* Address to Name */} + + Address to Name + + {nameLoading && Loading...} + {resolvedName && ( + + Name: {resolvedName} + + )} + {nameError && ( + + Error: {nameError} + + )} + + + {/* Name to Address */} + + Name to Address + + {addressLoading && Loading...} + {resolvedAddress && ( + + Address: {resolvedAddress} + + )} + {addressError && ( + + Error: {addressError} + + )} + + +
); }; diff --git a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationForm.tsx b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationForm.tsx index 6522f0b689..235d287266 100644 --- a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationForm.tsx +++ b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationForm.tsx @@ -1,4 +1,12 @@ import { ChainId } from '@kadena/client'; +import { + Button, + Select, + SelectItem, + Stack, + Text, + TextField, +} from '@kadena/kode-ui'; import { walletSdk } from '@kadena/wallet-sdk'; import React, { useCallback, useEffect, useState } from 'react'; import { getChainIdByNetwork } from '../../actions/host'; @@ -32,17 +40,15 @@ export const NameRegistrationForm: React.FC = ({ const [registrationPeriod, setRegistrationPeriod] = useState<1 | 2>(1); const [status, setStatus] = useState(''); const [error, setError] = useState(''); - const [availabilityLoading, setAvailabilityLoading] = - useState(false); - const [priceLoading, setPriceLoading] = useState(false); - const [registering, setRegistering] = useState(false); + const [availabilityLoading, setAvailabilityLoading] = useState(false); + const [priceLoading, setPriceLoading] = useState(false); + const [registering, setRegistering] = useState(false); const [price, setPrice] = useState(null); const wallet = useWalletState(); const { selectChain, selectedChain } = wallet; const validChain = getChainIdByNetwork(wallet.selectedNetwork); - const debouncedName = useDebounce(name, 500); const checkAvailabilityAndSetPrice = useCallback(async () => { @@ -148,103 +154,95 @@ export const NameRegistrationForm: React.FC = ({ return 'Confirm Registration'; }; - const handleOwnerChange = (e: React.ChangeEvent) => { - const address = e.target.value; - setOwner(address); - - if (onOwnerAddressChange) { - onOwnerAddressChange(address); - } - }; - return ( -
-

- Network: {wallet.selectedNetwork} -

-

- Current Balance: {balance} KDA -

-
- - -
-
- - setAddress(e.target.value)} - className="bg-medium-slate border border-border-gray rounded-md py-2 px-3 text-white w-full" - placeholder="Enter the receiver address" - /> -
-
- - -
-
- - -
-
- - setName(e.target.value)} - className="bg-medium-slate border border-border-gray rounded-md py-2 px-3 text-white w-full" - placeholder="Enter the name to register" - /> -
+ + {/* Network Info */} + + Network: {wallet.selectedNetwork} + + + Current Balance: {balance} KDA + + + {/* Owner Address */} + { + setOwner(val); + onOwnerAddressChange?.(val); + }} + size="md" + /> + + {/* Receiver Address */} + + + {/* Chain Selector */} + + + {/* Registration Period */} + + + {/* Name Input */} + + + {/* Price Info */} {price !== null && ( -
+ Price: {price} KDA for {registrationPeriod} year(s) -
+ )} - - {status &&

{status}

} - {error && ( -

- Error: {error} -

- )} -
+ + + {/* Status/Error Messages */} + {status && {status}} + {error && {error}} + ); }; diff --git a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx index b013c3c972..70e7201015 100644 --- a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx +++ b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx @@ -1,3 +1,5 @@ +import { MonoAccountBalance } from '@kadena/kode-icons/system'; +import { Button, ContentHeader, Dialog, Divider, Stack } from '@kadena/kode-ui'; import React from 'react'; import { NameRegistrationForm } from './NameRegistrationForm'; @@ -17,33 +19,48 @@ export const NameRegistrationModal: React.FC = ({ balance, }) => { return ( -
{ + if (!isOpen) onClose(); + }} + size="sm" > -
} + /> + + + + {/* Modal Content */} + + { + onRegistered?.(); + onClose(); }} + balance={balance} + /> + + {/* Buttons */} + -

- Register Kadena Name -

- { - onRegistered?.(); - onClose(); - }} - balance={balance} - /> - + -
-
+ + + ); }; diff --git a/packages/apps/wallet-sdk-example/src/constants/fund.ts b/packages/apps/wallet-sdk-example/src/constants/fund.ts new file mode 100644 index 0000000000..de20489660 --- /dev/null +++ b/packages/apps/wallet-sdk-example/src/constants/fund.ts @@ -0,0 +1,21 @@ +export const NAMESPACES = { + DEV_NET: 'n_34d947e2627143159ea73cdf277138fd571f17ac', + TEST_NET: 'n_d8cbb935f9cd9d2399a5886bb08caed71f9bad49', +} as const; + +export const GAS_STATIONS = { + DEV_NET: 'c:zWPXcVXoHwkNTzKhMU02u2tzN_yL6V3-XTEH1uJaVY4', + TEST_NET: 'c:Ecwy85aCW3eogZUnIQxknH8tG8uXHM5QiC__jeI0nWA', +} as const; + +export const GAS_STATIONS_MAP: { [key: string]: string } = { + development: GAS_STATIONS.DEV_NET, + testnet04: GAS_STATIONS.TEST_NET, +} as const; + +export const NAMESPACES_MAP: { [key: string]: string } = { + development: NAMESPACES.DEV_NET, + testnet04: NAMESPACES.TEST_NET, +}; + +export const DEFAULT_CONTRACT_NAME = 'coin-faucet'; diff --git a/packages/apps/wallet-sdk-example/src/global.css.ts b/packages/apps/wallet-sdk-example/src/global.css.ts new file mode 100644 index 0000000000..9e9b09091d --- /dev/null +++ b/packages/apps/wallet-sdk-example/src/global.css.ts @@ -0,0 +1,14 @@ +import { globalStyle } from '@vanilla-extract/css'; + +globalStyle('*', { + boxSizing: 'border-box', +}); + +globalStyle('body', { + margin: 0, + padding: 0, + fontFamily: 'var(--font-body)', + backgroundColor: 'var(--color-background)', + color: 'var(--color-text)', + transition: 'background-color 0.3s, color 0.3s', +}); diff --git a/packages/apps/wallet-sdk-example/src/index.css b/packages/apps/wallet-sdk-example/src/index.css index 6d23437303..cd47d2f6a6 100644 --- a/packages/apps/wallet-sdk-example/src/index.css +++ b/packages/apps/wallet-sdk-example/src/index.css @@ -1,213 +1,16 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -:root { - /* Fonts */ - font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; - font-size: 16px; - line-height: 1.5; - font-weight: 400; - - /* Colors */ - --primary-green: #3BA583; - --secondary-green: #5DB399; - --dark-slate: #1E293B; - --medium-slate: #3F4C5C; - --border-gray: #CBD5E0; - --text-color: #FFFFFF; - --text-secondary: #A0AEC0; - --background-gray: #F7FAFC; - --error-color: #E53E3E; - - /* Shadows */ - --shadow-elevation: 0 2px 8px rgba(0, 0, 0, 0.1); -} -body { - background-color: var(--dark-slate); - color: var(--text-color); - font-family: inherit; - margin: 0; - padding: 0; - -webkit-font-smoothing: antialiased; -} +@tailwind utilities; -/* Headings */ -h1, h2, h3, h4, h5, h6 { - color: var(--text-color); - margin: 0 0 0.5em 0; - font-weight: 600; - line-height: 1.2; -} -h1 { font-size: 2.25rem; } /* 36px */ -h2 { font-size: 1.875rem; } /* 30px */ -h3 { font-size: 1.5rem; } /* 24px */ -h4 { font-size: 1.25rem; } /* 20px */ -h5 { font-size: 1.125rem; } /* 18px */ -h6 { font-size: 1rem; } /* 16px */ -/* Links */ -a { - color: var(--primary-green); - text-decoration: none; - transition: color 0.2s; -} -a:hover { - color: var(--secondary-green); -} - -/* Buttons */ -button { - display: inline-flex; - align-items: center; - justify-content: center; - background-color: var(--primary-green); - color: var(--text-color); - border: none; - border-radius: 6px; - padding: 0.75em 1.5em; - font-size: 1em; - font-weight: 500; - cursor: pointer; - transition: background-color 0.2s, box-shadow 0.2s; - box-shadow: var(--shadow-elevation); -} -button:hover { - background-color: var(--secondary-green); -} -button:focus { - outline: none; - box-shadow: 0 0 0 4px rgba(59, 165, 131, 0.5); -} -button:disabled { - background-color: var(--border-gray); - cursor: not-allowed; -} - -/* Input Fields */ -input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="reset"]):not([type="button"]), -textarea { +[class^="Form__"] { width: 100%; - background-color: var(--medium-slate); - color: var(--text-color); - border: 1px solid var(--border-gray); - border-radius: 6px; - padding: 0.75em 1em; - font-size: 1em; - transition: border-color 0.2s, box-shadow 0.2s; -} -input::placeholder, -textarea::placeholder { - color: var(--text-secondary); -} -input:focus, -textarea:focus { - outline: none; - border-color: var(--primary-green); - box-shadow: 0 0 0 4px rgba(59, 165, 131, 0.3); } -/* Checkbox and Radio Buttons */ -input[type="checkbox"], -input[type="radio"] { - appearance: none; - background-color: var(--medium-slate); - margin: 0; - font: inherit; - color: var(--primary-green); - width: 1.15em; - height: 1.15em; - border: 1.5px solid var(--border-gray); - border-radius: 0.15em; - display: grid; - place-content: center; - cursor: pointer; -} -input[type="checkbox"]::before, -input[type="radio"]::before { - content: ''; - width: 0.65em; - height: 0.65em; - transform: scale(0); - transition: transform 0.1s ease-in-out; - background-color: var(--primary-green); -} -input[type="checkbox"]:checked::before { - transform: scale(1); -} -input[type="radio"] { - border-radius: 50%; -} -input[type="radio"]::before { - border-radius: 50%; -} -input[type="radio"]:checked::before { - transform: scale(0.6); +[class^="Dialog"] { + max-height: inherit } - -/* Select */ -select { - background-color: var(--medium-slate); - color: var(--text-color); - border: 1px solid var(--border-gray); - border-radius: 6px; - padding: 0.75em 1em; - font-size: 1em; - appearance: none; - background-image: url('data:image/svg+xml;charset=UTF-8,'); - background-repeat: no-repeat; - background-position: right 1em top 50%; - background-size: 1em; +textarea { width: 100%; } - -select:focus { - outline: none; - border-color: var(--primary-green); - box-shadow: 0 0 0 4px rgba(59, 165, 131, 0.3); -} - -/* Forms */ -form { - display: flex; - flex-direction: column; - gap: 1.5em; - margin: 0 auto; -} -form .form-group { - display: flex; - flex-direction: column; -} -form .form-group label { - margin-bottom: 0.5em; - color: var(--text-secondary); - font-size: 0.9em; -} -form .form-group .error-message { - margin-top: 0.5em; - color: var(--error-color); - font-size: 0.85em; -} - -/* Text */ -p { - margin: 0 0 1em 0; -} - -/* Utility Classes */ -.container { - padding: 2em; -} -.centered { - display: flex; - justify-content: center; - align-items: center; -} -.mt-1 { margin-top: 0.25em; } -.mt-2 { margin-top: 0.5em; } -.mt-3 { margin-top: 0.75em; } -.mt-4 { margin-top: 1em; } -.mt-5 { margin-top: 1.5em; } diff --git a/packages/apps/wallet-sdk-example/src/main.tsx b/packages/apps/wallet-sdk-example/src/main.tsx index bef5202a32..1b7eb1dfb0 100644 --- a/packages/apps/wallet-sdk-example/src/main.tsx +++ b/packages/apps/wallet-sdk-example/src/main.tsx @@ -1,10 +1,13 @@ -import { StrictMode } from 'react' -import { createRoot } from 'react-dom/client' -import './index.css' -import App from './App.tsx' +import { StrictMode } from 'react'; +import { createRoot } from 'react-dom/client'; +import { BrowserRouter } from 'react-router-dom'; +import App from './App.tsx'; +import './index.css'; createRoot(document.getElementById('root')!).render( - + + + , -) +); diff --git a/packages/apps/wallet-sdk-example/tailwind.config.mjs b/packages/apps/wallet-sdk-example/tailwind.config.mjs index 2fbb544ae3..60aea86bc8 100644 --- a/packages/apps/wallet-sdk-example/tailwind.config.mjs +++ b/packages/apps/wallet-sdk-example/tailwind.config.mjs @@ -1,16 +1,16 @@ /** @type {import('tailwindcss').Config} */ export default { content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'], - theme: { - extend: { - 'primary-green': '#3BA583', - 'secondary-green': '#5DB399', - 'dark-slate': '#1E293B', - 'medium-slate': '#3F4C5C', - 'border-gray': '#CBD5E0', - 'text-secondary': '#A0AEC0', - 'error-color': '#E53E3E', - }, - }, + // theme: { + // extend: { + // 'primary-green': '#3BA583', + // 'secondary-green': '#5DB399', + // 'dark-slate': '#1E293B', + // 'medium-slate': '#3F4C5C', + // 'border-gray': '#CBD5E0', + // 'text-secondary': '#A0AEC0', + // 'error-color': '#E53E3E', + // }, + // }, plugins: [], }; diff --git a/packages/apps/wallet-sdk-example/vite.config.ts b/packages/apps/wallet-sdk-example/vite.config.ts index 0dc1048039..d30e1a69b9 100644 --- a/packages/apps/wallet-sdk-example/vite.config.ts +++ b/packages/apps/wallet-sdk-example/vite.config.ts @@ -1,3 +1,4 @@ +import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'; import react from '@vitejs/plugin-react-swc'; import fs from 'fs'; import path from 'path'; @@ -31,7 +32,7 @@ const monorepoPathsRegex = monorepoPackages.map( monorepoPackages.push('@kadena/client/fp'); export const config: UserConfig = { - plugins: [react()], + plugins: [vanillaExtractPlugin(), react()], optimizeDeps: { // add all monorepo packages to optimizeDeps since they are commonjs include: [...monorepoPackages], diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5ab856b6c7..605846e44d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1636,24 +1636,45 @@ importers: '@kadena/hd-wallet': specifier: workspace:* version: link:../../libs/hd-wallet + '@kadena/kode-icons': + specifier: workspace:* + version: link:../../libs/kode-icons + '@kadena/kode-ui': + specifier: workspace:* + version: link:../../libs/kode-ui '@kadena/wallet-sdk': specifier: workspace:* version: link:../../libs/wallet-sdk '@tanstack/react-query': specifier: ^5.32.0 version: 5.49.2(react@18.3.1) + '@types/react-router-dom': + specifier: ^5.3.3 + version: 5.3.3 + '@vanilla-extract/css': + specifier: 1.14.2 + version: 1.14.2 + '@vanilla-extract/vite-plugin': + specifier: 4.0.7 + version: 4.0.7(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)) clsx: specifier: ^2.1.1 version: 2.1.1 jotai: specifier: ^2.10.1 version: 2.10.1(@types/react@18.3.14)(react@18.3.1) + next-themes: + specifier: ^0.2.1 + version: 0.2.1(next@14.2.2(@opentelemetry/api@1.9.0)(@playwright/test@1.46.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) react: specifier: ^18.3.1 version: 18.3.1 react-dom: specifier: ^18.3.1 version: 18.3.1(react@18.3.1) + react-router-dom: + specifier: ^6.26.2 + version: 6.26.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) devDependencies: '@eslint/js': specifier: ^9.11.1 @@ -8138,10 +8159,6 @@ packages: react-redux: optional: true - '@remix-run/router@1.17.1': - resolution: {integrity: sha512-mCOMec4BKd6BRGBZeSnGiIgwsbLGp3yhVqAD8H+PxiRNEHgDpZb8J1TnrSDlg97t0ySKMQJTHCWBCmBpSmkF6Q==} - engines: {node: '>=14.0.0'} - '@remix-run/router@1.19.2': resolution: {integrity: sha512-baiMx18+IMuD1yyvOGaHM9QrVUPGGG0jC+z+IPHnRJWUAUvaKuWKyE8gjDj2rzv3sz9zOGoRSPgeBVHRhZnBlA==} engines: {node: '>=14.0.0'} @@ -9640,6 +9657,9 @@ packages: '@types/heft-jest@1.0.6': resolution: {integrity: sha512-oTVSfKEgvQEaukVq+y57m5UTo2sSh3MxmJWxpcnASPjSi3RUKbKXeNjvmrSnT4D6rF3Cs57u2jfn9JFFKf2hLg==} + '@types/history@4.7.11': + resolution: {integrity: sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==} + '@types/hosted-git-info@3.0.5': resolution: {integrity: sha512-Dmngh7U003cOHPhKGyA7LWqrnvcTyILNgNPmNCxlx7j8MIi54iBliiT8XqVLIQ3GchoOjVAyBzNJVyuaJjqokg==} @@ -9829,6 +9849,15 @@ packages: '@types/react-dom@18.3.0': resolution: {integrity: sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==} + '@types/react-router-dom@5.3.3': + resolution: {integrity: sha512-kpqnYK4wcdm5UaWI3fLcELopqLrHgLqNsdpHauzlQktfkHL3npOSwtj1Uz9oKBAzs7lFtVkV8j83voAz2D8fhw==} + + '@types/react-router@5.1.20': + resolution: {integrity: sha512-jGjmu/ZqS7FjSH6owMcD5qpq19+1RS9DeVRqfl1FeBMxTDQAGwlMWOcs52NDoXaNKyG3d1cYQFMs9rCrb88o9Q==} + + '@types/react@18.3.11': + resolution: {integrity: sha512-r6QZ069rFTjrEYgFdOck1gK7FLVsgJE7tTz0pQBczlBNUhBNk0MQH4UbnFSwjpQLMkLzgqvBBa+qGpLje16eTQ==} + '@types/react@18.3.14': resolution: {integrity: sha512-NzahNKvjNhVjuPBQ+2G7WlxstQ+47kXZNHlUvFakDViuIEfGY926GqhMueQFZ7woG+sPiQKlF36XfrIUVSUfFg==} @@ -10341,9 +10370,6 @@ packages: peerDependencies: next: '>=12.1.7' - '@vanilla-extract/private@1.0.5': - resolution: {integrity: sha512-6YXeOEKYTA3UV+RC8DeAjFk+/okoNz/h88R+McnzA2zpaVqTR/Ep+vszkWYlGBcMNO7vEkqbq5nT/JMMvhi+tw==} - '@vanilla-extract/private@1.0.6': resolution: {integrity: sha512-ytsG/JLweEjw7DBuZ/0JCN4WAQgM9erfSTdS1NQY778hFQSZ6cfCDEZZ0sgVm4k54uNz6ImKB33AYvSR//fjxw==} @@ -10362,6 +10388,11 @@ packages: peerDependencies: vite: ^4.0.3 || ^5.0.0 + '@vanilla-extract/vite-plugin@4.0.7': + resolution: {integrity: sha512-uRAFWdq5Eq0ybpgW2P0LNOw8eW+MTg/OFo5K0Hsl2cKu/Tu2tabCsBf6vNjfhDrm4jBShHy1wJIVcYxf6sczVQ==} + peerDependencies: + vite: ^4.0.3 || ^5.0.0 + '@vanilla-extract/webpack-plugin@2.3.7': resolution: {integrity: sha512-xKhl7BUGqjj1eRzgASBcfKSvzIWGN1ndNT9ycUcfDz1AXZr6rok99LSj+Z2LqAnCGZGAiLsYzdQ5AYBABXV+vA==} peerDependencies: @@ -17723,13 +17754,6 @@ packages: resolution: {integrity: sha512-Gvzk7OZpiqKSkxsQvO/mbTN1poglhmAV7gR/DdIrRrSMXraRQQlfikRJOr3Nb9GTMPC5kof948Zy6jJZIFtDvQ==} engines: {node: '>=0.10.0'} - react-router-dom@6.24.1: - resolution: {integrity: sha512-U19KtXqooqw967Vw0Qcn5cOvrX5Ejo9ORmOtJMzYWtCT4/WOfFLIZGGsVLxcd9UkBO0mSTZtXqhZBsWlHr7+Sg==} - engines: {node: '>=14.0.0'} - peerDependencies: - react: '>=16.8' - react-dom: '>=16.8' - react-router-dom@6.26.2: resolution: {integrity: sha512-z7YkaEW0Dy35T3/QKPYB1LjMK2R1fxnHO8kWpUMTBdfVzZrWOiY9a7CtN8HqdWtDUWd5FY6Dl8HFsqVwH4uOtQ==} engines: {node: '>=14.0.0'} @@ -17737,12 +17761,6 @@ packages: react: '>=16.8' react-dom: '>=16.8' - react-router@6.24.1: - resolution: {integrity: sha512-PTXFXGK2pyXpHzVo3rR9H7ip4lSPZZc0bHG5CARmj65fTT6qG7sTngmb6lcYu1gf3y/8KxORoy9yn59pGpCnpg==} - engines: {node: '>=14.0.0'} - peerDependencies: - react: '>=16.8' - react-router@6.26.2: resolution: {integrity: sha512-tvN1iuT03kHgOFnLPfLJ8V95eijteveqdOSk+srqfePtQvqCExB8eHOYnlilbOcyJyKnYkr1vJvf7YqotAJu1A==} engines: {node: '>=14.0.0'} @@ -21770,7 +21788,7 @@ snapshots: dependencies: react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - react-router-dom: 6.24.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + react-router-dom: 6.26.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@cspotcode/source-map-support@0.8.1': dependencies: @@ -25682,15 +25700,13 @@ snapshots: transitivePeerDependencies: - '@parcel/core' - '@parcel/cache@2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11)': + '@parcel/cache@2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))': dependencies: '@parcel/core': 2.12.0(@swc/helpers@0.5.11) '@parcel/fs': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/logger': 2.12.0 '@parcel/utils': 2.12.0 lmdb: 2.8.5 - transitivePeerDependencies: - - '@swc/helpers' '@parcel/codeframe@2.12.0': dependencies: @@ -25750,7 +25766,7 @@ snapshots: '@parcel/core@2.12.0(@swc/helpers@0.5.11)': dependencies: '@mischnic/json-sourcemap': 0.1.1 - '@parcel/cache': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) + '@parcel/cache': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) '@parcel/diagnostic': 2.12.0 '@parcel/events': 2.12.0 '@parcel/fs': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) @@ -26165,7 +26181,7 @@ snapshots: '@parcel/types@2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11)': dependencies: - '@parcel/cache': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) + '@parcel/cache': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) '@parcel/diagnostic': 2.12.0 '@parcel/fs': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/package-manager': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) @@ -27609,8 +27625,6 @@ snapshots: optionalDependencies: react: 18.3.1 - '@remix-run/router@1.17.1': {} - '@remix-run/router@1.19.2': {} '@repeaterjs/repeater@3.0.6': {} @@ -29485,6 +29499,8 @@ snapshots: dependencies: '@types/jest': 29.5.13 + '@types/history@4.7.11': {} + '@types/hosted-git-info@3.0.5': {} '@types/html-minifier-terser@6.1.0': {} @@ -29683,6 +29699,22 @@ snapshots: dependencies: '@types/react': 18.3.3 + '@types/react-router-dom@5.3.3': + dependencies: + '@types/history': 4.7.11 + '@types/react': 18.3.11 + '@types/react-router': 5.1.20 + + '@types/react-router@5.1.20': + dependencies: + '@types/history': 4.7.11 + '@types/react': 18.3.11 + + '@types/react@18.3.11': + dependencies: + '@types/prop-types': 15.7.12 + csstype: 3.1.3 + '@types/react@18.3.14': dependencies: '@types/prop-types': 15.7.12 @@ -30460,7 +30492,7 @@ snapshots: '@vanilla-extract/css@1.14.2': dependencies: '@emotion/hash': 0.9.1 - '@vanilla-extract/private': 1.0.5 + '@vanilla-extract/private': 1.0.6 chalk: 4.1.2 css-what: 6.1.0 cssesc: 3.0.0 @@ -30655,6 +30687,32 @@ snapshots: - supports-color - terser + '@vanilla-extract/integration@7.1.7(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)': + dependencies: + '@babel/core': 7.24.7 + '@babel/plugin-syntax-typescript': 7.24.7(@babel/core@7.24.7) + '@vanilla-extract/babel-plugin-debug-ids': 1.0.6 + '@vanilla-extract/css': 1.15.3 + dedent: 1.5.3 + esbuild: 0.21.5 + eval: 0.1.8 + find-up: 5.0.0 + javascript-stringify: 2.1.0 + mlly: 1.7.1 + vite: 5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) + vite-node: 1.6.0(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) + transitivePeerDependencies: + - '@types/node' + - babel-plugin-macros + - less + - lightningcss + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + '@vanilla-extract/next-plugin@2.1.2(@types/node@20.14.9)(lightningcss@1.25.1)(next@14.2.2(@opentelemetry/api@1.9.0)(@playwright/test@1.46.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(terser@5.31.1)(webpack@5.88.2)': dependencies: '@vanilla-extract/webpack-plugin': 2.3.7(@types/node@20.14.9)(lightningcss@1.25.1)(terser@5.31.1)(webpack@5.88.2) @@ -30758,8 +30816,6 @@ snapshots: - terser - webpack - '@vanilla-extract/private@1.0.5': {} - '@vanilla-extract/private@1.0.6': {} '@vanilla-extract/recipes@0.5.1(@vanilla-extract/css@1.14.2)': @@ -30818,6 +30874,22 @@ snapshots: - supports-color - terser + '@vanilla-extract/vite-plugin@4.0.7(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1))': + dependencies: + '@vanilla-extract/integration': 7.1.7(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) + vite: 5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) + transitivePeerDependencies: + - '@types/node' + - babel-plugin-macros + - less + - lightningcss + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + '@vanilla-extract/webpack-plugin@2.3.7(@types/node@20.14.9)(lightningcss@1.25.1)(terser@5.31.1)(webpack@5.88.2(@swc/core@1.3.107(@swc/helpers@0.5.11)))': dependencies: '@vanilla-extract/integration': 7.1.7(@types/node@20.14.9)(lightningcss@1.25.1)(terser@5.31.1) @@ -38104,7 +38176,7 @@ snapshots: media-query-parser@2.0.2: dependencies: - '@babel/runtime': 7.24.7 + '@babel/runtime': 7.25.6 media-typer@0.3.0: {} @@ -40711,13 +40783,6 @@ snapshots: react-refresh@0.9.0: {} - react-router-dom@6.24.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1): - dependencies: - '@remix-run/router': 1.17.1 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - react-router: 6.24.1(react@18.3.1) - react-router-dom@6.26.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: '@remix-run/router': 1.19.2 @@ -40725,11 +40790,6 @@ snapshots: react-dom: 18.3.1(react@18.3.1) react-router: 6.26.2(react@18.3.1) - react-router@6.24.1(react@18.3.1): - dependencies: - '@remix-run/router': 1.17.1 - react: 18.3.1 - react-router@6.26.2(react@18.3.1): dependencies: '@remix-run/router': 1.19.2 From 36ecd88f6eec8d81599b106253b93bc99ec2621c Mon Sep 17 00:00:00 2001 From: Nillo Date: Mon, 25 Nov 2024 01:00:12 +0100 Subject: [PATCH 042/103] feat(wallet-sdk-example) added nicely formatted markdown support for docs using kode-ui --- packages/apps/wallet-sdk-example/package.json | 6 + packages/apps/wallet-sdk-example/src/App.tsx | 7 +- .../src/components/Accordion.tsx | 76 -- .../src/components/ChainSelectorModal.tsx | 3 +- .../src/components/Root.tsx | 254 ++++++ .../src/components/TransactionModal.tsx | 4 +- .../src/components/Transfer.tsx | 4 +- .../src/components/Transfers.tsx | 4 +- .../src/components/WordPhrase.tsx | 4 +- .../wallet-sdk-example/src/components/docs.md | 798 ++++++++++++++++++ .../kadenaNames/KadenaNamesResolver.tsx | 4 +- .../kadenaNames/NameRegistrationModal.tsx | 4 +- .../apps/wallet-sdk-example/src/index.css | 4 +- .../apps/wallet-sdk-example/src/vite-env.d.ts | 1 - .../apps/wallet-sdk-example/src/vite.d.ts | 11 + pnpm-lock.yaml | 131 ++- 16 files changed, 1206 insertions(+), 109 deletions(-) delete mode 100644 packages/apps/wallet-sdk-example/src/components/Accordion.tsx create mode 100644 packages/apps/wallet-sdk-example/src/components/Root.tsx create mode 100644 packages/apps/wallet-sdk-example/src/components/docs.md delete mode 100644 packages/apps/wallet-sdk-example/src/vite-env.d.ts create mode 100644 packages/apps/wallet-sdk-example/src/vite.d.ts diff --git a/packages/apps/wallet-sdk-example/package.json b/packages/apps/wallet-sdk-example/package.json index e3dd212505..080ec352a4 100644 --- a/packages/apps/wallet-sdk-example/package.json +++ b/packages/apps/wallet-sdk-example/package.json @@ -16,11 +16,17 @@ "@kadena/kode-ui": "workspace:*", "@kadena/wallet-sdk": "workspace:*", "@tanstack/react-query": "^5.32.0", + "@types/markdown-it": "^14.1.2", "@types/react-router-dom": "^5.3.3", + "@types/react-syntax-highlighter": "^15.5.13", "@vanilla-extract/css": "1.14.2", "@vanilla-extract/vite-plugin": "4.0.7", "clsx": "^2.1.1", + "dompurify": "^3.2.1", + "highlight.js": "^11.10.0", + "html-react-parser": "^5.1.18", "jotai": "^2.10.1", + "markdown-it": "^14.1.0", "next-themes": "^0.2.1", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/packages/apps/wallet-sdk-example/src/App.tsx b/packages/apps/wallet-sdk-example/src/App.tsx index 1a3f7687c5..45e33b6c0d 100644 --- a/packages/apps/wallet-sdk-example/src/App.tsx +++ b/packages/apps/wallet-sdk-example/src/App.tsx @@ -4,12 +4,13 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { ThemeProvider } from 'next-themes'; import './global.css.ts'; -import { Navigate, Route, Routes } from 'react-router-dom'; +import { Route, Routes } from 'react-router-dom'; import Header from './components/Header'; +import { KadenaNames } from './components/kadenaNames/KadenaNamesResolver'; +import MarkdownPage from './components/Root'; import { Transfer } from './components/Transfer'; import { Transfers } from './components/Transfers'; import { Wallet } from './components/Wallet'; -import { KadenaNames } from './components/kadenaNames/KadenaNamesResolver'; const queryClient = new QueryClient(); @@ -27,7 +28,7 @@ function App() {
- } /> + } /> } /> } /> } /> diff --git a/packages/apps/wallet-sdk-example/src/components/Accordion.tsx b/packages/apps/wallet-sdk-example/src/components/Accordion.tsx deleted file mode 100644 index ee491d5899..0000000000 --- a/packages/apps/wallet-sdk-example/src/components/Accordion.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import { useEffect, useRef, useState } from 'react'; - -export interface AccordionSectionProps { - title: string; - children: React.ReactNode; - defaultOpen?: boolean; - onToggle?: (toggleFunction: () => void) => void; -} - -export function AccordionSection({ - title, - children, - defaultOpen = false, - onToggle, -}: AccordionSectionProps) { - const [isOpen, setIsOpen] = useState(defaultOpen); - const [maxHeight, setMaxHeight] = useState('0'); - const contentRef = useRef(null); - - const toggle = () => setIsOpen((prev) => !prev); - - useEffect(() => { - if (onToggle) { - onToggle(toggle); - } - }, [onToggle]); - - useEffect(() => { - const contentElement = contentRef.current; - - const updateMaxHeight = () => { - if (contentElement) { - setMaxHeight(isOpen ? `${contentElement.scrollHeight + 50}px` : '0'); - } - }; - - updateMaxHeight(); - - const observer = new ResizeObserver(updateMaxHeight); - if (contentElement) { - observer.observe(contentElement); - } - - return () => { - if (contentElement) { - observer.unobserve(contentElement); - } - }; - }, [isOpen]); - - return ( -
- -
-
{children}
-
-
- ); -} diff --git a/packages/apps/wallet-sdk-example/src/components/ChainSelectorModal.tsx b/packages/apps/wallet-sdk-example/src/components/ChainSelectorModal.tsx index 9983073942..c018f788f8 100644 --- a/packages/apps/wallet-sdk-example/src/components/ChainSelectorModal.tsx +++ b/packages/apps/wallet-sdk-example/src/components/ChainSelectorModal.tsx @@ -1,4 +1,5 @@ import { ChainId } from '@kadena/client'; +import { MonoOutgoingMultichainFunds } from '@kadena/kode-icons/system'; import { Button, ContentHeader, @@ -39,7 +40,7 @@ export const ChainSelectionModal: React.FC = ({ 🔗} + icon={} /> diff --git a/packages/apps/wallet-sdk-example/src/components/Root.tsx b/packages/apps/wallet-sdk-example/src/components/Root.tsx new file mode 100644 index 0000000000..5a5546a297 --- /dev/null +++ b/packages/apps/wallet-sdk-example/src/components/Root.tsx @@ -0,0 +1,254 @@ +import { + Card, + ContentHeader, + Divider, + Heading, + Text, + TextLink, +} from '@kadena/kode-ui'; + +import { MonoWallet } from '@kadena/kode-icons/system'; +import clsx from 'clsx'; +import DOMPurify from 'dompurify'; +import hljs from 'highlight.js'; +import 'highlight.js/styles/github.css'; +import parse, { + DOMNode, + Element, + HTMLReactParserOptions, +} from 'html-react-parser'; +import MarkdownIt from 'markdown-it'; +import React, { useEffect, useRef, useState } from 'react'; +import markdownContentRaw from './docs.md?raw'; + +export type HeadingElementType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; + +export type HeadingVariant = 'ui' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; + +const isElement = (node: DOMNode): node is Element => { + return node.type === 'tag'; +}; + +const mdParser: MarkdownIt = new MarkdownIt({ + html: true, + linkify: true, + typographer: true, + highlight: function (str: string, lang: string): string { + if (lang && hljs.getLanguage(lang)) { + try { + const highlighted = hljs.highlight(str, { language: lang }).value; + return `
${highlighted}
`; + } catch (error) { + console.error('Highlighting error:', error); + } + } + const escaped = mdParser.utils.escapeHtml(str); + return `
${escaped}
`; + }, +}); + +const MarkdownPage: React.FC = () => { + const [content, setContent] = useState(null); + const contentRef = useRef(null); + + useEffect(() => { + const processMarkdown = () => { + try { + const rawHtml = mdParser.render(markdownContentRaw); + + const sanitizedHtml = DOMPurify.sanitize(rawHtml, { + ALLOWED_TAGS: [ + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'p', + 'code', + 'pre', + 'strong', + 'em', + 'a', + 'ul', + 'ol', + 'li', + 'blockquote', + 'hr', + 'img', + 'table', + 'thead', + 'tbody', + 'tr', + 'th', + 'td', + 'span', + ], + ALLOWED_ATTR: ['href', 'src', 'alt', 'title', 'class'], + }); + + const options: HTMLReactParserOptions = { + replace: (domNode) => { + if (!isElement(domNode)) { + return undefined; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const element = domNode as any; + + if (element.name === 'hr') { + return ; + } + + if (['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(element.name)) { + const level = parseInt(element.name.charAt(1), 10) as + | 1 + | 2 + | 3 + | 4 + | 5 + | 6; + return ( + + {parse(domToString(element.children), options)} + + ); + } + + if (element.name === 'p') { + return ( + + {parse(domToString(element.children), options)} + + ); + } + + if ( + element.name === 'pre' && + element.children[0]?.name === 'code' + ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const codeElement = element.children[0] as any; + const className = codeElement.attribs.class || ''; + const language = + className.replace('language-', '') || 'plaintext'; + const highlighted = domToString(codeElement.children); + + return ( +
+                  
+                
+ ); + } + + if (element.name === 'code' && element.parent?.name !== 'pre') { + const codeContent = domToString(element.children); + return ( + + {codeContent} + + ); + } + + if (element.name === 'a') { + const href = element.attribs.href || '#'; + const isDisabled = element.attribs['data-disabled'] === 'true'; + const isCompact = element.attribs['data-compact'] === 'true'; + const withIcon = element.attribs['data-with-icon'] === 'true'; + const childrenContent = parse( + domToString(element.children), + options, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ) as any; + + return ( + + {childrenContent} + + ); + } + + return undefined; + }, + }; + + const reactContent = parse(sanitizedHtml, options); + + setContent(reactContent); + } catch (error) { + console.error('Error processing Markdown:', error); + } + }; + + processMarkdown(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + useEffect(() => { + if (contentRef.current) { + const codeBlocks = contentRef.current.querySelectorAll('pre code'); + codeBlocks.forEach((block) => { + hljs.highlightElement(block as HTMLElement); + }); + } + }, [content]); + + const domToString = (children: DOMNode[]): string => { + return children + .map((child) => { + if (child.type === 'text') { + return child.data || ''; + } else if (isElement(child)) { + const attrs = Object.entries(child.attribs || {}) + .map(([key, value]) => ` ${key}="${value}"`) + .join(''); + const childrenHtml = child.children + ? // eslint-disable-next-line @typescript-eslint/no-explicit-any + domToString(child.children as any) + : ''; + return `<${child.name}${attrs}>${childrenHtml}`; + } + return ''; + }) + .join(''); + }; + + return ( +
+ + } + /> +
+ +
+ +
+ {content} +
+
+
+ ); +}; + +export default MarkdownPage; diff --git a/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx b/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx index b4bbebedcc..e8c874377c 100644 --- a/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx +++ b/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx @@ -1,4 +1,4 @@ -import { MonoAccountBalance } from '@kadena/kode-icons/system'; +import { MonoCommit } from '@kadena/kode-icons/system'; import { Button, ContentHeader, @@ -34,7 +34,7 @@ export const TransactionModal: React.FC = ({ } + icon={} /> diff --git a/packages/apps/wallet-sdk-example/src/components/Transfer.tsx b/packages/apps/wallet-sdk-example/src/components/Transfer.tsx index c7c0d15fdc..0a86184f7b 100644 --- a/packages/apps/wallet-sdk-example/src/components/Transfer.tsx +++ b/packages/apps/wallet-sdk-example/src/components/Transfer.tsx @@ -1,5 +1,5 @@ import { ChainId, ICommand, IUnsignedCommand } from '@kadena/client'; -import { MonoArrowRight } from '@kadena/kode-icons/system'; +import { MonoAccountTree } from '@kadena/kode-icons/system'; import { Button, Card, @@ -144,7 +144,7 @@ export const Transfer = () => { } + icon={} /> diff --git a/packages/apps/wallet-sdk-example/src/components/Transfers.tsx b/packages/apps/wallet-sdk-example/src/components/Transfers.tsx index 2e36134d9e..0718a24fcf 100644 --- a/packages/apps/wallet-sdk-example/src/components/Transfers.tsx +++ b/packages/apps/wallet-sdk-example/src/components/Transfers.tsx @@ -1,4 +1,4 @@ -import { MonoCallToAction } from '@kadena/kode-icons/system'; +import { MonoFormatListBulleted } from '@kadena/kode-icons/system'; import { Card, Cell, @@ -31,7 +31,7 @@ export const Transfers = () => { } + icon={} /> diff --git a/packages/apps/wallet-sdk-example/src/components/WordPhrase.tsx b/packages/apps/wallet-sdk-example/src/components/WordPhrase.tsx index 514dc3d937..e39a0886f5 100644 --- a/packages/apps/wallet-sdk-example/src/components/WordPhrase.tsx +++ b/packages/apps/wallet-sdk-example/src/components/WordPhrase.tsx @@ -1,4 +1,4 @@ -import { MonoKeyboardArrowRight } from '@kadena/kode-icons/system'; +import { MonoShortText } from '@kadena/kode-icons/system'; import { Button, Card, @@ -35,7 +35,7 @@ export const WordPhrase = () => { heading="Word Phrase" description="Manage your wallet's mnemonic phrase. You can either generate a new random phrase or enter an existing one to restore your wallet." - icon={} + icon={} /> ; +``` + +**Parameters:** + +- `transaction`: `ICommand` - The signed transaction command. +- `networkId`: `string` - The network ID (e.g., `'mainnet01'`, `'testnet04'`). +- `chainId`: `ChainId` - The chain ID where the transaction will be executed. + +**Returns:** + +- `Promise`: An object containing the request key, chain + ID, and network ID of the transaction. + +**Example:** + +```typescript +const transactionDescriptor = await walletSdk.sendTransaction( + signedTransaction, + 'testnet04', + '1', +); + +console.log( + 'Transaction sent with request key:', + transactionDescriptor.requestKey, +); +``` + +--- + +### Retrieving History and Updates + +#### `getTransfers` + +Retrieves a list of transfers associated with an account. + +**Method Signature:** + +```typescript +getTransfers( + accountName: string, + networkId: string, + fungible?: string, + chainsIds?: ChainId[], +): Promise; +``` + +**Parameters:** + +- `accountName`: `string` - The account name to query (e.g., + `'k:accountPublicKey'`). +- `networkId`: `string` - The network ID. +- `fungible?`: `string` - Optional fungible token name (defaults to `'coin'`). +- `chainsIds?`: `ChainId[]` - Optional list of chain IDs to query. + +**Returns:** + +- `Promise`: A promise that resolves to an array of transfer + objects. + +**Example:** + +```typescript +const transfers = await walletSdk.getTransfers( + 'k:accountPublicKey', + 'testnet04', +); + +transfers.forEach((transfer) => { + console.log( + `Transfer of ${transfer.amount} from ${transfer.senderAccount} to ${transfer.receiverAccount}`, + ); +}); +``` + +#### `subscribeOnCrossChainComplete` + +Subscribes to cross-chain transfer completion events. + +**Method Signature:** + +```typescript +subscribeOnCrossChainComplete( + transfers: ITransactionDescriptor[], + callback: (transfer: Transfer) => void, + options?: { signal?: AbortSignal }, +): void; +``` + +**Parameters:** + +- `transfers`: `ITransactionDescriptor[]` - An array of transaction descriptors + representing the cross-chain transfers to monitor. +- `callback`: `(transfer: Transfer) => void` - A function to call when a + transfer completes. +- `options?`: `{ signal?: AbortSignal }` - Optional settings, including an + `AbortSignal` to cancel the subscription. + +**Example:** + +```typescript +walletSdk.subscribeOnCrossChainComplete( + [crossChainTransactionDescriptor], + (transfer) => { + console.log('Cross-chain transfer completed:', transfer); + }, +); +``` + +#### `waitForPendingTransaction` + +Waits for a pending transaction to be confirmed on the network. + +**Method Signature:** + +```typescript +waitForPendingTransaction( + transaction: ITransactionDescriptor, + options?: { signal?: AbortSignal }, +): Promise; +``` + +**Parameters:** + +- `transaction`: `ITransactionDescriptor` - The transaction descriptor to wait + for. +- `options?`: `{ signal?: AbortSignal }` - Optional settings, including an + `AbortSignal` to cancel the waiting. + +**Returns:** + +- `Promise`: A promise that resolves to the transaction result. + +**Example:** + +```typescript +const result = await walletSdk.waitForPendingTransaction(transactionDescriptor); + +if (result.status === 'success') { + console.log('Transaction confirmed:', result.data); +} else { + console.error('Transaction failed:', result.error); +} +``` + +#### `subscribePendingTransactions` + +Subscribes to updates for multiple pending transactions. + +**Method Signature:** + +```typescript +subscribePendingTransactions( + transactions: ITransactionDescriptor[], + callback: ( + transaction: ITransactionDescriptor, + result: ResponseResult, + ) => void, + options?: { signal?: AbortSignal }, +): void; +``` + +**Parameters:** + +- `transactions`: `ITransactionDescriptor[]` - An array of transaction + descriptors representing the transactions to monitor. +- `callback`: + `(transaction: ITransactionDescriptor, result: ResponseResult) => void` - A + function to call when a transaction status updates. +- `options?`: `{ signal?: AbortSignal }` - Optional settings, including an + `AbortSignal`. + +**Example:** + +```typescript +walletSdk.subscribePendingTransactions( + [transactionDescriptor1, transactionDescriptor2], + (transaction, result) => { + if (result.status === 'success') { + console.log(`Transaction ${transaction.requestKey} confirmed`); + } else { + console.error( + `Transaction ${transaction.requestKey} failed`, + result.error, + ); + } + }, +); +``` + +--- + +## Account Information + +### `getAccountDetails` + +Retrieves detailed information about an account across multiple chains. + +**Method Signature:** + +```typescript +getAccountDetails( + accountName: string, + networkId: string, + fungible: string, + chainIds?: ChainId[], +): Promise; +``` + +**Parameters:** + +- `accountName`: `string` - The account name to query (e.g., + `'k:accountPublicKey'`). +- `networkId`: `string` - The network ID. +- `fungible`: `string` - The fungible token name (e.g., `'coin'`). +- `chainIds?`: `ChainId[]` - Optional list of chain IDs to query. + +**Returns:** + +- `Promise`: A promise that resolves to an array of account + details for each chain. + +**Example:** + +```typescript +const accountDetails = await walletSdk.getAccountDetails( + 'k:accountPublicKey', + 'testnet04', + 'coin', +); + +accountDetails.forEach((detail) => { + if (detail.accountDetails) { + console.log( + `Chain ${detail.chainId} balance:`, + detail.accountDetails.balance, + ); + } else { + console.log(`Chain ${detail.chainId} has no account details.`); + } +}); +``` + +--- + +## Miscellaneous Functions + +### `getChains` + +Retrieves the list of chains available on a network. + +**Method Signature:** + +```typescript +getChains(networkHost: string): Promise; +``` + +**Parameters:** + +- `networkHost`: `string` - The network host URL (e.g., + `'https://api.testnet.chainweb.com'`). + +**Returns:** + +- `Promise`: A promise that resolves to an array of chain objects, + each with an `id` property. + +**Example:** + +```typescript +const chains = await walletSdk.getChains('https://api.testnet.chainweb.com'); + +chains.forEach((chain) => { + console.log('Available chain ID:', chain.id); +}); +``` + +### `getNetworkInfo` + +Retrieves network information. _(Note: Currently returns `null` as this method +is a placeholder for future implementation.)_ + +**Method Signature:** + +```typescript +getNetworkInfo(networkHost: string): Promise; +``` + +**Parameters:** + +- `networkHost`: `string` - The network host URL. + +**Returns:** + +- `Promise`: A promise that resolves to network information. + +**Example:** + +```typescript +const networkInfo = await walletSdk.getNetworkInfo( + 'https://api.testnet.chainweb.com', +); + +console.log('Network Info:', networkInfo); +``` + +### `getGasLimitEstimate` + +Estimates the gas limit required for a transaction. + +**Method Signature:** + +```typescript +getGasLimitEstimate( + transaction: ICommand, + networkId: string, + chainId: ChainId, +): Promise; +``` + +**Parameters:** + +- `transaction`: `ICommand` - The unsigned or signed transaction command to + estimate gas for. +- `networkId`: `string` - The network ID. +- `chainId`: `ChainId` - The chain ID where the transaction will be executed. + +**Returns:** + +- `Promise`: A promise that resolves to the estimated gas limit. + +**Example:** + +```typescript +const gasLimit = await walletSdk.getGasLimitEstimate( + unsignedTransaction, + 'testnet04', + '1', +); + +console.log('Estimated Gas Limit:', gasLimit); +``` + +--- + +## Extras + +--- + +### Exchange Helper + +Provides functionality to retrieve token information from the ETHVM Dev API. + +#### `getEthvmDevTokenInfo` + +Fetches token information such as current price, supply, and 24-hour high/low +values. + +**Method Signature:** + +```typescript +getEthvmDevTokenInfo( + tokens?: T[], +): Promise>; +``` + +**Parameters:** + +- `tokens?`: `T[]` - An array of token names as strings (default is + `['kadena']`). + +**Returns:** + +- `Promise>`: A promise that resolves + to a record mapping token names to their information. + +**Example:** + +```typescript +const tokenInfo = await walletSdk.exchange.getEthvmDevTokenInfo(['kadena']); + +console.log('Kadena Token Info:', tokenInfo.kadena); +``` + +--- + +### Kadena Names Service + +Provides functions to resolve Kadena names to addresses and vice versa. + +#### `nameToAddress` + +Resolves a Kadena name (e.g., a human-readable name) to a Kadena address. + +**Method Signature:** + +```typescript +nameToAddress(name: string, networkId: string): Promise; +``` + +**Parameters:** + +- `name`: `string` - The Kadena name to resolve (e.g., `'example.kda'`). +- `networkId`: `string` - The network ID. + +**Returns:** + +- `Promise`: A promise that resolves to the address or `null` if + not found. + +**Example:** + +```typescript +const address = await walletSdk.kadenaNames.nameToAddress( + 'example.kda', + 'testnet04', +); + +if (address) { + console.log('Resolved address:', address); +} else { + console.log('No address found for the given name.'); +} +``` + +#### `addressToName` + +Resolves a Kadena address to a Kadena name. + +**Method Signature:** + +```typescript +addressToName(address: string, networkId: string): Promise; +``` + +**Parameters:** + +- `address`: `string` - The Kadena address to resolve (e.g., + `'k:accountPublicKey'`). +- `networkId`: `string` - The network ID. + +**Returns:** + +- `Promise`: A promise that resolves to the name or `null` if not + found. + +**Example:** + +```typescript +const name = await walletSdk.kadenaNames.addressToName( + 'k:accountPublicKey', + 'testnet04', +); + +if (name) { + console.log('Resolved name:', name); +} else { + console.log('No name found for the given address.'); +} +``` + +--- + +## Conclusion + +The Kadena Wallet SDK offers a comprehensive set of tools to integrate Kadena +blockchain functionalities into your wallet applications easily. Designed with +developers in mind, it ensures that even those with intermediate experience can +build robust wallets without delving into the complexities of blockchain +interactions. + +By providing clear methods with well-defined parameters, the SDK simplifies +tasks such as transaction creation, account querying, and handling cross-chain +transfers. With the Kadena Wallet SDK, building wallets on Kadena is as clear as +day. + +For more information and advanced usage, please refer to the SDK documentation +and explore the various classes and methods provided. + +--- + +## Happy Coding! + +With the Kadena Wallet SDK and Kadena HD Wallet, you're well-equipped to build +powerful and secure wallet applications on the Kadena blockchain. Dive into the +documentation, explore the features, and start building today! + +--- + +## Additional Resources + +- [Kadena Official Website](https://kadena.io/) +- [Kadena Documentation](https://docs.kadena.io/) +- [Kadena GitHub Repository](https://github.com/kadena-io/) diff --git a/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx b/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx index 6d2c9e1680..a83e1c3d8f 100644 --- a/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx +++ b/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx @@ -8,7 +8,7 @@ import { TextField, } from '@kadena/kode-ui'; -import { MonoAccountTree } from '@kadena/kode-icons'; +import { MonoShortcut } from '@kadena/kode-icons'; import React from 'react'; import { @@ -42,7 +42,7 @@ export const KadenaNames: React.FC = () => { } + icon={} /> diff --git a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx index 70e7201015..662560906a 100644 --- a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx +++ b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx @@ -1,4 +1,4 @@ -import { MonoAccountBalance } from '@kadena/kode-icons/system'; +import { MonoShortText } from '@kadena/kode-icons/system'; import { Button, ContentHeader, Dialog, Divider, Stack } from '@kadena/kode-ui'; import React from 'react'; import { NameRegistrationForm } from './NameRegistrationForm'; @@ -30,7 +30,7 @@ export const NameRegistrationModal: React.FC = ({ } + icon={} /> diff --git a/packages/apps/wallet-sdk-example/src/index.css b/packages/apps/wallet-sdk-example/src/index.css index cd47d2f6a6..cf523b67bd 100644 --- a/packages/apps/wallet-sdk-example/src/index.css +++ b/packages/apps/wallet-sdk-example/src/index.css @@ -2,10 +2,10 @@ @tailwind utilities; - +/* [class^="Form__"] { width: 100%; -} +} */ [class^="Dialog"] { max-height: inherit diff --git a/packages/apps/wallet-sdk-example/src/vite-env.d.ts b/packages/apps/wallet-sdk-example/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2a0..0000000000 --- a/packages/apps/wallet-sdk-example/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/packages/apps/wallet-sdk-example/src/vite.d.ts b/packages/apps/wallet-sdk-example/src/vite.d.ts new file mode 100644 index 0000000000..0d4f39edb6 --- /dev/null +++ b/packages/apps/wallet-sdk-example/src/vite.d.ts @@ -0,0 +1,11 @@ +/// + +declare module '*.md' { + const content: string; + export default content; +} + +declare module '*.md?raw' { + const content: string; + export default content; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 605846e44d..b9abaacc01 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1648,9 +1648,15 @@ importers: '@tanstack/react-query': specifier: ^5.32.0 version: 5.49.2(react@18.3.1) + '@types/markdown-it': + specifier: ^14.1.2 + version: 14.1.2 '@types/react-router-dom': specifier: ^5.3.3 version: 5.3.3 + '@types/react-syntax-highlighter': + specifier: ^15.5.13 + version: 15.5.13 '@vanilla-extract/css': specifier: 1.14.2 version: 1.14.2 @@ -1660,9 +1666,21 @@ importers: clsx: specifier: ^2.1.1 version: 2.1.1 + dompurify: + specifier: ^3.2.1 + version: 3.2.1 + highlight.js: + specifier: ^11.10.0 + version: 11.10.0 + html-react-parser: + specifier: ^5.1.18 + version: 5.1.18(@types/react@18.3.14)(react@18.3.1) jotai: specifier: ^2.10.1 version: 2.10.1(@types/react@18.3.14)(react@18.3.1) + markdown-it: + specifier: ^14.1.0 + version: 14.1.0 next-themes: specifier: ^0.2.1 version: 0.2.1(next@14.2.2(@opentelemetry/api@1.9.0)(@playwright/test@1.46.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -9759,6 +9777,9 @@ packages: '@types/markdown-it@14.1.1': resolution: {integrity: sha512-4NpsnpYl2Gt1ljyBGrKMxFYAYvpqbnnkgP/i/g+NLpjEUa3obn1XJCur9YbEXKDAkaXqsR1LbDnGEJ0MmKFxfg==} + '@types/markdown-it@14.1.2': + resolution: {integrity: sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog==} + '@types/mdast@3.0.15': resolution: {integrity: sha512-LnwD+mUEfxWMa1QpDraczIn6k0Ee3SMicuYSSzS6ZYl2gKS09EClnJYGd8Du6rfc5r/GZEk5o1mRb8TaTj03sQ==} @@ -9855,6 +9876,9 @@ packages: '@types/react-router@5.1.20': resolution: {integrity: sha512-jGjmu/ZqS7FjSH6owMcD5qpq19+1RS9DeVRqfl1FeBMxTDQAGwlMWOcs52NDoXaNKyG3d1cYQFMs9rCrb88o9Q==} + '@types/react-syntax-highlighter@15.5.13': + resolution: {integrity: sha512-uLGJ87j6Sz8UaBAooU0T6lWJ0dBmjZgN1PZTrj05TNql2/XpC6+4HhMT5syIdFUUt+FASfCeLLv4kBygNU+8qA==} + '@types/react@18.3.11': resolution: {integrity: sha512-r6QZ069rFTjrEYgFdOck1gK7FLVsgJE7tTz0pQBczlBNUhBNk0MQH4UbnFSwjpQLMkLzgqvBBa+qGpLje16eTQ==} @@ -12563,6 +12587,9 @@ packages: dompurify@3.1.5: resolution: {integrity: sha512-lwG+n5h8QNpxtyrJW/gJWckL+1/DQiYMX8f7t8Z2AZTPw1esVrqjI63i7Zc2Gz0aKzLVMYC1V1PL/ky+aY/NgA==} + dompurify@3.2.1: + resolution: {integrity: sha512-NBHEsc0/kzRYQd+AY6HR6B/IgsqzBABrqJbpCDQII/OK6h7B7LXzweZTDsqSW2LkTRpoxf18YUP+YjGySk6B3w==} + domutils@2.8.0: resolution: {integrity: sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==} @@ -13973,6 +14000,10 @@ packages: highlight.js@10.7.3: resolution: {integrity: sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==} + highlight.js@11.10.0: + resolution: {integrity: sha512-SYVnVFswQER+zu1laSya563s+F8VDGt7o35d4utbamowvUNLLMovFqwCLSocpZTz3MgaSRA1IbqRWZv97dtErQ==} + engines: {node: '>=12.0.0'} + hmac-drbg@1.0.1: resolution: {integrity: sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==} @@ -13994,6 +14025,9 @@ packages: resolution: {integrity: sha512-puUZAUKT5m8Zzvs72XWy3HtvVbTWljRE66cP60bxJzAqf2DgICo7lYTY2IHUmLnNpjYvw5bvmoHvPc0QO2a62w==} engines: {node: ^16.14.0 || >=18.0.0} + html-dom-parser@5.0.10: + resolution: {integrity: sha512-GwArYL3V3V8yU/mLKoFF7HlLBv80BZ2Ey1BzfVNRpAci0cEKhFHI/Qh8o8oyt3qlAMLlK250wsxLdYX4viedvg==} + html-encoding-sniffer@3.0.0: resolution: {integrity: sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==} engines: {node: '>=12'} @@ -14012,6 +14046,15 @@ packages: engines: {node: '>=12'} hasBin: true + html-react-parser@5.1.18: + resolution: {integrity: sha512-65BwC0zzrdeW96jB2FRr5f1ovBhRMpLPJNvwkY5kA8Ay5xdL9t/RH2/uUTM7p+cl5iM88i6dDk4LXtfMnRmaJQ==} + peerDependencies: + '@types/react': 0.14 || 15 || 16 || 17 || 18 + react: 0.14 || 15 || 16 || 17 || 18 + peerDependenciesMeta: + '@types/react': + optional: true + html-void-elements@3.0.0: resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==} @@ -14069,6 +14112,9 @@ packages: htmlparser2@8.0.2: resolution: {integrity: sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==} + htmlparser2@9.1.0: + resolution: {integrity: sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==} + http-cache-semantics@4.1.1: resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==} @@ -14272,6 +14318,9 @@ packages: inline-style-parser@0.1.1: resolution: {integrity: sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q==} + inline-style-parser@0.2.4: + resolution: {integrity: sha512-0aO8FkhNZlj/ZIbNi7Lxxr12obT7cL1moPfE4tg1LkX7LlLfC6DeX4l2ZEud1ukP9jNQyNnfzQVqwbwmAATY4Q==} + inline-style-prefixer@7.0.0: resolution: {integrity: sha512-I7GEdScunP1dQ6IM2mQWh6v0mOYdYmH3Bp31UecKdrcUgcURTcctSe1IECdUznSHKSmsHtjrT3CwCPI1pyxfUQ==} @@ -17740,6 +17789,9 @@ packages: '@types/react': '>=16' react: '>=16' + react-property@2.0.2: + resolution: {integrity: sha512-+PbtI3VuDV0l6CleQMsx2gtK0JZbZKbpdu5ynr+lbsuvtmgbNcS3VM0tuY2QjFNOcWxvXeHjDpy42RO+4U2rug==} + react-qrcode-logo@2.10.0: resolution: {integrity: sha512-Q1+jLtcyDl5rLR29YdkXVLzYk62p3+541x00HxURVBQhs6SqFyEZZVhvkU/VQ082ytXa3GdCmGWMLK5z0Vhe7g==} peerDependencies: @@ -18539,10 +18591,6 @@ packages: resolution: {integrity: sha512-d76wfhgUuGypKqY72Unm5LFnMpACbdxXsLPcL27pOsSrmVqH3PztFp1uq+Z22suk15h7vXmTesuh2aEjdCqb5w==} hasBin: true - source-map-js@1.2.0: - resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} - engines: {node: '>=0.10.0'} - source-map-js@1.2.1: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} @@ -18850,9 +18898,15 @@ packages: peerDependencies: webpack: ^5.0.0 + style-to-js@1.1.16: + resolution: {integrity: sha512-/Q6ld50hKYPH3d/r6nr117TZkHR0w0kGGIVfpG9N6D8NymRPM9RqCUv4pRpJ62E5DqOYx2AFpbZMyCPnjQCnOw==} + style-to-object@0.4.4: resolution: {integrity: sha512-HYNoHZa2GorYNyqiCaBgsxvcJIn7OHq6inEga+E6Ke3m5JkoqpQbnFssk4jwe+K7AhGa2fcha4wSOf1Kn01dMg==} + style-to-object@1.0.8: + resolution: {integrity: sha512-xT47I/Eo0rwJmaXC4oilDGDWLohVhR6o/xAQcPQN8q6QBuZVL8qMYL85kLmST5cPjAorwvqIA4qXTRQoYHaL6g==} + styled-components@5.3.11: resolution: {integrity: sha512-uuzIIfnVkagcVHv9nE0VPlHPSCmXIUGKfJ42LNjxCCTDTL5sgnJ8Z7GZBq0EnLYGln77tPpEpExt2+qa+cZqSw==} engines: {node: '>=10'} @@ -25700,13 +25754,15 @@ snapshots: transitivePeerDependencies: - '@parcel/core' - '@parcel/cache@2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))': + '@parcel/cache@2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11)': dependencies: '@parcel/core': 2.12.0(@swc/helpers@0.5.11) '@parcel/fs': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/logger': 2.12.0 '@parcel/utils': 2.12.0 lmdb: 2.8.5 + transitivePeerDependencies: + - '@swc/helpers' '@parcel/codeframe@2.12.0': dependencies: @@ -25766,7 +25822,7 @@ snapshots: '@parcel/core@2.12.0(@swc/helpers@0.5.11)': dependencies: '@mischnic/json-sourcemap': 0.1.1 - '@parcel/cache': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) + '@parcel/cache': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/diagnostic': 2.12.0 '@parcel/events': 2.12.0 '@parcel/fs': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) @@ -26181,7 +26237,7 @@ snapshots: '@parcel/types@2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11)': dependencies: - '@parcel/cache': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) + '@parcel/cache': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/diagnostic': 2.12.0 '@parcel/fs': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/package-manager': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) @@ -29251,7 +29307,7 @@ snapshots: '@testing-library/dom@9.3.4': dependencies: '@babel/code-frame': 7.24.7 - '@babel/runtime': 7.24.7 + '@babel/runtime': 7.25.6 '@types/aria-query': 5.0.4 aria-query: 5.1.3 chalk: 4.1.2 @@ -29607,6 +29663,11 @@ snapshots: '@types/linkify-it': 5.0.0 '@types/mdurl': 2.0.0 + '@types/markdown-it@14.1.2': + dependencies: + '@types/linkify-it': 5.0.0 + '@types/mdurl': 2.0.0 + '@types/mdast@3.0.15': dependencies: '@types/unist': 2.0.10 @@ -29710,6 +29771,10 @@ snapshots: '@types/history': 4.7.11 '@types/react': 18.3.11 + '@types/react-syntax-highlighter@15.5.13': + dependencies: + '@types/react': 18.3.11 + '@types/react@18.3.11': dependencies: '@types/prop-types': 15.7.12 @@ -33849,6 +33914,10 @@ snapshots: dompurify@3.1.5: {} + dompurify@3.2.1: + optionalDependencies: + '@types/trusted-types': 2.0.7 + domutils@2.8.0: dependencies: dom-serializer: 1.4.1 @@ -36055,6 +36124,8 @@ snapshots: highlight.js@10.7.3: {} + highlight.js@11.10.0: {} + hmac-drbg@1.0.1: dependencies: hash.js: 1.1.7 @@ -36079,6 +36150,11 @@ snapshots: dependencies: lru-cache: 10.3.0 + html-dom-parser@5.0.10: + dependencies: + domhandler: 5.0.3 + htmlparser2: 9.1.0 + html-encoding-sniffer@3.0.0: dependencies: whatwg-encoding: 2.0.0 @@ -36101,6 +36177,16 @@ snapshots: relateurl: 0.2.7 terser: 5.31.1 + html-react-parser@5.1.18(@types/react@18.3.14)(react@18.3.1): + dependencies: + domhandler: 5.0.3 + html-dom-parser: 5.0.10 + react: 18.3.1 + react-property: 2.0.2 + style-to-js: 1.1.16 + optionalDependencies: + '@types/react': 18.3.14 + html-void-elements@3.0.0: {} html-webpack-plugin@5.6.0(webpack@5.88.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(esbuild@0.21.5)): @@ -36150,6 +36236,13 @@ snapshots: domutils: 3.1.0 entities: 4.5.0 + htmlparser2@9.1.0: + dependencies: + domelementtype: 2.3.0 + domhandler: 5.0.3 + domutils: 3.1.0 + entities: 4.5.0 + http-cache-semantics@4.1.1: {} http-errors@2.0.0: @@ -36352,6 +36445,8 @@ snapshots: inline-style-parser@0.1.1: {} + inline-style-parser@0.2.4: {} + inline-style-prefixer@7.0.0: dependencies: css-in-js-utils: 3.1.0 @@ -39140,7 +39235,7 @@ snapshots: '@next/env': 14.2.2 '@swc/helpers': 0.5.5 busboy: 1.6.0 - caniuse-lite: 1.0.30001640 + caniuse-lite: 1.0.30001675 graceful-fs: 4.2.11 postcss: 8.4.31 react: 18.3.1 @@ -40218,8 +40313,8 @@ snapshots: postcss@8.4.31: dependencies: nanoid: 3.3.7 - picocolors: 1.0.1 - source-map-js: 1.2.0 + picocolors: 1.1.0 + source-map-js: 1.2.1 postcss@8.4.47: dependencies: @@ -40720,7 +40815,7 @@ snapshots: react-error-boundary@3.1.4(react@18.3.1): dependencies: - '@babel/runtime': 7.24.7 + '@babel/runtime': 7.25.6 react: 18.3.1 react-error-overlay@6.0.9: {} @@ -40772,6 +40867,8 @@ snapshots: transitivePeerDependencies: - supports-color + react-property@2.0.2: {} + react-qrcode-logo@2.10.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: lodash.isequal: 4.5.0 @@ -41859,8 +41956,6 @@ snapshots: semver: 7.6.3 sort-object-keys: 1.1.3 - source-map-js@1.2.0: {} - source-map-js@1.2.1: {} source-map-support@0.5.13: @@ -42197,10 +42292,18 @@ snapshots: dependencies: webpack: 5.88.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(esbuild@0.21.5) + style-to-js@1.1.16: + dependencies: + style-to-object: 1.0.8 + style-to-object@0.4.4: dependencies: inline-style-parser: 0.1.1 + style-to-object@1.0.8: + dependencies: + inline-style-parser: 0.2.4 + styled-components@5.3.11(@babel/core@7.24.7)(react-dom@18.3.1(react@18.3.1))(react-is@18.3.1)(react@18.3.1): dependencies: '@babel/helper-module-imports': 7.24.7(supports-color@5.5.0) From d120df78631496ba76923834b4f688e245bbb59c Mon Sep 17 00:00:00 2001 From: Nillo Date: Mon, 25 Nov 2024 01:06:02 +0100 Subject: [PATCH 043/103] chore(wallet-sdk-example): cleanup readme docs --- .../wallet-sdk-example/src/components/docs.md | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/packages/apps/wallet-sdk-example/src/components/docs.md b/packages/apps/wallet-sdk-example/src/components/docs.md index cd86604031..bf3e5a78e6 100644 --- a/packages/apps/wallet-sdk-example/src/components/docs.md +++ b/packages/apps/wallet-sdk-example/src/components/docs.md @@ -1,8 +1,9 @@ Welcome to the Example Wallet App! This wallet application leverages the robust -capabilities of the Kadena Wallet SDK to provide a seamless and secure -experience for managing your blockchain assets. Designed with user-friendliness -and advanced functionality in mind, our wallet ensures that you can effortlessly -interact with the Kadena network while enjoying a feature-rich interface. +capabilities of **Kadena Wallet SDK** to provide a seamless and secure +experience for managing your blockchain assets. Designed with UI building blocks +of **Kadena Kode-UI** with user-friendliness and advanced functionality in mind, +our wallet ensures that you can effortlessly interact with the Kadena network +while enjoying a feature-rich interface. The Kadena Wallet SDK provides a simple and unified interface to integrate Kadena blockchain functionalities into your wallet applications. It abstracts @@ -765,28 +766,11 @@ if (name) { --- -## Conclusion - -The Kadena Wallet SDK offers a comprehensive set of tools to integrate Kadena -blockchain functionalities into your wallet applications easily. Designed with -developers in mind, it ensures that even those with intermediate experience can -build robust wallets without delving into the complexities of blockchain -interactions. - -By providing clear methods with well-defined parameters, the SDK simplifies -tasks such as transaction creation, account querying, and handling cross-chain -transfers. With the Kadena Wallet SDK, building wallets on Kadena is as clear as -day. - -For more information and advanced usage, please refer to the SDK documentation -and explore the various classes and methods provided. - ---- - ## Happy Coding! -With the Kadena Wallet SDK and Kadena HD Wallet, you're well-equipped to build -powerful and secure wallet applications on the Kadena blockchain. Dive into the +With the Kadena Wallet SDK, Kadena HD Wallet, ande Kadena Kode-UI you're +well-equipped to build powerful and secure wallet applications on the Kadena +blockchain. Please use this example app as a Reference and dive into the documentation, explore the features, and start building today! --- From be0729c585c6d240888852f6389f36aa3ca1ddfb Mon Sep 17 00:00:00 2001 From: Nillo Date: Mon, 25 Nov 2024 01:18:59 +0100 Subject: [PATCH 044/103] chore(wallet-sdk-example): cleanup readme docs --- .../wallet-sdk-example/src/components/Root.tsx | 16 +++++++++++++--- packages/apps/wallet-sdk-example/src/index.css | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/apps/wallet-sdk-example/src/components/Root.tsx b/packages/apps/wallet-sdk-example/src/components/Root.tsx index 5a5546a297..ed3dac87f1 100644 --- a/packages/apps/wallet-sdk-example/src/components/Root.tsx +++ b/packages/apps/wallet-sdk-example/src/components/Root.tsx @@ -120,7 +120,7 @@ const MarkdownPage: React.FC = () => { if (element.name === 'p') { return ( - + {parse(domToString(element.children), options)} ); @@ -138,7 +138,17 @@ const MarkdownPage: React.FC = () => { const highlighted = domToString(codeElement.children); return ( -
+                
                    {
               const codeContent = domToString(element.children);
               return (
                 
diff --git a/packages/apps/wallet-sdk-example/src/index.css b/packages/apps/wallet-sdk-example/src/index.css
index cf523b67bd..cd47d2f6a6 100644
--- a/packages/apps/wallet-sdk-example/src/index.css
+++ b/packages/apps/wallet-sdk-example/src/index.css
@@ -2,10 +2,10 @@
 @tailwind utilities;
 
 
-/*
+
 [class^="Form__"] {
   width: 100%;
-} */
+}
 
 [class^="Dialog"] {
   max-height: inherit

From 6f8e74c645b8eb804b34f27c2a19da02509a2f54 Mon Sep 17 00:00:00 2001
From: Nillo 
Date: Mon, 25 Nov 2024 01:27:31 +0100
Subject: [PATCH 045/103] chore(wallet-sdk-example): balance indication color

---
 .../src/components/AccountItem.tsx                | 15 +++++++++++----
 packages/apps/wallet-sdk-example/src/index.css    |  1 -
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx
index f31e8fd7d3..664f86f753 100644
--- a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx
+++ b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx
@@ -75,6 +75,15 @@ export const AccountItem: React.FC = ({
     onFundAccount();
   };
 
+  const accountBalanceRaw = accountsBalances[account.name];
+  const accountBalance =
+    accountBalanceRaw !== undefined && accountBalanceRaw !== null
+      ? Number(accountBalanceRaw)
+      : 0;
+
+  // Determine the variant based on the account balance
+  const badgeVariant = accountBalance > 0 ? 'positive' : 'negative';
+
   return (
     <>
       
@@ -102,10 +111,8 @@ export const AccountItem: React.FC = ({
             
               Balance:
             
-            
-              {loadingBalance
-                ? 'Loading...'
-                : accountsBalances[account.name] ?? '0'}
+            
+              {loadingBalance ? 'Loading...' : accountBalance.toLocaleString()}
             
           
 
diff --git a/packages/apps/wallet-sdk-example/src/index.css b/packages/apps/wallet-sdk-example/src/index.css
index cd47d2f6a6..a7dd22d3f5 100644
--- a/packages/apps/wallet-sdk-example/src/index.css
+++ b/packages/apps/wallet-sdk-example/src/index.css
@@ -2,7 +2,6 @@
 @tailwind utilities;
 
 
-
 [class^="Form__"] {
   width: 100%;
 }

From 39257d748804e8d49d0203a43b184b5b6a8cd9c8 Mon Sep 17 00:00:00 2001
From: Nillo 
Date: Mon, 25 Nov 2024 08:33:17 +0100
Subject: [PATCH 046/103] chore(wallet-sdk-example): cleanup

---
 packages/apps/wallet-sdk-example/index.html           |  4 ++--
 .../wallet-sdk-example/src/components/Transfers.tsx   |  1 +
 .../apps/wallet-sdk-example/src/components/docs.md    |  2 +-
 packages/apps/wallet-sdk-example/src/index.css        | 10 ++++++++++
 .../wallet-sdk-example/src/utils/kadenanames/date.ts  |  1 +
 .../src/utils/kadenanames/transactionParser.ts        |  1 +
 packages/apps/wallet-sdk-example/tailwind.config.mjs  | 11 -----------
 packages/apps/wallet-sdk-example/tsconfig.json        |  1 +
 8 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/packages/apps/wallet-sdk-example/index.html b/packages/apps/wallet-sdk-example/index.html
index 80cef4eb3b..a4e90efdd6 100644
--- a/packages/apps/wallet-sdk-example/index.html
+++ b/packages/apps/wallet-sdk-example/index.html
@@ -5,8 +5,8 @@
     
     
     Vite + React + TS
-       
-       
+      
+      
        {
   const { transfers, pendingTransfers, account } = useTransfers();
 
+  // eslint-disable-next-line @typescript-eslint/no-explicit-any
   const getAmountStyle = (transfer: any) => {
     if (!transfer.success) return 'text-default';
     return transfer.senderAccount === account
diff --git a/packages/apps/wallet-sdk-example/src/components/docs.md b/packages/apps/wallet-sdk-example/src/components/docs.md
index bf3e5a78e6..7b1367fc8b 100644
--- a/packages/apps/wallet-sdk-example/src/components/docs.md
+++ b/packages/apps/wallet-sdk-example/src/components/docs.md
@@ -17,7 +17,7 @@ integrations.
 
 For key generation and signing functionalities, you will need the Kadena HD
 Wallet package. Please refer to the
-[Kadena HD Wallet documentation](https://github.com/kadena-io/kadena.js/tree/master/packages/hdwallet)
+[Kadena HD Wallet documentation](https://github.com/kadena-io/kadena.js/tree/master/packages/libs/hd-wallet)
 for detailed instructions on how to generate keys and sign transactions
 securely.
 
diff --git a/packages/apps/wallet-sdk-example/src/index.css b/packages/apps/wallet-sdk-example/src/index.css
index a7dd22d3f5..f07e1204bc 100644
--- a/packages/apps/wallet-sdk-example/src/index.css
+++ b/packages/apps/wallet-sdk-example/src/index.css
@@ -13,3 +13,13 @@
 textarea {
   width: 100%;
 }
+
+
+/* deze nog fixen */
+.text-negative {
+  color: green
+}
+
+.text-negative {
+  color: red
+}
diff --git a/packages/apps/wallet-sdk-example/src/utils/kadenanames/date.ts b/packages/apps/wallet-sdk-example/src/utils/kadenanames/date.ts
index e0567f34ae..54fc8c8a93 100644
--- a/packages/apps/wallet-sdk-example/src/utils/kadenanames/date.ts
+++ b/packages/apps/wallet-sdk-example/src/utils/kadenanames/date.ts
@@ -1,3 +1,4 @@
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
 export const transformPactDate = (val: any): Date | null => {
   if (!val) return null;
 
diff --git a/packages/apps/wallet-sdk-example/src/utils/kadenanames/transactionParser.ts b/packages/apps/wallet-sdk-example/src/utils/kadenanames/transactionParser.ts
index a103e5fec6..8a39a8cb96 100644
--- a/packages/apps/wallet-sdk-example/src/utils/kadenanames/transactionParser.ts
+++ b/packages/apps/wallet-sdk-example/src/utils/kadenanames/transactionParser.ts
@@ -1,4 +1,5 @@
 import { ICommandResult } from '@kadena/client';
+
 export function parseChainResponse(
   response: ICommandResult,
   subject: string,
diff --git a/packages/apps/wallet-sdk-example/tailwind.config.mjs b/packages/apps/wallet-sdk-example/tailwind.config.mjs
index 60aea86bc8..3b6fa3d22c 100644
--- a/packages/apps/wallet-sdk-example/tailwind.config.mjs
+++ b/packages/apps/wallet-sdk-example/tailwind.config.mjs
@@ -1,16 +1,5 @@
 /** @type {import('tailwindcss').Config} */
 export default {
   content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
-  // theme: {
-  //   extend: {
-  //     'primary-green': '#3BA583',
-  //     'secondary-green': '#5DB399',
-  //     'dark-slate': '#1E293B',
-  //     'medium-slate': '#3F4C5C',
-  //     'border-gray': '#CBD5E0',
-  //     'text-secondary': '#A0AEC0',
-  //     'error-color': '#E53E3E',
-  //   },
-  // },
   plugins: [],
 };
diff --git a/packages/apps/wallet-sdk-example/tsconfig.json b/packages/apps/wallet-sdk-example/tsconfig.json
index 4a688192e9..52e51f007d 100644
--- a/packages/apps/wallet-sdk-example/tsconfig.json
+++ b/packages/apps/wallet-sdk-example/tsconfig.json
@@ -13,6 +13,7 @@
     "isolatedModules": true,
     "noEmit": true,
     "jsx": "react-jsx",
+
     /* Linting */
     "strict": true,
     "noUnusedLocals": true,

From bb1244367632a9c30407b0a87cde9c78633ce775 Mon Sep 17 00:00:00 2001
From: Nillo 
Date: Mon, 25 Nov 2024 13:59:27 +0100
Subject: [PATCH 047/103] feat(wallet-example-app) added network selector, and
 prevention for trying to fund on mainnet

---
 .../src/actions/kadenaNames/README.md         | 162 ++++++++++++++++++
 .../src/components/AccountItem.tsx            |  16 +-
 .../src/components/Header.tsx                 |  27 ++-
 .../wallet-sdk-example/src/state/wallet.ts    |   3 +-
 4 files changed, 204 insertions(+), 4 deletions(-)
 create mode 100644 packages/apps/wallet-sdk-example/src/actions/kadenaNames/README.md

diff --git a/packages/apps/wallet-sdk-example/src/actions/kadenaNames/README.md b/packages/apps/wallet-sdk-example/src/actions/kadenaNames/README.md
new file mode 100644
index 0000000000..ba3a17b78a
--- /dev/null
+++ b/packages/apps/wallet-sdk-example/src/actions/kadenaNames/README.md
@@ -0,0 +1,162 @@
+# Kadena Names Interaction Module - Advanced Examples
+
+This module demonstrates advanced Kadena Names interactions with the Kadena
+blockchain. The functions provided here are **independent of the Wallet SDK**
+and are designed purely for **demonstration purposes**. They showcase how to
+implement more complex functionalities using `@kadena/client` to interact with
+Kadena's Chainweb.
+
+Below is an overview of the functions and their purpose:
+
+---
+
+## Installation
+
+You can install `@kadena/client` using your preferred package manager:
+
+### Using npm
+
+```bash
+npm install @kadena/client
+```
+
+### Using yarn
+
+```bash
+yarn add @kadena/client
+```
+
+### Using pnpm
+
+```bash
+pnpm add @kadena/client
+```
+
+---
+
+### How to Import
+
+To use the Kadena client library, you can import it as shown below (or use other
+imports provided by @kadena/client):
+
+```bash
+import { Pact } from '@kadena/client';
+```
+
+You can then use Pact.builder to create transactions, interact with modules, and
+execute commands.
+
+---
+
+## Functions Overview
+
+### **1. `fetchSaleState`**
+
+- **Purpose:** Fetches the sale state of a specific Kadena Name.
+- **Inputs:**
+  - `name` - The name being queried.
+  - `networkId` - The network ID (e.g., `testnet04`, `mainnet01`).
+- **Outputs:**
+  - `SaleState` - Indicates whether the name is sellable and the associated
+    price.
+- **Details:** Uses the Kadena blockchain to call the `get-sale-state` function
+  in the namespace module, returning the sale status of a given name.
+
+---
+
+### **2. `fetchNameInfo`**
+
+- **Purpose:** Retrieves detailed information about a Kadena Name.
+- **Inputs:**
+  - `name` - The name being queried.
+  - `networkId` - The network ID (e.g., `testnet04`, `mainnet01`).
+  - `owner` - The owner's Kadena account.
+- **Outputs:**
+  - `NameInfo` - Includes availability, sale status, price, market price, and
+    expiry details.
+- **Details:** Combines data from the Kadena blockchain (`get-name-info` and
+  `get-sale-state`) to present comprehensive name details. Expiry dates are also
+  validated for availability status.
+
+---
+
+### **3. `fetchPriceByPeriod`**
+
+- **Purpose:** Fetches the registration price for a specific period.
+- **Inputs:**
+  - `period` - The registration period (e.g., `oneYear`, `threeYears`).
+  - `networkId` - The network ID.
+  - `owner` - The owner's Kadena account.
+- **Outputs:**
+  - `number` - The price of registering a Kadena Name for the given period.
+- **Details:** Calls the `get-price` function on the blockchain, passing the
+  period as an argument.
+
+---
+
+### **4. `createRegisterNameTransaction`**
+
+- **Purpose:** Creates an unsigned transaction to register a Kadena Name.
+- **Inputs:**
+  - `owner` - The owner's Kadena account.
+  - `address` - The address to register the name to.
+  - `name` - The name to register.
+  - `days` - The duration of the registration.
+  - `price` - The price of registration.
+  - `networkId` - The network ID.
+  - `account` - The sender's account.
+- **Outputs:**
+  - `IUnsignedCommand` - An unsigned transaction that can be signed and
+    submitted.
+- **Details:** Builds a transaction that registers a name using Kadena's
+  `register` function and adds the necessary capabilities for gas and payment.
+
+---
+
+### **5. `executeCreateRegisterNameTransaction`**
+
+- **Purpose:** Executes the Kadena Name registration process by fetching
+  necessary data and creating a transaction.
+- **Inputs:**
+  - `owner` - The owner's Kadena account.
+  - `address` - The address to register the name to.
+  - `name` - The name to register.
+  - `registrationPeriod` - The desired registration period.
+  - `networkId` - The network ID.
+  - `account` - The sender's account.
+- **Outputs:**
+  - `IUnsignedCommand | null` - The generated transaction or null if an error
+    occurs.
+- **Details:** Combines the logic of `fetchNameInfo`, `fetchPriceByPeriod`, and
+  `createRegisterNameTransaction` to streamline the registration process.
+
+---
+
+## Interaction Details
+
+These actions communicate directly with Kadena's Chainweb using the
+`@kadena/client` library. The host configuration is defined in the `hostfile`
+module:
+
+- **`getClient`**: Generates or retrieves a cached Kadena client for a given
+  `networkId`.
+- **`getChainIdByNetwork`**: Dynamically determines the appropriate chain ID
+  based on the network.
+- **`defaultChainwebHostGenerator`**: Constructs the URL for Kadena's Pact API
+  endpoints.
+
+---
+
+## Note
+
+These functions are standalone implementations for interacting with Kadena Names
+on the Kadena. They are **not part of the Wallet SDK** and are provided to
+demonstrate how to handle more advanced features and transactions, such as:
+
+- Fetching state and metadata.
+- Handling gas and signing capabilities.
+- Constructing and executing custom transactions.
+
+For production use or integration into larger systems, consider combining these
+functionalities with Kadena's Wallet SDK or your custom client setup for
+enhanced usability.
diff --git a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx
index 664f86f753..f41ef0d6af 100644
--- a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx
+++ b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx
@@ -137,7 +137,21 @@ export const AccountItem: React.FC = ({
               Fund:
             
             
-              
               
-          
+          
+            
+            
+          
         
-      
-    
+        {/*
+          This is for Demo purposes, displaying what SDK function is execution for this action
+        */}
+        
+      
+    
   );
 };
diff --git a/packages/apps/wallet-sdk-example/src/components/Header.tsx b/packages/apps/wallet-sdk-example/src/components/Header.tsx
index 7c64dcf02a..13858a46d2 100644
--- a/packages/apps/wallet-sdk-example/src/components/Header.tsx
+++ b/packages/apps/wallet-sdk-example/src/components/Header.tsx
@@ -1,4 +1,9 @@
-import { MonoContrast, MonoUsb } from '@kadena/kode-icons';
+import {
+  MonoCode,
+  MonoCodeOff,
+  MonoContrast,
+  MonoUsb,
+} from '@kadena/kode-icons';
 import {
   NavHeader,
   NavHeaderButton,
@@ -15,12 +20,17 @@ import { KadenaLogo } from './KadenaLogo';
 export const Header = () => {
   const location = useLocation();
   const { theme, setTheme } = useTheme();
-  const { selectNetwork, selectedNetwork } = useWalletState();
+  const { selectNetwork, selectedNetwork, debugMode, setDebugMode } =
+    useWalletState();
 
   const toggleTheme = () => {
     setTheme(theme === 'light' ? 'dark' : 'light');
   };
 
+  const toggleDebugMode = () => {
+    setDebugMode(!debugMode);
+  };
+
   const selectChainNetwork = (network: string) => {
     selectNetwork(network);
   };
@@ -69,6 +79,11 @@ export const Header = () => {
         onPress={toggleTheme}
         aria-label="Toggle Theme"
       />
+       : }
+        onPress={toggleDebugMode}
+        aria-label="Toggle Theme"
+      />
     
   );
 };
diff --git a/packages/apps/wallet-sdk-example/src/components/SdkFunctionDisplayer.tsx b/packages/apps/wallet-sdk-example/src/components/SdkFunctionDisplayer.tsx
new file mode 100644
index 0000000000..ac0ed7d985
--- /dev/null
+++ b/packages/apps/wallet-sdk-example/src/components/SdkFunctionDisplayer.tsx
@@ -0,0 +1,53 @@
+import { Card, Divider, Stack, Text } from '@kadena/kode-ui';
+import hljs from 'highlight.js/lib/core';
+import javascript from 'highlight.js/lib/languages/javascript';
+import 'highlight.js/styles/github.css';
+import React, { useEffect, useRef } from 'react';
+import { useWalletState } from '../state/wallet';
+
+interface SdkFunctionDisplayProps {
+  functionName: string;
+  // eslint-disable-next-line @typescript-eslint/no-explicit-any
+  functionArgs: any;
+}
+
+const SdkFunctionDisplay: React.FC = ({
+  functionName,
+  functionArgs,
+}) => {
+  const codeString = `${functionName}(${JSON.stringify(
+    functionArgs,
+    null,
+    2,
+  )});`;
+
+  const { debugMode } = useWalletState();
+  const codeRef = useRef(null);
+
+  useEffect(() => {
+    hljs.registerLanguage('javascript', javascript);
+    if (codeRef.current) {
+      hljs.highlightElement(codeRef.current);
+    }
+  }, [codeString]);
+
+  if (!debugMode) return null;
+
+  return (
+    
+ + + SDK Function Call + +
+            
+              {codeString}
+            
+          
+
+
+
+ ); +}; + +export default SdkFunctionDisplay; diff --git a/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx b/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx index e8c874377c..1fb517f97a 100644 --- a/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx +++ b/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx @@ -9,12 +9,19 @@ import { TextareaField, } from '@kadena/kode-ui'; import React from 'react'; +import SdkFunctionDisplay from './SdkFunctionDisplayer'; interface TransactionModalProps { estimatedGas: number | null; transactionJSON: string; onClose: () => void; onConfirm: () => void; + gasFunctionCall?: { + // demo + functionName: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + functionArgs: any; + } | null; } export const TransactionModal: React.FC = ({ @@ -22,6 +29,7 @@ export const TransactionModal: React.FC = ({ transactionJSON, onClose, onConfirm, + gasFunctionCall, }) => { return ( = ({ {estimatedGas ?? 'Calculating...'} + {/* + This is for Demo purposes, displaying the SDK function used to estimate gas + */} + {gasFunctionCall && ( + <> + + + + )} + = ({ autoResize={false} /> + + { const wallet = useWalletState(); @@ -36,13 +45,60 @@ export const Transfer = () => { amount: string; } | null>(null); + /* -- Start demo ---------------*/ + const [sdkFunctionCall, setSdkFunctionCall] = useState( + null, + ); + const [gasFunctionCall, setGasFunctionCall] = useState( + null, + ); + /* -- End demo ---------------*/ + const navigate = useNavigate(); const { chains } = useChains(wallet.selectedNetwork); - const prepareTransaction = async ( - receiverAccount: string, - amount: string, - ) => { + const [receiverAccount, setReceiverAccount] = useState( + wallet.accounts.find((a) => a.index !== wallet.account?.index)?.name || '', + ); + const [amount, setAmount] = useState('0.01'); + + /* --- Start Demo purposes --- */ + useEffect(() => { + if (!wallet.account) return; + + const fromChain = wallet.selectedChain; + + if (isCrossChain) { + // Cross-chain transfers are not supported yet + setSdkFunctionCall({ + functionName: 'Cross-chain transfers are not supported yet.', + functionArgs: null, + }); + } else { + const functionName = 'walletSdk.createSimpleTransfer'; + const functionArgs: SimpleCreateTransfer & { networkId: string } = { + amount, + sender: wallet.account.name, + receiver: receiverAccount, + chainId: fromChain, + networkId: wallet.selectedNetwork, + }; + + setSdkFunctionCall({ functionName, functionArgs }); + } + + setGasFunctionCall(null); + }, [ + wallet.account, + amount, + receiverAccount, + wallet.selectedChain, + wallet.selectedNetwork, + isCrossChain, + ]); + /* -- End demo ---------------*/ + + const prepareTransaction = async () => { if (!wallet.account) return; const fromChain = wallet.selectedChain; const toChain = isCrossChain ? wallet.selectedToChain : fromChain; @@ -53,29 +109,36 @@ export const Transfer = () => { ); } - const transaction = isCrossChain - ? ({} as IUnsignedCommand) - : walletSdk.createSimpleTransfer({ - amount, - sender: wallet.account.name, - receiver: receiverAccount, - chainId: fromChain, - networkId: wallet.selectedNetwork, - }); + let transaction: IUnsignedCommand; + + if (isCrossChain) { + /* --- Start Demo purposes --- */ + setSdkFunctionCall({ + functionName: 'Cross-chain transfers are not supported yet.', + functionArgs: null, + }); + /* -- End demo ---------------*/ + throw new Error('Cross-chain transfers are not supported yet.'); + } else { + const functionArgs: SimpleCreateTransfer & { networkId: string } = { + amount, + sender: wallet.account.name, + receiver: receiverAccount, + chainId: fromChain, + networkId: wallet.selectedNetwork, + }; - return await wallet.signTransaction(transaction); + transaction = walletSdk.createSimpleTransfer(functionArgs); + return await wallet.signTransaction(transaction); + } }; const onSubmitTransfer = async (e: React.FormEvent) => { e.preventDefault(); if (!wallet.account) return; - const formData = new FormData(e.currentTarget); - const receiverAccount = formData.get('to') as string; - const amount = formData.get('amount') as string; - try { - const signed = await prepareTransaction(receiverAccount, amount); + const signed = await prepareTransaction(); if (!signed) { setAlertMessage('Transaction was not signed'); return; @@ -87,6 +150,18 @@ export const Transfer = () => { wallet.selectedChain, ); + /* --- Start Demo purposes --- */ + const newCall = { + functionName: 'walletSdk.getGasLimitEstimate', + functionArgs: { + transaction: '[SIGNED TRANSACTION]', + networkId: wallet.selectedNetwork, + chainId: wallet.selectedChain, + }, + }; + setGasFunctionCall(newCall); + /* -- End demo ---------------*/ + setSignedTransaction(signed); setEstimatedGas(gasLimit); setTransactionDetails({ receiverAccount, amount }); @@ -103,6 +178,11 @@ export const Transfer = () => { ? error.message : 'Failed to prepare transaction', ); + + /* -- Start demo ---------------*/ + setSdkFunctionCall(null); + setGasFunctionCall(null); + /* -- End demo ---------------*/ } }; @@ -128,6 +208,11 @@ export const Transfer = () => { addPendingTransfer(pendingTransfer); setIsModalOpen(false); setSignedTransaction(null); + + /* -- Start demo ---------------*/ + setSdkFunctionCall(null); + setGasFunctionCall(null); + /* -- End demo ---------------*/ navigate('/list'); } catch (error) { console.warn(error); @@ -142,8 +227,8 @@ export const Transfer = () => {
} /> @@ -161,17 +246,16 @@ export const Transfer = () => { label="To" name="to" placeholder="Enter recipient account" - defaultValue={ - wallet.accounts.find((a) => a.index !== wallet.account?.index) - ?.name - } + value={receiverAccount} + onValueChange={(value) => setReceiverAccount(value)} size="md" /> setAmount(value)} size="md" /> @@ -227,6 +311,7 @@ export const Transfer = () => { transactionJSON={JSON.stringify(signedTransaction, null, 2)} onClose={() => setIsModalOpen(false)} onConfirm={confirmTransaction} + gasFunctionCall={gasFunctionCall} /> )} @@ -238,6 +323,16 @@ export const Transfer = () => { /> )} + + {/* + This is for Demo purposes, displaying the SDK function used to create the transaction + */} + {sdkFunctionCall && ( + + )}
); }; diff --git a/packages/apps/wallet-sdk-example/src/components/Transfers.tsx b/packages/apps/wallet-sdk-example/src/components/Transfers.tsx index 7c09e1136a..16ab0b3518 100644 --- a/packages/apps/wallet-sdk-example/src/components/Transfers.tsx +++ b/packages/apps/wallet-sdk-example/src/components/Transfers.tsx @@ -12,12 +12,15 @@ import { TableHeader, Text, } from '@kadena/kode-ui'; + import { useTransfers } from '../hooks/transfers'; import { shortenString } from '../utils/kadenanames/transform'; +import SdkFunctionDisplay from './SdkFunctionDisplayer'; // Demo import { TextEllipsis } from './Text'; export const Transfers = () => { - const { transfers, pendingTransfers, account } = useTransfers(); + const { transfers, pendingTransfers, account, functionCalls } = + useTransfers(); // eslint-disable-next-line @typescript-eslint/no-explicit-any const getAmountStyle = (transfer: any) => { @@ -147,6 +150,17 @@ export const Transfers = () => { )}
+ + {/* + This is for Demo purposes, displaying what SDK function is execution for this action + */} + {functionCalls.map((call, index) => ( + + ))}
); }; diff --git a/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx b/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx index a83e1c3d8f..5b5fe28f0b 100644 --- a/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx +++ b/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx @@ -1,3 +1,4 @@ +import { MonoShortcut } from '@kadena/kode-icons'; import { Card, ContentHeader, @@ -8,14 +9,13 @@ import { TextField, } from '@kadena/kode-ui'; -import { MonoShortcut } from '@kadena/kode-icons'; - -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { useAddressToName, useNameToAddress, } from '../../hooks/kadenaNames/kadenaNamesResolver'; import { useWalletState } from '../../state/wallet'; +import SdkFunctionDisplay from '../SdkFunctionDisplayer'; // Demo export const KadenaNames: React.FC = () => { const wallet = useWalletState(); @@ -36,6 +36,39 @@ export const KadenaNames: React.FC = () => { name: inputName, } = useNameToAddress(0, wallet.selectedNetwork); + //* -- Start demo ---------------*/ + const [functionCalls, setFunctionCalls] = useState< + // eslint-disable-next-line @typescript-eslint/no-explicit-any + { functionName: string; functionArgs: any }[] + >([]); + + useEffect(() => { + const calls = []; + + if (inputAddress) { + calls.push({ + functionName: 'walletSdk.kadenaNames.addressToName', + functionArgs: { + address: inputAddress, + networkId: wallet.selectedNetwork, + }, + }); + } + + if (inputName) { + calls.push({ + functionName: 'walletSdk.kadenaNames.nameToAddress', + functionArgs: { + name: inputName, + networkId: wallet.selectedNetwork, + }, + }); + } + + setFunctionCalls(calls); + }, [inputAddress, inputName, wallet.selectedNetwork]); + /* -- End demo ---------------*/ + return (
@@ -95,6 +128,19 @@ export const KadenaNames: React.FC = () => { + + {/* + This is for Demo purposes, displaying what SDK function is execution for this action + */} +
+ {functionCalls.map((call, index) => ( + + ))} +
); }; diff --git a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts index 9ddf755818..29e44c920f 100644 --- a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts +++ b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts @@ -1,13 +1,21 @@ import { walletSdk } from '@kadena/wallet-sdk'; import { useQuery } from '@tanstack/react-query'; -import { useEffect } from 'react'; +import { useEffect, useState } from 'react'; import { usePendingTransfers } from '../state/pending'; import { useWalletState } from '../state/wallet'; +interface FunctionCall { + functionName: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + functionArgs: any; +} + export const useTransfers = () => { const wallet = useWalletState(); const { pendingTransfers, removePendingTransfer } = usePendingTransfers(); + const [functionCalls, setFunctionCalls] = useState([]); + const { data: transfers, error, @@ -15,17 +23,63 @@ export const useTransfers = () => { } = useQuery({ queryKey: ['transfers', wallet.account?.name], enabled: !!wallet.account?.name, - queryFn: () => - walletSdk.getTransfers( - wallet.account?.name ?? '', - wallet.selectedNetwork, - wallet.selectedFungible, - ), + queryFn: async () => { + /* --- Start Demo purposes --- */ + const functionName = 'walletSdk.getTransfers'; + const functionArgs = { + accountName: wallet.account?.name ?? '', + networkId: wallet.selectedNetwork, + fungible: wallet.selectedFungible, + }; + + setFunctionCalls((prevCalls) => { + const exists = prevCalls.some( + (call) => + call.functionName === functionName && + JSON.stringify(call.functionArgs) === JSON.stringify(functionArgs), + ); + if (exists) { + return prevCalls; + } else { + return [...prevCalls, { functionName, functionArgs }]; + } + }); + /* -- End demo ---------------*/ + + return walletSdk.getTransfers( + functionArgs.accountName, + functionArgs.networkId, + functionArgs.fungible, + ); + }, }); useEffect(() => { - if (!transfers) return; + if (!transfers || transfers.length === 0) return; const controller = new AbortController(); + + /* --- Start Demo purposes --- */ + const functionName = 'walletSdk.subscribeOnCrossChainComplete'; + const functionArgs = { + transfers, + callback: '() => refetch()', + options: { signal: controller.signal }, + }; + + setFunctionCalls((prevCalls) => { + const exists = prevCalls.some( + (call) => + call.functionName === functionName && + JSON.stringify(call.functionArgs) === JSON.stringify(functionArgs), + ); + if (exists) { + return prevCalls; + } else { + return [...prevCalls, { functionName, functionArgs }]; + } + }); + /* -- End demo ---------------*/ + walletSdk.subscribeOnCrossChainComplete(transfers, () => refetch(), { signal: controller.signal, }); @@ -33,7 +87,31 @@ export const useTransfers = () => { }, [transfers, refetch]); useEffect(() => { + if (!pendingTransfers || pendingTransfers.length === 0) return; const controller = new AbortController(); + + /* --- Start Demo purposes --- */ + const functionName = 'walletSdk.subscribePendingTransactions'; + const functionArgs = { + pendingTransfers, + callback: '(transfer) => { ... }', + options: { signal: controller.signal }, + }; + + setFunctionCalls((prevCalls) => { + const exists = prevCalls.some( + (call) => + call.functionName === functionName && + JSON.stringify(call.functionArgs) === JSON.stringify(functionArgs), + ); + if (exists) { + return prevCalls; + } else { + return [...prevCalls, { functionName, functionArgs }]; + } + }); + /* -- End demo ---------------*/ + walletSdk.subscribePendingTransactions( pendingTransfers, (transfer) => { @@ -52,5 +130,6 @@ export const useTransfers = () => { pendingTransfers, account: wallet.account?.name, refetch, + functionCalls, // demo }; }; diff --git a/packages/apps/wallet-sdk-example/src/state/wallet.ts b/packages/apps/wallet-sdk-example/src/state/wallet.ts index bdaea13d45..ba77e021be 100644 --- a/packages/apps/wallet-sdk-example/src/state/wallet.ts +++ b/packages/apps/wallet-sdk-example/src/state/wallet.ts @@ -25,6 +25,7 @@ const seedAtom = atomWithStorage( 'mmnemonic_seed', null, ); +const debugModeAtom = atomWithStorage('debugMode', true); const selectedChainAtom = atomWithStorage('chain_id', '0'); const selectedNetworkAtom = atomWithStorage('network_id', 'testnet04'); const selectedFungibleAtom = atomWithStorage('selected_fungible', 'coin'); @@ -47,6 +48,7 @@ export const useWalletState = (initialPassword?: string) => { const [selectedChain, selectChain] = useAtom(selectedChainAtom); const [accounts, setAccounts] = useAtom(accountsAtom); const [seed, setSeed] = useAtom(seedAtom); + const [debugMode, setDebugMode] = useAtom(debugModeAtom); // Temporary state const [password, setPassword] = useAtom(passwordAtom); const [selectedAccount, setSelectedAccount] = useAtom(selectedAccountAtom); @@ -139,6 +141,7 @@ export const useWalletState = (initialPassword?: string) => { selectedNetwork, selectedChain, selectedToChain, + debugMode, selectNetwork, generateMnemonic, selectAccount, @@ -147,5 +150,6 @@ export const useWalletState = (initialPassword?: string) => { generateAccount, signTransaction, setSelectedToChain, + setDebugMode, }; }; From 12a205a5fc1b98245445e04364b3890ca037783f Mon Sep 17 00:00:00 2001 From: Nillo Date: Wed, 27 Nov 2024 13:53:32 +0100 Subject: [PATCH 050/103] chore(wallet-sdk-example) typo --- .../src/components/kadenaNames/KadenaNamesResolver.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx b/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx index 5b5fe28f0b..5fd807b565 100644 --- a/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx +++ b/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx @@ -73,7 +73,7 @@ export const KadenaNames: React.FC = () => {
} /> From b6561396eb2f42e7de6f36289b72eb3f9eba2720 Mon Sep 17 00:00:00 2001 From: Nillo Date: Wed, 27 Nov 2024 14:25:14 +0100 Subject: [PATCH 051/103] chore(wallet-sdk-example) folder cleanup / added sticky header --- packages/apps/wallet-sdk-example/src/App.tsx | 24 ++++++-------- .../actions/kadenaNames/kadenaNamesActions.ts | 2 +- .../src/components/AccountItem.tsx | 2 +- .../src/components/Header.tsx | 2 ++ .../src/components/header.css.ts | 7 ++++ .../kadenaNames/NameRegistrationForm.tsx | 2 +- .../wallet-sdk-example/src/constants/fund.ts | 21 ------------ .../src/{components => }/docs.md | 0 .../src/{actions => }/host.ts | 0 .../{components/Root.tsx => pages/Home.tsx} | 2 +- .../src/{components => pages}/Transfer.tsx | 6 ++-- .../src/{components => pages}/Transfers.tsx | 4 +-- .../src/{components => pages}/Wallet.tsx | 4 +-- .../kadenaNames/KadenaNamesResolver.tsx | 2 +- .../apps/wallet-sdk-example/src/routes.tsx | 32 +++++++++++++++++++ 15 files changed, 62 insertions(+), 48 deletions(-) create mode 100644 packages/apps/wallet-sdk-example/src/components/header.css.ts delete mode 100644 packages/apps/wallet-sdk-example/src/constants/fund.ts rename packages/apps/wallet-sdk-example/src/{components => }/docs.md (100%) rename packages/apps/wallet-sdk-example/src/{actions => }/host.ts (100%) rename packages/apps/wallet-sdk-example/src/{components/Root.tsx => pages/Home.tsx} (99%) rename packages/apps/wallet-sdk-example/src/{components => pages}/Transfer.tsx (98%) rename packages/apps/wallet-sdk-example/src/{components => pages}/Transfers.tsx (97%) rename packages/apps/wallet-sdk-example/src/{components => pages}/Wallet.tsx (73%) rename packages/apps/wallet-sdk-example/src/{components => pages}/kadenaNames/KadenaNamesResolver.tsx (97%) create mode 100644 packages/apps/wallet-sdk-example/src/routes.tsx diff --git a/packages/apps/wallet-sdk-example/src/App.tsx b/packages/apps/wallet-sdk-example/src/App.tsx index 45e33b6c0d..2a5df0afc8 100644 --- a/packages/apps/wallet-sdk-example/src/App.tsx +++ b/packages/apps/wallet-sdk-example/src/App.tsx @@ -2,19 +2,17 @@ import '@kadena/kode-ui/global'; import { darkThemeClass } from '@kadena/kode-ui/styles'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { ThemeProvider } from 'next-themes'; +import Header from './components/Header'; import './global.css.ts'; -import { Route, Routes } from 'react-router-dom'; -import Header from './components/Header'; -import { KadenaNames } from './components/kadenaNames/KadenaNamesResolver'; -import MarkdownPage from './components/Root'; -import { Transfer } from './components/Transfer'; -import { Transfers } from './components/Transfers'; -import { Wallet } from './components/Wallet'; +import { useRoutes } from 'react-router-dom'; +import routes from './routes'; const queryClient = new QueryClient(); function App() { + const routing = useRoutes(routes); + return ( -
- - } /> - } /> - } /> - } /> - } /> - + <> +
+ {routing} + ); diff --git a/packages/apps/wallet-sdk-example/src/actions/kadenaNames/kadenaNamesActions.ts b/packages/apps/wallet-sdk-example/src/actions/kadenaNames/kadenaNamesActions.ts index 611164a855..ff89eacc3e 100644 --- a/packages/apps/wallet-sdk-example/src/actions/kadenaNames/kadenaNamesActions.ts +++ b/packages/apps/wallet-sdk-example/src/actions/kadenaNames/kadenaNamesActions.ts @@ -3,10 +3,10 @@ import { PRICE_MAP, VAULT, } from '../../constants/kadenaNames/kadenaNamesConstants'; +import { getChainIdByNetwork, getClient } from '../../host'; import { isNameExpired, transformPactDate } from '../../utils/kadenanames/date'; import { parseChainResponse } from '../../utils/kadenanames/transactionParser'; import { addExtentionToName } from '../../utils/kadenanames/transform'; -import { getChainIdByNetwork, getClient } from '../host'; import { getNamespaceModule } from '../../constants/kadenaNames/kadenaNamesConstants'; diff --git a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx index 16c1e35e5b..8132e40c3d 100644 --- a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx +++ b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx @@ -1,9 +1,9 @@ import { Badge, Button, Card, Divider, Stack, Text } from '@kadena/kode-ui'; import React, { useEffect, useState } from 'react'; -import { chainwebHostMap } from '../actions/host'; import { createAndTransferFund } from '../domain/fund'; import { useFund } from '../hooks/fund'; import { useAddressToName } from '../hooks/kadenaNames/kadenaNamesResolver'; +import { chainwebHostMap } from '../host'; import type { Account } from '../state/wallet'; import { useWalletState } from '../state/wallet'; import { AlertDialog } from './AlertDialog'; diff --git a/packages/apps/wallet-sdk-example/src/components/Header.tsx b/packages/apps/wallet-sdk-example/src/components/Header.tsx index 13858a46d2..4e7844aad6 100644 --- a/packages/apps/wallet-sdk-example/src/components/Header.tsx +++ b/packages/apps/wallet-sdk-example/src/components/Header.tsx @@ -15,6 +15,7 @@ import { import { useTheme } from 'next-themes'; import { Link, useLocation } from 'react-router-dom'; import { useWalletState } from '../state/wallet'; +import { stickyHeader } from './Header.css'; import { KadenaLogo } from './KadenaLogo'; export const Header = () => { @@ -37,6 +38,7 @@ export const Header = () => { return ( diff --git a/packages/apps/wallet-sdk-example/src/components/header.css.ts b/packages/apps/wallet-sdk-example/src/components/header.css.ts new file mode 100644 index 0000000000..33290f966f --- /dev/null +++ b/packages/apps/wallet-sdk-example/src/components/header.css.ts @@ -0,0 +1,7 @@ +import { style } from '@vanilla-extract/css'; + +export const stickyHeader = style({ + position: 'sticky', + top: 0, + zIndex: 1000, +}); diff --git a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationForm.tsx b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationForm.tsx index 235d287266..a16e89c20a 100644 --- a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationForm.tsx +++ b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationForm.tsx @@ -9,13 +9,13 @@ import { } from '@kadena/kode-ui'; import { walletSdk } from '@kadena/wallet-sdk'; import React, { useCallback, useEffect, useState } from 'react'; -import { getChainIdByNetwork } from '../../actions/host'; import { executeCreateRegisterNameTransaction, fetchNameInfo, fetchPriceByPeriod, } from '../../actions/kadenaNames/kadenaNamesActions'; import { PRICE_MAP } from '../../constants/kadenaNames/kadenaNamesConstants'; +import { getChainIdByNetwork } from '../../host'; import { Account, useWalletState } from '../../state/wallet'; import { useDebounce } from '../../utils/useDebounce'; diff --git a/packages/apps/wallet-sdk-example/src/constants/fund.ts b/packages/apps/wallet-sdk-example/src/constants/fund.ts deleted file mode 100644 index de20489660..0000000000 --- a/packages/apps/wallet-sdk-example/src/constants/fund.ts +++ /dev/null @@ -1,21 +0,0 @@ -export const NAMESPACES = { - DEV_NET: 'n_34d947e2627143159ea73cdf277138fd571f17ac', - TEST_NET: 'n_d8cbb935f9cd9d2399a5886bb08caed71f9bad49', -} as const; - -export const GAS_STATIONS = { - DEV_NET: 'c:zWPXcVXoHwkNTzKhMU02u2tzN_yL6V3-XTEH1uJaVY4', - TEST_NET: 'c:Ecwy85aCW3eogZUnIQxknH8tG8uXHM5QiC__jeI0nWA', -} as const; - -export const GAS_STATIONS_MAP: { [key: string]: string } = { - development: GAS_STATIONS.DEV_NET, - testnet04: GAS_STATIONS.TEST_NET, -} as const; - -export const NAMESPACES_MAP: { [key: string]: string } = { - development: NAMESPACES.DEV_NET, - testnet04: NAMESPACES.TEST_NET, -}; - -export const DEFAULT_CONTRACT_NAME = 'coin-faucet'; diff --git a/packages/apps/wallet-sdk-example/src/components/docs.md b/packages/apps/wallet-sdk-example/src/docs.md similarity index 100% rename from packages/apps/wallet-sdk-example/src/components/docs.md rename to packages/apps/wallet-sdk-example/src/docs.md diff --git a/packages/apps/wallet-sdk-example/src/actions/host.ts b/packages/apps/wallet-sdk-example/src/host.ts similarity index 100% rename from packages/apps/wallet-sdk-example/src/actions/host.ts rename to packages/apps/wallet-sdk-example/src/host.ts diff --git a/packages/apps/wallet-sdk-example/src/components/Root.tsx b/packages/apps/wallet-sdk-example/src/pages/Home.tsx similarity index 99% rename from packages/apps/wallet-sdk-example/src/components/Root.tsx rename to packages/apps/wallet-sdk-example/src/pages/Home.tsx index ed3dac87f1..a82fb77fdb 100644 --- a/packages/apps/wallet-sdk-example/src/components/Root.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/Home.tsx @@ -19,7 +19,7 @@ import parse, { } from 'html-react-parser'; import MarkdownIt from 'markdown-it'; import React, { useEffect, useRef, useState } from 'react'; -import markdownContentRaw from './docs.md?raw'; +import markdownContentRaw from '../docs.md?raw'; export type HeadingElementType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; diff --git a/packages/apps/wallet-sdk-example/src/components/Transfer.tsx b/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx similarity index 98% rename from packages/apps/wallet-sdk-example/src/components/Transfer.tsx rename to packages/apps/wallet-sdk-example/src/pages/Transfer.tsx index bd876c8518..e81a4e6c55 100644 --- a/packages/apps/wallet-sdk-example/src/components/Transfer.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx @@ -17,11 +17,11 @@ import { useNavigate } from 'react-router-dom'; import { useChains } from '../hooks/chains'; import { PendingTransfer, usePendingTransfers } from '../state/pending'; -import SdkFunctionDisplay from './SdkFunctionDisplayer'; // Demo -import { TransactionModal } from './TransactionModal'; +import SdkFunctionDisplay from '../components/SdkFunctionDisplayer'; // Demo +import { TransactionModal } from '../components/TransactionModal'; +import { AlertDialog } from '../components/AlertDialog'; import { useWalletState } from '../state/wallet'; -import { AlertDialog } from './AlertDialog'; interface FunctionCall { functionName: string; diff --git a/packages/apps/wallet-sdk-example/src/components/Transfers.tsx b/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx similarity index 97% rename from packages/apps/wallet-sdk-example/src/components/Transfers.tsx rename to packages/apps/wallet-sdk-example/src/pages/Transfers.tsx index 16ab0b3518..fbe3ddc96a 100644 --- a/packages/apps/wallet-sdk-example/src/components/Transfers.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx @@ -13,10 +13,10 @@ import { Text, } from '@kadena/kode-ui'; +import SdkFunctionDisplay from '../components/SdkFunctionDisplayer'; // Demo +import { TextEllipsis } from '../components/Text'; import { useTransfers } from '../hooks/transfers'; import { shortenString } from '../utils/kadenanames/transform'; -import SdkFunctionDisplay from './SdkFunctionDisplayer'; // Demo -import { TextEllipsis } from './Text'; export const Transfers = () => { const { transfers, pendingTransfers, account, functionCalls } = diff --git a/packages/apps/wallet-sdk-example/src/components/Wallet.tsx b/packages/apps/wallet-sdk-example/src/pages/Wallet.tsx similarity index 73% rename from packages/apps/wallet-sdk-example/src/components/Wallet.tsx rename to packages/apps/wallet-sdk-example/src/pages/Wallet.tsx index a8b5cf7a0c..c26995259e 100644 --- a/packages/apps/wallet-sdk-example/src/components/Wallet.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/Wallet.tsx @@ -1,7 +1,7 @@ import { Divider } from '@kadena/kode-ui'; +import { Accounts } from '../components/Accounts'; +import { WordPhrase } from '../components/WordPhrase'; import { useWalletState } from '../state/wallet'; -import { Accounts } from './Accounts'; -import { WordPhrase } from './WordPhrase'; export function Wallet() { useWalletState('password'); diff --git a/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx b/packages/apps/wallet-sdk-example/src/pages/kadenaNames/KadenaNamesResolver.tsx similarity index 97% rename from packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx rename to packages/apps/wallet-sdk-example/src/pages/kadenaNames/KadenaNamesResolver.tsx index 5fd807b565..5b857a32ae 100644 --- a/packages/apps/wallet-sdk-example/src/components/kadenaNames/KadenaNamesResolver.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/kadenaNames/KadenaNamesResolver.tsx @@ -10,12 +10,12 @@ import { } from '@kadena/kode-ui'; import React, { useEffect, useState } from 'react'; +import SdkFunctionDisplay from '../../components/SdkFunctionDisplayer'; // Demo import { useAddressToName, useNameToAddress, } from '../../hooks/kadenaNames/kadenaNamesResolver'; import { useWalletState } from '../../state/wallet'; -import SdkFunctionDisplay from '../SdkFunctionDisplayer'; // Demo export const KadenaNames: React.FC = () => { const wallet = useWalletState(); diff --git a/packages/apps/wallet-sdk-example/src/routes.tsx b/packages/apps/wallet-sdk-example/src/routes.tsx new file mode 100644 index 0000000000..8e0bd7cf0f --- /dev/null +++ b/packages/apps/wallet-sdk-example/src/routes.tsx @@ -0,0 +1,32 @@ +import { RouteObject } from 'react-router-dom'; + +import MarkdownPage from './pages/Home'; +import { KadenaNames } from './pages/kadenaNames/KadenaNamesResolver'; +import { Transfer } from './pages/Transfer'; +import { Transfers } from './pages/Transfers'; +import { Wallet } from './pages/Wallet'; + +const routes: RouteObject[] = [ + { + path: '/', + element: , + }, + { + path: '/wallet', + element: , + }, + { + path: '/list', + element: , + }, + { + path: '/transfer', + element: , + }, + { + path: '/kadenanames', + element: , + }, +]; + +export default routes; From ab38ed00ed14eabb69a5a9e4eec362b6c4d05971 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Wed, 27 Nov 2024 15:12:40 +0100 Subject: [PATCH 052/103] feat(wallet-sdk): add wip cross chain finish command --- .../src/sdk/crossChainFinishCreate.ts | 75 +++++++++++++++++++ packages/libs/wallet-sdk/src/sdk/interface.ts | 6 +- .../{utils-tmp.ts => simpleTransferCreate.ts} | 57 ++++++-------- packages/libs/wallet-sdk/src/sdk/walletSdk.ts | 26 ++++--- 4 files changed, 115 insertions(+), 49 deletions(-) create mode 100644 packages/libs/wallet-sdk/src/sdk/crossChainFinishCreate.ts rename packages/libs/wallet-sdk/src/sdk/{utils-tmp.ts => simpleTransferCreate.ts} (53%) diff --git a/packages/libs/wallet-sdk/src/sdk/crossChainFinishCreate.ts b/packages/libs/wallet-sdk/src/sdk/crossChainFinishCreate.ts new file mode 100644 index 0000000000..b35dffc1b8 --- /dev/null +++ b/packages/libs/wallet-sdk/src/sdk/crossChainFinishCreate.ts @@ -0,0 +1,75 @@ +import type { ChainId, ISigner } from '@kadena/client'; +import { createClient, Pact } from '@kadena/client'; +// import {} from '@kadena/client-utils/coin'; + +/** + * ICreateCrossChainFinishInput represents a subset of Transfer + * and should not deviate from that interface + */ +export interface ICreateCrossChainFinishInput { + senderAccount: string; + receiverAccount: string; + amount: number; + host: string; + requestKey: string; + networkId: string; + chainId: ChainId; + targetChainId: ChainId; +} + +/** + * Accepts a cross-chain Transfer and creates a cross-chain finish transaction + */ +export const crossChainFinishCreateCommand = async ( + { + senderAccount, + receiverAccount, + amount, + chainId, + host, + networkId, + requestKey, + targetChainId, + }: ICreateCrossChainFinishInput, + gasPayer: { account: string; publicKeys: ISigner[] }, +) => { + const client = createClient(() => host); + const spv = await client.pollCreateSpv( + { + chainId, + networkId, + requestKey, + }, + targetChainId, + ); + + const builder = Pact.builder + .continuation({ + pactId: requestKey, + proof: spv, + rollback: false, + step: 1, + data: { + from: senderAccount, + to: receiverAccount, + amount: amount, + fromChain: chainId, + toChain: targetChainId, + }, + }) + .setMeta({ + chainId: chainId, + senderAccount: gasPayer.account, + gasLimit: 850, + }) + .setNetworkId(networkId); + + for (const signer of gasPayer.publicKeys) { + builder.addSigner( + typeof signer === 'string' ? signer : signer.pubKey, + (withCap: any) => [withCap('coin.GAS')], + ); + } + + return builder.createTransaction(); +}; diff --git a/packages/libs/wallet-sdk/src/sdk/interface.ts b/packages/libs/wallet-sdk/src/sdk/interface.ts index 84c038acb4..969f9594c9 100644 --- a/packages/libs/wallet-sdk/src/sdk/interface.ts +++ b/packages/libs/wallet-sdk/src/sdk/interface.ts @@ -3,7 +3,6 @@ import type { createCrossChainCommand, transferCreateCommand, } from '@kadena/client-utils/coin'; -import type { simpleTransferCreateCommand } from './utils-tmp'; interface ITransactionFeeTransfer extends IBaseTransfer { /** @@ -60,10 +59,7 @@ export interface IChain { // Will add later: type: 'pact' | 'evm' } export type Transfer = ISameChainTransfer | ICrossChainTransfer; -export type CreateFinishCrossChainTransfer = unknown; -export type SimpleCreateTransfer = Parameters< - typeof simpleTransferCreateCommand ->[0]; + export type CreateTransfer = Parameters[0]; export type CreateCrossChainTransfer = Parameters< typeof createCrossChainCommand diff --git a/packages/libs/wallet-sdk/src/sdk/utils-tmp.ts b/packages/libs/wallet-sdk/src/sdk/simpleTransferCreate.ts similarity index 53% rename from packages/libs/wallet-sdk/src/sdk/utils-tmp.ts rename to packages/libs/wallet-sdk/src/sdk/simpleTransferCreate.ts index 91efc5aba5..4744c6871a 100644 --- a/packages/libs/wallet-sdk/src/sdk/utils-tmp.ts +++ b/packages/libs/wallet-sdk/src/sdk/simpleTransferCreate.ts @@ -1,14 +1,7 @@ import type { ChainId, ISigner } from '@kadena/client'; -import { Pact, readKeyset } from '@kadena/client'; -import { - addKeyset, - addSigner, - composePactCommand, - execution, - setMeta, -} from '@kadena/client/fp'; +import { transferCreateCommand } from '@kadena/client-utils/coin'; -interface ICreateSimpleTransferInput { +export interface ICreateSimpleTransferInput { sender: string; receiver: string; amount: string; @@ -21,7 +14,6 @@ interface ICreateSimpleTransferInput { } /** - * @alpha * transfer create that only supports `k:` accounts for sender and receiver. * Accepts either account name or public key */ @@ -46,29 +38,24 @@ export const simpleTransferCreateCommand = ({ const gasPayerPublicKeys = gasPayer ? gasPayer.publicKeys : [senderPublicKey]; const gasPayerAccount = gasPayer ? gasPayer.account : senderAccount; - return composePactCommand( - execution( - (Pact as any).modules[contract]['transfer-create']( - senderAccount, - receiverAccount, - readKeyset('account-guard'), - { - decimal: amount, - }, - ), - ), - addKeyset('account-guard', 'keys-all', receiverPublicKey), - addSigner(senderPublicKey, (signFor: any) => [ - signFor( - `${contract as 'coin'}.TRANSFER`, - senderAccount, - receiverAccount, - { - decimal: amount, - }, - ), - ]), - addSigner(gasPayerPublicKeys, (signFor: any) => [signFor('coin.GAS')]), - setMeta({ senderAccount: gasPayerAccount, chainId }), - ); + return transferCreateCommand({ + amount, + chainId, + contract, + gasPayer: { + account: gasPayerAccount, + publicKeys: gasPayerPublicKeys, + }, + receiver: { + account: receiverAccount, + keyset: { + keys: [receiverPublicKey], + pred: 'keys-all', + }, + }, + sender: { + account: senderAccount, + publicKeys: [senderPublicKey], + }, + }); }; diff --git a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts index 84bd6dde3b..18ce05daf1 100644 --- a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts +++ b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts @@ -5,13 +5,20 @@ import { transferCreateCommand, } from '@kadena/client-utils/coin'; import { estimateGas } from '@kadena/client-utils/core'; -import type { ChainId, ICommand, IUnsignedCommand } from '@kadena/types'; +import type { + ChainId, + ICommand, + ISigner, + IUnsignedCommand, +} from '@kadena/types'; import * as accountService from '../services/accountService.js'; import { pollRequestKeys } from '../services/chainweb/chainweb.js'; import { getTransfers } from '../services/graphql/getTransfers.js'; import { poll } from '../utils/retry.js'; import { isEmpty, notEmpty } from '../utils/typeUtils.js'; +import type { ICreateCrossChainFinishInput } from './crossChainFinishCreate.js'; +import { crossChainFinishCreateCommand } from './crossChainFinishCreate.js'; import { exchange } from './exchange.js'; import type { ChainwebHostGenerator, GraphqlHostGenerator } from './host.js'; import { @@ -20,19 +27,18 @@ import { } from './host.js'; import type { CreateCrossChainTransfer, - CreateFinishCrossChainTransfer, CreateTransfer, IAccountDetails, IChain, ITransactionDescriptor, - SimpleCreateTransfer, Transfer, } from './interface.js'; import { KadenaNames } from './kadenaNames.js'; import type { ILogTransport, LogLevel } from './logger.js'; import { Logger } from './logger.js'; import type { ResponseResult } from './schema.js'; -import { simpleTransferCreateCommand } from './utils-tmp.js'; +import type { ICreateSimpleTransferInput } from './simpleTransferCreate.js'; +import { simpleTransferCreateCommand } from './simpleTransferCreate.js'; export class WalletSDK { private _chainwebHostGenerator: ChainwebHostGenerator; @@ -95,7 +101,7 @@ export class WalletSDK { /** Create a transfer that only accepts `k:` accounts */ public createSimpleTransfer( - transfer: SimpleCreateTransfer & { networkId: string }, + transfer: ICreateSimpleTransferInput & { networkId: string }, ): IUnsignedCommand { const command = simpleTransferCreateCommand(transfer)(); return createTransaction({ @@ -127,10 +133,12 @@ export class WalletSDK { } /** create cross-chain transfer finish */ - public createFinishCrossChainTransfer( - transfer: CreateFinishCrossChainTransfer, - ): IUnsignedCommand { - return {} as IUnsignedCommand; + public async createFinishCrossChainTransfer( + transfer: ICreateCrossChainFinishInput, + gasPayer: { account: string; publicKeys: ISigner[] }, + ): Promise { + const command = await crossChainFinishCreateCommand(transfer, gasPayer); + return command; } /** send signed transaction */ From 7a6c56c4e3c2503a554ce97c5c002f85686127d9 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Wed, 27 Nov 2024 15:13:02 +0100 Subject: [PATCH 053/103] feat(wallet-sdk): add display of cross chain in transaction list --- .../wallet-sdk-example/src/hooks/transfers.ts | 18 +++++++++++++----- .../wallet-sdk-example/src/pages/Transfers.tsx | 6 +++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts index 29e44c920f..932cba0a4c 100644 --- a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts +++ b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts @@ -58,10 +58,14 @@ export const useTransfers = () => { if (!transfers || transfers.length === 0) return; const controller = new AbortController(); + const incompleteTransfers = transfers.filter( + (transfer) => transfer.isCrossChainTransfer && !transfer.continuation, + ); + /* --- Start Demo purposes --- */ const functionName = 'walletSdk.subscribeOnCrossChainComplete'; const functionArgs = { - transfers, + transfers: incompleteTransfers, callback: '() => refetch()', options: { signal: controller.signal }, }; @@ -80,11 +84,15 @@ export const useTransfers = () => { }); /* -- End demo ---------------*/ - walletSdk.subscribeOnCrossChainComplete(transfers, () => refetch(), { - signal: controller.signal, - }); + walletSdk.subscribeOnCrossChainComplete( + incompleteTransfers, + () => refetch(), + { + signal: controller.signal, + }, + ); return () => controller.abort(); - }, [transfers, refetch]); + }, [refetch, transfers]); useEffect(() => { if (!pendingTransfers || pendingTransfers.length === 0) return; diff --git a/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx b/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx index fbe3ddc96a..9bbc07502e 100644 --- a/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx @@ -111,7 +111,11 @@ export const Transfers = () => { {transfers.map((transfer, index) => ( {shortenString(transfer.requestKey)} - {transfer.chainId} + + {transfer.isCrossChainTransfer + ? `${transfer.chainId} → ${transfer.targetChainId}` + : transfer.chainId} + {transfer.senderAccount} From e2f5784e001d5df274ccf216174cf123dba3b35e Mon Sep 17 00:00:00 2001 From: Nillo Date: Wed, 27 Nov 2024 15:49:18 +0100 Subject: [PATCH 054/103] chore(wallet-sdk-example): cleanup --- packages/apps/wallet-sdk-example/src/components/Header.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/apps/wallet-sdk-example/src/components/Header.tsx b/packages/apps/wallet-sdk-example/src/components/Header.tsx index 4e7844aad6..ff2adbac0f 100644 --- a/packages/apps/wallet-sdk-example/src/components/Header.tsx +++ b/packages/apps/wallet-sdk-example/src/components/Header.tsx @@ -15,7 +15,7 @@ import { import { useTheme } from 'next-themes'; import { Link, useLocation } from 'react-router-dom'; import { useWalletState } from '../state/wallet'; -import { stickyHeader } from './Header.css'; +import { stickyHeader } from './header.css'; import { KadenaLogo } from './KadenaLogo'; export const Header = () => { From b5b393e332700a33c7ed3ed76b890cd275798c91 Mon Sep 17 00:00:00 2001 From: Nillo Date: Wed, 27 Nov 2024 16:38:24 +0100 Subject: [PATCH 055/103] chore(wallet-sdk-example): cleanup / fix for highlighting fail --- .../src/components/SdkFunctionDisplayer.tsx | 10 +++++++--- .../src/components/sdkFunctionDisplayer.css.ts | 10 ++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 packages/apps/wallet-sdk-example/src/components/sdkFunctionDisplayer.css.ts diff --git a/packages/apps/wallet-sdk-example/src/components/SdkFunctionDisplayer.tsx b/packages/apps/wallet-sdk-example/src/components/SdkFunctionDisplayer.tsx index ac0ed7d985..c1b30e6b7d 100644 --- a/packages/apps/wallet-sdk-example/src/components/SdkFunctionDisplayer.tsx +++ b/packages/apps/wallet-sdk-example/src/components/SdkFunctionDisplayer.tsx @@ -4,6 +4,10 @@ import javascript from 'highlight.js/lib/languages/javascript'; import 'highlight.js/styles/github.css'; import React, { useEffect, useRef } from 'react'; import { useWalletState } from '../state/wallet'; +import { + sdkDisplayCode, + sdkDisplayContainer, +} from './sdkFunctionDisplayer.css'; interface SdkFunctionDisplayProps { functionName: string; @@ -29,17 +33,17 @@ const SdkFunctionDisplay: React.FC = ({ if (codeRef.current) { hljs.highlightElement(codeRef.current); } - }, [codeString]); + }, [codeString, debugMode]); if (!debugMode) return null; return ( -
+
SDK Function Call -
+          
             
               {codeString}
             
diff --git a/packages/apps/wallet-sdk-example/src/components/sdkFunctionDisplayer.css.ts b/packages/apps/wallet-sdk-example/src/components/sdkFunctionDisplayer.css.ts
new file mode 100644
index 0000000000..47c9a838bc
--- /dev/null
+++ b/packages/apps/wallet-sdk-example/src/components/sdkFunctionDisplayer.css.ts
@@ -0,0 +1,10 @@
+import { style } from '@vanilla-extract/css';
+
+export const sdkDisplayContainer = style({
+  marginTop: '20px',
+  width: '100%',
+});
+
+export const sdkDisplayCode = style({
+  margin: 0,
+});

From 108c7698175384b57248d4c2c9caaa4b5e1bc721 Mon Sep 17 00:00:00 2001
From: Nillo 
Date: Wed, 27 Nov 2024 17:07:11 +0100
Subject: [PATCH 056/103] chore(wallet-sdk-example): refactoring / cleanup

---
 .../src/components/AccountItem.tsx            | 53 ++++++++++++++-
 .../src/components/TransactionModal.tsx       |  7 +-
 .../src/components/WordPhrase.tsx             |  5 ++
 .../kadenaNames/NameRegistrationForm.tsx      |  9 ---
 .../kadenaNames/NameRegistrationModal.tsx     |  4 --
 .../hooks/kadenaNames/kadenaNamesResolver.ts  | 39 ++++++++++-
 .../pages/kadenaNames/KadenaNamesResolver.tsx | 64 ++++++-------------
 .../wallet-sdk-example/src/state/words.ts     |  7 +-
 8 files changed, 121 insertions(+), 67 deletions(-)

diff --git a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx
index 8132e40c3d..8939aece16 100644
--- a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx
+++ b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx
@@ -1,3 +1,5 @@
+// src/components/AccountItem.tsx
+
 import { Badge, Button, Card, Divider, Stack, Text } from '@kadena/kode-ui';
 import React, { useEffect, useState } from 'react';
 import { createAndTransferFund } from '../domain/fund';
@@ -9,6 +11,7 @@ import { useWalletState } from '../state/wallet';
 import { AlertDialog } from './AlertDialog';
 import { ChainSelectionModal } from './ChainSelectorModal';
 import { NameRegistrationModal } from './kadenaNames/NameRegistrationModal';
+import SdkFunctionDisplay from './SdkFunctionDisplayer'; // Import SdkFunctionDisplay
 import { TextEllipsis } from './Text';
 
 interface AccountItemProps {
@@ -36,12 +39,42 @@ export const AccountItem: React.FC = ({
     name: resolvedName,
     loading: nameLoading,
     setAddress,
+    /* -- Start demo ---------------*/
+    sdkFunctionCall: nameSdkFunctionCall,
+    /* -- End demo ---------------*/
   } = useAddressToName(refreshKey, wallet.selectedNetwork);
 
+  /* -- Start demo ---------------*/
+  const [balanceSdkFunctionCall, setBalanceSdkFunctionCall] = useState<{
+    functionName: string;
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
+    functionArgs: any;
+  } | null>(null);
+  /* -- End demo ---------------*/
+
   useEffect(() => {
     setAddress(account.name);
   }, [account.name, setAddress, refreshKey]);
 
+  useEffect(() => {
+    /* -- Start demo ---------------*/
+    setBalanceSdkFunctionCall({
+      functionName: 'walletSdk.getAccountDetails',
+      functionArgs: {
+        accountName: account.name,
+        networkId: wallet.selectedNetwork,
+        fungible: wallet.selectedFungible,
+        chainIds: [wallet.selectedChain],
+      },
+    });
+    /* -- End demo ---------------*/
+  }, [
+    account.name,
+    wallet.selectedNetwork,
+    wallet.selectedFungible,
+    wallet.selectedChain,
+  ]);
+
   const openRegisterModal = () => setModalVisible(true);
   const closeRegisterModal = () => setModalVisible(false);
 
@@ -84,8 +117,6 @@ export const AccountItem: React.FC = ({
 
   const badgeVariant = accountBalance > 0 ? 'positive' : 'negative';
 
-  console.log('selectedNetwork: ', wallet.selectedNetwork);
-
   return (
     <>
       
@@ -182,6 +213,24 @@ export const AccountItem: React.FC = ({
               
             )}
           
+
+          {/* -- Start demo ---------------*/}
+          {/* Display the SDK function call for getAccountDetails */}
+          {balanceSdkFunctionCall && (
+            
+          )}
+
+          {/* Display the SDK function call for addressToName */}
+          {nameSdkFunctionCall && (
+            
+          )}
+          {/* -- End demo ---------------*/}
         
       
 
diff --git a/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx b/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx
index 1fb517f97a..3e5a9dd4de 100644
--- a/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx
+++ b/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx
@@ -16,8 +16,8 @@ interface TransactionModalProps {
   transactionJSON: string;
   onClose: () => void;
   onConfirm: () => void;
+  // demo
   gasFunctionCall?: {
-    // demo
     functionName: string;
     // eslint-disable-next-line @typescript-eslint/no-explicit-any
     functionArgs: any;
@@ -51,10 +51,9 @@ export const TransactionModal: React.FC = ({
           Estimated Gas Cost:{' '}
           {estimatedGas ?? 'Calculating...'}
         
-
         {/*
-              This is for Demo purposes, displaying the SDK function used to estimate gas
-            */}
+          This is for Demo purposes, displaying the SDK function used to estimate gas
+        */}
         {gasFunctionCall && (
           <>
              {
 
   const onGenerateMnemonic = () => {
     const words = wallet.generateMnemonic();
+    /*
+      For demonstration purposes only, the mnemonic is stored locally in this app,
+      which is not secure and should never be implemented this way in a production environment.
+      In production, only the encrypted seed should be stored if necessary, while the mnemonic should be securely kept by the end user.
+    */
     setMnemonicWords(words);
     wallet.changeMnemonicWords(words).catch(console.error);
   };
diff --git a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationForm.tsx b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationForm.tsx
index a16e89c20a..24a7d94767 100644
--- a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationForm.tsx
+++ b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationForm.tsx
@@ -156,7 +156,6 @@ export const NameRegistrationForm: React.FC = ({
 
   return (
     
-      {/* Network Info */}
       
         Network: {wallet.selectedNetwork}
       
@@ -164,7 +163,6 @@ export const NameRegistrationForm: React.FC = ({
         Current Balance: {balance} KDA
       
 
-      {/* Owner Address */}
        = ({
         size="md"
       />
 
-      {/* Receiver Address */}
        = ({
         size="md"
       />
 
-      {/* Chain Selector */}
       
 
-      {/* Registration Period */}
       
 
-      {/* Name Input */}
        = ({
         size="md"
       />
 
-      {/* Price Info */}
       {price !== null && (
         
           Price: {price} KDA for {registrationPeriod} year(s)
         
       )}
 
-      {/* Register Button */}
       
 
-      {/* Status/Error Messages */}
       {status && {status}}
       {error && {error}}
     
diff --git a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx
index b5f71a436d..16b1f0f78f 100644
--- a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx
+++ b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx
@@ -26,7 +26,6 @@ export const NameRegistrationModal: React.FC = ({
       }}
       size="sm"
     >
-      {/* Modal Header */}
        = ({
 
       
 
-      {/* Modal Content */}
-
        = ({
         balance={balance}
       />
 
-      {/* Buttons */}
        {
   const [error, setError] = useState(null);
   const [loading, setLoading] = useState(false);
 
+  /* -- Start demo ---------------*/
+  const [sdkFunctionCall, setSdkFunctionCall] = useState<{
+    functionName: string;
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
+    functionArgs: any;
+  } | null>(null);
+  /* -- End demo ---------------*/
+
   useEffect(() => {
     setName(null);
     setError(null);
@@ -24,6 +32,16 @@ export const useAddressToName = (refreshKey = 0, selectedNetwork: string) => {
     const getName = async () => {
       setLoading(true);
       try {
+        /* -- Start demo ---------------*/
+        setSdkFunctionCall({
+          functionName: 'walletSdk.kadenaNames.addressToName',
+          functionArgs: {
+            address: debouncedAddress,
+            networkId: selectedNetwork,
+          },
+        });
+        /* -- End demo ---------------*/
+
         const result = await walletSdk.kadenaNames.addressToName(
           debouncedAddress,
           selectedNetwork,
@@ -53,7 +71,7 @@ export const useAddressToName = (refreshKey = 0, selectedNetwork: string) => {
     };
   }, [debouncedAddress, refreshKey, selectedNetwork]);
 
-  return { name, error, loading, setAddress, address };
+  return { name, error, loading, setAddress, address, sdkFunctionCall };
 };
 
 export const useNameToAddress = (refreshKey = 0, selectedNetwork: string) => {
@@ -64,6 +82,14 @@ export const useNameToAddress = (refreshKey = 0, selectedNetwork: string) => {
   const [error, setError] = useState(null);
   const [loading, setLoading] = useState(false);
 
+  /* -- Start demo ---------------*/
+  const [sdkFunctionCall, setSdkFunctionCall] = useState<{
+    functionName: string;
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
+    functionArgs: any;
+  } | null>(null);
+  /* -- End demo ---------------*/
+
   useEffect(() => {
     setAddress(null);
     setError(null);
@@ -78,6 +104,15 @@ export const useNameToAddress = (refreshKey = 0, selectedNetwork: string) => {
     const getAddress = async () => {
       setLoading(true);
       try {
+        /* -- Start demo ---------------*/
+        setSdkFunctionCall({
+          functionName: 'walletSdk.kadenaNames.nameToAddress',
+          functionArgs: {
+            name: debouncedName,
+            networkId: selectedNetwork,
+          },
+        });
+        /* -- End demo ---------------*/
         const result = await walletSdk.kadenaNames.nameToAddress(
           debouncedName,
           selectedNetwork,
@@ -107,5 +142,5 @@ export const useNameToAddress = (refreshKey = 0, selectedNetwork: string) => {
     };
   }, [debouncedName, refreshKey, selectedNetwork]);
 
-  return { address, error, loading, setName, name };
+  return { address, error, loading, setName, name, sdkFunctionCall };
 };
diff --git a/packages/apps/wallet-sdk-example/src/pages/kadenaNames/KadenaNamesResolver.tsx b/packages/apps/wallet-sdk-example/src/pages/kadenaNames/KadenaNamesResolver.tsx
index 5b857a32ae..3258798215 100644
--- a/packages/apps/wallet-sdk-example/src/pages/kadenaNames/KadenaNamesResolver.tsx
+++ b/packages/apps/wallet-sdk-example/src/pages/kadenaNames/KadenaNamesResolver.tsx
@@ -9,8 +9,8 @@ import {
   TextField,
 } from '@kadena/kode-ui';
 
-import React, { useEffect, useState } from 'react';
-import SdkFunctionDisplay from '../../components/SdkFunctionDisplayer'; // Demo
+import React from 'react';
+import SdkFunctionDisplay from '../../components/SdkFunctionDisplayer';
 import {
   useAddressToName,
   useNameToAddress,
@@ -26,6 +26,9 @@ export const KadenaNames: React.FC = () => {
     loading: nameLoading,
     setAddress,
     address: inputAddress,
+    /* -- Start demo ---------------*/
+    sdkFunctionCall: addressToNameSdkCall,
+    /* -- End demo ---------------*/
   } = useAddressToName(0, wallet.selectedNetwork);
 
   const {
@@ -34,41 +37,11 @@ export const KadenaNames: React.FC = () => {
     loading: addressLoading,
     setName,
     name: inputName,
+    /* -- Start demo ---------------*/
+    sdkFunctionCall: nameToAddressSdkCall,
+    /* -- End demo ---------------*/
   } = useNameToAddress(0, wallet.selectedNetwork);
 
-  //* -- Start demo ---------------*/
-  const [functionCalls, setFunctionCalls] = useState<
-    // eslint-disable-next-line @typescript-eslint/no-explicit-any
-    { functionName: string; functionArgs: any }[]
-  >([]);
-
-  useEffect(() => {
-    const calls = [];
-
-    if (inputAddress) {
-      calls.push({
-        functionName: 'walletSdk.kadenaNames.addressToName',
-        functionArgs: {
-          address: inputAddress,
-          networkId: wallet.selectedNetwork,
-        },
-      });
-    }
-
-    if (inputName) {
-      calls.push({
-        functionName: 'walletSdk.kadenaNames.nameToAddress',
-        functionArgs: {
-          name: inputName,
-          networkId: wallet.selectedNetwork,
-        },
-      });
-    }
-
-    setFunctionCalls(calls);
-  }, [inputAddress, inputName, wallet.selectedNetwork]);
-  /* -- End demo ---------------*/
-
   return (
     
@@ -81,7 +54,6 @@ export const KadenaNames: React.FC = () => { - {/* Address to Name */} Address to Name { )} - {/* Name to Address */} Name to Address { {/* - This is for Demo purposes, displaying what SDK function is execution for this action + This is for Demo purposes, displaying the SDK functions used in this component */}
- {functionCalls.map((call, index) => ( + {/* -- Start demo ---------------*/} + {addressToNameSdkCall && ( + + )} + {nameToAddressSdkCall && ( - ))} + )} + {/* -- End demo ---------------*/}
); diff --git a/packages/apps/wallet-sdk-example/src/state/words.ts b/packages/apps/wallet-sdk-example/src/state/words.ts index 74c601f19a..1a434d7957 100644 --- a/packages/apps/wallet-sdk-example/src/state/words.ts +++ b/packages/apps/wallet-sdk-example/src/state/words.ts @@ -1,9 +1,10 @@ import { useAtom } from 'jotai'; import { atomWithStorage } from 'jotai/utils'; -// Words logic is separated because a wallet normally would not store this, ever. -// This example wallet stores it for testing purposes. - +/* + Words logic is separated because a wallet normally would not store this, ever. + This example wallet stores it for testing purposes. +*/ const mnemonicWordsAtom = atomWithStorage( 'mnemonic_words', null, From c36f5ebe8eed148605f90909509a3e2842b122e6 Mon Sep 17 00:00:00 2001 From: Nillo Date: Wed, 27 Nov 2024 18:19:34 +0100 Subject: [PATCH 057/103] feat(wallet-sdk-example) added tooltip with (popper) support --- packages/apps/wallet-sdk-example/package.json | 1 + .../src/components/Header.tsx | 95 ++++++++++-------- .../src/components/ToolTip.tsx | 96 +++++++++++++++++++ .../src/components/tooltip.css.ts | 28 ++++++ pnpm-lock.yaml | 8 ++ 5 files changed, 189 insertions(+), 39 deletions(-) create mode 100644 packages/apps/wallet-sdk-example/src/components/ToolTip.tsx create mode 100644 packages/apps/wallet-sdk-example/src/components/tooltip.css.ts diff --git a/packages/apps/wallet-sdk-example/package.json b/packages/apps/wallet-sdk-example/package.json index 080ec352a4..ecbdc46f63 100644 --- a/packages/apps/wallet-sdk-example/package.json +++ b/packages/apps/wallet-sdk-example/package.json @@ -15,6 +15,7 @@ "@kadena/kode-icons": "workspace:*", "@kadena/kode-ui": "workspace:*", "@kadena/wallet-sdk": "workspace:*", + "@popperjs/core": "^2.11.8", "@tanstack/react-query": "^5.32.0", "@types/markdown-it": "^14.1.2", "@types/react-router-dom": "^5.3.3", diff --git a/packages/apps/wallet-sdk-example/src/components/Header.tsx b/packages/apps/wallet-sdk-example/src/components/Header.tsx index ff2adbac0f..ccfd11d165 100644 --- a/packages/apps/wallet-sdk-example/src/components/Header.tsx +++ b/packages/apps/wallet-sdk-example/src/components/Header.tsx @@ -13,12 +13,14 @@ import { SelectItem, } from '@kadena/kode-ui'; import { useTheme } from 'next-themes'; +import React from 'react'; import { Link, useLocation } from 'react-router-dom'; import { useWalletState } from '../state/wallet'; import { stickyHeader } from './header.css'; import { KadenaLogo } from './KadenaLogo'; +import Tooltip from './ToolTip'; -export const Header = () => { +export const Header: React.FC = () => { const location = useLocation(); const { theme, setTheme } = useTheme(); const { selectNetwork, selectedNetwork, debugMode, setDebugMode } = @@ -47,45 +49,60 @@ export const Header = () => { activeHref={location.pathname} > - - Wallet - - - Transfers List - - - Transfer Funds - - - Kadena Names - + + + Wallet + + + + + Transfers List + + + + + Transfer Funds + + + + + Kadena Names + + - selectChainNetwork(key as string)} - selectedKey={selectedNetwork} - startVisual={} - > - - Mainnet - - - Testnet - - - Testnet (Pact 5) - - - } - onPress={toggleTheme} - aria-label="Toggle Theme" - /> - : } - onPress={toggleDebugMode} - aria-label="Toggle Theme" - /> + + + selectChainNetwork(key as string)} + selectedKey={selectedNetwork} + startVisual={} + > + + Mainnet + + + Testnet + + + Testnet (Pact 5) + + + + + } + onPress={toggleTheme} + aria-label="Toggle Theme" + /> + + + : } + onPress={toggleDebugMode} + aria-label="Toggle Tutorial Mode" + /> + ); }; diff --git a/packages/apps/wallet-sdk-example/src/components/ToolTip.tsx b/packages/apps/wallet-sdk-example/src/components/ToolTip.tsx new file mode 100644 index 0000000000..f2b2e9d34d --- /dev/null +++ b/packages/apps/wallet-sdk-example/src/components/ToolTip.tsx @@ -0,0 +1,96 @@ +import { createPopper, Instance as PopperInstance } from '@popperjs/core'; +import React, { useEffect, useRef, useState } from 'react'; +import { tooltipContent } from './tooltip.css'; + +interface TooltipProps { + text: string; + children: React.ReactNode; +} + +const Tooltip: React.FC = ({ text, children }) => { + const referenceRef = useRef(null); + const popperRef = useRef(null); + const popperInstanceRef = useRef(null); + const [visible, setVisible] = useState(false); + const [hasShown, setHasShown] = useState(false); + + const showTooltip = () => { + if (!hasShown) { + setVisible(true); + setHasShown(true); + } + if (popperInstanceRef.current) { + popperInstanceRef.current.update(); + } + }; + + const hideTooltip = () => { + setVisible(false); + }; + + useEffect(() => { + if (referenceRef.current && popperRef.current) { + popperInstanceRef.current = createPopper( + referenceRef.current, + popperRef.current, + { + placement: 'auto', + strategy: 'fixed', + modifiers: [ + { name: 'offset', options: { offset: [0, 8] } }, + { + name: 'preventOverflow', + options: { boundary: 'clippingParents' }, + }, + { + name: 'flip', + options: { + fallbackPlacements: ['top', 'right', 'bottom', 'left'], + }, + }, + ], + }, + ); + } + + return () => { + if (popperInstanceRef.current) { + popperInstanceRef.current.destroy(); + popperInstanceRef.current = null; + } + }; + }, []); + + useEffect(() => { + if (visible && popperInstanceRef.current) { + popperInstanceRef.current.update(); + } + }, [visible]); + + return ( + <> + + {children} + +
+ {text} +
+ + ); +}; + +export default Tooltip; diff --git a/packages/apps/wallet-sdk-example/src/components/tooltip.css.ts b/packages/apps/wallet-sdk-example/src/components/tooltip.css.ts new file mode 100644 index 0000000000..720cd70c00 --- /dev/null +++ b/packages/apps/wallet-sdk-example/src/components/tooltip.css.ts @@ -0,0 +1,28 @@ +import { style } from '@vanilla-extract/css'; + +export const tooltipContainer = style({ + position: 'relative', + display: 'inline-block', +}); + +export const tooltipContent = style({ + backgroundColor: '#333', + color: '#fff', + padding: '8px', + borderRadius: '4px', + fontSize: '14px', + boxShadow: '0 2px 8px rgba(0, 0, 0, 0.15)', + zIndex: 1000, + maxWidth: '200px', + textAlign: 'center', + position: 'fixed', + opacity: 0, + visibility: 'hidden', + transition: 'opacity 0.2s', + selectors: { + '&[data-show]': { + opacity: 1, + visibility: 'visible', + }, + }, +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b9abaacc01..ba1cfe83db 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1645,6 +1645,9 @@ importers: '@kadena/wallet-sdk': specifier: workspace:* version: link:../../libs/wallet-sdk + '@popperjs/core': + specifier: ^2.11.8 + version: 2.11.8 '@tanstack/react-query': specifier: ^5.32.0 version: 5.49.2(react@18.3.1) @@ -7506,6 +7509,9 @@ packages: '@polka/url@1.0.0-next.25': resolution: {integrity: sha512-j7P6Rgr3mmtdkeDGTe0E/aYyWEWVtc5yFXtHCRHs28/jptDEWfaVOc5T7cblqy1XKPPfCxJc/8DwQ5YgLOZOVQ==} + '@popperjs/core@2.11.8': + resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==} + '@pothos/core@3.41.2': resolution: {integrity: sha512-iR1gqd93IyD/snTW47HwKSsRCrvnJaYwjVNcUG8BztZPqMxyJKPAnjPHAgu1XB82KEdysrNqIUnXqnzZIs08QA==} peerDependencies: @@ -26578,6 +26584,8 @@ snapshots: '@polka/url@1.0.0-next.25': {} + '@popperjs/core@2.11.8': {} + '@pothos/core@3.41.2(graphql@16.8.2)': dependencies: graphql: 16.8.2 From 92faf0f5f349aafb57518d7cd8721130b05a0a54 Mon Sep 17 00:00:00 2001 From: Nillo Date: Wed, 27 Nov 2024 20:41:57 +0100 Subject: [PATCH 058/103] minor fix --- packages/apps/wallet-sdk-example/src/components/AccountItem.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx index 8939aece16..537b866233 100644 --- a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx +++ b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx @@ -1,5 +1,3 @@ -// src/components/AccountItem.tsx - import { Badge, Button, Card, Divider, Stack, Text } from '@kadena/kode-ui'; import React, { useEffect, useState } from 'react'; import { createAndTransferFund } from '../domain/fund'; From f32765d7d3cf27692f5827bafc7b03df1c766826 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Tue, 3 Dec 2024 09:56:13 +0100 Subject: [PATCH 059/103] feat(wallet-sdk): add cross chain complete subscribe method --- .../wallet-sdk-example/src/hooks/transfers.ts | 1 + packages/libs/wallet-sdk/src/gql/gql.ts | 9 +- packages/libs/wallet-sdk/src/gql/graphql.ts | 18 +- .../src/sdk/crossChainFinishCreate.ts | 1 - packages/libs/wallet-sdk/src/sdk/interface.ts | 2 +- .../sdk/tests/mapTransferXchainEnd.test.ts | 2 +- .../sdk/tests/mapTransferXchainStart.test.tsx | 2 +- .../tests/mapTransferXchainUnfinished.test.ts | 2 +- packages/libs/wallet-sdk/src/sdk/walletSdk.ts | 38 ++- .../src/services/graphql/getTransfers.ts | 311 +----------------- .../src/services/graphql/pollTransfers.ts | 71 ++++ .../src/services/graphql/transfer.query.ts | 66 ++++ .../src/services/graphql/transfer.util.ts | 310 +++++++++++++++++ 13 files changed, 512 insertions(+), 321 deletions(-) create mode 100644 packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts create mode 100644 packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts diff --git a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts index 932cba0a4c..3ed0015c4b 100644 --- a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts +++ b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts @@ -85,6 +85,7 @@ export const useTransfers = () => { /* -- End demo ---------------*/ walletSdk.subscribeOnCrossChainComplete( + wallet.account?.name ?? '', incompleteTransfers, () => refetch(), { diff --git a/packages/libs/wallet-sdk/src/gql/gql.ts b/packages/libs/wallet-sdk/src/gql/gql.ts index 935722c05c..ffc2c7808b 100644 --- a/packages/libs/wallet-sdk/src/gql/gql.ts +++ b/packages/libs/wallet-sdk/src/gql/gql.ts @@ -14,7 +14,8 @@ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document- * Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size */ const documents = { - "\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n": types.AccountTransfersDocument, + "\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n": types.AccountTransfersDocument, + "\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n": types.AccountTransferRequestKeyDocument, }; /** @@ -34,7 +35,11 @@ export function graphql(source: string): unknown; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n"]; +export function graphql(source: "\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n"]; export function graphql(source: string) { return (documents as any)[source] ?? {}; diff --git a/packages/libs/wallet-sdk/src/gql/graphql.ts b/packages/libs/wallet-sdk/src/gql/graphql.ts index 30c29628e9..0f9b726b79 100644 --- a/packages/libs/wallet-sdk/src/gql/graphql.ts +++ b/packages/libs/wallet-sdk/src/gql/graphql.ts @@ -49,7 +49,19 @@ export type AccountTransfersQuery = { __typename?: 'Query', lastBlockHeight?: an & { ' $fragmentRefs'?: { 'TransferFieldsFragment': TransferFieldsFragment } } ) }> } } | null }; -export type TransferFieldsFragment = { __typename?: 'Transfer', amount: any, chainId: any, orderIndex: any, receiverAccount: string, requestKey: string, senderAccount: string, block: { __typename?: 'Block', hash: string, height: any, creationTime: any }, transaction?: { __typename?: 'Transaction', cmd: { __typename?: 'TransactionCommand', networkId: string, payload: { __typename: 'ContinuationPayload', step?: number | null, pactId?: string | null } | { __typename: 'ExecutionPayload', code?: string | null, data: string }, signers: Array<{ __typename?: 'Signer', clist: Array<{ __typename?: 'TransactionCapability', name: string, args: string }> }> }, result: { __typename: 'TransactionMempoolInfo' } | { __typename: 'TransactionResult', goodResult?: string | null, badResult?: string | null, events: { __typename?: 'TransactionResultEventsConnection', edges: Array<{ __typename?: 'TransactionResultEventsConnectionEdge', node: { __typename?: 'Event', name: string, parameters?: string | null } } | null> } } } | null } & { ' $fragmentName'?: 'TransferFieldsFragment' }; +export type TransferFieldsFragment = { __typename?: 'Transfer', amount: any, chainId: any, orderIndex: any, receiverAccount: string, requestKey: string, senderAccount: string, moduleName: string, block: { __typename?: 'Block', hash: string, height: any, creationTime: any }, transaction?: { __typename?: 'Transaction', cmd: { __typename?: 'TransactionCommand', networkId: string, payload: { __typename: 'ContinuationPayload', step?: number | null, pactId?: string | null } | { __typename: 'ExecutionPayload', code?: string | null, data: string }, signers: Array<{ __typename?: 'Signer', clist: Array<{ __typename?: 'TransactionCapability', name: string, args: string }> }> }, result: { __typename: 'TransactionMempoolInfo' } | { __typename: 'TransactionResult', goodResult?: string | null, badResult?: string | null, events: { __typename?: 'TransactionResultEventsConnection', edges: Array<{ __typename?: 'TransactionResultEventsConnectionEdge', node: { __typename?: 'Event', name: string, parameters?: string | null } } | null> } } } | null } & { ' $fragmentName'?: 'TransferFieldsFragment' }; -export const TransferFieldsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; -export const AccountTransfersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountTransfers"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"fungibleAccount"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}},{"kind":"Argument","name":{"kind":"Name","value":"fungibleName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"100"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}},{"kind":"Field","name":{"kind":"Name","value":"crossChainTransfer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file +export type AccountTransferRequestKeyQueryVariables = Exact<{ + requestKey: Scalars['String']['input']; + accountName?: InputMaybe; +}>; + + +export type AccountTransferRequestKeyQuery = { __typename?: 'Query', lastBlockHeight?: any | null, transfers: { __typename?: 'QueryTransfersConnection', edges: Array<{ __typename?: 'QueryTransfersConnectionEdge', node: ( + { __typename?: 'Transfer' } + & { ' $fragmentRefs'?: { 'TransferFieldsFragment': TransferFieldsFragment } } + ) }> } }; + +export const TransferFieldsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; +export const AccountTransfersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountTransfers"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"fungibleAccount"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}},{"kind":"Argument","name":{"kind":"Name","value":"fungibleName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"100"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}},{"kind":"Field","name":{"kind":"Name","value":"crossChainTransfer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; +export const AccountTransferRequestKeyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountTransferRequestKey"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"requestKey"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"requestKey"},"value":{"kind":"Variable","name":{"kind":"Name","value":"requestKey"}}},{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/packages/libs/wallet-sdk/src/sdk/crossChainFinishCreate.ts b/packages/libs/wallet-sdk/src/sdk/crossChainFinishCreate.ts index b35dffc1b8..d7a121676a 100644 --- a/packages/libs/wallet-sdk/src/sdk/crossChainFinishCreate.ts +++ b/packages/libs/wallet-sdk/src/sdk/crossChainFinishCreate.ts @@ -1,6 +1,5 @@ import type { ChainId, ISigner } from '@kadena/client'; import { createClient, Pact } from '@kadena/client'; -// import {} from '@kadena/client-utils/coin'; /** * ICreateCrossChainFinishInput represents a subset of Transfer diff --git a/packages/libs/wallet-sdk/src/sdk/interface.ts b/packages/libs/wallet-sdk/src/sdk/interface.ts index 969f9594c9..fc43a7e0a5 100644 --- a/packages/libs/wallet-sdk/src/sdk/interface.ts +++ b/packages/libs/wallet-sdk/src/sdk/interface.ts @@ -36,7 +36,7 @@ interface ISameChainTransfer extends IBaseTransfer { isCrossChainTransfer: false; } -interface ICrossChainTransfer extends IBaseTransfer { +export interface ICrossChainTransfer extends IBaseTransfer { isCrossChainTransfer: true; targetChainId: ChainId; continuation?: { diff --git a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts index 309f9a8ee0..3adfa8d782 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from 'vitest'; -import { parseGqlTransfers } from '../../services/graphql/getTransfers'; +import { parseGqlTransfers } from '../../services/graphql/transfer.util'; import type { Transfer } from '../interface'; const GQL_TRANSFER_XCHAIN_FINISH = [ diff --git a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx index 3c4670a400..101d4bfdf1 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx +++ b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx @@ -1,5 +1,5 @@ import { describe, expect, test } from 'vitest'; -import { parseGqlTransfers } from '../../services/graphql/getTransfers'; +import { parseGqlTransfers } from '../../services/graphql/transfer.util'; import type { Transfer } from '../interface'; const TRANSFER_XCHAIN_SEND = [ diff --git a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts index d325365f06..a2f34d71e3 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from 'vitest'; -import { parseGqlTransfers } from '../../services/graphql/getTransfers'; +import { parseGqlTransfers } from '../../services/graphql/transfer.util'; import type { Transfer } from '../interface'; const TRANSFER_XCHAIN_SEND = [ diff --git a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts index 18ce05daf1..2addd9ec9f 100644 --- a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts +++ b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts @@ -15,6 +15,7 @@ import type { import * as accountService from '../services/accountService.js'; import { pollRequestKeys } from '../services/chainweb/chainweb.js'; import { getTransfers } from '../services/graphql/getTransfers.js'; +import { pollGraphqlTransfers } from '../services/graphql/pollTransfers.js'; import { poll } from '../utils/retry.js'; import { isEmpty, notEmpty } from '../utils/typeUtils.js'; import type { ICreateCrossChainFinishInput } from './crossChainFinishCreate.js'; @@ -30,6 +31,7 @@ import type { CreateTransfer, IAccountDetails, IChain, + ICrossChainTransfer, ITransactionDescriptor, Transfer, } from './interface.js'; @@ -165,11 +167,43 @@ export class WalletSDK { } public subscribeOnCrossChainComplete( + accountName: string, transfers: ITransactionDescriptor[], - callback: (transfer: Transfer) => void, + callback: (transfer: ICrossChainTransfer) => void, options?: { signal?: AbortSignal }, ): void { - return undefined; + const promises = transfers.map(async (transfer) => { + return poll( + async (signal) => { + const result = await pollGraphqlTransfers({ + accountName: accountName, + graphqlUrl: this.getGraphqlUrl({ + networkId: transfer.networkId, + }), + logger: this.logger, + requestKeys: [transfer.requestKey], + signal, + }); + const results = Object.values(result).flat(); + results.forEach((row) => { + if (row.isCrossChainTransfer && row.continuation !== undefined) { + callback(row); + } else { + throw new Error('Cross-chain transfer not complete'); + } + }); + }, + { + delayMs: 30000, + timeoutSeconds: 3600, + signal: options?.signal, + }, + ); + }); + + Promise.all(promises).catch((error) => { + console.log('error', error); + }); } public async waitForPendingTransaction( diff --git a/packages/libs/wallet-sdk/src/services/graphql/getTransfers.ts b/packages/libs/wallet-sdk/src/services/graphql/getTransfers.ts index 03bc79883d..7e69bce0d7 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/getTransfers.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/getTransfers.ts @@ -1,50 +1,8 @@ -import type { ChainId } from '@kadena/types'; import { createClient, fetchExchange } from '@urql/core'; -import type { TransferFieldsFragment } from '../../gql/graphql.js'; import type { Transfer } from '../../sdk/interface.js'; -import { parsePactNumber } from '../../utils/pact.util.js'; -import { safeJsonParse } from '../../utils/string.util.js'; -import { isEmpty, notEmpty } from '../../utils/typeUtils.js'; import { TRANSFER_QUERY } from './transfer.query.js'; - -type GqlTransfer = TransferFieldsFragment & { - crossChainTransfer?: TransferFieldsFragment | null; -}; - -function parseClist(node: GqlTransfer) { - if (isEmpty(node.transaction)) return []; - const clist = node.transaction.cmd.signers.flatMap((x) => - x.clist - .map((item) => { - const args = safeJsonParse<(number | string | object)[]>(item.args); - if (args === null) return null; - return { name: item.name, args }; - }) - .filter(notEmpty), - ); - return clist; -} -type CList = ReturnType; - -function parseEvents(node: GqlTransfer) { - if ( - isEmpty(node.transaction) || - node.transaction.result.__typename === 'TransactionMempoolInfo' - ) { - return []; - } - return node.transaction.result.events.edges - .flatMap((x) => { - if (!x) return null; - const parameters = safeJsonParse<(number | string | object)[]>( - x.node.parameters, - ); - if (parameters === null) return null; - return { name: x.node.name, parameters }; - }) - .filter(notEmpty); -} -type Events = ReturnType; +import type { GqlTransfer } from './transfer.util.js'; +import { parseGqlTransfers } from './transfer.util.js'; async function fetchTransfers( graphqlUrl: string, @@ -66,271 +24,6 @@ async function fetchTransfers( }; } -type GqlTransferParsed = GqlTransfer & { - events: Events; - clist: CList; - fungibleName: string; - crossChainTransfer?: - | (TransferFieldsFragment & { - events: Events; - clist: CList; - fungibleName: string; - }) - | null; -}; - -const parseTransfer = ( - node: GqlTransfer, - fungibleName: string, -): GqlTransferParsed => { - return { - ...node, - events: parseEvents(node), - clist: parseClist(node), - fungibleName, - crossChainTransfer: node.crossChainTransfer - ? parseTransfer(node.crossChainTransfer, fungibleName) - : null, - }; -}; - -const isTransactionFeeTransfer = (transfer: GqlTransfer) => - transfer.orderIndex === 0; - -const isSuccess = (transfer: GqlTransfer) => { - return ( - transfer.transaction?.result.__typename === 'TransactionResult' && - Boolean(transfer.transaction.result.goodResult) - ); -}; - -const matchSender = ( - transfer: GqlTransferParsed, - arg: number | string | object, -) => { - return transfer.senderAccount !== '' ? arg === transfer.senderAccount : true; -}; -const matchReceiver = ( - transfer: GqlTransferParsed, - arg: number | string | object, -) => { - return transfer.receiverAccount !== '' - ? arg === transfer.receiverAccount - : true; -}; -const matchAmount = ( - transfer: GqlTransferParsed, - arg: number | string | object, -) => { - return transfer.amount <= parsePactNumber(arg); -}; - -const getCrossChainTransferStart = (transfer: GqlTransferParsed) => { - const match = transfer.events.find( - (event) => - event.name === `TRANSFER_XCHAIN` && - matchSender(transfer, event.parameters[0]) && - matchReceiver(transfer, event.parameters[1]) && - matchAmount(transfer, event.parameters[2]), - ); - if (isEmpty(match)) return null; - return { - receiverAccount: (transfer.receiverAccount || - transfer.crossChainTransfer?.receiverAccount || - match.parameters[1]) as string, - senderAccount: (transfer.senderAccount || - transfer.crossChainTransfer?.senderAccount || - match.parameters[0]) as string, - targetChainId: String(match.parameters?.[3]) as ChainId, - }; -}; - -const getCrossChainTransferFinish = (transfer: GqlTransferParsed) => { - const match = transfer.events.find( - (event) => - event.name === 'TRANSFER_XCHAIN_RECD' && - matchSender(transfer, event.parameters[0]) && - matchReceiver(transfer, event.parameters[1]) && - matchAmount(transfer, event.parameters[2]), - ); - - if (isEmpty(match)) return null; - - return { - receiverAccount: (transfer.receiverAccount || - transfer.crossChainTransfer?.receiverAccount || - match.parameters?.[1]) as string, - senderAccount: (transfer.senderAccount || - transfer.crossChainTransfer?.senderAccount || - match.parameters?.[0]) as string, - targetChainId: String( - transfer.crossChainTransfer?.chainId || match.parameters?.[3], - ) as ChainId, - }; -}; - -const mapBaseTransfer = ( - gqlTransfer: GqlTransferParsed, - lastBlockHeight: number, -): Transfer => { - return { - amount: gqlTransfer.amount, - chainId: String(gqlTransfer.chainId) as ChainId, - requestKey: gqlTransfer.requestKey, - senderAccount: gqlTransfer.senderAccount, - receiverAccount: gqlTransfer.receiverAccount, - isCrossChainTransfer: false, - success: isSuccess(gqlTransfer), - token: gqlTransfer.fungibleName, - networkId: gqlTransfer.transaction?.cmd.networkId!, - block: { - creationTime: new Date(gqlTransfer.block.creationTime), - blockDepthEstimate: lastBlockHeight - 3 - gqlTransfer.block.height, - hash: gqlTransfer.block.hash, - height: gqlTransfer.block.height, - }, - }; -}; - -export const gqlTransferToTransfer = ( - rawGqlTransfer: GqlTransfer, - _accountName: string, - lastBlockHeight: number, - fungibleName: string = 'coin', -): Transfer | null => { - const gqlTransfer = parseTransfer(rawGqlTransfer, fungibleName); - const xChainStart = getCrossChainTransferStart(gqlTransfer); - const xChainFinish = getCrossChainTransferFinish(gqlTransfer); - - if (xChainStart) { - const result: Transfer = { - ...mapBaseTransfer(gqlTransfer, lastBlockHeight), - isCrossChainTransfer: true, - targetChainId: xChainStart.targetChainId, - receiverAccount: isTransactionFeeTransfer(gqlTransfer) - ? gqlTransfer.receiverAccount - : xChainStart.receiverAccount, - }; - if (gqlTransfer.crossChainTransfer) { - result.continuation = { - requestKey: gqlTransfer.crossChainTransfer.requestKey, - success: isSuccess(gqlTransfer.crossChainTransfer), - }; - } - return result; - } - - if (xChainFinish) { - // crossChainTransfer can't be null for finish events - if (!gqlTransfer.crossChainTransfer) return null; - return { - ...mapBaseTransfer(gqlTransfer.crossChainTransfer, lastBlockHeight), - isCrossChainTransfer: true, - targetChainId: String(gqlTransfer.chainId) as ChainId, - receiverAccount: xChainFinish.receiverAccount, - continuation: { - requestKey: gqlTransfer.requestKey, - success: isSuccess(gqlTransfer), - }, - }; - } - - return mapBaseTransfer(gqlTransfer, lastBlockHeight); -}; - -export function parseGqlTransfers( - nodes: GqlTransfer[], - lastBlockHeight: number, - accountName: string, - fungibleName?: string, -): Transfer[] { - const grouped = nodes.reduce( - (acc, node) => { - const key = node.requestKey; - if (!(key in acc)) acc[key] = []; - acc[key].push(node); - return acc; - }, - {} as Record, - ); - - const mapped = Object.values(grouped).flatMap((nodes) => { - const transactionFee = nodes.find((node) => isTransactionFeeTransfer(node)); - const transfers = nodes.filter((node) => !isTransactionFeeTransfer(node)); - - // console.log('nodes', nodes); - - // Failed transfers only have the transaction fee transfer - // For wallets, give the transfer with original amount and receiver - if (transfers.length === 0) { - const gqlTransfer = nodes[0]; - - if (isSuccess(gqlTransfer)) { - // eslint-disable-next-line no-console - console.log( - 'RequestKey found with one one Transfer, but it does not have failed status.', - ); - return []; - } - - // Not success, must be a gas payment: Reconstruct original transfer - const clist = parseClist(gqlTransfer); - const transferCap = clist.find((x) => x.name === 'coin.TRANSFER')?.args; - if (isEmpty(transferCap)) return []; - const transactionFeeTransfer = gqlTransferToTransfer( - gqlTransfer, - accountName, - lastBlockHeight, - fungibleName, - ); - if (!transactionFeeTransfer) return []; - const transfer: Transfer = { - ...transactionFeeTransfer, - receiverAccount: String(transferCap[1]), - // Could technically be different from the value used in payload.code - // It would be an improvement to parse code instead of using the cap, but that is very complex. - amount: parsePactNumber(transferCap[2]), - success: false, - transactionFeeTransfer: { - ...transactionFeeTransfer, - isBulkTransfer: false, - success: true, - }, - }; - return [transfer]; - } - - return transfers.map((gqlTransfer) => { - const base = gqlTransferToTransfer( - gqlTransfer, - accountName, - lastBlockHeight, - fungibleName, - ); - if (!base) return null; - const transactionFeeBase = transactionFee - ? gqlTransferToTransfer( - transactionFee, - accountName, - lastBlockHeight, - fungibleName, - ) - : null; - return { - ...base, - transactionFeeTransfer: transactionFeeBase - ? { - ...transactionFeeBase, - isBulkTransfer: transfers.length > 1, - } - : undefined, - } as Transfer; - }); - }); - - return mapped.filter(notEmpty); -} - // Currently queries all chains export async function getTransfers( graphqlUrl: string, diff --git a/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts b/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts new file mode 100644 index 0000000000..8a955b4b3f --- /dev/null +++ b/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts @@ -0,0 +1,71 @@ +import { createClient, fetchExchange } from '@urql/core'; +import type { Transfer } from '../../sdk/interface'; +import type { Logger } from '../../sdk/logger'; +import { TRANSFER_REQUESTKEY_QUERY } from './transfer.query'; +import type { GqlTransfer } from './transfer.util'; +import { parseGqlTransfers } from './transfer.util'; + +interface IRollGraphqlTransfers { + graphqlUrl: string; + accountName: string; + requestKeys: string[]; + signal?: AbortSignal; + logger: Logger; +} + +export async function queryTransferRequestKey( + graphqlUrl: string, + accountName: string, + requestKey: string, +) { + const client = createClient({ url: graphqlUrl, exchanges: [fetchExchange] }); + + const result = await client + .query(TRANSFER_REQUESTKEY_QUERY, { + accountName, + requestKey, + }) + .toPromise(); + + const nodes = result.data?.transfers.edges.map( + (edge) => edge.node as GqlTransfer, + ); + + return { + transfers: nodes ?? [], + lastBlockHeight: (result.data?.lastBlockHeight ?? null) as number | null, + }; +} + +export async function pollGraphqlTransfers({ + accountName, + graphqlUrl, + logger, + requestKeys, + signal, +}: IRollGraphqlTransfers) { + console.log('pollGraphqlTransfers', { + accountName, + graphqlUrl, + requestKeys, + }); + + const result = await Promise.all( + requestKeys.map(async (requestKey) => { + const { transfers: nodes, lastBlockHeight } = + await queryTransferRequestKey(graphqlUrl, accountName, requestKey); + return parseGqlTransfers(nodes, lastBlockHeight ?? 0, accountName); + }), + ); + + return result.reduce( + (acc, row) => { + for (const transfer of row) { + if (!acc[transfer.requestKey]) acc[transfer.requestKey] = []; + acc[transfer.requestKey].push(transfer); + } + return acc; + }, + {} as Record, + ); +} diff --git a/packages/libs/wallet-sdk/src/services/graphql/transfer.query.ts b/packages/libs/wallet-sdk/src/services/graphql/transfer.query.ts index 81620665bb..33119c7a91 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/transfer.query.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/transfer.query.ts @@ -23,6 +23,72 @@ export const TRANSFER_QUERY = graphql(` receiverAccount requestKey senderAccount + moduleName + block { + hash + height + creationTime + } + transaction { + cmd { + networkId + payload { + __typename + ... on ExecutionPayload { + code + data + } + ... on ContinuationPayload { + step + pactId + } + } + signers { + clist { + name + args + } + } + } + result { + __typename + ... on TransactionResult { + goodResult + badResult + events { + edges { + node { + name + parameters + } + } + } + } + } + } + } +`); + +export const TRANSFER_REQUESTKEY_QUERY = graphql(` + query accountTransferRequestKey($requestKey: String!, $accountName: String) { + lastBlockHeight + transfers(requestKey: $requestKey, accountName: $accountName) { + edges { + node { + ...TransferFields + } + } + } + } + + fragment TransferFields on Transfer { + amount + chainId + orderIndex + receiverAccount + requestKey + senderAccount + moduleName block { hash height diff --git a/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts b/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts new file mode 100644 index 0000000000..b22a2344c8 --- /dev/null +++ b/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts @@ -0,0 +1,310 @@ +import type { ChainId } from '@kadena/types'; +import type { TransferFieldsFragment } from '../../gql/graphql'; +import type { Transfer } from '../../sdk/interface'; +import { parsePactNumber } from '../../utils/pact.util'; +import { safeJsonParse } from '../../utils/string.util'; +import { isEmpty, notEmpty } from '../../utils/typeUtils'; + +export type GqlTransfer = TransferFieldsFragment & { + crossChainTransfer?: TransferFieldsFragment | null; +}; + +function parseClist(node: GqlTransfer) { + if (isEmpty(node.transaction)) return []; + const clist = node.transaction.cmd.signers.flatMap((x) => + x.clist + .map((item) => { + const args = safeJsonParse<(number | string | object)[]>(item.args); + if (args === null) return null; + return { name: item.name, args }; + }) + .filter(notEmpty), + ); + return clist; +} +type CList = ReturnType; + +function parseEvents(node: GqlTransfer) { + if ( + isEmpty(node.transaction) || + node.transaction.result.__typename === 'TransactionMempoolInfo' + ) { + return []; + } + return node.transaction.result.events.edges + .flatMap((x) => { + if (!x) return null; + const parameters = safeJsonParse<(number | string | object)[]>( + x.node.parameters, + ); + if (parameters === null) return null; + return { name: x.node.name, parameters }; + }) + .filter(notEmpty); +} +type Events = ReturnType; + +type GqlTransferParsed = GqlTransfer & { + events: Events; + clist: CList; + fungibleName: string; + crossChainTransfer?: + | (TransferFieldsFragment & { + events: Events; + clist: CList; + fungibleName: string; + }) + | null; +}; + +const parseTransfer = ( + node: GqlTransfer, + fungibleName?: string, +): GqlTransferParsed => { + return { + ...node, + events: parseEvents(node), + clist: parseClist(node), + fungibleName: fungibleName ?? node.moduleName, + crossChainTransfer: node.crossChainTransfer + ? parseTransfer(node.crossChainTransfer, fungibleName) + : null, + }; +}; + +const isTransactionFeeTransfer = (transfer: GqlTransfer) => + transfer.orderIndex === 0; + +const isSuccess = (transfer: GqlTransfer) => { + return ( + transfer.transaction?.result.__typename === 'TransactionResult' && + Boolean(transfer.transaction.result.goodResult) + ); +}; + +const matchSender = ( + transfer: GqlTransferParsed, + arg: number | string | object, +) => { + return transfer.senderAccount !== '' ? arg === transfer.senderAccount : true; +}; +const matchReceiver = ( + transfer: GqlTransferParsed, + arg: number | string | object, +) => { + return transfer.receiverAccount !== '' + ? arg === transfer.receiverAccount + : true; +}; +const matchAmount = ( + transfer: GqlTransferParsed, + arg: number | string | object, +) => { + return transfer.amount <= parsePactNumber(arg); +}; + +const getCrossChainTransferStart = (transfer: GqlTransferParsed) => { + const match = transfer.events.find( + (event) => + event.name === `TRANSFER_XCHAIN` && + matchSender(transfer, event.parameters[0]) && + matchReceiver(transfer, event.parameters[1]) && + matchAmount(transfer, event.parameters[2]), + ); + if (isEmpty(match)) return null; + return { + receiverAccount: (transfer.receiverAccount || + transfer.crossChainTransfer?.receiverAccount || + match.parameters[1]) as string, + senderAccount: (transfer.senderAccount || + transfer.crossChainTransfer?.senderAccount || + match.parameters[0]) as string, + targetChainId: String(match.parameters?.[3]) as ChainId, + }; +}; + +const getCrossChainTransferFinish = (transfer: GqlTransferParsed) => { + const match = transfer.events.find( + (event) => + event.name === 'TRANSFER_XCHAIN_RECD' && + matchSender(transfer, event.parameters[0]) && + matchReceiver(transfer, event.parameters[1]) && + matchAmount(transfer, event.parameters[2]), + ); + + if (isEmpty(match)) return null; + + return { + receiverAccount: (transfer.receiverAccount || + transfer.crossChainTransfer?.receiverAccount || + match.parameters?.[1]) as string, + senderAccount: (transfer.senderAccount || + transfer.crossChainTransfer?.senderAccount || + match.parameters?.[0]) as string, + targetChainId: String( + transfer.crossChainTransfer?.chainId || match.parameters?.[3], + ) as ChainId, + }; +}; + +const mapBaseTransfer = ( + gqlTransfer: GqlTransferParsed, + lastBlockHeight: number, +): Transfer => { + return { + amount: gqlTransfer.amount, + chainId: String(gqlTransfer.chainId) as ChainId, + requestKey: gqlTransfer.requestKey, + senderAccount: gqlTransfer.senderAccount, + receiverAccount: gqlTransfer.receiverAccount, + isCrossChainTransfer: false, + success: isSuccess(gqlTransfer), + token: gqlTransfer.fungibleName, + networkId: gqlTransfer.transaction?.cmd.networkId!, + block: { + creationTime: new Date(gqlTransfer.block.creationTime), + blockDepthEstimate: lastBlockHeight - 3 - gqlTransfer.block.height, + hash: gqlTransfer.block.hash, + height: gqlTransfer.block.height, + }, + }; +}; + +export const gqlTransferToTransfer = ( + rawGqlTransfer: GqlTransfer, + _accountName: string, + lastBlockHeight: number, + fungibleName?: string, +): Transfer | null => { + const gqlTransfer = parseTransfer(rawGqlTransfer, fungibleName); + const xChainStart = getCrossChainTransferStart(gqlTransfer); + const xChainFinish = getCrossChainTransferFinish(gqlTransfer); + + if (xChainStart) { + const result: Transfer = { + ...mapBaseTransfer(gqlTransfer, lastBlockHeight), + isCrossChainTransfer: true, + targetChainId: xChainStart.targetChainId, + receiverAccount: isTransactionFeeTransfer(gqlTransfer) + ? gqlTransfer.receiverAccount + : xChainStart.receiverAccount, + }; + if (gqlTransfer.crossChainTransfer) { + result.continuation = { + requestKey: gqlTransfer.crossChainTransfer.requestKey, + success: isSuccess(gqlTransfer.crossChainTransfer), + }; + } + return result; + } + + if (xChainFinish) { + // crossChainTransfer can't be null for finish events + if (!gqlTransfer.crossChainTransfer) return null; + return { + ...mapBaseTransfer(gqlTransfer.crossChainTransfer, lastBlockHeight), + isCrossChainTransfer: true, + targetChainId: String(gqlTransfer.chainId) as ChainId, + receiverAccount: xChainFinish.receiverAccount, + continuation: { + requestKey: gqlTransfer.requestKey, + success: isSuccess(gqlTransfer), + }, + }; + } + + return mapBaseTransfer(gqlTransfer, lastBlockHeight); +}; + +export function parseGqlTransfers( + nodes: GqlTransfer[], + lastBlockHeight: number, + accountName: string, + fungibleName?: string, +): Transfer[] { + const grouped = nodes.reduce( + (acc, node) => { + const key = node.requestKey; + if (!(key in acc)) acc[key] = []; + acc[key].push(node); + return acc; + }, + {} as Record, + ); + + const mapped = Object.values(grouped).flatMap((nodes) => { + const transactionFee = nodes.find((node) => isTransactionFeeTransfer(node)); + const transfers = nodes.filter((node) => !isTransactionFeeTransfer(node)); + + // console.log('nodes', nodes); + + // Failed transfers only have the transaction fee transfer + // For wallets, give the transfer with original amount and receiver + if (transfers.length === 0) { + const gqlTransfer = nodes[0]; + + if (isSuccess(gqlTransfer)) { + // eslint-disable-next-line no-console + console.log( + 'RequestKey found with one one Transfer, but it does not have failed status.', + ); + return []; + } + + // Not success, must be a gas payment: Reconstruct original transfer + const clist = parseClist(gqlTransfer); + const transferCap = clist.find((x) => x.name === 'coin.TRANSFER')?.args; + if (isEmpty(transferCap)) return []; + const transactionFeeTransfer = gqlTransferToTransfer( + gqlTransfer, + accountName, + lastBlockHeight, + fungibleName, + ); + if (!transactionFeeTransfer) return []; + const transfer: Transfer = { + ...transactionFeeTransfer, + receiverAccount: String(transferCap[1]), + // Could technically be different from the value used in payload.code + // It would be an improvement to parse code instead of using the cap, but that is very complex. + amount: parsePactNumber(transferCap[2]), + success: false, + transactionFeeTransfer: { + ...transactionFeeTransfer, + isBulkTransfer: false, + success: true, + }, + }; + return [transfer]; + } + + return transfers.map((gqlTransfer) => { + const base = gqlTransferToTransfer( + gqlTransfer, + accountName, + lastBlockHeight, + fungibleName, + ); + if (!base) return null; + const transactionFeeBase = transactionFee + ? gqlTransferToTransfer( + transactionFee, + accountName, + lastBlockHeight, + fungibleName, + ) + : null; + return { + ...base, + transactionFeeTransfer: transactionFeeBase + ? { + ...transactionFeeBase, + isBulkTransfer: transfers.length > 1, + } + : undefined, + } as Transfer; + }); + }); + + return mapped.filter(notEmpty); +} From 4b9198feed6eb734777120ffa36039f2e1e6dd1b Mon Sep 17 00:00:00 2001 From: Nillo Date: Wed, 4 Dec 2024 10:12:39 +0100 Subject: [PATCH 060/103] feat(wallet-sdk): added network call, and tests --- packages/libs/wallet-sdk/src/sdk/interface.ts | 18 ++++++++++++ packages/libs/wallet-sdk/src/sdk/walletSdk.ts | 29 +++++++++++++------ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/packages/libs/wallet-sdk/src/sdk/interface.ts b/packages/libs/wallet-sdk/src/sdk/interface.ts index fc43a7e0a5..5b863045bb 100644 --- a/packages/libs/wallet-sdk/src/sdk/interface.ts +++ b/packages/libs/wallet-sdk/src/sdk/interface.ts @@ -92,3 +92,21 @@ export interface ITransactionDescriptor { chainId: ChainId; networkId: string; } + +export interface INetworkInfo { + nodeApiVersion: string; + nodeBlockDelay: number; + nodeChains: string[]; + nodeGenesisHeights: [string, number][]; + nodeGraphHistory: [number, [number, [string, string[]]][]][]; + nodeHistoricalChains: [number, [number, [string, string[]]][]][]; + nodeLatestBehaviorHeight: number; + nodeNumberOfChains: number; + nodePackageVersion: string; + nodeServiceDate: string; + nodeVersion: string; +} + +export type NodeChainInfo = Pick; + +export type NodeNetworkInfo = Omit; diff --git a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts index 2addd9ec9f..1da3c5f46f 100644 --- a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts +++ b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts @@ -32,7 +32,10 @@ import type { IAccountDetails, IChain, ICrossChainTransfer, + INetworkInfo, ITransactionDescriptor, + NodeChainInfo, + NodeNetworkInfo, Transfer, } from './interface.js'; import { KadenaNames } from './kadenaNames.js'; @@ -202,7 +205,7 @@ export class WalletSDK { }); Promise.all(promises).catch((error) => { - console.log('error', error); + this.logger.error(error); }); } @@ -256,7 +259,7 @@ export class WalletSDK { networkId: tx.networkId, chainId: tx.chainId, }); - acc[host] = acc[host] || []; + acc[host] = acc[host] !== undefined ? acc[host] : []; acc[host].push(tx); return acc; }, @@ -335,15 +338,23 @@ export class WalletSDK { public async getChains(networkHost: string): Promise { const res = await fetch(`${networkHost}/info`); - const json: { - nodeChains: string[]; - nodeVersion: string; - } = await res.json(); - return json.nodeChains.map((c) => ({ id: c as ChainId })); + const json: NodeChainInfo = await res.json(); + + const chains = json.nodeChains ?? []; + return chains.map((c) => ({ id: c as ChainId })); } - public async getNetworkInfo(networkHost: string): Promise { - return null; + public async getNetworkInfo(networkHost: string): Promise { + const res = await fetch(`${networkHost}/info`); + const json: INetworkInfo = await res.json(); + + const { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + nodeChains = [], + ...networkInfo + }: NodeNetworkInfo & { nodeChains: string[] } = json; + + return networkInfo; } public async getGasLimitEstimate( From 60d00a0af44ec6a4f746abcd6e33b17471512306 Mon Sep 17 00:00:00 2001 From: Nillo Date: Wed, 4 Dec 2024 10:12:57 +0100 Subject: [PATCH 061/103] chore(wallet-sdk): added tests for network --- .../src/sdk/tests/getGasLimitEstimate.test.ts | 84 ++++++++ .../src/sdk/tests/getNetworkInfo.test.ts | 179 ++++++++++++++++++ 2 files changed, 263 insertions(+) create mode 100644 packages/libs/wallet-sdk/src/sdk/tests/getGasLimitEstimate.test.ts create mode 100644 packages/libs/wallet-sdk/src/sdk/tests/getNetworkInfo.test.ts diff --git a/packages/libs/wallet-sdk/src/sdk/tests/getGasLimitEstimate.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/getGasLimitEstimate.test.ts new file mode 100644 index 0000000000..111ec3614b --- /dev/null +++ b/packages/libs/wallet-sdk/src/sdk/tests/getGasLimitEstimate.test.ts @@ -0,0 +1,84 @@ +// import type { ICommand } from '@kadena/types'; +// import { http, HttpResponse } from 'msw'; +// import { setupServer } from 'msw/node'; +// import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'; +// import { walletSdk } from '../walletSdk.js'; + +// const server = setupServer(); + +// beforeAll(() => server.listen()); +// afterEach(() => server.resetHandlers()); +// afterAll(() => server.close()); + +// function setupServerResponse( +// url: string, +// responseData: { +// result: { gasLimit: number; status: 'success' }; +// } | null, +// responseType: 'json' | 'error' = 'json', +// ) { +// server.use( +// http.post(url, (req) => { +// if (responseType === 'json' && responseData) { +// return HttpResponse.json(responseData, { status: 200 }); +// } +// return HttpResponse.json( +// { result: { error: 'Execution failed', status: 'error' } }, +// { status: 400 }, +// ); +// }), +// ); +// } + +// describe('WalletSDK - getGasLimitEstimate', () => { +// const networkId = 'testnet04'; +// const chainId = '1'; +// const host = `https://api.testnet.chainweb.com/chainweb/0.0/${networkId}/chain/${chainId}/pact/api/v1/local`; +// const mockTransaction: ICommand = { +// cmd: JSON.stringify({ +// networkId, +// payload: { +// exec: { +// data: { someKey: 'someValue' }, +// code: '(+ 1 2)', +// }, +// }, +// meta: { +// chainId, +// gasLimit: 10000, +// gasPrice: 1e-8, +// ttl: 28800, +// creationTime: Math.floor(Date.now() / 1000), +// sender: 'sender', +// }, +// signers: [{ pubKey: 'publicKey' }], +// nonce: 'test-nonce', +// }), +// hash: 'mock-hash', +// sigs: [{ sig: 'mock-sig' }], +// }; + +// it('should return the gas limit estimate', async () => { +// const gasLimit = 12000; + +// setupServerResponse(host, { +// result: { gasLimit, status: 'success' }, +// }); + +// const result = await walletSdk.getGasLimitEstimate( +// mockTransaction, +// networkId, +// chainId, +// ); + +// expect(result).toBe(gasLimit); +// }); + +// it('should throw an error when the network request fails', async () => { +// setupServerResponse(host, null, 'error'); + +// await expect( +// walletSdk.getGasLimitEstimate(mockTransaction, networkId, chainId), +// ).rejects.toThrow('Execution failed'); +// }); +// }); diff --git a/packages/libs/wallet-sdk/src/sdk/tests/getNetworkInfo.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/getNetworkInfo.test.ts new file mode 100644 index 0000000000..1b8e0c3f87 --- /dev/null +++ b/packages/libs/wallet-sdk/src/sdk/tests/getNetworkInfo.test.ts @@ -0,0 +1,179 @@ +import { http, HttpResponse } from 'msw'; +import { setupServer } from 'msw/node'; +import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'; +import { walletSdk } from '../walletSdk.js'; + +const server = setupServer(); + +beforeAll(() => server.listen()); +afterEach(() => server.resetHandlers()); +afterAll(() => server.close()); + +function setupServerResponse( + url: string, + responseType: 'json' | 'networkError' | 'text', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + responseData?: any, +) { + server.use( + http.get(url, (req) => { + if (responseType === 'json') { + return HttpResponse.json(responseData, { status: 200 }); + } else if (responseType === 'text') { + const body = + typeof responseData === 'string' ? responseData : 'Invalid response'; + return HttpResponse.text(body, { status: 200 }); + } + return undefined; + }), + ); +} + +describe('WalletSDK - Info Functions', () => { + const networkHost = 'https://api.testnet.chainweb.com'; + + describe('getChains', () => { + it('should return a list of chains when nodeChains is present', async () => { + const mockResponse = { + nodeChains: ['0', '1', '2', '3'], + nodeVersion: '1.0', + }; + + setupServerResponse(`${networkHost}/info`, 'json', mockResponse); + + const result = await walletSdk.getChains(networkHost); + + expect(result).toEqual([ + { id: '0' }, + { id: '1' }, + { id: '2' }, + { id: '3' }, + ]); + }); + + it('should return an empty array when nodeChains is missing', async () => { + const mockResponse = { + nodeVersion: '1.0', + }; + + setupServerResponse(`${networkHost}/info`, 'json', mockResponse); + + const result = await walletSdk.getChains(networkHost); + + expect(result).toEqual([]); + }); + + it('should return an empty array when nodeChains is null', async () => { + const mockResponse = { + nodeChains: null, + nodeVersion: '1.0', + }; + + setupServerResponse(`${networkHost}/info`, 'json', mockResponse); + + const result = await walletSdk.getChains(networkHost); + + expect(result).toEqual([]); + }); + }); + + describe('getNetworkInfo', () => { + it('should return network info excluding nodeChains when nodeChains is present', async () => { + const mockResponse = { + nodeApiVersion: '1.0', + nodeBlockDelay: 10, + nodeChains: ['0', '1', '2', '3'], + nodeGenesisHeights: [['0', 123456]], + nodeGraphHistory: [], + nodeHistoricalChains: [], + nodeLatestBehaviorHeight: 100, + nodeNumberOfChains: 4, + nodePackageVersion: '2.0', + nodeServiceDate: '2025-01-01T00:00:00Z', + nodeVersion: '1.0', + }; + + setupServerResponse(`${networkHost}/info`, 'json', mockResponse); + + const result = await walletSdk.getNetworkInfo(networkHost); + + expect(result).toEqual({ + nodeApiVersion: '1.0', + nodeBlockDelay: 10, + nodeGenesisHeights: [['0', 123456]], + nodeGraphHistory: [], + nodeHistoricalChains: [], + nodeLatestBehaviorHeight: 100, + nodeNumberOfChains: 4, + nodePackageVersion: '2.0', + nodeServiceDate: '2025-01-01T00:00:00Z', + nodeVersion: '1.0', + }); + }); + + it('should return network info excluding nodeChains when nodeChains is missing', async () => { + const mockResponse = { + nodeApiVersion: '1.0', + nodeBlockDelay: 10, + nodeGenesisHeights: [['0', 123456]], + nodeGraphHistory: [], + nodeHistoricalChains: [], + nodeLatestBehaviorHeight: 100, + nodeNumberOfChains: 4, + nodePackageVersion: '2.0', + nodeServiceDate: '2025-01-01T00:00:00Z', + nodeVersion: '1.0', + }; + + setupServerResponse(`${networkHost}/info`, 'json', mockResponse); + + const result = await walletSdk.getNetworkInfo(networkHost); + + expect(result).toEqual({ + nodeApiVersion: '1.0', + nodeBlockDelay: 10, + nodeGenesisHeights: [['0', 123456]], + nodeGraphHistory: [], + nodeHistoricalChains: [], + nodeLatestBehaviorHeight: 100, + nodeNumberOfChains: 4, + nodePackageVersion: '2.0', + nodeServiceDate: '2025-01-01T00:00:00Z', + nodeVersion: '1.0', + }); + }); + + it('should return network info excluding nodeChains when nodeChains is null', async () => { + const mockResponse = { + nodeApiVersion: '1.0', + nodeBlockDelay: 10, + nodeChains: null, + nodeGenesisHeights: [['0', 123456]], + nodeGraphHistory: [], + nodeHistoricalChains: [], + nodeLatestBehaviorHeight: 100, + nodeNumberOfChains: 4, + nodePackageVersion: '2.0', + nodeServiceDate: '2025-01-01T00:00:00Z', + nodeVersion: '1.0', + }; + + setupServerResponse(`${networkHost}/info`, 'json', mockResponse); + + const result = await walletSdk.getNetworkInfo(networkHost); + + expect(result).toEqual({ + nodeApiVersion: '1.0', + nodeBlockDelay: 10, + nodeGenesisHeights: [['0', 123456]], + nodeGraphHistory: [], + nodeHistoricalChains: [], + nodeLatestBehaviorHeight: 100, + nodeNumberOfChains: 4, + nodePackageVersion: '2.0', + nodeServiceDate: '2025-01-01T00:00:00Z', + nodeVersion: '1.0', + }); + }); + }); +}); From 976fb5a2737408c8ac8ce7126a23d0e812b8f165 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Wed, 4 Dec 2024 10:44:08 +0100 Subject: [PATCH 062/103] feat(wallet-sdk): query getTrasnfer per chain --- packages/libs/wallet-sdk/src/gql/gql.ts | 18 ++- packages/libs/wallet-sdk/src/gql/graphql.ts | 19 ++- packages/libs/wallet-sdk/src/sdk/walletSdk.ts | 46 +++++--- .../src/services/graphql/getChainTransfers.ts | 47 ++++++++ .../src/services/graphql/getTransfers.ts | 4 +- .../src/services/graphql/transfer.query.ts | 109 +++++++----------- .../src/services/graphql/transfer.util.ts | 18 +++ 7 files changed, 174 insertions(+), 87 deletions(-) create mode 100644 packages/libs/wallet-sdk/src/services/graphql/getChainTransfers.ts diff --git a/packages/libs/wallet-sdk/src/gql/gql.ts b/packages/libs/wallet-sdk/src/gql/gql.ts index ffc2c7808b..d4b60b8c39 100644 --- a/packages/libs/wallet-sdk/src/gql/gql.ts +++ b/packages/libs/wallet-sdk/src/gql/gql.ts @@ -14,8 +14,10 @@ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document- * Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size */ const documents = { - "\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n": types.AccountTransfersDocument, - "\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n": types.AccountTransferRequestKeyDocument, + "\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n": types.TransferFieldsFragmentDoc, + "\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n": types.AccountTransfersDocument, + "\n query accountChainTransfers(\n $accountName: String!\n $chainId: String\n $fungibleName: String\n $first: Int\n ) {\n lastBlockHeight\n transfers(\n accountName: $accountName\n chainId: $chainId\n fungibleName: $fungibleName\n first: $first\n ) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n": types.AccountChainTransfersDocument, + "\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n": types.AccountTransferRequestKeyDocument, }; /** @@ -35,11 +37,19 @@ export function graphql(source: string): unknown; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n"]; +export function graphql(source: "\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n"): (typeof documents)["\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n"]; +export function graphql(source: "\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "\n query accountChainTransfers(\n $accountName: String!\n $chainId: String\n $fungibleName: String\n $first: Int\n ) {\n lastBlockHeight\n transfers(\n accountName: $accountName\n chainId: $chainId\n fungibleName: $fungibleName\n first: $first\n ) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query accountChainTransfers(\n $accountName: String!\n $chainId: String\n $fungibleName: String\n $first: Int\n ) {\n lastBlockHeight\n transfers(\n accountName: $accountName\n chainId: $chainId\n fungibleName: $fungibleName\n first: $first\n ) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n"): (typeof documents)["\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n"]; export function graphql(source: string) { return (documents as any)[source] ?? {}; diff --git a/packages/libs/wallet-sdk/src/gql/graphql.ts b/packages/libs/wallet-sdk/src/gql/graphql.ts index 0f9b726b79..73bcb70015 100644 --- a/packages/libs/wallet-sdk/src/gql/graphql.ts +++ b/packages/libs/wallet-sdk/src/gql/graphql.ts @@ -35,6 +35,8 @@ export type PactQueryData = { value: Scalars['String']['input']; }; +export type TransferFieldsFragment = { __typename?: 'Transfer', amount: any, chainId: any, orderIndex: any, receiverAccount: string, requestKey: string, senderAccount: string, moduleName: string, block: { __typename?: 'Block', hash: string, height: any, creationTime: any }, transaction?: { __typename?: 'Transaction', cmd: { __typename?: 'TransactionCommand', networkId: string, payload: { __typename: 'ContinuationPayload', step?: number | null, pactId?: string | null } | { __typename: 'ExecutionPayload', code?: string | null, data: string }, signers: Array<{ __typename?: 'Signer', clist: Array<{ __typename?: 'TransactionCapability', name: string, args: string }> }> }, result: { __typename: 'TransactionMempoolInfo' } | { __typename: 'TransactionResult', goodResult?: string | null, badResult?: string | null, events: { __typename?: 'TransactionResultEventsConnection', edges: Array<{ __typename?: 'TransactionResultEventsConnectionEdge', node: { __typename?: 'Event', name: string, parameters?: string | null } } | null> } } } | null } & { ' $fragmentName'?: 'TransferFieldsFragment' }; + export type AccountTransfersQueryVariables = Exact<{ accountName: Scalars['String']['input']; fungibleName?: InputMaybe; @@ -49,7 +51,21 @@ export type AccountTransfersQuery = { __typename?: 'Query', lastBlockHeight?: an & { ' $fragmentRefs'?: { 'TransferFieldsFragment': TransferFieldsFragment } } ) }> } } | null }; -export type TransferFieldsFragment = { __typename?: 'Transfer', amount: any, chainId: any, orderIndex: any, receiverAccount: string, requestKey: string, senderAccount: string, moduleName: string, block: { __typename?: 'Block', hash: string, height: any, creationTime: any }, transaction?: { __typename?: 'Transaction', cmd: { __typename?: 'TransactionCommand', networkId: string, payload: { __typename: 'ContinuationPayload', step?: number | null, pactId?: string | null } | { __typename: 'ExecutionPayload', code?: string | null, data: string }, signers: Array<{ __typename?: 'Signer', clist: Array<{ __typename?: 'TransactionCapability', name: string, args: string }> }> }, result: { __typename: 'TransactionMempoolInfo' } | { __typename: 'TransactionResult', goodResult?: string | null, badResult?: string | null, events: { __typename?: 'TransactionResultEventsConnection', edges: Array<{ __typename?: 'TransactionResultEventsConnectionEdge', node: { __typename?: 'Event', name: string, parameters?: string | null } } | null> } } } | null } & { ' $fragmentName'?: 'TransferFieldsFragment' }; +export type AccountChainTransfersQueryVariables = Exact<{ + accountName: Scalars['String']['input']; + chainId?: InputMaybe; + fungibleName?: InputMaybe; + first?: InputMaybe; +}>; + + +export type AccountChainTransfersQuery = { __typename?: 'Query', lastBlockHeight?: any | null, transfers: { __typename?: 'QueryTransfersConnection', edges: Array<{ __typename?: 'QueryTransfersConnectionEdge', node: ( + { __typename?: 'Transfer', crossChainTransfer?: ( + { __typename?: 'Transfer' } + & { ' $fragmentRefs'?: { 'TransferFieldsFragment': TransferFieldsFragment } } + ) | null } + & { ' $fragmentRefs'?: { 'TransferFieldsFragment': TransferFieldsFragment } } + ) }> } }; export type AccountTransferRequestKeyQueryVariables = Exact<{ requestKey: Scalars['String']['input']; @@ -64,4 +80,5 @@ export type AccountTransferRequestKeyQuery = { __typename?: 'Query', lastBlockHe export const TransferFieldsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; export const AccountTransfersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountTransfers"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"fungibleAccount"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}},{"kind":"Argument","name":{"kind":"Name","value":"fungibleName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"100"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}},{"kind":"Field","name":{"kind":"Name","value":"crossChainTransfer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; +export const AccountChainTransfersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountChainTransfers"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"chainId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}},{"kind":"Argument","name":{"kind":"Name","value":"chainId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"chainId"}}},{"kind":"Argument","name":{"kind":"Name","value":"fungibleName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}}},{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}},{"kind":"Field","name":{"kind":"Name","value":"crossChainTransfer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; export const AccountTransferRequestKeyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountTransferRequestKey"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"requestKey"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"requestKey"},"value":{"kind":"Variable","name":{"kind":"Name","value":"requestKey"}}},{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts index 1da3c5f46f..b50ccfcf4a 100644 --- a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts +++ b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts @@ -14,8 +14,10 @@ import type { import * as accountService from '../services/accountService.js'; import { pollRequestKeys } from '../services/chainweb/chainweb.js'; +import { getChainTransfers } from '../services/graphql/getChainTransfers.js'; import { getTransfers } from '../services/graphql/getTransfers.js'; import { pollGraphqlTransfers } from '../services/graphql/pollTransfers.js'; +import { isSameTransfer } from '../services/graphql/transfer.util.js'; import { poll } from '../utils/retry.js'; import { isEmpty, notEmpty } from '../utils/typeUtils.js'; import type { ICreateCrossChainFinishInput } from './crossChainFinishCreate.js'; @@ -89,6 +91,7 @@ export class WalletSDK { if (!result) { this.logger.error( 'Failed to generate graphql url using graphqlHostGenerator method', + { args }, ); throw new Error( 'Failed to generate chainweb url using graphqlHostGenerator method', @@ -162,16 +165,18 @@ export class WalletSDK { accountName: string, networkId: string, fungible?: string, - chainsIds?: ChainId[], + chainId?: ChainId, ): Promise { const url = this.getGraphqlUrl({ networkId }); - const transfers = await getTransfers(url, accountName, fungible); - return transfers; + if (chainId) { + return getChainTransfers(url, accountName, chainId, fungible); + } + return getTransfers(url, accountName, fungible); } public subscribeOnCrossChainComplete( accountName: string, - transfers: ITransactionDescriptor[], + transfers: ICrossChainTransfer[], callback: (transfer: ICrossChainTransfer) => void, options?: { signal?: AbortSignal }, ): void { @@ -188,13 +193,18 @@ export class WalletSDK { signal, }); const results = Object.values(result).flat(); - results.forEach((row) => { - if (row.isCrossChainTransfer && row.continuation !== undefined) { - callback(row); - } else { - throw new Error('Cross-chain transfer not complete'); - } - }); + const match = results.find((resultTransfer) => + isSameTransfer(transfer, resultTransfer), + ); + if ( + match && + match.isCrossChainTransfer && + match.continuation !== undefined + ) { + callback(match); + } else { + throw new Error('Cross-chain transfer not complete'); + } }, { delayMs: 30000, @@ -205,7 +215,10 @@ export class WalletSDK { }); Promise.all(promises).catch((error) => { - this.logger.error(error); + this.logger.error( + `Error in subscribeOnCrossChainComplete: ${error.message}`, + { error }, + ); }); } @@ -308,7 +321,10 @@ export class WalletSDK { }); Promise.all(promises).catch((error) => { - this.logger.error(error); + this.logger.error( + `Error in subscribePendingTransactions: ${error.message}`, + { error }, + ); }); } @@ -331,7 +347,9 @@ export class WalletSDK { return accountDetailsList; } catch (error) { - this.logger.error(`Error in fetching account details: ${error.message}`); + this.logger.error(`Error in fetching account details: ${error.message}`, { + error, + }); throw new Error(`Failed to get account details for ${accountName}`); } } diff --git a/packages/libs/wallet-sdk/src/services/graphql/getChainTransfers.ts b/packages/libs/wallet-sdk/src/services/graphql/getChainTransfers.ts new file mode 100644 index 0000000000..ee89076560 --- /dev/null +++ b/packages/libs/wallet-sdk/src/services/graphql/getChainTransfers.ts @@ -0,0 +1,47 @@ +import { createClient, fetchExchange } from '@urql/core'; +import type { Transfer } from '../../sdk/interface.js'; +import { ACCOUNT_CHAIN_TRANSFER_QUERY } from './transfer.query.js'; +import type { GqlTransfer } from './transfer.util.js'; +import { parseGqlTransfers } from './transfer.util.js'; + +async function fetchChainTransfers( + graphqlUrl: string, + accountName: string, + chainId: string, + fungibleName?: string, +) { + const client = createClient({ url: graphqlUrl, exchanges: [fetchExchange] }); + const result = await client + .query(ACCOUNT_CHAIN_TRANSFER_QUERY, { accountName, fungibleName, chainId }) + .toPromise(); + + const nodes = result.data?.transfers.edges.map( + (edge) => edge.node as GqlTransfer, + ); + + return { + transfers: nodes ?? [], + lastBlockHeight: (result.data?.lastBlockHeight ?? null) as number | null, + }; +} + +// Currently queries all chains +export async function getChainTransfers( + graphqlUrl: string, + accountName: string, + chainId: string, + fungibleName?: string, +): Promise { + const { transfers: nodes, lastBlockHeight } = await fetchChainTransfers( + graphqlUrl, + accountName, + chainId, + fungibleName, + ); + return parseGqlTransfers( + nodes, + lastBlockHeight ?? 0, + accountName, + fungibleName, + ); +} diff --git a/packages/libs/wallet-sdk/src/services/graphql/getTransfers.ts b/packages/libs/wallet-sdk/src/services/graphql/getTransfers.ts index 7e69bce0d7..bb65f0ad72 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/getTransfers.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/getTransfers.ts @@ -1,6 +1,6 @@ import { createClient, fetchExchange } from '@urql/core'; import type { Transfer } from '../../sdk/interface.js'; -import { TRANSFER_QUERY } from './transfer.query.js'; +import { ACCOUNT_TRANSFER_QUERY } from './transfer.query.js'; import type { GqlTransfer } from './transfer.util.js'; import { parseGqlTransfers } from './transfer.util.js'; @@ -11,7 +11,7 @@ async function fetchTransfers( ) { const client = createClient({ url: graphqlUrl, exchanges: [fetchExchange] }); const result = await client - .query(TRANSFER_QUERY, { accountName, fungibleName }) + .query(ACCOUNT_TRANSFER_QUERY, { accountName, fungibleName }) .toPromise(); const nodes = result.data?.fungibleAccount?.transfers.edges.map( diff --git a/packages/libs/wallet-sdk/src/services/graphql/transfer.query.ts b/packages/libs/wallet-sdk/src/services/graphql/transfer.query.ts index 33119c7a91..b81a44d1d8 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/transfer.query.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/transfer.query.ts @@ -1,21 +1,6 @@ import { graphql } from '../../gql/gql.js'; -export const TRANSFER_QUERY = graphql(` - query accountTransfers($accountName: String!, $fungibleName: String) { - lastBlockHeight - fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) { - transfers(first: 100) { - edges { - node { - ...TransferFields - crossChainTransfer { - ...TransferFields - } - } - } - } - } - } +export const TRANSFER_FIELDS_FRAGMENT = graphql(` fragment TransferFields on Transfer { amount chainId @@ -69,65 +54,57 @@ export const TRANSFER_QUERY = graphql(` } `); -export const TRANSFER_REQUESTKEY_QUERY = graphql(` - query accountTransferRequestKey($requestKey: String!, $accountName: String) { +export const ACCOUNT_TRANSFER_QUERY = graphql(` + query accountTransfers($accountName: String!, $fungibleName: String) { lastBlockHeight - transfers(requestKey: $requestKey, accountName: $accountName) { - edges { - node { - ...TransferFields + fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) { + transfers(first: 100) { + edges { + node { + ...TransferFields + crossChainTransfer { + ...TransferFields + } + } } } } } +`); - fragment TransferFields on Transfer { - amount - chainId - orderIndex - receiverAccount - requestKey - senderAccount - moduleName - block { - hash - height - creationTime - } - transaction { - cmd { - networkId - payload { - __typename - ... on ExecutionPayload { - code - data - } - ... on ContinuationPayload { - step - pactId - } - } - signers { - clist { - name - args +export const ACCOUNT_CHAIN_TRANSFER_QUERY = graphql(` + query accountChainTransfers( + $accountName: String! + $chainId: String + $fungibleName: String + $first: Int + ) { + lastBlockHeight + transfers( + accountName: $accountName + chainId: $chainId + fungibleName: $fungibleName + first: $first + ) { + edges { + node { + ...TransferFields + crossChainTransfer { + ...TransferFields } } } - result { - __typename - ... on TransactionResult { - goodResult - badResult - events { - edges { - node { - name - parameters - } - } - } + } + } +`); + +export const TRANSFER_REQUESTKEY_QUERY = graphql(` + query accountTransferRequestKey($requestKey: String!, $accountName: String) { + lastBlockHeight + transfers(requestKey: $requestKey, accountName: $accountName) { + edges { + node { + ...TransferFields } } } diff --git a/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts b/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts index b22a2344c8..8b87ee32fa 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts @@ -308,3 +308,21 @@ export function parseGqlTransfers( return mapped.filter(notEmpty); } + +export function isSameTransfer(transferA: Transfer, transferB: Transfer) { + const isSameBaseTransfer = + transferA.requestKey === transferB.requestKey && + transferA.chainId === transferB.chainId && + transferA.senderAccount === transferB.senderAccount && + transferA.receiverAccount === transferB.receiverAccount && + transferA.amount === transferB.amount && + transferA.isCrossChainTransfer === transferB.isCrossChainTransfer; + + if (transferA.isCrossChainTransfer && transferB.isCrossChainTransfer) { + return ( + isSameBaseTransfer && transferA.targetChainId === transferB.targetChainId + ); + } + + return isSameBaseTransfer; +} From d01565376efd14e8f020219f13ae918f0f22505b Mon Sep 17 00:00:00 2001 From: Nillo Date: Wed, 4 Dec 2024 11:29:26 +0100 Subject: [PATCH 063/103] chore(wallet-sdk): added tests for accountdetail / gastlimitestimat / hosts --- packages/libs/wallet-sdk/src/sdk/host.ts | 1 + .../src/sdk/tests/getAccountDetails.test.ts | 237 ++++++++++++++++++ .../src/sdk/tests/getGasLimitEstimate.test.ts | 159 ++++++------ .../wallet-sdk/src/sdk/tests/hosts.test.ts | 110 ++++++++ 4 files changed, 433 insertions(+), 74 deletions(-) create mode 100644 packages/libs/wallet-sdk/src/sdk/tests/getAccountDetails.test.ts create mode 100644 packages/libs/wallet-sdk/src/sdk/tests/hosts.test.ts diff --git a/packages/libs/wallet-sdk/src/sdk/host.ts b/packages/libs/wallet-sdk/src/sdk/host.ts index be2d103d95..303fd38dc0 100644 --- a/packages/libs/wallet-sdk/src/sdk/host.ts +++ b/packages/libs/wallet-sdk/src/sdk/host.ts @@ -25,6 +25,7 @@ const graphqlHostMap: Record = { export const defaultGraphqlHostGenerator: GraphqlHostGenerator = (options) => { if (graphqlHostMap[options.networkId] === undefined) { + // eslint-disable-next-line no-console console.warn( `[defaultGraphqlHostGenerator] Network ${options.networkId} not supported`, ); diff --git a/packages/libs/wallet-sdk/src/sdk/tests/getAccountDetails.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/getAccountDetails.test.ts new file mode 100644 index 0000000000..8d24d8a494 --- /dev/null +++ b/packages/libs/wallet-sdk/src/sdk/tests/getAccountDetails.test.ts @@ -0,0 +1,237 @@ +import type { ChainId } from '@kadena/types'; +import { http, HttpResponse } from 'msw'; +import { setupServer } from 'msw/node'; +import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'; +import { walletSdk } from '../walletSdk.js'; + +const server = setupServer(); + +beforeAll(() => server.listen()); +afterEach(() => server.resetHandlers()); +afterAll(() => server.close()); + +function setupServerResponse( + url: string, + responseType: 'json' | 'networkError' | 'text', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + responseData?: any, +) { + server.use( + http.post(url, (req) => { + if (responseType === 'json') { + return HttpResponse.json(responseData, { status: 200 }); + } else if (responseType === 'text') { + const body = + typeof responseData === 'string' ? responseData : 'Invalid response'; + return HttpResponse.text(body, { status: 200 }); + } else if (responseType === 'networkError') { + throw new Error('Network Error'); + } + return undefined; + }), + ); +} + +/** + * Helper function to construct the local URL for the Pact API. + */ +function getLocalUrl(networkId: string, chainId: string): string { + const host = walletSdk.getChainwebUrl({ networkId, chainId }); + + return `${host}/api/v1/local`; +} + +describe('WalletSDK - getAccountDetails', () => { + const accountName = 'test-account'; + const networkId = 'testnet04'; + const fungible = 'coin'; + const chainIds: ChainId[] = ['0', '1']; + + it('should return account details for multiple chains', async () => { + chainIds.forEach((chainId) => { + const url = getLocalUrl(networkId, chainId); + + const responseData = { + gas: 0, + result: { + status: 'success', + data: { + account: accountName, + balance: 1000, + guard: { + pred: 'keys-all', + keys: ['key1', 'key2'], + }, + }, + }, + reqKey: 'some-request-key', + logs: 'some-logs', + metaData: null, + }; + + setupServerResponse(url, 'json', responseData); + }); + + const result = await walletSdk.getAccountDetails( + accountName, + networkId, + fungible, + chainIds, + ); + + expect(result).toEqual([ + { + chainId: '0', + accountDetails: { + account: accountName, + balance: 1000, + guard: { + pred: 'keys-all', + keys: ['key1', 'key2'], + }, + }, + }, + { + chainId: '1', + accountDetails: { + account: accountName, + balance: 1000, + guard: { + pred: 'keys-all', + keys: ['key1', 'key2'], + }, + }, + }, + ]); + }); + + it('should return null accountDetails for chains where account does not exist', async () => { + chainIds.forEach((chainId) => { + const url = getLocalUrl(networkId, chainId); + + const responseData = { + gas: 0, + result: { + status: 'failure', + error: { + callStack: [], + type: 'TxFailure', + message: `with-read: row not found: ${accountName}`, + info: '', + }, + }, + reqKey: 'some-request-key', + logs: 'some-logs', + metaData: null, + }; + + setupServerResponse(url, 'json', responseData); + }); + + const result = await walletSdk.getAccountDetails( + accountName, + networkId, + fungible, + chainIds, + ); + + expect(result).toEqual([ + { + chainId: '0', + accountDetails: null, + }, + { + chainId: '1', + accountDetails: null, + }, + ]); + }); + + it('should handle network errors gracefully', async () => { + chainIds.forEach((chainId) => { + const url = getLocalUrl(networkId, chainId); + + setupServerResponse(url, 'networkError'); + }); + + const result = await walletSdk.getAccountDetails( + accountName, + networkId, + fungible, + chainIds, + ); + + expect(result).toEqual([]); + }); + + it('should handle partial failures', async () => { + // First chain returns success + const urlSuccess = getLocalUrl(networkId, '0'); + + const responseDataSuccess = { + gas: 0, + result: { + status: 'success', + data: { + account: accountName, + balance: 1000, + guard: { + pred: 'keys-all', + keys: ['key1', 'key2'], + }, + }, + }, + reqKey: 'some-request-key', + logs: 'some-logs', + metaData: null, + }; + + setupServerResponse(urlSuccess, 'json', responseDataSuccess); + + // second chain returns error + const urlFail = getLocalUrl(networkId, '1'); + + const responseDataFailure = { + gas: 0, + result: { + status: 'failure', + error: { + callStack: [], + type: 'TxFailure', + message: `with-read: row not found: ${accountName}`, + info: '', + }, + }, + reqKey: 'some-request-key', + logs: 'some-logs', + metaData: null, + }; + + setupServerResponse(urlFail, 'json', responseDataFailure); + + const result = await walletSdk.getAccountDetails( + accountName, + networkId, + fungible, + chainIds, + ); + + expect(result).toEqual([ + { + chainId: '0', + accountDetails: { + account: accountName, + balance: 1000, + guard: { + pred: 'keys-all', + keys: ['key1', 'key2'], + }, + }, + }, + { + chainId: '1', + accountDetails: null, + }, + ]); + }); +}); diff --git a/packages/libs/wallet-sdk/src/sdk/tests/getGasLimitEstimate.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/getGasLimitEstimate.test.ts index 111ec3614b..b804939d32 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/getGasLimitEstimate.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/getGasLimitEstimate.test.ts @@ -1,84 +1,95 @@ -// import type { ICommand } from '@kadena/types'; -// import { http, HttpResponse } from 'msw'; -// import { setupServer } from 'msw/node'; -// import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'; -// import { walletSdk } from '../walletSdk.js'; +import type { ICommand } from '@kadena/types'; +import { http, HttpResponse } from 'msw'; +import { setupServer } from 'msw/node'; +import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'; +import { walletSdk } from '../walletSdk.js'; -// const server = setupServer(); +const server = setupServer(); -// beforeAll(() => server.listen()); -// afterEach(() => server.resetHandlers()); -// afterAll(() => server.close()); +beforeAll(() => server.listen()); +afterEach(() => server.resetHandlers()); +afterAll(() => server.close()); -// function setupServerResponse( -// url: string, -// responseData: { -// result: { gasLimit: number; status: 'success' }; -// } | null, -// responseType: 'json' | 'error' = 'json', -// ) { -// server.use( -// http.post(url, (req) => { -// if (responseType === 'json' && responseData) { -// return HttpResponse.json(responseData, { status: 200 }); -// } -// return HttpResponse.json( -// { result: { error: 'Execution failed', status: 'error' } }, -// { status: 400 }, -// ); -// }), -// ); -// } +function setupServerResponse( + url: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + responseData: any, + responseType: 'json' | 'error' = 'json', +) { + server.use( + http.post(url, (req) => { + if (responseType === 'json' && responseData !== undefined) { + return HttpResponse.json(responseData, { status: 200 }); + } + return HttpResponse.json( + { result: { error: 'Execution failed', status: 'error' } }, + { status: 400 }, + ); + }), + ); +} -// describe('WalletSDK - getGasLimitEstimate', () => { -// const networkId = 'testnet04'; -// const chainId = '1'; -// const host = `https://api.testnet.chainweb.com/chainweb/0.0/${networkId}/chain/${chainId}/pact/api/v1/local`; -// const mockTransaction: ICommand = { -// cmd: JSON.stringify({ -// networkId, -// payload: { -// exec: { -// data: { someKey: 'someValue' }, -// code: '(+ 1 2)', -// }, -// }, -// meta: { -// chainId, -// gasLimit: 10000, -// gasPrice: 1e-8, -// ttl: 28800, -// creationTime: Math.floor(Date.now() / 1000), -// sender: 'sender', -// }, -// signers: [{ pubKey: 'publicKey' }], -// nonce: 'test-nonce', -// }), -// hash: 'mock-hash', -// sigs: [{ sig: 'mock-sig' }], -// }; +/** + * Helper function to construct the local URL for the Pact API. + */ +function getLocalUrl(networkId: string, chainId: string): string { + const host = walletSdk.getChainwebUrl({ networkId, chainId }); -// it('should return the gas limit estimate', async () => { -// const gasLimit = 12000; + return `${host}/api/v1/local`; +} -// setupServerResponse(host, { -// result: { gasLimit, status: 'success' }, -// }); +describe('WalletSDK - getGasLimitEstimate', () => { + const networkId = 'testnet04'; + const chainId = '1'; -// const result = await walletSdk.getGasLimitEstimate( -// mockTransaction, -// networkId, -// chainId, -// ); + const url = getLocalUrl(networkId, chainId); -// expect(result).toBe(gasLimit); -// }); + const mockTransaction: ICommand = { + cmd: JSON.stringify({ + networkId, + payload: { + exec: { + data: { someKey: 'someValue' }, + code: '(+ 1 2)', + }, + }, + meta: { + chainId, + gasLimit: 10000, + gasPrice: 1e-8, + ttl: 28800, + creationTime: Math.floor(Date.now() / 1000), + sender: 'sender', + }, + signers: [{ pubKey: 'publicKey' }], + nonce: 'test-nonce', + }), + hash: 'mock-hash', + sigs: [{ sig: 'mock-sig' }], + }; -// it('should throw an error when the network request fails', async () => { -// setupServerResponse(host, null, 'error'); + it('should return the gas limit estimate', async () => { + const gasLimit = 12000; -// await expect( -// walletSdk.getGasLimitEstimate(mockTransaction, networkId, chainId), -// ).rejects.toThrow('Execution failed'); -// }); -// }); + setupServerResponse(url, { + gas: gasLimit, + result: { status: 'success', data: null }, + }); + + const result = await walletSdk.getGasLimitEstimate( + mockTransaction, + networkId, + chainId, + ); + + expect(result).toBe(gasLimit); + }); + + it('should throw an error when the network request fails', async () => { + setupServerResponse(url, null, 'error'); + + await expect( + walletSdk.getGasLimitEstimate(mockTransaction, networkId, chainId), + ).rejects.toThrow('Execution failed'); + }); +}); diff --git a/packages/libs/wallet-sdk/src/sdk/tests/hosts.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/hosts.test.ts new file mode 100644 index 0000000000..ac4a9a2ebd --- /dev/null +++ b/packages/libs/wallet-sdk/src/sdk/tests/hosts.test.ts @@ -0,0 +1,110 @@ +import type { MockInstance } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { + defaultChainwebHostGenerator, + defaultGraphqlHostGenerator, +} from '../host.js'; + +describe('Host Generators', () => { + describe('defaultChainwebHostGenerator', () => { + it('should generate the correct Chainweb URL for a supported networkId and chainId', () => { + const networkId = 'mainnet01'; + const chainId = '2'; + const expectedUrl = + 'https://api.chainweb.com/chainweb/0.0/mainnet01/chain/2/pact'; + + const result = defaultChainwebHostGenerator({ networkId, chainId }); + + expect(result).toBe(expectedUrl); + }); + + it('should generate the correct Chainweb URL for testnet04 and chainId 1', () => { + const networkId = 'testnet04'; + const chainId = '1'; + const expectedUrl = + 'https://api.testnet.chainweb.com/chainweb/0.0/testnet04/chain/1/pact'; + + const result = defaultChainwebHostGenerator({ networkId, chainId }); + + expect(result).toBe(expectedUrl); + }); + + it('should generate the correct Chainweb URL for testnet05 and chainId 3', () => { + const networkId = 'testnet05'; + const chainId = '3'; + const expectedUrl = + 'https://api.testnet.chainweb.com/chainweb/0.0/testnet05/chain/3/pact'; + + const result = defaultChainwebHostGenerator({ networkId, chainId }); + + expect(result).toBe(expectedUrl); + }); + + it('should generate a URL with "undefined" for unsupported networkId', () => { + const networkId = 'unknownNetwork'; + const chainId = '1'; + const expectedUrl = 'undefined/chainweb/0.0/unknownNetwork/chain/1/pact'; + + const result = defaultChainwebHostGenerator({ networkId, chainId }); + + expect(result).toBe(expectedUrl); + }); + }); + + describe('defaultGraphqlHostGenerator', () => { + let consoleWarnSpy: MockInstance< + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [message?: any, ...optionalParams: any[]], + void + >; + + beforeEach(() => { + consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); + }); + + afterEach(() => { + consoleWarnSpy.mockRestore(); + }); + + it('should generate the correct GraphQL URL for a supported networkId', () => { + const networkId = 'mainnet01'; + const expectedUrl = 'https://graph.kadena.network/graphql'; + + const result = defaultGraphqlHostGenerator({ networkId }); + + expect(result).toBe(expectedUrl); + expect(consoleWarnSpy).not.toHaveBeenCalled(); + }); + + it('should generate the correct GraphQL URL for testnet04', () => { + const networkId = 'testnet04'; + const expectedUrl = 'https://graph.testnet.kadena.network/graphql'; + + const result = defaultGraphqlHostGenerator({ networkId }); + + expect(result).toBe(expectedUrl); + expect(consoleWarnSpy).not.toHaveBeenCalled(); + }); + + it('should generate the correct GraphQL URL for testnet05', () => { + const networkId = 'testnet05'; + const expectedUrl = 'https://graph.testnet.kadena.network/graphql'; + + const result = defaultGraphqlHostGenerator({ networkId }); + + expect(result).toBe(expectedUrl); + expect(consoleWarnSpy).not.toHaveBeenCalled(); + }); + + it('should return undefined and log a warning for an unsupported networkId', () => { + const networkId = 'unknownNetwork'; + const expectedUrl = undefined; + const expectedWarning = `[defaultGraphqlHostGenerator] Network ${networkId} not supported`; + + const result = defaultGraphqlHostGenerator({ networkId }); + + expect(result).toBe(expectedUrl); + expect(consoleWarnSpy).toHaveBeenCalledWith(expectedWarning); + }); + }); +}); From 61171f14bf3c011c390b3a2947643ac12ee5a056 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Wed, 4 Dec 2024 16:31:05 +0100 Subject: [PATCH 064/103] feat(wallet-sdk): cross chain send, improve tracking logic --- packages/apps/wallet-sdk-example/src/App.tsx | 2 + .../src/components/AccountItem.tsx | 50 +++---- .../src/components/Accounts.tsx | 22 +-- .../src/components/ChainSelectorModal.tsx | 25 +--- .../src/components/SdkFunctionDisplayer.tsx | 63 ++++++--- .../src/components/Text.tsx | 18 ++- .../src/components/TransactionModal.tsx | 93 ++++++------ .../src/hooks/functionTracker.ts | 42 ++++++ .../hooks/kadenaNames/kadenaNamesResolver.ts | 76 +++++----- .../wallet-sdk-example/src/hooks/transfers.ts | 112 +++++---------- .../apps/wallet-sdk-example/src/index.css | 13 +- .../wallet-sdk-example/src/pages/Transfer.tsx | 133 ++++++++++-------- .../src/pages/Transfers.tsx | 37 +++-- .../wallet-sdk-example/src/pages/Wallet.tsx | 3 - .../pages/kadenaNames/KadenaNamesResolver.tsx | 18 +-- .../wallet-sdk-example/src/state/pending.ts | 23 +-- .../libs/wallet-sdk/src/sdk/kadenaNames.ts | 2 + packages/libs/wallet-sdk/src/sdk/walletSdk.ts | 8 ++ .../src/services/graphql/pollTransfers.ts | 6 - 19 files changed, 379 insertions(+), 367 deletions(-) create mode 100644 packages/apps/wallet-sdk-example/src/hooks/functionTracker.ts diff --git a/packages/apps/wallet-sdk-example/src/App.tsx b/packages/apps/wallet-sdk-example/src/App.tsx index 2a5df0afc8..294a36c317 100644 --- a/packages/apps/wallet-sdk-example/src/App.tsx +++ b/packages/apps/wallet-sdk-example/src/App.tsx @@ -7,10 +7,12 @@ import './global.css.ts'; import { useRoutes } from 'react-router-dom'; import routes from './routes'; +import { useWalletState } from './state/wallet.ts'; const queryClient = new QueryClient(); function App() { + useWalletState('password'); const routing = useRoutes(routes); return ( diff --git a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx index 537b866233..65dd1bfe65 100644 --- a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx +++ b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx @@ -1,6 +1,7 @@ import { Badge, Button, Card, Divider, Stack, Text } from '@kadena/kode-ui'; import React, { useEffect, useState } from 'react'; import { createAndTransferFund } from '../domain/fund'; +import { useFunctionTracker } from '../hooks/functionTracker'; import { useFund } from '../hooks/fund'; import { useAddressToName } from '../hooks/kadenaNames/kadenaNamesResolver'; import { chainwebHostMap } from '../host'; @@ -33,45 +34,38 @@ export const AccountItem: React.FC = ({ const [selectedChain, setSelectedChain] = useState(wallet.selectedChain); const [alertMessage, setAlertMessage] = useState(null); const { onFundOtherFungible } = useFund(); + + const trackGetAccountDetails = useFunctionTracker( + 'walletSdk.getAccountDetails', + ); + const { name: resolvedName, loading: nameLoading, setAddress, - /* -- Start demo ---------------*/ - sdkFunctionCall: nameSdkFunctionCall, - /* -- End demo ---------------*/ + trackAddressToName, } = useAddressToName(refreshKey, wallet.selectedNetwork); - /* -- Start demo ---------------*/ - const [balanceSdkFunctionCall, setBalanceSdkFunctionCall] = useState<{ - functionName: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - functionArgs: any; - } | null>(null); - /* -- End demo ---------------*/ - useEffect(() => { setAddress(account.name); }, [account.name, setAddress, refreshKey]); + /* -- Start demo ---------------*/ useEffect(() => { - /* -- Start demo ---------------*/ - setBalanceSdkFunctionCall({ - functionName: 'walletSdk.getAccountDetails', - functionArgs: { - accountName: account.name, - networkId: wallet.selectedNetwork, - fungible: wallet.selectedFungible, - chainIds: [wallet.selectedChain], - }, + trackGetAccountDetails.setArgs({ + accountName: account.name, + networkId: wallet.selectedNetwork, + fungible: wallet.selectedFungible, + chainIds: [wallet.selectedChain], }); - /* -- End demo ---------------*/ + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ account.name, wallet.selectedNetwork, wallet.selectedFungible, wallet.selectedChain, ]); + /* -- End demo ---------------*/ const openRegisterModal = () => setModalVisible(true); const closeRegisterModal = () => setModalVisible(false); @@ -214,19 +208,13 @@ export const AccountItem: React.FC = ({ {/* -- Start demo ---------------*/} {/* Display the SDK function call for getAccountDetails */} - {balanceSdkFunctionCall && ( - + {trackGetAccountDetails && ( + )} {/* Display the SDK function call for addressToName */} - {nameSdkFunctionCall && ( - + {trackAddressToName && ( + )} {/* -- End demo ---------------*/}
diff --git a/packages/apps/wallet-sdk-example/src/components/Accounts.tsx b/packages/apps/wallet-sdk-example/src/components/Accounts.tsx index 84e838627b..b7a8ea68fb 100644 --- a/packages/apps/wallet-sdk-example/src/components/Accounts.tsx +++ b/packages/apps/wallet-sdk-example/src/components/Accounts.tsx @@ -11,6 +11,7 @@ import { import { useEffect, useState } from 'react'; import { useAccountsBalances } from '../hooks/balances'; import { useChains } from '../hooks/chains'; +import { useFunctionTracker } from '../hooks/functionTracker'; import { useWalletState } from '../state/wallet'; import { AccountItem } from './AccountItem'; import SdkFunctionDisplay from './SdkFunctionDisplayer'; // Demo @@ -29,20 +30,10 @@ export const Accounts = () => { const { chains } = useChains(wallet.selectedNetwork); /* -- Start demo ---------------*/ - const [functionCall, setFunctionCall] = useState<{ - functionName: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - functionArgs: any; - }>({ - functionName: 'walletSdk.getChains', - functionArgs: { networkId: wallet.selectedNetwork }, - }); - + const trackGetChains = useFunctionTracker('walletSdk.getChains'); useEffect(() => { - setFunctionCall({ - functionName: 'walletSdk.getChains', - functionArgs: { networkId: wallet.selectedNetwork }, - }); + trackGetChains.setArgs(wallet.selectedNetwork); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [wallet.selectedNetwork]); /* -- End demo ---------------*/ @@ -85,10 +76,7 @@ export const Accounts = () => { {/* This is for Demo purposes, displaying what SDK function is execution for this action */} - + {wallet.accounts.map((account) => ( = ({ const { chains } = useChains(wallet.selectedNetwork); /* -- Start demo ---------------*/ - const [functionCall, setFunctionCall] = useState<{ - functionName: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - functionArgs: any; - }>({ - functionName: 'walletSdk.getChains', - functionArgs: { networkId: wallet.selectedNetwork }, - }); - + const trackGetChains = useFunctionTracker('walletSdk.getChains'); useEffect(() => { - setFunctionCall({ - functionName: 'walletSdk.getChains', - functionArgs: { networkId: wallet.selectedNetwork }, - }); + trackGetChains.setArgs(wallet.selectedNetwork); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [wallet.selectedNetwork]); - /* -- End demo ---------------*/ const handleChainChange = (chainId: ChainId) => { @@ -93,10 +83,7 @@ export const ChainSelectionModal: React.FC = ({ {/* This is for Demo purposes, displaying what SDK function is execution for this action */} - + ); diff --git a/packages/apps/wallet-sdk-example/src/components/SdkFunctionDisplayer.tsx b/packages/apps/wallet-sdk-example/src/components/SdkFunctionDisplayer.tsx index c1b30e6b7d..9f2fff58d8 100644 --- a/packages/apps/wallet-sdk-example/src/components/SdkFunctionDisplayer.tsx +++ b/packages/apps/wallet-sdk-example/src/components/SdkFunctionDisplayer.tsx @@ -1,8 +1,10 @@ -import { Card, Divider, Stack, Text } from '@kadena/kode-ui'; +import { Card, Divider, Stack, TabItem, Tabs, Text } from '@kadena/kode-ui'; import hljs from 'highlight.js/lib/core'; import javascript from 'highlight.js/lib/languages/javascript'; +import jsonHighlight from 'highlight.js/lib/languages/json'; import 'highlight.js/styles/github.css'; import React, { useEffect, useRef } from 'react'; +import { TrackedFunction } from '../hooks/functionTracker'; import { useWalletState } from '../state/wallet'; import { sdkDisplayCode, @@ -10,32 +12,39 @@ import { } from './sdkFunctionDisplayer.css'; interface SdkFunctionDisplayProps { - functionName: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - functionArgs: any; + data: TrackedFunction; } -const SdkFunctionDisplay: React.FC = ({ - functionName, - functionArgs, +const HighlightBlock: React.FC<{ data: string; language: string }> = ({ + data, + language, }) => { - const codeString = `${functionName}(${JSON.stringify( - functionArgs, - null, - 2, - )});`; + const elRef = useRef(null); + useEffect(() => { + if (elRef.current) hljs.highlightElement(elRef.current); + }, []); + return ( +
+      
+        {data}
+      
+    
+ ); +}; + +const SdkFunctionDisplay: React.FC = (props) => { + const { name, args, response } = props.data ?? { args: null }; + const codeString = `${name}(${JSON.stringify(args, null, 2).slice(1, -1)});`; const { debugMode } = useWalletState(); - const codeRef = useRef(null); useEffect(() => { hljs.registerLanguage('javascript', javascript); - if (codeRef.current) { - hljs.highlightElement(codeRef.current); - } - }, [codeString, debugMode]); + hljs.registerLanguage('json', jsonHighlight); + }, []); if (!debugMode) return null; + if (args === null) return null; return (
@@ -43,11 +52,21 @@ const SdkFunctionDisplay: React.FC = ({ SDK Function Call -
-            
-              {codeString}
-            
-          
+ {response ? ( + + + + + + + + + ) : ( + + )}
diff --git a/packages/apps/wallet-sdk-example/src/components/Text.tsx b/packages/apps/wallet-sdk-example/src/components/Text.tsx index 1198a6a71a..52fd58cdd6 100644 --- a/packages/apps/wallet-sdk-example/src/components/Text.tsx +++ b/packages/apps/wallet-sdk-example/src/components/Text.tsx @@ -5,11 +5,13 @@ export const TextEllipsis = ({ maxLength, placement, withCopyButton, + withCopyClick, }: { children: React.ReactNode; maxLength?: number; placement?: 'middle' | 'end'; withCopyButton?: boolean; + withCopyClick?: boolean; }) => { if (typeof children !== 'string') return null; @@ -17,7 +19,13 @@ export const TextEllipsis = ({ if (placement === 'end') { return ( <> - + { + if (withCopyClick) navigator.clipboard.writeText(children); + }} + > {`${children.slice(0, maxLength - 3)}...`}{' '} {withCopyButton && } @@ -28,7 +36,13 @@ export const TextEllipsis = ({ const middle = Math.floor(maxLength / 2); return ( <> - + { + if (withCopyClick) navigator.clipboard.writeText(children); + }} + > {children.slice(0, middle)} ... {children.slice(children.length - maxLength + middle)} diff --git a/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx b/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx index 3e5a9dd4de..58f6c1ada5 100644 --- a/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx +++ b/packages/apps/wallet-sdk-example/src/components/TransactionModal.tsx @@ -3,12 +3,14 @@ import { Button, ContentHeader, Dialog, + DialogContent, Divider, Stack, Text, TextareaField, } from '@kadena/kode-ui'; import React from 'react'; +import { TrackedFunction } from '../hooks/functionTracker'; import SdkFunctionDisplay from './SdkFunctionDisplayer'; interface TransactionModalProps { @@ -17,11 +19,7 @@ interface TransactionModalProps { onClose: () => void; onConfirm: () => void; // demo - gasFunctionCall?: { - functionName: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - functionArgs: any; - } | null; + gasFunctionCall?: TrackedFunction; } export const TransactionModal: React.FC = ({ @@ -38,61 +36,60 @@ export const TransactionModal: React.FC = ({ if (!isOpen) onClose(); }} size="sm" + className="max-h-[90vh]" > } /> - - - - - Estimated Gas Cost:{' '} - {estimatedGas ?? 'Calculating...'} - - {/* + + + + + Estimated Gas Cost:{' '} + {estimatedGas ?? 'Calculating...'} + + {/* This is for Demo purposes, displaying the SDK function used to estimate gas */} - {gasFunctionCall && ( - <> - - - - )} + {gasFunctionCall && ( + <> + + + + )} - + - + - - - + + + + - + ); }; diff --git a/packages/apps/wallet-sdk-example/src/hooks/functionTracker.ts b/packages/apps/wallet-sdk-example/src/hooks/functionTracker.ts new file mode 100644 index 0000000000..5681480282 --- /dev/null +++ b/packages/apps/wallet-sdk-example/src/hooks/functionTracker.ts @@ -0,0 +1,42 @@ +import { useCallback, useState } from 'react'; + +export interface TrackedFunction { + name: string; + args: unknown[] | null; + response: { data: unknown } | null; +} + +export function useFunctionTracker(name: string) { + const [args, setArgs] = useState(null); + const [response, setResponse] = useState(null); + const clear = useCallback(() => { + setArgs(null); + setResponse(null); + }, []); + const wrap = useCallback( + ReturnType>(fn: T) => { + return (...args: Parameters): ReturnType => { + setArgs(args); + const response = fn(...args); + Promise.resolve(response).then((data) => setResponse({ data })); + console.log('track wrap', name, args, response); + return response; + }; + }, + [], + ); + const setAnyArgs = useCallback((args: unknown) => { + setArgs(Array.isArray(args) ? args : [args]); + }, []); + return { + data: { + name, + args, + response, + } as TrackedFunction, + setArgs: setAnyArgs, + setResponse, + wrap, + clear, + }; +} diff --git a/packages/apps/wallet-sdk-example/src/hooks/kadenaNames/kadenaNamesResolver.ts b/packages/apps/wallet-sdk-example/src/hooks/kadenaNames/kadenaNamesResolver.ts index 6f461ffa2b..dd125e82ec 100644 --- a/packages/apps/wallet-sdk-example/src/hooks/kadenaNames/kadenaNamesResolver.ts +++ b/packages/apps/wallet-sdk-example/src/hooks/kadenaNames/kadenaNamesResolver.ts @@ -1,6 +1,7 @@ import { walletSdk } from '@kadena/wallet-sdk'; import { useEffect, useState } from 'react'; import { useDebounce } from '../../utils/useDebounce'; +import { useFunctionTracker } from '../functionTracker'; export const useAddressToName = (refreshKey = 0, selectedNetwork: string) => { const [address, setAddress] = useState(''); @@ -10,13 +11,9 @@ export const useAddressToName = (refreshKey = 0, selectedNetwork: string) => { const [error, setError] = useState(null); const [loading, setLoading] = useState(false); - /* -- Start demo ---------------*/ - const [sdkFunctionCall, setSdkFunctionCall] = useState<{ - functionName: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - functionArgs: any; - } | null>(null); - /* -- End demo ---------------*/ + const trackAddressToName = useFunctionTracker( + 'walletSdk.kadenaNames.addressToName', + ); useEffect(() => { setName(null); @@ -32,20 +29,10 @@ export const useAddressToName = (refreshKey = 0, selectedNetwork: string) => { const getName = async () => { setLoading(true); try { - /* -- Start demo ---------------*/ - setSdkFunctionCall({ - functionName: 'walletSdk.kadenaNames.addressToName', - functionArgs: { - address: debouncedAddress, - networkId: selectedNetwork, - }, - }); - /* -- End demo ---------------*/ - - const result = await walletSdk.kadenaNames.addressToName( - debouncedAddress, - selectedNetwork, - ); + const result = await trackAddressToName.wrap( + walletSdk.kadenaNames.addressToName, + )(debouncedAddress, selectedNetwork); + if (isCurrent) { if (result !== null) { setName(result); @@ -69,9 +56,17 @@ export const useAddressToName = (refreshKey = 0, selectedNetwork: string) => { return () => { isCurrent = false; }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [debouncedAddress, refreshKey, selectedNetwork]); - return { name, error, loading, setAddress, address, sdkFunctionCall }; + return { + name, + error, + loading, + setAddress, + address, + trackAddressToName: trackAddressToName.data, + }; }; export const useNameToAddress = (refreshKey = 0, selectedNetwork: string) => { @@ -82,13 +77,9 @@ export const useNameToAddress = (refreshKey = 0, selectedNetwork: string) => { const [error, setError] = useState(null); const [loading, setLoading] = useState(false); - /* -- Start demo ---------------*/ - const [sdkFunctionCall, setSdkFunctionCall] = useState<{ - functionName: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - functionArgs: any; - } | null>(null); - /* -- End demo ---------------*/ + const trackNameToAddress = useFunctionTracker( + 'walletSdk.kadenaNames.nameToAddress', + ); useEffect(() => { setAddress(null); @@ -104,19 +95,10 @@ export const useNameToAddress = (refreshKey = 0, selectedNetwork: string) => { const getAddress = async () => { setLoading(true); try { - /* -- Start demo ---------------*/ - setSdkFunctionCall({ - functionName: 'walletSdk.kadenaNames.nameToAddress', - functionArgs: { - name: debouncedName, - networkId: selectedNetwork, - }, - }); - /* -- End demo ---------------*/ - const result = await walletSdk.kadenaNames.nameToAddress( - debouncedName, - selectedNetwork, - ); + const result = await trackNameToAddress.wrap( + walletSdk.kadenaNames.nameToAddress, + )(debouncedName, selectedNetwork); + if (isCurrent) { if (result !== null) { setAddress(result); @@ -140,7 +122,15 @@ export const useNameToAddress = (refreshKey = 0, selectedNetwork: string) => { return () => { isCurrent = false; }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [debouncedName, refreshKey, selectedNetwork]); - return { address, error, loading, setName, name, sdkFunctionCall }; + return { + address, + error, + loading, + setName, + name, + trackNameToAddress: trackNameToAddress.data, + }; }; diff --git a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts index 3ed0015c4b..b48bab90c5 100644 --- a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts +++ b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts @@ -1,20 +1,21 @@ import { walletSdk } from '@kadena/wallet-sdk'; import { useQuery } from '@tanstack/react-query'; -import { useEffect, useState } from 'react'; +import { useEffect } from 'react'; import { usePendingTransfers } from '../state/pending'; import { useWalletState } from '../state/wallet'; - -interface FunctionCall { - functionName: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - functionArgs: any; -} +import { useFunctionTracker } from './functionTracker'; export const useTransfers = () => { const wallet = useWalletState(); const { pendingTransfers, removePendingTransfer } = usePendingTransfers(); - const [functionCalls, setFunctionCalls] = useState([]); + const trackGetTransfers = useFunctionTracker('walletSdk.getTransfers'); + const trackSubscribePendingTransactions = useFunctionTracker( + 'walletSdk.subscribePendingTransactions', + ); + const trackSubscribeOnCrossChainComplete = useFunctionTracker( + 'walletSdk.subscribeOnCrossChainComplete', + ); const { data: transfers, @@ -24,32 +25,19 @@ export const useTransfers = () => { queryKey: ['transfers', wallet.account?.name], enabled: !!wallet.account?.name, queryFn: async () => { - /* --- Start Demo purposes --- */ - const functionName = 'walletSdk.getTransfers'; - const functionArgs = { - accountName: wallet.account?.name ?? '', - networkId: wallet.selectedNetwork, - fungible: wallet.selectedFungible, - }; - - setFunctionCalls((prevCalls) => { - const exists = prevCalls.some( - (call) => - call.functionName === functionName && - JSON.stringify(call.functionArgs) === JSON.stringify(functionArgs), + if (!wallet.account?.name) return []; + /** + Without the tracking of the function, the code would look like: + walletSdk.getTransfers( + wallet.account.name, + wallet.selectedNetwork, + wallet.selectedFungible, ); - if (exists) { - return prevCalls; - } else { - return [...prevCalls, { functionName, functionArgs }]; - } - }); - /* -- End demo ---------------*/ - - return walletSdk.getTransfers( - functionArgs.accountName, - functionArgs.networkId, - functionArgs.fungible, + */ + return trackGetTransfers.wrap(walletSdk.getTransfers)( + wallet.account.name, + wallet.selectedNetwork, + wallet.selectedFungible, ); }, }); @@ -58,68 +46,41 @@ export const useTransfers = () => { if (!transfers || transfers.length === 0) return; const controller = new AbortController(); - const incompleteTransfers = transfers.filter( - (transfer) => transfer.isCrossChainTransfer && !transfer.continuation, + const crossChainTransfers = transfers.filter( + (transfer) => transfer.isCrossChainTransfer, + ); + const incompleteTransfers = crossChainTransfers.filter( + (transfer) => !transfer.continuation, ); /* --- Start Demo purposes --- */ - const functionName = 'walletSdk.subscribeOnCrossChainComplete'; - const functionArgs = { + trackSubscribeOnCrossChainComplete.setArgs({ transfers: incompleteTransfers, callback: '() => refetch()', options: { signal: controller.signal }, - }; - - setFunctionCalls((prevCalls) => { - const exists = prevCalls.some( - (call) => - call.functionName === functionName && - JSON.stringify(call.functionArgs) === JSON.stringify(functionArgs), - ); - if (exists) { - return prevCalls; - } else { - return [...prevCalls, { functionName, functionArgs }]; - } }); - /* -- End demo ---------------*/ + /* --- End demo ---------------*/ walletSdk.subscribeOnCrossChainComplete( wallet.account?.name ?? '', incompleteTransfers, () => refetch(), - { - signal: controller.signal, - }, + { signal: controller.signal }, ); return () => controller.abort(); - }, [refetch, transfers]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [refetch, transfers, wallet.account?.name]); useEffect(() => { + console.log({ pendingTransfers }); if (!pendingTransfers || pendingTransfers.length === 0) return; const controller = new AbortController(); - /* --- Start Demo purposes --- */ - const functionName = 'walletSdk.subscribePendingTransactions'; - const functionArgs = { + trackSubscribePendingTransactions.setArgs({ pendingTransfers, callback: '(transfer) => { ... }', options: { signal: controller.signal }, - }; - - setFunctionCalls((prevCalls) => { - const exists = prevCalls.some( - (call) => - call.functionName === functionName && - JSON.stringify(call.functionArgs) === JSON.stringify(functionArgs), - ); - if (exists) { - return prevCalls; - } else { - return [...prevCalls, { functionName, functionArgs }]; - } }); - /* -- End demo ---------------*/ walletSdk.subscribePendingTransactions( pendingTransfers, @@ -131,6 +92,7 @@ export const useTransfers = () => { { signal: controller.signal }, ); return () => controller.abort(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [pendingTransfers, refetch, removePendingTransfer]); return { @@ -139,6 +101,10 @@ export const useTransfers = () => { pendingTransfers, account: wallet.account?.name, refetch, - functionCalls, // demo + functionCalls: [ + trackGetTransfers.data, + trackSubscribePendingTransactions.data, + trackSubscribeOnCrossChainComplete.data, + ], // demo }; }; diff --git a/packages/apps/wallet-sdk-example/src/index.css b/packages/apps/wallet-sdk-example/src/index.css index f07e1204bc..034c8bb87c 100644 --- a/packages/apps/wallet-sdk-example/src/index.css +++ b/packages/apps/wallet-sdk-example/src/index.css @@ -1,25 +1,18 @@ - @tailwind utilities; - -[class^="Form__"] { +[class^='Form__'] { width: 100%; } -[class^="Dialog"] { - max-height: inherit -} - textarea { width: 100%; } - /* deze nog fixen */ .text-negative { - color: green + color: green; } .text-negative { - color: red + color: red; } diff --git a/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx b/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx index e81a4e6c55..7ab6f46cab 100644 --- a/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx @@ -11,7 +11,7 @@ import { Text, TextField, } from '@kadena/kode-ui'; -import { SimpleCreateTransfer, walletSdk } from '@kadena/wallet-sdk'; +import { walletSdk } from '@kadena/wallet-sdk'; import React, { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useChains } from '../hooks/chains'; @@ -21,13 +21,16 @@ import SdkFunctionDisplay from '../components/SdkFunctionDisplayer'; // Demo import { TransactionModal } from '../components/TransactionModal'; import { AlertDialog } from '../components/AlertDialog'; +import { useFunctionTracker } from '../hooks/functionTracker'; import { useWalletState } from '../state/wallet'; -interface FunctionCall { - functionName: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - functionArgs: any; -} +type SimpleCreateTransfer = Parameters< + typeof walletSdk.createSimpleTransfer +>[0]; + +type CrossChainCreateTransfer = Parameters< + typeof walletSdk.createCrossChainTransfer +>[0]; export const Transfer = () => { const wallet = useWalletState(); @@ -45,14 +48,14 @@ export const Transfer = () => { amount: string; } | null>(null); - /* -- Start demo ---------------*/ - const [sdkFunctionCall, setSdkFunctionCall] = useState( - null, + const trackCreateSimpleTransfer = useFunctionTracker( + 'walletSdk.createSimpleTransfer', ); - const [gasFunctionCall, setGasFunctionCall] = useState( - null, + const trackCreateCrossChainTransfer = useFunctionTracker( + 'walletSdk.createCrossChainTransfer', ); - /* -- End demo ---------------*/ + const trackGasEstimate = useFunctionTracker('walletSdk.getGasLimitEstimate'); + const trackSendTransaction = useFunctionTracker('walletSdk.sendTransaction'); const navigate = useNavigate(); const { chains } = useChains(wallet.selectedNetwork); @@ -69,25 +72,34 @@ export const Transfer = () => { const fromChain = wallet.selectedChain; if (isCrossChain) { - // Cross-chain transfers are not supported yet - setSdkFunctionCall({ - functionName: 'Cross-chain transfers are not supported yet.', - functionArgs: null, + trackCreateCrossChainTransfer.setArgs({ + amount: amount, + chainId: fromChain, + networkId: wallet.selectedNetwork, + receiver: { + account: receiverAccount, + keyset: { + keys: [receiverAccount.split(':')[1]], + pred: 'keys-all', + }, + }, + sender: { + account: wallet.account.name, + publicKeys: [wallet.account.publicKey], + }, + targetChainId: wallet.selectedToChain, }); } else { - const functionName = 'walletSdk.createSimpleTransfer'; - const functionArgs: SimpleCreateTransfer & { networkId: string } = { + trackCreateSimpleTransfer.setArgs({ amount, sender: wallet.account.name, receiver: receiverAccount, chainId: fromChain, networkId: wallet.selectedNetwork, - }; - - setSdkFunctionCall({ functionName, functionArgs }); + }); } - - setGasFunctionCall(null); + trackGasEstimate.setArgs(null); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ wallet.account, amount, @@ -103,6 +115,9 @@ export const Transfer = () => { const fromChain = wallet.selectedChain; const toChain = isCrossChain ? wallet.selectedToChain : fromChain; + if (isCrossChain && !toChain) { + throw new Error('To chain not set'); + } if (isCrossChain && fromChain === toChain) { throw new Error( 'Cannot perform a cross-chain transfer to the same chain', @@ -112,13 +127,25 @@ export const Transfer = () => { let transaction: IUnsignedCommand; if (isCrossChain) { - /* --- Start Demo purposes --- */ - setSdkFunctionCall({ - functionName: 'Cross-chain transfers are not supported yet.', - functionArgs: null, - }); - /* -- End demo ---------------*/ - throw new Error('Cross-chain transfers are not supported yet.'); + const crossChainTransferArgs: CrossChainCreateTransfer = { + amount: amount, + chainId: fromChain, + networkId: wallet.selectedNetwork, + receiver: { + account: receiverAccount, + keyset: { + keys: [receiverAccount.split(':')[1]], + pred: 'keys-all', + }, + }, + sender: { + account: wallet.account.name, + publicKeys: [wallet.account.publicKey], + }, + targetChainId: toChain!, + }; + transaction = walletSdk.createCrossChainTransfer(crossChainTransferArgs); + return await wallet.signTransaction(transaction); } else { const functionArgs: SimpleCreateTransfer & { networkId: string } = { amount, @@ -144,23 +171,9 @@ export const Transfer = () => { return; } - const gasLimit = await walletSdk.getGasLimitEstimate( - signed, - wallet.selectedNetwork, - wallet.selectedChain, - ); - - /* --- Start Demo purposes --- */ - const newCall = { - functionName: 'walletSdk.getGasLimitEstimate', - functionArgs: { - transaction: '[SIGNED TRANSACTION]', - networkId: wallet.selectedNetwork, - chainId: wallet.selectedChain, - }, - }; - setGasFunctionCall(newCall); - /* -- End demo ---------------*/ + const gasLimit = await trackGasEstimate.wrap( + walletSdk.getGasLimitEstimate, + )(signed, wallet.selectedNetwork, wallet.selectedChain); setSignedTransaction(signed); setEstimatedGas(gasLimit); @@ -180,8 +193,9 @@ export const Transfer = () => { ); /* -- Start demo ---------------*/ - setSdkFunctionCall(null); - setGasFunctionCall(null); + trackGasEstimate.setArgs(null); + trackCreateSimpleTransfer.setArgs(null); + trackCreateCrossChainTransfer.setArgs(null); /* -- End demo ---------------*/ } }; @@ -190,7 +204,7 @@ export const Transfer = () => { if (!wallet.account || !signedTransaction || !transactionDetails) return; try { - const result = await walletSdk.sendTransaction( + const result = await trackSendTransaction.wrap(walletSdk.sendTransaction)( signedTransaction, wallet.selectedNetwork, wallet.selectedChain, @@ -210,8 +224,9 @@ export const Transfer = () => { setSignedTransaction(null); /* -- Start demo ---------------*/ - setSdkFunctionCall(null); - setGasFunctionCall(null); + trackGasEstimate.setArgs(null); + trackCreateSimpleTransfer.setArgs(null); + trackCreateCrossChainTransfer.setArgs(null); /* -- End demo ---------------*/ navigate('/list'); } catch (error) { @@ -311,7 +326,7 @@ export const Transfer = () => { transactionJSON={JSON.stringify(signedTransaction, null, 2)} onClose={() => setIsModalOpen(false)} onConfirm={confirmTransaction} - gasFunctionCall={gasFunctionCall} + gasFunctionCall={trackGasEstimate.data} /> )} @@ -327,12 +342,12 @@ export const Transfer = () => { {/* This is for Demo purposes, displaying the SDK function used to create the transaction */} - {sdkFunctionCall && ( - - )} + +
); }; diff --git a/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx b/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx index 9bbc07502e..ac234451dc 100644 --- a/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx @@ -16,12 +16,13 @@ import { import SdkFunctionDisplay from '../components/SdkFunctionDisplayer'; // Demo import { TextEllipsis } from '../components/Text'; import { useTransfers } from '../hooks/transfers'; -import { shortenString } from '../utils/kadenanames/transform'; export const Transfers = () => { const { transfers, pendingTransfers, account, functionCalls } = useTransfers(); + console.log('Transfers render'); + // eslint-disable-next-line @typescript-eslint/no-explicit-any const getAmountStyle = (transfer: any) => { if (!transfer.success) return 'text-default'; @@ -58,8 +59,12 @@ export const Transfers = () => { {pendingTransfers.map((transfer, index) => ( - - {shortenString(transfer.requestKey)} + + + + {transfer.requestKey} + + {transfer.chainId} @@ -109,8 +114,12 @@ export const Transfers = () => { {transfers.map((transfer, index) => ( - - {shortenString(transfer.requestKey)} + + + + {transfer.requestKey} + + {transfer.isCrossChainTransfer ? `${transfer.chainId} → ${transfer.targetChainId}` @@ -142,7 +151,15 @@ export const Transfers = () => { - {transfer.success ? 'Success' : 'Failed'} + {transfer.success + ? transfer.isCrossChainTransfer + ? transfer.continuation + ? transfer.continuation.success + ? 'Finished' + : 'Finish failed' + : 'Awaiting completion' + : 'Success' + : 'Failed'} @@ -158,12 +175,8 @@ export const Transfers = () => { {/* This is for Demo purposes, displaying what SDK function is execution for this action */} - {functionCalls.map((call, index) => ( - + {functionCalls.map((data, index) => ( + ))}
); diff --git a/packages/apps/wallet-sdk-example/src/pages/Wallet.tsx b/packages/apps/wallet-sdk-example/src/pages/Wallet.tsx index c26995259e..885cd5eb1e 100644 --- a/packages/apps/wallet-sdk-example/src/pages/Wallet.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/Wallet.tsx @@ -1,11 +1,8 @@ import { Divider } from '@kadena/kode-ui'; import { Accounts } from '../components/Accounts'; import { WordPhrase } from '../components/WordPhrase'; -import { useWalletState } from '../state/wallet'; export function Wallet() { - useWalletState('password'); - return (
diff --git a/packages/apps/wallet-sdk-example/src/pages/kadenaNames/KadenaNamesResolver.tsx b/packages/apps/wallet-sdk-example/src/pages/kadenaNames/KadenaNamesResolver.tsx index 3258798215..a06386f302 100644 --- a/packages/apps/wallet-sdk-example/src/pages/kadenaNames/KadenaNamesResolver.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/kadenaNames/KadenaNamesResolver.tsx @@ -27,7 +27,7 @@ export const KadenaNames: React.FC = () => { setAddress, address: inputAddress, /* -- Start demo ---------------*/ - sdkFunctionCall: addressToNameSdkCall, + trackAddressToName, /* -- End demo ---------------*/ } = useAddressToName(0, wallet.selectedNetwork); @@ -38,7 +38,7 @@ export const KadenaNames: React.FC = () => { setName, name: inputName, /* -- Start demo ---------------*/ - sdkFunctionCall: nameToAddressSdkCall, + trackNameToAddress, /* -- End demo ---------------*/ } = useNameToAddress(0, wallet.selectedNetwork); @@ -105,18 +105,8 @@ export const KadenaNames: React.FC = () => { */}
{/* -- Start demo ---------------*/} - {addressToNameSdkCall && ( - - )} - {nameToAddressSdkCall && ( - - )} + {trackAddressToName && } + {trackNameToAddress && } {/* -- End demo ---------------*/}
diff --git a/packages/apps/wallet-sdk-example/src/state/pending.ts b/packages/apps/wallet-sdk-example/src/state/pending.ts index 2e3b79d67a..c7ee1491b6 100644 --- a/packages/apps/wallet-sdk-example/src/state/pending.ts +++ b/packages/apps/wallet-sdk-example/src/state/pending.ts @@ -1,6 +1,7 @@ import { ITransactionDescriptor } from '@kadena/client'; import { useAtom } from 'jotai'; import { atomWithStorage } from 'jotai/utils'; +import { useCallback } from 'react'; export type PendingTransfer = ITransactionDescriptor & { receiverAccount: string; @@ -16,15 +17,21 @@ export const pendingTransfersAtom = atomWithStorage( export const usePendingTransfers = () => { const [pendingTransfers, setPendingTransfers] = useAtom(pendingTransfersAtom); - const addPendingTransfer = (transfer: PendingTransfer) => { - setPendingTransfers((prev) => [...prev, transfer]); - }; + const addPendingTransfer = useCallback( + (transfer: PendingTransfer) => { + setPendingTransfers((prev) => [...prev, transfer]); + }, + [setPendingTransfers], + ); - const removePendingTransfer = (transfer: ITransactionDescriptor) => { - setPendingTransfers((prev) => - prev.filter((t) => t.requestKey !== transfer.requestKey), - ); - }; + const removePendingTransfer = useCallback( + (transfer: ITransactionDescriptor) => { + setPendingTransfers((prev) => + prev.filter((t) => t.requestKey !== transfer.requestKey), + ); + }, + [setPendingTransfers], + ); return { pendingTransfers, addPendingTransfer, removePendingTransfer }; }; diff --git a/packages/libs/wallet-sdk/src/sdk/kadenaNames.ts b/packages/libs/wallet-sdk/src/sdk/kadenaNames.ts index 0a70e1d687..632fd84ec0 100644 --- a/packages/libs/wallet-sdk/src/sdk/kadenaNames.ts +++ b/packages/libs/wallet-sdk/src/sdk/kadenaNames.ts @@ -10,6 +10,8 @@ export class KadenaNames { public constructor(walletSDK: WalletSDK) { this._sdk = walletSDK; + this.nameToAddress = this.nameToAddress.bind(this); + this.addressToName = this.addressToName.bind(this); } public async nameToAddress( diff --git a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts index b50ccfcf4a..ce574631f2 100644 --- a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts +++ b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts @@ -70,6 +70,14 @@ export class WalletSDK { options?.logTransport, ); this.kadenaNames = new KadenaNames(this); + + this.getTransfers = this.getTransfers.bind(this); + this.createSimpleTransfer = this.createSimpleTransfer.bind(this); + this.createCrossChainTransfer = this.createCrossChainTransfer.bind(this); + this.createFinishCrossChainTransfer = + this.createFinishCrossChainTransfer.bind(this); + this.sendTransaction = this.sendTransaction.bind(this); + this.getGasLimitEstimate = this.getGasLimitEstimate.bind(this); } public getChainwebUrl( diff --git a/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts b/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts index 8a955b4b3f..3cf744b76b 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts @@ -44,12 +44,6 @@ export async function pollGraphqlTransfers({ requestKeys, signal, }: IRollGraphqlTransfers) { - console.log('pollGraphqlTransfers', { - accountName, - graphqlUrl, - requestKeys, - }); - const result = await Promise.all( requestKeys.map(async (requestKey) => { const { transfers: nodes, lastBlockHeight } = From 4de6048a9e76d08826c61b1a47e362f6287496b5 Mon Sep 17 00:00:00 2001 From: Nillo Date: Wed, 4 Dec 2024 16:44:37 +0100 Subject: [PATCH 065/103] feat(wallet-sdk-example): added notifications. --- packages/apps/wallet-sdk-example/src/App.tsx | 108 ++++++++++++++++++ .../apps/wallet-sdk-example/src/index.css | 19 +++ 2 files changed, 127 insertions(+) diff --git a/packages/apps/wallet-sdk-example/src/App.tsx b/packages/apps/wallet-sdk-example/src/App.tsx index 294a36c317..ea6cd7cf1e 100644 --- a/packages/apps/wallet-sdk-example/src/App.tsx +++ b/packages/apps/wallet-sdk-example/src/App.tsx @@ -1,7 +1,10 @@ +import { Notification, NotificationHeading } from '@kadena/kode-ui'; import '@kadena/kode-ui/global'; import { darkThemeClass } from '@kadena/kode-ui/styles'; +import { walletSdk } from '@kadena/wallet-sdk'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { ThemeProvider } from 'next-themes'; +import { useEffect, useRef, useState } from 'react'; import Header from './components/Header'; import './global.css.ts'; @@ -11,9 +14,53 @@ import { useWalletState } from './state/wallet.ts'; const queryClient = new QueryClient(); +interface ILogObject { + level: number; + message: string; + data?: Record; + timestamp: number; +} + +interface ILogNotification extends ILogObject { + id: number; +} + +const logLevelMap: Record< + number, + { intent: 'info' | 'warning' | 'negative'; heading: string } +> = { + 0: { intent: 'info', heading: 'Debug' }, + 1: { intent: 'info', heading: 'Information' }, + 2: { intent: 'warning', heading: 'Warning' }, + 3: { intent: 'negative', heading: 'Error' }, +}; + +const triggerTestLogs = () => { + walletSdk.logger.debug('This is a debug message'); + walletSdk.logger.info('This is an info message'); + walletSdk.logger.warn('This is a warning message'); + walletSdk.logger.error('This is an error message'); +}; + function App() { useWalletState('password'); const routing = useRoutes(routes); + const [notifications, setNotifications] = useState([]); + const notificationIdCounter = useRef(0); + + useEffect(() => { + const transport = (log: ILogObject) => { + const id = notificationIdCounter.current++; + const notification: ILogNotification = { ...log, id }; + + setNotifications((prev) => [...prev, notification]); + setTimeout(() => { + setNotifications((prev) => prev.filter((n) => n.id !== id)); + }, 5000); + }; + + walletSdk.logger.setTransport(transport); + }, []); return (
{routing} + +
+ {notifications.map((notification) => { + const { intent, heading } = logLevelMap[notification.level] || { + intent: 'info', + heading: 'Log', + }; + + return ( +
+ + setNotifications((prev) => + prev.filter((n) => n.id !== notification.id), + ) + } + intent={intent} + role="status" + > + {heading} + {notification.message} + {notification.data && ( +
+                        {JSON.stringify(notification.data, null, 2)}
+                      
+ )} +
+
+ ); + })} +
+ + diff --git a/packages/apps/wallet-sdk-example/src/index.css b/packages/apps/wallet-sdk-example/src/index.css index 034c8bb87c..f8abd41dc0 100644 --- a/packages/apps/wallet-sdk-example/src/index.css +++ b/packages/apps/wallet-sdk-example/src/index.css @@ -16,3 +16,22 @@ textarea { .text-negative { color: red; } + + +button[class^="Button__"] > span[class^="Button__"] { + margin-inline-start: 16px !important; + margin-inline-end: 16px !important; +} + +button[class^="Button__"][class*="Button_isCompact_false"] { + margin-top: 20px; +} + +button[class^="Button__"][class*="Button_isCompact_false"] > span[class^="Button__"] { + margin-inline-start: 24px !important; + margin-inline-end: 24px !important; +} + +[class*="Divider__"] { + margin-block: 24px!important; +} From 52fc39bc47505a48e5f046b3feaf703b45fc6f17 Mon Sep 17 00:00:00 2001 From: Nillo Date: Wed, 4 Dec 2024 16:49:25 +0100 Subject: [PATCH 066/103] chore(wallet-sdk-example): fixed styling for modal --- packages/apps/wallet-sdk-example/src/App.tsx | 26 ------------------- .../apps/wallet-sdk-example/src/index.css | 4 +++ 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/packages/apps/wallet-sdk-example/src/App.tsx b/packages/apps/wallet-sdk-example/src/App.tsx index ea6cd7cf1e..ac7a51e064 100644 --- a/packages/apps/wallet-sdk-example/src/App.tsx +++ b/packages/apps/wallet-sdk-example/src/App.tsx @@ -35,13 +35,6 @@ const logLevelMap: Record< 3: { intent: 'negative', heading: 'Error' }, }; -const triggerTestLogs = () => { - walletSdk.logger.debug('This is a debug message'); - walletSdk.logger.info('This is an info message'); - walletSdk.logger.warn('This is a warning message'); - walletSdk.logger.error('This is an error message'); -}; - function App() { useWalletState('password'); const routing = useRoutes(routes); @@ -118,25 +111,6 @@ function App() { ); })}
- - diff --git a/packages/apps/wallet-sdk-example/src/index.css b/packages/apps/wallet-sdk-example/src/index.css index f8abd41dc0..081b92ebbd 100644 --- a/packages/apps/wallet-sdk-example/src/index.css +++ b/packages/apps/wallet-sdk-example/src/index.css @@ -35,3 +35,7 @@ button[class^="Button__"][class*="Button_isCompact_false"] > span[class^="Button [class*="Divider__"] { margin-block: 24px!important; } + +[class*="Dialog__"] { + max-height: inherit!important; +} From b10c97bc42a3be14642ac74689fcb36bcf476481 Mon Sep 17 00:00:00 2001 From: Nillo Date: Wed, 4 Dec 2024 16:59:14 +0100 Subject: [PATCH 067/103] fix(wallet-sdk-example): fixed chain selection on fund --- .../apps/wallet-sdk-example/src/components/AccountItem.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx index 65dd1bfe65..27e36353e5 100644 --- a/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx +++ b/packages/apps/wallet-sdk-example/src/components/AccountItem.tsx @@ -31,7 +31,7 @@ export const AccountItem: React.FC = ({ const wallet = useWalletState(); const [modalVisible, setModalVisible] = useState(false); const [chainModalVisible, setChainModalVisible] = useState(false); - const [selectedChain, setSelectedChain] = useState(wallet.selectedChain); + // const [selectedChain, setSelectedChain] = useState(wallet.selectedChain); const [alertMessage, setAlertMessage] = useState(null); const { onFundOtherFungible } = useFund(); @@ -84,7 +84,7 @@ export const AccountItem: React.FC = ({ config: { amount: '20', contract: 'coin', - chainId: selectedChain, + chainId: wallet.selectedChain, networkId: wallet.selectedNetwork, }, }); @@ -234,7 +234,7 @@ export const AccountItem: React.FC = ({ )} {chainModalVisible && ( From 62ec99f00b38c6a83c24a5368d22a1436678da74 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Thu, 5 Dec 2024 09:57:32 +0100 Subject: [PATCH 068/103] removed console logs --- packages/apps/wallet-sdk-example/src/hooks/functionTracker.ts | 1 - packages/apps/wallet-sdk-example/src/hooks/transfers.ts | 1 - packages/apps/wallet-sdk-example/src/pages/Transfers.tsx | 2 -- 3 files changed, 4 deletions(-) diff --git a/packages/apps/wallet-sdk-example/src/hooks/functionTracker.ts b/packages/apps/wallet-sdk-example/src/hooks/functionTracker.ts index 5681480282..2cf2e9f83e 100644 --- a/packages/apps/wallet-sdk-example/src/hooks/functionTracker.ts +++ b/packages/apps/wallet-sdk-example/src/hooks/functionTracker.ts @@ -19,7 +19,6 @@ export function useFunctionTracker(name: string) { setArgs(args); const response = fn(...args); Promise.resolve(response).then((data) => setResponse({ data })); - console.log('track wrap', name, args, response); return response; }; }, diff --git a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts index b48bab90c5..6439a5e6f8 100644 --- a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts +++ b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts @@ -72,7 +72,6 @@ export const useTransfers = () => { }, [refetch, transfers, wallet.account?.name]); useEffect(() => { - console.log({ pendingTransfers }); if (!pendingTransfers || pendingTransfers.length === 0) return; const controller = new AbortController(); diff --git a/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx b/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx index ac234451dc..4f2bf25999 100644 --- a/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx @@ -21,8 +21,6 @@ export const Transfers = () => { const { transfers, pendingTransfers, account, functionCalls } = useTransfers(); - console.log('Transfers render'); - // eslint-disable-next-line @typescript-eslint/no-explicit-any const getAmountStyle = (transfer: any) => { if (!transfer.success) return 'text-default'; From b2b7a5c4077524ce35c2d26521ca5469f4ba16b8 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Thu, 5 Dec 2024 11:13:01 +0100 Subject: [PATCH 069/103] feat(wallet-sdk): add pagination for getTransfer and other fixes --- .../kadenaNames/NameRegistrationModal.tsx | 53 +++++++++------ .../wallet-sdk-example/src/hooks/transfers.ts | 44 +++++++----- .../apps/wallet-sdk-example/src/index.css | 16 ++--- packages/libs/wallet-sdk/src/gql/gql.ts | 12 ++-- packages/libs/wallet-sdk/src/gql/graphql.ts | 19 ++++-- packages/libs/wallet-sdk/src/sdk/interface.ts | 31 +++++++-- .../src/sdk/tests/getTransfers.test.ts | 13 ++-- .../sdk/tests/mapTransferXchainEnd.test.ts | 4 +- .../sdk/tests/mapTransferXchainStart.test.tsx | 4 +- .../tests/mapTransferXchainUnfinished.test.ts | 4 +- packages/libs/wallet-sdk/src/sdk/walletSdk.ts | 43 ++++++------ .../src/services/graphql/getChainTransfers.ts | 67 +++++++++++++------ .../src/services/graphql/getTransfers.ts | 64 ++++++++++++------ .../src/services/graphql/pollTransfers.ts | 4 +- .../src/services/graphql/transfer.query.ts | 35 +++++++++- .../src/services/graphql/transfer.util.ts | 16 ++--- 16 files changed, 276 insertions(+), 153 deletions(-) diff --git a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx index 16b1f0f78f..6582eea9c1 100644 --- a/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx +++ b/packages/apps/wallet-sdk-example/src/components/kadenaNames/NameRegistrationModal.tsx @@ -1,5 +1,12 @@ import { MonoShortText } from '@kadena/kode-icons/system'; -import { Button, ContentHeader, Dialog, Divider, Stack } from '@kadena/kode-ui'; +import { + Button, + ContentHeader, + Dialog, + DialogContent, + Divider, + Stack, +} from '@kadena/kode-ui'; import React from 'react'; import { NameRegistrationForm } from './NameRegistrationForm'; @@ -25,35 +32,37 @@ export const NameRegistrationModal: React.FC = ({ if (!isOpen) onClose(); }} size="sm" + className="max-h-[90vh]" > } /> + + - + { + onRegistered?.(); + onClose(); + }} + balance={balance} + /> - { - onRegistered?.(); - onClose(); - }} - balance={balance} - /> - - - - + + + + ); }; diff --git a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts index 6439a5e6f8..e90ef69126 100644 --- a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts +++ b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts @@ -18,32 +18,39 @@ export const useTransfers = () => { ); const { - data: transfers, + data: transfersResponse, error, refetch, } = useQuery({ queryKey: ['transfers', wallet.account?.name], enabled: !!wallet.account?.name, queryFn: async () => { - if (!wallet.account?.name) return []; + if (!wallet.account?.name) return undefined; /** Without the tracking of the function, the code would look like: - walletSdk.getTransfers( - wallet.account.name, - wallet.selectedNetwork, - wallet.selectedFungible, - ); + walletSdk.getTransfers({ + accountName: wallet.account.name, + networkId: wallet.selectedNetwork, + fungibleName: wallet.selectedFungible, + }); */ - return trackGetTransfers.wrap(walletSdk.getTransfers)( - wallet.account.name, - wallet.selectedNetwork, - wallet.selectedFungible, - ); + return trackGetTransfers.wrap(walletSdk.getTransfers)({ + accountName: wallet.account.name, + networkId: wallet.selectedNetwork, + fungibleName: wallet.selectedFungible, + }); }, }); useEffect(() => { - if (!transfers || transfers.length === 0) return; + if ( + !transfersResponse?.transfers || + transfersResponse.transfers.length === 0 + ) { + return; + } + + const transfers = transfersResponse.transfers; const controller = new AbortController(); const crossChainTransfers = transfers.filter( @@ -69,7 +76,7 @@ export const useTransfers = () => { ); return () => controller.abort(); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [refetch, transfers, wallet.account?.name]); + }, [refetch, transfersResponse, wallet.account?.name]); useEffect(() => { if (!pendingTransfers || pendingTransfers.length === 0) return; @@ -95,15 +102,20 @@ export const useTransfers = () => { }, [pendingTransfers, refetch, removePendingTransfer]); return { - transfers: transfers ?? [], + transfers: transfersResponse?.transfers ?? [], + pageInfo: transfersResponse?.pageInfo ?? { + hasNextPage: false, + hasPreviousPage: false, + }, error, pendingTransfers, account: wallet.account?.name, refetch, + // demo functionCalls: [ trackGetTransfers.data, trackSubscribePendingTransactions.data, trackSubscribeOnCrossChainComplete.data, - ], // demo + ], }; }; diff --git a/packages/apps/wallet-sdk-example/src/index.css b/packages/apps/wallet-sdk-example/src/index.css index 081b92ebbd..1e85fef218 100644 --- a/packages/apps/wallet-sdk-example/src/index.css +++ b/packages/apps/wallet-sdk-example/src/index.css @@ -17,25 +17,21 @@ textarea { color: red; } - -button[class^="Button__"] > span[class^="Button__"] { +button[class^='Button__'] > span[class^='Button__'] { margin-inline-start: 16px !important; margin-inline-end: 16px !important; } -button[class^="Button__"][class*="Button_isCompact_false"] { +button[class^='Button__'][class*='Button_isCompact_false'] { margin-top: 20px; } -button[class^="Button__"][class*="Button_isCompact_false"] > span[class^="Button__"] { +button[class^='Button__'][class*='Button_isCompact_false'] + > span[class^='Button__'] { margin-inline-start: 24px !important; margin-inline-end: 24px !important; } -[class*="Divider__"] { - margin-block: 24px!important; -} - -[class*="Dialog__"] { - max-height: inherit!important; +[class*='Divider__'] { + margin-block: 24px !important; } diff --git a/packages/libs/wallet-sdk/src/gql/gql.ts b/packages/libs/wallet-sdk/src/gql/gql.ts index d4b60b8c39..a6c0e497be 100644 --- a/packages/libs/wallet-sdk/src/gql/gql.ts +++ b/packages/libs/wallet-sdk/src/gql/gql.ts @@ -15,9 +15,9 @@ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document- */ const documents = { "\n fragment TransferFields on Transfer {\n amount\n chainId\n orderIndex\n receiverAccount\n requestKey\n senderAccount\n moduleName\n block {\n hash\n height\n creationTime\n }\n transaction {\n cmd {\n networkId\n payload {\n __typename\n ... on ExecutionPayload {\n code\n data\n }\n ... on ContinuationPayload {\n step\n pactId\n }\n }\n signers {\n clist {\n name\n args\n }\n }\n }\n result {\n __typename\n ... on TransactionResult {\n goodResult\n badResult\n events {\n edges {\n node {\n name\n parameters\n }\n }\n }\n }\n }\n }\n }\n": types.TransferFieldsFragmentDoc, - "\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n": types.AccountTransfersDocument, - "\n query accountChainTransfers(\n $accountName: String!\n $chainId: String\n $fungibleName: String\n $first: Int\n ) {\n lastBlockHeight\n transfers(\n accountName: $accountName\n chainId: $chainId\n fungibleName: $fungibleName\n first: $first\n ) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n": types.AccountChainTransfersDocument, - "\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n": types.AccountTransferRequestKeyDocument, + "\n query accountTransfers(\n $accountName: String!\n $fungibleName: String\n $first: Int\n $last: Int\n $before: String\n $after: String\n ) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: $first, last: $last, before: $before, after: $after) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n": types.AccountTransfersDocument, + "\n query accountChainTransfers(\n $accountName: String!\n $chainId: String\n $fungibleName: String\n $first: Int\n $last: Int\n $before: String\n $after: String\n ) {\n lastBlockHeight\n transfers(\n accountName: $accountName\n chainId: $chainId\n fungibleName: $fungibleName\n first: $first\n last: $last\n before: $before\n after: $after\n ) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n": types.AccountChainTransfersDocument, + "\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n": types.AccountTransferRequestKeyDocument, }; /** @@ -41,15 +41,15 @@ export function graphql(source: "\n fragment TransferFields on Transfer {\n /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query accountTransfers($accountName: String!, $fungibleName: String) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: 100) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n"]; +export function graphql(source: "\n query accountTransfers(\n $accountName: String!\n $fungibleName: String\n $first: Int\n $last: Int\n $before: String\n $after: String\n ) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: $first, last: $last, before: $before, after: $after) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query accountTransfers(\n $accountName: String!\n $fungibleName: String\n $first: Int\n $last: Int\n $before: String\n $after: String\n ) {\n lastBlockHeight\n fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) {\n transfers(first: $first, last: $last, before: $before, after: $after) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n query accountChainTransfers(\n $accountName: String!\n $chainId: String\n $fungibleName: String\n $first: Int\n ) {\n lastBlockHeight\n transfers(\n accountName: $accountName\n chainId: $chainId\n fungibleName: $fungibleName\n first: $first\n ) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query accountChainTransfers(\n $accountName: String!\n $chainId: String\n $fungibleName: String\n $first: Int\n ) {\n lastBlockHeight\n transfers(\n accountName: $accountName\n chainId: $chainId\n fungibleName: $fungibleName\n first: $first\n ) {\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n"]; +export function graphql(source: "\n query accountChainTransfers(\n $accountName: String!\n $chainId: String\n $fungibleName: String\n $first: Int\n $last: Int\n $before: String\n $after: String\n ) {\n lastBlockHeight\n transfers(\n accountName: $accountName\n chainId: $chainId\n fungibleName: $fungibleName\n first: $first\n last: $last\n before: $before\n after: $after\n ) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query accountChainTransfers(\n $accountName: String!\n $chainId: String\n $fungibleName: String\n $first: Int\n $last: Int\n $before: String\n $after: String\n ) {\n lastBlockHeight\n transfers(\n accountName: $accountName\n chainId: $chainId\n fungibleName: $fungibleName\n first: $first\n last: $last\n before: $before\n after: $after\n ) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n ...TransferFields\n crossChainTransfer {\n ...TransferFields\n }\n }\n }\n }\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n"): (typeof documents)["\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n"]; +export function graphql(source: "\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n"): (typeof documents)["\n query accountTransferRequestKey($requestKey: String!, $accountName: String) {\n lastBlockHeight\n transfers(requestKey: $requestKey, accountName: $accountName) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n ...TransferFields\n }\n }\n }\n }\n"]; export function graphql(source: string) { return (documents as any)[source] ?? {}; diff --git a/packages/libs/wallet-sdk/src/gql/graphql.ts b/packages/libs/wallet-sdk/src/gql/graphql.ts index 73bcb70015..63cfc14aad 100644 --- a/packages/libs/wallet-sdk/src/gql/graphql.ts +++ b/packages/libs/wallet-sdk/src/gql/graphql.ts @@ -40,10 +40,14 @@ export type TransferFieldsFragment = { __typename?: 'Transfer', amount: any, cha export type AccountTransfersQueryVariables = Exact<{ accountName: Scalars['String']['input']; fungibleName?: InputMaybe; + first?: InputMaybe; + last?: InputMaybe; + before?: InputMaybe; + after?: InputMaybe; }>; -export type AccountTransfersQuery = { __typename?: 'Query', lastBlockHeight?: any | null, fungibleAccount?: { __typename?: 'FungibleAccount', transfers: { __typename?: 'FungibleAccountTransfersConnection', edges: Array<{ __typename?: 'FungibleAccountTransfersConnectionEdge', node: ( +export type AccountTransfersQuery = { __typename?: 'Query', lastBlockHeight?: any | null, fungibleAccount?: { __typename?: 'FungibleAccount', transfers: { __typename?: 'FungibleAccountTransfersConnection', pageInfo: { __typename?: 'PageInfo', startCursor?: string | null, endCursor?: string | null, hasNextPage: boolean, hasPreviousPage: boolean }, edges: Array<{ __typename?: 'FungibleAccountTransfersConnectionEdge', node: ( { __typename?: 'Transfer', crossChainTransfer?: ( { __typename?: 'Transfer' } & { ' $fragmentRefs'?: { 'TransferFieldsFragment': TransferFieldsFragment } } @@ -56,10 +60,13 @@ export type AccountChainTransfersQueryVariables = Exact<{ chainId?: InputMaybe; fungibleName?: InputMaybe; first?: InputMaybe; + last?: InputMaybe; + before?: InputMaybe; + after?: InputMaybe; }>; -export type AccountChainTransfersQuery = { __typename?: 'Query', lastBlockHeight?: any | null, transfers: { __typename?: 'QueryTransfersConnection', edges: Array<{ __typename?: 'QueryTransfersConnectionEdge', node: ( +export type AccountChainTransfersQuery = { __typename?: 'Query', lastBlockHeight?: any | null, transfers: { __typename?: 'QueryTransfersConnection', pageInfo: { __typename?: 'PageInfo', startCursor?: string | null, endCursor?: string | null, hasNextPage: boolean, hasPreviousPage: boolean }, edges: Array<{ __typename?: 'QueryTransfersConnectionEdge', node: ( { __typename?: 'Transfer', crossChainTransfer?: ( { __typename?: 'Transfer' } & { ' $fragmentRefs'?: { 'TransferFieldsFragment': TransferFieldsFragment } } @@ -73,12 +80,12 @@ export type AccountTransferRequestKeyQueryVariables = Exact<{ }>; -export type AccountTransferRequestKeyQuery = { __typename?: 'Query', lastBlockHeight?: any | null, transfers: { __typename?: 'QueryTransfersConnection', edges: Array<{ __typename?: 'QueryTransfersConnectionEdge', node: ( +export type AccountTransferRequestKeyQuery = { __typename?: 'Query', lastBlockHeight?: any | null, transfers: { __typename?: 'QueryTransfersConnection', pageInfo: { __typename?: 'PageInfo', startCursor?: string | null, endCursor?: string | null, hasNextPage: boolean, hasPreviousPage: boolean }, edges: Array<{ __typename?: 'QueryTransfersConnectionEdge', node: ( { __typename?: 'Transfer' } & { ' $fragmentRefs'?: { 'TransferFieldsFragment': TransferFieldsFragment } } ) }> } }; export const TransferFieldsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; -export const AccountTransfersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountTransfers"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"fungibleAccount"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}},{"kind":"Argument","name":{"kind":"Name","value":"fungibleName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"100"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}},{"kind":"Field","name":{"kind":"Name","value":"crossChainTransfer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; -export const AccountChainTransfersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountChainTransfers"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"chainId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}},{"kind":"Argument","name":{"kind":"Name","value":"chainId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"chainId"}}},{"kind":"Argument","name":{"kind":"Name","value":"fungibleName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}}},{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}},{"kind":"Field","name":{"kind":"Name","value":"crossChainTransfer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; -export const AccountTransferRequestKeyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountTransferRequestKey"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"requestKey"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"requestKey"},"value":{"kind":"Variable","name":{"kind":"Name","value":"requestKey"}}},{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file +export const AccountTransfersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountTransfers"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"last"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"before"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"fungibleAccount"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}},{"kind":"Argument","name":{"kind":"Name","value":"fungibleName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"last"},"value":{"kind":"Variable","name":{"kind":"Name","value":"last"}}},{"kind":"Argument","name":{"kind":"Name","value":"before"},"value":{"kind":"Variable","name":{"kind":"Name","value":"before"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}},{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}}]}},{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}},{"kind":"Field","name":{"kind":"Name","value":"crossChainTransfer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; +export const AccountChainTransfersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountChainTransfers"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"chainId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"last"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"before"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}},{"kind":"Argument","name":{"kind":"Name","value":"chainId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"chainId"}}},{"kind":"Argument","name":{"kind":"Name","value":"fungibleName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fungibleName"}}},{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"last"},"value":{"kind":"Variable","name":{"kind":"Name","value":"last"}}},{"kind":"Argument","name":{"kind":"Name","value":"before"},"value":{"kind":"Variable","name":{"kind":"Name","value":"before"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}},{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}}]}},{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}},{"kind":"Field","name":{"kind":"Name","value":"crossChainTransfer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; +export const AccountTransferRequestKeyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"accountTransferRequestKey"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"requestKey"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"lastBlockHeight"}},{"kind":"Field","name":{"kind":"Name","value":"transfers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"requestKey"},"value":{"kind":"Variable","name":{"kind":"Name","value":"requestKey"}}},{"kind":"Argument","name":{"kind":"Name","value":"accountName"},"value":{"kind":"Variable","name":{"kind":"Name","value":"accountName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}},{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}}]}},{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"TransferFields"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"TransferFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Transfer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"amount"}},{"kind":"Field","name":{"kind":"Name","value":"chainId"}},{"kind":"Field","name":{"kind":"Name","value":"orderIndex"}},{"kind":"Field","name":{"kind":"Name","value":"receiverAccount"}},{"kind":"Field","name":{"kind":"Name","value":"requestKey"}},{"kind":"Field","name":{"kind":"Name","value":"senderAccount"}},{"kind":"Field","name":{"kind":"Name","value":"moduleName"}},{"kind":"Field","name":{"kind":"Name","value":"block"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hash"}},{"kind":"Field","name":{"kind":"Name","value":"height"}},{"kind":"Field","name":{"kind":"Name","value":"creationTime"}}]}},{"kind":"Field","name":{"kind":"Name","value":"transaction"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cmd"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"payload"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ExecutionPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"data"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ContinuationPayload"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"step"}},{"kind":"Field","name":{"kind":"Name","value":"pactId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clist"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"args"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"TransactionResult"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"goodResult"}},{"kind":"Field","name":{"kind":"Name","value":"badResult"}},{"kind":"Field","name":{"kind":"Name","value":"events"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"parameters"}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/packages/libs/wallet-sdk/src/sdk/interface.ts b/packages/libs/wallet-sdk/src/sdk/interface.ts index 5b863045bb..e3bb3806b5 100644 --- a/packages/libs/wallet-sdk/src/sdk/interface.ts +++ b/packages/libs/wallet-sdk/src/sdk/interface.ts @@ -58,10 +58,31 @@ export interface IChain { id: ChainId; // Will add later: type: 'pact' | 'evm' } -export type Transfer = ISameChainTransfer | ICrossChainTransfer; +export type ITransfer = ISameChainTransfer | ICrossChainTransfer; -export type CreateTransfer = Parameters[0]; -export type CreateCrossChainTransfer = Parameters< +export interface ITransferOptions { + accountName: string; + networkId: string; + fungibleName?: string; + chainId?: ChainId; + first?: number; + after?: string; + before?: string; + last?: number; +} + +export interface ITransferResponse { + transfers: ITransfer[]; + pageInfo: { + hasNextPage: boolean; + hasPreviousPage: boolean; + startCursor: string | null; + endCursor: string | null; + }; +} + +export type ICreateTransfer = Parameters[0]; +export type ICreateCrossChainTransfer = Parameters< typeof createCrossChainCommand >[0]; export interface IAccountDetails { @@ -107,6 +128,6 @@ export interface INetworkInfo { nodeVersion: string; } -export type NodeChainInfo = Pick; +export type INodeChainInfo = Pick; -export type NodeNetworkInfo = Omit; +export type INodeNetworkInfo = Omit; diff --git a/packages/libs/wallet-sdk/src/sdk/tests/getTransfers.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/getTransfers.test.ts index 80c932b223..3bd3ee4afa 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/getTransfers.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/getTransfers.test.ts @@ -3,13 +3,14 @@ import { walletSdk } from '../walletSdk.js'; describe('getTransfers', () => { test('runs', async () => { - const result = await walletSdk.getTransfers( - 'k:2017fee3fb15cfe840e5ed34bf101cc7d5579ffdd20dea09e32fd77c1757f946', - 'testnet04', - ); + const result = await walletSdk.getTransfers({ + accountName: + 'k:2017fee3fb15cfe840e5ed34bf101cc7d5579ffdd20dea09e32fd77c1757f946', + networkId: 'testnet04', + }); // console.log(result); - const transfer = result.filter( + const transfer = result.transfers.filter( (x) => x.requestKey === 'FVw93gHbAURTTI74-gbwvTY8AQFA7pd9mfr6obB8SMY', ); console.log(transfer); @@ -56,7 +57,7 @@ describe('getTransfers', () => { }, ]); - const transfer2 = result.filter( + const transfer2 = result.transfers.filter( (x) => x.requestKey === 'KeasLpaJQUUAB_ROeHChuv-yW8hmM0NlMKM1ht5nb1k', ); console.log('transfer2', transfer2); diff --git a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts index 3adfa8d782..e6b783edf0 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from 'vitest'; import { parseGqlTransfers } from '../../services/graphql/transfer.util'; -import type { Transfer } from '../interface'; +import type { ITransfer } from '../interface'; const GQL_TRANSFER_XCHAIN_FINISH = [ { @@ -175,7 +175,7 @@ describe('getTransfers', () => { requestKey: 'UXkFsj8hFBZ4wNZBqw12HZ7mSlpHqyrg1VP2nfSdR4k', success: true, }, - } as Transfer, + } as ITransfer, ]); }); }); diff --git a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx index 101d4bfdf1..c295f82c58 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx +++ b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx @@ -1,6 +1,6 @@ import { describe, expect, test } from 'vitest'; import { parseGqlTransfers } from '../../services/graphql/transfer.util'; -import type { Transfer } from '../interface'; +import type { ITransfer } from '../interface'; const TRANSFER_XCHAIN_SEND = [ { @@ -282,7 +282,7 @@ describe('getTransfers', () => { success: true, token: 'coin', }, - } as Transfer, + } as ITransfer, ]); }); }); diff --git a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts index a2f34d71e3..77fda94bee 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from 'vitest'; import { parseGqlTransfers } from '../../services/graphql/transfer.util'; -import type { Transfer } from '../interface'; +import type { ITransfer } from '../interface'; const TRANSFER_XCHAIN_SEND = [ { @@ -208,7 +208,7 @@ describe('getTransfers', () => { success: true, token: 'coin', }, - } as Transfer, + } as ITransfer, ]); }); }); diff --git a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts index ce574631f2..200531b9aa 100644 --- a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts +++ b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts @@ -29,16 +29,17 @@ import { defaultGraphqlHostGenerator, } from './host.js'; import type { - CreateCrossChainTransfer, - CreateTransfer, IAccountDetails, IChain, + ICreateCrossChainTransfer, + ICreateTransfer, ICrossChainTransfer, INetworkInfo, + INodeChainInfo, + INodeNetworkInfo, ITransactionDescriptor, - NodeChainInfo, - NodeNetworkInfo, - Transfer, + ITransferOptions, + ITransferResponse, } from './interface.js'; import { KadenaNames } from './kadenaNames.js'; import type { ILogTransport, LogLevel } from './logger.js'; @@ -128,7 +129,7 @@ export class WalletSDK { /** create transfer that accepts any kind of account (requires keys/pred) */ public createTransfer( - transfer: CreateTransfer & { networkId: string }, + transfer: ICreateTransfer & { networkId: string }, ): IUnsignedCommand { const command = transferCreateCommand(transfer)(); return createTransaction({ @@ -139,7 +140,7 @@ export class WalletSDK { /** create cross-chain transfer */ public createCrossChainTransfer( - transfer: CreateCrossChainTransfer & { networkId: string }, + transfer: ICreateCrossChainTransfer & { networkId: string }, ): IUnsignedCommand { const command = createCrossChainCommand(transfer)(); return createTransaction({ @@ -170,16 +171,13 @@ export class WalletSDK { } public async getTransfers( - accountName: string, - networkId: string, - fungible?: string, - chainId?: ChainId, - ): Promise { - const url = this.getGraphqlUrl({ networkId }); - if (chainId) { - return getChainTransfers(url, accountName, chainId, fungible); + options: ITransferOptions, + ): Promise { + const url = this.getGraphqlUrl({ networkId: options.networkId }); + if (options.chainId) { + return getChainTransfers(url, options); } - return getTransfers(url, accountName, fungible); + return getTransfers(url, options); } public subscribeOnCrossChainComplete( @@ -355,22 +353,21 @@ export class WalletSDK { return accountDetailsList; } catch (error) { - this.logger.error(`Error in fetching account details: ${error.message}`, { - error, - }); - throw new Error(`Failed to get account details for ${accountName}`); + throw new Error( + `Failed to get account details for "${accountName}": ${error.message}`, + ); } } public async getChains(networkHost: string): Promise { const res = await fetch(`${networkHost}/info`); - const json: NodeChainInfo = await res.json(); + const json: INodeChainInfo = await res.json(); const chains = json.nodeChains ?? []; return chains.map((c) => ({ id: c as ChainId })); } - public async getNetworkInfo(networkHost: string): Promise { + public async getNetworkInfo(networkHost: string): Promise { const res = await fetch(`${networkHost}/info`); const json: INetworkInfo = await res.json(); @@ -378,7 +375,7 @@ export class WalletSDK { // eslint-disable-next-line @typescript-eslint/no-unused-vars nodeChains = [], ...networkInfo - }: NodeNetworkInfo & { nodeChains: string[] } = json; + }: INodeNetworkInfo & { nodeChains: string[] } = json; return networkInfo; } diff --git a/packages/libs/wallet-sdk/src/services/graphql/getChainTransfers.ts b/packages/libs/wallet-sdk/src/services/graphql/getChainTransfers.ts index ee89076560..7ff35773ac 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/getChainTransfers.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/getChainTransfers.ts @@ -1,47 +1,72 @@ import { createClient, fetchExchange } from '@urql/core'; -import type { Transfer } from '../../sdk/interface.js'; +import type { + ITransferOptions, + ITransferResponse, +} from '../../sdk/interface.js'; import { ACCOUNT_CHAIN_TRANSFER_QUERY } from './transfer.query.js'; import type { GqlTransfer } from './transfer.util.js'; import { parseGqlTransfers } from './transfer.util.js'; async function fetchChainTransfers( graphqlUrl: string, - accountName: string, - chainId: string, - fungibleName?: string, + options: ITransferOptions, ) { const client = createClient({ url: graphqlUrl, exchanges: [fetchExchange] }); const result = await client - .query(ACCOUNT_CHAIN_TRANSFER_QUERY, { accountName, fungibleName, chainId }) + .query(ACCOUNT_CHAIN_TRANSFER_QUERY, { + accountName: options.accountName, + fungibleName: options.fungibleName, + chainId: options.chainId, + first: options.first, + last: options.last, + before: options.before, + after: options.after, + }) .toPromise(); - const nodes = result.data?.transfers.edges.map( + if (!result.data || !result.data.transfers) { + // TODO: throw error instead? + return { + transfers: [], + pageInfo: { hasNextPage: false, hasPreviousPage: false }, + lastBlockHeight: 0, + }; + } + + const nodes = result.data.transfers.edges.map( (edge) => edge.node as GqlTransfer, ); return { - transfers: nodes ?? [], - lastBlockHeight: (result.data?.lastBlockHeight ?? null) as number | null, + transfers: nodes, + pageInfo: result.data.transfers.pageInfo, + lastBlockHeight: (result.data.lastBlockHeight ?? null) as number | null, }; } // Currently queries all chains export async function getChainTransfers( graphqlUrl: string, - accountName: string, - chainId: string, - fungibleName?: string, -): Promise { - const { transfers: nodes, lastBlockHeight } = await fetchChainTransfers( - graphqlUrl, - accountName, - chainId, - fungibleName, - ); - return parseGqlTransfers( + options: ITransferOptions, +): Promise { + const { + transfers: nodes, + pageInfo, + lastBlockHeight, + } = await fetchChainTransfers(graphqlUrl, options); + const transfers = parseGqlTransfers( nodes, lastBlockHeight ?? 0, - accountName, - fungibleName, + options.accountName, + options.fungibleName, ); + return { + transfers, + pageInfo: { + hasNextPage: pageInfo.hasNextPage, + hasPreviousPage: pageInfo.hasPreviousPage, + startCursor: pageInfo.startCursor ?? null, + endCursor: pageInfo.endCursor ?? null, + }, + }; } diff --git a/packages/libs/wallet-sdk/src/services/graphql/getTransfers.ts b/packages/libs/wallet-sdk/src/services/graphql/getTransfers.ts index bb65f0ad72..bbf73d5449 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/getTransfers.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/getTransfers.ts @@ -1,25 +1,41 @@ import { createClient, fetchExchange } from '@urql/core'; -import type { Transfer } from '../../sdk/interface.js'; +import type { + ITransferOptions, + ITransferResponse, +} from '../../sdk/interface.js'; import { ACCOUNT_TRANSFER_QUERY } from './transfer.query.js'; import type { GqlTransfer } from './transfer.util.js'; import { parseGqlTransfers } from './transfer.util.js'; -async function fetchTransfers( - graphqlUrl: string, - accountName: string, - fungibleName?: string, -) { +async function fetchTransfers(graphqlUrl: string, options: ITransferOptions) { const client = createClient({ url: graphqlUrl, exchanges: [fetchExchange] }); const result = await client - .query(ACCOUNT_TRANSFER_QUERY, { accountName, fungibleName }) + .query(ACCOUNT_TRANSFER_QUERY, { + accountName: options.accountName, + fungibleName: options.fungibleName, + first: options.first, + last: options.last, + before: options.before, + after: options.after, + }) .toPromise(); - const nodes = result.data?.fungibleAccount?.transfers.edges.map( + if (!result.data || !result.data.fungibleAccount) { + // TODO: throw error instead? + return { + transfers: [], + pageInfo: { hasNextPage: false, hasPreviousPage: false }, + lastBlockHeight: 0, + }; + } + + const transfers = result.data.fungibleAccount.transfers.edges.map( (edge) => edge.node as GqlTransfer, ); return { - transfers: nodes ?? [], + transfers, + pageInfo: result.data.fungibleAccount.transfers.pageInfo, lastBlockHeight: (result.data?.lastBlockHeight ?? null) as number | null, }; } @@ -27,18 +43,26 @@ async function fetchTransfers( // Currently queries all chains export async function getTransfers( graphqlUrl: string, - accountName: string, - fungibleName?: string, -): Promise { - const { transfers: nodes, lastBlockHeight } = await fetchTransfers( - graphqlUrl, - accountName, - fungibleName, - ); - return parseGqlTransfers( + options: ITransferOptions, +): Promise { + const { + transfers: nodes, + pageInfo, + lastBlockHeight, + } = await fetchTransfers(graphqlUrl, options); + const transfers = parseGqlTransfers( nodes, lastBlockHeight ?? 0, - accountName, - fungibleName, + options.accountName, + options.fungibleName, ); + return { + transfers, + pageInfo: { + hasNextPage: pageInfo.hasNextPage, + hasPreviousPage: pageInfo.hasPreviousPage, + startCursor: pageInfo.startCursor ?? null, + endCursor: pageInfo.endCursor ?? null, + }, + }; } diff --git a/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts b/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts index 3cf744b76b..4b06fb21f4 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts @@ -1,5 +1,5 @@ import { createClient, fetchExchange } from '@urql/core'; -import type { Transfer } from '../../sdk/interface'; +import type { ITransfer } from '../../sdk/interface'; import type { Logger } from '../../sdk/logger'; import { TRANSFER_REQUESTKEY_QUERY } from './transfer.query'; import type { GqlTransfer } from './transfer.util'; @@ -60,6 +60,6 @@ export async function pollGraphqlTransfers({ } return acc; }, - {} as Record, + {} as Record, ); } diff --git a/packages/libs/wallet-sdk/src/services/graphql/transfer.query.ts b/packages/libs/wallet-sdk/src/services/graphql/transfer.query.ts index b81a44d1d8..468f0f0d28 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/transfer.query.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/transfer.query.ts @@ -55,10 +55,23 @@ export const TRANSFER_FIELDS_FRAGMENT = graphql(` `); export const ACCOUNT_TRANSFER_QUERY = graphql(` - query accountTransfers($accountName: String!, $fungibleName: String) { + query accountTransfers( + $accountName: String! + $fungibleName: String + $first: Int + $last: Int + $before: String + $after: String + ) { lastBlockHeight fungibleAccount(accountName: $accountName, fungibleName: $fungibleName) { - transfers(first: 100) { + transfers(first: $first, last: $last, before: $before, after: $after) { + pageInfo { + startCursor + endCursor + hasNextPage + hasPreviousPage + } edges { node { ...TransferFields @@ -78,6 +91,9 @@ export const ACCOUNT_CHAIN_TRANSFER_QUERY = graphql(` $chainId: String $fungibleName: String $first: Int + $last: Int + $before: String + $after: String ) { lastBlockHeight transfers( @@ -85,7 +101,16 @@ export const ACCOUNT_CHAIN_TRANSFER_QUERY = graphql(` chainId: $chainId fungibleName: $fungibleName first: $first + last: $last + before: $before + after: $after ) { + pageInfo { + startCursor + endCursor + hasNextPage + hasPreviousPage + } edges { node { ...TransferFields @@ -102,6 +127,12 @@ export const TRANSFER_REQUESTKEY_QUERY = graphql(` query accountTransferRequestKey($requestKey: String!, $accountName: String) { lastBlockHeight transfers(requestKey: $requestKey, accountName: $accountName) { + pageInfo { + startCursor + endCursor + hasNextPage + hasPreviousPage + } edges { node { ...TransferFields diff --git a/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts b/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts index 8b87ee32fa..0239c2c6e9 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts @@ -1,6 +1,6 @@ import type { ChainId } from '@kadena/types'; import type { TransferFieldsFragment } from '../../gql/graphql'; -import type { Transfer } from '../../sdk/interface'; +import type { ITransfer } from '../../sdk/interface'; import { parsePactNumber } from '../../utils/pact.util'; import { safeJsonParse } from '../../utils/string.util'; import { isEmpty, notEmpty } from '../../utils/typeUtils'; @@ -150,7 +150,7 @@ const getCrossChainTransferFinish = (transfer: GqlTransferParsed) => { const mapBaseTransfer = ( gqlTransfer: GqlTransferParsed, lastBlockHeight: number, -): Transfer => { +): ITransfer => { return { amount: gqlTransfer.amount, chainId: String(gqlTransfer.chainId) as ChainId, @@ -175,13 +175,13 @@ export const gqlTransferToTransfer = ( _accountName: string, lastBlockHeight: number, fungibleName?: string, -): Transfer | null => { +): ITransfer | null => { const gqlTransfer = parseTransfer(rawGqlTransfer, fungibleName); const xChainStart = getCrossChainTransferStart(gqlTransfer); const xChainFinish = getCrossChainTransferFinish(gqlTransfer); if (xChainStart) { - const result: Transfer = { + const result: ITransfer = { ...mapBaseTransfer(gqlTransfer, lastBlockHeight), isCrossChainTransfer: true, targetChainId: xChainStart.targetChainId, @@ -221,7 +221,7 @@ export function parseGqlTransfers( lastBlockHeight: number, accountName: string, fungibleName?: string, -): Transfer[] { +): ITransfer[] { const grouped = nodes.reduce( (acc, node) => { const key = node.requestKey; @@ -262,7 +262,7 @@ export function parseGqlTransfers( fungibleName, ); if (!transactionFeeTransfer) return []; - const transfer: Transfer = { + const transfer: ITransfer = { ...transactionFeeTransfer, receiverAccount: String(transferCap[1]), // Could technically be different from the value used in payload.code @@ -302,14 +302,14 @@ export function parseGqlTransfers( isBulkTransfer: transfers.length > 1, } : undefined, - } as Transfer; + } as ITransfer; }); }); return mapped.filter(notEmpty); } -export function isSameTransfer(transferA: Transfer, transferB: Transfer) { +export function isSameTransfer(transferA: ITransfer, transferB: ITransfer) { const isSameBaseTransfer = transferA.requestKey === transferB.requestKey && transferA.chainId === transferB.chainId && From 998a95a3aaab8c276f635e4aec97b1f4bc8e895d Mon Sep 17 00:00:00 2001 From: Nillo Date: Thu, 5 Dec 2024 22:12:43 +0100 Subject: [PATCH 070/103] updated readme --- packages/libs/wallet-sdk/README.md | 129 +++++++++++------- packages/libs/wallet-sdk/src/sdk/walletSdk.ts | 3 +- 2 files changed, 81 insertions(+), 51 deletions(-) diff --git a/packages/libs/wallet-sdk/README.md b/packages/libs/wallet-sdk/README.md index 5d149a576b..fd7d04e35a 100644 --- a/packages/libs/wallet-sdk/README.md +++ b/packages/libs/wallet-sdk/README.md @@ -1,5 +1,3 @@ - - # @kadena/wallet-sdk # Kadena Wallet SDK Documentation @@ -155,6 +153,11 @@ const transactionDescriptor = await walletSdk.sendTransaction( 'testnet04', '1', ); + +console.log( + 'Transaction sent with request key:', + transactionDescriptor.requestKey, +); ``` #### `createTransfer` @@ -208,6 +211,11 @@ const transactionDescriptor = await walletSdk.sendTransaction( 'testnet04', '1', ); + +console.log( + 'Transaction sent with request key:', + transactionDescriptor.requestKey, +); ``` #### `createCrossChainTransfer` @@ -262,6 +270,11 @@ const transactionDescriptor = await walletSdk.sendTransaction( 'testnet04', '0', // Source chain ID ); + +console.log( + 'Cross-chain transaction sent with request key:', + transactionDescriptor.requestKey, +); ``` #### `createFinishCrossChainTransfer` @@ -272,7 +285,10 @@ complete the transfer on the target chain. **Method Signature:** ```typescript -createFinishCrossChainTransfer(transfer: CreateFinishCrossChainTransfer): IUnsignedCommand; +createFinishCrossChainTransfer( + transfer: ICreateCrossChainFinishInput, + gasPayer: { account: string; publicKeys: ISigner[] }, +): Promise; ``` **Parameters:** @@ -286,25 +302,35 @@ createFinishCrossChainTransfer(transfer: CreateFinishCrossChainTransfer): IUnsig - `networkId`: `string` - The network ID. - `receiver`: `string` - Receiver's account name. - `receiverGuard`: `IGuard` - Optional guard for the receiver's account. +- `gasPayer`: An object containing: + - `account`: `string` - The account that will pay for the gas fees. + - `publicKeys`: `ISigner[]` - The public keys associated with the gas payer's + account. **Returns:** -- `IUnsignedCommand`: An unsigned transaction command ready to be signed and - sent. +- `Promise`: An unsigned transaction command ready to be + signed and sent. **Example:** ```typescript -const unsignedTransaction = walletSdk.createFinishCrossChainTransfer({ - proof: 'spvProofString', - requestKey: 'initialRequestKey', - fromChainId: '0', - toChainId: '1', - networkId: 'testnet04', - receiver: 'receiverAccount', - // Optional receiver guard - // receiverGuard: { keys: ['receiverPublicKey'], pred: 'keys-all' }, -}); +const unsignedTransaction = await walletSdk.createFinishCrossChainTransfer( + { + proof: 'spvProofString', + requestKey: 'initialRequestKey', + fromChainId: '0', + toChainId: '1', + networkId: 'testnet04', + receiver: 'receiverAccount', + // Optional receiver guard + // receiverGuard: { keys: ['receiverPublicKey'], pred: 'keys-all' }, + }, + { + account: 'gasPayerAccount', + publicKeys: ['gasPayerPublicKey1', 'gasPayerPublicKey2'], + }, +); // Sign the transaction // const signedTransaction = signTransaction(unsignedTransaction); @@ -315,6 +341,11 @@ const transactionDescriptor = await walletSdk.sendTransaction( 'testnet04', '1', // Target chain ID ); + +console.log( + 'Finishing cross-chain transaction sent with request key:', + transactionDescriptor.requestKey, +); ``` #### `sendTransaction` @@ -372,7 +403,7 @@ getTransfers( accountName: string, networkId: string, fungible?: string, - chainsIds?: ChainId[], + chainId?: ChainId, ): Promise; ``` @@ -382,7 +413,7 @@ getTransfers( `'k:accountPublicKey'`). - `networkId`: `string` - The network ID. - `fungible?`: `string` - Optional fungible token name (defaults to `'coin'`). -- `chainsIds?`: `ChainId[]` - Optional list of chain IDs to query. +- `chainId?`: `ChainId` - Optional chain ID to filter transfers. **Returns:** @@ -412,18 +443,20 @@ Subscribes to cross-chain transfer completion events. ```typescript subscribeOnCrossChainComplete( - transfers: ITransactionDescriptor[], - callback: (transfer: Transfer) => void, + accountName: string, + transfers: ICrossChainTransfer[], + callback: (transfer: ICrossChainTransfer) => void, options?: { signal?: AbortSignal }, ): void; ``` **Parameters:** -- `transfers`: `ITransactionDescriptor[]` - An array of transaction descriptors - representing the cross-chain transfers to monitor. -- `callback`: `(transfer: Transfer) => void` - A function to call when a - transfer completes. +- `accountName`: `string` - The account name associated with the transfers. +- `transfers`: `ICrossChainTransfer[]` - An array of cross-chain transfer + objects to monitor. +- `callback`: `(transfer: ICrossChainTransfer) => void` - A function to call + when a transfer completes. - `options?`: `{ signal?: AbortSignal }` - Optional settings, including an `AbortSignal` to cancel the subscription. @@ -431,7 +464,8 @@ subscribeOnCrossChainComplete( ```typescript walletSdk.subscribeOnCrossChainComplete( - [crossChainTransactionDescriptor], + 'senderAccount', + [crossChainTransfer1, crossChainTransfer2], (transfer) => { console.log('Cross-chain transfer completed:', transfer); }, @@ -487,7 +521,12 @@ subscribePendingTransactions( transaction: ITransactionDescriptor, result: ResponseResult, ) => void, - options?: { signal?: AbortSignal }, + options?: { + signal?: AbortSignal; + confirmationDepth?: number; + timeoutSeconds?: number; + intervalMs?: number; + }, ): void; ``` @@ -498,8 +537,14 @@ subscribePendingTransactions( - `callback`: `(transaction: ITransactionDescriptor, result: ResponseResult) => void` - A function to call when a transaction status updates. -- `options?`: `{ signal?: AbortSignal }` - Optional settings, including an - `AbortSignal`. +- `options?`: + - `signal?: AbortSignal` - Optional signal to abort the subscription. + - `confirmationDepth?: number` - Optional number of confirmations to wait for + (default is `1`). + - `timeoutSeconds?: number` - Optional timeout in seconds (default is `60` or + based on `confirmationDepth`). + - `intervalMs?: number` - Optional polling interval in milliseconds (default + is `1000`). **Example:** @@ -516,6 +561,11 @@ walletSdk.subscribePendingTransactions( ); } }, + { + confirmationDepth: 2, + timeoutSeconds: 300, + intervalMs: 2000, + }, ); ``` @@ -608,13 +658,12 @@ chains.forEach((chain) => { ### `getNetworkInfo` -Retrieves network information. _(Note: Currently returns `null` as this method -is a placeholder for future implementation.)_ +Retrieves network information. **Method Signature:** ```typescript -getNetworkInfo(networkHost: string): Promise; +getNetworkInfo(networkHost: string): Promise; ``` **Parameters:** @@ -623,7 +672,7 @@ getNetworkInfo(networkHost: string): Promise; **Returns:** -- `Promise`: A promise that resolves to network information. +- `Promise`: A promise that resolves to network information. **Example:** @@ -788,24 +837,6 @@ if (name) { --- -## Conclusion - -The Kadena Wallet SDK offers a comprehensive set of tools to integrate Kadena -blockchain functionalities into your wallet applications easily. Designed with -developers in mind, it ensures that even those with intermediate experience can -build robust wallets without delving into the complexities of blockchain -interactions. - -By providing clear methods with well-defined parameters, the SDK simplifies -tasks such as transaction creation, account querying, and handling cross-chain -transfers. With the Kadena Wallet SDK, building wallets on Kadena is as clear as -day. - -For more information and advanced usage, please refer to the SDK documentation -and explore the various classes and methods provided. - ---- - ## Happy Coding! With the Kadena Wallet SDK and Kadena HD Wallet, you're well-equipped to build diff --git a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts index 200531b9aa..a89e761ea0 100644 --- a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts +++ b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts @@ -164,7 +164,6 @@ export class WalletSDK { networkId: string, chainId: ChainId, ): Promise { - // const parsed = JSON.parse(transaction.cmd); // unused const host = this.getChainwebUrl({ networkId, chainId }); const result = await createClient(() => host).submitOne(transaction); return result; @@ -174,7 +173,7 @@ export class WalletSDK { options: ITransferOptions, ): Promise { const url = this.getGraphqlUrl({ networkId: options.networkId }); - if (options.chainId) { + if (options.chainId !== undefined) { return getChainTransfers(url, options); } return getTransfers(url, options); From cbc889462f5696927b7ef0ea43651b10df2871d5 Mon Sep 17 00:00:00 2001 From: Nillo Date: Thu, 5 Dec 2024 22:18:28 +0100 Subject: [PATCH 071/103] chore(wallet-sdk): updated readme --- packages/libs/wallet-sdk/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/libs/wallet-sdk/README.md b/packages/libs/wallet-sdk/README.md index fd7d04e35a..ff6c158af8 100644 --- a/packages/libs/wallet-sdk/README.md +++ b/packages/libs/wallet-sdk/README.md @@ -12,7 +12,7 @@ integrations. For key generation and signing functionalities, you will need the Kadena HD Wallet package. Please refer to the -[Kadena HD Wallet documentation](https://github.com/kadena-io/kadena.js/tree/master/packages/hdwallet) +[Kadena HD Wallet documentation](https://github.com/kadena-community/kadena.js/tree/main/packages/libs/hd-wallet) for detailed instructions on how to generate keys and sign transactions securely. @@ -46,7 +46,6 @@ securely. - [Kadena Names Service](#kadena-names-service) - [`nameToAddress`](#nametoaddress) - [`addressToName`](#addresstoname) -- [Conclusion](#conclusion) - [Additional Resources](#additional-resources) --- From 0fa98b93afb3c91b7ddb3080d62f3c8fcf6bbee3 Mon Sep 17 00:00:00 2001 From: Nillo Date: Thu, 5 Dec 2024 23:27:32 +0100 Subject: [PATCH 072/103] chore(wallet-sdk/walletsdk-example): updated readme --- packages/apps/wallet-sdk-example/README.md | 198 +++++++++++++----- packages/apps/wallet-sdk-example/package.json | 2 +- packages/libs/wallet-sdk/README.md | 16 ++ 3 files changed, 165 insertions(+), 51 deletions(-) diff --git a/packages/apps/wallet-sdk-example/README.md b/packages/apps/wallet-sdk-example/README.md index 74872fd4af..9ec1fe80fe 100644 --- a/packages/apps/wallet-sdk-example/README.md +++ b/packages/apps/wallet-sdk-example/README.md @@ -1,50 +1,148 @@ -# React + TypeScript + Vite - -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. - -Currently, two official plugins are available: - -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh - -## Expanding the ESLint configuration - -If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: - -- Configure the top-level `parserOptions` property like this: - -```js -export default tseslint.config({ - languageOptions: { - // other options... - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - }, -}) -``` - -- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked` -- Optionally add `...tseslint.configs.stylisticTypeChecked` -- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config: - -```js -// eslint.config.js -import react from 'eslint-plugin-react' - -export default tseslint.config({ - // Set the react version - settings: { react: { version: '18.3' } }, - plugins: { - // Add the react plugin - react, - }, - rules: { - // other rules... - // Enable its recommended rules - ...react.configs.recommended.rules, - ...react.configs['jsx-runtime'].rules, - }, -}) -``` +# Wallet SDK Example App + +The Wallet SDK Example App is a comprehensive showcase of the features and +capabilities of the +[Kadena Wallet SDK](https://github.com/kadena-community/kadena.js/tree/feat/wallet-sdk-interface/packages/libs/wallet-sdk). +This app is designed to provide developers with an interactive platform to +explore, understand, and experiment with every function of the SDK. + +## **Features** + +- **Function Demonstrations**: Every function of the Wallet SDK is demonstrated, + including examples of: + + - Transaction creation. + - Account querying. + - Transfers + - Cross-chain transfers. + - Gas estimation. + - Human Readible Name Resolving + +- **Live Code Execution**: Each function displays: + - The code being executed. + - The real-time response from the Kadena network. + - The real-time response from the Kadena Graph +- **Code Highlighter**: Interactive code snippets are highlighted for better + understanding. +- **Step-by-Step Guidance**: Navigate the app to learn how to implement each + feature of the Wallet SDK. + +--- + +## **Getting Started** + +### **Prerequisites** + +Ensure you have the following installed: + +- **Node.js** (v16 or later) +- **Yarn** or **npm** +- A modern browser (Chrome, Firefox, etc.) + +### **Installation** + +1. Clone the repository: + + ```bash + git clone https://github.com/kadena-community/kadena.js.git + cd kadena.js/packages/apps/wallet-sdk-example + ``` + +2. Install dependencies: + + ```bash + npm install + # or + yarn install + # or + pnpm install + ``` + +3. Start the development server: + + ```bash + npm run dev + # or + yarn dev + # or + pnpm run dev + ``` + +4. Open the app in your browser: + ```bash + http://localhost:3000 + ``` + +--- + +## **Usage** + +1. Launch the app in your browser. +2. Explore the features: + - Select a option from the navigation menu. + - View the code example and corresponding response. + - Modify inputs (where applicable) to test custom scenarios. +3. Use the app as a guide to integrate Wallet SDK functions into your own + projects. + +--- + +## **Technical Details** + +This app is built using: + +- **React** for the UI. +- **TypeScript** for type safety. +- **Vite** for fast builds and development. +- **Kadena Wallet SDK** for blockchain interactions. + +--- + +## **Development** + +To extend or modify or play with the app: + +1. Open the project in your favorite IDE. +2. Navigate to the `src` folder to explore the codebase: + - `components/`: Reusable React components. + - `pages/`: Main pages showcasing the SDK functions. + - `utils/`: Utility functions for interacting with the SDK. +3. Add new features or update existing examples as needed. + +--- + +## **Contributing** + +Contributions are welcome! If you'd like to improve the app or add new features, +please: + +1. Fork the repository. +2. Create a new branch: + ```bash + git checkout -b feature/your-feature-name + ``` +3. Commit your changes: + ```bash + git commit -m "Add your feature" + ``` +4. Push your changes and create a pull request. + +--- + +## **License** + +This project is licensed under the BSD 3-Clause License. See the +[LICENSE](https://github.com/kadena-community/kadena.js/LICENSE) file for +details. + +--- + +## **Resources** + +- [Kadena Wallet SDK Documentation](https://github.com/kadena-community/kadena.js/tree/feat/wallet-sdk-interface/packages/libs/wallet-sdk/README.md) +- [Kadena Official Documentation](https://docs.kadena.io/) +- [Kadena GitHub Repository](https://github.com/kadena-io/) + +--- + +Happy coding! 🎉 diff --git a/packages/apps/wallet-sdk-example/package.json b/packages/apps/wallet-sdk-example/package.json index ecbdc46f63..f372794c55 100644 --- a/packages/apps/wallet-sdk-example/package.json +++ b/packages/apps/wallet-sdk-example/package.json @@ -1,5 +1,5 @@ { - "name": "wallet-sdk-example", + "name": "wallet-sdk-example-app", "version": "0.0.1", "private": true, "type": "module", diff --git a/packages/libs/wallet-sdk/README.md b/packages/libs/wallet-sdk/README.md index ff6c158af8..dfc48ae7ba 100644 --- a/packages/libs/wallet-sdk/README.md +++ b/packages/libs/wallet-sdk/README.md @@ -836,6 +836,22 @@ if (name) { --- +### **Introduction Text for Wallet SDK Documentation** + +To explore the capabilities of the Kadena Wallet SDK in action, check out the +[Wallet SDK Example App](https://github.com/kadena-community/kadena.js/tree/feat/wallet-sdk-interface/packages/apps/wallet-sdk-example). +This example app demonstrates every function available in the SDK. It +highlights: + +- **Usage Examples**: See how each function is implemented with real-time code + execution. +- **Code Previews**: A code highlighter showcases the function being called, the + code executed, and its response. +- **Interactive Learning**: Learn the SDK features step-by-step while seeing the + immediate effects. + +--- + ## Happy Coding! With the Kadena Wallet SDK and Kadena HD Wallet, you're well-equipped to build From 18ad63166e76c274b60488e88c35d2937ca6e795 Mon Sep 17 00:00:00 2001 From: de-nial-lo Date: Thu, 5 Dec 2024 23:30:02 +0100 Subject: [PATCH 073/103] Update README.md --- packages/apps/wallet-sdk-example/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/apps/wallet-sdk-example/README.md b/packages/apps/wallet-sdk-example/README.md index 9ec1fe80fe..5f1953d3c6 100644 --- a/packages/apps/wallet-sdk-example/README.md +++ b/packages/apps/wallet-sdk-example/README.md @@ -1,8 +1,8 @@ # Wallet SDK Example App The Wallet SDK Example App is a comprehensive showcase of the features and -capabilities of the -[Kadena Wallet SDK](https://github.com/kadena-community/kadena.js/tree/feat/wallet-sdk-interface/packages/libs/wallet-sdk). +capabilities of the +[Kadena Wallet SDK](https://github.com/kadena-community/kadena.js/blob/main/packages/libs/wallet-sdk). This app is designed to provide developers with an interactive platform to explore, understand, and experiment with every function of the SDK. From a93c8a8ec254d6a804291219442fa3cb1f658b37 Mon Sep 17 00:00:00 2001 From: Nillo Date: Fri, 6 Dec 2024 00:02:26 +0100 Subject: [PATCH 074/103] chore(wallet-sdk-example): bug fix showing wrong data / updated in apps docs / updated sdk readme link --- packages/apps/wallet-sdk-example/src/docs.md | 198 +++++++++--------- .../wallet-sdk-example/src/pages/Transfer.tsx | 4 +- packages/libs/wallet-sdk/README.md | 2 +- 3 files changed, 105 insertions(+), 99 deletions(-) diff --git a/packages/apps/wallet-sdk-example/src/docs.md b/packages/apps/wallet-sdk-example/src/docs.md index 7b1367fc8b..2b13b1f11d 100644 --- a/packages/apps/wallet-sdk-example/src/docs.md +++ b/packages/apps/wallet-sdk-example/src/docs.md @@ -1,9 +1,16 @@ Welcome to the Example Wallet App! This wallet application leverages the robust -capabilities of **Kadena Wallet SDK** to provide a seamless and secure -experience for managing your blockchain assets. Designed with UI building blocks -of **Kadena Kode-UI** with user-friendliness and advanced functionality in mind, -our wallet ensures that you can effortlessly interact with the Kadena network -while enjoying a feature-rich interface. +capabilities of: + +## **[Kadena Wallet SDK](https://github.com/kadena-community/kadena.js/tree/main/packages/libs/wallet-sdk)** + +to provide a seamless and secure experience for managing your blockchain assets. +Designed with UI building blocks of: + +## **[Kadena Kode-UI](https://github.com/kadena-community/kadena.js/tree/main/packages/libs/kode-ui)** + +with user-friendliness and advanced functionality in mind, our wallet ensures +that you can effortlessly interact with the Kadena network while enjoying a +feature-rich interface. The Kadena Wallet SDK provides a simple and unified interface to integrate Kadena blockchain functionalities into your wallet applications. It abstracts @@ -11,70 +18,19 @@ the complexities of interacting with the Kadena network, allowing you to focus on building feature-rich wallet experiences without re-implementing common integrations. ---- - **Important Note on Key Generation and Signing** For key generation and signing functionalities, you will need the Kadena HD -Wallet package. Please refer to the -[Kadena HD Wallet documentation](https://github.com/kadena-io/kadena.js/tree/master/packages/libs/hd-wallet) -for detailed instructions on how to generate keys and sign transactions -securely. - ---- - -## Introduction - -Building wallets on the Kadena blockchain has never been easier. The Kadena -Wallet SDK is designed to be intuitive and straightforward, enabling developers -of all levels—even those with intermediate experience—to seamlessly integrate -Kadena functionalities into their wallet applications. With this SDK, you can -quickly add essential features like transaction management, account querying, -and cross-chain transfers without getting bogged down by the underlying -complexities. - -### Key Benefits - -- **Ease of Use**: Designed with simplicity in mind, allowing developers to get - started quickly. -- **Time-saving**: Eliminates the need to re-implement common functionalities, - accelerating development. -- **Comprehensive**: Offers a wide range of features to cover most wallet - integration needs. -- **Flexible**: Provides detailed control when needed, with clear parameters and - options. +Wallet package. Please refer to the: ---- - -## Getting Started - ---- +## [Kadena HD Wallet documentation](https://github.com/kadena-community/kadena.js/tree/main/packages/libs/hd-wallet) -### Installation - -To install the Kadena Wallet SDK, you can use npm or yarn: - -```bash -# Using npm -npm install @kadena/wallet-sdk - -# Using yarn -yarn add @kadena/wallet-sdk -``` - -### Basic Usage - -Import the `WalletSDK` class and create an instance: - -```typescript -import { WalletSDK } from '@kadena/wallet-sdk'; - -const walletSdk = new WalletSDK(); -``` +for detailed instructions on how to generate keys and sign transactions +securely. --- -## Core Features +## Getting started - Core Features --- @@ -129,6 +85,11 @@ const transactionDescriptor = await walletSdk.sendTransaction( 'testnet04', '1', ); + +console.log( + 'Transaction sent with request key:', + transactionDescriptor.requestKey, +); ``` #### `createTransfer` @@ -182,6 +143,11 @@ const transactionDescriptor = await walletSdk.sendTransaction( 'testnet04', '1', ); + +console.log( + 'Transaction sent with request key:', + transactionDescriptor.requestKey, +); ``` #### `createCrossChainTransfer` @@ -236,6 +202,11 @@ const transactionDescriptor = await walletSdk.sendTransaction( 'testnet04', '0', // Source chain ID ); + +console.log( + 'Cross-chain transaction sent with request key:', + transactionDescriptor.requestKey, +); ``` #### `createFinishCrossChainTransfer` @@ -246,7 +217,10 @@ complete the transfer on the target chain. **Method Signature:** ```typescript -createFinishCrossChainTransfer(transfer: CreateFinishCrossChainTransfer): IUnsignedCommand; +createFinishCrossChainTransfer( + transfer: ICreateCrossChainFinishInput, + gasPayer: { account: string; publicKeys: ISigner[] }, +): Promise; ``` **Parameters:** @@ -260,25 +234,35 @@ createFinishCrossChainTransfer(transfer: CreateFinishCrossChainTransfer): IUnsig - `networkId`: `string` - The network ID. - `receiver`: `string` - Receiver's account name. - `receiverGuard`: `IGuard` - Optional guard for the receiver's account. +- `gasPayer`: An object containing: + - `account`: `string` - The account that will pay for the gas fees. + - `publicKeys`: `ISigner[]` - The public keys associated with the gas payer's + account. **Returns:** -- `IUnsignedCommand`: An unsigned transaction command ready to be signed and - sent. +- `Promise`: An unsigned transaction command ready to be + signed and sent. **Example:** ```typescript -const unsignedTransaction = walletSdk.createFinishCrossChainTransfer({ - proof: 'spvProofString', - requestKey: 'initialRequestKey', - fromChainId: '0', - toChainId: '1', - networkId: 'testnet04', - receiver: 'receiverAccount', - // Optional receiver guard - // receiverGuard: { keys: ['receiverPublicKey'], pred: 'keys-all' }, -}); +const unsignedTransaction = await walletSdk.createFinishCrossChainTransfer( + { + proof: 'spvProofString', + requestKey: 'initialRequestKey', + fromChainId: '0', + toChainId: '1', + networkId: 'testnet04', + receiver: 'receiverAccount', + // Optional receiver guard + // receiverGuard: { keys: ['receiverPublicKey'], pred: 'keys-all' }, + }, + { + account: 'gasPayerAccount', + publicKeys: ['gasPayerPublicKey1', 'gasPayerPublicKey2'], + }, +); // Sign the transaction // const signedTransaction = signTransaction(unsignedTransaction); @@ -289,6 +273,11 @@ const transactionDescriptor = await walletSdk.sendTransaction( 'testnet04', '1', // Target chain ID ); + +console.log( + 'Finishing cross-chain transaction sent with request key:', + transactionDescriptor.requestKey, +); ``` #### `sendTransaction` @@ -346,7 +335,7 @@ getTransfers( accountName: string, networkId: string, fungible?: string, - chainsIds?: ChainId[], + chainId?: ChainId, ): Promise; ``` @@ -356,7 +345,7 @@ getTransfers( `'k:accountPublicKey'`). - `networkId`: `string` - The network ID. - `fungible?`: `string` - Optional fungible token name (defaults to `'coin'`). -- `chainsIds?`: `ChainId[]` - Optional list of chain IDs to query. +- `chainId?`: `ChainId` - Optional chain ID to filter transfers. **Returns:** @@ -386,18 +375,20 @@ Subscribes to cross-chain transfer completion events. ```typescript subscribeOnCrossChainComplete( - transfers: ITransactionDescriptor[], - callback: (transfer: Transfer) => void, + accountName: string, + transfers: ICrossChainTransfer[], + callback: (transfer: ICrossChainTransfer) => void, options?: { signal?: AbortSignal }, ): void; ``` **Parameters:** -- `transfers`: `ITransactionDescriptor[]` - An array of transaction descriptors - representing the cross-chain transfers to monitor. -- `callback`: `(transfer: Transfer) => void` - A function to call when a - transfer completes. +- `accountName`: `string` - The account name associated with the transfers. +- `transfers`: `ICrossChainTransfer[]` - An array of cross-chain transfer + objects to monitor. +- `callback`: `(transfer: ICrossChainTransfer) => void` - A function to call + when a transfer completes. - `options?`: `{ signal?: AbortSignal }` - Optional settings, including an `AbortSignal` to cancel the subscription. @@ -405,7 +396,8 @@ subscribeOnCrossChainComplete( ```typescript walletSdk.subscribeOnCrossChainComplete( - [crossChainTransactionDescriptor], + 'senderAccount', + [crossChainTransfer1, crossChainTransfer2], (transfer) => { console.log('Cross-chain transfer completed:', transfer); }, @@ -461,7 +453,12 @@ subscribePendingTransactions( transaction: ITransactionDescriptor, result: ResponseResult, ) => void, - options?: { signal?: AbortSignal }, + options?: { + signal?: AbortSignal; + confirmationDepth?: number; + timeoutSeconds?: number; + intervalMs?: number; + }, ): void; ``` @@ -472,8 +469,14 @@ subscribePendingTransactions( - `callback`: `(transaction: ITransactionDescriptor, result: ResponseResult) => void` - A function to call when a transaction status updates. -- `options?`: `{ signal?: AbortSignal }` - Optional settings, including an - `AbortSignal`. +- `options?`: + - `signal?: AbortSignal` - Optional signal to abort the subscription. + - `confirmationDepth?: number` - Optional number of confirmations to wait for + (default is `1`). + - `timeoutSeconds?: number` - Optional timeout in seconds (default is `60` or + based on `confirmationDepth`). + - `intervalMs?: number` - Optional polling interval in milliseconds (default + is `1000`). **Example:** @@ -490,6 +493,11 @@ walletSdk.subscribePendingTransactions( ); } }, + { + confirmationDepth: 2, + timeoutSeconds: 300, + intervalMs: 2000, + }, ); ``` @@ -582,13 +590,12 @@ chains.forEach((chain) => { ### `getNetworkInfo` -Retrieves network information. _(Note: Currently returns `null` as this method -is a placeholder for future implementation.)_ +Retrieves network information. **Method Signature:** ```typescript -getNetworkInfo(networkHost: string): Promise; +getNetworkInfo(networkHost: string): Promise; ``` **Parameters:** @@ -597,7 +604,7 @@ getNetworkInfo(networkHost: string): Promise; **Returns:** -- `Promise`: A promise that resolves to network information. +- `Promise`: A promise that resolves to network information. **Example:** @@ -650,8 +657,6 @@ console.log('Estimated Gas Limit:', gasLimit); ## Extras ---- - ### Exchange Helper Provides functionality to retrieve token information from the ETHVM Dev API. @@ -687,8 +692,6 @@ const tokenInfo = await walletSdk.exchange.getEthvmDevTokenInfo(['kadena']); console.log('Kadena Token Info:', tokenInfo.kadena); ``` ---- - ### Kadena Names Service Provides functions to resolve Kadena names to addresses and vice versa. @@ -768,9 +771,8 @@ if (name) { ## Happy Coding! -With the Kadena Wallet SDK, Kadena HD Wallet, ande Kadena Kode-UI you're -well-equipped to build powerful and secure wallet applications on the Kadena -blockchain. Please use this example app as a Reference and dive into the +With the Kadena Wallet SDK and Kadena HD Wallet, you're well-equipped to build +powerful and secure wallet applications on the Kadena blockchain. Dive into the documentation, explore the features, and start building today! --- @@ -780,3 +782,5 @@ documentation, explore the features, and start building today! - [Kadena Official Website](https://kadena.io/) - [Kadena Documentation](https://docs.kadena.io/) - [Kadena GitHub Repository](https://github.com/kadena-io/) + +--- diff --git a/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx b/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx index 7ab6f46cab..55172a67e4 100644 --- a/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx @@ -345,7 +345,9 @@ export const Transfer = () => { diff --git a/packages/libs/wallet-sdk/README.md b/packages/libs/wallet-sdk/README.md index dfc48ae7ba..334eb3e784 100644 --- a/packages/libs/wallet-sdk/README.md +++ b/packages/libs/wallet-sdk/README.md @@ -839,7 +839,7 @@ if (name) { ### **Introduction Text for Wallet SDK Documentation** To explore the capabilities of the Kadena Wallet SDK in action, check out the -[Wallet SDK Example App](https://github.com/kadena-community/kadena.js/tree/feat/wallet-sdk-interface/packages/apps/wallet-sdk-example). +[Wallet SDK Example App](https://github.com/kadena-community/kadena.js/tree/main/packages/apps/wallet-sdk-example). This example app demonstrates every function available in the SDK. It highlights: From 7bdb76ef9cdcd294d7827ca82f46c672890faefa Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 10:01:56 +0100 Subject: [PATCH 075/103] feat(wallet-sdk): add crosschain data to pending transaction --- packages/apps/wallet-sdk-example/src/pages/Transfer.tsx | 3 +++ packages/apps/wallet-sdk-example/src/pages/Transfers.tsx | 6 +++++- packages/apps/wallet-sdk-example/src/state/pending.ts | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx b/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx index 55172a67e4..b5fd838842 100644 --- a/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/Transfer.tsx @@ -127,6 +127,8 @@ export const Transfer = () => { let transaction: IUnsignedCommand; if (isCrossChain) { + // This logic assumes `receiverAccount` is always a k: account + // TODO: support non-k: accounts const crossChainTransferArgs: CrossChainCreateTransfer = { amount: amount, chainId: fromChain, @@ -217,6 +219,7 @@ export const Transfer = () => { senderAccount: wallet.account.name, receiverAccount: transactionDetails.receiverAccount, amount: transactionDetails.amount, + toChain: wallet.selectedToChain ?? undefined, }; addPendingTransfer(pendingTransfer); diff --git a/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx b/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx index 4f2bf25999..9eacb6f932 100644 --- a/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx +++ b/packages/apps/wallet-sdk-example/src/pages/Transfers.tsx @@ -63,7 +63,11 @@ export const Transfers = () => { {transfer.requestKey} - {transfer.chainId} + + {transfer.toChain + ? `${transfer.chainId} → ${transfer.toChain}` + : transfer.chainId} + {transfer.senderAccount} diff --git a/packages/apps/wallet-sdk-example/src/state/pending.ts b/packages/apps/wallet-sdk-example/src/state/pending.ts index c7ee1491b6..ecd4017c09 100644 --- a/packages/apps/wallet-sdk-example/src/state/pending.ts +++ b/packages/apps/wallet-sdk-example/src/state/pending.ts @@ -1,4 +1,4 @@ -import { ITransactionDescriptor } from '@kadena/client'; +import { ChainId, ITransactionDescriptor } from '@kadena/client'; import { useAtom } from 'jotai'; import { atomWithStorage } from 'jotai/utils'; import { useCallback } from 'react'; @@ -7,6 +7,7 @@ export type PendingTransfer = ITransactionDescriptor & { receiverAccount: string; senderAccount: string; amount: string; + toChain?: ChainId; }; export const pendingTransfersAtom = atomWithStorage( From 543bf7fcfe99e653c3daa00bd35855e103089553 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 10:25:08 +0100 Subject: [PATCH 076/103] fix: sync package versions for wallet-sdk --- packages/apps/dev-wallet/package.json | 4 +- packages/apps/wallet-sdk-example/package.json | 26 +- packages/libs/wallet-sdk/package.json | 4 +- pnpm-lock.yaml | 668 +++--------------- 4 files changed, 105 insertions(+), 597 deletions(-) diff --git a/packages/apps/dev-wallet/package.json b/packages/apps/dev-wallet/package.json index 79966b2b6d..216ae4e3bf 100644 --- a/packages/apps/dev-wallet/package.json +++ b/packages/apps/dev-wallet/package.json @@ -62,14 +62,14 @@ "@types/react-dom": "^18.2.25", "@vanilla-extract/esbuild-plugin": "^2.3.11", "@vanilla-extract/vite-plugin": "4.0.17", - "@vitejs/plugin-react-swc": "^3.3.2", + "@vitejs/plugin-react-swc": "^3.2.2", "chokidar-cli": "^3.0.0", "concurrently": "^8.2.2", "eslint": "^8.45.0", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.3", "typescript": "5.4.5", - "vite": "^5.2.11", + "vite": "^5.4.8", "vite-plugin-static-copy": "^1.0.0", "vite-tsconfig-paths": "^4.2.1", "vitest": "^1.6.0" diff --git a/packages/apps/wallet-sdk-example/package.json b/packages/apps/wallet-sdk-example/package.json index f372794c55..b74b3bbca6 100644 --- a/packages/apps/wallet-sdk-example/package.json +++ b/packages/apps/wallet-sdk-example/package.json @@ -17,11 +17,8 @@ "@kadena/wallet-sdk": "workspace:*", "@popperjs/core": "^2.11.8", "@tanstack/react-query": "^5.32.0", - "@types/markdown-it": "^14.1.2", - "@types/react-router-dom": "^5.3.3", - "@types/react-syntax-highlighter": "^15.5.13", "@vanilla-extract/css": "1.14.2", - "@vanilla-extract/vite-plugin": "4.0.7", + "@vanilla-extract/vite-plugin": "4.0.17", "clsx": "^2.1.1", "dompurify": "^3.2.1", "highlight.js": "^11.10.0", @@ -29,24 +26,27 @@ "jotai": "^2.10.1", "markdown-it": "^14.1.0", "next-themes": "^0.2.1", - "react": "^18.3.1", - "react-dom": "^18.3.1", + "react": "^18.2.0", + "react-dom": "^18.2.0", "react-router-dom": "^6.26.2" }, "devDependencies": { "@eslint/js": "^9.11.1", "@kadena-dev/shared-config": "workspace:*", - "@types/react": "^18.3.10", - "@types/react-dom": "^18.3.0", - "@vitejs/plugin-react-swc": "^3.5.0", + "@types/markdown-it": "^14.1.2", + "@types/react": "^18.2.79", + "@types/react-dom": "^18.2.25", + "@types/react-router-dom": "^5.3.3", + "@types/react-syntax-highlighter": "^15.5.13", + "@vitejs/plugin-react-swc": "^3.2.2", "autoprefixer": "^10.4.20", - "eslint": "^9.11.1", - "eslint-plugin-react-hooks": "^5.1.0-rc.0", - "eslint-plugin-react-refresh": "^0.4.12", + "eslint": "^8.45.0", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-react-refresh": "^0.4.3", "globals": "^15.9.0", "postcss": "^8", "tailwindcss": "^3.4.1", - "typescript": "^5.5.3", + "typescript": "5.4.5", "typescript-eslint": "^8.7.0", "vite": "^5.4.8", "vite-plugin-node-polyfills": "^0.22.0" diff --git a/packages/libs/wallet-sdk/package.json b/packages/libs/wallet-sdk/package.json index 57aad4021b..d1c47248f8 100644 --- a/packages/libs/wallet-sdk/package.json +++ b/packages/libs/wallet-sdk/package.json @@ -42,7 +42,6 @@ "valibot": "^0.42.1" }, "devDependencies": { - "msw": "2.2.14", "@graphql-codegen/cli": "5.0.2", "@graphql-codegen/client-preset": "^4.4.0", "@graphql-typed-document-node/core": "^3.2.0", @@ -53,7 +52,7 @@ "@kadena/hd-wallet": "workspace:*", "@kadena/types": "workspace:*", "@microsoft/api-extractor": "^7.43.1", - "@rollup/plugin-commonjs": "^25.0.8", + "@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-inject": "^5.0.5", "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^15.2.3", @@ -64,6 +63,7 @@ "@vitest/coverage-v8": "^1.6.0", "cpy-cli": "^5.0.0", "eslint": "^8.45.0", + "msw": "^2.2.14", "prettier": "~3.2.5", "rollup": "^4.17.2", "rollup-plugin-polyfill-node": "^0.13.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ba1cfe83db..ca12cf845b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -175,10 +175,10 @@ importers: version: 2.3.11(@types/node@22.9.1)(esbuild@0.21.5)(lightningcss@1.25.1)(terser@5.31.1) '@vanilla-extract/vite-plugin': specifier: 4.0.17 - version: 4.0.17(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)(vite@5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)) + version: 4.0.17(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)) '@vitejs/plugin-react-swc': - specifier: ^3.3.2 - version: 3.7.0(@swc/helpers@0.5.11)(vite@5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)) + specifier: ^3.2.2 + version: 3.7.0(@swc/helpers@0.5.11)(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)) chokidar-cli: specifier: ^3.0.0 version: 3.0.0 @@ -198,14 +198,14 @@ importers: specifier: 5.4.5 version: 5.4.5 vite: - specifier: ^5.2.11 - version: 5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) + specifier: ^5.4.8 + version: 5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) vite-plugin-static-copy: specifier: ^1.0.0 - version: 1.0.6(vite@5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)) + version: 1.0.6(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)) vite-tsconfig-paths: specifier: ^4.2.1 - version: 4.3.2(typescript@5.4.5)(vite@5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)) + version: 4.3.2(typescript@5.4.5)(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)) vitest: specifier: ^1.6.0 version: 1.6.0(@types/node@22.9.1)(@vitest/ui@1.6.0)(happy-dom@12.10.3)(jsdom@22.1.0(canvas@2.11.2(encoding@0.1.13)))(lightningcss@1.25.1)(terser@5.31.1) @@ -1651,21 +1651,12 @@ importers: '@tanstack/react-query': specifier: ^5.32.0 version: 5.49.2(react@18.3.1) - '@types/markdown-it': - specifier: ^14.1.2 - version: 14.1.2 - '@types/react-router-dom': - specifier: ^5.3.3 - version: 5.3.3 - '@types/react-syntax-highlighter': - specifier: ^15.5.13 - version: 15.5.13 '@vanilla-extract/css': specifier: 1.14.2 version: 1.14.2 '@vanilla-extract/vite-plugin': - specifier: 4.0.7 - version: 4.0.7(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)) + specifier: 4.0.17 + version: 4.0.17(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)) clsx: specifier: ^2.1.1 version: 2.1.1 @@ -1688,10 +1679,10 @@ importers: specifier: ^0.2.1 version: 0.2.1(next@14.2.2(@opentelemetry/api@1.9.0)(@playwright/test@1.46.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) react: - specifier: ^18.3.1 + specifier: ^18.2.0 version: 18.3.1 react-dom: - specifier: ^18.3.1 + specifier: ^18.2.0 version: 18.3.1(react@18.3.1) react-router-dom: specifier: ^6.26.2 @@ -1703,27 +1694,36 @@ importers: '@kadena-dev/shared-config': specifier: workspace:* version: link:../../tools/shared-config + '@types/markdown-it': + specifier: ^14.1.2 + version: 14.1.2 '@types/react': - specifier: ^18.3.10 + specifier: ^18.2.79 version: 18.3.14 '@types/react-dom': - specifier: ^18.3.0 + specifier: ^18.2.25 version: 18.3.0 + '@types/react-router-dom': + specifier: ^5.3.3 + version: 5.3.3 + '@types/react-syntax-highlighter': + specifier: ^15.5.13 + version: 15.5.13 '@vitejs/plugin-react-swc': - specifier: ^3.5.0 + specifier: ^3.2.2 version: 3.7.0(@swc/helpers@0.5.11)(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)) autoprefixer: specifier: ^10.4.20 version: 10.4.20(postcss@8.4.47) eslint: - specifier: ^9.11.1 - version: 9.16.0(jiti@1.21.6) + specifier: ^8.45.0 + version: 8.57.0 eslint-plugin-react-hooks: - specifier: ^5.1.0-rc.0 - version: 5.1.0(eslint@9.16.0(jiti@1.21.6)) + specifier: ^4.6.0 + version: 4.6.2(eslint@8.57.0) eslint-plugin-react-refresh: - specifier: ^0.4.12 - version: 0.4.16(eslint@9.16.0(jiti@1.21.6)) + specifier: ^0.4.3 + version: 0.4.16(eslint@8.57.0) globals: specifier: ^15.9.0 version: 15.13.0 @@ -1732,13 +1732,13 @@ importers: version: 8.4.47 tailwindcss: specifier: ^3.4.1 - version: 3.4.4(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(@types/node@22.9.1)(typescript@5.6.3)) + version: 3.4.4(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(@types/node@22.9.1)(typescript@5.4.5)) typescript: - specifier: ^5.5.3 - version: 5.6.3 + specifier: 5.4.5 + version: 5.4.5 typescript-eslint: specifier: ^8.7.0 - version: 8.17.0(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3) + version: 8.17.0(eslint@8.57.0)(typescript@5.4.5) vite: specifier: ^5.4.8 version: 5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) @@ -3221,7 +3221,7 @@ importers: specifier: ^7.43.1 version: 7.47.0(@types/node@20.16.5) '@rollup/plugin-commonjs': - specifier: ^25.0.8 + specifier: ^25.0.7 version: 25.0.8(rollup@4.24.0) '@rollup/plugin-inject': specifier: ^5.0.5 @@ -3254,8 +3254,8 @@ importers: specifier: ^8.45.0 version: 8.57.0 msw: - specifier: 2.2.14 - version: 2.2.14(typescript@5.4.5) + specifier: ^2.2.14 + version: 2.3.1(typescript@5.4.5) prettier: specifier: ~3.2.5 version: 3.2.5 @@ -5128,14 +5128,6 @@ packages: resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} - '@eslint/config-array@0.19.1': - resolution: {integrity: sha512-fo6Mtm5mWyKjA/Chy1BYTdn5mGJoDNjC7C64ug20ADsRDGrA85bN3uK3MaKbeRkRuuIEAR5N33Jr1pbm411/PA==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - - '@eslint/core@0.9.1': - resolution: {integrity: sha512-GuUdqkyyzQI5RMIWkHhvTWLCyLo1jNK3vzkSyaExH5kHPDHcuL2VOpHjmMY+y3+NC69qAKToBqldTBgYeLSr9Q==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/eslintrc@0.4.3': resolution: {integrity: sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw==} engines: {node: ^10.12.0 || >=12.0.0} @@ -5144,10 +5136,6 @@ packages: resolution: {integrity: sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - '@eslint/eslintrc@3.2.0': - resolution: {integrity: sha512-grOjVNN8P3hjJn/eIETF1wwd12DdnwFDoyceUJLYYdkpbwq3nLi+4fqrTAONx7XDALqlL220wC/RHSC/QTI/0w==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/js@8.57.0': resolution: {integrity: sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -5156,14 +5144,6 @@ packages: resolution: {integrity: sha512-tw2HxzQkrbeuvyj1tG2Yqq+0H9wGoI2IMk4EOsQeX+vmd75FtJAzf+gTA69WF+baUKRYQ3x2kbLE08js5OsTVg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/object-schema@2.1.5': - resolution: {integrity: sha512-o0bhxnL89h5Bae5T318nFoFzGy+YE5i/gGkoPAgkmTVdRKTiv3p8JHevPiPaMwoloKfEiiaHlawCqaZMqRm+XQ==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - - '@eslint/plugin-kit@0.2.4': - resolution: {integrity: sha512-zSkKow6H5Kdm0ZUQUB2kV5JIXqoG0+uH5YADhaEHswm664N9Db8dXSi0nMJpacpMf+MyyglF1vnZohpEg5yUtg==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@etchteam/storybook-addon-status@5.0.0': resolution: {integrity: sha512-0Dg94xQ3T+rYTi6ekFkaH0XU9k0IQOqidiSmwN47Oqw4u1qjxK6m7wV3j7C0deLEuf4U4PrAcsDfDjyehKne2A==} @@ -5785,14 +5765,6 @@ packages: peerDependencies: react-hook-form: ^7.0.0 - '@humanfs/core@0.19.1': - resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==} - engines: {node: '>=18.18.0'} - - '@humanfs/node@0.16.6': - resolution: {integrity: sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==} - engines: {node: '>=18.18.0'} - '@humanwhocodes/config-array@0.11.14': resolution: {integrity: sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==} engines: {node: '>=10.10.0'} @@ -5815,14 +5787,6 @@ packages: resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==} deprecated: Use @eslint/object-schema instead - '@humanwhocodes/retry@0.3.1': - resolution: {integrity: sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==} - engines: {node: '>=18.18'} - - '@humanwhocodes/retry@0.4.1': - resolution: {integrity: sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA==} - engines: {node: '>=18.18'} - '@img/sharp-darwin-arm64@0.33.4': resolution: {integrity: sha512-p0suNqXufJs9t3RqLBO6vvrgr5OhgbWp76s5gTRvdmxmuv9E1rcaqGUsl3l4mKVmXPkTkTErXediAui4x+8PSA==} engines: {glibc: '>=2.26', node: ^18.17.0 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0', yarn: '>=3.2.0'} @@ -6614,10 +6578,6 @@ packages: resolution: {integrity: sha512-W68qOHEjx1iD+4VjQudlx26CPIoxmIAtK4ZCexU0/UJBG6jYhcuyzKJx+Iw8uhBIGd9eba64XgWVgo20it1qwA==} engines: {node: '>=18'} - '@mswjs/interceptors@0.26.15': - resolution: {integrity: sha512-HM47Lu1YFmnYHKMBynFfjCp0U/yRskHj/8QEJW0CBEPOlw8Gkmjfll+S9b8M7V5CNDw2/ciRxjjnWeaCiblSIQ==} - engines: {node: '>=18'} - '@mswjs/interceptors@0.29.1': resolution: {integrity: sha512-3rDakgJZ77+RiQUuSK69t1F0m8BQKA8Vh5DCS5V0DWvNY67zob2JhhQrhCO0AKLGINTRSFd1tBaHcJTkhefoSw==} engines: {node: '>=18'} @@ -9099,12 +9059,6 @@ packages: cpu: [arm64] os: [darwin] - '@swc/core-darwin-arm64@1.6.7': - resolution: {integrity: sha512-sNb+ghP2OhZyUjS7E5Mf3PqSvoXJ5gY6GBaH2qp8WQxx9VL7ozC4HVo6vkeFJBN5cmYqUCLnhrM3HU4W+7yMSA==} - engines: {node: '>=10'} - cpu: [arm64] - os: [darwin] - '@swc/core-darwin-arm64@1.9.2': resolution: {integrity: sha512-nETmsCoY29krTF2PtspEgicb3tqw7Ci5sInTI03EU5zpqYbPjoPH99BVTjj0OsF53jP5MxwnLI5Hm21lUn1d6A==} engines: {node: '>=10'} @@ -9123,12 +9077,6 @@ packages: cpu: [x64] os: [darwin] - '@swc/core-darwin-x64@1.6.7': - resolution: {integrity: sha512-LQwYm/ATYN5fYSYVPMfComPiFo5i8jh75h1ASvNWhXtS+/+k1dq1zXTJWZRuojd5NXgW3bb6mJtJ2evwYIgYbA==} - engines: {node: '>=10'} - cpu: [x64] - os: [darwin] - '@swc/core-darwin-x64@1.9.2': resolution: {integrity: sha512-9gD+bwBz8ZByjP6nZTXe/hzd0tySIAjpDHgkFiUrc+5zGF+rdTwhcNrzxNHJmy6mw+PW38jqII4uspFHUqqxuQ==} engines: {node: '>=10'} @@ -9147,12 +9095,6 @@ packages: cpu: [arm] os: [linux] - '@swc/core-linux-arm-gnueabihf@1.6.7': - resolution: {integrity: sha512-kEDzVhNci38LX3kdY99t68P2CDf+2QFDk5LawVamXH0iN5DRAO/+wjOhxL8KOHa6wQVqKEt5WrhD+Rrvk/34Yw==} - engines: {node: '>=10'} - cpu: [arm] - os: [linux] - '@swc/core-linux-arm-gnueabihf@1.9.2': resolution: {integrity: sha512-kYq8ief1Qrn+WmsTWAYo4r+Coul4dXN6cLFjiPZ29Cv5pyU+GFvSPAB4bEdMzwy99rCR0u2P10UExaeCjurjvg==} engines: {node: '>=10'} @@ -9171,12 +9113,6 @@ packages: cpu: [arm64] os: [linux] - '@swc/core-linux-arm64-gnu@1.6.7': - resolution: {integrity: sha512-SyOBUGfl31xLGpIJ/Jd6GKHtkfZyHBXSwFlK7FmPN//MBQLtTBm4ZaWTnWnGo4aRsJwQdXWDKPyqlMBtnIl1nQ==} - engines: {node: '>=10'} - cpu: [arm64] - os: [linux] - '@swc/core-linux-arm64-gnu@1.9.2': resolution: {integrity: sha512-n0W4XiXlmEIVqxt+rD3ZpkogsEWUk1jJ+i5bQNgB+1JuWh0fBE8c/blDgTQXa0GB5lTPVDZQussgdNOCnAZwiA==} engines: {node: '>=10'} @@ -9195,12 +9131,6 @@ packages: cpu: [arm64] os: [linux] - '@swc/core-linux-arm64-musl@1.6.7': - resolution: {integrity: sha512-1fOAXkDFbRfItEdMZPxT3du1QWYhgToa4YsnqTujjE8EqJW8K27hIcHRIkVuzp7PNhq8nLBg0JpJM4g27EWD7g==} - engines: {node: '>=10'} - cpu: [arm64] - os: [linux] - '@swc/core-linux-arm64-musl@1.9.2': resolution: {integrity: sha512-8xzrOmsyCC1zrx2Wzx/h8dVsdewO1oMCwBTLc1gSJ/YllZYTb04pNm6NsVbzUX2tKddJVRgSJXV10j/NECLwpA==} engines: {node: '>=10'} @@ -9219,12 +9149,6 @@ packages: cpu: [x64] os: [linux] - '@swc/core-linux-x64-gnu@1.6.7': - resolution: {integrity: sha512-Gp7uCwPsNO5ATxbyvfTyeNCHUGD9oA+xKMm43G1tWCy+l07gLqWMKp7DIr3L3qPD05TfAVo3OuiOn2abpzOFbw==} - engines: {node: '>=10'} - cpu: [x64] - os: [linux] - '@swc/core-linux-x64-gnu@1.9.2': resolution: {integrity: sha512-kZrNz/PjRQKcchWF6W292jk3K44EoVu1ad5w+zbS4jekIAxsM8WwQ1kd+yjUlN9jFcF8XBat5NKIs9WphJCVXg==} engines: {node: '>=10'} @@ -9243,12 +9167,6 @@ packages: cpu: [x64] os: [linux] - '@swc/core-linux-x64-musl@1.6.7': - resolution: {integrity: sha512-QeruGBZJ15tadqEMQ77ixT/CYGk20MtlS8wmvJiV+Wsb8gPW5LgCjtupzcLLnoQzDG54JGNCeeZ0l/T8NYsOvA==} - engines: {node: '>=10'} - cpu: [x64] - os: [linux] - '@swc/core-linux-x64-musl@1.9.2': resolution: {integrity: sha512-TTIpR4rjMkhX1lnFR+PSXpaL83TrQzp9znRdp2TzYrODlUd/R20zOwSo9vFLCyH6ZoD47bccY7QeGZDYT3nlRg==} engines: {node: '>=10'} @@ -9267,12 +9185,6 @@ packages: cpu: [arm64] os: [win32] - '@swc/core-win32-arm64-msvc@1.6.7': - resolution: {integrity: sha512-ouRqgSnT95lTCiU/6kJRNS5b1o+p8I/V9jxtL21WUj/JOVhsFmBErqQ0MZyCu514noWiR5BIqOrZXR8C1Knx6Q==} - engines: {node: '>=10'} - cpu: [arm64] - os: [win32] - '@swc/core-win32-arm64-msvc@1.9.2': resolution: {integrity: sha512-+Eg2d4icItKC0PMjZxH7cSYFLWk0aIp94LNmOw6tPq0e69ax6oh10upeq0D1fjWsKLmOJAWEvnXlayZcijEXDw==} engines: {node: '>=10'} @@ -9291,12 +9203,6 @@ packages: cpu: [ia32] os: [win32] - '@swc/core-win32-ia32-msvc@1.6.7': - resolution: {integrity: sha512-eZAP/EmJ0IcfgAx6B4/SpSjq3aT8gr0ooktfMqw/w0/5lnNrbMl2v+2kvxcneNcF7bp8VNcYZnoHlsP+LvmVbA==} - engines: {node: '>=10'} - cpu: [ia32] - os: [win32] - '@swc/core-win32-ia32-msvc@1.9.2': resolution: {integrity: sha512-nLWBi4vZDdM/LkiQmPCakof8Dh1/t5EM7eudue04V1lIcqx9YHVRS3KMwEaCoHLGg0c312Wm4YgrWQd9vwZ5zQ==} engines: {node: '>=10'} @@ -9315,12 +9221,6 @@ packages: cpu: [x64] os: [win32] - '@swc/core-win32-x64-msvc@1.6.7': - resolution: {integrity: sha512-QOdE+7GQg1UQPS6p0KxzJOh/8GLbJ5zI1vqKArCCB0unFqUfKIjYb2TaH0geEBy3w9qtXxe3ZW6hzxtZSS9lDg==} - engines: {node: '>=10'} - cpu: [x64] - os: [win32] - '@swc/core-win32-x64-msvc@1.9.2': resolution: {integrity: sha512-ik/k+JjRJBFkXARukdU82tSVx0CbExFQoQ78qTO682esbYXzjdB5eLVkoUbwen299pnfr88Kn4kyIqFPTje8Xw==} engines: {node: '>=10'} @@ -9345,15 +9245,6 @@ packages: '@swc/helpers': optional: true - '@swc/core@1.6.7': - resolution: {integrity: sha512-BBzORL9qWz5hZqAZ83yn+WNaD54RH5eludjqIOboolFOK/Pw+2l00/H77H4CEBJnzCIBQszsyqtITmrn4evp0g==} - engines: {node: '>=10'} - peerDependencies: - '@swc/helpers': '*' - peerDependenciesMeta: - '@swc/helpers': - optional: true - '@swc/core@1.9.2': resolution: {integrity: sha512-dYyEkO6mRYtZFpnOsnYzv9rY69fHAHoawYOjGOEcxk9WYtaJhowMdP/w6NcOKnz2G7GlZaenjkzkMa6ZeQeMsg==} engines: {node: '>=10'} @@ -9885,9 +9776,6 @@ packages: '@types/react-syntax-highlighter@15.5.13': resolution: {integrity: sha512-uLGJ87j6Sz8UaBAooU0T6lWJ0dBmjZgN1PZTrj05TNql2/XpC6+4HhMT5syIdFUUt+FASfCeLLv4kBygNU+8qA==} - '@types/react@18.3.11': - resolution: {integrity: sha512-r6QZ069rFTjrEYgFdOck1gK7FLVsgJE7tTz0pQBczlBNUhBNk0MQH4UbnFSwjpQLMkLzgqvBBa+qGpLje16eTQ==} - '@types/react@18.3.14': resolution: {integrity: sha512-NzahNKvjNhVjuPBQ+2G7WlxstQ+47kXZNHlUvFakDViuIEfGY926GqhMueQFZ7woG+sPiQKlF36XfrIUVSUfFg==} @@ -10418,11 +10306,6 @@ packages: peerDependencies: vite: ^4.0.3 || ^5.0.0 - '@vanilla-extract/vite-plugin@4.0.7': - resolution: {integrity: sha512-uRAFWdq5Eq0ybpgW2P0LNOw8eW+MTg/OFo5K0Hsl2cKu/Tu2tabCsBf6vNjfhDrm4jBShHy1wJIVcYxf6sczVQ==} - peerDependencies: - vite: ^4.0.3 || ^5.0.0 - '@vanilla-extract/webpack-plugin@2.3.7': resolution: {integrity: sha512-xKhl7BUGqjj1eRzgASBcfKSvzIWGN1ndNT9ycUcfDz1AXZr6rok99LSj+Z2LqAnCGZGAiLsYzdQ5AYBABXV+vA==} peerDependencies: @@ -10755,11 +10638,6 @@ packages: engines: {node: '>=0.4.0'} hasBin: true - acorn@8.14.0: - resolution: {integrity: sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==} - engines: {node: '>=0.4.0'} - hasBin: true - agent-base@6.0.2: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} @@ -11996,10 +11874,6 @@ packages: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} engines: {node: '>= 8'} - cross-spawn@7.0.6: - resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} - engines: {node: '>= 8'} - crossws@0.2.4: resolution: {integrity: sha512-DAxroI2uSOgUKLz00NX6A8U/8EE3SZHmIND+10jkVSaypvyt57J5JEOxAQOL6lQxyzi/wZbTIwssU1uy69h5Vg==} peerDependencies: @@ -12982,12 +12856,6 @@ packages: peerDependencies: eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 - eslint-plugin-react-hooks@5.1.0: - resolution: {integrity: sha512-mpJRtPgHN2tNAvZ35AMfqeB3Xqeo273QxrHJsbBEPWODRM4r0yB6jfoROqKEYrOn27UtRPpcpHc2UqyBSuUNTw==} - engines: {node: '>=10'} - peerDependencies: - eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0 - eslint-plugin-react-refresh@0.4.16: resolution: {integrity: sha512-slterMlxAhov/DZO8NScf6mEeMBBXodFUolijDvrtTxyezyLoTQaa73FyYus/VbTdftd8wBgBxPMRk3poleXNQ==} peerDependencies: @@ -13027,10 +12895,6 @@ packages: resolution: {integrity: sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - eslint-scope@8.2.0: - resolution: {integrity: sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - eslint-utils@2.1.0: resolution: {integrity: sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==} engines: {node: '>=6'} @@ -13069,20 +12933,6 @@ packages: deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. hasBin: true - eslint@9.16.0: - resolution: {integrity: sha512-whp8mSQI4C8VXd+fLgSM0lh3UlmcFtVwUQjyKCFfsp+2ItAIYhlq/hqGahGqHE6cv9unM41VlqKk2VtKYR2TaA==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - hasBin: true - peerDependencies: - jiti: '*' - peerDependenciesMeta: - jiti: - optional: true - - espree@10.3.0: - resolution: {integrity: sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - espree@6.2.1: resolution: {integrity: sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==} engines: {node: '>=6.0.0'} @@ -13392,10 +13242,6 @@ packages: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} engines: {node: ^10.12.0 || >=12.0.0} - file-entry-cache@8.0.0: - resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==} - engines: {node: '>=16.0.0'} - file-type@17.1.6: resolution: {integrity: sha512-hlDw5Ev+9e883s0pwUsuuYNu4tD7GgpUnOvykjv1Gya0ZIjuKumthDRua90VUn6/nlRKAjcxLUnHNTIUWwWIiw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -13472,10 +13318,6 @@ packages: resolution: {integrity: sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==} engines: {node: ^10.12.0 || >=12.0.0} - flat-cache@4.0.1: - resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==} - engines: {node: '>=16'} - flat@5.0.2: resolution: {integrity: sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==} hasBin: true @@ -13779,10 +13621,6 @@ packages: resolution: {integrity: sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==} engines: {node: '>=8'} - globals@14.0.0: - resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} - engines: {node: '>=18'} - globals@15.13.0: resolution: {integrity: sha512-49TewVEz0UxZjr1WYYsWpPrhyC/B/pA8Bq0fUmet2n+eR7yn0IvNzNaoBwnK6mdkzcN+se7Ez9zUgULTz2QH4g==} engines: {node: '>=18'} @@ -16219,16 +16057,6 @@ packages: msgpackr@1.10.2: resolution: {integrity: sha512-L60rsPynBvNE+8BWipKKZ9jHcSGbtyJYIwjRq0VrIvQ08cRjntGXJYW/tmciZ2IHWIY8WEW32Qa2xbh5+SKBZA==} - msw@2.2.14: - resolution: {integrity: sha512-64i8rNCa1xzDK8ZYsTrVMli05D687jty8+Th+PU5VTbJ2/4P7fkQFVyDQ6ZFT5FrNR8z2BHhbY47fKNvfHrumA==} - engines: {node: '>=18'} - hasBin: true - peerDependencies: - typescript: '>= 4.7.x' - peerDependenciesMeta: - typescript: - optional: true - msw@2.3.1: resolution: {integrity: sha512-ocgvBCLn/5l3jpl1lssIb3cniuACJLoOfZu01e3n5dbJrpA5PeeWn28jCLgQDNt6d7QT8tF2fYRzm9JoEHtiig==} engines: {node: '>=18'} @@ -20028,34 +19856,6 @@ packages: vite: optional: true - vite@5.3.3: - resolution: {integrity: sha512-NPQdeCU0Dv2z5fu+ULotpuq5yfCS1BzKUIPhNbP3YBfAMGJXbt2nS+sbTFu+qchaqWTD+H3JK++nRwr6XIcp6A==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - peerDependencies: - '@types/node': ^18.0.0 || >=20.0.0 - less: '*' - lightningcss: ^1.21.0 - sass: '*' - stylus: '*' - sugarss: '*' - terser: ^5.4.0 - peerDependenciesMeta: - '@types/node': - optional: true - less: - optional: true - lightningcss: - optional: true - sass: - optional: true - stylus: - optional: true - sugarss: - optional: true - terser: - optional: true - vite@5.4.9: resolution: {integrity: sha512-20OVpJHh0PAM0oSOELa5GaZNWeDjcAvQjGXy2Uyr+Tp+/D2/Hdz6NLgpJLsarPTA2QJ6v8mX2P1ZfbsSKvdMkg==} engines: {node: ^18.0.0 || >=20.0.0} @@ -22116,27 +21916,10 @@ snapshots: eslint: 8.57.0 eslint-visitor-keys: 3.4.3 - '@eslint-community/eslint-utils@4.4.0(eslint@9.16.0(jiti@1.21.6))': - dependencies: - eslint: 9.16.0(jiti@1.21.6) - eslint-visitor-keys: 3.4.3 - '@eslint-community/regexpp@4.11.0': {} '@eslint-community/regexpp@4.12.1': {} - '@eslint/config-array@0.19.1': - dependencies: - '@eslint/object-schema': 2.1.5 - debug: 4.3.4(supports-color@5.5.0) - minimatch: 3.1.2 - transitivePeerDependencies: - - supports-color - - '@eslint/core@0.9.1': - dependencies: - '@types/json-schema': 7.0.15 - '@eslint/eslintrc@0.4.3': dependencies: ajv: 6.12.6 @@ -22165,30 +21948,10 @@ snapshots: transitivePeerDependencies: - supports-color - '@eslint/eslintrc@3.2.0': - dependencies: - ajv: 6.12.6 - debug: 4.3.4(supports-color@5.5.0) - espree: 10.3.0 - globals: 14.0.0 - ignore: 5.3.2 - import-fresh: 3.3.0 - js-yaml: 4.1.0 - minimatch: 3.1.2 - strip-json-comments: 3.1.1 - transitivePeerDependencies: - - supports-color - '@eslint/js@8.57.0': {} '@eslint/js@9.16.0': {} - '@eslint/object-schema@2.1.5': {} - - '@eslint/plugin-kit@0.2.4': - dependencies: - levn: 0.4.1 - '@etchteam/storybook-addon-status@5.0.0': dependencies: lodash: 4.17.21 @@ -23500,13 +23263,6 @@ snapshots: dependencies: react-hook-form: 7.52.1(react@18.3.1) - '@humanfs/core@0.19.1': {} - - '@humanfs/node@0.16.6': - dependencies: - '@humanfs/core': 0.19.1 - '@humanwhocodes/retry': 0.3.1 - '@humanwhocodes/config-array@0.11.14': dependencies: '@humanwhocodes/object-schema': 2.0.3 @@ -23529,10 +23285,6 @@ snapshots: '@humanwhocodes/object-schema@2.0.3': {} - '@humanwhocodes/retry@0.3.1': {} - - '@humanwhocodes/retry@0.4.1': {} - '@img/sharp-darwin-arm64@0.33.4': optionalDependencies: '@img/sharp-libvips-darwin-arm64': 1.0.2 @@ -25198,15 +24950,6 @@ snapshots: '@mswjs/cookies@1.1.1': {} - '@mswjs/interceptors@0.26.15': - dependencies: - '@open-draft/deferred-promise': 2.2.0 - '@open-draft/logger': 0.3.0 - '@open-draft/until': 2.1.0 - is-node-process: 1.2.0 - outvariant: 1.4.2 - strict-event-emitter: 0.5.1 - '@mswjs/interceptors@0.29.1': dependencies: '@open-draft/deferred-promise': 2.2.0 @@ -29039,9 +28782,6 @@ snapshots: '@swc/core-darwin-arm64@1.3.78': optional: true - '@swc/core-darwin-arm64@1.6.7': - optional: true - '@swc/core-darwin-arm64@1.9.2': optional: true @@ -29051,9 +28791,6 @@ snapshots: '@swc/core-darwin-x64@1.3.78': optional: true - '@swc/core-darwin-x64@1.6.7': - optional: true - '@swc/core-darwin-x64@1.9.2': optional: true @@ -29063,9 +28800,6 @@ snapshots: '@swc/core-linux-arm-gnueabihf@1.3.78': optional: true - '@swc/core-linux-arm-gnueabihf@1.6.7': - optional: true - '@swc/core-linux-arm-gnueabihf@1.9.2': optional: true @@ -29075,9 +28809,6 @@ snapshots: '@swc/core-linux-arm64-gnu@1.3.78': optional: true - '@swc/core-linux-arm64-gnu@1.6.7': - optional: true - '@swc/core-linux-arm64-gnu@1.9.2': optional: true @@ -29087,9 +28818,6 @@ snapshots: '@swc/core-linux-arm64-musl@1.3.78': optional: true - '@swc/core-linux-arm64-musl@1.6.7': - optional: true - '@swc/core-linux-arm64-musl@1.9.2': optional: true @@ -29099,9 +28827,6 @@ snapshots: '@swc/core-linux-x64-gnu@1.3.78': optional: true - '@swc/core-linux-x64-gnu@1.6.7': - optional: true - '@swc/core-linux-x64-gnu@1.9.2': optional: true @@ -29111,9 +28836,6 @@ snapshots: '@swc/core-linux-x64-musl@1.3.78': optional: true - '@swc/core-linux-x64-musl@1.6.7': - optional: true - '@swc/core-linux-x64-musl@1.9.2': optional: true @@ -29123,9 +28845,6 @@ snapshots: '@swc/core-win32-arm64-msvc@1.3.78': optional: true - '@swc/core-win32-arm64-msvc@1.6.7': - optional: true - '@swc/core-win32-arm64-msvc@1.9.2': optional: true @@ -29135,9 +28854,6 @@ snapshots: '@swc/core-win32-ia32-msvc@1.3.78': optional: true - '@swc/core-win32-ia32-msvc@1.6.7': - optional: true - '@swc/core-win32-ia32-msvc@1.9.2': optional: true @@ -29147,9 +28863,6 @@ snapshots: '@swc/core-win32-x64-msvc@1.3.78': optional: true - '@swc/core-win32-x64-msvc@1.6.7': - optional: true - '@swc/core-win32-x64-msvc@1.9.2': optional: true @@ -29184,23 +28897,6 @@ snapshots: '@swc/core-win32-x64-msvc': 1.3.78 '@swc/helpers': 0.5.11 - '@swc/core@1.6.7(@swc/helpers@0.5.11)': - dependencies: - '@swc/counter': 0.1.3 - '@swc/types': 0.1.9 - optionalDependencies: - '@swc/core-darwin-arm64': 1.6.7 - '@swc/core-darwin-x64': 1.6.7 - '@swc/core-linux-arm-gnueabihf': 1.6.7 - '@swc/core-linux-arm64-gnu': 1.6.7 - '@swc/core-linux-arm64-musl': 1.6.7 - '@swc/core-linux-x64-gnu': 1.6.7 - '@swc/core-linux-x64-musl': 1.6.7 - '@swc/core-win32-arm64-msvc': 1.6.7 - '@swc/core-win32-ia32-msvc': 1.6.7 - '@swc/core-win32-x64-msvc': 1.6.7 - '@swc/helpers': 0.5.11 - '@swc/core@1.9.2(@swc/helpers@0.5.11)': dependencies: '@swc/counter': 0.1.3 @@ -29771,22 +29467,17 @@ snapshots: '@types/react-router-dom@5.3.3': dependencies: '@types/history': 4.7.11 - '@types/react': 18.3.11 + '@types/react': 18.3.14 '@types/react-router': 5.1.20 '@types/react-router@5.1.20': dependencies: '@types/history': 4.7.11 - '@types/react': 18.3.11 + '@types/react': 18.3.14 '@types/react-syntax-highlighter@15.5.13': dependencies: - '@types/react': 18.3.11 - - '@types/react@18.3.11': - dependencies: - '@types/prop-types': 15.7.12 - csstype: 3.1.3 + '@types/react': 18.3.14 '@types/react@18.3.14': dependencies: @@ -29926,21 +29617,21 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/eslint-plugin@8.17.0(@typescript-eslint/parser@8.17.0(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3))(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3)': + '@typescript-eslint/eslint-plugin@8.17.0(@typescript-eslint/parser@8.17.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5)': dependencies: '@eslint-community/regexpp': 4.11.0 - '@typescript-eslint/parser': 8.17.0(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3) + '@typescript-eslint/parser': 8.17.0(eslint@8.57.0)(typescript@5.4.5) '@typescript-eslint/scope-manager': 8.17.0 - '@typescript-eslint/type-utils': 8.17.0(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3) - '@typescript-eslint/utils': 8.17.0(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3) + '@typescript-eslint/type-utils': 8.17.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/utils': 8.17.0(eslint@8.57.0)(typescript@5.4.5) '@typescript-eslint/visitor-keys': 8.17.0 - eslint: 9.16.0(jiti@1.21.6) + eslint: 8.57.0 graphemer: 1.4.0 ignore: 5.3.2 natural-compare: 1.4.0 - ts-api-utils: 1.3.0(typescript@5.6.3) + ts-api-utils: 1.3.0(typescript@5.4.5) optionalDependencies: - typescript: 5.6.3 + typescript: 5.4.5 transitivePeerDependencies: - supports-color @@ -30023,16 +29714,16 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.17.0(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3)': + '@typescript-eslint/parser@8.17.0(eslint@8.57.0)(typescript@5.4.5)': dependencies: '@typescript-eslint/scope-manager': 8.17.0 '@typescript-eslint/types': 8.17.0 - '@typescript-eslint/typescript-estree': 8.17.0(typescript@5.6.3) + '@typescript-eslint/typescript-estree': 8.17.0(typescript@5.4.5) '@typescript-eslint/visitor-keys': 8.17.0 debug: 4.3.4(supports-color@5.5.0) - eslint: 9.16.0(jiti@1.21.6) + eslint: 8.57.0 optionalDependencies: - typescript: 5.6.3 + typescript: 5.4.5 transitivePeerDependencies: - supports-color @@ -30105,15 +29796,15 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/type-utils@8.17.0(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3)': + '@typescript-eslint/type-utils@8.17.0(eslint@8.57.0)(typescript@5.4.5)': dependencies: - '@typescript-eslint/typescript-estree': 8.17.0(typescript@5.6.3) - '@typescript-eslint/utils': 8.17.0(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3) + '@typescript-eslint/typescript-estree': 8.17.0(typescript@5.4.5) + '@typescript-eslint/utils': 8.17.0(eslint@8.57.0)(typescript@5.4.5) debug: 4.3.4(supports-color@5.5.0) - eslint: 9.16.0(jiti@1.21.6) - ts-api-utils: 1.3.0(typescript@5.6.3) + eslint: 8.57.0 + ts-api-utils: 1.3.0(typescript@5.4.5) optionalDependencies: - typescript: 5.6.3 + typescript: 5.4.5 transitivePeerDependencies: - supports-color @@ -30314,7 +30005,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/typescript-estree@8.17.0(typescript@5.6.3)': + '@typescript-eslint/typescript-estree@8.17.0(typescript@5.4.5)': dependencies: '@typescript-eslint/types': 8.17.0 '@typescript-eslint/visitor-keys': 8.17.0 @@ -30323,9 +30014,9 @@ snapshots: is-glob: 4.0.3 minimatch: 9.0.5 semver: 7.6.3 - ts-api-utils: 1.3.0(typescript@5.6.3) + ts-api-utils: 1.3.0(typescript@5.4.5) optionalDependencies: - typescript: 5.6.3 + typescript: 5.4.5 transitivePeerDependencies: - supports-color @@ -30478,15 +30169,15 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.17.0(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3)': + '@typescript-eslint/utils@8.17.0(eslint@8.57.0)(typescript@5.4.5)': dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@9.16.0(jiti@1.21.6)) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) '@typescript-eslint/scope-manager': 8.17.0 '@typescript-eslint/types': 8.17.0 - '@typescript-eslint/typescript-estree': 8.17.0(typescript@5.6.3) - eslint: 9.16.0(jiti@1.21.6) + '@typescript-eslint/typescript-estree': 8.17.0(typescript@5.4.5) + eslint: 8.57.0 optionalDependencies: - typescript: 5.6.3 + typescript: 5.4.5 transitivePeerDependencies: - supports-color @@ -30760,32 +30451,6 @@ snapshots: - supports-color - terser - '@vanilla-extract/integration@7.1.7(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)': - dependencies: - '@babel/core': 7.24.7 - '@babel/plugin-syntax-typescript': 7.24.7(@babel/core@7.24.7) - '@vanilla-extract/babel-plugin-debug-ids': 1.0.6 - '@vanilla-extract/css': 1.15.3 - dedent: 1.5.3 - esbuild: 0.21.5 - eval: 0.1.8 - find-up: 5.0.0 - javascript-stringify: 2.1.0 - mlly: 1.7.1 - vite: 5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) - vite-node: 1.6.0(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - less - - lightningcss - - sass - - sass-embedded - - stylus - - sugarss - - supports-color - - terser - '@vanilla-extract/next-plugin@2.1.2(@types/node@20.14.9)(lightningcss@1.25.1)(next@14.2.2(@opentelemetry/api@1.9.0)(@playwright/test@1.46.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(terser@5.31.1)(webpack@5.88.2)': dependencies: '@vanilla-extract/webpack-plugin': 2.3.7(@types/node@20.14.9)(lightningcss@1.25.1)(terser@5.31.1)(webpack@5.88.2) @@ -30931,25 +30596,9 @@ snapshots: - supports-color - terser - '@vanilla-extract/vite-plugin@4.0.17(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)(vite@5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1))': + '@vanilla-extract/vite-plugin@4.0.17(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1))': dependencies: '@vanilla-extract/integration': 7.1.11(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) - vite: 5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) - transitivePeerDependencies: - - '@types/node' - - babel-plugin-macros - - less - - lightningcss - - sass - - sass-embedded - - stylus - - sugarss - - supports-color - - terser - - '@vanilla-extract/vite-plugin@4.0.7(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1))': - dependencies: - '@vanilla-extract/integration': 7.1.7(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) vite: 5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) transitivePeerDependencies: - '@types/node' @@ -31077,23 +30726,16 @@ snapshots: - supports-color - terser - '@vitejs/plugin-react-swc@3.7.0(@swc/helpers@0.5.11)(vite@5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1))': - dependencies: - '@swc/core': 1.6.7(@swc/helpers@0.5.11) - vite: 5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) - transitivePeerDependencies: - - '@swc/helpers' - '@vitejs/plugin-react-swc@3.7.0(@swc/helpers@0.5.11)(vite@5.4.9(@types/node@20.14.9)(lightningcss@1.25.1)(terser@5.31.1))': dependencies: - '@swc/core': 1.6.7(@swc/helpers@0.5.11) + '@swc/core': 1.9.2(@swc/helpers@0.5.11) vite: 5.4.9(@types/node@20.14.9)(lightningcss@1.25.1)(terser@5.31.1) transitivePeerDependencies: - '@swc/helpers' '@vitejs/plugin-react-swc@3.7.0(@swc/helpers@0.5.11)(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1))': dependencies: - '@swc/core': 1.6.7(@swc/helpers@0.5.11) + '@swc/core': 1.9.2(@swc/helpers@0.5.11) vite: 5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) transitivePeerDependencies: - '@swc/helpers' @@ -31736,10 +31378,6 @@ snapshots: dependencies: acorn: 8.11.3 - acorn-jsx@5.3.2(acorn@8.14.0): - dependencies: - acorn: 8.14.0 - acorn-node@1.8.2: dependencies: acorn: 7.4.1 @@ -31756,8 +31394,6 @@ snapshots: acorn@8.11.3: {} - acorn@8.14.0: {} - agent-base@6.0.2: dependencies: debug: 4.3.4(supports-color@5.5.0) @@ -33307,12 +32943,6 @@ snapshots: shebang-command: 2.0.0 which: 2.0.2 - cross-spawn@7.0.6: - dependencies: - path-key: 3.1.1 - shebang-command: 2.0.0 - which: 2.0.2 - crossws@0.2.4: {} crypto-browserify@3.12.0: @@ -34591,13 +34221,9 @@ snapshots: dependencies: eslint: 8.57.0 - eslint-plugin-react-hooks@5.1.0(eslint@9.16.0(jiti@1.21.6)): - dependencies: - eslint: 9.16.0(jiti@1.21.6) - - eslint-plugin-react-refresh@0.4.16(eslint@9.16.0(jiti@1.21.6)): + eslint-plugin-react-refresh@0.4.16(eslint@8.57.0): dependencies: - eslint: 9.16.0(jiti@1.21.6) + eslint: 8.57.0 eslint-plugin-react-refresh@0.4.7(eslint@8.57.0): dependencies: @@ -34667,11 +34293,6 @@ snapshots: esrecurse: 4.3.0 estraverse: 5.3.0 - eslint-scope@8.2.0: - dependencies: - esrecurse: 4.3.0 - estraverse: 5.3.0 - eslint-utils@2.1.0: dependencies: eslint-visitor-keys: 1.3.0 @@ -34777,53 +34398,6 @@ snapshots: transitivePeerDependencies: - supports-color - eslint@9.16.0(jiti@1.21.6): - dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@9.16.0(jiti@1.21.6)) - '@eslint-community/regexpp': 4.12.1 - '@eslint/config-array': 0.19.1 - '@eslint/core': 0.9.1 - '@eslint/eslintrc': 3.2.0 - '@eslint/js': 9.16.0 - '@eslint/plugin-kit': 0.2.4 - '@humanfs/node': 0.16.6 - '@humanwhocodes/module-importer': 1.0.1 - '@humanwhocodes/retry': 0.4.1 - '@types/estree': 1.0.6 - '@types/json-schema': 7.0.15 - ajv: 6.12.6 - chalk: 4.1.2 - cross-spawn: 7.0.6 - debug: 4.3.4(supports-color@5.5.0) - escape-string-regexp: 4.0.0 - eslint-scope: 8.2.0 - eslint-visitor-keys: 4.2.0 - espree: 10.3.0 - esquery: 1.5.0 - esutils: 2.0.3 - fast-deep-equal: 3.1.3 - file-entry-cache: 8.0.0 - find-up: 5.0.0 - glob-parent: 6.0.2 - ignore: 5.3.2 - imurmurhash: 0.1.4 - is-glob: 4.0.3 - json-stable-stringify-without-jsonify: 1.0.1 - lodash.merge: 4.6.2 - minimatch: 3.1.2 - natural-compare: 1.4.0 - optionator: 0.9.4 - optionalDependencies: - jiti: 1.21.6 - transitivePeerDependencies: - - supports-color - - espree@10.3.0: - dependencies: - acorn: 8.14.0 - acorn-jsx: 5.3.2(acorn@8.14.0) - eslint-visitor-keys: 4.2.0 - espree@6.2.1: dependencies: acorn: 7.4.1 @@ -35211,10 +34785,6 @@ snapshots: dependencies: flat-cache: 3.2.0 - file-entry-cache@8.0.0: - dependencies: - flat-cache: 4.0.1 - file-type@17.1.6: dependencies: readable-web-to-node-stream: 3.0.2 @@ -35354,11 +34924,6 @@ snapshots: keyv: 4.5.4 rimraf: 3.0.2 - flat-cache@4.0.1: - dependencies: - flatted: 3.3.1 - keyv: 4.5.4 - flat@5.0.2: {} flatted@3.3.1: {} @@ -35704,8 +35269,6 @@ snapshots: dependencies: type-fest: 0.20.2 - globals@14.0.0: {} - globals@15.13.0: {} globalthis@1.0.4: @@ -39074,28 +38637,6 @@ snapshots: optionalDependencies: msgpackr-extract: 3.0.3 - msw@2.2.14(typescript@5.4.5): - dependencies: - '@bundled-es-modules/cookie': 2.0.0 - '@bundled-es-modules/statuses': 1.0.1 - '@inquirer/confirm': 3.1.13 - '@mswjs/cookies': 1.1.1 - '@mswjs/interceptors': 0.26.15 - '@open-draft/until': 2.1.0 - '@types/cookie': 0.6.0 - '@types/statuses': 2.0.5 - chalk: 4.1.2 - graphql: 16.8.2 - headers-polyfill: 4.0.3 - is-node-process: 1.2.0 - outvariant: 1.4.2 - path-to-regexp: 6.2.2 - strict-event-emitter: 0.5.1 - type-fest: 4.21.0 - yargs: 17.7.2 - optionalDependencies: - typescript: 5.4.5 - msw@2.3.1(typescript@5.4.5): dependencies: '@bundled-es-modules/cookie': 2.0.0 @@ -40165,13 +39706,13 @@ snapshots: postcss: 8.4.47 ts-node: 10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(@types/node@20.14.9)(typescript@5.4.5) - postcss-load-config@4.0.2(postcss@8.4.47)(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(@types/node@22.9.1)(typescript@5.6.3)): + postcss-load-config@4.0.2(postcss@8.4.47)(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(@types/node@22.9.1)(typescript@5.4.5)): dependencies: lilconfig: 3.1.2 yaml: 2.4.5 optionalDependencies: postcss: 8.4.47 - ts-node: 10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(@types/node@22.9.1)(typescript@5.6.3) + ts-node: 10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(@types/node@22.9.1)(typescript@5.4.5) postcss-merge-longhand@7.0.2(postcss@8.4.47): dependencies: @@ -42538,7 +42079,7 @@ snapshots: transitivePeerDependencies: - ts-node - tailwindcss@3.4.4(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(@types/node@22.9.1)(typescript@5.6.3)): + tailwindcss@3.4.4(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(@types/node@22.9.1)(typescript@5.4.5)): dependencies: '@alloc/quick-lru': 5.2.0 arg: 5.0.2 @@ -42557,7 +42098,7 @@ snapshots: postcss: 8.4.47 postcss-import: 15.1.0(postcss@8.4.47) postcss-js: 4.0.1(postcss@8.4.47) - postcss-load-config: 4.0.2(postcss@8.4.47)(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(@types/node@22.9.1)(typescript@5.6.3)) + postcss-load-config: 4.0.2(postcss@8.4.47)(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(@types/node@22.9.1)(typescript@5.4.5)) postcss-nested: 6.0.1(postcss@8.4.47) postcss-selector-parser: 6.1.0 resolve: 1.22.8 @@ -42924,7 +42465,7 @@ snapshots: optionalDependencies: '@swc/core': 1.9.2(@swc/helpers@0.5.11) - ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(@types/node@22.9.1)(typescript@5.6.3): + ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.11))(@types/node@22.9.1)(typescript@5.4.5): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.11 @@ -42938,7 +42479,7 @@ snapshots: create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 5.6.3 + typescript: 5.4.5 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 optionalDependencies: @@ -43125,14 +42666,14 @@ snapshots: dependencies: typescript-logic: 0.0.0 - typescript-eslint@8.17.0(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3): + typescript-eslint@8.17.0(eslint@8.57.0)(typescript@5.4.5): dependencies: - '@typescript-eslint/eslint-plugin': 8.17.0(@typescript-eslint/parser@8.17.0(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3))(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3) - '@typescript-eslint/parser': 8.17.0(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3) - '@typescript-eslint/utils': 8.17.0(eslint@9.16.0(jiti@1.21.6))(typescript@5.6.3) - eslint: 9.16.0(jiti@1.21.6) + '@typescript-eslint/eslint-plugin': 8.17.0(@typescript-eslint/parser@8.17.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/parser': 8.17.0(eslint@8.57.0)(typescript@5.4.5) + '@typescript-eslint/utils': 8.17.0(eslint@8.57.0)(typescript@5.4.5) + eslint: 8.57.0 optionalDependencies: - typescript: 5.6.3 + typescript: 5.4.5 transitivePeerDependencies: - supports-color @@ -43757,21 +43298,21 @@ snapshots: transitivePeerDependencies: - rollup - vite-plugin-static-copy@1.0.6(vite@5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)): + vite-plugin-static-copy@1.0.6(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)): dependencies: chokidar: 3.6.0 fast-glob: 3.3.2 fs-extra: 11.2.0 picocolors: 1.0.1 - vite: 5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) + vite: 5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) - vite-tsconfig-paths@4.3.2(typescript@5.4.5)(vite@5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)): + vite-tsconfig-paths@4.3.2(typescript@5.4.5)(vite@5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1)): dependencies: debug: 4.3.4(supports-color@5.5.0) globrex: 0.1.2 tsconfck: 3.1.1(typescript@5.4.5) optionalDependencies: - vite: 5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) + vite: 5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) transitivePeerDependencies: - supports-color - typescript @@ -43787,39 +43328,6 @@ snapshots: - supports-color - typescript - vite@5.3.3(@types/node@20.14.9)(lightningcss@1.25.1)(terser@5.31.1): - dependencies: - esbuild: 0.21.5 - postcss: 8.4.47 - rollup: 4.18.0 - optionalDependencies: - '@types/node': 20.14.9 - fsevents: 2.3.3 - lightningcss: 1.25.1 - terser: 5.31.1 - - vite@5.3.3(@types/node@20.16.5)(lightningcss@1.25.1)(terser@5.31.1): - dependencies: - esbuild: 0.21.5 - postcss: 8.4.47 - rollup: 4.18.0 - optionalDependencies: - '@types/node': 20.16.5 - fsevents: 2.3.3 - lightningcss: 1.25.1 - terser: 5.31.1 - - vite@5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1): - dependencies: - esbuild: 0.21.5 - postcss: 8.4.47 - rollup: 4.18.0 - optionalDependencies: - '@types/node': 22.9.1 - fsevents: 2.3.3 - lightningcss: 1.25.1 - terser: 5.31.1 - vite@5.4.9(@types/node@20.14.9)(lightningcss@1.25.1)(terser@5.31.1): dependencies: esbuild: 0.21.5 @@ -43882,7 +43390,7 @@ snapshots: strip-literal: 2.1.0 tinybench: 2.8.0 tinypool: 0.8.4 - vite: 5.3.3(@types/node@20.14.9)(lightningcss@1.25.1)(terser@5.31.1) + vite: 5.4.9(@types/node@20.14.9)(lightningcss@1.25.1)(terser@5.31.1) vite-node: 1.6.0(@types/node@20.14.9)(lightningcss@1.25.1)(terser@5.31.1) why-is-node-running: 2.2.2 optionalDependencies: @@ -43919,7 +43427,7 @@ snapshots: strip-literal: 2.1.0 tinybench: 2.8.0 tinypool: 0.8.4 - vite: 5.3.3(@types/node@20.16.5)(lightningcss@1.25.1)(terser@5.31.1) + vite: 5.4.9(@types/node@20.16.5)(lightningcss@1.25.1)(terser@5.31.1) vite-node: 1.6.0(@types/node@20.16.5)(lightningcss@1.25.1)(terser@5.31.1) why-is-node-running: 2.2.2 optionalDependencies: @@ -43956,7 +43464,7 @@ snapshots: strip-literal: 2.1.0 tinybench: 2.8.0 tinypool: 0.8.4 - vite: 5.3.3(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) + vite: 5.4.9(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) vite-node: 1.6.0(@types/node@22.9.1)(lightningcss@1.25.1)(terser@5.31.1) why-is-node-running: 2.2.2 optionalDependencies: From 680001f3de8debe08f3baa2fea9556392b20a77e Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 11:25:30 +0100 Subject: [PATCH 077/103] fix: Removed unused code in client-utils --- packages/libs/client-utils/src/coin/index.ts | 1 - .../src/coin/simple-transfer-create.ts | 93 ------------------- 2 files changed, 94 deletions(-) delete mode 100644 packages/libs/client-utils/src/coin/simple-transfer-create.ts diff --git a/packages/libs/client-utils/src/coin/index.ts b/packages/libs/client-utils/src/coin/index.ts index 394147de44..23de952961 100644 --- a/packages/libs/client-utils/src/coin/index.ts +++ b/packages/libs/client-utils/src/coin/index.ts @@ -5,7 +5,6 @@ export * from './get-balance'; export * from './rotate'; export * from './safe-transfer'; export * from './safe-transfer-create'; -export * from './simple-transfer-create'; export * from './transfer'; export * from './transfer-all'; export * from './transfer-create'; diff --git a/packages/libs/client-utils/src/coin/simple-transfer-create.ts b/packages/libs/client-utils/src/coin/simple-transfer-create.ts deleted file mode 100644 index 0bf2f26cea..0000000000 --- a/packages/libs/client-utils/src/coin/simple-transfer-create.ts +++ /dev/null @@ -1,93 +0,0 @@ -import type { - ChainId, - IPactModules, - ISigner, - PactReturnType, -} from '@kadena/client'; -import { Pact, readKeyset } from '@kadena/client'; -import { - addKeyset, - addSigner, - composePactCommand, - execution, - setMeta, -} from '@kadena/client/fp'; - -import { submitClient } from '../core/client-helpers'; -import type { IClientConfig } from '../core/utils/helpers'; - -interface ICreateSimpleTransferInput { - sender: string; - receiver: string; - amount: string; - gasPayer?: { account: string; publicKeys: ISigner[] }; - chainId: ChainId; - /** - * compatible contract with fungible-v2; default is "coin" - */ - contract?: string; -} - -/** - * @alpha - * transfer create that only supports `k:` accounts for sender and receiver. - * Accepts either account name or public key - */ -export const simpleTransferCreateCommand = ({ - sender, - receiver, - amount, - gasPayer, - chainId, - contract = 'coin', -}: ICreateSimpleTransferInput) => { - const senderPublicKey = sender.startsWith('k:') - ? sender.substring(2) - : sender; - const senderAccount = `k:${senderPublicKey}`; - - const receiverPublicKey = receiver.startsWith('k:') - ? receiver.substring(2) - : receiver; - const receiverAccount = `k:${receiverPublicKey}`; - - const gasPayerPublicKeys = gasPayer ? gasPayer.publicKeys : [senderPublicKey]; - const gasPayerAccount = gasPayer ? gasPayer.account : senderAccount; - - return composePactCommand( - execution( - Pact.modules[contract as 'coin']['transfer-create']( - senderAccount, - receiverAccount, - readKeyset('account-guard'), - { - decimal: amount, - }, - ), - ), - addKeyset('account-guard', 'keys-all', receiverPublicKey), - addSigner(senderPublicKey, (signFor) => [ - signFor( - `${contract as 'coin'}.TRANSFER`, - senderAccount, - receiverAccount, - { - decimal: amount, - }, - ), - ]), - addSigner(gasPayerPublicKeys, (signFor) => [signFor('coin.GAS')]), - setMeta({ senderAccount: gasPayerAccount, chainId }), - ); -}; - -/** - * @alpha - */ -export const simpleTransferCreate = ( - inputs: ICreateSimpleTransferInput, - config: IClientConfig, -) => - submitClient>(config)( - simpleTransferCreateCommand(inputs), - ); From 7806939f1b3efca1ccb527af751388349d33a83c Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 12:32:30 +0100 Subject: [PATCH 078/103] feat(wallet-sdk): set up api extractor docs and export all required interfaces --- .../libs/wallet-sdk/etc/wallet-sdk.api.json | 3321 +++++++++++++++++ .../libs/wallet-sdk/etc/wallet-sdk.api.md | 274 ++ packages/libs/wallet-sdk/src/index.ts | 2 + packages/libs/wallet-sdk/src/sdk/host.ts | 6 + packages/libs/wallet-sdk/src/sdk/interface.ts | 57 + packages/libs/wallet-sdk/src/sdk/logger.ts | 7 + packages/libs/wallet-sdk/src/sdk/walletSdk.ts | 6 + 7 files changed, 3673 insertions(+) create mode 100644 packages/libs/wallet-sdk/etc/wallet-sdk.api.json create mode 100644 packages/libs/wallet-sdk/etc/wallet-sdk.api.md diff --git a/packages/libs/wallet-sdk/etc/wallet-sdk.api.json b/packages/libs/wallet-sdk/etc/wallet-sdk.api.json new file mode 100644 index 0000000000..573934b148 --- /dev/null +++ b/packages/libs/wallet-sdk/etc/wallet-sdk.api.json @@ -0,0 +1,3321 @@ +{ + "metadata": { + "toolPackage": "@microsoft/api-extractor", + "toolVersion": "7.47.0", + "schemaVersion": 1011, + "oldestForwardsCompatibleVersion": 1001, + "tsdocConfig": { + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "noStandardTags": true, + "tagDefinitions": [ + { + "tagName": "@alpha", + "syntaxKind": "modifier" + }, + { + "tagName": "@beta", + "syntaxKind": "modifier" + }, + { + "tagName": "@defaultValue", + "syntaxKind": "block" + }, + { + "tagName": "@decorator", + "syntaxKind": "block", + "allowMultiple": true + }, + { + "tagName": "@deprecated", + "syntaxKind": "block" + }, + { + "tagName": "@eventProperty", + "syntaxKind": "modifier" + }, + { + "tagName": "@example", + "syntaxKind": "block", + "allowMultiple": true + }, + { + "tagName": "@experimental", + "syntaxKind": "modifier" + }, + { + "tagName": "@inheritDoc", + "syntaxKind": "inline" + }, + { + "tagName": "@internal", + "syntaxKind": "modifier" + }, + { + "tagName": "@label", + "syntaxKind": "inline" + }, + { + "tagName": "@link", + "syntaxKind": "inline", + "allowMultiple": true + }, + { + "tagName": "@override", + "syntaxKind": "modifier" + }, + { + "tagName": "@packageDocumentation", + "syntaxKind": "modifier" + }, + { + "tagName": "@param", + "syntaxKind": "block", + "allowMultiple": true + }, + { + "tagName": "@privateRemarks", + "syntaxKind": "block" + }, + { + "tagName": "@public", + "syntaxKind": "modifier" + }, + { + "tagName": "@readonly", + "syntaxKind": "modifier" + }, + { + "tagName": "@remarks", + "syntaxKind": "block" + }, + { + "tagName": "@returns", + "syntaxKind": "block" + }, + { + "tagName": "@sealed", + "syntaxKind": "modifier" + }, + { + "tagName": "@see", + "syntaxKind": "block" + }, + { + "tagName": "@throws", + "syntaxKind": "block", + "allowMultiple": true + }, + { + "tagName": "@typeParam", + "syntaxKind": "block", + "allowMultiple": true + }, + { + "tagName": "@virtual", + "syntaxKind": "modifier" + }, + { + "tagName": "@betaDocumentation", + "syntaxKind": "modifier" + }, + { + "tagName": "@internalRemarks", + "syntaxKind": "block" + }, + { + "tagName": "@preapproved", + "syntaxKind": "modifier" + } + ], + "supportForTags": { + "@alpha": true, + "@beta": true, + "@defaultValue": true, + "@decorator": true, + "@deprecated": true, + "@eventProperty": true, + "@example": true, + "@experimental": true, + "@inheritDoc": true, + "@internal": true, + "@label": true, + "@link": true, + "@override": true, + "@packageDocumentation": true, + "@param": true, + "@privateRemarks": true, + "@public": true, + "@readonly": true, + "@remarks": true, + "@returns": true, + "@sealed": true, + "@see": true, + "@throws": true, + "@typeParam": true, + "@virtual": true, + "@betaDocumentation": true, + "@internalRemarks": true, + "@preapproved": true + }, + "reportUnsupportedHtmlElements": false + } + }, + "kind": "Package", + "canonicalReference": "@kadena/wallet-sdk!", + "docComment": "", + "name": "@kadena/wallet-sdk", + "preserveMemberOrder": false, + "members": [ + { + "kind": "EntryPoint", + "canonicalReference": "@kadena/wallet-sdk!", + "name": "", + "preserveMemberOrder": false, + "members": [ + { + "kind": "TypeAlias", + "canonicalReference": "@kadena/wallet-sdk!ChainwebHostGenerator:type", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export type ChainwebHostGenerator = " + }, + { + "kind": "Content", + "text": "(options: {\n networkId: string;\n chainId: string;\n}) => string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "fileUrlPath": "src/sdk/host.ts", + "releaseTag": "Public", + "name": "ChainwebHostGenerator", + "typeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "TypeAlias", + "canonicalReference": "@kadena/wallet-sdk!GraphqlHostGenerator:type", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export type GraphqlHostGenerator = " + }, + { + "kind": "Content", + "text": "(options: {\n networkId: string;\n}) => string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "fileUrlPath": "src/sdk/host.ts", + "releaseTag": "Public", + "name": "GraphqlHostGenerator", + "typeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!IAccountDetails:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface IAccountDetails " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "IAccountDetails", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IAccountDetails#accountDetails:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "accountDetails: " + }, + { + "kind": "Reference", + "text": "IAccountDetailsResult", + "canonicalReference": "@kadena/wallet-sdk!IAccountDetailsResult:interface" + }, + { + "kind": "Content", + "text": " | null" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "accountDetails", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 3 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IAccountDetails#chainId:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "chainId: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "chainId", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + } + ], + "extendsTokenRanges": [] + }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!IAccountDetailsResult:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface IAccountDetailsResult " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "IAccountDetailsResult", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IAccountDetailsResult#account:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "account: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "account", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IAccountDetailsResult#balance:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "balance: " + }, + { + "kind": "Content", + "text": "number | {\n decimal: number;\n }" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "balance", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IAccountDetailsResult#guard:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "guard: " + }, + { + "kind": "Reference", + "text": "IGuard", + "canonicalReference": "@kadena/wallet-sdk!IGuard:interface" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "guard", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + } + ], + "extendsTokenRanges": [] + }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!IChain:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface IChain " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "IChain", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IChain#id:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "id: " + }, + { + "kind": "Reference", + "text": "ChainId", + "canonicalReference": "@kadena/types!ChainId:type" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "id", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + } + ], + "extendsTokenRanges": [] + }, + { + "kind": "TypeAlias", + "canonicalReference": "@kadena/wallet-sdk!ICreateCrossChainTransfer:type", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export type ICreateCrossChainTransfer = " + }, + { + "kind": "Reference", + "text": "Parameters", + "canonicalReference": "!Parameters:type" + }, + { + "kind": "Content", + "text": "[0]" + }, + { + "kind": "Content", + "text": ";" + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "ICreateCrossChainTransfer", + "typeTokenRange": { + "startIndex": 1, + "endIndex": 5 + } + }, + { + "kind": "TypeAlias", + "canonicalReference": "@kadena/wallet-sdk!ICreateTransfer:type", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export type ICreateTransfer = " + }, + { + "kind": "Reference", + "text": "Parameters", + "canonicalReference": "!Parameters:type" + }, + { + "kind": "Content", + "text": "[0]" + }, + { + "kind": "Content", + "text": ";" + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "ICreateTransfer", + "typeTokenRange": { + "startIndex": 1, + "endIndex": 5 + } + }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!ICrossChainTransfer:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface ICrossChainTransfer extends " + }, + { + "kind": "Reference", + "text": "IBaseTransfer", + "canonicalReference": "@kadena/wallet-sdk!~IBaseTransfer:interface" + }, + { + "kind": "Content", + "text": " " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "ICrossChainTransfer", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ICrossChainTransfer#continuation:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "continuation?: " + }, + { + "kind": "Content", + "text": "{\n requestKey: string;\n success: boolean;\n }" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "continuation", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ICrossChainTransfer#isCrossChainTransfer:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "isCrossChainTransfer: " + }, + { + "kind": "Content", + "text": "true" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "isCrossChainTransfer", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ICrossChainTransfer#targetChainId:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "targetChainId: " + }, + { + "kind": "Reference", + "text": "ChainId", + "canonicalReference": "@kadena/types!ChainId:type" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "targetChainId", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + } + ], + "extendsTokenRanges": [ + { + "startIndex": 1, + "endIndex": 2 + } + ] + }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!IEthvmDevTokenInfo:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface IEthvmDevTokenInfo " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "IEthvmDevTokenInfo", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IEthvmDevTokenInfo#circulatingSupply:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "circulatingSupply?: " + }, + { + "kind": "Content", + "text": "number" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "circulatingSupply", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IEthvmDevTokenInfo#currentPrice:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "currentPrice?: " + }, + { + "kind": "Content", + "text": "number" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "currentPrice", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IEthvmDevTokenInfo#high24h:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "high24h?: " + }, + { + "kind": "Content", + "text": "number" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "high24h", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IEthvmDevTokenInfo#low24h:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "low24h?: " + }, + { + "kind": "Content", + "text": "number" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "low24h", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IEthvmDevTokenInfo#maxSupply:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "maxSupply?: " + }, + { + "kind": "Content", + "text": "number" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "maxSupply", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IEthvmDevTokenInfo#totalSupply:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "totalSupply?: " + }, + { + "kind": "Content", + "text": "number" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "totalSupply", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + } + ], + "extendsTokenRanges": [] + }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!IGuard:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface IGuard " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "IGuard", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IGuard#keys:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "keys: " + }, + { + "kind": "Content", + "text": "string[]" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "keys", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!IGuard#pred:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "pred: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "pred", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + } + ], + "extendsTokenRanges": [] + }, + { + "kind": "TypeAlias", + "canonicalReference": "@kadena/wallet-sdk!ILogTransport:type", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export type ILogTransport = " + }, + { + "kind": "Content", + "text": "(log: " + }, + { + "kind": "Reference", + "text": "ILogObject", + "canonicalReference": "@kadena/wallet-sdk!~ILogObject:interface" + }, + { + "kind": "Content", + "text": ") => void" + }, + { + "kind": "Content", + "text": ";" + } + ], + "fileUrlPath": "src/sdk/logger.ts", + "releaseTag": "Public", + "name": "ILogTransport", + "typeTokenRange": { + "startIndex": 1, + "endIndex": 4 + } + }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface INetworkInfo " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "INetworkInfo", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo#nodeApiVersion:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "nodeApiVersion: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "nodeApiVersion", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo#nodeBlockDelay:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "nodeBlockDelay: " + }, + { + "kind": "Content", + "text": "number" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "nodeBlockDelay", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo#nodeChains:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "nodeChains: " + }, + { + "kind": "Content", + "text": "string[]" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "nodeChains", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo#nodeGenesisHeights:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "nodeGenesisHeights: " + }, + { + "kind": "Content", + "text": "[string, number][]" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "nodeGenesisHeights", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo#nodeGraphHistory:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "nodeGraphHistory: " + }, + { + "kind": "Content", + "text": "[number, [number, [string, string[]]][]][]" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "nodeGraphHistory", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo#nodeHistoricalChains:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "nodeHistoricalChains: " + }, + { + "kind": "Content", + "text": "[number, [number, [string, string[]]][]][]" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "nodeHistoricalChains", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo#nodeLatestBehaviorHeight:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "nodeLatestBehaviorHeight: " + }, + { + "kind": "Content", + "text": "number" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "nodeLatestBehaviorHeight", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo#nodeNumberOfChains:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "nodeNumberOfChains: " + }, + { + "kind": "Content", + "text": "number" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "nodeNumberOfChains", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo#nodePackageVersion:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "nodePackageVersion: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "nodePackageVersion", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo#nodeServiceDate:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "nodeServiceDate: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "nodeServiceDate", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo#nodeVersion:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "nodeVersion: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "nodeVersion", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + } + ], + "extendsTokenRanges": [] + }, + { + "kind": "TypeAlias", + "canonicalReference": "@kadena/wallet-sdk!INodeChainInfo:type", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export type INodeChainInfo = " + }, + { + "kind": "Reference", + "text": "Pick", + "canonicalReference": "!Pick:type" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "INetworkInfo", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo:interface" + }, + { + "kind": "Content", + "text": ", 'nodeChains' | 'nodeVersion'>" + }, + { + "kind": "Content", + "text": ";" + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "INodeChainInfo", + "typeTokenRange": { + "startIndex": 1, + "endIndex": 5 + } + }, + { + "kind": "TypeAlias", + "canonicalReference": "@kadena/wallet-sdk!INodeNetworkInfo:type", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export type INodeNetworkInfo = " + }, + { + "kind": "Reference", + "text": "Omit", + "canonicalReference": "!Omit:type" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "INetworkInfo", + "canonicalReference": "@kadena/wallet-sdk!INetworkInfo:interface" + }, + { + "kind": "Content", + "text": ", 'nodeChains'>" + }, + { + "kind": "Content", + "text": ";" + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "INodeNetworkInfo", + "typeTokenRange": { + "startIndex": 1, + "endIndex": 5 + } + }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!ITransaction:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface ITransaction " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "ITransaction", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransaction#chainId:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "chainId: " + }, + { + "kind": "Reference", + "text": "ChainId", + "canonicalReference": "@kadena/types!ChainId:type" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "chainId", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransaction#requestKey:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "requestKey: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "requestKey", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + } + ], + "extendsTokenRanges": [] + }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!ITransactionDescriptor:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface ITransactionDescriptor " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "ITransactionDescriptor", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransactionDescriptor#chainId:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "chainId: " + }, + { + "kind": "Reference", + "text": "ChainId", + "canonicalReference": "@kadena/types!ChainId:type" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "chainId", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransactionDescriptor#networkId:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "networkId: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "networkId", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransactionDescriptor#requestKey:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "requestKey: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "requestKey", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + } + ], + "extendsTokenRanges": [] + }, + { + "kind": "TypeAlias", + "canonicalReference": "@kadena/wallet-sdk!ITransfer:type", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export type ITransfer = " + }, + { + "kind": "Reference", + "text": "ISameChainTransfer", + "canonicalReference": "@kadena/wallet-sdk!~ISameChainTransfer:interface" + }, + { + "kind": "Content", + "text": " | " + }, + { + "kind": "Reference", + "text": "ICrossChainTransfer", + "canonicalReference": "@kadena/wallet-sdk!ICrossChainTransfer:interface" + }, + { + "kind": "Content", + "text": ";" + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "ITransfer", + "typeTokenRange": { + "startIndex": 1, + "endIndex": 4 + } + }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!ITransferOptions:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface ITransferOptions " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "ITransferOptions", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransferOptions#accountName:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "accountName: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "accountName", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransferOptions#after:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "after?: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "after", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransferOptions#before:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "before?: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "before", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransferOptions#chainId:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "chainId?: " + }, + { + "kind": "Reference", + "text": "ChainId", + "canonicalReference": "@kadena/types!ChainId:type" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "chainId", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransferOptions#first:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "first?: " + }, + { + "kind": "Content", + "text": "number" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "first", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransferOptions#fungibleName:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "fungibleName?: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "fungibleName", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransferOptions#last:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "last?: " + }, + { + "kind": "Content", + "text": "number" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": true, + "releaseTag": "Public", + "name": "last", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransferOptions#networkId:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "networkId: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "networkId", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + } + ], + "extendsTokenRanges": [] + }, + { + "kind": "Interface", + "canonicalReference": "@kadena/wallet-sdk!ITransferResponse:interface", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export interface ITransferResponse " + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "ITransferResponse", + "preserveMemberOrder": false, + "members": [ + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransferResponse#pageInfo:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "pageInfo: " + }, + { + "kind": "Content", + "text": "{\n hasNextPage: boolean;\n hasPreviousPage: boolean;\n startCursor: string | null;\n endCursor: string | null;\n }" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "pageInfo", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "PropertySignature", + "canonicalReference": "@kadena/wallet-sdk!ITransferResponse#transfers:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "transfers: " + }, + { + "kind": "Reference", + "text": "ITransfer", + "canonicalReference": "@kadena/wallet-sdk!ITransfer:type" + }, + { + "kind": "Content", + "text": "[]" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "transfers", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 3 + } + } + ], + "extendsTokenRanges": [] + }, + { + "kind": "TypeAlias", + "canonicalReference": "@kadena/wallet-sdk!LogLevel:type", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export type LogLevel = " + }, + { + "kind": "Content", + "text": "keyof typeof " + }, + { + "kind": "Reference", + "text": "LOG_LEVELS", + "canonicalReference": "@kadena/wallet-sdk!~LOG_LEVELS:var" + }, + { + "kind": "Content", + "text": ";" + } + ], + "fileUrlPath": "src/sdk/logger.ts", + "releaseTag": "Public", + "name": "LogLevel", + "typeTokenRange": { + "startIndex": 1, + "endIndex": 3 + } + }, + { + "kind": "TypeAlias", + "canonicalReference": "@kadena/wallet-sdk!RequestKey:type", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export type RequestKey = " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ";" + } + ], + "fileUrlPath": "src/sdk/interface.ts", + "releaseTag": "Public", + "name": "RequestKey", + "typeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + }, + { + "kind": "Class", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK:class", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "export declare class WalletSDK " + } + ], + "fileUrlPath": "src/sdk/walletSdk.ts", + "releaseTag": "Public", + "isAbstract": false, + "name": "WalletSDK", + "preserveMemberOrder": false, + "members": [ + { + "kind": "Constructor", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK:constructor(1)", + "docComment": "/**\n * Constructs a new instance of the `WalletSDK` class\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "constructor(options?: " + }, + { + "kind": "Content", + "text": "{\n chainwebHostGenerator?: " + }, + { + "kind": "Reference", + "text": "ChainwebHostGenerator", + "canonicalReference": "@kadena/wallet-sdk!ChainwebHostGenerator:type" + }, + { + "kind": "Content", + "text": ";\n graphqlHostGenerator?: " + }, + { + "kind": "Reference", + "text": "GraphqlHostGenerator", + "canonicalReference": "@kadena/wallet-sdk!GraphqlHostGenerator:type" + }, + { + "kind": "Content", + "text": ";\n logTransport?: " + }, + { + "kind": "Reference", + "text": "ILogTransport", + "canonicalReference": "@kadena/wallet-sdk!ILogTransport:type" + }, + { + "kind": "Content", + "text": ";\n logLevel?: " + }, + { + "kind": "Reference", + "text": "LogLevel", + "canonicalReference": "@kadena/wallet-sdk!LogLevel:type" + }, + { + "kind": "Content", + "text": ";\n }" + }, + { + "kind": "Content", + "text": ");" + } + ], + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "options", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 10 + }, + "isOptional": true + } + ] + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#createCrossChainTransfer:member(1)", + "docComment": "/**\n * create cross-chain transfer\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "createCrossChainTransfer(transfer: " + }, + { + "kind": "Reference", + "text": "ICreateCrossChainTransfer", + "canonicalReference": "@kadena/wallet-sdk!ICreateCrossChainTransfer:type" + }, + { + "kind": "Content", + "text": " & {\n networkId: string;\n }" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "IUnsignedCommand", + "canonicalReference": "@kadena/types!IUnsignedCommand:interface" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 4, + "endIndex": 5 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "transfer", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 3 + }, + "isOptional": false + } + ], + "isOptional": false, + "isAbstract": false, + "name": "createCrossChainTransfer" + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#createFinishCrossChainTransfer:member(1)", + "docComment": "/**\n * create cross-chain transfer finish\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "createFinishCrossChainTransfer(transfer: " + }, + { + "kind": "Reference", + "text": "ICreateCrossChainFinishInput", + "canonicalReference": "@kadena/wallet-sdk!~ICreateCrossChainFinishInput:interface" + }, + { + "kind": "Content", + "text": ", gasPayer: " + }, + { + "kind": "Content", + "text": "{\n account: string;\n publicKeys: " + }, + { + "kind": "Reference", + "text": "ISigner", + "canonicalReference": "@kadena/types!ISigner:interface" + }, + { + "kind": "Content", + "text": "[];\n }" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "Promise", + "canonicalReference": "!Promise:interface" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "IUnsignedCommand", + "canonicalReference": "@kadena/types!IUnsignedCommand:interface" + }, + { + "kind": "Content", + "text": ">" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 7, + "endIndex": 11 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "transfer", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isOptional": false + }, + { + "parameterName": "gasPayer", + "parameterTypeTokenRange": { + "startIndex": 3, + "endIndex": 6 + }, + "isOptional": false + } + ], + "isOptional": false, + "isAbstract": false, + "name": "createFinishCrossChainTransfer" + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#createSimpleTransfer:member(1)", + "docComment": "/**\n * Create a transfer that only accepts `k:` accounts\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "createSimpleTransfer(transfer: " + }, + { + "kind": "Reference", + "text": "ICreateSimpleTransferInput", + "canonicalReference": "@kadena/wallet-sdk!~ICreateSimpleTransferInput:interface" + }, + { + "kind": "Content", + "text": " & {\n networkId: string;\n }" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "IUnsignedCommand", + "canonicalReference": "@kadena/types!IUnsignedCommand:interface" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 4, + "endIndex": 5 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "transfer", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 3 + }, + "isOptional": false + } + ], + "isOptional": false, + "isAbstract": false, + "name": "createSimpleTransfer" + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#createTransfer:member(1)", + "docComment": "/**\n * create transfer that accepts any kind of account (requires keys/pred)\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "createTransfer(transfer: " + }, + { + "kind": "Reference", + "text": "ICreateTransfer", + "canonicalReference": "@kadena/wallet-sdk!ICreateTransfer:type" + }, + { + "kind": "Content", + "text": " & {\n networkId: string;\n }" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "IUnsignedCommand", + "canonicalReference": "@kadena/types!IUnsignedCommand:interface" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 4, + "endIndex": 5 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "transfer", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 3 + }, + "isOptional": false + } + ], + "isOptional": false, + "isAbstract": false, + "name": "createTransfer" + }, + { + "kind": "Property", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#exchange:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "exchange: " + }, + { + "kind": "Content", + "text": "typeof " + }, + { + "kind": "Reference", + "text": "exchange", + "canonicalReference": "@kadena/wallet-sdk!~exchange:var" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "exchange", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 3 + }, + "isStatic": false, + "isProtected": false, + "isAbstract": false + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#getAccountDetails:member(1)", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "getAccountDetails(accountName: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ", networkId: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ", fungible: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ", chainIds?: " + }, + { + "kind": "Reference", + "text": "ChainId", + "canonicalReference": "@kadena/types!ChainId:type" + }, + { + "kind": "Content", + "text": "[]" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "Promise", + "canonicalReference": "!Promise:interface" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "IAccountDetails", + "canonicalReference": "@kadena/wallet-sdk!IAccountDetails:interface" + }, + { + "kind": "Content", + "text": "[]>" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 10, + "endIndex": 14 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "accountName", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isOptional": false + }, + { + "parameterName": "networkId", + "parameterTypeTokenRange": { + "startIndex": 3, + "endIndex": 4 + }, + "isOptional": false + }, + { + "parameterName": "fungible", + "parameterTypeTokenRange": { + "startIndex": 5, + "endIndex": 6 + }, + "isOptional": false + }, + { + "parameterName": "chainIds", + "parameterTypeTokenRange": { + "startIndex": 7, + "endIndex": 9 + }, + "isOptional": true + } + ], + "isOptional": false, + "isAbstract": false, + "name": "getAccountDetails" + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#getChains:member(1)", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "getChains(networkHost: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "Promise", + "canonicalReference": "!Promise:interface" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "IChain", + "canonicalReference": "@kadena/wallet-sdk!IChain:interface" + }, + { + "kind": "Content", + "text": "[]>" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 3, + "endIndex": 7 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "networkHost", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isOptional": false + } + ], + "isOptional": false, + "isAbstract": false, + "name": "getChains" + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#getChainwebUrl:member(1)", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "getChainwebUrl(...args: " + }, + { + "kind": "Reference", + "text": "Parameters", + "canonicalReference": "!Parameters:type" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "ChainwebHostGenerator", + "canonicalReference": "@kadena/wallet-sdk!ChainwebHostGenerator:type" + }, + { + "kind": "Content", + "text": ">" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "ReturnType", + "canonicalReference": "!ReturnType:type" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "ChainwebHostGenerator", + "canonicalReference": "@kadena/wallet-sdk!ChainwebHostGenerator:type" + }, + { + "kind": "Content", + "text": ">" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 6, + "endIndex": 10 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "args", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 5 + }, + "isOptional": false + } + ], + "isOptional": false, + "isAbstract": false, + "name": "getChainwebUrl" + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#getGasLimitEstimate:member(1)", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "getGasLimitEstimate(transaction: " + }, + { + "kind": "Reference", + "text": "ICommand", + "canonicalReference": "@kadena/types!ICommand:interface" + }, + { + "kind": "Content", + "text": ", networkId: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ", chainId: " + }, + { + "kind": "Reference", + "text": "ChainId", + "canonicalReference": "@kadena/types!ChainId:type" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "Promise", + "canonicalReference": "!Promise:interface" + }, + { + "kind": "Content", + "text": "" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 7, + "endIndex": 9 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "transaction", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isOptional": false + }, + { + "parameterName": "networkId", + "parameterTypeTokenRange": { + "startIndex": 3, + "endIndex": 4 + }, + "isOptional": false + }, + { + "parameterName": "chainId", + "parameterTypeTokenRange": { + "startIndex": 5, + "endIndex": 6 + }, + "isOptional": false + } + ], + "isOptional": false, + "isAbstract": false, + "name": "getGasLimitEstimate" + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#getGraphqlUrl:member(1)", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "getGraphqlUrl(...args: " + }, + { + "kind": "Reference", + "text": "Parameters", + "canonicalReference": "!Parameters:type" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "GraphqlHostGenerator", + "canonicalReference": "@kadena/wallet-sdk!GraphqlHostGenerator:type" + }, + { + "kind": "Content", + "text": ">" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "ReturnType", + "canonicalReference": "!ReturnType:type" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "GraphqlHostGenerator", + "canonicalReference": "@kadena/wallet-sdk!GraphqlHostGenerator:type" + }, + { + "kind": "Content", + "text": ">" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 6, + "endIndex": 10 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "args", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 5 + }, + "isOptional": false + } + ], + "isOptional": false, + "isAbstract": false, + "name": "getGraphqlUrl" + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#getNetworkInfo:member(1)", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "getNetworkInfo(networkHost: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "Promise", + "canonicalReference": "!Promise:interface" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "INodeNetworkInfo", + "canonicalReference": "@kadena/wallet-sdk!INodeNetworkInfo:type" + }, + { + "kind": "Content", + "text": ">" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 3, + "endIndex": 7 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "networkHost", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isOptional": false + } + ], + "isOptional": false, + "isAbstract": false, + "name": "getNetworkInfo" + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#getTransfers:member(1)", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "getTransfers(options: " + }, + { + "kind": "Reference", + "text": "ITransferOptions", + "canonicalReference": "@kadena/wallet-sdk!ITransferOptions:interface" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "Promise", + "canonicalReference": "!Promise:interface" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "ITransferResponse", + "canonicalReference": "@kadena/wallet-sdk!ITransferResponse:interface" + }, + { + "kind": "Content", + "text": ">" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 3, + "endIndex": 7 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "options", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isOptional": false + } + ], + "isOptional": false, + "isAbstract": false, + "name": "getTransfers" + }, + { + "kind": "Property", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#kadenaNames:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "kadenaNames: " + }, + { + "kind": "Reference", + "text": "KadenaNames", + "canonicalReference": "@kadena/wallet-sdk!~KadenaNames:class" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "kadenaNames", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isStatic": false, + "isProtected": false, + "isAbstract": false + }, + { + "kind": "Property", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#logger:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "logger: " + }, + { + "kind": "Reference", + "text": "Logger", + "canonicalReference": "@kadena/wallet-sdk!~Logger:class" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "logger", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isStatic": false, + "isProtected": false, + "isAbstract": false + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#sendTransaction:member(1)", + "docComment": "/**\n * send signed transaction\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "sendTransaction(transaction: " + }, + { + "kind": "Reference", + "text": "ICommand", + "canonicalReference": "@kadena/types!ICommand:interface" + }, + { + "kind": "Content", + "text": ", networkId: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ", chainId: " + }, + { + "kind": "Reference", + "text": "ChainId", + "canonicalReference": "@kadena/types!ChainId:type" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "Promise", + "canonicalReference": "!Promise:interface" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "ITransactionDescriptor", + "canonicalReference": "@kadena/wallet-sdk!ITransactionDescriptor:interface" + }, + { + "kind": "Content", + "text": ">" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 7, + "endIndex": 11 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "transaction", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isOptional": false + }, + { + "parameterName": "networkId", + "parameterTypeTokenRange": { + "startIndex": 3, + "endIndex": 4 + }, + "isOptional": false + }, + { + "parameterName": "chainId", + "parameterTypeTokenRange": { + "startIndex": 5, + "endIndex": 6 + }, + "isOptional": false + } + ], + "isOptional": false, + "isAbstract": false, + "name": "sendTransaction" + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#subscribeOnCrossChainComplete:member(1)", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "subscribeOnCrossChainComplete(accountName: " + }, + { + "kind": "Content", + "text": "string" + }, + { + "kind": "Content", + "text": ", transfers: " + }, + { + "kind": "Reference", + "text": "ICrossChainTransfer", + "canonicalReference": "@kadena/wallet-sdk!ICrossChainTransfer:interface" + }, + { + "kind": "Content", + "text": "[]" + }, + { + "kind": "Content", + "text": ", callback: " + }, + { + "kind": "Content", + "text": "(transfer: " + }, + { + "kind": "Reference", + "text": "ICrossChainTransfer", + "canonicalReference": "@kadena/wallet-sdk!ICrossChainTransfer:interface" + }, + { + "kind": "Content", + "text": ") => void" + }, + { + "kind": "Content", + "text": ", options?: " + }, + { + "kind": "Content", + "text": "{\n signal?: " + }, + { + "kind": "Reference", + "text": "AbortSignal", + "canonicalReference": "!AbortSignal:interface" + }, + { + "kind": "Content", + "text": ";\n }" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Content", + "text": "void" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 14, + "endIndex": 15 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "accountName", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isOptional": false + }, + { + "parameterName": "transfers", + "parameterTypeTokenRange": { + "startIndex": 3, + "endIndex": 5 + }, + "isOptional": false + }, + { + "parameterName": "callback", + "parameterTypeTokenRange": { + "startIndex": 6, + "endIndex": 9 + }, + "isOptional": false + }, + { + "parameterName": "options", + "parameterTypeTokenRange": { + "startIndex": 10, + "endIndex": 13 + }, + "isOptional": true + } + ], + "isOptional": false, + "isAbstract": false, + "name": "subscribeOnCrossChainComplete" + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#subscribePendingTransactions:member(1)", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "subscribePendingTransactions(transactions: " + }, + { + "kind": "Reference", + "text": "ITransactionDescriptor", + "canonicalReference": "@kadena/wallet-sdk!ITransactionDescriptor:interface" + }, + { + "kind": "Content", + "text": "[]" + }, + { + "kind": "Content", + "text": ", callback: " + }, + { + "kind": "Content", + "text": "(transaction: " + }, + { + "kind": "Reference", + "text": "ITransactionDescriptor", + "canonicalReference": "@kadena/wallet-sdk!ITransactionDescriptor:interface" + }, + { + "kind": "Content", + "text": ", result: " + }, + { + "kind": "Reference", + "text": "ResponseResult", + "canonicalReference": "@kadena/wallet-sdk!~ResponseResult:type" + }, + { + "kind": "Content", + "text": ") => void" + }, + { + "kind": "Content", + "text": ", options?: " + }, + { + "kind": "Content", + "text": "{\n signal?: " + }, + { + "kind": "Reference", + "text": "AbortSignal", + "canonicalReference": "!AbortSignal:interface" + }, + { + "kind": "Content", + "text": ";\n confirmationDepth?: number;\n timeoutSeconds?: number;\n intervalMs?: number;\n }" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Content", + "text": "void" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 14, + "endIndex": 15 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "transactions", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 3 + }, + "isOptional": false + }, + { + "parameterName": "callback", + "parameterTypeTokenRange": { + "startIndex": 4, + "endIndex": 9 + }, + "isOptional": false + }, + { + "parameterName": "options", + "parameterTypeTokenRange": { + "startIndex": 10, + "endIndex": 13 + }, + "isOptional": true + } + ], + "isOptional": false, + "isAbstract": false, + "name": "subscribePendingTransactions" + }, + { + "kind": "Method", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK#waitForPendingTransaction:member(1)", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "waitForPendingTransaction(transaction: " + }, + { + "kind": "Reference", + "text": "ITransactionDescriptor", + "canonicalReference": "@kadena/wallet-sdk!ITransactionDescriptor:interface" + }, + { + "kind": "Content", + "text": ", options?: " + }, + { + "kind": "Content", + "text": "{\n signal?: " + }, + { + "kind": "Reference", + "text": "AbortSignal", + "canonicalReference": "!AbortSignal:interface" + }, + { + "kind": "Content", + "text": ";\n }" + }, + { + "kind": "Content", + "text": "): " + }, + { + "kind": "Reference", + "text": "Promise", + "canonicalReference": "!Promise:interface" + }, + { + "kind": "Content", + "text": "<" + }, + { + "kind": "Reference", + "text": "ResponseResult", + "canonicalReference": "@kadena/wallet-sdk!~ResponseResult:type" + }, + { + "kind": "Content", + "text": ">" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isStatic": false, + "returnTypeTokenRange": { + "startIndex": 7, + "endIndex": 11 + }, + "releaseTag": "Public", + "isProtected": false, + "overloadIndex": 1, + "parameters": [ + { + "parameterName": "transaction", + "parameterTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isOptional": false + }, + { + "parameterName": "options", + "parameterTypeTokenRange": { + "startIndex": 3, + "endIndex": 6 + }, + "isOptional": true + } + ], + "isOptional": false, + "isAbstract": false, + "name": "waitForPendingTransaction" + } + ], + "implementsTokenRanges": [] + }, + { + "kind": "Variable", + "canonicalReference": "@kadena/wallet-sdk!walletSdk:var", + "docComment": "/**\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "walletSdk: " + }, + { + "kind": "Reference", + "text": "WalletSDK", + "canonicalReference": "@kadena/wallet-sdk!WalletSDK:class" + } + ], + "fileUrlPath": "src/sdk/walletSdk.ts", + "isReadonly": true, + "releaseTag": "Public", + "name": "walletSdk", + "variableTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + } + } + ] + } + ] +} diff --git a/packages/libs/wallet-sdk/etc/wallet-sdk.api.md b/packages/libs/wallet-sdk/etc/wallet-sdk.api.md new file mode 100644 index 0000000000..59c60bb91a --- /dev/null +++ b/packages/libs/wallet-sdk/etc/wallet-sdk.api.md @@ -0,0 +1,274 @@ +## API Report File for "@kadena/wallet-sdk" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { ChainId } from '@kadena/client'; +import type { ChainId as ChainId_2 } from '@kadena/types'; +import type { createCrossChainCommand } from '@kadena/client-utils/coin'; +import type { ICommand } from '@kadena/types'; +import type { ISigner } from '@kadena/client'; +import type { ISigner as ISigner_2 } from '@kadena/types'; +import type { IUnsignedCommand } from '@kadena/types'; +import type { transferCreateCommand } from '@kadena/client-utils/coin'; +import * as v from 'valibot'; + +// @public (undocumented) +export type ChainwebHostGenerator = (options: { + networkId: string; + chainId: string; +}) => string; + +// @public (undocumented) +export type GraphqlHostGenerator = (options: { + networkId: string; +}) => string; + +// @public (undocumented) +export interface IAccountDetails { + // (undocumented) + accountDetails: IAccountDetailsResult | null; + // (undocumented) + chainId: string; +} + +// @public (undocumented) +export interface IAccountDetailsResult { + // (undocumented) + account: string; + // (undocumented) + balance: number | { + decimal: number; + }; + // (undocumented) + guard: IGuard; +} + +// @public (undocumented) +export interface IChain { + // (undocumented) + id: ChainId; +} + +// @public (undocumented) +export type ICreateCrossChainTransfer = Parameters[0]; + +// @public (undocumented) +export type ICreateTransfer = Parameters[0]; + +// Warning: (ae-forgotten-export) The symbol "IBaseTransfer" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +export interface ICrossChainTransfer extends IBaseTransfer { + // (undocumented) + continuation?: { + requestKey: string; + success: boolean; + }; + // (undocumented) + isCrossChainTransfer: true; + // (undocumented) + targetChainId: ChainId; +} + +// @public (undocumented) +export interface IEthvmDevTokenInfo { + // (undocumented) + circulatingSupply?: number; + // (undocumented) + currentPrice?: number; + // (undocumented) + high24h?: number; + // (undocumented) + low24h?: number; + // (undocumented) + maxSupply?: number; + // (undocumented) + totalSupply?: number; +} + +// @public (undocumented) +export interface IGuard { + // (undocumented) + keys: string[]; + // (undocumented) + pred: string; +} + +// Warning: (ae-forgotten-export) The symbol "ILogObject" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +export type ILogTransport = (log: ILogObject) => void; + +// @public (undocumented) +export interface INetworkInfo { + // (undocumented) + nodeApiVersion: string; + // (undocumented) + nodeBlockDelay: number; + // (undocumented) + nodeChains: string[]; + // (undocumented) + nodeGenesisHeights: [string, number][]; + // (undocumented) + nodeGraphHistory: [number, [number, [string, string[]]][]][]; + // (undocumented) + nodeHistoricalChains: [number, [number, [string, string[]]][]][]; + // (undocumented) + nodeLatestBehaviorHeight: number; + // (undocumented) + nodeNumberOfChains: number; + // (undocumented) + nodePackageVersion: string; + // (undocumented) + nodeServiceDate: string; + // (undocumented) + nodeVersion: string; +} + +// @public (undocumented) +export type INodeChainInfo = Pick; + +// @public (undocumented) +export type INodeNetworkInfo = Omit; + +// @public (undocumented) +export interface ITransaction { + // (undocumented) + chainId: ChainId; + // (undocumented) + requestKey: string; +} + +// @public (undocumented) +export interface ITransactionDescriptor { + // (undocumented) + chainId: ChainId; + // (undocumented) + networkId: string; + // (undocumented) + requestKey: string; +} + +// Warning: (ae-forgotten-export) The symbol "ISameChainTransfer" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +export type ITransfer = ISameChainTransfer | ICrossChainTransfer; + +// @public (undocumented) +export interface ITransferOptions { + // (undocumented) + accountName: string; + // (undocumented) + after?: string; + // (undocumented) + before?: string; + // (undocumented) + chainId?: ChainId; + // (undocumented) + first?: number; + // (undocumented) + fungibleName?: string; + // (undocumented) + last?: number; + // (undocumented) + networkId: string; +} + +// @public (undocumented) +export interface ITransferResponse { + // (undocumented) + pageInfo: { + hasNextPage: boolean; + hasPreviousPage: boolean; + startCursor: string | null; + endCursor: string | null; + }; + // (undocumented) + transfers: ITransfer[]; +} + +// Warning: (ae-forgotten-export) The symbol "LOG_LEVELS" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +export type LogLevel = keyof typeof LOG_LEVELS; + +// @public (undocumented) +export type RequestKey = string; + +// @public (undocumented) +export class WalletSDK { + constructor(options?: { + chainwebHostGenerator?: ChainwebHostGenerator; + graphqlHostGenerator?: GraphqlHostGenerator; + logTransport?: ILogTransport; + logLevel?: LogLevel; + }); + createCrossChainTransfer(transfer: ICreateCrossChainTransfer & { + networkId: string; + }): IUnsignedCommand; + // Warning: (ae-forgotten-export) The symbol "ICreateCrossChainFinishInput" needs to be exported by the entry point index.d.ts + createFinishCrossChainTransfer(transfer: ICreateCrossChainFinishInput, gasPayer: { + account: string; + publicKeys: ISigner_2[]; + }): Promise; + // Warning: (ae-forgotten-export) The symbol "ICreateSimpleTransferInput" needs to be exported by the entry point index.d.ts + createSimpleTransfer(transfer: ICreateSimpleTransferInput & { + networkId: string; + }): IUnsignedCommand; + createTransfer(transfer: ICreateTransfer & { + networkId: string; + }): IUnsignedCommand; + // Warning: (ae-forgotten-export) The symbol "exchange" needs to be exported by the entry point index.d.ts + // + // (undocumented) + exchange: typeof exchange; + // (undocumented) + getAccountDetails(accountName: string, networkId: string, fungible: string, chainIds?: ChainId_2[]): Promise; + // (undocumented) + getChains(networkHost: string): Promise; + // (undocumented) + getChainwebUrl(...args: Parameters): ReturnType; + // (undocumented) + getGasLimitEstimate(transaction: ICommand, networkId: string, chainId: ChainId_2): Promise; + // (undocumented) + getGraphqlUrl(...args: Parameters): ReturnType; + // (undocumented) + getNetworkInfo(networkHost: string): Promise; + // (undocumented) + getTransfers(options: ITransferOptions): Promise; + // Warning: (ae-forgotten-export) The symbol "KadenaNames" needs to be exported by the entry point index.d.ts + // + // (undocumented) + kadenaNames: KadenaNames; + // Warning: (ae-forgotten-export) The symbol "Logger" needs to be exported by the entry point index.d.ts + // + // (undocumented) + logger: Logger; + sendTransaction(transaction: ICommand, networkId: string, chainId: ChainId_2): Promise; + // (undocumented) + subscribeOnCrossChainComplete(accountName: string, transfers: ICrossChainTransfer[], callback: (transfer: ICrossChainTransfer) => void, options?: { + signal?: AbortSignal; + }): void; + // (undocumented) + subscribePendingTransactions(transactions: ITransactionDescriptor[], callback: (transaction: ITransactionDescriptor, result: ResponseResult) => void, options?: { + signal?: AbortSignal; + confirmationDepth?: number; + timeoutSeconds?: number; + intervalMs?: number; + }): void; + // Warning: (ae-forgotten-export) The symbol "ResponseResult" needs to be exported by the entry point index.d.ts + // + // (undocumented) + waitForPendingTransaction(transaction: ITransactionDescriptor, options?: { + signal?: AbortSignal; + }): Promise; +} + +// @public (undocumented) +export const walletSdk: WalletSDK; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/packages/libs/wallet-sdk/src/index.ts b/packages/libs/wallet-sdk/src/index.ts index 11fd62752c..d3077d8a38 100644 --- a/packages/libs/wallet-sdk/src/index.ts +++ b/packages/libs/wallet-sdk/src/index.ts @@ -1,2 +1,4 @@ +export { ChainwebHostGenerator, GraphqlHostGenerator } from './sdk/host.js'; export type * from './sdk/interface.js'; +export { ILogTransport, LogLevel } from './sdk/logger.js'; export { WalletSDK, walletSdk } from './sdk/walletSdk.js'; diff --git a/packages/libs/wallet-sdk/src/sdk/host.ts b/packages/libs/wallet-sdk/src/sdk/host.ts index 303fd38dc0..36abb65e95 100644 --- a/packages/libs/wallet-sdk/src/sdk/host.ts +++ b/packages/libs/wallet-sdk/src/sdk/host.ts @@ -1,8 +1,14 @@ +/** + * @public + */ export type ChainwebHostGenerator = (options: { networkId: string; chainId: string; }) => string; +/** + * @public + */ export type GraphqlHostGenerator = (options: { networkId: string }) => string; const chainwebHostMap: Record = { diff --git a/packages/libs/wallet-sdk/src/sdk/interface.ts b/packages/libs/wallet-sdk/src/sdk/interface.ts index e3bb3806b5..f96c24769a 100644 --- a/packages/libs/wallet-sdk/src/sdk/interface.ts +++ b/packages/libs/wallet-sdk/src/sdk/interface.ts @@ -36,6 +36,9 @@ interface ISameChainTransfer extends IBaseTransfer { isCrossChainTransfer: false; } +/** + * @public + */ export interface ICrossChainTransfer extends IBaseTransfer { isCrossChainTransfer: true; targetChainId: ChainId; @@ -45,6 +48,9 @@ export interface ICrossChainTransfer extends IBaseTransfer { }; } +/** + * @public + */ export interface IEthvmDevTokenInfo { currentPrice?: number; maxSupply?: number; @@ -54,12 +60,22 @@ export interface IEthvmDevTokenInfo { high24h?: number; } +/** + * @public + */ export interface IChain { id: ChainId; // Will add later: type: 'pact' | 'evm' } + +/** + * @public + */ export type ITransfer = ISameChainTransfer | ICrossChainTransfer; +/** + * @public + */ export interface ITransferOptions { accountName: string; networkId: string; @@ -71,6 +87,9 @@ export interface ITransferOptions { last?: number; } +/** + * @public + */ export interface ITransferResponse { transfers: ITransfer[]; pageInfo: { @@ -81,14 +100,29 @@ export interface ITransferResponse { }; } +/** + * @public + */ export type ICreateTransfer = Parameters[0]; + +/** + * @public + */ export type ICreateCrossChainTransfer = Parameters< typeof createCrossChainCommand >[0]; + +/** + * @public + */ export interface IAccountDetails { chainId: string; accountDetails: IAccountDetailsResult | null; } + +/** + * @public + */ export interface IAccountDetailsResult { guard: IGuard; account: string; @@ -99,21 +133,38 @@ export interface IAccountDetailsResult { }; } +/** + * @public + */ export interface IGuard { keys: string[]; pred: string; } +/** + * @public + */ export interface ITransaction { requestKey: string; chainId: ChainId; } + +/** + * @public + */ export type RequestKey = string; + +/** + * @public + */ export interface ITransactionDescriptor { requestKey: string; chainId: ChainId; networkId: string; } +/** + * @public + */ export interface INetworkInfo { nodeApiVersion: string; nodeBlockDelay: number; @@ -128,6 +179,12 @@ export interface INetworkInfo { nodeVersion: string; } +/** + * @public + */ export type INodeChainInfo = Pick; +/** + * @public + */ export type INodeNetworkInfo = Omit; diff --git a/packages/libs/wallet-sdk/src/sdk/logger.ts b/packages/libs/wallet-sdk/src/sdk/logger.ts index 69120878ee..f7b47f39c9 100644 --- a/packages/libs/wallet-sdk/src/sdk/logger.ts +++ b/packages/libs/wallet-sdk/src/sdk/logger.ts @@ -4,6 +4,10 @@ interface ILogObject { data?: Record; timestamp: number; } + +/** + * @public + */ export type ILogTransport = (log: ILogObject) => void; const LOG_LEVELS = { @@ -13,6 +17,9 @@ const LOG_LEVELS = { ERROR: 3, }; +/** + * @public + */ export type LogLevel = keyof typeof LOG_LEVELS; export class Logger { diff --git a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts index a89e761ea0..d742492877 100644 --- a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts +++ b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts @@ -48,6 +48,9 @@ import type { ResponseResult } from './schema.js'; import type { ICreateSimpleTransferInput } from './simpleTransferCreate.js'; import { simpleTransferCreateCommand } from './simpleTransferCreate.js'; +/** + * @public + */ export class WalletSDK { private _chainwebHostGenerator: ChainwebHostGenerator; private _graphqlHostGenerator: GraphqlHostGenerator; @@ -393,4 +396,7 @@ export class WalletSDK { } } +/** + * @public + */ export const walletSdk = new WalletSDK(); From ebba61ea0c3d67812692726bf83dbb9f84fdb485 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 12:39:31 +0100 Subject: [PATCH 079/103] fix(wallet-sdk): update tests --- .../sdk/tests/mapTransferXchainEnd.test.ts | 2 +- .../sdk/tests/mapTransferXchainStart.test.tsx | 4 ++-- .../tests/mapTransferXchainUnfinished.test.ts | 4 ++-- .../src/services/graphql/transfer.util.ts | 19 ++++++++++--------- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts index e6b783edf0..d163ba5287 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts @@ -167,7 +167,7 @@ describe('getTransfers', () => { networkId: 'testnet04', block: { creationTime: new Date('2024-09-12T10:09:18.577Z'), - blockDepthEstimate: 0, + blockDepthEstimate: -4638197, hash: 'i4jeD4i8SFI6STZBMoh5p2mYBwFOlnaJBB-HzYCHZLE', height: 4638194, }, diff --git a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx index c295f82c58..5e6debf59f 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx +++ b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx @@ -254,7 +254,7 @@ describe('getTransfers', () => { networkId: 'testnet04', block: { creationTime: new Date('2024-09-12T10:00:58.767Z'), - blockDepthEstimate: 0, + blockDepthEstimate: -4638181, hash: 'PSjGxqGz-R9oM06MxXZKTKhNT79DlzZSCwE7842y20E', height: 4638178, }, @@ -265,7 +265,7 @@ describe('getTransfers', () => { transactionFeeTransfer: { amount: 0.00000619, block: { - blockDepthEstimate: 0, + blockDepthEstimate: -4638181, creationTime: new Date('2024-09-12T10:00:58.767Z'), hash: 'PSjGxqGz-R9oM06MxXZKTKhNT79DlzZSCwE7842y20E', height: 4638178, diff --git a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts index 77fda94bee..2b0b17bdc4 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts @@ -184,14 +184,14 @@ describe('getTransfers', () => { networkId: 'testnet04', block: { creationTime: new Date('2024-09-30T10:08:39.033Z'), - blockDepthEstimate: 0, + blockDepthEstimate: -4690012, hash: 'yJjKVagCvIkrQXvJwciIb-m-O_yjPDCaPliHQpgXGdo', height: 4690009, }, transactionFeeTransfer: { amount: 0.00000619, block: { - blockDepthEstimate: 0, + blockDepthEstimate: -4690012, creationTime: new Date('2024-09-30T10:08:39.033Z'), hash: 'yJjKVagCvIkrQXvJwciIb-m-O_yjPDCaPliHQpgXGdo', height: 4690009, diff --git a/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts b/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts index 0239c2c6e9..bbfa5911b1 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts @@ -294,15 +294,16 @@ export function parseGqlTransfers( fungibleName, ) : null; - return { - ...base, - transactionFeeTransfer: transactionFeeBase - ? { - ...transactionFeeBase, - isBulkTransfer: transfers.length > 1, - } - : undefined, - } as ITransfer; + if (transactionFeeBase) { + return { + ...base, + transactionFeeTransfer: { + ...transactionFeeBase, + isBulkTransfer: transfers.length > 1, + }, + } as ITransfer; + } + return base; }); }); From 433cbf5df92502876f34cd89425e549adc499c5f Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 12:55:21 +0100 Subject: [PATCH 080/103] fix(wallet-sdk): update tests --- .../sdk/tests/createSimpleTransfer.test.ts | 183 ++++++++++++++++++ ...est.tsx => mapTransferXchainStart.test.ts} | 0 2 files changed, 183 insertions(+) create mode 100644 packages/libs/wallet-sdk/src/sdk/tests/createSimpleTransfer.test.ts rename packages/libs/wallet-sdk/src/sdk/tests/{mapTransferXchainStart.test.tsx => mapTransferXchainStart.test.ts} (100%) diff --git a/packages/libs/wallet-sdk/src/sdk/tests/createSimpleTransfer.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/createSimpleTransfer.test.ts new file mode 100644 index 0000000000..532eacc0ac --- /dev/null +++ b/packages/libs/wallet-sdk/src/sdk/tests/createSimpleTransfer.test.ts @@ -0,0 +1,183 @@ +import type { ChainId } from '@kadena/types'; +import { describe, expect, it, vi } from 'vitest'; +import { simpleTransferCreateCommand } from '../simpleTransferCreate'; + +vi.useFakeTimers(); + +const specificDate = new Date('2023-10-25T12:00:00Z'); +vi.setSystemTime(specificDate); + +describe('simpleTransferCreateCommand', () => { + it('should create a transfer command', () => { + const input = { + sender: 'k:senderKey', + receiver: 'k:receiverKey', + amount: '100', + chainId: '1' as ChainId, + }; + + const output = simpleTransferCreateCommand(input)(); + expect(output).toEqual({ + payload: { + exec: { + code: '(coin.transfer-create "k:senderKey" "k:receiverKey" (read-keyset "account-guard") 100.0)', + data: { + 'account-guard': { + keys: ['receiverKey'], + pred: 'keys-all', + }, + }, + }, + }, + signers: [ + { + pubKey: 'senderKey', + scheme: 'ED25519', + clist: [ + { + name: 'coin.TRANSFER', + args: [ + 'k:senderKey', + 'k:receiverKey', + { + decimal: '100', + }, + ], + }, + { + name: 'coin.GAS', + args: [], + }, + ], + }, + ], + meta: { + gasLimit: 2500, + gasPrice: 1e-8, + sender: 'k:senderKey', + ttl: 28800, + creationTime: 1698235200, + chainId: '1', + }, + nonce: 'kjs:nonce:1698235200000', + }); + }); + + it('should create a transfer command with public key', () => { + const input = { + sender: 'senderKey', + receiver: 'receiverKey', + amount: '100', + chainId: '1' as ChainId, + }; + + const output = simpleTransferCreateCommand(input)(); + expect(output).toEqual({ + payload: { + exec: { + code: '(coin.transfer-create "k:senderKey" "k:receiverKey" (read-keyset "account-guard") 100.0)', + data: { + 'account-guard': { + keys: ['receiverKey'], + pred: 'keys-all', + }, + }, + }, + }, + signers: [ + { + pubKey: 'senderKey', + scheme: 'ED25519', + clist: [ + { + name: 'coin.TRANSFER', + args: [ + 'k:senderKey', + 'k:receiverKey', + { + decimal: '100', + }, + ], + }, + { + name: 'coin.GAS', + args: [], + }, + ], + }, + ], + meta: { + gasLimit: 2500, + gasPrice: 1e-8, + sender: 'k:senderKey', + ttl: 28800, + creationTime: 1698235200, + chainId: '1', + }, + nonce: 'kjs:nonce:1698235200000', + }); + }); + + it('should create a transfer command with custom gasPayer', () => { + const output = simpleTransferCreateCommand({ + sender: 'k:senderKey', + receiver: 'k:receiverKey', + amount: '100', + chainId: '1' as ChainId, + gasPayer: { + account: 'k:gasPayerKey', + publicKeys: ['gasPayerKey'], + }, + })(); + expect(output).toEqual({ + payload: { + exec: { + code: '(coin.transfer-create "k:senderKey" "k:receiverKey" (read-keyset "account-guard") 100.0)', + data: { + 'account-guard': { + keys: ['receiverKey'], + pred: 'keys-all', + }, + }, + }, + }, + signers: [ + { + pubKey: 'senderKey', + scheme: 'ED25519', + clist: [ + { + name: 'coin.TRANSFER', + args: [ + 'k:senderKey', + 'k:receiverKey', + { + decimal: '100', + }, + ], + }, + ], + }, + { + pubKey: 'gasPayerKey', + scheme: 'ED25519', + clist: [ + { + name: 'coin.GAS', + args: [], + }, + ], + }, + ], + meta: { + gasLimit: 2500, + gasPrice: 1e-8, + sender: 'k:gasPayerKey', + ttl: 28800, + creationTime: 1698235200, + chainId: '1', + }, + nonce: 'kjs:nonce:1698235200000', + }); + }); +}); diff --git a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.ts similarity index 100% rename from packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.tsx rename to packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.ts From d78d89153e927b89c3c49a0ff2135dc8eec428f9 Mon Sep 17 00:00:00 2001 From: Nillo Date: Fri, 6 Dec 2024 12:59:18 +0100 Subject: [PATCH 081/103] chore(wallet-sdk) pact-utils test --- .../src/utils/tests/pact.util.test.ts | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 packages/libs/wallet-sdk/src/utils/tests/pact.util.test.ts diff --git a/packages/libs/wallet-sdk/src/utils/tests/pact.util.test.ts b/packages/libs/wallet-sdk/src/utils/tests/pact.util.test.ts new file mode 100644 index 0000000000..ebfdc87379 --- /dev/null +++ b/packages/libs/wallet-sdk/src/utils/tests/pact.util.test.ts @@ -0,0 +1,112 @@ +import { describe, expect, it } from 'vitest'; +import { parsePactNumber } from '../pact.util'; + +describe('parsePactNumber', () => { + it('should return the number when input is a number', () => { + expect(parsePactNumber(42)).toBe(42); + expect(parsePactNumber(-3.14)).toBe(-3.14); + expect(parsePactNumber(0)).toBe(0); + }); + + it('should parse and return the decimal string as a float', () => { + const input = { decimal: '123.456' }; + expect(parsePactNumber(input)).toBe(123.456); + + const negativeInput = { decimal: '-789.012' }; + expect(parsePactNumber(negativeInput)).toBe(-789.012); + + const zeroInput = { decimal: '0.0' }; + expect(parsePactNumber(zeroInput)).toBe(0.0); + }); + + it('should parse and return the int string as an integer', () => { + const input = { int: '789' }; + expect(parsePactNumber(input)).toBe(789); + + const negativeInput = { int: '-456' }; + expect(parsePactNumber(negativeInput)).toBe(-456); + + const zeroInput = { int: '0' }; + expect(parsePactNumber(zeroInput)).toBe(0); + }); + + it('should throw an error when input is a plain string', () => { + expect(() => parsePactNumber('123')).toThrow( + 'Failed to parse Pact number: "123"', + ); + expect(() => parsePactNumber('abc')).toThrow( + 'Failed to parse Pact number: "abc"', + ); + }); + + it('should throw an error when object lacks both "decimal" and "int" properties', () => { + const input = { other: 'value' }; + expect(() => parsePactNumber(input)).toThrow( + 'Failed to parse Pact number: "[object Object]"', + ); + }); + + it('should throw an error when "decimal" property is not a string', () => { + const input = { decimal: 123.456 }; + expect(() => parsePactNumber(input)).toThrow( + 'Failed to parse Pact number: "[object Object]"', + ); + }); + + it('should throw an error when "int" property is not a string', () => { + const input = { int: 789 }; + expect(() => parsePactNumber(input)).toThrow( + 'Failed to parse Pact number: "[object Object]"', + ); + }); + + it('should throw an error when input is undefined', () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + expect(() => parsePactNumber(undefined as any)).toThrow( + 'Failed to parse Pact number: "undefined"', + ); + }); + + it('should prioritize "decimal" over "int" when both are present', () => { + const input = { decimal: '123.456', int: '789' }; + expect(parsePactNumber(input)).toBe(123.456); + }); + + it('should correctly parse large numbers', () => { + const largeDecimal = { decimal: '1234567890.123456789' }; + expect(parsePactNumber(largeDecimal)).toBe(1234567890.123456789); + + const largeInt = { int: '9876543210' }; + expect(parsePactNumber(largeInt)).toBe(9876543210); + }); + + it('should parse valid numeric strings within objects and handle invalid formats appropriately', () => { + const validDecimal = { decimal: '456.789' }; + expect(parsePactNumber(validDecimal)).toBe(456.789); + + const invalidDecimal = { decimal: '456.78.9' }; + const resultDecimal = parsePactNumber(invalidDecimal); + expect(resultDecimal).toBe(456.78); + + const validInt = { int: '123' }; + expect(parsePactNumber(validInt)).toBe(123); + + const invalidInt = { int: '123abc' }; + expect(parsePactNumber(invalidInt)).toBe(123); + }); + + it('should throw an error when input is an empty object', () => { + const input = {}; + expect(() => parsePactNumber(input)).toThrow( + 'Failed to parse Pact number: "[object Object]"', + ); + }); + + it('should correctly parse when object has additional properties', () => { + const inputDecimal = { decimal: '321.654', extra: 'data' }; + expect(parsePactNumber(inputDecimal)).toBe(321.654); + + const inputInt = { int: '654', extra: 123 }; + expect(parsePactNumber(inputInt)).toBe(654); + }); +}); From 13c674c5f3d9bb0fa03d467a329e3b62f69f9b21 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 13:08:22 +0100 Subject: [PATCH 082/103] fix(wallet-sdk): test coverage --- packages/libs/wallet-sdk/vitest.config.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/libs/wallet-sdk/vitest.config.ts b/packages/libs/wallet-sdk/vitest.config.ts index 557a97190c..3ae3df110c 100644 --- a/packages/libs/wallet-sdk/vitest.config.ts +++ b/packages/libs/wallet-sdk/vitest.config.ts @@ -5,8 +5,14 @@ const localConfig = defineConfig({ test: { exclude: ['src/**/*.int.test.ts'], coverage: { + exclude: ['src/gql/*.ts'], provider: 'v8', - thresholds: {}, + thresholds: { + lines: 75, + functions: 75, + branches: 75, + statements: 75, + }, }, }, }); From 39142d6480f8d98345610d08072b61e570c12995 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 13:17:33 +0100 Subject: [PATCH 083/103] fix(wallet-sdk): linting issues --- packages/libs/wallet-sdk/.prettierignore | 2 ++ packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts | 2 +- packages/libs/wallet-sdk/src/tests/example.test.ts | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/libs/wallet-sdk/.prettierignore b/packages/libs/wallet-sdk/.prettierignore index 87e9d34d64..4df6761865 100644 --- a/packages/libs/wallet-sdk/.prettierignore +++ b/packages/libs/wallet-sdk/.prettierignore @@ -5,3 +5,5 @@ temp **/*.md !README.md tsdoc-metadata.json +coverage/* +src/gql/* diff --git a/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts b/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts index bbfa5911b1..5c6ba6047c 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts @@ -172,7 +172,7 @@ const mapBaseTransfer = ( export const gqlTransferToTransfer = ( rawGqlTransfer: GqlTransfer, - _accountName: string, + accountName: string, lastBlockHeight: number, fungibleName?: string, ): ITransfer | null => { diff --git a/packages/libs/wallet-sdk/src/tests/example.test.ts b/packages/libs/wallet-sdk/src/tests/example.test.ts index 6b43576451..810b8eebd3 100644 --- a/packages/libs/wallet-sdk/src/tests/example.test.ts +++ b/packages/libs/wallet-sdk/src/tests/example.test.ts @@ -16,7 +16,6 @@ describe('example test', () => { const password = '12345678'; const seed = await kadenaMnemonicToSeed(password, mnemonic); const [publicKey] = await kadenaGenKeypairFromSeed(password, seed, 0); - console.log('PublicKey:', publicKey); const [publicKey2] = await kadenaGenKeypairFromSeed(password, seed, 1); const chainId = '0' as ChainId; From 03c0045a89f4d2503ed4bb91bce0726556f5ab15 Mon Sep 17 00:00:00 2001 From: Nillo Date: Fri, 6 Dec 2024 13:18:36 +0100 Subject: [PATCH 084/103] chore(wallet-sdk): added exchange test --- .../wallet-sdk/src/sdk/tests/exchange.test.ts | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 packages/libs/wallet-sdk/src/sdk/tests/exchange.test.ts diff --git a/packages/libs/wallet-sdk/src/sdk/tests/exchange.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/exchange.test.ts new file mode 100644 index 0000000000..fcc9df53fe --- /dev/null +++ b/packages/libs/wallet-sdk/src/sdk/tests/exchange.test.ts @@ -0,0 +1,171 @@ +import type { Mock } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { exchange } from '../exchange'; +import type { IEthvmDevTokenInfo } from '../interface'; + +type Token = 'kadena' | 'ethereum'; + +const tokens: Token[] = ['kadena', 'ethereum']; + +const mockSuccessResponse = { + data: { + getCoinGeckoTokenMarketDataByIds: [ + { + current_price: 1.5, + max_supply: 1000000, + total_supply: 900000, + circulating_supply: 850000, + // eslint-disable-next-line @typescript-eslint/naming-convention + low_24h: 1.4, + // eslint-disable-next-line @typescript-eslint/naming-convention + high_24h: 1.6, + }, + { + current_price: 3000, + max_supply: 21000000, + total_supply: 18500000, + circulating_supply: 18000000, + // eslint-disable-next-line @typescript-eslint/naming-convention + low_24h: 2950, + // eslint-disable-next-line @typescript-eslint/naming-convention + high_24h: 3050, + }, + ], + }, +}; + +const mockFailureResponse = { + error: 'Something went wrong', +}; + +describe('exchange.getEthvmDevTokenInfo', () => { + beforeEach(() => { + vi.resetAllMocks(); + }); + + it('should return token info when API call is successful', async () => { + global.fetch = vi.fn().mockResolvedValueOnce({ + json: vi.fn().mockResolvedValueOnce(mockSuccessResponse), + } as unknown as Response); + + const result = await exchange.getEthvmDevTokenInfo(tokens); + + const expected: Record = { + kadena: { + currentPrice: 1.5, + maxSupply: 1000000, + totalSupply: 900000, + circulatingSupply: 850000, + low24h: 1.4, + high24h: 1.6, + }, + ethereum: { + currentPrice: 3000, + maxSupply: 21000000, + totalSupply: 18500000, + circulatingSupply: 18000000, + low24h: 2950, + high24h: 3050, + }, + }; + + expect(result).toEqual(expected); + expect(global.fetch).toHaveBeenCalledTimes(1); + + const fetchCall = (global.fetch as unknown as Mock).mock.calls[0]; + expect(fetchCall[0]).toBe('https://api-v2.ethvm.dev/'); + + const fetchOptions = fetchCall[1]; + expect(fetchOptions.method).toBe('POST'); + expect(fetchOptions.headers).toEqual({ + 'Content-Type': 'application/json', + }); + + const body = JSON.parse(fetchOptions.body); + expect(body.operationName).toBeNull(); + expect(body.variables).toEqual({ tokens }); + expect(body.query).toContain('query getCoinGeckoTokenMarketDataByIds'); + }); + + it('should return undefined for each token when API call fails', async () => { + global.fetch = vi.fn().mockRejectedValueOnce(new Error('Network error')); + + const result = await exchange.getEthvmDevTokenInfo(tokens); + + const expected: Record = { + kadena: undefined, + ethereum: undefined, + }; + + expect(result).toEqual(expected); + expect(global.fetch).toHaveBeenCalledTimes(1); + + const fetchCall = (global.fetch as unknown as Mock).mock.calls[0]; + expect(fetchCall[0]).toBe('https://api-v2.ethvm.dev/'); + expect(fetchCall[1]).toMatchObject({ + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + }); + + const body = JSON.parse(fetchCall[1].body); + expect(body.operationName).toBeNull(); + expect(body.variables).toEqual({ tokens }); + expect(body.query).toContain('query getCoinGeckoTokenMarketDataByIds'); + }); + + it('should return undefined for each token when API response is malformed', async () => { + global.fetch = vi.fn().mockResolvedValueOnce({ + json: vi.fn().mockResolvedValueOnce(mockFailureResponse), + } as unknown as Response); + + const result = await exchange.getEthvmDevTokenInfo(tokens); + + const expected: Record = { + kadena: undefined, + ethereum: undefined, + }; + + expect(result).toEqual(expected); + expect(global.fetch).toHaveBeenCalledTimes(1); + + const fetchCall = (global.fetch as unknown as Mock).mock.calls[0]; + expect(fetchCall[0]).toBe('https://api-v2.ethvm.dev/'); + expect(fetchCall[1]).toMatchObject({ + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + }); + + const body = JSON.parse(fetchCall[1].body); + expect(body.operationName).toBeNull(); + expect(body.variables).toEqual({ tokens }); + expect(body.query).toContain('query getCoinGeckoTokenMarketDataByIds'); + }); + + it('should handle empty token array', async () => { + // Mock the fetch implementation + global.fetch = vi.fn().mockResolvedValueOnce({ + json: vi.fn().mockResolvedValueOnce({ + data: { getCoinGeckoTokenMarketDataByIds: [] }, + }), + } as unknown as Response); + + const result = await exchange.getEthvmDevTokenInfo([]); + + const expected: Record = {}; + + expect(result).toEqual(expected); + expect(global.fetch).toHaveBeenCalledTimes(1); + + const fetchCall = (global.fetch as unknown as Mock).mock.calls[0]; + expect(fetchCall[0]).toBe('https://api-v2.ethvm.dev/'); + expect(fetchCall[1]).toMatchObject({ + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + }); + + const body = JSON.parse(fetchCall[1].body); + expect(body.operationName).toBeNull(); + expect(body.variables).toEqual({ tokens: [] }); + expect(body.query).toContain('query getCoinGeckoTokenMarketDataByIds'); + }); +}); From 4a2524ee232f6c55085eb78c42526630f2e1a919 Mon Sep 17 00:00:00 2001 From: Nillo Date: Fri, 6 Dec 2024 13:24:28 +0100 Subject: [PATCH 085/103] chore(wallet-sdk): added exchange test fix --- .../wallet-sdk/src/sdk/tests/exchange.test.ts | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/packages/libs/wallet-sdk/src/sdk/tests/exchange.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/exchange.test.ts index fcc9df53fe..0c5eda0a09 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/exchange.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/exchange.test.ts @@ -87,6 +87,57 @@ describe('exchange.getEthvmDevTokenInfo', () => { expect(body.query).toContain('query getCoinGeckoTokenMarketDataByIds'); }); + it('should assign undefined when data entries are null', async () => { + const tokensWithNullData: Token[] = ['kadena', 'ethereum']; + + const mockNullDataResponse = { + data: { + getCoinGeckoTokenMarketDataByIds: [null, null], + }, + }; + + global.fetch = vi.fn().mockResolvedValueOnce({ + json: vi.fn().mockResolvedValueOnce(mockNullDataResponse), + } as unknown as Response); + + const result = + await exchange.getEthvmDevTokenInfo(tokensWithNullData); + + const expected: Record = { + ethereum: { + circulatingSupply: undefined, + currentPrice: undefined, + high24h: undefined, + low24h: undefined, + maxSupply: undefined, + totalSupply: undefined, + }, + kadena: { + circulatingSupply: undefined, + currentPrice: undefined, + high24h: undefined, + low24h: undefined, + maxSupply: undefined, + totalSupply: undefined, + }, + }; + + expect(result).toEqual(expected); + expect(global.fetch).toHaveBeenCalledTimes(1); + + const fetchCall = (global.fetch as unknown as Mock).mock.calls[0]; + expect(fetchCall[0]).toBe('https://api-v2.ethvm.dev/'); + expect(fetchCall[1]).toMatchObject({ + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + }); + + const body = JSON.parse(fetchCall[1].body); + expect(body.operationName).toBeNull(); + expect(body.variables).toEqual({ tokens: tokensWithNullData }); + expect(body.query).toContain('query getCoinGeckoTokenMarketDataByIds'); + }); + it('should return undefined for each token when API call fails', async () => { global.fetch = vi.fn().mockRejectedValueOnce(new Error('Network error')); From 53c7834fca8b51654f21210a3f1e75245a6bbc63 Mon Sep 17 00:00:00 2001 From: Nillo Date: Fri, 6 Dec 2024 13:36:39 +0100 Subject: [PATCH 086/103] chore(wallet-sdk): string util test added --- .../src/utils/tests/string.util.test.ts | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 packages/libs/wallet-sdk/src/utils/tests/string.util.test.ts diff --git a/packages/libs/wallet-sdk/src/utils/tests/string.util.test.ts b/packages/libs/wallet-sdk/src/utils/tests/string.util.test.ts new file mode 100644 index 0000000000..189ed0e852 --- /dev/null +++ b/packages/libs/wallet-sdk/src/utils/tests/string.util.test.ts @@ -0,0 +1,94 @@ +import { describe, expect, it } from 'vitest'; +import { safeJsonParse } from '../string.util'; + +interface IUser { + name: string; + age: number; +} + +interface IUserDetails { + age: number; + city: string; +} + +interface INestedUser { + user: { + name: string; + details: IUserDetails; + }; +} + +describe('safeJsonParse', () => { + it('should parse a valid JSON string and return the correct object', () => { + const jsonString = '{"name": "Alice", "age": 30}'; + + const result = safeJsonParse(jsonString); + + expect(result).toEqual({ name: 'Alice', age: 30 }); + }); + + it('should return null for an invalid JSON string', () => { + const invalidJsonString = '{"name": "Alice", "age": 30'; // Missing closing brace + const result = safeJsonParse(invalidJsonString); + + expect(result).toBeNull(); + }); + + it('should return null when the input is null', () => { + const result = safeJsonParse(null); + + expect(result).toBeNull(); + }); + + it('should return null when the input is undefined', () => { + const result = safeJsonParse(undefined); + + expect(result).toBeNull(); + }); + + it('should correctly parse a JSON array', () => { + const jsonArray = '["apple", "banana", "cherry"]'; + type Fruits = string[]; + const result = safeJsonParse(jsonArray); + + expect(result).toEqual(['apple', 'banana', 'cherry']); + }); + + it('should return null when JSON.parse throws an error', () => { + const malformedJson = '{"name": "Bob", "age":}'; + const result = safeJsonParse(malformedJson); + + expect(result).toBeNull(); + }); + + it('should parse nested JSON objects correctly', () => { + const nestedJson = + '{"user": {"name": "Charlie", "details": {"age": 25, "city": "New York"}}}'; + + const result = safeJsonParse(nestedJson); + + expect(result).toEqual({ + user: { + name: 'Charlie', + details: { + age: 25, + city: 'New York', + }, + }, + }); + }); + + it('should handle empty JSON objects', () => { + const emptyJson = '{}'; + const result = safeJsonParse>(emptyJson); + + expect(result).toEqual({}); + }); + + it('should handle empty JSON arrays', () => { + const emptyArrayJson = '[]'; + const result = safeJsonParse(emptyArrayJson); + + expect(result).toEqual([]); + }); +}); From f41ff04c5649aafd1ccd683c0d206c6001131bac Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 14:01:20 +0100 Subject: [PATCH 087/103] chore(wallet-sdk): test create cross chain finish command --- .../libs/wallet-sdk/etc/wallet-sdk.api.json | 23 ++++-- .../libs/wallet-sdk/etc/wallet-sdk.api.md | 2 +- .../sdk/tests/crossChainFinishCreate.test.ts | 79 +++++++++++++++++++ packages/libs/wallet-sdk/src/sdk/walletSdk.ts | 14 +++- 4 files changed, 110 insertions(+), 8 deletions(-) create mode 100644 packages/libs/wallet-sdk/src/sdk/tests/crossChainFinishCreate.test.ts diff --git a/packages/libs/wallet-sdk/etc/wallet-sdk.api.json b/packages/libs/wallet-sdk/etc/wallet-sdk.api.json index 573934b148..7503c8ecd2 100644 --- a/packages/libs/wallet-sdk/etc/wallet-sdk.api.json +++ b/packages/libs/wallet-sdk/etc/wallet-sdk.api.json @@ -2048,11 +2048,24 @@ "kind": "Content", "text": "createFinishCrossChainTransfer(transfer: " }, + { + "kind": "Reference", + "text": "Omit", + "canonicalReference": "!Omit:type" + }, + { + "kind": "Content", + "text": "<" + }, { "kind": "Reference", "text": "ICreateCrossChainFinishInput", "canonicalReference": "@kadena/wallet-sdk!~ICreateCrossChainFinishInput:interface" }, + { + "kind": "Content", + "text": ", 'host'>" + }, { "kind": "Content", "text": ", gasPayer: " @@ -2099,8 +2112,8 @@ ], "isStatic": false, "returnTypeTokenRange": { - "startIndex": 7, - "endIndex": 11 + "startIndex": 10, + "endIndex": 14 }, "releaseTag": "Public", "isProtected": false, @@ -2110,15 +2123,15 @@ "parameterName": "transfer", "parameterTypeTokenRange": { "startIndex": 1, - "endIndex": 2 + "endIndex": 5 }, "isOptional": false }, { "parameterName": "gasPayer", "parameterTypeTokenRange": { - "startIndex": 3, - "endIndex": 6 + "startIndex": 6, + "endIndex": 9 }, "isOptional": false } diff --git a/packages/libs/wallet-sdk/etc/wallet-sdk.api.md b/packages/libs/wallet-sdk/etc/wallet-sdk.api.md index 59c60bb91a..4e2957b6b3 100644 --- a/packages/libs/wallet-sdk/etc/wallet-sdk.api.md +++ b/packages/libs/wallet-sdk/etc/wallet-sdk.api.md @@ -209,7 +209,7 @@ export class WalletSDK { networkId: string; }): IUnsignedCommand; // Warning: (ae-forgotten-export) The symbol "ICreateCrossChainFinishInput" needs to be exported by the entry point index.d.ts - createFinishCrossChainTransfer(transfer: ICreateCrossChainFinishInput, gasPayer: { + createFinishCrossChainTransfer(transfer: Omit, gasPayer: { account: string; publicKeys: ISigner_2[]; }): Promise; diff --git a/packages/libs/wallet-sdk/src/sdk/tests/crossChainFinishCreate.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/crossChainFinishCreate.test.ts new file mode 100644 index 0000000000..307c4d5b97 --- /dev/null +++ b/packages/libs/wallet-sdk/src/sdk/tests/crossChainFinishCreate.test.ts @@ -0,0 +1,79 @@ +import type { ChainId } from '@kadena/types'; +import { http, HttpResponse } from 'msw'; +import { setupServer } from 'msw/node'; +import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'; +import { crossChainFinishCreateCommand } from '../crossChainFinishCreate'; + +const server = setupServer(); + +beforeAll(() => server.listen()); +afterEach(() => server.resetHandlers()); +afterAll(() => server.close()); + +server.use( + http.post( + 'https://api.testnet.chainweb.com/chainweb/0.0/testnet04/chain/0/pact/spv', + async () => { + return HttpResponse.text( + 'eyJjaGFpbiI6MSwib2JqZWN0IjoiQUFBQUVBQUFBQUFBQUFBQkFEYy1ZMEwzdldwMXRMU0ZPWTQ4emtnUGlKd3NWZU41M0wtaURFamV5NTJ1QUgzdExDR0NVbFEwcjUwZll0eVl6X3NCeThmV3lydTVmUGNaT3AxYWRhT01BZWhPUk94V0FyQmJ1emV2dktNR1BlMHVGVV9QTzJ6MzdULS1jS2F0NnV3ekFYeTdDVGV0Zl9tWWc5LXpJb2x6ZXhWNENWeXpMamRzWnpsVXlpUDhMLXh2QU9DM2ZzUE9SU3VsenJsSkpfc2pLdVJ3ZVhISnNhUUI2OEtCWW1kSmd1bmVBU21ER0hkWUd2ZzZvMXNwaXR2NldORjkxMm9GYmFqQWZ4dVMtY3pPbnJVU0FMM1R4Rm40UWZ1ZFI3T2w5NkxiQVV1Nmxsektua1RLbVBSNEVkNTdkay1PQU5DcFM1NllTRzgySkhqSVcwci04N1NxckdzeWNQSmx2VVk3VkgtaG1lbXVBZFlZenNERjhhS05RRWlPcDJidU1UOTFuSWFEM3dpaF9wVURfem9JVWxEVEFEUGJfTTVNdkxFWTh3Z2V0OWYzbWVvWXBZemdLOGI3NXFCZXVKTGd6TDlHQWJhYWdkWkJFdEVlQjlsOUt6TzUycUstMkQ2XzdOdkRnZHAtU255OFBkVmpBTU0tRGYzNGdkN1hDZmsycXNsU2lvWm00UWhRTUdLMUw3UzU4eGpmUkpBbEFCaXVwZENaeEJhcEVjZUV4UXVDZXp3ODFySXJDa2gyTnRrY2V4N1F5TTFnQVNIT2w0NllldGFEWU1pMDlGS0pOYUNDMUthV2paMVlfVnFsamhRZXNINzBBRS14YXh3a3RfZmVRdnBibkZkR0EwVWVuVTlSb1FpdkxwcDBhZklvZzdfVEFDdTZ0dFU0OXRpcW11R0hraDhVTF80Sm9OUVBvRmdWZlBWVktCbzJ5RU1aIiwic3ViamVjdCI6eyJpbnB1dCI6IkFCUjdJbWRoY3lJNk5qRTVMQ0p5WlhOMWJIUWlPbnNpYzNSaGRIVnpJam9pYzNWalkyVnpjeUlzSW1SaGRHRWlPbnNpWVcxdmRXNTBJam93TGpFc0luSmxZMlZwZG1WeUlqb2lhem95TURFM1ptVmxNMlppTVRWalptVTROREJsTldWa016UmlaakV3TVdOak4yUTFOVGM1Wm1aa1pESXdaR1ZoTURsbE16Sm1aRGMzWXpFM05UZG1PVFEySWl3aWMyOTFjbU5sTFdOb1lXbHVJam9pTUNJc0luSmxZMlZwZG1WeUxXZDFZWEprSWpwN0luQnlaV1FpT2lKclpYbHpMV0ZzYkNJc0ltdGxlWE1pT2xzaU1qQXhOMlpsWlRObVlqRTFZMlpsT0RRd1pUVmxaRE0wWW1ZeE1ERmpZemRrTlRVM09XWm1aR1F5TUdSbFlUQTVaVE15Wm1RM04yTXhOelUzWmprME5pSmRmWDE5TENKeVpYRkxaWGtpT2lKR1ZuYzVNMmRJWWtGVlVsUlVTVGMwTFdkaWQzWlVXVGhCVVVaQk4zQmtPVzFtY2padllrSTRVMDFaSWl3aWJHOW5jeUk2SWxwWlNVOUhNbFJUYjFwVmMweEVRbGREV0ZoRlgxVjZla1ZhY1hJM2RYZG9SeTFCVDNCcFJVcDZSbWNpTENKbGRtVnVkSE1pT2x0N0luQmhjbUZ0Y3lJNld5SnJPakl3TVRkbVpXVXpabUl4TldObVpUZzBNR1UxWldRek5HSm1NVEF4WTJNM1pEVTFOemxtWm1Sa01qQmtaV0V3T1dVek1tWmtOemRqTVRjMU4yWTVORFlpTENKck9tUmlOemMyTnprelltVXdabU5tT0dVM05tTTNOV0prWWpNMVlUTTJaVFkzWmpJNU9ERXhNV1JqTmpFME5XTTJOalk1TTJJd01UTXpNVGt5WlRJMk1UWWlMRFl1TVRsbExUWmRMQ0p1WVcxbElqb2lWRkpCVGxOR1JWSWlMQ0p0YjJSMWJHVWlPbnNpYm1GdFpYTndZV05sSWpwdWRXeHNMQ0p1WVcxbElqb2lZMjlwYmlKOUxDSnRiMlIxYkdWSVlYTm9Jam9pYTJ4R2EzSk1abkI1VEZjdFRUTjRhbFpRVTJSeFdFVk5aM2hRVUVwcFlsSjBYMFEyY1dsQ2QzTTJjeUo5TEhzaWNHRnlZVzF6SWpwYkltczZNakF4TjJabFpUTm1ZakUxWTJabE9EUXdaVFZsWkRNMFltWXhNREZqWXpka05UVTNPV1ptWkdReU1HUmxZVEE1WlRNeVptUTNOMk14TnpVM1pqazBOaUlzSW1zNk1qQXhOMlpsWlRObVlqRTFZMlpsT0RRd1pUVmxaRE0wWW1ZeE1ERmpZemRrTlRVM09XWm1aR1F5TUdSbFlUQTVaVE15Wm1RM04yTXhOelUzWmprME5pSXNNQzR4TENJeElsMHNJbTVoYldVaU9pSlVVa0ZPVTBaRlVsOVlRMGhCU1U0aUxDSnRiMlIxYkdVaU9uc2libUZ0WlhOd1lXTmxJanB1ZFd4c0xDSnVZVzFsSWpvaVkyOXBiaUo5TENKdGIyUjFiR1ZJWVhOb0lqb2lhMnhHYTNKTVpuQjVURmN0VFRONGFsWlFVMlJ4V0VWTlozaFFVRXBwWWxKMFgwUTJjV2xDZDNNMmN5SjlMSHNpY0dGeVlXMXpJanBiSW1zNk1qQXhOMlpsWlRObVlqRTFZMlpsT0RRd1pUVmxaRE0wWW1ZeE1ERmpZemRrTlRVM09XWm1aR1F5TUdSbFlUQTVaVE15Wm1RM04yTXhOelUzWmprME5pSXNJaUlzTUM0eFhTd2libUZ0WlNJNklsUlNRVTVUUmtWU0lpd2liVzlrZFd4bElqcDdJbTVoYldWemNHRmpaU0k2Ym5Wc2JDd2libUZ0WlNJNkltTnZhVzRpZlN3aWJXOWtkV3hsU0dGemFDSTZJbXRzUm10eVRHWndlVXhYTFUwemVHcFdVRk5rY1ZoRlRXZDRVRkJLYVdKU2RGOUVObkZwUW5kek5uTWlmU3g3SW5CaGNtRnRjeUk2V3lJeElpd2lZMjlwYmk1MGNtRnVjMlpsY2kxamNtOXpjMk5vWVdsdUlpeGJJbXM2TWpBeE4yWmxaVE5tWWpFMVkyWmxPRFF3WlRWbFpETTBZbVl4TURGall6ZGtOVFUzT1dabVpHUXlNR1JsWVRBNVpUTXlabVEzTjJNeE56VTNaamswTmlJc0ltczZNakF4TjJabFpUTm1ZakUxWTJabE9EUXdaVFZsWkRNMFltWXhNREZqWXpka05UVTNPV1ptWkdReU1HUmxZVEE1WlRNeVptUTNOMk14TnpVM1pqazBOaUlzZXlKd2NtVmtJam9pYTJWNWN5MWhiR3dpTENKclpYbHpJanBiSWpJd01UZG1aV1V6Wm1JeE5XTm1aVGcwTUdVMVpXUXpOR0ptTVRBeFkyTTNaRFUxTnpsbVptUmtNakJrWldFd09XVXpNbVprTnpkak1UYzFOMlk1TkRZaVhYMHNJakVpTERBdU1WMWRMQ0p1WVcxbElqb2lXRjlaU1VWTVJDSXNJbTF2WkhWc1pTSTZleUp1WVcxbGMzQmhZMlVpT201MWJHd3NJbTVoYldVaU9pSndZV04wSW4wc0ltMXZaSFZzWlVoaGMyZ2lPaUpyYkVacmNreG1jSGxNVnkxTk0zaHFWbEJUWkhGWVJVMW5lRkJRU21saVVuUmZSRFp4YVVKM2N6WnpJbjFkTENKdFpYUmhSR0YwWVNJNmJuVnNiQ3dpWTI5dWRHbHVkV0YwYVc5dUlqcDdJbVY0WldOMWRHVmtJanB1ZFd4c0xDSndZV04wU1dRaU9pSkdWbmM1TTJkSVlrRlZVbFJVU1RjMExXZGlkM1pVV1RoQlVVWkJOM0JrT1cxbWNqWnZZa0k0VTAxWklpd2ljM1JsY0VoaGMxSnZiR3hpWVdOcklqcG1ZV3h6WlN3aWMzUmxjQ0k2TUN3aWVXbGxiR1FpT25zaVpHRjBZU0k2ZXlKaGJXOTFiblFpT2pBdU1Td2ljbVZqWldsMlpYSWlPaUpyT2pJd01UZG1aV1V6Wm1JeE5XTm1aVGcwTUdVMVpXUXpOR0ptTVRBeFkyTTNaRFUxTnpsbVptUmtNakJrWldFd09XVXpNbVprTnpkak1UYzFOMlk1TkRZaUxDSnpiM1Z5WTJVdFkyaGhhVzRpT2lJd0lpd2ljbVZqWldsMlpYSXRaM1ZoY21RaU9uc2ljSEpsWkNJNkltdGxlWE10WVd4c0lpd2lhMlY1Y3lJNld5SXlNREUzWm1WbE0yWmlNVFZqWm1VNE5EQmxOV1ZrTXpSaVpqRXdNV05qTjJRMU5UYzVabVprWkRJd1pHVmhNRGxsTXpKbVpEYzNZekUzTlRkbU9UUTJJbDE5ZlN3aWMyOTFjbU5sSWpvaU1DSXNJbkJ5YjNabGJtRnVZMlVpT25zaWRHRnlaMlYwUTJoaGFXNUpaQ0k2SWpFaUxDSnRiMlIxYkdWSVlYTm9Jam9pYTJ4R2EzSk1abkI1VEZjdFRUTjRhbFpRVTJSeFdFVk5aM2hRVUVwcFlsSjBYMFEyY1dsQ2QzTTJjeUo5ZlN3aVkyOXVkR2x1ZFdGMGFXOXVJanA3SW1GeVozTWlPbHNpYXpveU1ERTNabVZsTTJaaU1UVmpabVU0TkRCbE5XVmtNelJpWmpFd01XTmpOMlExTlRjNVptWmtaREl3WkdWaE1EbGxNekptWkRjM1l6RTNOVGRtT1RRMklpd2lhem95TURFM1ptVmxNMlppTVRWalptVTROREJsTldWa016UmlaakV3TVdOak4yUTFOVGM1Wm1aa1pESXdaR1ZoTURsbE16Sm1aRGMzWXpFM05UZG1PVFEySWl4N0luQnlaV1FpT2lKclpYbHpMV0ZzYkNJc0ltdGxlWE1pT2xzaU1qQXhOMlpsWlRObVlqRTFZMlpsT0RRd1pUVmxaRE0wWW1ZeE1ERmpZemRrTlRVM09XWm1aR1F5TUdSbFlUQTVaVE15Wm1RM04yTXhOelUzWmprME5pSmRmU3dpTVNJc01DNHhYU3dpWkdWbUlqb2lZMjlwYmk1MGNtRnVjMlpsY2kxamNtOXpjMk5vWVdsdUluMHNJbk4wWlhCRGIzVnVkQ0k2TW4wc0luUjRTV1FpT2pRNE9ETTNPVEY5In0sImFsZ29yaXRobSI6IlNIQTUxMnRfMjU2In0', + ); + }, + ), +); + +describe('simpleTransferCreateCommand', () => { + it('should create a transfer command', async () => { + const output = await crossChainFinishCreateCommand( + { + amount: 100, + chainId: '0' as ChainId, + receiverAccount: 'k:receiverKey', + senderAccount: 'k:senderKey', + targetChainId: '1' as ChainId, + host: 'https://api.testnet.chainweb.com/chainweb/0.0/testnet04/chain/0/pact', + networkId: 'testnet04', + requestKey: 'FVw93gHbAURTTI74-gbwvTY8AQFA7pd9mfr6obB8SMY', + }, + { + account: 'k:gasPayerKey', + publicKeys: ['gasPayerKey'], + }, + ); + + expect(JSON.parse(output.cmd)).toEqual({ + payload: { + cont: { + data: { + from: 'k:senderKey', + to: 'k:receiverKey', + amount: 100, + fromChain: '0', + toChain: '1', + }, + proof: + 'eyJjaGFpbiI6MSwib2JqZWN0IjoiQUFBQUVBQUFBQUFBQUFBQkFEYy1ZMEwzdldwMXRMU0ZPWTQ4emtnUGlKd3NWZU41M0wtaURFamV5NTJ1QUgzdExDR0NVbFEwcjUwZll0eVl6X3NCeThmV3lydTVmUGNaT3AxYWRhT01BZWhPUk94V0FyQmJ1emV2dktNR1BlMHVGVV9QTzJ6MzdULS1jS2F0NnV3ekFYeTdDVGV0Zl9tWWc5LXpJb2x6ZXhWNENWeXpMamRzWnpsVXlpUDhMLXh2QU9DM2ZzUE9SU3VsenJsSkpfc2pLdVJ3ZVhISnNhUUI2OEtCWW1kSmd1bmVBU21ER0hkWUd2ZzZvMXNwaXR2NldORjkxMm9GYmFqQWZ4dVMtY3pPbnJVU0FMM1R4Rm40UWZ1ZFI3T2w5NkxiQVV1Nmxsektua1RLbVBSNEVkNTdkay1PQU5DcFM1NllTRzgySkhqSVcwci04N1NxckdzeWNQSmx2VVk3VkgtaG1lbXVBZFlZenNERjhhS05RRWlPcDJidU1UOTFuSWFEM3dpaF9wVURfem9JVWxEVEFEUGJfTTVNdkxFWTh3Z2V0OWYzbWVvWXBZemdLOGI3NXFCZXVKTGd6TDlHQWJhYWdkWkJFdEVlQjlsOUt6TzUycUstMkQ2XzdOdkRnZHAtU255OFBkVmpBTU0tRGYzNGdkN1hDZmsycXNsU2lvWm00UWhRTUdLMUw3UzU4eGpmUkpBbEFCaXVwZENaeEJhcEVjZUV4UXVDZXp3ODFySXJDa2gyTnRrY2V4N1F5TTFnQVNIT2w0NllldGFEWU1pMDlGS0pOYUNDMUthV2paMVlfVnFsamhRZXNINzBBRS14YXh3a3RfZmVRdnBibkZkR0EwVWVuVTlSb1FpdkxwcDBhZklvZzdfVEFDdTZ0dFU0OXRpcW11R0hraDhVTF80Sm9OUVBvRmdWZlBWVktCbzJ5RU1aIiwic3ViamVjdCI6eyJpbnB1dCI6IkFCUjdJbWRoY3lJNk5qRTVMQ0p5WlhOMWJIUWlPbnNpYzNSaGRIVnpJam9pYzNWalkyVnpjeUlzSW1SaGRHRWlPbnNpWVcxdmRXNTBJam93TGpFc0luSmxZMlZwZG1WeUlqb2lhem95TURFM1ptVmxNMlppTVRWalptVTROREJsTldWa016UmlaakV3TVdOak4yUTFOVGM1Wm1aa1pESXdaR1ZoTURsbE16Sm1aRGMzWXpFM05UZG1PVFEySWl3aWMyOTFjbU5sTFdOb1lXbHVJam9pTUNJc0luSmxZMlZwZG1WeUxXZDFZWEprSWpwN0luQnlaV1FpT2lKclpYbHpMV0ZzYkNJc0ltdGxlWE1pT2xzaU1qQXhOMlpsWlRObVlqRTFZMlpsT0RRd1pUVmxaRE0wWW1ZeE1ERmpZemRrTlRVM09XWm1aR1F5TUdSbFlUQTVaVE15Wm1RM04yTXhOelUzWmprME5pSmRmWDE5TENKeVpYRkxaWGtpT2lKR1ZuYzVNMmRJWWtGVlVsUlVTVGMwTFdkaWQzWlVXVGhCVVVaQk4zQmtPVzFtY2padllrSTRVMDFaSWl3aWJHOW5jeUk2SWxwWlNVOUhNbFJUYjFwVmMweEVRbGREV0ZoRlgxVjZla1ZhY1hJM2RYZG9SeTFCVDNCcFJVcDZSbWNpTENKbGRtVnVkSE1pT2x0N0luQmhjbUZ0Y3lJNld5SnJPakl3TVRkbVpXVXpabUl4TldObVpUZzBNR1UxWldRek5HSm1NVEF4WTJNM1pEVTFOemxtWm1Sa01qQmtaV0V3T1dVek1tWmtOemRqTVRjMU4yWTVORFlpTENKck9tUmlOemMyTnprelltVXdabU5tT0dVM05tTTNOV0prWWpNMVlUTTJaVFkzWmpJNU9ERXhNV1JqTmpFME5XTTJOalk1TTJJd01UTXpNVGt5WlRJMk1UWWlMRFl1TVRsbExUWmRMQ0p1WVcxbElqb2lWRkpCVGxOR1JWSWlMQ0p0YjJSMWJHVWlPbnNpYm1GdFpYTndZV05sSWpwdWRXeHNMQ0p1WVcxbElqb2lZMjlwYmlKOUxDSnRiMlIxYkdWSVlYTm9Jam9pYTJ4R2EzSk1abkI1VEZjdFRUTjRhbFpRVTJSeFdFVk5aM2hRVUVwcFlsSjBYMFEyY1dsQ2QzTTJjeUo5TEhzaWNHRnlZVzF6SWpwYkltczZNakF4TjJabFpUTm1ZakUxWTJabE9EUXdaVFZsWkRNMFltWXhNREZqWXpka05UVTNPV1ptWkdReU1HUmxZVEE1WlRNeVptUTNOMk14TnpVM1pqazBOaUlzSW1zNk1qQXhOMlpsWlRObVlqRTFZMlpsT0RRd1pUVmxaRE0wWW1ZeE1ERmpZemRrTlRVM09XWm1aR1F5TUdSbFlUQTVaVE15Wm1RM04yTXhOelUzWmprME5pSXNNQzR4TENJeElsMHNJbTVoYldVaU9pSlVVa0ZPVTBaRlVsOVlRMGhCU1U0aUxDSnRiMlIxYkdVaU9uc2libUZ0WlhOd1lXTmxJanB1ZFd4c0xDSnVZVzFsSWpvaVkyOXBiaUo5TENKdGIyUjFiR1ZJWVhOb0lqb2lhMnhHYTNKTVpuQjVURmN0VFRONGFsWlFVMlJ4V0VWTlozaFFVRXBwWWxKMFgwUTJjV2xDZDNNMmN5SjlMSHNpY0dGeVlXMXpJanBiSW1zNk1qQXhOMlpsWlRObVlqRTFZMlpsT0RRd1pUVmxaRE0wWW1ZeE1ERmpZemRrTlRVM09XWm1aR1F5TUdSbFlUQTVaVE15Wm1RM04yTXhOelUzWmprME5pSXNJaUlzTUM0eFhTd2libUZ0WlNJNklsUlNRVTVUUmtWU0lpd2liVzlrZFd4bElqcDdJbTVoYldWemNHRmpaU0k2Ym5Wc2JDd2libUZ0WlNJNkltTnZhVzRpZlN3aWJXOWtkV3hsU0dGemFDSTZJbXRzUm10eVRHWndlVXhYTFUwemVHcFdVRk5rY1ZoRlRXZDRVRkJLYVdKU2RGOUVObkZwUW5kek5uTWlmU3g3SW5CaGNtRnRjeUk2V3lJeElpd2lZMjlwYmk1MGNtRnVjMlpsY2kxamNtOXpjMk5vWVdsdUlpeGJJbXM2TWpBeE4yWmxaVE5tWWpFMVkyWmxPRFF3WlRWbFpETTBZbVl4TURGall6ZGtOVFUzT1dabVpHUXlNR1JsWVRBNVpUTXlabVEzTjJNeE56VTNaamswTmlJc0ltczZNakF4TjJabFpUTm1ZakUxWTJabE9EUXdaVFZsWkRNMFltWXhNREZqWXpka05UVTNPV1ptWkdReU1HUmxZVEE1WlRNeVptUTNOMk14TnpVM1pqazBOaUlzZXlKd2NtVmtJam9pYTJWNWN5MWhiR3dpTENKclpYbHpJanBiSWpJd01UZG1aV1V6Wm1JeE5XTm1aVGcwTUdVMVpXUXpOR0ptTVRBeFkyTTNaRFUxTnpsbVptUmtNakJrWldFd09XVXpNbVprTnpkak1UYzFOMlk1TkRZaVhYMHNJakVpTERBdU1WMWRMQ0p1WVcxbElqb2lXRjlaU1VWTVJDSXNJbTF2WkhWc1pTSTZleUp1WVcxbGMzQmhZMlVpT201MWJHd3NJbTVoYldVaU9pSndZV04wSW4wc0ltMXZaSFZzWlVoaGMyZ2lPaUpyYkVacmNreG1jSGxNVnkxTk0zaHFWbEJUWkhGWVJVMW5lRkJRU21saVVuUmZSRFp4YVVKM2N6WnpJbjFkTENKdFpYUmhSR0YwWVNJNmJuVnNiQ3dpWTI5dWRHbHVkV0YwYVc5dUlqcDdJbVY0WldOMWRHVmtJanB1ZFd4c0xDSndZV04wU1dRaU9pSkdWbmM1TTJkSVlrRlZVbFJVU1RjMExXZGlkM1pVV1RoQlVVWkJOM0JrT1cxbWNqWnZZa0k0VTAxWklpd2ljM1JsY0VoaGMxSnZiR3hpWVdOcklqcG1ZV3h6WlN3aWMzUmxjQ0k2TUN3aWVXbGxiR1FpT25zaVpHRjBZU0k2ZXlKaGJXOTFiblFpT2pBdU1Td2ljbVZqWldsMlpYSWlPaUpyT2pJd01UZG1aV1V6Wm1JeE5XTm1aVGcwTUdVMVpXUXpOR0ptTVRBeFkyTTNaRFUxTnpsbVptUmtNakJrWldFd09XVXpNbVprTnpkak1UYzFOMlk1TkRZaUxDSnpiM1Z5WTJVdFkyaGhhVzRpT2lJd0lpd2ljbVZqWldsMlpYSXRaM1ZoY21RaU9uc2ljSEpsWkNJNkltdGxlWE10WVd4c0lpd2lhMlY1Y3lJNld5SXlNREUzWm1WbE0yWmlNVFZqWm1VNE5EQmxOV1ZrTXpSaVpqRXdNV05qTjJRMU5UYzVabVprWkRJd1pHVmhNRGxsTXpKbVpEYzNZekUzTlRkbU9UUTJJbDE5ZlN3aWMyOTFjbU5sSWpvaU1DSXNJbkJ5YjNabGJtRnVZMlVpT25zaWRHRnlaMlYwUTJoaGFXNUpaQ0k2SWpFaUxDSnRiMlIxYkdWSVlYTm9Jam9pYTJ4R2EzSk1abkI1VEZjdFRUTjRhbFpRVTJSeFdFVk5aM2hRVUVwcFlsSjBYMFEyY1dsQ2QzTTJjeUo5ZlN3aVkyOXVkR2x1ZFdGMGFXOXVJanA3SW1GeVozTWlPbHNpYXpveU1ERTNabVZsTTJaaU1UVmpabVU0TkRCbE5XVmtNelJpWmpFd01XTmpOMlExTlRjNVptWmtaREl3WkdWaE1EbGxNekptWkRjM1l6RTNOVGRtT1RRMklpd2lhem95TURFM1ptVmxNMlppTVRWalptVTROREJsTldWa016UmlaakV3TVdOak4yUTFOVGM1Wm1aa1pESXdaR1ZoTURsbE16Sm1aRGMzWXpFM05UZG1PVFEySWl4N0luQnlaV1FpT2lKclpYbHpMV0ZzYkNJc0ltdGxlWE1pT2xzaU1qQXhOMlpsWlRObVlqRTFZMlpsT0RRd1pUVmxaRE0wWW1ZeE1ERmpZemRrTlRVM09XWm1aR1F5TUdSbFlUQTVaVE15Wm1RM04yTXhOelUzWmprME5pSmRmU3dpTVNJc01DNHhYU3dpWkdWbUlqb2lZMjlwYmk1MGNtRnVjMlpsY2kxamNtOXpjMk5vWVdsdUluMHNJbk4wWlhCRGIzVnVkQ0k2TW4wc0luUjRTV1FpT2pRNE9ETTNPVEY5In0sImFsZ29yaXRobSI6IlNIQTUxMnRfMjU2In0', + pactId: 'FVw93gHbAURTTI74-gbwvTY8AQFA7pd9mfr6obB8SMY', + rollback: false, + step: 1, + }, + }, + nonce: expect.any(String), + signers: [ + { + pubKey: 'gasPayerKey', + scheme: 'ED25519', + clist: [{ name: 'coin.GAS', args: [] }], + }, + ], + meta: { + gasLimit: 850, + gasPrice: 1e-8, + sender: 'k:gasPayerKey', + ttl: 28800, + creationTime: expect.any(Number), + chainId: '0', + }, + networkId: 'testnet04', + }); + }); +}); diff --git a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts index d742492877..06b4b86836 100644 --- a/packages/libs/wallet-sdk/src/sdk/walletSdk.ts +++ b/packages/libs/wallet-sdk/src/sdk/walletSdk.ts @@ -154,10 +154,20 @@ export class WalletSDK { /** create cross-chain transfer finish */ public async createFinishCrossChainTransfer( - transfer: ICreateCrossChainFinishInput, + transfer: Omit, gasPayer: { account: string; publicKeys: ISigner[] }, ): Promise { - const command = await crossChainFinishCreateCommand(transfer, gasPayer); + const host = this.getChainwebUrl({ + chainId: transfer.chainId, + networkId: transfer.networkId, + }); + const command = await crossChainFinishCreateCommand( + { + ...transfer, + host, + }, + gasPayer, + ); return command; } From e164f8ef1248831a3fbc37b7e12768b223873b07 Mon Sep 17 00:00:00 2001 From: Nillo Date: Fri, 6 Dec 2024 14:04:59 +0100 Subject: [PATCH 088/103] chore(wallet-sdk): kadenanames test update --- .../src/sdk/tests/kadenanames.test.ts | 97 ++++++++++++++++++- .../src/services/kadenaNamesService.ts | 5 +- 2 files changed, 99 insertions(+), 3 deletions(-) diff --git a/packages/libs/wallet-sdk/src/sdk/tests/kadenanames.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/kadenanames.test.ts index d33a65cc12..1e3b9ee49e 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/kadenanames.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/kadenanames.test.ts @@ -1,8 +1,10 @@ -// kadenaNames.test.ts - import { http, HttpResponse } from 'msw'; import { setupServer } from 'msw/node'; import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'; +import { + ensureKdaExtension, + parseChainResponse, +} from '../../services/kadenaNamesService'; import { walletSdk } from '../walletSdk.js'; const server = setupServer(); @@ -78,6 +80,97 @@ function getLocalUrl(networkId: string, chainId: string): string { return `${host}/api/v1/local`; } +describe('ensureKdaExtension', () => { + it('should append .kda if not already present', () => { + const result = ensureKdaExtension('example'); + expect(result).toBe('example.kda'); + }); + + it('should not append .kda if already present', () => { + const result = ensureKdaExtension('example.kda'); + expect(result).toBe('example.kda'); + }); + + it('should handle uppercase names and append .kda', () => { + const result = ensureKdaExtension('EXAMPLE'); + expect(result).toBe('example.kda'); + }); +}); + +describe('parseChainResponse', () => { + it('should return data on success', () => { + const response = { + result: { + status: 'success', + data: 'mockData', + }, + }; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const result = parseChainResponse(response as any, 'address'); + expect(result).toBe('mockData'); + }); + + it('should throw an error on failure with a detailed message', () => { + const response = { + result: { + status: 'failure', + error: { + message: 'An error occurred', + }, + }, + }; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + expect(() => parseChainResponse(response as any, 'address')).toThrow( + 'Failed to retrieve address: {"message":"An error occurred"}', + ); + }); + + it('should throw an unknown error when no status is present', () => { + const response = {}; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + expect(() => parseChainResponse(response as any, 'address')).toThrow( + 'Failed to retrieve address: Unknown error', + ); + }); +}); + +describe('parseChainResponse', () => { + it('should return data on success', () => { + const response = { + result: { + status: 'success', + data: 'mockData', + }, + }; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const result = parseChainResponse(response as any, 'address'); + expect(result).toBe('mockData'); + }); + + it('should throw an error on failure with a detailed message', () => { + const response = { + result: { + status: 'failure', + error: { + message: 'An error occurred', + }, + }, + }; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + expect(() => parseChainResponse(response as any, 'address')).toThrow( + 'Failed to retrieve address: {"message":"An error occurred"}', + ); + }); + + it('should throw an unknown error when no status is present', () => { + const response = {}; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + expect(() => parseChainResponse(response as any, 'address')).toThrow( + 'Failed to retrieve address: Unknown error', + ); + }); +}); + describe('KadenaNames', () => { describe('nameToAddress', () => { it('should return address for registered name on mainnet', async () => { diff --git a/packages/libs/wallet-sdk/src/services/kadenaNamesService.ts b/packages/libs/wallet-sdk/src/services/kadenaNamesService.ts index c08805460e..bea92b78b3 100644 --- a/packages/libs/wallet-sdk/src/services/kadenaNamesService.ts +++ b/packages/libs/wallet-sdk/src/services/kadenaNamesService.ts @@ -75,7 +75,10 @@ export async function addressToName( return kdnResolver(address, networkId, networkHost, 'name'); } -function parseChainResponse(response: ICommandResult, subject: string): T { +export function parseChainResponse( + response: ICommandResult, + subject: string, +): T { if (response.result?.status === 'success') { return response.result.data as T; } else if (response.result?.status === 'failure') { From 227956849f088f0afa357732dedfa7574a7ce9bb Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 14:10:39 +0100 Subject: [PATCH 089/103] fix(wallet-sdk-example): fix typescript issue --- packages/apps/wallet-sdk-example/src/hooks/transfers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts index e90ef69126..aa619db075 100644 --- a/packages/apps/wallet-sdk-example/src/hooks/transfers.ts +++ b/packages/apps/wallet-sdk-example/src/hooks/transfers.ts @@ -1,4 +1,4 @@ -import { walletSdk } from '@kadena/wallet-sdk'; +import { ICrossChainTransfer, walletSdk } from '@kadena/wallet-sdk'; import { useQuery } from '@tanstack/react-query'; import { useEffect } from 'react'; import { usePendingTransfers } from '../state/pending'; @@ -55,7 +55,7 @@ export const useTransfers = () => { const crossChainTransfers = transfers.filter( (transfer) => transfer.isCrossChainTransfer, - ); + ) as ICrossChainTransfer[]; const incompleteTransfers = crossChainTransfers.filter( (transfer) => !transfer.continuation, ); From 588c3d286ebec2a9381976d346e8910c182b6c90 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 14:24:44 +0100 Subject: [PATCH 090/103] fix(wallet-sdk-example): add to packages --- .github/labeler.yml | 3 +++ README.md | 14 +++++++++----- packages.json | 6 ++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index 7bfc8d69e2..052fcf1cfd 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -151,3 +151,6 @@ e2e-proof-of-us: '@kadena/wallet-sdk': - changed-files: - any-glob-to-any-file: packages/libs/wallet-sdk/* +wallet-sdk-example-app: + - changed-files: + - any-glob-to-any-file: packages/apps/wallet-sdk-example/* diff --git a/README.md b/README.md index 7e76e18aaf..03e9da4be8 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,8 @@ Overview of the main packages maintained in this repository: | [@kadena/pactjs-cli][53] | [![version][55]][54] | | [@kadena/pactjs-generator][56] | [![version][58]][57] | | [@kadena/snap][59] | [![version][61]][60] | -| [@kadena/types][62] | [![version][61]][60] | -| [@kadena/wallet-sdk][62] | [![version][64]][63] | +| [@kadena/types][62] | [![version][64]][63] | +| [@kadena/wallet-sdk][65] | [![version][67]][66] | @@ -54,7 +54,7 @@ Overview of the main packages maintained in this repository: Special thanks to the wonderful people who have contributed to this project: -[![Contributors][66]][65] +[![Contributors][69]][68] [1]: https://docs.kadena.io [2]: https://discord.io/kadena @@ -139,5 +139,9 @@ Special thanks to the wonderful people who have contributed to this project: https://github.com/kadena-community/kadena.js/tree/main/packages/libs/types [63]: packages/libs/types/CHANGELOG.md [64]: https://img.shields.io/npm/v/@kadena/types.svg -[65]: https://github.com/kadena-community/kadena.js/graphs/contributors -[66]: https://contrib.rocks/image?repo=kadena-community/kadena.js +[65]: + https://github.com/kadena-community/kadena.js/tree/main/packages/libs/wallet-sdk +[66]: packages/libs/wallet-sdk/CHANGELOG.md +[67]: https://img.shields.io/npm/v/@kadena/wallet-sdk.svg +[68]: https://github.com/kadena-community/kadena.js/graphs/contributors +[69]: https://contrib.rocks/image?repo=kadena-community/kadena.js diff --git a/packages.json b/packages.json index e3603b0a8e..7d5a943f9a 100644 --- a/packages.json +++ b/packages.json @@ -262,5 +262,11 @@ "version": "0.0.2", "private": true, "path": "packages/e2e/e2e-tools" + }, + { + "name": "wallet-sdk-example-app", + "version": "0.0.1", + "private": true, + "path": "packages/apps/wallet-sdk-example" } ] From 4bfe084c7c73699c8135c001dd478e812c9c9e54 Mon Sep 17 00:00:00 2001 From: Javad Khalilian Date: Fri, 6 Dec 2024 14:45:40 +0100 Subject: [PATCH 091/103] fix(dw): migarte db to 40 (#2714) --- packages/apps/dev-wallet/src/config.ts | 6 +- .../dev-wallet/src/modules/db/db-channel.ts | 17 +++++ .../dev-wallet/src/modules/db/db.service.tsx | 63 +----------------- .../modules/db/migration/migrateFrom39to40.ts | 38 +++++++++++ .../src/modules/db/migration/migration.ts | 64 +++++++++++++++++++ 5 files changed, 123 insertions(+), 65 deletions(-) create mode 100644 packages/apps/dev-wallet/src/modules/db/db-channel.ts create mode 100644 packages/apps/dev-wallet/src/modules/db/migration/migrateFrom39to40.ts create mode 100644 packages/apps/dev-wallet/src/modules/db/migration/migration.ts diff --git a/packages/apps/dev-wallet/src/config.ts b/packages/apps/dev-wallet/src/config.ts index b002bd1158..a772aa364d 100644 --- a/packages/apps/dev-wallet/src/config.ts +++ b/packages/apps/dev-wallet/src/config.ts @@ -12,12 +12,8 @@ export const config = { colorList, defaultAccentColor: colorList[0], DB: { - DB_VERSION: 39, + DB_VERSION: 40, DB_NAME: 'dev-wallet', - // This should be used carefully, as it will wipe the database on version change - // I have added this for development purposes, We should remove this and write - // a migration script - DB_WIPE_ON_VERSION_CHANGE: true, }, ACCOUNTS: { SYNC_INTERVAL: 5 * 60 * 1000, // 5 minutes diff --git a/packages/apps/dev-wallet/src/modules/db/db-channel.ts b/packages/apps/dev-wallet/src/modules/db/db-channel.ts new file mode 100644 index 0000000000..4970e533a7 --- /dev/null +++ b/packages/apps/dev-wallet/src/modules/db/db-channel.ts @@ -0,0 +1,17 @@ +export type EventTypes = + | 'add' + | 'update' + | 'delete' + | 'import' + | 'migration-started' + | 'migration-finished'; + +export const dbChannel = new BroadcastChannel('db-channel'); +export const broadcast = ( + event: EventTypes, + storeName?: string, + data?: any[], +) => { + console.log('broadcast', event, storeName, data); + dbChannel.postMessage({ type: event, storeName, data }); +}; diff --git a/packages/apps/dev-wallet/src/modules/db/db.service.tsx b/packages/apps/dev-wallet/src/modules/db/db.service.tsx index 1088b62de1..0a7e62f445 100644 --- a/packages/apps/dev-wallet/src/modules/db/db.service.tsx +++ b/packages/apps/dev-wallet/src/modules/db/db.service.tsx @@ -2,7 +2,6 @@ import { config } from '@/config'; import { addItem, connect, - deleteDatabase, deleteItem, getAllItems, getOneItem, @@ -11,15 +10,8 @@ import { import { execInSequence } from '@/utils/helpers'; import { IDBBackup, importBackup, serializeTables } from './backup/backup'; -import { createTables } from './migration/createDB'; -import { migrateFrom37to38 } from './migration/migrateFrom37to38'; -import { migrateFrom38to39 } from './migration/migrateFrom38to39'; - -const dbChannel = new BroadcastChannel('db-channel'); -const broadcast = (event: EventTypes, storeName?: string, data?: any[]) => { - console.log('broadcast', event, storeName, data); - dbChannel.postMessage({ type: event, storeName, data }); -}; +import { broadcast, dbChannel, EventTypes } from './db-channel'; +import { migration } from './migration/migration'; const { DB_NAME, DB_VERSION } = config.DB; @@ -28,49 +20,7 @@ export const setupDatabase = execInSequence(async (): Promise => { let db = result.db; if (result.needsUpgrade) { broadcast('migration-started'); - const oldVersion = result.oldVersion; - if (oldVersion === 0) { - console.log('creating new database'); - createTables(db); - } else if (oldVersion < 37) { - const confirmed = confirm( - 'You’re using an outdated database version that doesn’t support migration. To continue using the app, all data must be wiped. Do you want to proceed?', - ); - if (!confirmed) { - throw new Error('OUTDATED_DATABASE: database needs upgrade'); - } - - console.log( - 'Attempting to delete database because it is too old to be migrated', - ); - db.close(); - console.log('deleting database'); - await deleteDatabase(DB_NAME); - console.log('creating new database'); - const { db: newDb } = await connect(DB_NAME, DB_VERSION); - db = newDb; - - createTables(db); - } else { - for ( - let fromVersion = oldVersion; - fromVersion < DB_VERSION; - fromVersion++ - ) { - // we need to add a migration path for each version - if (fromVersion === 37) { - await migrateFrom37to38(db, result.versionTransaction); - continue; - } - if (fromVersion === 38) { - await migrateFrom38to39(db, result.versionTransaction); - continue; - } - throw new Error( - `There is no migration path for version ${fromVersion} to ${fromVersion + 1}`, - ); - } - } + db = await migration(result); broadcast('migration-finished'); } @@ -101,13 +51,6 @@ export const injectDb = Promise>( }); }) as R; -type EventTypes = - | 'add' - | 'update' - | 'delete' - | 'import' - | 'migration-started' - | 'migration-finished'; // eslint-disable-next-line @typescript-eslint/no-explicit-any type Listener = (type: EventTypes, storeName: string, ...data: any[]) => void; diff --git a/packages/apps/dev-wallet/src/modules/db/migration/migrateFrom39to40.ts b/packages/apps/dev-wallet/src/modules/db/migration/migrateFrom39to40.ts new file mode 100644 index 0000000000..861f07bc73 --- /dev/null +++ b/packages/apps/dev-wallet/src/modules/db/migration/migrateFrom39to40.ts @@ -0,0 +1,38 @@ +// this function is called by db service when the database is updated from version 39 to 40 +// check the change log for more details +import { IActivity } from '@/modules/activity/activity.repository'; +import { addItem, createStore, getAllItems } from '../indexeddb'; +import { defineSchemeFactory, ExtendedTableName } from './createDB'; + +const changeLog = ['Index activity by profileId']; + +const { defineScheme } = defineSchemeFactory(); + +export async function migrateFrom39to40( + db: IDBDatabase, + transaction: IDBTransaction, +) { + console.log('migrating from 39 to 40', 'change log:'); + changeLog.forEach((log, index) => console.log(index, log)); + const create = createStore(db); + const activityTemp: ExtendedTableName = `temp:activity-v40:${Date.now()}`; + create( + defineScheme(activityTemp, 'uuid', [ + { index: 'profileId' }, + { index: 'profile-network', indexKeyPath: ['profileId', 'networkUUID'] }, + { index: 'keyset-network', indexKeyPath: ['keysetId', 'networkUUID'] }, + ]), + ); + const allActivities = await getAllItems( + db, + transaction, + )('activity'); + const add = addItem(db, transaction); + await Promise.all( + allActivities.map((activity) => add(activityTemp, activity)), + ); + const backupName: ExtendedTableName = `backup:activity-v39:${Date.now()}`; + transaction.objectStore('activity').name = backupName; + transaction.objectStore(activityTemp).name = 'activity'; + db.deleteObjectStore(backupName); +} diff --git a/packages/apps/dev-wallet/src/modules/db/migration/migration.ts b/packages/apps/dev-wallet/src/modules/db/migration/migration.ts new file mode 100644 index 0000000000..dafd821d78 --- /dev/null +++ b/packages/apps/dev-wallet/src/modules/db/migration/migration.ts @@ -0,0 +1,64 @@ +import { config } from '@/config'; +import { connect, deleteDatabase } from '../indexeddb'; +import { createTables } from './createDB'; +import { migrateFrom37to38 } from './migrateFrom37to38'; +import { migrateFrom38to39 } from './migrateFrom38to39'; +import { migrateFrom39to40 } from './migrateFrom39to40'; + +const { DB_NAME, DB_VERSION } = config.DB; + +const migrationMap = { + 37: migrateFrom37to38, + 38: migrateFrom38to39, + 39: migrateFrom39to40, +}; + +export async function migration(result: { + db: IDBDatabase; + oldVersion: number; + versionTransaction: IDBTransaction; +}) { + let { db } = result; + const oldVersion = result.oldVersion; + if (oldVersion === 0) { + console.log('creating new database'); + createTables(db); + } else if (oldVersion < 37) { + const confirmed = confirm( + 'You’re using an outdated database version that doesn’t support migration. To continue using the app, all data must be wiped. Do you want to proceed?', + ); + if (!confirmed) { + throw new Error('OUTDATED_DATABASE: database needs upgrade'); + } + + console.log( + 'Attempting to delete database because it is too old to be migrated', + ); + db.close(); + console.log('deleting database'); + await deleteDatabase(DB_NAME); + console.log('creating new database'); + const { db: newDb } = await connect(DB_NAME, DB_VERSION); + db = newDb; + + createTables(db); + } else { + for ( + let fromVersion = oldVersion; + fromVersion < DB_VERSION; + fromVersion++ + ) { + const migrationPath = + migrationMap[fromVersion as keyof typeof migrationMap]; + // we need to add a migration path for each version + if (migrationPath) { + await migrationPath(db, result.versionTransaction); + continue; + } + throw new Error( + `There is no migration path for version ${fromVersion} to ${fromVersion + 1}`, + ); + } + } + return db; +} From 5e9bfd048f066431bc3988abfabd4f29bbfba6f2 Mon Sep 17 00:00:00 2001 From: Javad Khalilian Date: Fri, 6 Dec 2024 14:45:55 +0100 Subject: [PATCH 092/103] feat(client): support headers in client (#2611) * feat(client): suppport headers in client * refactor(client): host url * feat(client): accept request init options * fix(chainweb-client): header * test(client): add unit tests * :chore(client): clean up * chore(changeset): add log * fix(client): export type --- .changeset/hungry-steaks-count.md | 6 + .../etc/chainweb-node-client.api.md | 128 +++++++++- .../libs/chainweb-node-client/src/listen.ts | 4 +- .../libs/chainweb-node-client/src/local.ts | 22 +- .../libs/chainweb-node-client/src/poll.ts | 4 +- .../libs/chainweb-node-client/src/send.ts | 4 +- packages/libs/chainweb-node-client/src/spv.ts | 4 +- .../src/stringifyAndMakePOSTRequest.ts | 9 +- .../tests/stringifyAndMakePOSTRequest.test.ts | 15 ++ .../client-utils/etc/client-utils-core.api.md | 44 +++- .../libs/client-utils/src/core/cross-chain.ts | 6 +- packages/libs/client/etc/client.api.md | 37 +-- .../libs/client/src/client/api/runPact.ts | 7 +- packages/libs/client/src/client/api/spv.ts | 10 +- packages/libs/client/src/client/api/status.ts | 28 ++- .../src/client/api/tests/status.test.ts | 46 +++- packages/libs/client/src/client/client.ts | 171 ++++++++++--- .../src/client/interfaces/interfaces.ts | 12 +- .../client/src/client/tests/client.test.ts | 238 +++++++++++++++++- .../client/src/client/utils/mergeOptions.ts | 33 +++ .../libs/client/src/client/utils/retry.ts | 13 +- .../client/utils/tests/mergeOptions.test.ts | 42 ++++ .../src/client/utils/tests/retry.test.ts | 36 +++ .../libs/client/src/client/utils/utils.ts | 18 +- packages/libs/client/src/index.ts | 1 + packages/libs/client/vitest.config.ts | 1 + 26 files changed, 832 insertions(+), 107 deletions(-) create mode 100644 .changeset/hungry-steaks-count.md create mode 100644 packages/libs/client/src/client/utils/mergeOptions.ts create mode 100644 packages/libs/client/src/client/utils/tests/mergeOptions.test.ts diff --git a/.changeset/hungry-steaks-count.md b/.changeset/hungry-steaks-count.md new file mode 100644 index 0000000000..eb8da1c8a5 --- /dev/null +++ b/.changeset/hungry-steaks-count.md @@ -0,0 +1,6 @@ +--- +'@kadena/chainweb-node-client': minor +'@kadena/client': minor +--- + +Support for passing a request init object to client functions diff --git a/packages/libs/chainweb-node-client/etc/chainweb-node-client.api.md b/packages/libs/chainweb-node-client/etc/chainweb-node-client.api.md index c0b557717e..f829367b4d 100644 --- a/packages/libs/chainweb-node-client/etc/chainweb-node-client.api.md +++ b/packages/libs/chainweb-node-client/etc/chainweb-node-client.api.md @@ -23,6 +23,9 @@ export type ChainwebChainId = (typeof CHAINS)[number]; // @alpha export type ChainwebNetworkId = 'mainnet01' | 'testnet04' | 'testnet05' | 'development'; +// @alpha (undocumented) +export type ClientRequestInit = Omit; + // @alpha (undocumented) export function convertIUnsignedTransactionToNoSig(transaction: IUnsignedCommand): ICommand; @@ -86,7 +89,7 @@ export interface ILocalCommandResult { } // @alpha (undocumented) -export interface ILocalOptions { +export interface ILocalOptions extends ClientRequestInit { // (undocumented) preflight?: boolean; // (undocumented) @@ -153,7 +156,7 @@ export interface ISPVRequestBody { } // @alpha -export function listen(requestBody: IListenRequestBody, apiHost: string): Promise; +export function listen(requestBody: IListenRequestBody, apiHost: string, requestInit?: ClientRequestInit): Promise; // @alpha (undocumented) export type ListenResponse = ICommandResult; @@ -162,7 +165,7 @@ export type ListenResponse = ICommandResult; export function local(requestBody: LocalRequestBody, apiHost: string, options?: T): Promise>; // @alpha -export function localRaw(requestBody: LocalRequestBody, apiHost: string, { preflight, signatureVerification, }: { +export function localRaw(requestBody: LocalRequestBody, apiHost: string, { preflight, signatureVerification, ...requestInit }: ILocalOptions & { signatureVerification: boolean; preflight: boolean; }): Promise; @@ -191,22 +194,133 @@ export function parseResponse(response: Response): Promise; export function parseResponseTEXT(response: Response): Promise; // @alpha -export function poll(requestBody: IPollRequestBody, apiHost: string, confirmationDepth?: number): Promise; +export function poll(requestBody: IPollRequestBody, apiHost: string, confirmationDepth?: number, requestInit?: ClientRequestInit): Promise; // @alpha -export function send(requestBody: ISendRequestBody, apiHost: string): Promise; +export function send(requestBody: ISendRequestBody, apiHost: string, requestInit?: ClientRequestInit): Promise; // @alpha export type SendResponse = IRequestKeys; // @alpha -export function spv(requestBody: ISPVRequestBody, apiHost: string): Promise; +export function spv(requestBody: ISPVRequestBody, apiHost: string, requestInit?: ClientRequestInit): Promise; // @alpha export type SPVResponse = SPVProof; // @alpha -export function stringifyAndMakePOSTRequest(body: T): object; +export function stringifyAndMakePOSTRequest(body: T, requestInit?: ClientRequestInit): { + headers: { + 'Content-Type': string; + } | { + length: number; + toString(): string; + toLocaleString(): string; + pop(): [string, string] | undefined; + push(...items: [string, string][]): number; + concat(...items: ConcatArray<[string, string]>[]): [string, string][]; + concat(...items: ([string, string] | ConcatArray<[string, string]>)[]): [string, string][]; + join(separator?: string | undefined): string; + reverse(): [string, string][]; + shift(): [string, string] | undefined; + slice(start?: number | undefined, end?: number | undefined): [string, string][]; + sort(compareFn?: ((a: [string, string], b: [string, string]) => number) | undefined): [string, string][]; + splice(start: number, deleteCount?: number | undefined): [string, string][]; + splice(start: number, deleteCount: number, ...items: [string, string][]): [string, string][]; + unshift(...items: [string, string][]): number; + indexOf(searchElement: [string, string], fromIndex?: number | undefined): number; + lastIndexOf(searchElement: [string, string], fromIndex?: number | undefined): number; + every(predicate: (value: [string, string], index: number, array: [string, string][]) => value is S, thisArg?: any): this is S[]; + every(predicate: (value: [string, string], index: number, array: [string, string][]) => unknown, thisArg?: any): boolean; + some(predicate: (value: [string, string], index: number, array: [string, string][]) => unknown, thisArg?: any): boolean; + forEach(callbackfn: (value: [string, string], index: number, array: [string, string][]) => void, thisArg?: any): void; + map(callbackfn: (value: [string, string], index: number, array: [string, string][]) => U, thisArg?: any): U[]; + filter(predicate: (value: [string, string], index: number, array: [string, string][]) => value is S_1, thisArg?: any): S_1[]; + filter(predicate: (value: [string, string], index: number, array: [string, string][]) => unknown, thisArg?: any): [string, string][]; + reduce(callbackfn: (previousValue: [string, string], currentValue: [string, string], currentIndex: number, array: [string, string][]) => [string, string]): [string, string]; + reduce(callbackfn: (previousValue: [string, string], currentValue: [string, string], currentIndex: number, array: [string, string][]) => [string, string], initialValue: [string, string]): [string, string]; + reduce(callbackfn: (previousValue: U_1, currentValue: [string, string], currentIndex: number, array: [string, string][]) => U_1, initialValue: U_1): U_1; + reduceRight(callbackfn: (previousValue: [string, string], currentValue: [string, string], currentIndex: number, array: [string, string][]) => [string, string]): [string, string]; + reduceRight(callbackfn: (previousValue: [string, string], currentValue: [string, string], currentIndex: number, array: [string, string][]) => [string, string], initialValue: [string, string]): [string, string]; + reduceRight(callbackfn: (previousValue: U_2, currentValue: [string, string], currentIndex: number, array: [string, string][]) => U_2, initialValue: U_2): U_2; + find(predicate: (value: [string, string], index: number, obj: [string, string][]) => value is S_2, thisArg?: any): S_2 | undefined; + find(predicate: (value: [string, string], index: number, obj: [string, string][]) => unknown, thisArg?: any): [string, string] | undefined; + findIndex(predicate: (value: [string, string], index: number, obj: [string, string][]) => unknown, thisArg?: any): number; + fill(value: [string, string], start?: number | undefined, end?: number | undefined): [string, string][]; + copyWithin(target: number, start: number, end?: number | undefined): [string, string][]; + entries(): IterableIterator<[number, [string, string]]>; + keys(): IterableIterator; + values(): IterableIterator<[string, string]>; + includes(searchElement: [string, string], fromIndex?: number | undefined): boolean; + flatMap(callback: (this: This, value: [string, string], index: number, array: [string, string][]) => U_3 | readonly U_3[], thisArg?: This | undefined): U_3[]; + flat(this: A, depth?: D | undefined): FlatArray[]; + [Symbol.iterator](): IterableIterator<[string, string]>; + [Symbol.unscopables]: { + [x: number]: boolean | undefined; + length?: boolean | undefined; + toString?: boolean | undefined; + toLocaleString?: boolean | undefined; + pop?: boolean | undefined; + push?: boolean | undefined; + concat?: boolean | undefined; + join?: boolean | undefined; + reverse?: boolean | undefined; + shift?: boolean | undefined; + slice?: boolean | undefined; + sort?: boolean | undefined; + splice?: boolean | undefined; + unshift?: boolean | undefined; + indexOf?: boolean | undefined; + lastIndexOf?: boolean | undefined; + every?: boolean | undefined; + some?: boolean | undefined; + forEach?: boolean | undefined; + map?: boolean | undefined; + filter?: boolean | undefined; + reduce?: boolean | undefined; + reduceRight?: boolean | undefined; + find?: boolean | undefined; + findIndex?: boolean | undefined; + fill?: boolean | undefined; + copyWithin?: boolean | undefined; + entries?: boolean | undefined; + keys?: boolean | undefined; + values?: boolean | undefined; + includes?: boolean | undefined; + flatMap?: boolean | undefined; + flat?: boolean | undefined; + [Symbol.iterator]?: boolean | undefined; + readonly [Symbol.unscopables]?: boolean | undefined; + at?: boolean | undefined; + }; + at(index: number): [string, string] | undefined; + 'Content-Type': string; + } | { + 'Content-Type': string; + } | { + append(name: string, value: string): void; + delete(name: string): void; + get(name: string): string | null; + getSetCookie(): string[]; + has(name: string): boolean; + set(name: string, value: string): void; + forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void; + 'Content-Type': string; + }; + method: string; + body: string; + cache?: RequestCache | undefined; + credentials?: RequestCredentials | undefined; + integrity?: string | undefined; + keepalive?: boolean | undefined; + mode?: RequestMode | undefined; + priority?: RequestPriority | undefined; + redirect?: RequestRedirect | undefined; + referrer?: string | undefined; + referrerPolicy?: ReferrerPolicy | undefined; + signal?: AbortSignal | null | undefined; + window?: null | undefined; +}; // (No @packageDocumentation comment for this package) diff --git a/packages/libs/chainweb-node-client/src/listen.ts b/packages/libs/chainweb-node-client/src/listen.ts index 3aa3912b20..35d53ac48a 100644 --- a/packages/libs/chainweb-node-client/src/listen.ts +++ b/packages/libs/chainweb-node-client/src/listen.ts @@ -1,4 +1,5 @@ import type { ICommandResult, IListenRequestBody } from './interfaces/PactAPI'; +import type { ClientRequestInit } from './local'; import { parseResponse } from './parseResponse'; import { stringifyAndMakePOSTRequest } from './stringifyAndMakePOSTRequest'; import { fetch } from './utils/fetch'; @@ -13,8 +14,9 @@ import { fetch } from './utils/fetch'; export async function listen( requestBody: IListenRequestBody, apiHost: string, + requestInit?: ClientRequestInit, ): Promise { - const request = stringifyAndMakePOSTRequest(requestBody); + const request = stringifyAndMakePOSTRequest(requestBody, requestInit); const listenUrl = new URL(`${apiHost}/api/v1/listen`); const response = await fetch(listenUrl.toString(), request); diff --git a/packages/libs/chainweb-node-client/src/local.ts b/packages/libs/chainweb-node-client/src/local.ts index ec1295baa1..6ca7a72789 100644 --- a/packages/libs/chainweb-node-client/src/local.ts +++ b/packages/libs/chainweb-node-client/src/local.ts @@ -13,7 +13,12 @@ import { fetch } from './utils/fetch'; /** * @alpha */ -export interface ILocalOptions { +export type ClientRequestInit = Omit; + +/** + * @alpha + */ +export interface ILocalOptions extends ClientRequestInit { preflight?: boolean; signatureVerification?: boolean; } @@ -41,7 +46,11 @@ export async function local( apiHost: string, options?: T, ): Promise> { - const { signatureVerification = true, preflight = true } = options ?? {}; + const { + signatureVerification = true, + preflight = true, + ...requestInit + } = options ?? {}; if (!signatureVerification) { requestBody = convertIUnsignedTransactionToNoSig(requestBody); @@ -51,6 +60,7 @@ export async function local( const result = await localRaw(body, apiHost, { preflight, signatureVerification, + ...requestInit, }); return parsePreflight(result); @@ -72,9 +82,13 @@ export async function localRaw( { preflight, signatureVerification, - }: { signatureVerification: boolean; preflight: boolean }, + ...requestInit + }: ILocalOptions & { + signatureVerification: boolean; + preflight: boolean; + }, ): Promise { - const request = stringifyAndMakePOSTRequest(requestBody); + const request = stringifyAndMakePOSTRequest(requestBody, requestInit); const localUrlWithQueries = new URL(`${apiHost}/api/v1/local`); localUrlWithQueries.searchParams.append('preflight', preflight.toString()); diff --git a/packages/libs/chainweb-node-client/src/poll.ts b/packages/libs/chainweb-node-client/src/poll.ts index 072925c853..a22662a552 100644 --- a/packages/libs/chainweb-node-client/src/poll.ts +++ b/packages/libs/chainweb-node-client/src/poll.ts @@ -1,4 +1,5 @@ import type { IPollRequestBody, IPollResponse } from './interfaces/PactAPI'; +import type { ClientRequestInit } from './local'; import { parseResponse } from './parseResponse'; import { stringifyAndMakePOSTRequest } from './stringifyAndMakePOSTRequest'; import { fetch } from './utils/fetch'; @@ -18,8 +19,9 @@ export async function poll( requestBody: IPollRequestBody, apiHost: string, confirmationDepth = 0, + requestInit?: ClientRequestInit, ): Promise { - const request = stringifyAndMakePOSTRequest(requestBody); + const request = stringifyAndMakePOSTRequest(requestBody, requestInit); const pollUrl = new URL(`${apiHost}/api/v1/poll`); if (confirmationDepth > 0) { pollUrl.searchParams.append( diff --git a/packages/libs/chainweb-node-client/src/send.ts b/packages/libs/chainweb-node-client/src/send.ts index 5442ec9f0e..4d24e2844a 100644 --- a/packages/libs/chainweb-node-client/src/send.ts +++ b/packages/libs/chainweb-node-client/src/send.ts @@ -1,4 +1,5 @@ import type { ISendRequestBody, SendResponse } from './interfaces/PactAPI'; +import type { ClientRequestInit } from './local'; import { parseResponse } from './parseResponse'; import { stringifyAndMakePOSTRequest } from './stringifyAndMakePOSTRequest'; import { fetch } from './utils/fetch'; @@ -16,8 +17,9 @@ import { fetch } from './utils/fetch'; export async function send( requestBody: ISendRequestBody, apiHost: string, + requestInit?: ClientRequestInit, ): Promise { - const request = stringifyAndMakePOSTRequest(requestBody); + const request = stringifyAndMakePOSTRequest(requestBody, requestInit); const sendUrl = new URL(`${apiHost}/api/v1/send`); const response = await fetch(sendUrl.toString(), request); diff --git a/packages/libs/chainweb-node-client/src/spv.ts b/packages/libs/chainweb-node-client/src/spv.ts index 10a88aa449..c469aa648c 100644 --- a/packages/libs/chainweb-node-client/src/spv.ts +++ b/packages/libs/chainweb-node-client/src/spv.ts @@ -1,4 +1,5 @@ import type { ISPVRequestBody, SPVResponse } from './interfaces/PactAPI'; +import type { ClientRequestInit } from './local'; import { parseResponseTEXT } from './parseResponseTEXT'; import { stringifyAndMakePOSTRequest } from './stringifyAndMakePOSTRequest'; import { fetch } from './utils/fetch'; @@ -14,8 +15,9 @@ import { fetch } from './utils/fetch'; export async function spv( requestBody: ISPVRequestBody, apiHost: string, + requestInit?: ClientRequestInit, ): Promise { - const request = stringifyAndMakePOSTRequest(requestBody); + const request = stringifyAndMakePOSTRequest(requestBody, requestInit); const spvUrl = new URL(`${apiHost}/spv`); const response = await fetch(spvUrl.toString(), request); diff --git a/packages/libs/chainweb-node-client/src/stringifyAndMakePOSTRequest.ts b/packages/libs/chainweb-node-client/src/stringifyAndMakePOSTRequest.ts index 1d8554d837..0bbb6b46d7 100644 --- a/packages/libs/chainweb-node-client/src/stringifyAndMakePOSTRequest.ts +++ b/packages/libs/chainweb-node-client/src/stringifyAndMakePOSTRequest.ts @@ -1,3 +1,5 @@ +import type { ClientRequestInit } from './local'; + /** * Formats API request body to use with `fetch` function. * @@ -5,10 +7,15 @@ * https://github.com/kadena-io/pact-lang-api/blob/master/pact-lang-api.js#L533 * @alpha */ -export function stringifyAndMakePOSTRequest(body: T): object { +export function stringifyAndMakePOSTRequest( + body: T, + requestInit?: ClientRequestInit, +) { return { + ...requestInit, headers: { 'Content-Type': 'application/json', + ...requestInit?.headers, }, method: 'POST', body: JSON.stringify(body), diff --git a/packages/libs/chainweb-node-client/src/tests/stringifyAndMakePOSTRequest.test.ts b/packages/libs/chainweb-node-client/src/tests/stringifyAndMakePOSTRequest.test.ts index 10d1820422..7d6197437a 100644 --- a/packages/libs/chainweb-node-client/src/tests/stringifyAndMakePOSTRequest.test.ts +++ b/packages/libs/chainweb-node-client/src/tests/stringifyAndMakePOSTRequest.test.ts @@ -14,3 +14,18 @@ test('should stringify body and create POST request', () => { expect(expected).toEqual(actual); }); + +test('should stringify body and create POST request and add options', () => { + const body: object = { name: 'hello', val: "'world'" }; + const actual = stringifyAndMakePOSTRequest(body, { keepalive: true }); + const expected = { + headers: { + 'Content-Type': 'application/json', + }, + keepalive: true, + method: 'POST', + body: '{"name":"hello","val":"\'world\'"}', + }; + + expect(expected).toEqual(actual); +}); diff --git a/packages/libs/client-utils/etc/client-utils-core.api.md b/packages/libs/client-utils/etc/client-utils-core.api.md index 56a2bd5a52..9dee1106ca 100644 --- a/packages/libs/client-utils/etc/client-utils-core.api.md +++ b/packages/libs/client-utils/etc/client-utils-core.api.md @@ -44,7 +44,9 @@ export const crossChainClient: (args_0: IClientConfig, client?: I pactId: string; step: number; proof: string; - rollback: boolean; + rollback: boolean; /** + * @alpha + */ data: {}; }; }, { @@ -78,7 +80,9 @@ export const crossChainClient: (args_0: IClientConfig, client?: I pactId: string; step: number; proof: string; - rollback: boolean; + rollback: boolean; /** + * @alpha + */ data: {}; }; }, { @@ -111,7 +115,9 @@ export const crossChainClient: (args_0: IClientConfig, client?: I pactId: string; step: number; proof: string; - rollback: boolean; + rollback: boolean; /** + * @alpha + */ data: {}; }; }, { @@ -144,7 +150,9 @@ export const crossChainClient: (args_0: IClientConfig, client?: I pactId: string; step: number; proof: string; - rollback: boolean; + rollback: boolean; /** + * @alpha + */ data: {}; }; }, { @@ -177,7 +185,9 @@ export const crossChainClient: (args_0: IClientConfig, client?: I pactId: string; step: number; proof: string; - rollback: boolean; + rollback: boolean; /** + * @alpha + */ data: {}; }; }, { @@ -196,7 +206,9 @@ export const crossChainClient: (args_0: IClientConfig, client?: I pactId: string; step: number; proof: string; - rollback: boolean; + rollback: boolean; /** + * @alpha + */ data: {}; }) => IEmitterWrapper<[{ event: "sign"; @@ -216,7 +228,9 @@ export const crossChainClient: (args_0: IClientConfig, client?: I pactId: string; step: number; proof: string; - rollback: boolean; + rollback: boolean; /** + * @alpha + */ data: {}; }; }, { @@ -249,7 +263,9 @@ export const crossChainClient: (args_0: IClientConfig, client?: I pactId: string; step: number; proof: string; - rollback: boolean; + rollback: boolean; /** + * @alpha + */ data: {}; }; }, { @@ -282,7 +298,9 @@ export const crossChainClient: (args_0: IClientConfig, client?: I pactId: string; step: number; proof: string; - rollback: boolean; + rollback: boolean; /** + * @alpha + */ data: {}; }; }, { @@ -315,7 +333,9 @@ export const crossChainClient: (args_0: IClientConfig, client?: I pactId: string; step: number; proof: string; - rollback: boolean; + rollback: boolean; /** + * @alpha + */ data: {}; }; }, { @@ -348,7 +368,9 @@ export const crossChainClient: (args_0: IClientConfig, client?: I pactId: string; step: number; proof: string; - rollback: boolean; + rollback: boolean; /** + * @alpha + */ data: {}; }; }, { diff --git a/packages/libs/client-utils/src/core/cross-chain.ts b/packages/libs/client-utils/src/core/cross-chain.ts index d0a3d795ba..0ff2811123 100644 --- a/packages/libs/client-utils/src/core/cross-chain.ts +++ b/packages/libs/client-utils/src/core/cross-chain.ts @@ -28,7 +28,11 @@ import { } from './utils/helpers'; const requestSpvProof = - (targetChainId: ChainId, client: IClient, onPoll: (id: string) => void) => + ( + targetChainId: ChainId, + client: IClient, + onPoll: (id: string | undefined, error: any) => void, + ) => ([txDesc, txResult]: [ITransactionDescriptor, ICommandResult]) => { return client .pollCreateSpv(txDesc, targetChainId, { diff --git a/packages/libs/client/etc/client.api.md b/packages/libs/client/etc/client.api.md index a22882baef..218d421f9b 100644 --- a/packages/libs/client/etc/client.api.md +++ b/packages/libs/client/etc/client.api.md @@ -6,6 +6,7 @@ import { ChainId } from '@kadena/types'; import type Client from '@walletconnect/sign-client'; +import { ClientRequestInit } from '@kadena/chainweb-node-client'; import { ICap } from '@kadena/types'; import { ICommand } from '@kadena/types'; import { ICommandResult } from '@kadena/chainweb-node-client'; @@ -33,6 +34,8 @@ export type BuiltInPredicate = 'keys-all' | 'keys-any' | 'keys-2'; export { ChainId } +export { ClientRequestInit } + // @public export const createClient: ICreateClient; @@ -82,9 +85,9 @@ export const getHostUrl: (hostBaseUrl: string) => ({ networkId, chainId }: INetw // @public (undocumented) export interface IBaseClient { - createSpv: (transactionDescriptor: ITransactionDescriptor, targetChainId: ChainId) => Promise; - getStatus: (transactionDescriptors: ITransactionDescriptor[] | ITransactionDescriptor) => Promise; - listen: (transactionDescriptor: ITransactionDescriptor) => Promise; + createSpv: (transactionDescriptor: ITransactionDescriptor, targetChainId: ChainId, options?: ClientRequestInit) => Promise; + getStatus: (transactionDescriptors: ITransactionDescriptor[] | ITransactionDescriptor, options?: ClientRequestInit) => Promise; + listen: (transactionDescriptor: ITransactionDescriptor, options?: ClientRequestInit) => Promise; local: (transaction: LocalRequestBody, options?: T) => Promise>; pollCreateSpv: (transactionDescriptor: ITransactionDescriptor, targetChainId: ChainId, options?: IPollOptions) => Promise; pollStatus: (transactionDescriptors: ITransactionDescriptor[] | ITransactionDescriptor, options?: IPollOptions) => IPollRequestPromise; @@ -118,16 +121,16 @@ export type ICapabilityItem = ICap; // @public export interface IClient extends IBaseClient { - dirtyRead: (transaction: IUnsignedCommand) => Promise; + dirtyRead: (transaction: IUnsignedCommand, options?: ClientRequestInit) => Promise; // @deprecated - getPoll: (transactionDescriptors: ITransactionDescriptor[] | ITransactionDescriptor) => Promise; + getPoll: (transactionDescriptors: ITransactionDescriptor[] | ITransactionDescriptor, options?: ClientRequestInit) => Promise; pollOne: (transactionDescriptor: ITransactionDescriptor, options?: IPollOptions) => Promise; - preflight: (transaction: ICommand | IUnsignedCommand) => Promise; - runPact: (code: string, data: Record, option: INetworkOptions) => Promise; + preflight: (transaction: ICommand | IUnsignedCommand, options?: ClientRequestInit) => Promise; + runPact: (code: string, data: Record, option: ClientRequestInit & INetworkOptions) => Promise; // @deprecated send: ISubmit; - signatureVerification: (transaction: ICommand) => Promise; - submitOne: (transaction: ICommand) => Promise; + signatureVerification: (transaction: ICommand, options?: ClientRequestInit) => Promise; + submitOne: (transaction: ICommand, options?: ClientRequestInit) => Promise; } export { ICommand } @@ -166,7 +169,11 @@ export interface ICreateClient { (hostAddressGenerator?: (options: { chainId: ChainId; networkId: string; - }) => string, defaults?: { + type?: 'local' | 'send' | 'poll' | 'listen' | 'spv'; + }) => string | { + hostUrl: string; + requestInit: ClientRequestInit; + }, defaults?: { confirmationDepth?: number; }): IClient; } @@ -277,7 +284,7 @@ export interface IPartialPactCommand extends AllPartial { } // @public -export interface IPollOptions { +export interface IPollOptions extends ClientRequestInit { // (undocumented) confirmationDepth?: number; // Warning: (ae-incompatible-release-tags) The symbol "interval" is marked as @public, but its signature references "Milliseconds" which is marked as @alpha @@ -285,7 +292,9 @@ export interface IPollOptions { // (undocumented) interval?: Milliseconds; // (undocumented) - onPoll?: (id: string) => void; + onPoll?: (id: string | undefined, error: any) => void; + // (undocumented) + onResult?: (requestKey: string, result: ICommandResult) => void; // Warning: (ae-incompatible-release-tags) The symbol "timeout" is marked as @public, but its signature references "Milliseconds" which is marked as @alpha // // (undocumented) @@ -435,8 +444,8 @@ export function isSignedTransaction(command: IUnsignedCommand | ICommand): comma // @public (undocumented) export interface ISubmit { - (transaction: ICommand): Promise; - (transactionList: ICommand[]): Promise; + (transaction: ICommand, options?: ClientRequestInit): Promise; + (transactionList: ICommand[], options?: ClientRequestInit): Promise; } // @public (undocumented) diff --git a/packages/libs/client/src/client/api/runPact.ts b/packages/libs/client/src/client/api/runPact.ts index a4714913f4..2ce8bcef5e 100644 --- a/packages/libs/client/src/client/api/runPact.ts +++ b/packages/libs/client/src/client/api/runPact.ts @@ -1,4 +1,7 @@ -import type { ICommandResult } from '@kadena/chainweb-node-client'; +import type { + ClientRequestInit, + ICommandResult, +} from '@kadena/chainweb-node-client'; import { local } from '@kadena/chainweb-node-client'; import { hash as blackHash } from '@kadena/cryptography-utils'; import { composePactCommand, execution } from '../../composePactCommand'; @@ -7,6 +10,7 @@ export function runPact( hostUrl: string, code: string, data: Record = {}, + requestInit?: ClientRequestInit, ): Promise { const pactCommand = composePactCommand(execution(code), { payload: { exec: { data } }, @@ -23,6 +27,7 @@ export function runPact( { preflight: false, signatureVerification: false, + ...requestInit, }, ); } diff --git a/packages/libs/client/src/client/api/spv.ts b/packages/libs/client/src/client/api/spv.ts index d64114d72b..ad313afa52 100644 --- a/packages/libs/client/src/client/api/spv.ts +++ b/packages/libs/client/src/client/api/spv.ts @@ -1,4 +1,7 @@ -import type { SPVResponse } from '@kadena/chainweb-node-client'; +import type { + ClientRequestInit, + SPVResponse, +} from '@kadena/chainweb-node-client'; import { spv } from '@kadena/chainweb-node-client'; import type { ChainId } from '@kadena/types'; import type { IPollOptions } from '../interfaces/interfaces'; @@ -8,8 +11,9 @@ export async function getSpv( host: string, requestKey: string, targetChainId: ChainId, + requestInit: ClientRequestInit = {}, ): Promise { - const proof = await spv({ requestKey, targetChainId }, host); + const proof = await spv({ requestKey, targetChainId }, host, requestInit); if (typeof proof !== 'string') throw new Error('PROOF_IS_NOT_AVAILABLE'); return proof; } @@ -21,7 +25,7 @@ export const pollSpv = ( pollingOptions?: IPollOptions, ): Promise => { const task = async (): Promise => - getSpv(host, requestKey, targetChainId); + getSpv(host, requestKey, targetChainId, pollingOptions); const retrySpv = retry(task); diff --git a/packages/libs/client/src/client/api/status.ts b/packages/libs/client/src/client/api/status.ts index ae887b5ea1..ec8d044c84 100644 --- a/packages/libs/client/src/client/api/status.ts +++ b/packages/libs/client/src/client/api/status.ts @@ -29,7 +29,10 @@ export const pollStatus: IPollStatus = ( timeout, interval, confirmationDepth = 0, + onResult = () => {}, + ...requestInit } = options ?? {}; + const signal = requestInit.signal ?? undefined; let requestKeys = [...requestIds]; const prs: Record> = requestKeys.reduce( (acc, requestKey) => ({ @@ -39,17 +42,28 @@ export const pollStatus: IPollStatus = ( {}, ); const task = async (): Promise => { - requestKeys.forEach(onPoll); - const pollResponse = await poll({ requestKeys }, host, confirmationDepth); - Object.values(pollResponse).forEach((item) => { - prs[item.reqKey].resolve(item); - requestKeys = requestKeys.filter((key) => key !== item.reqKey); - }); + try { + requestKeys.forEach(onPoll); + const pollResponse = await poll( + { requestKeys }, + host, + confirmationDepth, + requestInit, + ); + Object.values(pollResponse).forEach((item) => { + prs[item.reqKey].resolve(item); + onResult(item.reqKey, item); + requestKeys = requestKeys.filter((key) => key !== item.reqKey); + }); + } catch (error) { + onPoll(undefined, error); + throw error; + } if (requestKeys.length > 0) { return Promise.reject(new Error('NOT_COMPLETED')); } }; - const retryStatus = retry(task); + const retryStatus = retry(task, signal); retryStatus({ interval, timeout }).catch((err) => { Object.values(prs).forEach((pr) => { diff --git a/packages/libs/client/src/client/api/tests/status.test.ts b/packages/libs/client/src/client/api/tests/status.test.ts index 90018721f4..e6404b045b 100644 --- a/packages/libs/client/src/client/api/tests/status.test.ts +++ b/packages/libs/client/src/client/api/tests/status.test.ts @@ -18,7 +18,7 @@ afterAll(() => server.close()); const post = ( path: string, - response: string | Record, + response: string | Record | Response, status = 200, wait?: number, ): ReturnType => @@ -143,4 +143,48 @@ describe('pollStatus', () => { 'key-2': { reqKey: 'key-2' }, }); }); + + it('calls onResult call back after each request key is fetched', async () => { + const responses = [ + {}, + { 'key-1': { reqKey: 'key-1' } }, + {}, + { 'key-2': { reqKey: 'key-2' } }, + ]; + + server.resetHandlers( + post('http://test-blockchain-host.com/api/v1/poll', responses[0]), + post('http://test-blockchain-host.com/api/v1/poll', responses[1]), + post('http://test-blockchain-host.com/api/v1/poll', responses[2]), + post('http://test-blockchain-host.com/api/v1/poll', responses[3]), + ); + + const hostUrl = 'http://test-blockchain-host.com'; + + const requestKeys = ['key-1', 'key-2']; + + const onResult = vi.fn(); + + await pollStatus(hostUrl, requestKeys, { interval: 10, onResult }); + expect(onResult).toBeCalledTimes(2); + expect(onResult.mock.calls[0]).toEqual(['key-1', { reqKey: 'key-1' }]); + expect(onResult.mock.calls[1]).toEqual(['key-2', { reqKey: 'key-2' }]); + }); + it('calls onPoll call back with error if the request fails', async () => { + server.resetHandlers( + post('http://test-blockchain-host.com/api/v1/poll', {}), + ); + + const onPoll = vi.fn(); + + const hostUrl = 'http://test-blockchain-host.com'; + + const requestKeys = ['key-1', 'key-2']; + + await expect( + pollStatus(hostUrl, requestKeys, { interval: 10, timeout: 20, onPoll }), + ).rejects.toEqual(new Error('TIME_OUT_REJECT')); + + expect(onPoll.mock.calls.at(-1)[1] instanceof Error).toBe(true); + }); }); diff --git a/packages/libs/client/src/client/client.ts b/packages/libs/client/src/client/client.ts index ec28cda5cb..4f180fe8b7 100644 --- a/packages/libs/client/src/client/client.ts +++ b/packages/libs/client/src/client/client.ts @@ -1,4 +1,5 @@ import type { + ClientRequestInit, ICommandResult, ILocalCommandResult, ILocalOptions, @@ -17,6 +18,7 @@ import type { IPollOptions, IPollRequestPromise, } from './interfaces/interfaces'; +import { mergeOptions } from './utils/mergeOptions'; import { groupByHost, kadenaHostGenerator, @@ -49,7 +51,10 @@ export interface ISubmit { * @param transaction - The transaction to be submitted. * @returns A promise that resolves the transactionDescriptor {@link ITransactionDescriptor} */ - (transaction: ICommand): Promise; + ( + transaction: ICommand, + options?: ClientRequestInit, + ): Promise; /** * Submits one or more public (unencrypted) signed commands to the blockchain for execution. @@ -60,7 +65,10 @@ export interface ISubmit { * @param transactionList - The list of transactions to be submitted. * @returns A promise that resolves the transactionDescriptor {@link ITransactionDescriptor} */ - (transactionList: ICommand[]): Promise; + ( + transactionList: ICommand[], + options?: ClientRequestInit, + ): Promise; } /** @@ -118,6 +126,7 @@ export interface IBaseClient { */ getStatus: ( transactionDescriptors: ITransactionDescriptor[] | ITransactionDescriptor, + options?: ClientRequestInit, ) => Promise; /** @@ -130,6 +139,7 @@ export interface IBaseClient { */ listen: ( transactionDescriptor: ITransactionDescriptor, + options?: ClientRequestInit, ) => Promise; /** @@ -160,6 +170,7 @@ export interface IBaseClient { createSpv: ( transactionDescriptor: ITransactionDescriptor, targetChainId: ChainId, + options?: ClientRequestInit, ) => Promise; } @@ -174,6 +185,7 @@ export interface IClient extends IBaseClient { */ preflight: ( transaction: ICommand | IUnsignedCommand, + options?: ClientRequestInit, ) => Promise; /** @@ -182,7 +194,10 @@ export interface IClient extends IBaseClient { * @remarks * @see {@link IBaseClient.local | local() function} */ - signatureVerification: (transaction: ICommand) => Promise; + signatureVerification: ( + transaction: ICommand, + options?: ClientRequestInit, + ) => Promise; /** * An alias for `local` when both preflight and signatureVerification are `false`. @@ -191,7 +206,10 @@ export interface IClient extends IBaseClient { * @remarks * @see {@link IBaseClient.local | local() function} */ - dirtyRead: (transaction: IUnsignedCommand) => Promise; + dirtyRead: ( + transaction: IUnsignedCommand, + options?: ClientRequestInit, + ) => Promise; /** * Generates a command from the code and data, then sends it to the '/local' endpoint. @@ -201,7 +219,7 @@ export interface IClient extends IBaseClient { runPact: ( code: string, data: Record, - option: INetworkOptions, + option: ClientRequestInit & INetworkOptions, ) => Promise; /** @@ -216,7 +234,10 @@ export interface IClient extends IBaseClient { * Alias for `submit` that accepts only one transaction. useful when you want more precise type checking. * {@link IBaseClient.submit | submit() function} */ - submitOne: (transaction: ICommand) => Promise; + submitOne: ( + transaction: ICommand, + options?: ClientRequestInit, + ) => Promise; /** * Use {@link IBaseClient.getStatus | getStatus() function} @@ -226,6 +247,7 @@ export interface IClient extends IBaseClient { */ getPoll: ( transactionDescriptors: ITransactionDescriptor[] | ITransactionDescriptor, + options?: ClientRequestInit, ) => Promise; /** @@ -267,11 +289,22 @@ export interface ICreateClient { hostAddressGenerator?: (options: { chainId: ChainId; networkId: string; - }) => string, + type?: 'local' | 'send' | 'poll' | 'listen' | 'spv'; + }) => string | { hostUrl: string; requestInit: ClientRequestInit }, defaults?: { confirmationDepth?: number }, ): IClient; } +const getHostData = ( + hostObject: string | { hostUrl: string; requestInit: ClientRequestInit }, +) => { + const hostUrl = + typeof hostObject === 'string' ? hostObject : hostObject.hostUrl; + const requestInit = + typeof hostObject === 'object' ? hostObject.requestInit : {}; + return { hostUrl, requestInit }; +}; + /** * Creates Chainweb client * @public @@ -286,13 +319,14 @@ export const createClient: ICreateClient = ( const client: IBaseClient = { local(body, options) { const cmd: IPactCommand = JSON.parse(body.cmd); - const hostUrl = getHost({ + const hostObject = getHost({ chainId: cmd.meta.chainId, networkId: cmd.networkId, }); - return local(body, hostUrl, options); + const { hostUrl, requestInit } = getHostData(hostObject); + return local(body, hostUrl, mergeOptions(requestInit, options)); }, - submit: (async (body) => { + submit: (async (body, options) => { const isList = Array.isArray(body); const commands = isList ? body : [body]; const [first] = commands; @@ -300,11 +334,18 @@ export const createClient: ICreateClient = ( throw new Error('EMPTY_COMMAND_LIST'); } const cmd: IPactCommand = JSON.parse(first.cmd); - const hostUrl = getHost({ + const hostObject = getHost({ chainId: cmd.meta.chainId, networkId: cmd.networkId, }); - const { requestKeys } = await send({ cmds: commands }, hostUrl); + + const { hostUrl, requestInit } = getHostData(hostObject); + + const { requestKeys } = await send( + { cmds: commands }, + hostUrl, + mergeOptions(requestInit, options), + ); const transactionDescriptors = requestKeys.map((key) => ({ requestKey: key, @@ -322,31 +363,58 @@ export const createClient: ICreateClient = ( ? transactionDescriptors : [transactionDescriptors]; const results = groupByHost( - requestsList.map(({ requestKey, chainId, networkId }) => ({ - requestKey, - hostUrl: getHost({ chainId, networkId }), - })), - ).map(([hostUrl, requestKeys]) => - pollStatus(hostUrl, requestKeys, { confirmationDepth, ...options }), - ); + requestsList.map(({ requestKey, chainId, networkId }) => { + const hostObject = getHost({ chainId, networkId, type: 'poll' }); + const { hostUrl, requestInit } = getHostData(hostObject); + return { + requestKey, + host: hostUrl, + requestInit, + }; + }), + ).map(([host, requestKeys]) => { + const requestInit = requestKeys[0].requestInit; + return pollStatus( + host, + requestKeys.map((r) => r.requestKey), + { + confirmationDepth, + ...mergeOptions(requestInit, options), + }, + ); + }); // merge all of the result in one object const mergedPollRequestPromises = mergeAllPollRequestPromises(results); return mergedPollRequestPromises; }, - async getStatus(transactionDescriptors) { + async getStatus(transactionDescriptors, options?: ClientRequestInit) { const requestsList = Array.isArray(transactionDescriptors) ? transactionDescriptors : [transactionDescriptors]; const results = await Promise.all( groupByHost( - requestsList.map(({ requestKey, chainId, networkId }) => ({ - requestKey, - hostUrl: getHost({ chainId, networkId }), - })), - ).map(([hostUrl, requestKeys]) => poll({ requestKeys }, hostUrl)), + requestsList.map(({ requestKey, chainId, networkId }) => { + const hostObject = getHost({ chainId, networkId, type: 'poll' }); + const { hostUrl, requestInit } = getHostData(hostObject); + return { + requestKey, + host: hostUrl, + requestInit, + }; + }), + ).map(([hostUrl, requestKeys]) => { + const requestInit = requestKeys[0].requestInit; + + return poll( + { requestKeys: requestKeys.map((r) => r.requestKey) }, + hostUrl, + undefined, + mergeOptions(requestInit, options), + ); + }), ); // merge all of the result in one object @@ -355,50 +423,75 @@ export const createClient: ICreateClient = ( return mergedResults; }, - async listen({ requestKey, chainId, networkId }) { - const hostUrl = getHost({ chainId, networkId }); - - const result = await listen({ listen: requestKey }, hostUrl); + async listen({ requestKey, chainId, networkId }, options) { + const hostObject = getHost({ chainId, networkId, type: 'listen' }); + const { hostUrl, requestInit } = getHostData(hostObject); + const result = await listen( + { listen: requestKey }, + hostUrl, + mergeOptions(requestInit, options), + ); return result; }, pollCreateSpv({ requestKey, chainId, networkId }, targetChainId, options) { - const hostUrl = getHost({ chainId, networkId }); - return pollSpv(hostUrl, requestKey, targetChainId, options); + const hostObject = getHost({ chainId, networkId, type: 'spv' }); + const { hostUrl, requestInit } = getHostData(hostObject); + return pollSpv( + hostUrl, + requestKey, + targetChainId, + mergeOptions(requestInit, options), + ); }, - async createSpv({ requestKey, chainId, networkId }, targetChainId) { - const hostUrl = getHost({ chainId, networkId }); - return getSpv(hostUrl, requestKey, targetChainId); + async createSpv( + { requestKey, chainId, networkId }, + targetChainId, + options, + ) { + const hostObject = getHost({ chainId, networkId, type: 'spv' }); + const { hostUrl, requestInit } = getHostData(hostObject); + return getSpv( + hostUrl, + requestKey, + targetChainId, + mergeOptions(requestInit, options), + ); }, }; return { ...client, submitOne: client.submit, - preflight(body) { + preflight(body, options) { return client.local(body, { + ...options, preflight: true, signatureVerification: true, }); }, - signatureVerification(body) { + signatureVerification(body, options) { return client.local(body, { + ...options, preflight: false, signatureVerification: true, }); }, - dirtyRead(body) { + dirtyRead(body, options) { return client.local(body, { + ...options, preflight: false, signatureVerification: false, }); }, runPact: (code, data, options) => { - const hostUrl = getHost(options); + const hostObject = getHost(options); + const { hostUrl, requestInit } = getHostData(hostObject); if (hostUrl === '') throw new Error('NO_HOST_URL'); - return runPact(hostUrl, code, data); + + return runPact(hostUrl, code, data, mergeOptions(requestInit, options)); }, send: client.submit, getPoll: client.getStatus, diff --git a/packages/libs/client/src/client/interfaces/interfaces.ts b/packages/libs/client/src/client/interfaces/interfaces.ts index 590d91e6ee..9d7d070aba 100644 --- a/packages/libs/client/src/client/interfaces/interfaces.ts +++ b/packages/libs/client/src/client/interfaces/interfaces.ts @@ -1,3 +1,7 @@ +import type { + ClientRequestInit, + ICommandResult, +} from '@kadena/chainweb-node-client'; import type { ChainId } from '@kadena/types'; /** @@ -17,8 +21,9 @@ export type Milliseconds = number & { _brand?: 'milliseconds' }; * Options for any polling action on {@link IClient} * @public */ -export interface IPollOptions { - onPoll?: (id: string) => void; +export interface IPollOptions extends ClientRequestInit { + onPoll?: (id: string | undefined, error: any) => void; + onResult?: (requestKey: string, result: ICommandResult) => void; timeout?: Milliseconds; interval?: Milliseconds; confirmationDepth?: number; @@ -28,5 +33,8 @@ export interface IPollOptions { * @public */ export type IPollRequestPromise = Promise> & { + /** + * @deprecated pass callback to {@link IPollOptions.onResult} instead + */ requests: Record>; }; diff --git a/packages/libs/client/src/client/tests/client.test.ts b/packages/libs/client/src/client/tests/client.test.ts index e66dfa6173..1175522dbe 100644 --- a/packages/libs/client/src/client/tests/client.test.ts +++ b/packages/libs/client/src/client/tests/client.test.ts @@ -1,9 +1,26 @@ +import type * as ChainWebNodeClient from '@kadena/chainweb-node-client'; +import { local } from '@kadena/chainweb-node-client'; import type { ChainId } from '@kadena/types'; import { http, HttpResponse } from 'msw'; import { setupServer } from 'msw/node'; -import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'; +import { + afterAll, + afterEach, + beforeAll, + describe, + expect, + it, + vi, +} from 'vitest'; import { createClient } from '../client'; +// Hack to spy on exported function +vi.mock('@kadena/chainweb-node-client', async (importOriginal) => { + const mod: typeof ChainWebNodeClient = await importOriginal(); + const local = vi.fn().mockImplementation(mod.local); + return { ...mod, local }; +}); + const server = setupServer(); beforeAll(() => server.listen({ onUnhandledRequest: 'error' })); afterEach(() => server.resetHandlers()); @@ -139,10 +156,12 @@ describe('client', () => { describe('local', () => { it('uses the hostApiGenerator function to generate hostUrl for local request', async () => { + const expectedResponse = { + reqKey: 'test-key', + result: 'test-result', + }; server.resetHandlers( - post('http://example.org/mainnet01/1/api/v1/local', { - reqKey: 'test-key', - }), + post('http://example.org/mainnet01/1/api/v1/local', expectedResponse), ); const { local } = createClient(hostApiGenerator); @@ -156,7 +175,8 @@ describe('client', () => { sigs: [{ sig: 'test-sig' }], }; - await local(body); + const res = await local(body); + expect(res).toEqual(expectedResponse); }); }); @@ -289,6 +309,57 @@ describe('client', () => { expect(result).toEqual(response[2]); }); + + it('returns a list if input is list of requests', async () => { + const response = [ + // first /poll + {}, + // second /poll + {}, + // third /poll + { + 'test-key-1': { reqKey: 'test-key-1' }, + 'test-key-2': { reqKey: 'test-key-2' }, + }, + ]; + + server.resetHandlers( + post('http://example.org/mainnet01/1/api/v1/send', { + requestKeys: ['test-key-1', 'test-key-2'], + }), + post('http://example.org/mainnet01/1/api/v1/poll', response[0]), + post('http://example.org/mainnet01/1/api/v1/poll', response[1]), + post('http://example.org/mainnet01/1/api/v1/poll', response[2]), + ); + + const { submit, pollStatus } = createClient(hostApiGenerator); + + const networkId = 'mainnet01'; + const chainId = '1'; + + const body = [ + { + cmd: JSON.stringify({ networkId, meta: { chainId } }), + hash: 'hash', + sigs: [{ sig: 'test-sig' }], + }, + { + cmd: JSON.stringify({ networkId, meta: { chainId } }), + hash: 'hash', + sigs: [{ sig: 'test-sig' }], + }, + ]; + + const transactionDescriptor = await submit(body); + + expect(transactionDescriptor.length).toEqual(2); + + const result = await pollStatus(transactionDescriptor, { + interval: 10, + }); + + expect(result).toEqual(response[2]); + }); }); describe('getStatus', () => { @@ -310,6 +381,31 @@ describe('client', () => { expect(result).toEqual({}); }); + + it('calls /poll endpoint once to get the status of the list of requests ', async () => { + server.resetHandlers( + post( + 'https://api.testnet.chainweb.com/chainweb/0.0/testnet04/chain/0/pact/api/v1/poll', + { 'test-key-1': 'result1', 'test-key-2': 'result2' }, + ), + ); + + const { getStatus } = createClient(); + + const result = await getStatus([ + { + requestKey: 'test-key-1', + chainId: '0', + networkId: 'testnet04', + }, + { requestKey: 'test-key-2', chainId: '0', networkId: 'testnet04' }, + ]); + + expect(result).toEqual({ + 'test-key-1': 'result1', + 'test-key-2': 'result2', + }); + }); }); describe('listen', () => { @@ -381,4 +477,136 @@ describe('client', () => { expect(result).toEqual('proof'); }); }); + + describe('preflight', () => { + it('uses local request and add preflight=true and signatureVerification=true', async () => { + const expectedResponse = { + reqKey: 'test-key', + result: 'test-result', + }; + server.resetHandlers( + post( + 'http://example.org/mainnet01/1/api/v1/local?preflight=true&signatureVerification=true', + expectedResponse, + ), + ); + + const { preflight } = createClient(hostApiGenerator); + + const networkId = 'mainnet01'; + const chainId = '1'; + + const body = { + cmd: JSON.stringify({ networkId, meta: { chainId } }), + hash: 'hash', + sigs: [{ sig: 'test-sig' }], + }; + + expect(await preflight(body)).toEqual(expectedResponse); + }); + }); + describe('signatureVerification', () => { + it('uses local request and add preflight=false and signatureVerification=true', async () => { + const expectedResponse = { + reqKey: 'test-key', + result: 'test-result', + }; + server.resetHandlers( + post( + 'http://example.org/mainnet01/1/api/v1/local?preflight=false&signatureVerification=true', + expectedResponse, + ), + ); + + const { signatureVerification } = createClient(hostApiGenerator); + + const networkId = 'mainnet01'; + const chainId = '1'; + + const body = { + cmd: JSON.stringify({ networkId, meta: { chainId } }), + hash: 'hash', + sigs: [{ sig: 'test-sig' }], + }; + + expect(await signatureVerification(body)).toEqual(expectedResponse); + }); + }); + + describe('dirtyRead', () => { + it('uses local request and add preflight=false and signatureVerification=false', async () => { + const expectedResponse = { + reqKey: 'test-key', + result: 'test-result', + }; + server.resetHandlers( + post( + 'http://example.org/mainnet01/1/api/v1/local?preflight=false&signatureVerification=false', + expectedResponse, + ), + ); + + const { dirtyRead } = createClient(hostApiGenerator); + + const networkId = 'mainnet01'; + const chainId = '1'; + + const body = { + cmd: JSON.stringify({ networkId, meta: { chainId } }), + hash: 'hash', + sigs: [{ sig: 'test-sig' }], + }; + + expect(await dirtyRead(body)).toEqual(expectedResponse); + }); + }); + + describe('runPact', () => { + beforeAll(() => { + vi.useFakeTimers().setSystemTime(new Date('2023-07-31')); + }); + + afterAll(() => { + vi.useRealTimers(); + }); + + it('create a complete pact command from the input and send it to the chain', async () => { + const { runPact } = createClient(hostApiGenerator); + const mockResponse = {}; + + server.resetHandlers( + http.post( + 'http://example.org/mainnet01/1/api/v1/local?preflight=false&signatureVerification=false', + () => HttpResponse.json(mockResponse), + { once: true }, + ), + ); + + const result = await runPact( + '(+ 1 1)', + { testData: 'testData' }, + { + networkId: 'mainnet01', + chainId: '1', + }, + ); + + expect(result).toStrictEqual(mockResponse); + + expect(local).toBeCalledWith( + { + cmd: '{"payload":{"exec":{"code":"(+ 1 1)","data":{"testData":"testData"}}},"nonce":"kjs:nonce:1690761600000","signers":[]}', + hash: '4KHg5lsf4zxOXsaqbvNIJlVPKXDtuzi3xiSlRUnqBJQ', + sigs: [], + }, + 'http://example.org/mainnet01/1', + { + preflight: false, + signatureVerification: false, + chainId: '1', + networkId: 'mainnet01', + }, + ); + }); + }); }); diff --git a/packages/libs/client/src/client/utils/mergeOptions.ts b/packages/libs/client/src/client/utils/mergeOptions.ts new file mode 100644 index 0000000000..377e812f0a --- /dev/null +++ b/packages/libs/client/src/client/utils/mergeOptions.ts @@ -0,0 +1,33 @@ +export function mergeOptions | undefined>( + first: T, + second: T, +): T { + if (!first) return second; + if (!second) return first; + const merged: T = { ...second }; + Object.entries(first).forEach(([key, value]) => { + if (merged[key] === undefined) { + merged[key] = value; + return; + } + if (Array.isArray(merged[key])) { + merged[key] = [ + ...(Array.isArray(value) ? value : [value]), + ...(merged[key] as Array), + ]; + return; + } + if ( + value !== null && + typeof merged[key] === 'object' && + typeof value === 'object' + ) { + merged[key] = mergeOptions( + value as Record, + merged[key] as Record, + ); + return; + } + }); + return merged; +} diff --git a/packages/libs/client/src/client/utils/retry.ts b/packages/libs/client/src/client/utils/retry.ts index 7ea325f60e..d70c607394 100644 --- a/packages/libs/client/src/client/utils/retry.ts +++ b/packages/libs/client/src/client/utils/retry.ts @@ -20,16 +20,22 @@ const rejectAfter = ( export const retry = ( task: () => Promise, + signal?: AbortSignal, ) => async function runTask(options?: IPollOptions, count = 0): Promise { const startTime = Date.now(); const { timeout = 1000 * 60 * 3, interval = 5000 } = options ?? {}; - const rejectTimer = rejectAfter(timeout); try { const result = await Promise.race([ + new Promise((resolve, reject) => { + if (signal?.aborted === true) { + reject(new Error('ABORTED')); + } + signal?.addEventListener('abort', () => reject(new Error('ABORTED'))); + }), rejectTimer.promise, // sleep for 1ms to let the timeout promise reject first. sleep(1) @@ -41,7 +47,10 @@ export const retry = ( ]); return result as T; } catch (error) { - if (error !== undefined && error.message === 'TIME_OUT_REJECT') { + if ( + error !== undefined && + (error.message === 'TIME_OUT_REJECT' || error.message === 'ABORTED') + ) { throw error; } diff --git a/packages/libs/client/src/client/utils/tests/mergeOptions.test.ts b/packages/libs/client/src/client/utils/tests/mergeOptions.test.ts new file mode 100644 index 0000000000..4803c5433d --- /dev/null +++ b/packages/libs/client/src/client/utils/tests/mergeOptions.test.ts @@ -0,0 +1,42 @@ +import { describe, expect, it } from 'vitest'; +import { mergeOptions } from '../mergeOptions'; + +describe('mergeOptions', () => { + it('should merge options', () => { + const options: Record = { a: 1, b: 2 }; + const newOptions: Record = { b: 3, c: 4 }; + const mergedOptions = mergeOptions(options, newOptions); + expect(mergedOptions).toEqual({ a: 1, b: 3, c: 4 }); + }); + + it('should merge arrays', () => { + const options: Record = { a: 1, b: [2] }; + const newOptions: Record = { b: [3], c: 4 }; + const mergedOptions = mergeOptions(options, newOptions); + expect(mergedOptions).toEqual({ a: 1, b: [2, 3], c: 4 }); + }); + + it('should merge object sub properties', () => { + const options: Record = { a: 1, b: 2, c: { one: 'one' } }; + const newOptions: Record = { b: [3], c: { second: 'second' } }; + const mergedOptions = mergeOptions(options, newOptions); + expect(mergedOptions).toEqual({ + a: 1, + b: [2, 3], + c: { + one: 'one', + second: 'second', + }, + }); + }); + it('returns the second object if the first object is undefined', () => { + const options: Record = { a: 1, b: 2 }; + const mergedOptions = mergeOptions(undefined, options); + expect(mergedOptions).toEqual({ a: 1, b: 2 }); + }); + it('returns the first object if the second object is undefined', () => { + const options: Record = { a: 1, b: 2 }; + const mergedOptions = mergeOptions(options, undefined); + expect(mergedOptions).toEqual({ a: 1, b: 2 }); + }); +}); diff --git a/packages/libs/client/src/client/utils/tests/retry.test.ts b/packages/libs/client/src/client/utils/tests/retry.test.ts index b107ee9fee..3e7bd71271 100644 --- a/packages/libs/client/src/client/utils/tests/retry.test.ts +++ b/packages/libs/client/src/client/utils/tests/retry.test.ts @@ -41,4 +41,40 @@ describe('retry', () => { await expect(promise).rejects.toEqual(new Error('TIME_OUT_REJECT')); }); + + it('it should abort the process if abortSignal is called', async () => { + const abortController = new AbortController(); + const task = vi.fn( + withCounter((idx) => { + if (idx === 2) { + abortController.abort(); + return Promise.resolve(true); + } + return Promise.reject(new Error('its not ready')); + }), + ); + const runTask = retry(task, abortController.signal); + + const promise = runTask({ interval: 10, timeout: 200 }); + + await expect(promise).rejects.toEqual(new Error('ABORTED')); + }); + + it('it should abort the process if abortSignal is alredy aborted', async () => { + const abortController = new AbortController(); + abortController.abort(); + const task = vi.fn( + withCounter((idx) => { + if (idx === 2) { + return Promise.resolve(true); + } + return Promise.reject(new Error('its not ready')); + }), + ); + const runTask = retry(task, abortController.signal); + + const promise = runTask({ interval: 10, timeout: 200 }); + + await expect(promise).rejects.toEqual(new Error('ABORTED')); + }); }); diff --git a/packages/libs/client/src/client/utils/utils.ts b/packages/libs/client/src/client/utils/utils.ts index 2e538b5156..a5628e9680 100644 --- a/packages/libs/client/src/client/utils/utils.ts +++ b/packages/libs/client/src/client/utils/utils.ts @@ -1,3 +1,4 @@ +import type { ClientRequestInit } from '@kadena/chainweb-node-client'; import type { INetworkOptions, IPollRequestPromise, @@ -153,12 +154,19 @@ export const sleep = (duration: number): Promise => new Promise((resolve) => setTimeout(resolve, duration)); export const groupByHost = ( - items: Array<{ requestKey: string; hostUrl: string }>, -): [string, string[]][] => { - const byHost = new Map(); - items.forEach(({ hostUrl, requestKey }) => { + items: Array<{ + requestKey: string; + host: string; + requestInit?: ClientRequestInit; + }>, +): [string, { requestInit?: ClientRequestInit; requestKey: string }[]][] => { + const byHost = new Map< + string, + { requestInit?: ClientRequestInit; requestKey: string }[] + >(); + items.forEach(({ host: hostUrl, requestKey, requestInit }) => { const prev = byHost.get(hostUrl) ?? []; - byHost.set(hostUrl, [...prev, requestKey]); + byHost.set(hostUrl, [...prev, { requestInit, requestKey }]); }); return [...byHost.entries()]; }; diff --git a/packages/libs/client/src/index.ts b/packages/libs/client/src/index.ts index 2d7c77bdb4..35c17501ab 100644 --- a/packages/libs/client/src/index.ts +++ b/packages/libs/client/src/index.ts @@ -15,6 +15,7 @@ export type * from './interfaces/IPactCommand'; export type * from './interfaces/ISigningRequest'; export { + ClientRequestInit, ICommandResult, IPollResponse, IPreflightResult, diff --git a/packages/libs/client/vitest.config.ts b/packages/libs/client/vitest.config.ts index 1a34b67cb3..4a2bf64d7c 100644 --- a/packages/libs/client/vitest.config.ts +++ b/packages/libs/client/vitest.config.ts @@ -11,6 +11,7 @@ const localConfig = defineConfig({ 'src/interfaces/IPactCommand.ts', 'src/interfaces/ISigningRequest.ts', 'src/interfaces/type-utilities.ts', + 'src/signing/eckoWallet/eckoTypes.ts', ], provider: 'v8', thresholds: { From 73fc204c31d93f01902865bfd7bded6d69ffcabd Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 14:47:34 +0100 Subject: [PATCH 093/103] fix(wallet-sdk): set type to module --- packages/apps/wallet-sdk-example/vite.config.ts | 1 + packages/libs/wallet-sdk/package.json | 1 + .../src/sdk/tests/createSimpleTransfer.test.ts | 2 +- .../src/sdk/tests/crossChainFinishCreate.test.ts | 2 +- .../libs/wallet-sdk/src/sdk/tests/exchange.test.ts | 4 ++-- .../libs/wallet-sdk/src/sdk/tests/kadenanames.test.ts | 2 +- .../src/sdk/tests/mapTransferXchainEnd.test.ts | 4 ++-- .../src/sdk/tests/mapTransferXchainStart.test.ts | 4 ++-- .../src/sdk/tests/mapTransferXchainUnfinished.test.ts | 4 ++-- packages/libs/wallet-sdk/src/sdk/tests/poll.test.ts | 2 +- .../libs/wallet-sdk/src/services/chainweb/chainweb.ts | 8 ++++---- .../wallet-sdk/src/services/graphql/pollTransfers.ts | 10 +++++----- .../wallet-sdk/src/services/graphql/transfer.util.ts | 10 +++++----- .../libs/wallet-sdk/src/utils/tests/pact.util.test.ts | 2 +- .../wallet-sdk/src/utils/tests/string.util.test.ts | 2 +- .../libs/wallet-sdk/src/utils/tests/typeUtils.test.ts | 2 +- 16 files changed, 31 insertions(+), 29 deletions(-) diff --git a/packages/apps/wallet-sdk-example/vite.config.ts b/packages/apps/wallet-sdk-example/vite.config.ts index d30e1a69b9..b4c68c1cf9 100644 --- a/packages/apps/wallet-sdk-example/vite.config.ts +++ b/packages/apps/wallet-sdk-example/vite.config.ts @@ -25,6 +25,7 @@ const monorepoPackages = getMonorepoPackagesFromPackageJson(); monorepoPackages.push('@kadena/client-utils'); monorepoPackages.push('@kadena/cryptography-utils'); +monorepoPackages.push('@kadena/pactjs'); const monorepoPathsRegex = monorepoPackages.map( (pkg) => new RegExp(`${pkg.replace('@kadena/', '')}`), diff --git a/packages/libs/wallet-sdk/package.json b/packages/libs/wallet-sdk/package.json index d1c47248f8..aa5321fbe5 100644 --- a/packages/libs/wallet-sdk/package.json +++ b/packages/libs/wallet-sdk/package.json @@ -13,6 +13,7 @@ "Bart Huijgen ", "Danillo Felixdaal " ], + "type": "module", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", "types": "./lib/esm/index.d.ts", diff --git a/packages/libs/wallet-sdk/src/sdk/tests/createSimpleTransfer.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/createSimpleTransfer.test.ts index 532eacc0ac..c6004dd3bb 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/createSimpleTransfer.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/createSimpleTransfer.test.ts @@ -1,6 +1,6 @@ import type { ChainId } from '@kadena/types'; import { describe, expect, it, vi } from 'vitest'; -import { simpleTransferCreateCommand } from '../simpleTransferCreate'; +import { simpleTransferCreateCommand } from '../simpleTransferCreate.js'; vi.useFakeTimers(); diff --git a/packages/libs/wallet-sdk/src/sdk/tests/crossChainFinishCreate.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/crossChainFinishCreate.test.ts index 307c4d5b97..975738e896 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/crossChainFinishCreate.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/crossChainFinishCreate.test.ts @@ -2,7 +2,7 @@ import type { ChainId } from '@kadena/types'; import { http, HttpResponse } from 'msw'; import { setupServer } from 'msw/node'; import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'; -import { crossChainFinishCreateCommand } from '../crossChainFinishCreate'; +import { crossChainFinishCreateCommand } from '../crossChainFinishCreate.js'; const server = setupServer(); diff --git a/packages/libs/wallet-sdk/src/sdk/tests/exchange.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/exchange.test.ts index 0c5eda0a09..d87103ac8f 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/exchange.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/exchange.test.ts @@ -1,7 +1,7 @@ import type { Mock } from 'vitest'; import { beforeEach, describe, expect, it, vi } from 'vitest'; -import { exchange } from '../exchange'; -import type { IEthvmDevTokenInfo } from '../interface'; +import { exchange } from '../exchange.js'; +import type { IEthvmDevTokenInfo } from '../interface.js'; type Token = 'kadena' | 'ethereum'; diff --git a/packages/libs/wallet-sdk/src/sdk/tests/kadenanames.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/kadenanames.test.ts index 1e3b9ee49e..f3b9b5f427 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/kadenanames.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/kadenanames.test.ts @@ -4,7 +4,7 @@ import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'; import { ensureKdaExtension, parseChainResponse, -} from '../../services/kadenaNamesService'; +} from '../../services/kadenaNamesService.js'; import { walletSdk } from '../walletSdk.js'; const server = setupServer(); diff --git a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts index d163ba5287..ac5db883c1 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainEnd.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from 'vitest'; -import { parseGqlTransfers } from '../../services/graphql/transfer.util'; -import type { ITransfer } from '../interface'; +import { parseGqlTransfers } from '../../services/graphql/transfer.util.js'; +import type { ITransfer } from '../interface.js'; const GQL_TRANSFER_XCHAIN_FINISH = [ { diff --git a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.ts index 5e6debf59f..9e2287258b 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainStart.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from 'vitest'; -import { parseGqlTransfers } from '../../services/graphql/transfer.util'; -import type { ITransfer } from '../interface'; +import { parseGqlTransfers } from '../../services/graphql/transfer.util.js'; +import type { ITransfer } from '../interface.js'; const TRANSFER_XCHAIN_SEND = [ { diff --git a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts index 2b0b17bdc4..e390b33907 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/mapTransferXchainUnfinished.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from 'vitest'; -import { parseGqlTransfers } from '../../services/graphql/transfer.util'; -import type { ITransfer } from '../interface'; +import { parseGqlTransfers } from '../../services/graphql/transfer.util.js'; +import type { ITransfer } from '../interface.js'; const TRANSFER_XCHAIN_SEND = [ { diff --git a/packages/libs/wallet-sdk/src/sdk/tests/poll.test.ts b/packages/libs/wallet-sdk/src/sdk/tests/poll.test.ts index 29e98ec46c..ac627c654f 100644 --- a/packages/libs/wallet-sdk/src/sdk/tests/poll.test.ts +++ b/packages/libs/wallet-sdk/src/sdk/tests/poll.test.ts @@ -7,7 +7,7 @@ import { kadenaMnemonicToSeed, kadenaSignWithSeed, } from '@kadena/hd-wallet'; -import { walletSdk } from '../walletSdk'; +import { walletSdk } from '../walletSdk.js'; describe('example test', () => { test( diff --git a/packages/libs/wallet-sdk/src/services/chainweb/chainweb.ts b/packages/libs/wallet-sdk/src/services/chainweb/chainweb.ts index 2bf6c82690..a683602edf 100644 --- a/packages/libs/wallet-sdk/src/services/chainweb/chainweb.ts +++ b/packages/libs/wallet-sdk/src/services/chainweb/chainweb.ts @@ -1,8 +1,8 @@ import * as v from 'valibot'; -import type { Logger } from '../../sdk/logger'; -import type { PollResponse, ResponseResult } from '../../sdk/schema'; -import { pollResponseSchema } from '../../sdk/schema'; -import { notEmpty } from '../../utils/typeUtils'; +import type { Logger } from '../../sdk/logger.js'; +import type { PollResponse, ResponseResult } from '../../sdk/schema.js'; +import { pollResponseSchema } from '../../sdk/schema.js'; +import { notEmpty } from '../../utils/typeUtils.js'; interface IPollRequestKeysOptions { chainwebUrl: string; diff --git a/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts b/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts index 4b06fb21f4..b97ec2b885 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/pollTransfers.ts @@ -1,9 +1,9 @@ import { createClient, fetchExchange } from '@urql/core'; -import type { ITransfer } from '../../sdk/interface'; -import type { Logger } from '../../sdk/logger'; -import { TRANSFER_REQUESTKEY_QUERY } from './transfer.query'; -import type { GqlTransfer } from './transfer.util'; -import { parseGqlTransfers } from './transfer.util'; +import type { ITransfer } from '../../sdk/interface.js'; +import type { Logger } from '../../sdk/logger.js'; +import { TRANSFER_REQUESTKEY_QUERY } from './transfer.query.js'; +import type { GqlTransfer } from './transfer.util.js'; +import { parseGqlTransfers } from './transfer.util.js'; interface IRollGraphqlTransfers { graphqlUrl: string; diff --git a/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts b/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts index 5c6ba6047c..0b83b4ac00 100644 --- a/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts +++ b/packages/libs/wallet-sdk/src/services/graphql/transfer.util.ts @@ -1,9 +1,9 @@ import type { ChainId } from '@kadena/types'; -import type { TransferFieldsFragment } from '../../gql/graphql'; -import type { ITransfer } from '../../sdk/interface'; -import { parsePactNumber } from '../../utils/pact.util'; -import { safeJsonParse } from '../../utils/string.util'; -import { isEmpty, notEmpty } from '../../utils/typeUtils'; +import type { TransferFieldsFragment } from '../../gql/graphql.js'; +import type { ITransfer } from '../../sdk/interface.js'; +import { parsePactNumber } from '../../utils/pact.util.js'; +import { safeJsonParse } from '../../utils/string.util.js'; +import { isEmpty, notEmpty } from '../../utils/typeUtils.js'; export type GqlTransfer = TransferFieldsFragment & { crossChainTransfer?: TransferFieldsFragment | null; diff --git a/packages/libs/wallet-sdk/src/utils/tests/pact.util.test.ts b/packages/libs/wallet-sdk/src/utils/tests/pact.util.test.ts index ebfdc87379..43f0850694 100644 --- a/packages/libs/wallet-sdk/src/utils/tests/pact.util.test.ts +++ b/packages/libs/wallet-sdk/src/utils/tests/pact.util.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import { parsePactNumber } from '../pact.util'; +import { parsePactNumber } from '../pact.util.js'; describe('parsePactNumber', () => { it('should return the number when input is a number', () => { diff --git a/packages/libs/wallet-sdk/src/utils/tests/string.util.test.ts b/packages/libs/wallet-sdk/src/utils/tests/string.util.test.ts index 189ed0e852..13d1acff04 100644 --- a/packages/libs/wallet-sdk/src/utils/tests/string.util.test.ts +++ b/packages/libs/wallet-sdk/src/utils/tests/string.util.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import { safeJsonParse } from '../string.util'; +import { safeJsonParse } from '../string.util.js'; interface IUser { name: string; diff --git a/packages/libs/wallet-sdk/src/utils/tests/typeUtils.test.ts b/packages/libs/wallet-sdk/src/utils/tests/typeUtils.test.ts index 31654668c7..01c4c3dd70 100644 --- a/packages/libs/wallet-sdk/src/utils/tests/typeUtils.test.ts +++ b/packages/libs/wallet-sdk/src/utils/tests/typeUtils.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import { notEmpty } from '../typeUtils'; +import { notEmpty } from '../typeUtils.js'; describe('notEmpty function', () => { it('returns true for non-null and non-undefined values', () => { From 6176ffe430dc5e6bb84822c1121aec2fbf02b60e Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 14:59:13 +0100 Subject: [PATCH 094/103] chore(wallet-sdk-example): remove unused code --- .../wallet-sdk-example/src/domain/wallet.ts | 46 ------------------- 1 file changed, 46 deletions(-) delete mode 100644 packages/apps/wallet-sdk-example/src/domain/wallet.ts diff --git a/packages/apps/wallet-sdk-example/src/domain/wallet.ts b/packages/apps/wallet-sdk-example/src/domain/wallet.ts deleted file mode 100644 index 14c7bd5472..0000000000 --- a/packages/apps/wallet-sdk-example/src/domain/wallet.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { addSignatures, createClient, createTransaction } from '@kadena/client'; -import { transferCreateCommand } from '@kadena/client-utils/coin'; -import { - kadenaGenKeypairFromSeed, - kadenaMnemonicToSeed, - kadenaSignWithKeyPair, -} from '@kadena/hd-wallet'; - -const phrase = - 'hunt barrel sea feature before wood canoe stem govern vacuum rival sadness'; -const password = 'password'; - -export async function main() { - const seed = await kadenaMnemonicToSeed(password, phrase); - const [key1, key1Secret] = await kadenaGenKeypairFromSeed(password, seed, 0); - const [key2] = await kadenaGenKeypairFromSeed(password, seed, 1); - const transaction = createTransaction({ - ...transferCreateCommand({ - amount: '0.1', - chainId: '0', - receiver: { - account: `k:${key2}`, - keyset: { - pred: 'keys-all', - keys: [key2], - }, - }, - sender: { - account: `k:${key1}`, - publicKeys: [key1], - }, - })(), - networkId: 'testnet04', - }); - - const sig = await kadenaSignWithKeyPair( - password, - key1, - key1Secret, - )(transaction.hash); - const signed = addSignatures(transaction, sig); - - const client = createClient(); - const result = await client.local(signed); - console.log(result); -} From 27b56803a0878922530c5be700b1ed184fc70ebc Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Fri, 6 Dec 2024 15:05:04 +0100 Subject: [PATCH 095/103] chore(wallet-sdk-example): attempt to fix ci build --- packages/apps/wallet-sdk-example/vite.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/apps/wallet-sdk-example/vite.config.ts b/packages/apps/wallet-sdk-example/vite.config.ts index b4c68c1cf9..77d0c4ed92 100644 --- a/packages/apps/wallet-sdk-example/vite.config.ts +++ b/packages/apps/wallet-sdk-example/vite.config.ts @@ -26,6 +26,7 @@ const monorepoPackages = getMonorepoPackagesFromPackageJson(); monorepoPackages.push('@kadena/client-utils'); monorepoPackages.push('@kadena/cryptography-utils'); monorepoPackages.push('@kadena/pactjs'); +monorepoPackages.push('@kadena/wallet-sdk'); const monorepoPathsRegex = monorepoPackages.map( (pkg) => new RegExp(`${pkg.replace('@kadena/', '')}`), From 7360b1cc54dc5b656c89934bf0e17ddfcfc23adb Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 6 Dec 2024 16:48:21 +0100 Subject: [PATCH 096/103] feat(rwa): show maxsupply numbers (#2717) --- .changeset/twenty-cherries-study.md | 2 + .../investors/[investorAccount]/page.tsx | 65 ++------ .../src/app/(app)/assets/[uuid]/page.tsx | 23 ++- .../src/components/AgentForm/AgentForm.tsx | 53 ++++-- .../src/components/AssetInfo/AssetInfo.tsx | 2 + .../AssetProvider/AssetProvider.tsx | 50 +++++- .../DistributionForm/DistributionForm.tsx | 141 +++++++++++----- .../src/components/HomePage/AgentRootPage.tsx | 2 + .../HomePage/ComplianceOwnerRootPage.tsx | 55 +----- .../InvestorBalance/InvestorBalance.tsx | 17 +- .../components/InvestorForm/InvestorForm.tsx | 11 +- .../PartiallyFreezeTokensForm.tsx | 156 +++++++++++++----- .../SetComplianceForm/SetComplianceForm.tsx | 100 +++++++++++ .../SetMaxBalanceForm/SetMaxBalanceForm.tsx | 57 ------- .../SetMaxSupplyForm/SetMaxSupplyForm.tsx | 57 ------- .../components/SupplyCount/SupplyCount.tsx | 7 +- .../components/TransferForm/TransferForm.tsx | 1 - .../apps/rwa-demo/src/hooks/addInvestor.ts | 1 - .../src/hooks/{addAgent.ts => editAgent.ts} | 10 +- packages/apps/rwa-demo/src/hooks/getAgents.ts | 1 - .../{setMaxBalance.ts => setCompliance.ts} | 10 +- .../apps/rwa-demo/src/hooks/setMaxSupply.ts | 38 ----- .../apps/rwa-demo/src/services/addAgent.ts | 24 ++- .../rwa-demo/src/services/distributeTokens.ts | 2 +- .../{setMaxBalance.ts => editAgent.ts} | 21 ++- .../src/services/getAssetMaxSupplyBalance.ts | 34 ++++ .../rwa-demo/src/services/getFrozenTokens.ts | 32 ++++ .../apps/rwa-demo/src/services/isFrozen.ts | 2 +- .../{setMaxSupply.ts => setCompliance.ts} | 11 +- packages/apps/rwa-demo/src/services/supply.ts | 2 + .../services/togglePartiallyFreezeTokens.ts | 2 +- .../src/utils/setAliasesToAccounts.ts | 1 - 32 files changed, 584 insertions(+), 406 deletions(-) create mode 100644 .changeset/twenty-cherries-study.md create mode 100644 packages/apps/rwa-demo/src/components/SetComplianceForm/SetComplianceForm.tsx delete mode 100644 packages/apps/rwa-demo/src/components/SetMaxBalanceForm/SetMaxBalanceForm.tsx delete mode 100644 packages/apps/rwa-demo/src/components/SetMaxSupplyForm/SetMaxSupplyForm.tsx rename packages/apps/rwa-demo/src/hooks/{addAgent.ts => editAgent.ts} (86%) rename packages/apps/rwa-demo/src/hooks/{setMaxBalance.ts => setCompliance.ts} (77%) delete mode 100644 packages/apps/rwa-demo/src/hooks/setMaxSupply.ts rename packages/apps/rwa-demo/src/services/{setMaxBalance.ts => editAgent.ts} (51%) create mode 100644 packages/apps/rwa-demo/src/services/getAssetMaxSupplyBalance.ts create mode 100644 packages/apps/rwa-demo/src/services/getFrozenTokens.ts rename packages/apps/rwa-demo/src/services/{setMaxSupply.ts => setCompliance.ts} (64%) diff --git a/.changeset/twenty-cherries-study.md b/.changeset/twenty-cherries-study.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/twenty-cherries-study.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/apps/rwa-demo/src/app/(app)/(isAgent)/investors/[investorAccount]/page.tsx b/packages/apps/rwa-demo/src/app/(app)/(isAgent)/investors/[investorAccount]/page.tsx index 1fdc77e149..3157490648 100644 --- a/packages/apps/rwa-demo/src/app/(app)/(isAgent)/investors/[investorAccount]/page.tsx +++ b/packages/apps/rwa-demo/src/app/(app)/(isAgent)/investors/[investorAccount]/page.tsx @@ -11,31 +11,17 @@ import { useFreeze } from '@/hooks/freeze'; import { useGetInvestor } from '@/hooks/getInvestor'; import { MonoAdd, MonoEditNote } from '@kadena/kode-icons'; import { Button, Stack } from '@kadena/kode-ui'; -import { SideBarBreadcrumbsItem, useLayout } from '@kadena/kode-ui/patterns'; +import { SideBarBreadcrumbsItem } from '@kadena/kode-ui/patterns'; import { useParams } from 'next/navigation'; -import { useState } from 'react'; const InvestorPage = () => { - const { isRightAsideExpanded, setIsRightAsideExpanded } = useLayout(); const { paused } = useAsset(); const params = useParams(); - const [hasOpenDistributeForm, setHasOpenDistributeForm] = useState(false); - const [hasOpenPartiallyFreezeForm, setHasOpenPartiallyFreezeForm] = - useState(false); const investorAccount = decodeURIComponent(params.investorAccount as string); const { data: investor } = useGetInvestor({ account: investorAccount }); const { frozen } = useFreeze({ investorAccount }); - const handleDistributeTokens = () => { - setIsRightAsideExpanded(true); - setHasOpenDistributeForm(true); - }; - const handlePartiallyFreezeTokens = () => { - setIsRightAsideExpanded(true); - setHasOpenPartiallyFreezeForm(true); - }; - if (!investor) return null; return ( @@ -46,43 +32,26 @@ const InvestorPage = () => { - {isRightAsideExpanded && hasOpenDistributeForm && ( - { - setIsRightAsideExpanded(false); - setHasOpenDistributeForm(false); - }} - /> - )} - {isRightAsideExpanded && hasOpenPartiallyFreezeForm && ( - { - setIsRightAsideExpanded(false); - setHasOpenPartiallyFreezeForm(false); - }} - /> - )} - - + } isDisabled={frozen || paused}> + Distribute Tokens + + } + /> - + } isDisabled={frozen || paused}> + Partially freeze tokens + + } + /> diff --git a/packages/apps/rwa-demo/src/app/(app)/assets/[uuid]/page.tsx b/packages/apps/rwa-demo/src/app/(app)/assets/[uuid]/page.tsx index 5479556818..dbec515dc9 100644 --- a/packages/apps/rwa-demo/src/app/(app)/assets/[uuid]/page.tsx +++ b/packages/apps/rwa-demo/src/app/(app)/assets/[uuid]/page.tsx @@ -1,17 +1,28 @@ 'use client'; +import type { IWalletAccount } from '@/components/AccountProvider/utils'; +import type { IAsset } from '@/components/AssetProvider/AssetProvider'; +import { useAccount } from '@/hooks/account'; import { useAsset } from '@/hooks/asset'; import { useParams } from 'next/navigation'; -import { useMemo } from 'react'; +import { useEffect, useState } from 'react'; const Assets = () => { const { getAsset } = useAsset(); + const { account } = useAccount(); + const [asset, setAsset] = useState(); const { uuid } = useParams(); - const asset = useMemo(() => { - return getAsset(uuid as string); - }, [uuid]); - console.log({ asset }); + const initData = async (uuid: string, account: IWalletAccount) => { + const data = await getAsset(uuid, account); + setAsset(data); + }; + + useEffect(() => { + if (!account) return; + // eslint-disable-next-line @typescript-eslint/no-floating-promises + initData(uuid as string, account); + }, [uuid, account?.address]); + return
{JSON.stringify(asset, null, 2)}
; }; - export default Assets; diff --git a/packages/apps/rwa-demo/src/components/AgentForm/AgentForm.tsx b/packages/apps/rwa-demo/src/components/AgentForm/AgentForm.tsx index 8819a6a34c..2b3b6c6928 100644 --- a/packages/apps/rwa-demo/src/components/AgentForm/AgentForm.tsx +++ b/packages/apps/rwa-demo/src/components/AgentForm/AgentForm.tsx @@ -1,7 +1,8 @@ -import { useAddAgent } from '@/hooks/addAgent'; +import { useEditAgent } from '@/hooks/editAgent'; import type { IAddAgentProps } from '@/services/addAgent'; +import { AGENTROLES } from '@/services/addAgent'; import type { IRecord } from '@/utils/filterRemovedRecords'; -import { Button, TextField } from '@kadena/kode-ui'; +import { Button, CheckboxGroup, TextField } from '@kadena/kode-ui'; import { RightAside, RightAsideContent, @@ -20,17 +21,32 @@ interface IProps { } export const AgentForm: FC = ({ onClose, agent, trigger }) => { - const { submit } = useAddAgent(); + const { submit } = useEditAgent(); const [isOpen, setIsOpen] = useState(false); const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); - const { handleSubmit, control } = useForm({ + const { + handleSubmit, + control, + register, + formState: { isValid }, + reset, + } = useForm({ defaultValues: { accountName: agent?.accountName ?? '', alias: agent?.alias ?? '', alreadyExists: !!agent?.accountName, + roles: [], }, }); + useEffect(() => { + reset({ + accountName: agent?.accountName, + alias: agent?.alias, + alreadyExists: !!agent?.accountName, + }); + }, [agent?.accountName]); + const handleOpen = () => { setIsRightAsideExpanded(true); setIsOpen(true); @@ -38,6 +54,7 @@ export const AgentForm: FC = ({ onClose, agent, trigger }) => { }; const handleOnClose = () => { + setIsRightAsideExpanded(false); setIsOpen(false); if (onClose) onClose(); }; @@ -47,10 +64,6 @@ export const AgentForm: FC = ({ onClose, agent, trigger }) => { handleOnClose(); }; - useEffect(() => { - console.log('agent', isOpen); - }, [isOpen]); - return ( <> {isRightAsideExpanded && isOpen && ( @@ -59,11 +72,14 @@ export const AgentForm: FC = ({ onClose, agent, trigger }) => { onClose={handleOnClose} >
- + ( = ({ onClose, agent, trigger }) => { control={control} render={({ field }) => } /> + + + {Object.entries(AGENTROLES).map(([key, val]) => { + return ( + + ); + })} + - + diff --git a/packages/apps/rwa-demo/src/components/AssetInfo/AssetInfo.tsx b/packages/apps/rwa-demo/src/components/AssetInfo/AssetInfo.tsx index 08224202ef..07e7a3f952 100644 --- a/packages/apps/rwa-demo/src/components/AssetInfo/AssetInfo.tsx +++ b/packages/apps/rwa-demo/src/components/AssetInfo/AssetInfo.tsx @@ -24,6 +24,8 @@ export const AssetInfo: FC = () => {
)} +
maxSupply: {asset.maxSupply}
+
maxBalance: {asset.maxBalance}
diff --git a/packages/apps/rwa-demo/src/components/AssetProvider/AssetProvider.tsx b/packages/apps/rwa-demo/src/components/AssetProvider/AssetProvider.tsx index 3a8eb1572f..cb7281dcf7 100644 --- a/packages/apps/rwa-demo/src/components/AssetProvider/AssetProvider.tsx +++ b/packages/apps/rwa-demo/src/components/AssetProvider/AssetProvider.tsx @@ -4,16 +4,22 @@ import { LOCALSTORAGE_ASSETS_SELECTED_KEY, } from '@/constants'; import { usePaused } from '@/hooks/paused'; +import { useSupply } from '@/hooks/supply'; +import type { IGetAssetMaxSupplyBalanceResult } from '@/services/getAssetMaxSupplyBalance'; +import { getAssetMaxSupplyBalance } from '@/services/getAssetMaxSupplyBalance'; +import { supply as supplyService } from '@/services/supply'; import { getFullAsset } from '@/utils/getAsset'; import { getLocalStorageKey } from '@/utils/getLocalStorageKey'; import { useRouter } from 'next/navigation'; import type { FC, PropsWithChildren } from 'react'; import { createContext, useEffect, useState } from 'react'; +import type { IWalletAccount } from '../AccountProvider/utils'; -export interface IAsset { +export interface IAsset extends IGetAssetMaxSupplyBalanceResult { uuid: string; name: string; + supply: number; } export interface IAssetContext { @@ -21,14 +27,17 @@ export interface IAssetContext { assets: IAsset[]; paused: boolean; setAsset: (asset: IAsset) => void; - getAsset: (uuid: string) => IAsset | undefined; + getAsset: ( + uuid: string, + account: IWalletAccount, + ) => Promise; } export const AssetContext = createContext({ assets: [], paused: false, setAsset: () => {}, - getAsset: (uuid: string) => undefined, + getAsset: async () => undefined, }); export const AssetProvider: FC = ({ children }) => { @@ -40,6 +49,7 @@ export const AssetProvider: FC = ({ children }) => { const selectedKey = getLocalStorageKey(LOCALSTORAGE_ASSETS_SELECTED_KEY) ?? ''; const { paused } = usePaused(); + const { data: supply } = useSupply(); const getAssets = (): IAsset[] => { const result = localStorage.getItem(storageKey); @@ -56,15 +66,25 @@ export const AssetProvider: FC = ({ children }) => { const handleSelectAsset = (data: IAsset) => { localStorage.setItem(selectedKey, JSON.stringify(data)); - setAsset(data); + setAsset((old) => ({ ...old, ...data })); router.replace('/'); router.refresh(); }; - const getAsset = (uuid: string) => { + const getAsset = async ( + uuid: string, + account: IWalletAccount, + ): Promise => { const data = getAssets().find((a) => a.uuid === uuid); - return data; + const extraAssetData = await getAssetMaxSupplyBalance(); + + const supplyResult = (await supplyService({ + account: account!, + })) as number; + + if (!data) return; + return { ...data, ...extraAssetData, supply: supplyResult ?? 0 }; }; useEffect(() => { @@ -78,6 +98,12 @@ export const AssetProvider: FC = ({ children }) => { }; }, []); + const loadAssetData = async () => { + const data = await getAssetMaxSupplyBalance(); + + setAsset((old) => old && { ...old, ...data }); + }; + useEffect(() => { const asset = getFullAsset(); setAsset(asset); @@ -86,6 +112,18 @@ export const AssetProvider: FC = ({ children }) => { } }, []); + useEffect(() => { + if (!asset) return; + + setAsset((old) => old && { ...old, supply }); + }, [asset?.name, supply]); + + useEffect(() => { + if (!asset) return; + // eslint-disable-next-line @typescript-eslint/no-floating-promises + loadAssetData(); + }, [asset?.uuid]); + return ( void; + onClose?: () => void; investorAccount: string; + trigger: ReactElement; } -export const DistributionForm: FC = ({ onClose, investorAccount }) => { +export const DistributionForm: FC = ({ + onClose, + investorAccount, + trigger, +}) => { + const { account } = useAccount(); + const { asset } = useAsset(); const { frozen } = useFreeze({ investorAccount }); const [tx, setTx] = useState(); const resolveRef = useRef(null); const { paused } = useAsset(); const { submit } = useDistributeTokens(); - const { register, handleSubmit } = useForm({ + const [tokenBalance, setTokenBalance] = useState(0); + const [isOpen, setIsOpen] = useState(false); + const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); + const { + control, + handleSubmit, + formState: { isValid, errors }, + } = useForm({ values: { - amount: 0, + amount: '0', investorAccount, }, }); + const handleOpen = () => { + setIsRightAsideExpanded(true); + setIsOpen(true); + if (trigger.props.onPress) trigger.props.onPress(); + }; + + const handleOnClose = () => { + setIsRightAsideExpanded(false); + setIsOpen(false); + if (onClose) onClose(); + }; + const onSubmit = async (data: IDistributeTokensProps) => { const transaction = await submit(data); setTx(transaction); @@ -45,7 +74,7 @@ export const DistributionForm: FC = ({ onClose, investorAccount }) => { useEffect(() => { if (tx && resolveRef.current) { resolveRef.current(tx); - onClose(); + handleOnClose(); } }, [tx]); @@ -60,40 +89,74 @@ export const DistributionForm: FC = ({ onClose, investorAccount }) => { return message; }; + const init = async () => { + const res = await getBalance({ investorAccount, account: account! }); + + if (typeof res === 'number') { + setTokenBalance(res); + } + }; + + useEffect(() => { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + init(); + }, []); + + const maxAmount = (asset?.maxSupply ?? 0) - tokenBalance; return ( <> - -
- - - - - - - - - } - > - - - Distribute - + {isRightAsideExpanded && isOpen && ( + + + + + ( + + )} + /> + + + + + } - /> - - - + > + + + Distribute + + } + /> + + +
+ )} + + {cloneElement(trigger, { ...trigger.props, onPress: handleOpen })} ); }; diff --git a/packages/apps/rwa-demo/src/components/HomePage/AgentRootPage.tsx b/packages/apps/rwa-demo/src/components/HomePage/AgentRootPage.tsx index 9d3017dc15..6c59a012f3 100644 --- a/packages/apps/rwa-demo/src/components/HomePage/AgentRootPage.tsx +++ b/packages/apps/rwa-demo/src/components/HomePage/AgentRootPage.tsx @@ -2,6 +2,7 @@ import { SideBarBreadcrumbs } from '@/components/SideBarBreadcrumbs/SideBarBread import { useAccount } from '@/hooks/account'; import { Stack } from '@kadena/kode-ui'; import type { FC } from 'react'; +import { AgentsList } from '../AgentsList/AgentsList'; import { InvestorList } from '../InvestorList/InvestorList'; import { PauseForm } from '../PauseForm/PauseForm'; @@ -18,6 +19,7 @@ export const AgentRootPage: FC = () => { + ); }; diff --git a/packages/apps/rwa-demo/src/components/HomePage/ComplianceOwnerRootPage.tsx b/packages/apps/rwa-demo/src/components/HomePage/ComplianceOwnerRootPage.tsx index f6a1f153c6..78b06b6908 100644 --- a/packages/apps/rwa-demo/src/components/HomePage/ComplianceOwnerRootPage.tsx +++ b/packages/apps/rwa-demo/src/components/HomePage/ComplianceOwnerRootPage.tsx @@ -1,68 +1,29 @@ 'use client'; -import { SetMaxBalanceForm } from '@/components/SetMaxBalanceForm/SetMaxBalanceForm'; import { SideBarBreadcrumbs } from '@/components/SideBarBreadcrumbs/SideBarBreadcrumbs'; import { useAccount } from '@/hooks/account'; import { useAsset } from '@/hooks/asset'; import { MonoAdd } from '@kadena/kode-icons'; import { Button, Stack } from '@kadena/kode-ui'; -import { useLayout } from '@kadena/kode-ui/patterns'; -import { useState } from 'react'; -import { SetMaxSupplyForm } from '../SetMaxSupplyForm/SetMaxSupplyForm'; +import { SetComplianceForm } from '../SetComplianceForm/SetComplianceForm'; export const ComplianceOwnerRootPage = () => { const { isComplianceOwner } = useAccount(); - const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); const { paused } = useAsset(); - const [hasOpenMaxBalanceForm, setHasOpenMaxBalanceForm] = useState(false); - const [hasOpenMaxSupplyForm, setHasOpenMaxSupplyForm] = useState(false); - - const handleMaxBalanceForm = () => { - setIsRightAsideExpanded(true); - setHasOpenMaxBalanceForm(true); - }; - const handleMaxSupplyForm = () => { - setIsRightAsideExpanded(true); - setHasOpenMaxSupplyForm(true); - }; return ( - {isRightAsideExpanded && hasOpenMaxBalanceForm && ( - { - setIsRightAsideExpanded(false); - setHasOpenMaxBalanceForm(false); - }} - /> - )} - {isRightAsideExpanded && hasOpenMaxSupplyForm && ( - { - setIsRightAsideExpanded(false); - setHasOpenMaxSupplyForm(false); - }} - /> - )} - {isComplianceOwner && ( <> - - + }> + Set Compliance + + } + /> )} diff --git a/packages/apps/rwa-demo/src/components/InvestorBalance/InvestorBalance.tsx b/packages/apps/rwa-demo/src/components/InvestorBalance/InvestorBalance.tsx index 492de8c104..0b931719c6 100644 --- a/packages/apps/rwa-demo/src/components/InvestorBalance/InvestorBalance.tsx +++ b/packages/apps/rwa-demo/src/components/InvestorBalance/InvestorBalance.tsx @@ -1,5 +1,6 @@ import { useAccount } from '@/hooks/account'; import { getBalance } from '@/services/getBalance'; +import { getFrozenTokens } from '@/services/getFrozenTokens'; import { Stack } from '@kadena/kode-ui'; import type { FC } from 'react'; import React, { useEffect, useState } from 'react'; @@ -11,6 +12,7 @@ interface IProps { export const InvestorBalance: FC = ({ investorAccount }) => { const { account } = useAccount(); const [data, setData] = useState(0); + const [frozenData, setFrozenData] = useState(0); const init = async () => { const res = await getBalance({ investorAccount, account: account! }); @@ -18,6 +20,15 @@ export const InvestorBalance: FC = ({ investorAccount }) => { if (typeof res === 'number') { setData(res); } + + const frozenRes = await getFrozenTokens({ + investorAccount, + account: account!, + }); + + if (typeof frozenRes === 'number') { + setFrozenData(frozenRes); + } }; useEffect(() => { @@ -25,5 +36,9 @@ export const InvestorBalance: FC = ({ investorAccount }) => { init(); }, []); - return investorBalance: {data}; + return ( + + investorBalance: {data} (frozen: {frozenData}) + + ); }; diff --git a/packages/apps/rwa-demo/src/components/InvestorForm/InvestorForm.tsx b/packages/apps/rwa-demo/src/components/InvestorForm/InvestorForm.tsx index 8eb394cc65..de8a660160 100644 --- a/packages/apps/rwa-demo/src/components/InvestorForm/InvestorForm.tsx +++ b/packages/apps/rwa-demo/src/components/InvestorForm/InvestorForm.tsx @@ -10,7 +10,7 @@ import { useLayout, } from '@kadena/kode-ui/patterns'; import type { FC, ReactElement } from 'react'; -import { cloneElement, useEffect, useState } from 'react'; +import { cloneElement, useState } from 'react'; import { Controller, useForm } from 'react-hook-form'; interface IProps { @@ -40,12 +40,9 @@ export const InvestorForm: FC = ({ onClose, trigger, investor }) => { }; const handleOnClose = () => { - console.log(333331); + setIsRightAsideExpanded(false); setIsOpen(false); if (onClose) onClose(); - // setIsRightAsideExpanded(false); - // setRightAsideOnClose(() => { - // }); }; const onSubmit = async (data: Omit) => { @@ -53,10 +50,6 @@ export const InvestorForm: FC = ({ onClose, trigger, investor }) => { handleOnClose(); }; - useEffect(() => { - console.log(isOpen); - }, [isOpen]); - return ( <> {isRightAsideExpanded && isOpen && ( diff --git a/packages/apps/rwa-demo/src/components/PartiallyFreezeTokensForm/PartiallyFreezeTokensForm.tsx b/packages/apps/rwa-demo/src/components/PartiallyFreezeTokensForm/PartiallyFreezeTokensForm.tsx index b6858767e4..ef2d9f5a7f 100644 --- a/packages/apps/rwa-demo/src/components/PartiallyFreezeTokensForm/PartiallyFreezeTokensForm.tsx +++ b/packages/apps/rwa-demo/src/components/PartiallyFreezeTokensForm/PartiallyFreezeTokensForm.tsx @@ -1,6 +1,9 @@ +import { useAccount } from '@/hooks/account'; import { useAsset } from '@/hooks/asset'; import { useFreeze } from '@/hooks/freeze'; import { useTogglePartiallyFreezeTokens } from '@/hooks/togglePartiallyFreezeTokens'; +import { getBalance } from '@/services/getBalance'; +import { getFrozenTokens } from '@/services/getFrozenTokens'; import type { ITogglePartiallyFreezeTokensProps } from '@/services/togglePartiallyFreezeTokens'; import { Button, TextField } from '@kadena/kode-ui'; import { @@ -8,45 +11,67 @@ import { RightAsideContent, RightAsideFooter, RightAsideHeader, + useLayout, } from '@kadena/kode-ui/patterns'; -import type { FC } from 'react'; -import { useEffect, useRef, useState } from 'react'; -import { useForm } from 'react-hook-form'; +import type { FC, ReactElement } from 'react'; +import { cloneElement, useEffect, useRef, useState } from 'react'; +import { Controller, useForm } from 'react-hook-form'; import { AssetPausedMessage } from '../AssetPausedMessage/AssetPausedMessage'; import { InvestorFrozenMessage } from '../InvestorFrozenMessage/InvestorFrozenMessage'; import { SendTransactionAnimation } from '../SendTransactionAnimation/SendTransactionAnimation'; import type { ITransaction } from '../TransactionsProvider/TransactionsProvider'; interface IProps { - onClose: () => void; + onClose?: () => void; investorAccount: string; + trigger: ReactElement; } export const PartiallyFreezeTokensForm: FC = ({ onClose, investorAccount, + trigger, }) => { const { frozen } = useFreeze({ investorAccount }); + const { account } = useAccount(); const [tx, setTx] = useState(); const resolveRef = useRef(null); const { paused } = useAsset(); + const [tokenBalance, setTokenBalance] = useState(0); + const [frozenData, setFrozenData] = useState(0); + const [isOpen, setIsOpen] = useState(false); + const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); const { submit } = useTogglePartiallyFreezeTokens(); - const { register, handleSubmit } = useForm( - { - values: { - amount: 0, - investorAccount, - }, + const { + handleSubmit, + formState: { isValid, errors }, + control, + } = useForm({ + values: { + amount: '0', + investorAccount, }, - ); + }); + + const handleOpen = () => { + setIsRightAsideExpanded(true); + setIsOpen(true); + if (trigger.props.onPress) trigger.props.onPress(); + }; + + const handleOnClose = () => { + setIsRightAsideExpanded(false); + setIsOpen(false); + if (onClose) onClose(); + }; const onSubmit = async (data: ITogglePartiallyFreezeTokensProps) => { - const freeze = data.amount >= 0; + const freeze = parseInt(data.amount) >= 0; const transaction = await submit({ ...data, - amount: Math.abs(data.amount), + amount: `${Math.abs(parseInt(data.amount))}`, freeze, }); setTx(transaction); @@ -57,7 +82,7 @@ export const PartiallyFreezeTokensForm: FC = ({ useEffect(() => { if (tx && resolveRef.current) { resolveRef.current(tx); - onClose(); + handleOnClose(); } }, [tx]); @@ -72,40 +97,81 @@ export const PartiallyFreezeTokensForm: FC = ({ return message; }; + const init = async () => { + const res = await getBalance({ investorAccount, account: account! }); + + if (typeof res === 'number') { + setTokenBalance(res); + } + + const frozenRes = await getFrozenTokens({ + investorAccount, + account: account!, + }); + + if (typeof frozenRes === 'number') { + setFrozenData(frozenRes); + } + }; + + useEffect(() => { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + init(); + }, []); + return ( <> - -
- - - - - - - - - } - > - - - Freeze / UnFreeze - + {isRightAsideExpanded && isOpen && ( + + + + + ( + + )} + /> + + + + + } - /> - - - + > + + + Freeze / UnFreeze + + } + /> + + +
+ )} + + {cloneElement(trigger, { ...trigger.props, onPress: handleOpen })} ); }; diff --git a/packages/apps/rwa-demo/src/components/SetComplianceForm/SetComplianceForm.tsx b/packages/apps/rwa-demo/src/components/SetComplianceForm/SetComplianceForm.tsx new file mode 100644 index 0000000000..9c242e5d66 --- /dev/null +++ b/packages/apps/rwa-demo/src/components/SetComplianceForm/SetComplianceForm.tsx @@ -0,0 +1,100 @@ +import { useAccount } from '@/hooks/account'; +import { useAsset } from '@/hooks/asset'; +import { useSetCompliance } from '@/hooks/setCompliance'; +import type { ISetComplianceProps } from '@/services/setCompliance'; +import { Button, TextField } from '@kadena/kode-ui'; +import { + RightAside, + RightAsideContent, + RightAsideFooter, + RightAsideHeader, + useLayout, +} from '@kadena/kode-ui/patterns'; +import type { FC, ReactElement } from 'react'; +import { cloneElement, useEffect, useState } from 'react'; +import { Controller, useForm } from 'react-hook-form'; + +interface IProps { + onClose?: () => void; + trigger: ReactElement; +} + +export const SetComplianceForm: FC = ({ onClose, trigger }) => { + const { isComplianceOwner } = useAccount(); + const { submit } = useSetCompliance(); + const { asset } = useAsset(); + const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); + const [isOpen, setIsOpen] = useState(false); + const { handleSubmit, reset, control } = useForm({ + defaultValues: { + maxBalance: `${asset?.maxBalance ?? 0}`, + maxSupply: `${asset?.maxSupply ?? 0}`, + }, + }); + + const handleOpen = () => { + setIsRightAsideExpanded(true); + setIsOpen(true); + if (trigger.props.onPress) trigger.props.onPress(); + }; + + const handleOnClose = () => { + setIsRightAsideExpanded(false); + setIsOpen(false); + if (onClose) onClose(); + }; + + const onSubmit = async (data: ISetComplianceProps) => { + await submit(data); + + handleOnClose(); + }; + + useEffect(() => { + reset({ + maxSupply: `${asset?.maxSupply}`, + maxBalance: `${asset?.maxBalance}`, + }); + }, [asset?.maxBalance, asset?.maxSupply]); + + if (!isComplianceOwner) return null; + + return ( + <> + {isRightAsideExpanded && isOpen && ( + +
+ + + ( + + )} + /> + + ( + + )} + /> + + + + + + +
+ )} + + {cloneElement(trigger, { ...trigger.props, onPress: handleOpen })} + + ); +}; diff --git a/packages/apps/rwa-demo/src/components/SetMaxBalanceForm/SetMaxBalanceForm.tsx b/packages/apps/rwa-demo/src/components/SetMaxBalanceForm/SetMaxBalanceForm.tsx deleted file mode 100644 index 3161d72b8b..0000000000 --- a/packages/apps/rwa-demo/src/components/SetMaxBalanceForm/SetMaxBalanceForm.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { useAccount } from '@/hooks/account'; -import { useSetMaxBalance } from '@/hooks/setMaxBalance'; -import type { ISetMaxBalanceProps } from '@/services/setMaxBalance'; -import { Button, TextField } from '@kadena/kode-ui'; -import { - RightAside, - RightAsideContent, - RightAsideFooter, - RightAsideHeader, -} from '@kadena/kode-ui/patterns'; -import type { FC } from 'react'; -import { useForm } from 'react-hook-form'; - -interface IProps { - onClose: () => void; -} - -export const SetMaxBalanceForm: FC = ({ onClose }) => { - const { isComplianceOwner } = useAccount(); - const { submit } = useSetMaxBalance(); - const { register, handleSubmit } = useForm({ - defaultValues: { - maxBalance: 0, - }, - }); - - const onSubmit = async (data: ISetMaxBalanceProps) => { - await submit(data); - - onClose(); - }; - - if (!isComplianceOwner) return null; - - return ( - <> - -
- - - - - - - - - -
- - ); -}; diff --git a/packages/apps/rwa-demo/src/components/SetMaxSupplyForm/SetMaxSupplyForm.tsx b/packages/apps/rwa-demo/src/components/SetMaxSupplyForm/SetMaxSupplyForm.tsx deleted file mode 100644 index 5a85f02e59..0000000000 --- a/packages/apps/rwa-demo/src/components/SetMaxSupplyForm/SetMaxSupplyForm.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { useAccount } from '@/hooks/account'; -import { useSetMaxSupply } from '@/hooks/setMaxSupply'; -import type { ISetMaxSupplyProps } from '@/services/setMaxSupply'; -import { Button, TextField } from '@kadena/kode-ui'; -import { - RightAside, - RightAsideContent, - RightAsideFooter, - RightAsideHeader, -} from '@kadena/kode-ui/patterns'; -import type { FC } from 'react'; -import { useForm } from 'react-hook-form'; - -interface IProps { - onClose: () => void; -} - -export const SetMaxSupplyForm: FC = ({ onClose }) => { - const { isComplianceOwner } = useAccount(); - const { submit } = useSetMaxSupply(); - const { register, handleSubmit } = useForm({ - defaultValues: { - maxSupply: 0, - }, - }); - - const onSubmit = async (data: ISetMaxSupplyProps) => { - await submit(data); - - onClose(); - }; - - if (!isComplianceOwner) return null; - - return ( - <> - -
- - - - - - - - - -
- - ); -}; diff --git a/packages/apps/rwa-demo/src/components/SupplyCount/SupplyCount.tsx b/packages/apps/rwa-demo/src/components/SupplyCount/SupplyCount.tsx index 67b2a701b0..3cbabad31b 100644 --- a/packages/apps/rwa-demo/src/components/SupplyCount/SupplyCount.tsx +++ b/packages/apps/rwa-demo/src/components/SupplyCount/SupplyCount.tsx @@ -1,10 +1,11 @@ -import { useSupply } from '@/hooks/supply'; +import { useAsset } from '@/hooks/asset'; + import { Stack } from '@kadena/kode-ui'; import type { FC } from 'react'; import React from 'react'; export const SupplyCount: FC = () => { - const { data } = useSupply(); + const { asset } = useAsset(); - return total supply: {data}; + return total supply: {asset?.supply}; }; diff --git a/packages/apps/rwa-demo/src/components/TransferForm/TransferForm.tsx b/packages/apps/rwa-demo/src/components/TransferForm/TransferForm.tsx index a11ca276ec..5adc0811dd 100644 --- a/packages/apps/rwa-demo/src/components/TransferForm/TransferForm.tsx +++ b/packages/apps/rwa-demo/src/components/TransferForm/TransferForm.tsx @@ -60,7 +60,6 @@ export const TransferForm: FC = ({ onClose }) => { if (!account) return; - console.log({ errors }); return ( <> diff --git a/packages/apps/rwa-demo/src/hooks/addInvestor.ts b/packages/apps/rwa-demo/src/hooks/addInvestor.ts index 93d72904a1..a78593f21d 100644 --- a/packages/apps/rwa-demo/src/hooks/addInvestor.ts +++ b/packages/apps/rwa-demo/src/hooks/addInvestor.ts @@ -27,7 +27,6 @@ export const useAddInvestor = () => { const client = getClient(); const res = await client.submit(signedTransaction); - console.log(res); return addTransaction({ ...res, diff --git a/packages/apps/rwa-demo/src/hooks/addAgent.ts b/packages/apps/rwa-demo/src/hooks/editAgent.ts similarity index 86% rename from packages/apps/rwa-demo/src/hooks/addAgent.ts rename to packages/apps/rwa-demo/src/hooks/editAgent.ts index e660716173..665be1a0c5 100644 --- a/packages/apps/rwa-demo/src/hooks/addAgent.ts +++ b/packages/apps/rwa-demo/src/hooks/editAgent.ts @@ -2,13 +2,14 @@ import type { ITransaction } from '@/components/TransactionsProvider/Transaction import { interpretErrorMessage } from '@/components/TransactionsProvider/TransactionsProvider'; import type { IAddAgentProps } from '@/services/addAgent'; import { addAgent } from '@/services/addAgent'; +import { editAgent } from '@/services/editAgent'; import { getClient } from '@/utils/client'; import { store } from '@/utils/store'; import { useNotifications } from '@kadena/kode-ui/patterns'; import { useAccount } from './account'; import { useTransactions } from './transactions'; -export const useAddAgent = () => { +export const useEditAgent = () => { const { account, sign } = useAccount(); const { addTransaction } = useTransactions(); const { addNotification } = useNotifications(); @@ -17,10 +18,9 @@ export const useAddAgent = () => { data: IAddAgentProps, ): Promise => { try { - //if the account is already agent, no need to add it again - if (data.alreadyExists) return; - - const tx = await addAgent(data, account!); + const tx = data.alreadyExists + ? await editAgent(data, account!) + : await addAgent(data, account!); const signedTransaction = await sign(tx); if (!signedTransaction) return; diff --git a/packages/apps/rwa-demo/src/hooks/getAgents.ts b/packages/apps/rwa-demo/src/hooks/getAgents.ts index dce3a27dd6..0d78cd24ba 100644 --- a/packages/apps/rwa-demo/src/hooks/getAgents.ts +++ b/packages/apps/rwa-demo/src/hooks/getAgents.ts @@ -142,7 +142,6 @@ export const useGetAgents = () => { }; const listenToAccounts = (aliases: IRecord[]) => { - console.log({ aliases }); setInnerData((v) => { return setAliasesToAccounts([...v], aliases); }); diff --git a/packages/apps/rwa-demo/src/hooks/setMaxBalance.ts b/packages/apps/rwa-demo/src/hooks/setCompliance.ts similarity index 77% rename from packages/apps/rwa-demo/src/hooks/setMaxBalance.ts rename to packages/apps/rwa-demo/src/hooks/setCompliance.ts index b812275458..74ec17f43a 100644 --- a/packages/apps/rwa-demo/src/hooks/setMaxBalance.ts +++ b/packages/apps/rwa-demo/src/hooks/setCompliance.ts @@ -1,19 +1,19 @@ import { interpretErrorMessage } from '@/components/TransactionsProvider/TransactionsProvider'; -import type { ISetMaxBalanceProps } from '@/services/setMaxBalance'; -import { setMaxBalance } from '@/services/setMaxBalance'; +import type { ISetComplianceProps } from '@/services/setCompliance'; +import { setCompliance } from '@/services/setCompliance'; import { getClient } from '@/utils/client'; import { useNotifications } from '@kadena/kode-ui/patterns'; import { useAccount } from './account'; import { useTransactions } from './transactions'; -export const useSetMaxBalance = () => { +export const useSetCompliance = () => { const { account, sign } = useAccount(); const { addTransaction } = useTransactions(); const { addNotification } = useNotifications(); - const submit = async (data: ISetMaxBalanceProps) => { + const submit = async (data: ISetComplianceProps) => { try { - const tx = await setMaxBalance(data, account!); + const tx = await setCompliance(data, account!); const signedTransaction = await sign(tx); if (!signedTransaction) return; diff --git a/packages/apps/rwa-demo/src/hooks/setMaxSupply.ts b/packages/apps/rwa-demo/src/hooks/setMaxSupply.ts deleted file mode 100644 index 734444c543..0000000000 --- a/packages/apps/rwa-demo/src/hooks/setMaxSupply.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { interpretErrorMessage } from '@/components/TransactionsProvider/TransactionsProvider'; -import type { ISetMaxSupplyProps } from '@/services/setMaxSupply'; -import { setMaxSupply } from '@/services/setMaxSupply'; -import { getClient } from '@/utils/client'; -import { useNotifications } from '@kadena/kode-ui/patterns'; -import { useAccount } from './account'; -import { useTransactions } from './transactions'; - -export const useSetMaxSupply = () => { - const { account, sign } = useAccount(); - const { addTransaction } = useTransactions(); - const { addNotification } = useNotifications(); - - const submit = async (data: ISetMaxSupplyProps) => { - try { - const tx = await setMaxSupply(data, account!); - - const signedTransaction = await sign(tx); - if (!signedTransaction) return; - - const client = getClient(); - const res = await client.submit(signedTransaction); - - return addTransaction({ - ...res, - type: 'SETMAXBALANCE', - }); - } catch (e: any) { - addNotification({ - intent: 'negative', - label: 'there was an error', - message: interpretErrorMessage(e.message), - }); - } - }; - - return { submit }; -}; diff --git a/packages/apps/rwa-demo/src/services/addAgent.ts b/packages/apps/rwa-demo/src/services/addAgent.ts index a07a294788..f4c20f29f5 100644 --- a/packages/apps/rwa-demo/src/services/addAgent.ts +++ b/packages/apps/rwa-demo/src/services/addAgent.ts @@ -3,11 +3,22 @@ import { getNetwork } from '@/utils/client'; import { getAsset } from '@/utils/getAsset'; import { Pact } from '@kadena/client'; +export const AGENTROLES = { + AGENTADMIN: 'agent-admin', + SUPPLYMODIFIER: 'supply-modifier', + FREEZER: 'freezer', + TRANSFERMANAGER: 'transfer-manager', + RECOVERY: 'recovery', + COMPLIANCE: 'compliance', + WHITELISTMANAGER: 'whitelist-manager', +} as const; + export interface IAddAgentProps { accountName: string; agent: IWalletAccount; alias: string; alreadyExists?: boolean; + roles: (keyof typeof AGENTROLES)[]; } const createPubKeyFromAccount = (account: string): string => { @@ -35,15 +46,10 @@ export const addAgent = async ( keys: [createPubKeyFromAccount(data.accountName)], pred: 'keys-all', }) - .addData('roles', [ - 'agent-admin', - 'supply-modifier', - 'freezer', - 'transfer-manager', - 'recovery', - 'compliance', - 'whitelist-manager', - ]) + .addData( + 'roles', + data.roles.map((val) => AGENTROLES[val]), + ) .setNetworkId(getNetwork().networkId) .createTransaction(); diff --git a/packages/apps/rwa-demo/src/services/distributeTokens.ts b/packages/apps/rwa-demo/src/services/distributeTokens.ts index 2b12c65631..6e2b3c01d7 100644 --- a/packages/apps/rwa-demo/src/services/distributeTokens.ts +++ b/packages/apps/rwa-demo/src/services/distributeTokens.ts @@ -6,7 +6,7 @@ import { Pact } from '@kadena/client'; import { PactNumber } from '@kadena/pactjs'; export interface IDistributeTokensProps { - amount: number; + amount: string; investorAccount: string; } diff --git a/packages/apps/rwa-demo/src/services/setMaxBalance.ts b/packages/apps/rwa-demo/src/services/editAgent.ts similarity index 51% rename from packages/apps/rwa-demo/src/services/setMaxBalance.ts rename to packages/apps/rwa-demo/src/services/editAgent.ts index 5010b0c922..2dbd3a6df6 100644 --- a/packages/apps/rwa-demo/src/services/setMaxBalance.ts +++ b/packages/apps/rwa-demo/src/services/editAgent.ts @@ -1,28 +1,31 @@ import type { IWalletAccount } from '@/components/AccountProvider/utils'; import { getNetwork } from '@/utils/client'; +import { getAsset } from '@/utils/getAsset'; import { Pact } from '@kadena/client'; -import { PactNumber } from '@kadena/pactjs'; +import type { IAddAgentProps } from './addAgent'; +import { AGENTROLES } from './addAgent'; -export interface ISetMaxBalanceProps { - maxBalance: number; -} - -export const setMaxBalance = async ( - data: ISetMaxBalanceProps, +export const editAgent = async ( + data: IAddAgentProps, account: IWalletAccount, ) => { return Pact.builder .execution( - ` (RWA.max-balance-compliance.set-max-balance ${new PactNumber(data.maxBalance).toPactDecimal().decimal})`, + `(RWA.${getAsset()}.update-agent-roles (read-string 'agent) (read-msg 'roles))`, ) .setMeta({ senderAccount: account.address, chainId: getNetwork().chainId, }) .addSigner(account.keyset.guard.keys[0], (withCap) => [ - withCap(`RWA.max-balance-compliance.ONLY-OWNER`), + withCap(`RWA.${getAsset()}.ONLY-AGENT`, 'agent-admin'), withCap(`coin.GAS`), ]) + .addData('agent', data.accountName) + .addData( + 'roles', + data.roles.map((val) => AGENTROLES[val]), + ) .setNetworkId(getNetwork().networkId) .createTransaction(); diff --git a/packages/apps/rwa-demo/src/services/getAssetMaxSupplyBalance.ts b/packages/apps/rwa-demo/src/services/getAssetMaxSupplyBalance.ts new file mode 100644 index 0000000000..f4d6554502 --- /dev/null +++ b/packages/apps/rwa-demo/src/services/getAssetMaxSupplyBalance.ts @@ -0,0 +1,34 @@ +import { getClient, getNetwork } from '@/utils/client'; +import { Pact } from '@kadena/client'; + +export interface IGetAssetMaxSupplyBalanceResult { + maxSupply: number; + maxBalance: number; +} + +export const getAssetMaxSupplyBalance = + async (): Promise => { + const client = getClient(); + + const transaction = Pact.builder + .execution(`(RWA.max-balance-compliance.get-max-balance-max-supply)`) + .setMeta({ + chainId: getNetwork().chainId, + }) + .setNetworkId(getNetwork().networkId) + .createTransaction(); + + const { result } = await client.local(transaction, { + preflight: false, + signatureVerification: false, + }); + + const data = (result as any).data as any; + + return result.status === 'success' + ? ({ + maxBalance: data['max-balance-per-investor'], + maxSupply: data['max-supply'], + } as IGetAssetMaxSupplyBalanceResult) + : { maxBalance: -1, maxSupply: -1 }; + }; diff --git a/packages/apps/rwa-demo/src/services/getFrozenTokens.ts b/packages/apps/rwa-demo/src/services/getFrozenTokens.ts new file mode 100644 index 0000000000..6cd519b86a --- /dev/null +++ b/packages/apps/rwa-demo/src/services/getFrozenTokens.ts @@ -0,0 +1,32 @@ +import type { IWalletAccount } from '@/components/AccountProvider/utils'; +import { getClient, getNetwork } from '@/utils/client'; +import { getAsset } from '@/utils/getAsset'; +import { Pact } from '@kadena/client'; + +export interface IGetBalanceProps { + investorAccount: string; + account: IWalletAccount; +} + +export const getFrozenTokens = async (data: IGetBalanceProps) => { + const client = getClient(); + + const transaction = Pact.builder + .execution( + `(RWA.${getAsset()}.get-frozen-tokens (read-string 'user-address))`, + ) + .setMeta({ + senderAccount: data.account.address, + chainId: getNetwork().chainId, + }) + .addData('user-address', data.investorAccount) + .setNetworkId(getNetwork().networkId) + .createTransaction(); + + const { result } = await client.local(transaction, { + preflight: false, + signatureVerification: false, + }); + + return result.status === 'success' ? result.data : undefined; +}; diff --git a/packages/apps/rwa-demo/src/services/isFrozen.ts b/packages/apps/rwa-demo/src/services/isFrozen.ts index aca6722232..06fdd0fef4 100644 --- a/packages/apps/rwa-demo/src/services/isFrozen.ts +++ b/packages/apps/rwa-demo/src/services/isFrozen.ts @@ -12,7 +12,7 @@ export const isFrozen = async (data: IIsFrozenProps) => { const client = getClient(); const transaction = Pact.builder - .execution(`(RWA.${getAsset()}.is-frozen (read-string 'investor))`) + .execution(`(RWA.${getAsset()}.address-frozen (read-string 'investor))`) .setMeta({ senderAccount: data.account.address, chainId: getNetwork().chainId, diff --git a/packages/apps/rwa-demo/src/services/setMaxSupply.ts b/packages/apps/rwa-demo/src/services/setCompliance.ts similarity index 64% rename from packages/apps/rwa-demo/src/services/setMaxSupply.ts rename to packages/apps/rwa-demo/src/services/setCompliance.ts index 552c761fe9..654f4882f2 100644 --- a/packages/apps/rwa-demo/src/services/setMaxSupply.ts +++ b/packages/apps/rwa-demo/src/services/setCompliance.ts @@ -3,17 +3,18 @@ import { getNetwork } from '@/utils/client'; import { Pact } from '@kadena/client'; import { PactNumber } from '@kadena/pactjs'; -export interface ISetMaxSupplyProps { - maxSupply: number; +export interface ISetComplianceProps { + maxBalance: string; + maxSupply: string; } -export const setMaxSupply = async ( - data: ISetMaxSupplyProps, +export const setCompliance = async ( + data: ISetComplianceProps, account: IWalletAccount, ) => { return Pact.builder .execution( - `(RWA.max-balance-compliance.set-max-supply ${new PactNumber(data.maxSupply).toPactDecimal().decimal})`, + ` (RWA.max-balance-compliance.set-max-balance-and-max-supply ${new PactNumber(data.maxSupply).toPactDecimal().decimal} ${new PactNumber(data.maxBalance).toPactDecimal().decimal})`, ) .setMeta({ senderAccount: account.address, diff --git a/packages/apps/rwa-demo/src/services/supply.ts b/packages/apps/rwa-demo/src/services/supply.ts index 5755c5c4ff..295ec89aba 100644 --- a/packages/apps/rwa-demo/src/services/supply.ts +++ b/packages/apps/rwa-demo/src/services/supply.ts @@ -10,6 +10,8 @@ export interface ISupplyProps { export const supply = async (data: ISupplyProps) => { const client = getClient(); + if (!data.account) return; + const transaction = Pact.builder .execution(`(RWA.${getAsset()}.supply)`) .setMeta({ diff --git a/packages/apps/rwa-demo/src/services/togglePartiallyFreezeTokens.ts b/packages/apps/rwa-demo/src/services/togglePartiallyFreezeTokens.ts index bd00678f07..6c2eb5e78b 100644 --- a/packages/apps/rwa-demo/src/services/togglePartiallyFreezeTokens.ts +++ b/packages/apps/rwa-demo/src/services/togglePartiallyFreezeTokens.ts @@ -5,7 +5,7 @@ import { Pact } from '@kadena/client'; import { PactNumber } from '@kadena/pactjs'; export interface ITogglePartiallyFreezeTokensProps { - amount: number; + amount: string; investorAccount: string; freeze?: boolean; } diff --git a/packages/apps/rwa-demo/src/utils/setAliasesToAccounts.ts b/packages/apps/rwa-demo/src/utils/setAliasesToAccounts.ts index a9afd1e6c7..bc198b9044 100644 --- a/packages/apps/rwa-demo/src/utils/setAliasesToAccounts.ts +++ b/packages/apps/rwa-demo/src/utils/setAliasesToAccounts.ts @@ -1,5 +1,4 @@ export const setAliasesToAccounts = (accounts: any[], aliases: any[]) => { - console.log(); return accounts.map((account) => { const alias = aliases.find( ({ accountName }) => accountName === account.accountName, From b844b59d30a77746ab44ed7afc2ec946f95d2c13 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Mon, 9 Dec 2024 09:34:33 +0100 Subject: [PATCH 097/103] chore(wallet-sdk): fix turbo output --- packages/libs/wallet-sdk/turbo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/libs/wallet-sdk/turbo.json b/packages/libs/wallet-sdk/turbo.json index 17b04c3869..b8787cdcfa 100644 --- a/packages/libs/wallet-sdk/turbo.json +++ b/packages/libs/wallet-sdk/turbo.json @@ -4,7 +4,7 @@ "tasks": { "build": { "dependsOn": ["^build"], - "outputs": ["dist/**"], + "outputs": ["lib/**"], "outputLogs": "new-only" } } From 898f3b72c797a90b30a764cb8a8ff553e12e83c7 Mon Sep 17 00:00:00 2001 From: de-nial-lo Date: Mon, 9 Dec 2024 10:49:22 +0100 Subject: [PATCH 098/103] hd-wallet - cleanup docs to match wallet-sdk (#2660) * chore(hd-wallet) cleanup docs to match wallet-sdk * fix(hd-wallet): apply docs feedback * fix(hd-wallet): more docs feedback --------- Co-authored-by: Bart Huijgen --- packages/libs/hd-wallet/README.md | 347 +++++++++++++++++++++++------- 1 file changed, 271 insertions(+), 76 deletions(-) diff --git a/packages/libs/hd-wallet/README.md b/packages/libs/hd-wallet/README.md index dbd1f73264..e177c42787 100644 --- a/packages/libs/hd-wallet/README.md +++ b/packages/libs/hd-wallet/README.md @@ -51,128 +51,273 @@ The library is divided into two parts: Below are some common use cases for the `@kadena/hd-wallet` library. -### Generating a Mnemonic +## Key Concepts -A mnemonic is a set of words that can be used to generate a seed. You can -generate a mnemonic using `kadenaGenMnemonic`: +- **Mnemonic Phrase**: A human-readable set of words derived from entropy, + designed to make cryptographic keys easier to back up and restore. It serves + as a representation of the underlying entropy. +- **Seed**: A binary value derived from the mnemonic phrase (using a hashing + algorithm, optionally with a passphrase). The seed is used to derive the + master private key. It cannot be converted back to the mnemonic or entropy. +- **Derivation Path**: A structured way to derive multiple key pairs from a + single master seed. +- **[SLIP-0010](https://github.com/kadena-community/kadena.js/blob/main/packages/libs/hd-wallet/docs/decisions/0001-use-slip10-for-private-key-generation.md)**: + The standard used for key derivation, ensuring compatibility with other + systems. +- **[KIP-0026 (draft)](https://github.com/Takadenoshi/KIPs/blob/kip-0026/kip-0026.md)** + Key Derivation and Mnemonic encoding methods for Kadena + +## High-Level Steps + +1. **Generate a Mnemonic Phrase** +2. **Convert Mnemonic to Seed** +3. **Generate Key Pairs from Seed** +4. **Sign Transactions with Keys** + +## Key Generation and Management + +### 1. Generating a Mnemonic Phrase + +A mnemonic phrase is the starting point for creating your wallet. It is a +sequence of words that encodes the seed for generating keys. You can generate a +12-word mnemonic phrase using the following function: ```javascript import { kadenaGenMnemonic } from '@kadena/hd-wallet'; const mnemonic = kadenaGenMnemonic(); -console.log(mnemonic); // Outputs a 12-word mnemonic +console.log(mnemonic); // Outputs a 12-word mnemonic phrase ``` -### Converting Mnemonic to Seed +### 2. Convert Entropy to Mnemonic + +You can also generate a mnemonic phrase from a specific entropy value using the +following function: -Once you have a mnemonic, you can convert it to a seed using -`kadenaMnemonicToSeed`. This seed can be encrypted with a password for added -security: +> **IMPORTANT** +> This isn't necessarily the same mnemonic from which the entropy was generated ```javascript -import { kadenaGenMnemonic, kadenaMnemonicToSeed } from '@kadena/hd-wallet'; +import { kadenaEntropyToMnemonic } from '@kadena/hd-wallet'; -const password = 'password'; -const mnemonic = kadenaGenMnemonic(); -const seed = await kadenaMnemonicToSeed(password, mnemonic); -console.log(seed); // Outputs an encrypted seed string +const entropy = Uint8Array.from([ + 163, 41, 221, 226, 205, 60, 81, 126, 184, 28, 50, 202, 148, 255, 178, 6, +]); +const mnemonic = kadenaEntropyToMnemonic(entropy); +console.log(mnemonic); // Outputs: "permit exclude judge omit shallow satisfy there main skin pony uncle arrive" ``` -### Signing a Transaction with Seed +### 3. Mnemonic to Seed Conversion -You can sign a transaction using a seed and an index. First, create a signer -using `kadenaSignWithSeed`: +Once a mnemonic is generated, you can convert it into a seed. The seed can then +be used to derive keys. This example shows how to encrypt the seed with a +password. ```javascript -import { - kadenaGenMnemonic, - kadenaMnemonicToSeed, - kadenaSignWithSeed, -} from '@kadena/hd-wallet'; +import { kadenaMnemonicToSeed } from '@kadena/hd-wallet'; -const password = 'password'; -const mnemonic = kadenaGenMnemonic(); -const seed = await kadenaMnemonicToSeed(password, mnemonic); -const index = 0; -const hash = 'transaction-hash'; +const mnemonic = + 'permit exclude judge omit shallow satisfy there main skin pony uncle arrive'; +const password = 'secret'; -const signer = kadenaSignWithSeed(password, seed, index); -const signature = await signer(hash); -console.log(signature); // Outputs the signature +const seed = await kadenaMnemonicToSeed(password, mnemonic); +console.log(seed); // Outputs the encrypted seed, this can be different every time due to included salt +// Output: "VmVDaFBDT2RtTVU2YXJPbll3dW8zUT09LjdHZUhqQkg5ZUlBdjRhWXouRjN2cTBOdHpGeW1aSEdkaW01ZDZQZ3kvZzl0ZytyUS9FZkdtMElvTWY1aHRDcVV1UCthTXIyWGtJZXVYSjZDUVRsQXdZREdTUTZZekRVTDVnK0lnaWRIYmhPRDB0TlNhWkxldHFnL3lOdVU9" ``` -### Generating a Key Pair from Seed +### 4. Key Pair Generation from Seed -Generate a key pair (public and private keys) from a seed using -`kadenaGenKeypairFromSeed`: +The `kadenaGenKeypairFromSeed` function generates a public-private key pair from +a seed. You can specify an index or range of indices to generate multiple key +pairs. ```javascript -import { - kadenaGenKeypairFromSeed, - kadenaGenMnemonic, - kadenaMnemonicToSeed, -} from '@kadena/hd-wallet'; - -const password = 'password'; -const mnemonic = kadenaGenMnemonic(); -const seed = await kadenaMnemonicToSeed(password, mnemonic); +import { kadenaGenKeypairFromSeed } from '@kadena/hd-wallet'; +const password = 'your_password'; const [publicKey, privateKey] = await kadenaGenKeypairFromSeed( password, seed, 0, ); -// Outputs the public key and encrypted private key -console.log(publicKey, privateKey); + +console.log(publicKey, privateKey); // Outputs the generated key pair ``` -### Signing a Transaction with Key Pair +You can also generate a range of key pairs: -Sign a transaction using a key pair (public and private keys) with -`kadenaSignWithKeyPair`: +```javascript +const keyPairs = await kadenaGenKeypairFromSeed(password, seed, [0, 3]); +console.log(keyPairs); // Outputs an array of key pairs +``` + +### 5. Generate Random Key Pairs + +In some cases, you may want to generate key pairs randomly without deriving them +from a seed. Use the `kadenaKeyPairsFromRandom` function to generate a specified +number of random key pairs: ```javascript -import { - kadenaGenKeypairFromSeed, - kadenaGenMnemonic, - kadenaMnemonicToSeed, - kadenaSignWithKeyPair, -} from '@kadena/hd-wallet'; +import { kadenaKeyPairsFromRandom } from '@kadena/hd-wallet'; -const password = 'password'; -const mnemonic = kadenaGenMnemonic(); -const seed = await kadenaMnemonicToSeed(password, mnemonic); -const [publicKey, privateKey] = await kadenaGenKeypairFromSeed( - password, - seed, - 0, -); +const keyPairs = kadenaKeyPairsFromRandom(2); // Generates two random key pairs +console.log(keyPairs); // Outputs an array of random key pairs +``` + +### 6. Public Key Retrieval + +You can retrieve the public key directly from the encrypted seed without the +need to access the private key. This is useful for read-only operations. + +```javascript +import { kadenaGetPublic } from '@kadena/hd-wallet'; -const txHash = 'tx-hash'; -const signer = kadenaSignWithKeyPair(password, publicKey, privateKey); -const signature = await signer(txHash); -console.log(signature); // Outputs the signature +const publicKey = await kadenaGetPublic(password, seed, 0); +console.log(publicKey); // Outputs the public key for the specified index ``` -### Retrieving Public Keys from Seed +### 7. Signing Transactions -Retrieve public keys from a seed using `kadenaGetPublic`: +To sign a transaction, you can either use a key pair or the encrypted seed with +an index. The following example demonstrates signing a transaction with a key +pair. ```javascript -import { - kadenaGenMnemonic, - kadenaGetPublic, - kadenaMnemonicToSeed, -} from '@kadena/hd-wallet'; +import { kadenaSignWithKeyPair } from '@kadena/hd-wallet'; + +const signFn = kadenaSignWithKeyPair(password, publicKey, privateKey); +const signature = await signFn(txHash); +console.log(signature); // Outputs the transaction signature +``` + +Alternatively, you can sign using a seed and index: + +```javascript +import { kadenaSignWithSeed } from '@kadena/hd-wallet'; + +const signature = await kadenaSignWithSeed(password, seed, 0)(txHash); +console.log(signature); // Outputs the transaction signature +``` + +### 8. Verifying Signatures + +After signing a transaction, you may need to verify its signature. The +`kadenaVerify` function allows you to verify that a given signature matches the +public key and message. + +```javascript +import { kadenaVerify } from '@kadena/hd-wallet'; + +const isValid = kadenaVerify(txHash, publicKey, signature.sig); +console.log(isValid); // Outputs true if the signature is valid +``` + +## Legacy Chainweaver (version 2) Support + +For backward compatibility with the legacy Chainweaver wallet, use the following +functions. These functions allow integration with older systems while +maintaining compatibility with the new Kadena SDK. + +### Mnemonic Generation (Legacy) + +The `kadenaGenMnemonic` function from the legacy Chainweaver wallet generates a +mnemonic phrase, which is similar to modern HD wallets but follows older +practices. + +```javascript +import { kadenaGenMnemonic } from '@kadena/hd-wallet/chainweaver'; -const password = 'password'; const mnemonic = kadenaGenMnemonic(); -const seed = await kadenaMnemonicToSeed(password, mnemonic); +console.log(mnemonic); // Outputs a 12-word mnemonic phrase +``` + +### Mnemonic Validation (Legacy) + +To validate a mnemonic, use the `kadenaCheckMnemonic` function to ensure the +mnemonic is correct before proceeding with key generation. + +```javascript +import { kadenaCheckMnemonic } from '@kadena/hd-wallet/chainweaver'; + +const isValid = kadenaCheckMnemonic(mnemonic); +console.log(isValid); // Outputs true if the mnemonic is valid +``` + +### Key Pair Generation (Legacy) + +The legacy function `kadenaGenKeypair` allows generating a key pair using a seed +phrase. This method follows the older Chainweaver key derivation process. + +```javascript +import { kadenaGenKeypair } from '@kadena/hd-wallet/chainweaver'; -const publicKeyIndex0 = await kadenaGetPublic(password, seed, 0); -const publicKeyIndex1 = await kadenaGetPublic(password, seed, 1); +const [publicKey, privateKey] = await kadenaGenKeypair(seed, password, 0); +console.log(publicKey, privateKey); // Outputs the key pair generated using Chainweaver's method +``` + +### Password Change for Seed (Legacy) + +If you need to change the password used to encrypt a seed in the legacy system, +the `kadenaChangePassword` function handles the re-encryption. + +```javascript +import { kadenaChangePassword } from '@kadena/hd-wallet/chainweaver'; + +const newSeed = await kadenaChangePassword(oldPassword, newPassword, seed); +console.log(newSeed); // Outputs the seed encrypted with the new password +``` + +### Signing with a Key Pair (Legacy) + +To sign a transaction with a key pair in the legacy Chainweaver wallet, use the +`kadenaSign` function. + +```javascript +import { kadenaSign } from '@kadena/hd-wallet/chainweaver'; + +const signature = await kadenaSign(publicKey, privateKey, txHash); +console.log(signature); // Outputs the transaction signature using the legacy key pair +``` + +### Public Key Retrieval from Root Key (Legacy) + +To retrieve the public key from the root key, use the +`kadenaGetPublicFromRootKey` function. This function derives the public key from +the legacy Chainweaver’s root key. + +```javascript +import { kadenaGetPublicFromRootKey } from '@kadena/hd-wallet/chainweaver'; + +const publicKey = await kadenaGetPublicFromRootKey(password, seed, index); +console.log(publicKey); // Outputs the public key for the specified index using the root key +``` + +### Key Pair Generation from Root Key (Legacy) + +If you need to generate a key pair from the root key in the legacy system, use +the `kadenaMnemonicToRootKeypair` function. + +```javascript +import { kadenaMnemonicToRootKeypair } from '@kadena/hd-wallet/chainweaver'; + +const [publicKey, privateKey] = await kadenaMnemonicToRootKeypair( + mnemonic, + password, + index, +); +console.log(publicKey, privateKey); // Outputs the key pair derived from the root key in the legacy system +``` + +### Signing from Root Key (Legacy) + +To sign a transaction using a root key, the `kadenaSignFromRootKey` function can +be used to derive the signature from the root key. + +```javascript +import { kadenaSignFromRootKey } from '@kadena/hd-wallet/chainweaver'; -console.log(publicKeyIndex0, publicKeyIndex1); // Outputs public keys for index 0 and 1 +const signature = await kadenaSignFromRootKey(password, seed, index, txHash); +console.log(signature); // Outputs the transaction signature using the root key ``` ### Decrypting Seed or Private Key @@ -186,6 +331,56 @@ const decryptedSeed = kadenaDecrypt(password, seed); console.log(decryptedSeed); // Outputs the decrypted seed ``` +## Integration Guide for Developers + +### How to Use in Your Wallet Application + +If you’re building a wallet application, you can integrate these key generation +and signing functionalities directly. Here’s a simple flow for implementation: + +1. **Generate a mnemonic phrase** and store it securely (e.g., show the user + their backup phrase). +2. **Convert the mnemonic to a seed** and encrypt it with a password before + storing. +3. **Generate key pairs as needed** using indices (e.g., index 0 for the primary + account, index 1 for a secondary account). +4. **Sign transactions** with the private key or directly with the seed. +5. **Retrieve public keys** when you need to display addresses or verify + signatures. + +### Key Derivation Path + +The Kadena wallet uses the standard derivation path +([SLIP-0010](https://github.com/kadena-community/kadena.js/blob/main/packages/libs/hd-wallet/docs/decisions/0001-use-slip10-for-private-key-generation.md)): + +``` +m'/44'/626'/' +``` + + + +### Architectural decisions + +Check [ADRs][1] documents for more information + +# Getting started + +## Installation + +To install the library, you can use npm or yarn: + +```sh +npm install @kadena/wallet-sdk +``` + +or + +```sh +yarn add @kadena/wallet-sdk +``` + +[1]: ./docs/decisions/ + ## Conclusion The `@kadena/hd-wallet` library offers a robust set of tools for generating From 2b0b87dad36e08f42dad9a8d71e6a13b59f573c0 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Mon, 9 Dec 2024 10:53:59 +0100 Subject: [PATCH 099/103] chore(wallet-sdk): add changeset for 0.1.0 --- .changeset/nervous-pears-remain.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .changeset/nervous-pears-remain.md diff --git a/.changeset/nervous-pears-remain.md b/.changeset/nervous-pears-remain.md new file mode 100644 index 0000000000..c2aae90fb9 --- /dev/null +++ b/.changeset/nervous-pears-remain.md @@ -0,0 +1,9 @@ +--- +'@kadena/wallet-sdk': minor +--- + +The Kadena Wallet SDK provides a simple and unified interface to integrate +Kadena blockchain functionalities into your wallet applications. It abstracts +the complexities of interacting with the Kadena network, allowing you to focus +on building feature-rich wallet experiences without re-implementing common +integrations. From 8615d097e5f3d5312446cd13520546cfa43ba4a4 Mon Sep 17 00:00:00 2001 From: Bart Huijgen Date: Mon, 9 Dec 2024 10:56:05 +0100 Subject: [PATCH 100/103] chore(hd-wallet): changeset for updated readme --- .changeset/pink-camels-float.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pink-camels-float.md diff --git a/.changeset/pink-camels-float.md b/.changeset/pink-camels-float.md new file mode 100644 index 0000000000..edac037ab2 --- /dev/null +++ b/.changeset/pink-camels-float.md @@ -0,0 +1,5 @@ +--- +'@kadena/hd-wallet': patch +--- + +Improved documentation in readme From ea017877659af40adb89fda42d8262e4125c78d4 Mon Sep 17 00:00:00 2001 From: Bart <45095973+barthuijgen@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:01:03 +0100 Subject: [PATCH 101/103] fix(rwa-demo): set local packages to workspace (#2720) Co-authored-by: Bart Huijgen --- packages/apps/rwa-demo/package.json | 4 +- pnpm-lock.yaml | 78 +++++++---------------------- 2 files changed, 19 insertions(+), 63 deletions(-) diff --git a/packages/apps/rwa-demo/package.json b/packages/apps/rwa-demo/package.json index 5ead245a13..6dbbad2064 100644 --- a/packages/apps/rwa-demo/package.json +++ b/packages/apps/rwa-demo/package.json @@ -19,7 +19,7 @@ "@apollo/client": "~3.9.11", "@graphql-yoga/apollo-link": "~3.3.0", "@hookform/resolvers": "^3.2.0", - "@kadena/client": "^1.15.0", + "@kadena/client": "workspace:*", "@kadena/cryptography-utils": "workspace:*", "@kadena/graph": "workspace:*", "@kadena/kode-icons": "workspace:*", @@ -49,7 +49,7 @@ "@kadena-dev/lint-package": "workspace:*", "@kadena-dev/shared-config": "workspace:*", "@kadena/pactjs": "workspace:*", - "@kadena/pactjs-cli": "^1.15.0", + "@kadena/pactjs-cli": "workspace:*", "@kadena/pactjs-generator": "workspace:*", "@types/node": "^20.12.7", "@types/react": "^18.2.79", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ca12cf845b..2ccd1fa563 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1280,8 +1280,8 @@ importers: specifier: ^3.2.0 version: 3.7.0(react-hook-form@7.52.1(react@18.3.1)) '@kadena/client': - specifier: ^1.15.0 - version: 1.15.0(encoding@0.1.13) + specifier: workspace:* + version: link:../../libs/client '@kadena/cryptography-utils': specifier: workspace:* version: link:../../libs/cryptography-utils @@ -1362,8 +1362,8 @@ importers: specifier: workspace:* version: link:../../tools/shared-config '@kadena/pactjs-cli': - specifier: ^1.15.0 - version: 1.15.0(encoding@0.1.13) + specifier: workspace:* + version: link:../../tools/pactjs-cli '@kadena/pactjs-generator': specifier: workspace:* version: link:../../libs/pactjs-generator @@ -6108,13 +6108,6 @@ packages: '@kadena/kode-ui@0.13.0': resolution: {integrity: sha512-zC8gIwduMKxDonoclMvYlcHSWwVzD4ZRWaM9s4Sgs5AK2zAZK17ioPW7SNxQV9+bNcCChcAuUMUZAyshT5YzPw==} - '@kadena/pactjs-cli@1.15.0': - resolution: {integrity: sha512-67gm8MO+jgfLdn8f/Cj8eJPDSZUgtRJIyd7P+jUSSb22omXaVqDVN7Za48o6tYTKdUm35+ydqvFXQ5Ilvf4Lng==} - hasBin: true - - '@kadena/pactjs-generator@1.15.0': - resolution: {integrity: sha512-uj6jG3J8lwolqLyIrkqNVsjTsLlBWy5hZ3nMFLgM2fcBFSMJgvNVPQlR9FNt9+jep8/QSMjskSRmXCidvRRL8w==} - '@kadena/pactjs@0.4.3': resolution: {integrity: sha512-EYqIrhw5YbGz7+10rq4QnqC9I22OfApCRfNIvrcq6Lwg0I04grFXCspgEFrgZO1ThTvG4nN0gs8DZl72HBleGw==} @@ -23832,43 +23825,6 @@ snapshots: react-dom: 18.3.1(react@18.3.1) react-stately: 3.31.1(react@18.3.1) - '@kadena/pactjs-cli@1.15.0(encoding@0.1.13)': - dependencies: - '@kadena/client': 1.15.0(encoding@0.1.13) - '@kadena/pactjs-generator': 1.15.0 - commander: 11.1.0 - cross-fetch: 3.1.8(encoding@0.1.13) - debug: 4.3.4(supports-color@5.5.0) - mkdirp: 1.0.4 - prettier: 3.2.5 - rimraf: 5.0.7 - zod: 3.23.8 - transitivePeerDependencies: - - '@azure/app-configuration' - - '@azure/cosmos' - - '@azure/data-tables' - - '@azure/identity' - - '@azure/keyvault-secrets' - - '@azure/storage-blob' - - '@capacitor/preferences' - - '@netlify/blobs' - - '@planetscale/database' - - '@react-native-async-storage/async-storage' - - '@upstash/redis' - - '@vercel/kv' - - bufferutil - - encoding - - ioredis - - supports-color - - uWebSockets.js - - utf-8-validate - - '@kadena/pactjs-generator@1.15.0': - dependencies: - memfs: 3.5.3 - moo: 0.5.2 - nearley: 2.20.1 - '@kadena/pactjs@0.4.3': dependencies: bignumber.js: 9.1.2 @@ -25503,15 +25459,13 @@ snapshots: transitivePeerDependencies: - '@parcel/core' - '@parcel/cache@2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11)': + '@parcel/cache@2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))': dependencies: '@parcel/core': 2.12.0(@swc/helpers@0.5.11) '@parcel/fs': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/logger': 2.12.0 '@parcel/utils': 2.12.0 lmdb: 2.8.5 - transitivePeerDependencies: - - '@swc/helpers' '@parcel/codeframe@2.12.0': dependencies: @@ -25571,7 +25525,7 @@ snapshots: '@parcel/core@2.12.0(@swc/helpers@0.5.11)': dependencies: '@mischnic/json-sourcemap': 0.1.1 - '@parcel/cache': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) + '@parcel/cache': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) '@parcel/diagnostic': 2.12.0 '@parcel/events': 2.12.0 '@parcel/fs': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) @@ -25584,7 +25538,7 @@ snapshots: '@parcel/source-map': 2.1.1 '@parcel/types': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/utils': 2.12.0 - '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) + '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) abortcontroller-polyfill: 1.7.5 base-x: 3.0.10 browserslist: 4.23.1 @@ -25612,7 +25566,7 @@ snapshots: '@parcel/types': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/utils': 2.12.0 '@parcel/watcher': 2.4.1 - '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) + '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) transitivePeerDependencies: - '@swc/helpers' @@ -25686,7 +25640,7 @@ snapshots: '@parcel/plugin': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) '@parcel/rust': 2.12.0 '@parcel/utils': 2.12.0 - '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) + '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/optimizer-svgo@2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))': dependencies: @@ -25718,7 +25672,7 @@ snapshots: '@parcel/node-resolver-core': 3.3.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) '@parcel/types': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/utils': 2.12.0 - '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) + '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@swc/core': 1.3.107(@swc/helpers@0.5.11) semver: 7.6.3 transitivePeerDependencies: @@ -25907,7 +25861,7 @@ snapshots: '@parcel/core': 2.12.0(@swc/helpers@0.5.11) '@parcel/plugin': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) '@parcel/utils': 2.12.0 - '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) + '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) nullthrows: 1.1.1 '@parcel/transformer-js@2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))': @@ -25918,7 +25872,7 @@ snapshots: '@parcel/rust': 2.12.0 '@parcel/source-map': 2.1.1 '@parcel/utils': 2.12.0 - '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) + '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@swc/helpers': 0.5.11 browserslist: 4.23.1 nullthrows: 1.1.1 @@ -25986,12 +25940,12 @@ snapshots: '@parcel/types@2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11)': dependencies: - '@parcel/cache': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) + '@parcel/cache': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) '@parcel/diagnostic': 2.12.0 '@parcel/fs': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/package-manager': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/source-map': 2.1.1 - '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11)) + '@parcel/workers': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) utility-types: 3.11.0 transitivePeerDependencies: - '@parcel/core' @@ -26069,7 +26023,7 @@ snapshots: '@parcel/watcher-win32-ia32': 2.4.1 '@parcel/watcher-win32-x64': 2.4.1 - '@parcel/workers@2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))': + '@parcel/workers@2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11)': dependencies: '@parcel/core': 2.12.0(@swc/helpers@0.5.11) '@parcel/diagnostic': 2.12.0 @@ -26078,6 +26032,8 @@ snapshots: '@parcel/types': 2.12.0(@parcel/core@2.12.0(@swc/helpers@0.5.11))(@swc/helpers@0.5.11) '@parcel/utils': 2.12.0 nullthrows: 1.1.1 + transitivePeerDependencies: + - '@swc/helpers' '@peculiar/asn1-schema@2.3.8': dependencies: From 0cabf05142b4ebd63fe8908e7973286d4cb81cb8 Mon Sep 17 00:00:00 2001 From: Albert G <516972+alber70g@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:44:06 +0100 Subject: [PATCH 102/103] [ci] Release (#2696) Co-authored-by: github-actions[bot] --- .changeset/afraid-parents-sparkle.md | 5 - .changeset/four-jokes-check.md | 5 - .changeset/healthy-trainers-film.md | 5 - .changeset/hungry-steaks-count.md | 6 - .changeset/khaki-forks-bake.md | 2 - .changeset/nervous-pears-remain.md | 9 - .changeset/nervous-turtles-heal.md | 5 - .changeset/perfect-rings-laugh.md | 2 - .changeset/pink-camels-float.md | 5 - .changeset/polite-bats-call.md | 5 - .changeset/slow-apples-think.md | 2 - .changeset/strange-steaks-begin.md | 2 - .changeset/tame-horses-heal.md | 2 - .changeset/twenty-cherries-study.md | 2 - packages.json | 42 +- packages/apps/dev-wallet-desktop/CHANGELOG.md | 6 + packages/apps/dev-wallet-desktop/package.json | 2 +- packages/apps/dev-wallet-example/CHANGELOG.md | 9 + packages/apps/dev-wallet-example/package.json | 2 +- packages/apps/dev-wallet/CHANGELOG.md | 18 + packages/apps/dev-wallet/package.json | 2 +- packages/apps/docs/src/data/changelogs.json | 1575 +++++++++++++++++ packages/apps/explorer/CHANGELOG.md | 11 + packages/apps/explorer/package.json | 2 +- packages/apps/graph-client/CHANGELOG.md | 11 + packages/apps/graph-client/package.json | 2 +- packages/apps/graph/CHANGELOG.md | 10 + packages/apps/graph/package.json | 2 +- .../apps/marmalade-marketplace/CHANGELOG.md | 14 + .../apps/marmalade-marketplace/package.json | 2 +- packages/apps/proof-of-us/CHANGELOG.md | 14 + packages/apps/proof-of-us/package.json | 2 +- packages/apps/rwa-demo/CHANGELOG.md | 14 + packages/apps/rwa-demo/package.json | 2 +- packages/apps/spirekey-example/CHANGELOG.md | 8 + packages/apps/spirekey-example/package.json | 2 +- packages/apps/wallet-sdk-example/CHANGELOG.md | 18 + packages/apps/wallet-sdk-example/package.json | 2 +- .../libs/chainweb-node-client/CHANGELOG.md | 6 + .../libs/chainweb-node-client/package.json | 2 +- packages/libs/client-examples/CHANGELOG.md | 10 + packages/libs/client-examples/package.json | 2 +- packages/libs/client-utils/CHANGELOG.md | 10 + packages/libs/client-utils/package.json | 2 +- packages/libs/client/CHANGELOG.md | 12 + packages/libs/client/package.json | 2 +- packages/libs/hd-wallet/CHANGELOG.md | 6 + packages/libs/hd-wallet/package.json | 2 +- packages/libs/kode-ui/CHANGELOG.md | 12 + packages/libs/kode-ui/package.json | 2 +- packages/libs/pactjs-generator/CHANGELOG.md | 2 + packages/libs/pactjs-generator/package.json | 2 +- packages/libs/wallet-sdk/CHANGELOG.md | 18 + packages/libs/wallet-sdk/package.json | 2 +- packages/tools/kadena-cli/CHANGELOG.md | 13 + packages/tools/kadena-cli/package.json | 2 +- packages/tools/pactjs-cli/CHANGELOG.md | 9 + packages/tools/pactjs-cli/package.json | 2 +- 58 files changed, 1848 insertions(+), 99 deletions(-) delete mode 100644 .changeset/afraid-parents-sparkle.md delete mode 100644 .changeset/four-jokes-check.md delete mode 100644 .changeset/healthy-trainers-film.md delete mode 100644 .changeset/hungry-steaks-count.md delete mode 100644 .changeset/khaki-forks-bake.md delete mode 100644 .changeset/nervous-pears-remain.md delete mode 100644 .changeset/nervous-turtles-heal.md delete mode 100644 .changeset/perfect-rings-laugh.md delete mode 100644 .changeset/pink-camels-float.md delete mode 100644 .changeset/polite-bats-call.md delete mode 100644 .changeset/slow-apples-think.md delete mode 100644 .changeset/strange-steaks-begin.md delete mode 100644 .changeset/tame-horses-heal.md delete mode 100644 .changeset/twenty-cherries-study.md create mode 100644 packages/apps/wallet-sdk-example/CHANGELOG.md diff --git a/.changeset/afraid-parents-sparkle.md b/.changeset/afraid-parents-sparkle.md deleted file mode 100644 index a62914ab65..0000000000 --- a/.changeset/afraid-parents-sparkle.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/kode-ui': minor ---- - -add context section in the sidebar layout header diff --git a/.changeset/four-jokes-check.md b/.changeset/four-jokes-check.md deleted file mode 100644 index f515a2043f..0000000000 --- a/.changeset/four-jokes-check.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/kode-ui': patch ---- - -fix in the sidebar header layout diff --git a/.changeset/healthy-trainers-film.md b/.changeset/healthy-trainers-film.md deleted file mode 100644 index 8d5e3f2c30..0000000000 --- a/.changeset/healthy-trainers-film.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/kode-ui': minor ---- - -add the SectionCard Component diff --git a/.changeset/hungry-steaks-count.md b/.changeset/hungry-steaks-count.md deleted file mode 100644 index eb8da1c8a5..0000000000 --- a/.changeset/hungry-steaks-count.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@kadena/chainweb-node-client': minor -'@kadena/client': minor ---- - -Support for passing a request init object to client functions diff --git a/.changeset/khaki-forks-bake.md b/.changeset/khaki-forks-bake.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/khaki-forks-bake.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/nervous-pears-remain.md b/.changeset/nervous-pears-remain.md deleted file mode 100644 index c2aae90fb9..0000000000 --- a/.changeset/nervous-pears-remain.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -'@kadena/wallet-sdk': minor ---- - -The Kadena Wallet SDK provides a simple and unified interface to integrate -Kadena blockchain functionalities into your wallet applications. It abstracts -the complexities of interacting with the Kadena network, allowing you to focus -on building feature-rich wallet experiences without re-implementing common -integrations. diff --git a/.changeset/nervous-turtles-heal.md b/.changeset/nervous-turtles-heal.md deleted file mode 100644 index 6bb663b972..0000000000 --- a/.changeset/nervous-turtles-heal.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/kode-ui': minor ---- - -add an extra styling variant to the table component diff --git a/.changeset/perfect-rings-laugh.md b/.changeset/perfect-rings-laugh.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/perfect-rings-laugh.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/pink-camels-float.md b/.changeset/pink-camels-float.md deleted file mode 100644 index edac037ab2..0000000000 --- a/.changeset/pink-camels-float.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/hd-wallet': patch ---- - -Improved documentation in readme diff --git a/.changeset/polite-bats-call.md b/.changeset/polite-bats-call.md deleted file mode 100644 index 4bd428f5a4..0000000000 --- a/.changeset/polite-bats-call.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/client': patch ---- - -Add a default value `null` for the proof diff --git a/.changeset/slow-apples-think.md b/.changeset/slow-apples-think.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/slow-apples-think.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/strange-steaks-begin.md b/.changeset/strange-steaks-begin.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/strange-steaks-begin.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/tame-horses-heal.md b/.changeset/tame-horses-heal.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/tame-horses-heal.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/twenty-cherries-study.md b/.changeset/twenty-cherries-study.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/twenty-cherries-study.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/packages.json b/packages.json index 7d5a943f9a..3341faa078 100644 --- a/packages.json +++ b/packages.json @@ -7,7 +7,7 @@ }, { "name": "@kadena/chainweb-node-client", - "version": "0.7.0", + "version": "0.8.0", "private": false, "path": "packages/libs/chainweb-node-client" }, @@ -25,19 +25,19 @@ }, { "name": "@kadena/client", - "version": "1.15.0", + "version": "1.16.0", "private": false, "path": "packages/libs/client" }, { "name": "@kadena/client-examples", - "version": "0.1.9", + "version": "0.1.10", "private": true, "path": "packages/libs/client-examples" }, { "name": "@kadena/client-utils", - "version": "0.11.0", + "version": "0.11.1", "private": false, "path": "packages/libs/client-utils" }, @@ -55,19 +55,19 @@ }, { "name": "@kadena/dev-wallet", - "version": "0.4.5", + "version": "0.4.6", "private": true, "path": "packages/apps/dev-wallet" }, { "name": "@kadena/dev-wallet-desktop", - "version": "0.0.27", + "version": "0.0.28", "private": true, "path": "packages/apps/dev-wallet-desktop" }, { "name": "@kadena/dev-wallet-example", - "version": "0.2.0", + "version": "0.2.1", "private": true, "path": "packages/apps/dev-wallet-example" }, @@ -85,25 +85,25 @@ }, { "name": "@kadena/explorer", - "version": "0.8.11", + "version": "0.8.12", "private": true, "path": "packages/apps/explorer" }, { "name": "@kadena/graph", - "version": "2.0.2", + "version": "2.0.3", "private": false, "path": "packages/apps/graph" }, { "name": "@kadena/graph-client", - "version": "0.4.9", + "version": "0.4.10", "private": true, "path": "packages/apps/graph-client" }, { "name": "@kadena/hd-wallet", - "version": "0.6.0", + "version": "0.6.1", "private": false, "path": "packages/libs/hd-wallet" }, @@ -115,7 +115,7 @@ }, { "name": "@kadena/kadena-cli", - "version": "1.3.7", + "version": "1.3.8", "private": false, "path": "packages/tools/kadena-cli" }, @@ -127,13 +127,13 @@ }, { "name": "@kadena/kode-ui", - "version": "0.19.0", + "version": "0.20.0", "private": false, "path": "packages/libs/kode-ui" }, { "name": "@kadena/marmalade-marketplace", - "version": "0.1.12", + "version": "0.1.13", "private": true, "path": "packages/apps/marmalade-marketplace" }, @@ -145,25 +145,25 @@ }, { "name": "@kadena/pactjs-cli", - "version": "1.15.0", + "version": "1.16.0", "private": false, "path": "packages/tools/pactjs-cli" }, { "name": "@kadena/pactjs-generator", - "version": "1.15.0", + "version": "1.16.0", "private": false, "path": "packages/libs/pactjs-generator" }, { "name": "@kadena/proof-of-us", - "version": "0.5.16", + "version": "0.5.17", "private": true, "path": "packages/apps/proof-of-us" }, { "name": "@kadena/rwa-demo", - "version": "0.1.3", + "version": "0.1.4", "private": true, "path": "packages/apps/rwa-demo" }, @@ -175,7 +175,7 @@ }, { "name": "@kadena/spirekey-example", - "version": "0.0.11", + "version": "0.0.12", "private": true, "path": "packages/apps/spirekey-example" }, @@ -193,7 +193,7 @@ }, { "name": "@kadena/wallet-sdk", - "version": "0.0.1", + "version": "0.1.0", "private": false, "path": "packages/libs/wallet-sdk" }, @@ -265,7 +265,7 @@ }, { "name": "wallet-sdk-example-app", - "version": "0.0.1", + "version": "0.0.2", "private": true, "path": "packages/apps/wallet-sdk-example" } diff --git a/packages/apps/dev-wallet-desktop/CHANGELOG.md b/packages/apps/dev-wallet-desktop/CHANGELOG.md index 415f385c66..b1f3ad2c5b 100644 --- a/packages/apps/dev-wallet-desktop/CHANGELOG.md +++ b/packages/apps/dev-wallet-desktop/CHANGELOG.md @@ -1,5 +1,11 @@ # @kadena/dev-wallet-desktop +## 0.0.28 + +### Patch Changes + +- @kadena/dev-wallet\@0.4.6 + ## 0.0.27 ### Patch Changes diff --git a/packages/apps/dev-wallet-desktop/package.json b/packages/apps/dev-wallet-desktop/package.json index b41c4d8e84..d5f762706f 100644 --- a/packages/apps/dev-wallet-desktop/package.json +++ b/packages/apps/dev-wallet-desktop/package.json @@ -2,7 +2,7 @@ "name": "@kadena/dev-wallet-desktop", "description": "Kadena developer wallet", "private": true, - "version": "0.0.27", + "version": "0.0.28", "type": "module", "scripts": { "dev": "tauri dev", diff --git a/packages/apps/dev-wallet-example/CHANGELOG.md b/packages/apps/dev-wallet-example/CHANGELOG.md index a91526e2aa..2c13b68377 100644 --- a/packages/apps/dev-wallet-example/CHANGELOG.md +++ b/packages/apps/dev-wallet-example/CHANGELOG.md @@ -1,5 +1,14 @@ # @kadena/dev-wallet-example +## 0.2.1 + +### Patch Changes + +- Updated dependencies \[5e9bfd0] +- Updated dependencies \[1f46bee] + - @kadena/client\@1.16.0 + - @kadena/client-utils\@0.11.1 + ## 0.2.0 ### Minor Changes diff --git a/packages/apps/dev-wallet-example/package.json b/packages/apps/dev-wallet-example/package.json index 51a65603f3..263dba0c58 100644 --- a/packages/apps/dev-wallet-example/package.json +++ b/packages/apps/dev-wallet-example/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/dev-wallet-example", - "version": "0.2.0", + "version": "0.2.1", "private": true, "scripts": { "dev": "next dev", diff --git a/packages/apps/dev-wallet/CHANGELOG.md b/packages/apps/dev-wallet/CHANGELOG.md index a978024198..7bf2b914a9 100644 --- a/packages/apps/dev-wallet/CHANGELOG.md +++ b/packages/apps/dev-wallet/CHANGELOG.md @@ -1,5 +1,23 @@ # @kadena/dev-wallet +## 0.4.6 + +### Patch Changes + +- Updated dependencies \[5c5c747] +- Updated dependencies \[f35e30c] +- Updated dependencies \[4c684a2] +- Updated dependencies \[5e9bfd0] +- Updated dependencies \[dbd9076] +- Updated dependencies \[8615d09] +- Updated dependencies \[1f46bee] + - @kadena/kode-ui\@0.20.0 + - @kadena/chainweb-node-client\@0.8.0 + - @kadena/client\@1.16.0 + - @kadena/hd-wallet\@0.6.1 + - @kadena/client-utils\@0.11.1 + - @kadena/pactjs-generator\@1.16.0 + ## 0.4.5 ### Patch Changes diff --git a/packages/apps/dev-wallet/package.json b/packages/apps/dev-wallet/package.json index 216ae4e3bf..6df2366312 100644 --- a/packages/apps/dev-wallet/package.json +++ b/packages/apps/dev-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/dev-wallet", - "version": "0.4.5", + "version": "0.4.6", "private": true, "description": "Kadena developer wallet", "type": "module", diff --git a/packages/apps/docs/src/data/changelogs.json b/packages/apps/docs/src/data/changelogs.json index 233f836b23..0e4800db12 100644 --- a/packages/apps/docs/src/data/changelogs.json +++ b/packages/apps/docs/src/data/changelogs.json @@ -28455,6 +28455,134 @@ "owner": "kadena-community", "repoName": "kadena.js", "content": { + "1.3.8": { + "label": "1.3.8", + "description": "", + "isLocked": true, + "authors": [ + { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + }, + { + "login": "barthuijgen", + "id": 45095973, + "avatar_url": "https://avatars.githubusercontent.com/u/45095973?v=4", + "html_url": "https://github.com/barthuijgen", + "url": "https://api.github.com/users/barthuijgen" + } + ], + "patches": [ + { + "label": "Updated dependencies", + "commits": [ + { + "hash": "5e9bfd0", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Fri, 06 Dec 2024 13:45:55 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "author": { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "commit": { + "message": "feat(client): support headers in client (#2611)\n\n* feat(client): suppport headers in client\r\n\r\n* refactor(client): host url\r\n\r\n* feat(client): accept request init options\r\n\r\n* fix(chainweb-client): header\r\n\r\n* test(client): add unit tests\r\n\r\n* :chore(client): clean up\r\n\r\n* chore(changeset): add log\r\n\r\n* fix(client): export type", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Updated dependencies", + "commits": [ + { + "hash": "8615d09", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Mon, 09 Dec 2024 09:56:05 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "8615d097e5f3d5312446cd13520546cfa43ba4a4", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/8615d097e5f3d5312446cd13520546cfa43ba4a4", + "author": { + "login": "barthuijgen", + "id": 45095973, + "avatar_url": "https://avatars.githubusercontent.com/u/45095973?v=4", + "html_url": "https://github.com/barthuijgen", + "url": "https://api.github.com/users/barthuijgen" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/8615d097e5f3d5312446cd13520546cfa43ba4a4/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/8615d097e5f3d5312446cd13520546cfa43ba4a4", + "commit": { + "message": "chore(hd-wallet): changeset for updated readme", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Updated dependencies \n* @kadena/client@1.16.0\n* @kadena/hd-wallet@0.6.1\n* @kadena/client-utils@0.11.1\n* @kadena/pactjs-cli@1.16.0\n* @kadena/pactjs-generator@1.16.0", + "commits": [ + { + "hash": "1f46bee", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Thu, 05 Dec 2024 11:22:59 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "1f46bee83e631a5383a17a6af223e59a42287771", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/1f46bee83e631a5383a17a6af223e59a42287771", + "author": { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/1f46bee83e631a5383a17a6af223e59a42287771/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/1f46bee83e631a5383a17a6af223e59a42287771", + "commit": { + "message": "feat(client): add default value of for proof (#1997)", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + } + ], + "minors": [], + "miscs": [], + "date": "2024-12-09T09:56:05.000Z" + }, "1.3.7": { "label": "1.3.7", "description": "", @@ -31026,6 +31154,692 @@ "owner": "kadena-io", "repoName": "chainweb-node", "content": { + "2.26.1": { + "label": "2.26.1", + "description": "This is a minor point release. Upgrading is **strongly recommended**.\n\nTo upgrade, pull the latest docker image, or download the binary and\nrestart the node with the same configuration file as before.\n", + "isLocked": true, + "authors": [ + { + "login": "larskuhtz", + "id": 1369810, + "avatar_url": "https://avatars.githubusercontent.com/u/1369810?v=4", + "html_url": "https://github.com/larskuhtz", + "url": "https://api.github.com/users/larskuhtz" + }, + { + "login": "chessai", + "id": 18648043, + "avatar_url": "https://avatars.githubusercontent.com/u/18648043?v=4", + "html_url": "https://github.com/chessai", + "url": "https://api.github.com/users/chessai" + }, + { + "login": "edmundnoble", + "id": 1369693, + "avatar_url": "https://avatars.githubusercontent.com/u/1369693?v=4", + "html_url": "https://github.com/edmundnoble", + "url": "https://api.github.com/users/edmundnoble" + }, + { + "login": "mdqst", + "id": 98899785, + "avatar_url": "https://avatars.githubusercontent.com/u/98899785?v=4", + "html_url": "https://github.com/mdqst", + "url": "https://api.github.com/users/mdqst" + } + ], + "patches": [], + "minors": [], + "miscs": [ + { + "label": "Update to Pact 4.13.2", + "commits": [ + { + "hash": "343b6e3", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Tue, 12 Nov 2024 17:02:35 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "343b6e3d9b2c771bb6a9b757a337fca1ec824e91", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/343b6e3d9b2c771bb6a9b757a337fca1ec824e91", + "author": { + "login": "larskuhtz", + "id": 1369810, + "avatar_url": "https://avatars.githubusercontent.com/u/1369810?v=4", + "html_url": "https://github.com/larskuhtz", + "url": "https://api.github.com/users/larskuhtz" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/343b6e3d9b2c771bb6a9b757a337fca1ec824e91/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/343b6e3d9b2c771bb6a9b757a337fca1ec824e91", + "commit": { + "message": "update pact pin", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Add informative error messages to pact /send API", + "commits": [ + { + "hash": "bd5d6af", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 20 Nov 2024 16:28:35 GMT", + "date": "Mon, 09 Dec 2024 14:04:40 GMT" + }, + "data": { + "sha": "bd5d6af959a986cc3cf690e0eb2180d62f78e51e", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/bd5d6af959a986cc3cf690e0eb2180d62f78e51e", + "author": { + "login": "chessai", + "id": 18648043, + "avatar_url": "https://avatars.githubusercontent.com/u/18648043?v=4", + "html_url": "https://github.com/chessai", + "url": "https://api.github.com/users/chessai" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/bd5d6af959a986cc3cf690e0eb2180d62f78e51e/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/bd5d6af959a986cc3cf690e0eb2180d62f78e51e", + "commit": { + "message": "add error messages for assertCommand failures in pact api\n\nChange-Id: Ifbad9a2e9c28810f34b80a6c02cc08d68c955cff", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Increase P2P network resiliency to unreliable nodes", + "commits": [ + { + "hash": "f784622", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 13 Nov 2024 17:16:54 GMT", + "date": "Mon, 09 Dec 2024 14:04:40 GMT" + }, + "data": { + "sha": "f7846228795ec93be82ae08ffce60ce4999e19f5", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/f7846228795ec93be82ae08ffce60ce4999e19f5", + "author": { + "login": "chessai", + "id": 18648043, + "avatar_url": "https://avatars.githubusercontent.com/u/18648043?v=4", + "html_url": "https://github.com/chessai", + "url": "https://api.github.com/users/chessai" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/f7846228795ec93be82ae08ffce60ce4999e19f5/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/f7846228795ec93be82ae08ffce60ce4999e19f5", + "commit": { + "message": "increment p2p successive failure count of failed peer syncs\n\nChange-Id: Ieca25025c414918bf1e7b2b2306b0764b0110a0e", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Compute P2P session count in O(1", + "commits": [ + { + "hash": "cab1674", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 13 Nov 2024 19:06:04 GMT", + "date": "Mon, 09 Dec 2024 14:04:40 GMT" + }, + "data": { + "sha": "cab1674ce9e25c2aba3690c219351eb7c049988a", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/cab1674ce9e25c2aba3690c219351eb7c049988a", + "author": { + "login": "edmundnoble", + "id": 1369693, + "avatar_url": "https://avatars.githubusercontent.com/u/1369693?v=4", + "html_url": "https://github.com/edmundnoble", + "url": "https://api.github.com/users/edmundnoble" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/cab1674ce9e25c2aba3690c219351eb7c049988a/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/cab1674ce9e25c2aba3690c219351eb7c049988a", + "commit": { + "message": "use M.size for session count", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Order P2P peer list by reliability", + "commits": [ + { + "hash": "c3130c9", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 13 Nov 2024 19:06:13 GMT", + "date": "Mon, 09 Dec 2024 14:04:40 GMT" + }, + "data": { + "sha": "c3130c995dcb4cd3923d8d6771acd892cf5d18b1", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/c3130c995dcb4cd3923d8d6771acd892cf5d18b1", + "author": { + "login": "edmundnoble", + "id": 1369693, + "avatar_url": "https://avatars.githubusercontent.com/u/1369693?v=4", + "html_url": "https://github.com/edmundnoble", + "url": "https://api.github.com/users/edmundnoble" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/c3130c995dcb4cd3923d8d6771acd892cf5d18b1/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/c3130c995dcb4cd3923d8d6771acd892cf5d18b1", + "commit": { + "message": "order peersList by SuccessiveFailures", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Remove unnecessary performance optimisation in P2P Peer DB update", + "commits": [ + { + "hash": "b4a4db0", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Thu, 14 Nov 2024 03:46:04 GMT", + "date": "Mon, 09 Dec 2024 14:04:40 GMT" + }, + "data": { + "sha": "b4a4db043fb2a7e1c7665e30f3e31d4f56f7e3ea", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/b4a4db043fb2a7e1c7665e30f3e31d4f56f7e3ea", + "author": { + "login": "edmundnoble", + "id": 1369693, + "avatar_url": "https://avatars.githubusercontent.com/u/1369693?v=4", + "html_url": "https://github.com/edmundnoble", + "url": "https://api.github.com/users/edmundnoble" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/b4a4db043fb2a7e1c7665e30f3e31d4f56f7e3ea/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/b4a4db043fb2a7e1c7665e30f3e31d4f56f7e3ea", + "commit": { + "message": "Remove redundant `force` calls in updatePeerDb\n\nThis code is already strict enough. ixset-typed is a set and a strict\nlist of maps. When updated, ixset-typed will force the set and maps\nto whnf, and insert the new element into a Set. Sets are strict in \ntheir elements and maps are strict in their keys, and the value type\n`PeerEntry` is itself strict in its components.", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Compute P2P peer count using faster monomorphic function", + "commits": [ + { + "hash": "9a95738", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 13 Nov 2024 22:00:48 GMT", + "date": "Mon, 09 Dec 2024 14:04:41 GMT" + }, + "data": { + "sha": "9a957388a0fac736abdb45c1cbd0d29694731247", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/9a957388a0fac736abdb45c1cbd0d29694731247", + "author": { + "login": "edmundnoble", + "id": 1369693, + "avatar_url": "https://avatars.githubusercontent.com/u/1369693?v=4", + "html_url": "https://github.com/edmundnoble", + "url": "https://api.github.com/users/edmundnoble" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/9a957388a0fac736abdb45c1cbd0d29694731247/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/9a957388a0fac736abdb45c1cbd0d29694731247", + "commit": { + "message": "compute peerCount using ixset's size function\n\nShould be faster than using the Foldable `length` because it's using\nthe default impl", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Randomize P2P peer ordering", + "commits": [ + { + "hash": "a1198fc", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Mon, 18 Nov 2024 21:15:30 GMT", + "date": "Mon, 09 Dec 2024 14:04:41 GMT" + }, + "data": { + "sha": "a1198fc61f6f50ccf8951be4e61d1967b340ed6c", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/a1198fc61f6f50ccf8951be4e61d1967b340ed6c", + "author": { + "login": "edmundnoble", + "id": 1369693, + "avatar_url": "https://avatars.githubusercontent.com/u/1369693?v=4", + "html_url": "https://github.com/edmundnoble", + "url": "https://api.github.com/users/edmundnoble" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/a1198fc61f6f50ccf8951be4e61d1967b340ed6c/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/a1198fc61f6f50ccf8951be4e61d1967b340ed6c", + "commit": { + "message": "randomized peer ordering\n\nWe randomize the peer ordering by assigning a peer a random number\nthat is used subsequently to order it with respect to other peers upon\nrequest from the /peer GET endpoint.\n\nAn alternative of generating a seed on startup that would be used to\n\"salt\" the peer ordering was considered but ran into implementation\ndifficulties and seems equivalent.", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Optimize P2P peer pruning algorithm via set deletion instead of set union", + "commits": [ + { + "hash": "75ab5b5", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Thu, 14 Nov 2024 03:46:04 GMT", + "date": "Mon, 09 Dec 2024 14:04:41 GMT" + }, + "data": { + "sha": "75ab5b5adc4843084623cfcbba6cb6683a71ac6d", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/75ab5b5adc4843084623cfcbba6cb6683a71ac6d", + "author": { + "login": "edmundnoble", + "id": 1369693, + "avatar_url": "https://avatars.githubusercontent.com/u/1369693?v=4", + "html_url": "https://github.com/edmundnoble", + "url": "https://api.github.com/users/edmundnoble" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/75ab5b5adc4843084623cfcbba6cb6683a71ac6d/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/75ab5b5adc4843084623cfcbba6cb6683a71ac6d", + "commit": { + "message": "optimize peer pruning algorithm, deleting instead of unioning", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Delete unnecessary indices in the P2P peer db", + "commits": [ + { + "hash": "5f67ad3", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 13 Nov 2024 19:05:59 GMT", + "date": "Mon, 09 Dec 2024 14:04:41 GMT" + }, + "data": { + "sha": "5f67ad35a44db0ef05ad77e5d705b3f964ee8b69", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/5f67ad35a44db0ef05ad77e5d705b3f964ee8b69", + "author": { + "login": "edmundnoble", + "id": 1369693, + "avatar_url": "https://avatars.githubusercontent.com/u/1369693?v=4", + "html_url": "https://github.com/edmundnoble", + "url": "https://api.github.com/users/edmundnoble" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/5f67ad35a44db0ef05ad77e5d705b3f964ee8b69/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/5f67ad35a44db0ef05ad77e5d705b3f964ee8b69", + "commit": { + "message": "delete some unnecessary indices in the peerdb", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Set the HTTP Server header to distinguish between the P2P and Service REST APIs", + "commits": [ + { + "hash": "4ecc5a9", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 13 Nov 2024 19:06:16 GMT", + "date": "Mon, 09 Dec 2024 14:04:42 GMT" + }, + "data": { + "sha": "4ecc5a999742e55d61c15d1c42af37362b4d4a23", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/4ecc5a999742e55d61c15d1c42af37362b4d4a23", + "author": { + "login": "edmundnoble", + "id": 1369693, + "avatar_url": "https://avatars.githubusercontent.com/u/1369693?v=4", + "html_url": "https://github.com/edmundnoble", + "url": "https://api.github.com/users/edmundnoble" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/4ecc5a999742e55d61c15d1c42af37362b4d4a23/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/4ecc5a999742e55d61c15d1c42af37362b4d4a23", + "commit": { + "message": "Set server name", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Support dependency `hashable-1.5.*`", + "commits": [ + { + "hash": "e5a05c6", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Tue, 12 Nov 2024 17:02:35 GMT", + "date": "Mon, 09 Dec 2024 14:04:42 GMT" + }, + "data": { + "sha": "e5a05c66201a841d20f50babf0b953b9d00594a4", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/e5a05c66201a841d20f50babf0b953b9d00594a4", + "author": { + "login": "larskuhtz", + "id": 1369810, + "avatar_url": "https://avatars.githubusercontent.com/u/1369810?v=4", + "html_url": "https://github.com/larskuhtz", + "url": "https://api.github.com/users/larskuhtz" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/e5a05c66201a841d20f50babf0b953b9d00594a4/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/e5a05c66201a841d20f50babf0b953b9d00594a4", + "commit": { + "message": "pact version that support hashable-1.5", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Correct node shutdown message due to old Chainweb version", + "commits": [ + { + "hash": "c0312c1", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 13 Nov 2024 02:25:48 GMT", + "date": "Mon, 09 Dec 2024 14:04:42 GMT" + }, + "data": { + "sha": "c0312c13a731b0cf8ac8227e9d18ee51442ac326", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/c0312c13a731b0cf8ac8227e9d18ee51442ac326", + "author": { + "login": "chessai", + "id": 18648043, + "avatar_url": "https://avatars.githubusercontent.com/u/18648043?v=4", + "html_url": "https://github.com/chessai", + "url": "https://api.github.com/users/chessai" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/c0312c13a731b0cf8ac8227e9d18ee51442ac326/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/c0312c13a731b0cf8ac8227e9d18ee51442ac326", + "commit": { + "message": "correct node shutdown message due to old ChainwebVersion\n\nChange-Id: Id45bc33f9fbdc799126df13c091961b03b5b1024", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Remove redundant dependency on `sbv`", + "commits": [ + { + "hash": "8d00677", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Mon, 25 Nov 2024 19:32:52 GMT", + "date": "Mon, 09 Dec 2024 14:04:42 GMT" + }, + "data": { + "sha": "8d00677d9f34107849b010d5cd27becdf2dc0852", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/8d00677d9f34107849b010d5cd27becdf2dc0852", + "author": { + "login": "larskuhtz", + "id": 1369810, + "avatar_url": "https://avatars.githubusercontent.com/u/1369810?v=4", + "html_url": "https://github.com/larskuhtz", + "url": "https://api.github.com/users/larskuhtz" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/8d00677d9f34107849b010d5cd27becdf2dc0852/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/8d00677d9f34107849b010d5cd27becdf2dc0852", + "commit": { + "message": "remove redundant sbv pin from cabal.project", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Split `ea` out into its own executable", + "commits": [ + { + "hash": "0865649", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Fri, 15 Nov 2024 15:49:33 GMT", + "date": "Mon, 09 Dec 2024 14:04:42 GMT" + }, + "data": { + "sha": "0865649fe6bf68e3ae213dbed522dd14b56ff39b", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/0865649fe6bf68e3ae213dbed522dd14b56ff39b", + "author": { + "login": "chessai", + "id": 18648043, + "avatar_url": "https://avatars.githubusercontent.com/u/18648043?v=4", + "html_url": "https://github.com/chessai", + "url": "https://api.github.com/users/chessai" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/0865649fe6bf68e3ae213dbed522dd14b56ff39b/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/0865649fe6bf68e3ae213dbed522dd14b56ff39b", + "commit": { + "message": "split ea out into its own executable\n\nChange-Id: I50906fb06cdc29c74a778fba0f673797cfdb53a6", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Split up all `cwtool` subcommands into their own executables. Only include necessary executables into the release.", + "commits": [ + { + "hash": "0cf12a2", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Tue, 19 Nov 2024 17:28:16 GMT", + "date": "Mon, 09 Dec 2024 14:04:43 GMT" + }, + "data": { + "sha": "0cf12a2975d2b82bd26473d5ddf2dca014c4f5c7", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/0cf12a2975d2b82bd26473d5ddf2dca014c4f5c7", + "author": { + "login": "chessai", + "id": 18648043, + "avatar_url": "https://avatars.githubusercontent.com/u/18648043?v=4", + "html_url": "https://github.com/chessai", + "url": "https://api.github.com/users/chessai" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/0cf12a2975d2b82bd26473d5ddf2dca014c4f5c7/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/0cf12a2975d2b82bd26473d5ddf2dca014c4f5c7", + "commit": { + "message": "make cwtool its own component; split all executables into their own.\n\nChange-Id: Ib1ee24d78c2b09e7687285e1b229e1996a214afa", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Stop going through PactService to pre-insert check an empty tx batch", + "commits": [ + { + "hash": "19f7d63", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 13 Nov 2024 21:40:12 GMT", + "date": "Mon, 09 Dec 2024 14:04:43 GMT" + }, + "data": { + "sha": "19f7d63cce2c5eed0d473047d4169417e61e1735", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/19f7d63cce2c5eed0d473047d4169417e61e1735", + "author": { + "login": "edmundnoble", + "id": 1369693, + "avatar_url": "https://avatars.githubusercontent.com/u/1369693?v=4", + "html_url": "https://github.com/edmundnoble", + "url": "https://api.github.com/users/edmundnoble" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/19f7d63cce2c5eed0d473047d4169417e61e1735/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/19f7d63cce2c5eed0d473047d4169417e61e1735", + "commit": { + "message": "stop going through PactService to pre-insert check an empty tx batch\n\nIt's extra latency that doesn't get us anything.", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Update location of `base64-bytestring` dependency to Kadena's fork", + "commits": [ + { + "hash": "5290cf1", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 13 Nov 2024 18:01:00 GMT", + "date": "Mon, 09 Dec 2024 14:04:43 GMT" + }, + "data": { + "sha": "5290cf1bc1144524789ce96988428d491090620b", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/5290cf1bc1144524789ce96988428d491090620b", + "author": { + "login": "edmundnoble", + "id": 1369693, + "avatar_url": "https://avatars.githubusercontent.com/u/1369693?v=4", + "html_url": "https://github.com/edmundnoble", + "url": "https://api.github.com/users/edmundnoble" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/5290cf1bc1144524789ce96988428d491090620b/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/5290cf1bc1144524789ce96988428d491090620b", + "commit": { + "message": "relocate base64-bytestring-kadena to kadena fork", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Fix some typos in README.md", + "commits": [ + { + "hash": "7eea51a", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Tue, 12 Nov 2024 17:03:15 GMT", + "date": "Mon, 09 Dec 2024 14:04:43 GMT" + }, + "data": { + "sha": "7eea51a5ad7b3f15abd6e24a6a6ea36f9868b688", + "url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/7eea51a5ad7b3f15abd6e24a6a6ea36f9868b688", + "author": { + "login": "mdqst", + "id": 98899785, + "avatar_url": "https://avatars.githubusercontent.com/u/98899785?v=4", + "html_url": "https://github.com/mdqst", + "url": "https://api.github.com/users/mdqst" + }, + "comments_url": "https://api.github.com/repos/kadena-io/chainweb-node/commits/7eea51a5ad7b3f15abd6e24a6a6ea36f9868b688/comments", + "html_url": "https://github.com/kadena-io/chainweb-node/commit/7eea51a5ad7b3f15abd6e24a6a6ea36f9868b688", + "commit": { + "message": "Typos Update README.md (#2032)\n\n\"inquires\"\r\nError: Incorrect word usage.\r\nCorrection: \"inquiries\"\r\n\r\n\"IMPORTANT NODE\"\r\nError: Typo.\r\nCorrection: \"IMPORTANT NOTE\"", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + } + ], + "date": "2024-11-25T19:32:52.000Z" + }, "2.26": { "label": "2.26", "description": "This is a major version update. This release replaces all previous versions.\n\nAny prior version will stop working on **2024-11-13T00:00:00Z**. Node administrators must\nupgrade to this version before that date. The 2.26 feature upgrade will\noccur at block height 5302559 which is estimated to be mined at **2024-11-14T00:00:00Z**.\n", @@ -80505,6 +81319,128 @@ "owner": "kadena-community", "repoName": "kadena.js", "content": { + "1.16.0": { + "label": "1.16.0", + "description": "", + "isLocked": true, + "authors": [ + { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + } + ], + "patches": [ + { + "label": "Add a default value `null` for the proof", + "commits": [ + { + "hash": "1f46bee", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Thu, 05 Dec 2024 11:22:59 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "1f46bee83e631a5383a17a6af223e59a42287771", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/1f46bee83e631a5383a17a6af223e59a42287771", + "author": { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/1f46bee83e631a5383a17a6af223e59a42287771/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/1f46bee83e631a5383a17a6af223e59a42287771", + "commit": { + "message": "feat(client): add default value of for proof (#1997)", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Updated dependencies \n* @kadena/chainweb-node-client@0.8.0", + "commits": [ + { + "hash": "5e9bfd0", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Fri, 06 Dec 2024 13:45:55 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "author": { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "commit": { + "message": "feat(client): support headers in client (#2611)\n\n* feat(client): suppport headers in client\r\n\r\n* refactor(client): host url\r\n\r\n* feat(client): accept request init options\r\n\r\n* fix(chainweb-client): header\r\n\r\n* test(client): add unit tests\r\n\r\n* :chore(client): clean up\r\n\r\n* chore(changeset): add log\r\n\r\n* fix(client): export type", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + } + ], + "minors": [ + { + "label": "Support for passing a request init object to client functions", + "commits": [ + { + "hash": "5e9bfd0", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Fri, 06 Dec 2024 13:45:55 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "author": { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "commit": { + "message": "feat(client): support headers in client (#2611)\n\n* feat(client): suppport headers in client\r\n\r\n* refactor(client): host url\r\n\r\n* feat(client): accept request init options\r\n\r\n* fix(chainweb-client): header\r\n\r\n* test(client): add unit tests\r\n\r\n* :chore(client): clean up\r\n\r\n* chore(changeset): add log\r\n\r\n* fix(client): export type", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + } + ], + "miscs": [], + "date": "2024-12-06T13:45:55.000Z" + }, "1.15.0": { "label": "1.15.0", "description": "", @@ -83423,6 +84359,93 @@ "owner": "kadena-community", "repoName": "kadena.js", "content": { + "0.11.1": { + "label": "0.11.1", + "description": "", + "isLocked": true, + "authors": [ + { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + } + ], + "patches": [ + { + "label": "Updated dependencies", + "commits": [ + { + "hash": "5e9bfd0", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Fri, 06 Dec 2024 13:45:55 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "author": { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "commit": { + "message": "feat(client): support headers in client (#2611)\n\n* feat(client): suppport headers in client\r\n\r\n* refactor(client): host url\r\n\r\n* feat(client): accept request init options\r\n\r\n* fix(chainweb-client): header\r\n\r\n* test(client): add unit tests\r\n\r\n* :chore(client): clean up\r\n\r\n* chore(changeset): add log\r\n\r\n* fix(client): export type", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Updated dependencies \n* @kadena/chainweb-node-client@0.8.0\n* @kadena/client@1.16.0\n* @kadena/pactjs-cli@1.16.0", + "commits": [ + { + "hash": "1f46bee", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Thu, 05 Dec 2024 11:22:59 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "1f46bee83e631a5383a17a6af223e59a42287771", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/1f46bee83e631a5383a17a6af223e59a42287771", + "author": { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/1f46bee83e631a5383a17a6af223e59a42287771/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/1f46bee83e631a5383a17a6af223e59a42287771", + "commit": { + "message": "feat(client): add default value of for proof (#1997)", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + } + ], + "minors": [], + "miscs": [], + "date": "2024-12-06T13:45:55.000Z" + }, "0.11.0": { "label": "0.11.0", "description": "", @@ -86553,6 +87576,59 @@ "owner": "kadena-community", "repoName": "kadena.js", "content": { + "0.6.1": { + "label": "0.6.1", + "description": "", + "isLocked": true, + "authors": [ + { + "login": "barthuijgen", + "id": 45095973, + "avatar_url": "https://avatars.githubusercontent.com/u/45095973?v=4", + "html_url": "https://github.com/barthuijgen", + "url": "https://api.github.com/users/barthuijgen" + } + ], + "patches": [ + { + "label": "Improved documentation in readme", + "commits": [ + { + "hash": "8615d09", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Mon, 09 Dec 2024 09:56:05 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "8615d097e5f3d5312446cd13520546cfa43ba4a4", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/8615d097e5f3d5312446cd13520546cfa43ba4a4", + "author": { + "login": "barthuijgen", + "id": 45095973, + "avatar_url": "https://avatars.githubusercontent.com/u/45095973?v=4", + "html_url": "https://github.com/barthuijgen", + "url": "https://api.github.com/users/barthuijgen" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/8615d097e5f3d5312446cd13520546cfa43ba4a4/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/8615d097e5f3d5312446cd13520546cfa43ba4a4", + "commit": { + "message": "chore(hd-wallet): changeset for updated readme", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + } + ], + "minors": [], + "miscs": [], + "date": "2024-12-09T09:56:05.000Z" + }, "0.6.0": { "label": "0.6.0", "description": "", @@ -87477,6 +88553,93 @@ "owner": "kadena-community", "repoName": "kadena.js", "content": { + "2.0.3": { + "label": "2.0.3", + "description": "", + "isLocked": true, + "authors": [ + { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + } + ], + "patches": [ + { + "label": "Updated dependencies", + "commits": [ + { + "hash": "5e9bfd0", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Fri, 06 Dec 2024 13:45:55 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "author": { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "commit": { + "message": "feat(client): support headers in client (#2611)\n\n* feat(client): suppport headers in client\r\n\r\n* refactor(client): host url\r\n\r\n* feat(client): accept request init options\r\n\r\n* fix(chainweb-client): header\r\n\r\n* test(client): add unit tests\r\n\r\n* :chore(client): clean up\r\n\r\n* chore(changeset): add log\r\n\r\n* fix(client): export type", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Updated dependencies \n* @kadena/chainweb-node-client@0.8.0\n* @kadena/client@1.16.0\n* @kadena/client-utils@0.11.1", + "commits": [ + { + "hash": "1f46bee", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Thu, 05 Dec 2024 11:22:59 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "1f46bee83e631a5383a17a6af223e59a42287771", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/1f46bee83e631a5383a17a6af223e59a42287771", + "author": { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/1f46bee83e631a5383a17a6af223e59a42287771/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/1f46bee83e631a5383a17a6af223e59a42287771", + "commit": { + "message": "feat(client): add default value of for proof (#1997)", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + } + ], + "minors": [], + "miscs": [], + "date": "2024-12-06T13:45:55.000Z" + }, "2.0.2": { "label": "2.0.2", "description": "", @@ -93734,6 +94897,137 @@ "owner": "kadena-community", "repoName": "kadena.js", "content": { + "0.8.12": { + "label": "0.8.12", + "description": "", + "isLocked": true, + "authors": [ + { + "login": "sstraatemans", + "id": 4015521, + "avatar_url": "https://avatars.githubusercontent.com/u/4015521?v=4", + "html_url": "https://github.com/sstraatemans", + "url": "https://api.github.com/users/sstraatemans" + } + ], + "patches": [ + { + "label": "Updated dependencies", + "commits": [ + { + "hash": "5c5c747", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 27 Nov 2024 07:36:07 GMT", + "date": "Mon, 09 Dec 2024 14:04:44 GMT" + }, + "data": { + "sha": "5c5c74724f2e796b8dc2b700215980251e907ae8", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5c5c74724f2e796b8dc2b700215980251e907ae8", + "author": { + "login": "sstraatemans", + "id": 4015521, + "avatar_url": "https://avatars.githubusercontent.com/u/4015521?v=4", + "html_url": "https://github.com/sstraatemans", + "url": "https://api.github.com/users/sstraatemans" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5c5c74724f2e796b8dc2b700215980251e907ae8/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/5c5c74724f2e796b8dc2b700215980251e907ae8", + "commit": { + "message": "feat(rwa): add firebase (#2689)", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Updated dependencies", + "commits": [ + { + "hash": "f35e30c", + "tries": 1 + } + ], + "prIds": [] + }, + { + "label": "Updated dependencies", + "commits": [ + { + "hash": "4c684a2", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 27 Nov 2024 15:34:44 GMT", + "date": "Mon, 09 Dec 2024 14:04:44 GMT" + }, + "data": { + "sha": "4c684a2fef84ca0ac30677f8b4d810268741caf9", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/4c684a2fef84ca0ac30677f8b4d810268741caf9", + "author": { + "login": "sstraatemans", + "id": 4015521, + "avatar_url": "https://avatars.githubusercontent.com/u/4015521?v=4", + "html_url": "https://github.com/sstraatemans", + "url": "https://api.github.com/users/sstraatemans" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/4c684a2fef84ca0ac30677f8b4d810268741caf9/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/4c684a2fef84ca0ac30677f8b4d810268741caf9", + "commit": { + "message": "feat(ui): Add the SectionCard Component (#2697)", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Updated dependencies \n* @kadena/kode-ui@0.20.0\n* @kadena/graph@2.0.3", + "commits": [ + { + "hash": "dbd9076", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Fri, 06 Dec 2024 07:10:53 GMT", + "date": "Mon, 09 Dec 2024 14:04:45 GMT" + }, + "data": { + "sha": "dbd907693d8b8451eab739740fa5cd055084d755", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/dbd907693d8b8451eab739740fa5cd055084d755", + "author": { + "login": "sstraatemans", + "id": 4015521, + "avatar_url": "https://avatars.githubusercontent.com/u/4015521?v=4", + "html_url": "https://github.com/sstraatemans", + "url": "https://api.github.com/users/sstraatemans" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/dbd907693d8b8451eab739740fa5cd055084d755/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/dbd907693d8b8451eab739740fa5cd055084d755", + "commit": { + "message": "feat(ui): extra styling variant of the table component (#2715)", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + } + ], + "minors": [], + "miscs": [], + "date": "2024-12-06T07:10:53.000Z" + }, "0.8.11": { "label": "0.8.11", "description": "", @@ -100382,6 +101676,59 @@ "owner": "kadena-community", "repoName": "kadena.js", "content": { + "0.8.0": { + "label": "0.8.0", + "description": "", + "isLocked": true, + "authors": [ + { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + } + ], + "patches": [], + "minors": [ + { + "label": "Support for passing a request init object to client functions", + "commits": [ + { + "hash": "5e9bfd0", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Fri, 06 Dec 2024 13:45:55 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "author": { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "commit": { + "message": "feat(client): support headers in client (#2611)\n\n* feat(client): suppport headers in client\r\n\r\n* refactor(client): host url\r\n\r\n* feat(client): accept request init options\r\n\r\n* fix(chainweb-client): header\r\n\r\n* test(client): add unit tests\r\n\r\n* :chore(client): clean up\r\n\r\n* chore(changeset): add log\r\n\r\n* fix(client): export type", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + } + ], + "miscs": [], + "date": "2024-12-06T13:45:55.000Z" + }, "0.7.0": { "label": "0.7.0", "description": "", @@ -101649,6 +102996,93 @@ "owner": "kadena-community", "repoName": "kadena.js", "content": { + "1.16.0": { + "label": "1.16.0", + "description": "", + "isLocked": true, + "authors": [ + { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + } + ], + "patches": [ + { + "label": "Updated dependencies", + "commits": [ + { + "hash": "5e9bfd0", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Fri, 06 Dec 2024 13:45:55 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "author": { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5e9bfd048f066431bc3988abfabd4f29bbfba6f2/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/5e9bfd048f066431bc3988abfabd4f29bbfba6f2", + "commit": { + "message": "feat(client): support headers in client (#2611)\n\n* feat(client): suppport headers in client\r\n\r\n* refactor(client): host url\r\n\r\n* feat(client): accept request init options\r\n\r\n* fix(chainweb-client): header\r\n\r\n* test(client): add unit tests\r\n\r\n* :chore(client): clean up\r\n\r\n* chore(changeset): add log\r\n\r\n* fix(client): export type", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "Updated dependencies \n* @kadena/client@1.16.0\n* @kadena/pactjs-generator@1.16.0", + "commits": [ + { + "hash": "1f46bee", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Thu, 05 Dec 2024 11:22:59 GMT", + "date": "Mon, 09 Dec 2024 14:04:39 GMT" + }, + "data": { + "sha": "1f46bee83e631a5383a17a6af223e59a42287771", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/1f46bee83e631a5383a17a6af223e59a42287771", + "author": { + "login": "javadkh2", + "id": 18360508, + "avatar_url": "https://avatars.githubusercontent.com/u/18360508?v=4", + "html_url": "https://github.com/javadkh2", + "url": "https://api.github.com/users/javadkh2" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/1f46bee83e631a5383a17a6af223e59a42287771/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/1f46bee83e631a5383a17a6af223e59a42287771", + "commit": { + "message": "feat(client): add default value of for proof (#1997)", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + } + ], + "minors": [], + "miscs": [], + "date": "2024-12-06T13:45:55.000Z" + }, "1.15.0": { "label": "1.15.0", "description": "", @@ -104206,6 +105640,15 @@ "owner": "kadena-community", "repoName": "kadena.js", "content": { + "1.16.0": { + "label": "1.16.0", + "description": "", + "isLocked": true, + "authors": [], + "patches": [], + "minors": [], + "miscs": [] + }, "1.15.0": { "label": "1.15.0", "description": "", @@ -105302,6 +106745,138 @@ "owner": "kadena-community", "repoName": "kadena.js", "content": { + "0.20.0": { + "label": "0.20.0", + "description": "", + "isLocked": true, + "authors": [ + { + "login": "sstraatemans", + "id": 4015521, + "avatar_url": "https://avatars.githubusercontent.com/u/4015521?v=4", + "html_url": "https://github.com/sstraatemans", + "url": "https://api.github.com/users/sstraatemans" + } + ], + "patches": [ + { + "label": "fix in the sidebar header layout", + "commits": [ + { + "hash": "f35e30c", + "tries": 1 + } + ], + "prIds": [] + } + ], + "minors": [ + { + "label": "add context section in the sidebar layout header", + "commits": [ + { + "hash": "5c5c747", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 27 Nov 2024 07:36:07 GMT", + "date": "Mon, 09 Dec 2024 14:04:44 GMT" + }, + "data": { + "sha": "5c5c74724f2e796b8dc2b700215980251e907ae8", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5c5c74724f2e796b8dc2b700215980251e907ae8", + "author": { + "login": "sstraatemans", + "id": 4015521, + "avatar_url": "https://avatars.githubusercontent.com/u/4015521?v=4", + "html_url": "https://github.com/sstraatemans", + "url": "https://api.github.com/users/sstraatemans" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/5c5c74724f2e796b8dc2b700215980251e907ae8/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/5c5c74724f2e796b8dc2b700215980251e907ae8", + "commit": { + "message": "feat(rwa): add firebase (#2689)", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "add the SectionCard Component", + "commits": [ + { + "hash": "4c684a2", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Wed, 27 Nov 2024 15:34:44 GMT", + "date": "Mon, 09 Dec 2024 14:04:44 GMT" + }, + "data": { + "sha": "4c684a2fef84ca0ac30677f8b4d810268741caf9", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/4c684a2fef84ca0ac30677f8b4d810268741caf9", + "author": { + "login": "sstraatemans", + "id": 4015521, + "avatar_url": "https://avatars.githubusercontent.com/u/4015521?v=4", + "html_url": "https://github.com/sstraatemans", + "url": "https://api.github.com/users/sstraatemans" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/4c684a2fef84ca0ac30677f8b4d810268741caf9/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/4c684a2fef84ca0ac30677f8b4d810268741caf9", + "commit": { + "message": "feat(ui): Add the SectionCard Component (#2697)", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + }, + { + "label": "add an extra styling variant to the table component", + "commits": [ + { + "hash": "dbd9076", + "tries": 1, + "data": { + "status": 200, + "headers": { + "last-modified": "Fri, 06 Dec 2024 07:10:53 GMT", + "date": "Mon, 09 Dec 2024 14:04:45 GMT" + }, + "data": { + "sha": "dbd907693d8b8451eab739740fa5cd055084d755", + "url": "https://api.github.com/repos/kadena-community/kadena.js/commits/dbd907693d8b8451eab739740fa5cd055084d755", + "author": { + "login": "sstraatemans", + "id": 4015521, + "avatar_url": "https://avatars.githubusercontent.com/u/4015521?v=4", + "html_url": "https://github.com/sstraatemans", + "url": "https://api.github.com/users/sstraatemans" + }, + "comments_url": "https://api.github.com/repos/kadena-community/kadena.js/commits/dbd907693d8b8451eab739740fa5cd055084d755/comments", + "html_url": "https://github.com/kadena-community/kadena.js/commit/dbd907693d8b8451eab739740fa5cd055084d755", + "commit": { + "message": "feat(ui): extra styling variant of the table component (#2715)", + "comment_count": 0 + } + } + } + } + ], + "prIds": [] + } + ], + "miscs": [], + "date": "2024-12-06T07:10:53.000Z" + }, "0.19.0": { "label": "0.19.0", "description": "", diff --git a/packages/apps/explorer/CHANGELOG.md b/packages/apps/explorer/CHANGELOG.md index b363b0d6a3..e5368b0599 100644 --- a/packages/apps/explorer/CHANGELOG.md +++ b/packages/apps/explorer/CHANGELOG.md @@ -1,5 +1,16 @@ # @kadena/explorer +## 0.8.12 + +### Patch Changes + +- Updated dependencies \[5c5c747] +- Updated dependencies \[f35e30c] +- Updated dependencies \[4c684a2] +- Updated dependencies \[dbd9076] + - @kadena/kode-ui\@0.20.0 + - @kadena/graph\@2.0.3 + ## 0.8.11 ### Patch Changes diff --git a/packages/apps/explorer/package.json b/packages/apps/explorer/package.json index 4cbd87e4c5..d2b9069db6 100644 --- a/packages/apps/explorer/package.json +++ b/packages/apps/explorer/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/explorer", - "version": "0.8.11", + "version": "0.8.12", "private": true, "scripts": { "build": "pnpm run generate:sdk && next build", diff --git a/packages/apps/graph-client/CHANGELOG.md b/packages/apps/graph-client/CHANGELOG.md index c5be9ca574..0035529903 100644 --- a/packages/apps/graph-client/CHANGELOG.md +++ b/packages/apps/graph-client/CHANGELOG.md @@ -1,5 +1,16 @@ # @kadena/graph-client +## 0.4.10 + +### Patch Changes + +- Updated dependencies \[5c5c747] +- Updated dependencies \[f35e30c] +- Updated dependencies \[4c684a2] +- Updated dependencies \[dbd9076] + - @kadena/kode-ui\@0.20.0 + - @kadena/graph\@2.0.3 + ## 0.4.9 ### Patch Changes diff --git a/packages/apps/graph-client/package.json b/packages/apps/graph-client/package.json index 7c7135da22..35161fa075 100644 --- a/packages/apps/graph-client/package.json +++ b/packages/apps/graph-client/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/graph-client", - "version": "0.4.9", + "version": "0.4.10", "private": true, "scripts": { "build": "pnpm run generate:sdk && next build", diff --git a/packages/apps/graph/CHANGELOG.md b/packages/apps/graph/CHANGELOG.md index 8d75d05b1f..db454536c3 100644 --- a/packages/apps/graph/CHANGELOG.md +++ b/packages/apps/graph/CHANGELOG.md @@ -1,5 +1,15 @@ # @kadena/graph +## 2.0.3 + +### Patch Changes + +- Updated dependencies \[5e9bfd0] +- Updated dependencies \[1f46bee] + - @kadena/chainweb-node-client\@0.8.0 + - @kadena/client\@1.16.0 + - @kadena/client-utils\@0.11.1 + ## 2.0.2 ### Patch Changes diff --git a/packages/apps/graph/package.json b/packages/apps/graph/package.json index bd16f0acb5..73814bef24 100644 --- a/packages/apps/graph/package.json +++ b/packages/apps/graph/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/graph", - "version": "2.0.2", + "version": "2.0.3", "description": "GraphQL server, available for running your own GraphQL endpoint. This project uses chainweb-data as the datasource.", "repository": { "type": "git", diff --git a/packages/apps/marmalade-marketplace/CHANGELOG.md b/packages/apps/marmalade-marketplace/CHANGELOG.md index 3093ac23dd..8fc02cef05 100644 --- a/packages/apps/marmalade-marketplace/CHANGELOG.md +++ b/packages/apps/marmalade-marketplace/CHANGELOG.md @@ -1,5 +1,19 @@ # @kadena/marmalade-marketplace +## 0.1.13 + +### Patch Changes + +- Updated dependencies \[5c5c747] +- Updated dependencies \[f35e30c] +- Updated dependencies \[4c684a2] +- Updated dependencies \[5e9bfd0] +- Updated dependencies \[dbd9076] +- Updated dependencies \[1f46bee] + - @kadena/kode-ui\@0.20.0 + - @kadena/client\@1.16.0 + - @kadena/client-utils\@0.11.1 + ## 0.1.12 ### Patch Changes diff --git a/packages/apps/marmalade-marketplace/package.json b/packages/apps/marmalade-marketplace/package.json index 9df13a9a47..c36c15c559 100644 --- a/packages/apps/marmalade-marketplace/package.json +++ b/packages/apps/marmalade-marketplace/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/marmalade-marketplace", - "version": "0.1.12", + "version": "0.1.13", "private": true, "browser": { "fs": false diff --git a/packages/apps/proof-of-us/CHANGELOG.md b/packages/apps/proof-of-us/CHANGELOG.md index 92e1f98858..f3ba4907af 100644 --- a/packages/apps/proof-of-us/CHANGELOG.md +++ b/packages/apps/proof-of-us/CHANGELOG.md @@ -1,5 +1,19 @@ # @kadena/proof-of-us +## 0.5.17 + +### Patch Changes + +- Updated dependencies \[5c5c747] +- Updated dependencies \[f35e30c] +- Updated dependencies \[4c684a2] +- Updated dependencies \[5e9bfd0] +- Updated dependencies \[dbd9076] +- Updated dependencies \[1f46bee] + - @kadena/kode-ui\@0.20.0 + - @kadena/client\@1.16.0 + - @kadena/graph\@2.0.3 + ## 0.5.16 ### Patch Changes diff --git a/packages/apps/proof-of-us/package.json b/packages/apps/proof-of-us/package.json index 1b76ff5d61..682155a295 100644 --- a/packages/apps/proof-of-us/package.json +++ b/packages/apps/proof-of-us/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/proof-of-us", - "version": "0.5.16", + "version": "0.5.17", "private": true, "scripts": { "build": "pnpm run generate:sdk && next build", diff --git a/packages/apps/rwa-demo/CHANGELOG.md b/packages/apps/rwa-demo/CHANGELOG.md index fe7f323a10..45116c2e45 100644 --- a/packages/apps/rwa-demo/CHANGELOG.md +++ b/packages/apps/rwa-demo/CHANGELOG.md @@ -1,5 +1,19 @@ # @kadena/rwa-demo +## 0.1.4 + +### Patch Changes + +- Updated dependencies \[5c5c747] +- Updated dependencies \[f35e30c] +- Updated dependencies \[4c684a2] +- Updated dependencies \[5e9bfd0] +- Updated dependencies \[dbd9076] +- Updated dependencies \[1f46bee] + - @kadena/kode-ui\@0.20.0 + - @kadena/client\@1.16.0 + - @kadena/graph\@2.0.3 + ## 0.1.3 ### Patch Changes diff --git a/packages/apps/rwa-demo/package.json b/packages/apps/rwa-demo/package.json index 6dbbad2064..e97249eb92 100644 --- a/packages/apps/rwa-demo/package.json +++ b/packages/apps/rwa-demo/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/rwa-demo", - "version": "0.1.3", + "version": "0.1.4", "private": true, "scripts": { "build": "next build", diff --git a/packages/apps/spirekey-example/CHANGELOG.md b/packages/apps/spirekey-example/CHANGELOG.md index f7b4a09977..358305b210 100644 --- a/packages/apps/spirekey-example/CHANGELOG.md +++ b/packages/apps/spirekey-example/CHANGELOG.md @@ -1,5 +1,13 @@ # @kadena/spirekey-example +## 0.0.12 + +### Patch Changes + +- Updated dependencies \[5e9bfd0] +- Updated dependencies \[1f46bee] + - @kadena/client\@1.16.0 + ## 0.0.11 ### Patch Changes diff --git a/packages/apps/spirekey-example/package.json b/packages/apps/spirekey-example/package.json index efe64199c7..b60df13d2b 100644 --- a/packages/apps/spirekey-example/package.json +++ b/packages/apps/spirekey-example/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/spirekey-example", - "version": "0.0.11", + "version": "0.0.12", "private": true, "scripts": { "build": "echo 'no build'", diff --git a/packages/apps/wallet-sdk-example/CHANGELOG.md b/packages/apps/wallet-sdk-example/CHANGELOG.md new file mode 100644 index 0000000000..4bef5b91ae --- /dev/null +++ b/packages/apps/wallet-sdk-example/CHANGELOG.md @@ -0,0 +1,18 @@ +# wallet-sdk-example-app + +## 0.0.2 + +### Patch Changes + +- Updated dependencies \[5c5c747] +- Updated dependencies \[f35e30c] +- Updated dependencies \[4c684a2] +- Updated dependencies \[5e9bfd0] +- Updated dependencies \[2b0b87d] +- Updated dependencies \[dbd9076] +- Updated dependencies \[8615d09] +- Updated dependencies \[1f46bee] + - @kadena/kode-ui\@0.20.0 + - @kadena/client\@1.16.0 + - @kadena/wallet-sdk\@0.1.0 + - @kadena/hd-wallet\@0.6.1 diff --git a/packages/apps/wallet-sdk-example/package.json b/packages/apps/wallet-sdk-example/package.json index b74b3bbca6..8850149522 100644 --- a/packages/apps/wallet-sdk-example/package.json +++ b/packages/apps/wallet-sdk-example/package.json @@ -1,6 +1,6 @@ { "name": "wallet-sdk-example-app", - "version": "0.0.1", + "version": "0.0.2", "private": true, "type": "module", "scripts": { diff --git a/packages/libs/chainweb-node-client/CHANGELOG.md b/packages/libs/chainweb-node-client/CHANGELOG.md index 726f5a06b8..49e1f90fe6 100644 --- a/packages/libs/chainweb-node-client/CHANGELOG.md +++ b/packages/libs/chainweb-node-client/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @kadena/chainweb-node-client +## 0.8.0 + +### Minor Changes + +- 5e9bfd0: Support for passing a request init object to client functions + ## 0.7.0 ### Minor Changes diff --git a/packages/libs/chainweb-node-client/package.json b/packages/libs/chainweb-node-client/package.json index a25ca87ea8..16e9f435fd 100644 --- a/packages/libs/chainweb-node-client/package.json +++ b/packages/libs/chainweb-node-client/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/chainweb-node-client", - "version": "0.7.0", + "version": "0.8.0", "description": "Typed JavaScript wrapper with fetch to call chainweb-node API endpoints", "keywords": [], "repository": { diff --git a/packages/libs/client-examples/CHANGELOG.md b/packages/libs/client-examples/CHANGELOG.md index 0240c77909..50067091b8 100644 --- a/packages/libs/client-examples/CHANGELOG.md +++ b/packages/libs/client-examples/CHANGELOG.md @@ -1,5 +1,15 @@ # @kadena/client-examples +## 0.1.10 + +### Patch Changes + +- Updated dependencies \[5e9bfd0] +- Updated dependencies \[1f46bee] + - @kadena/chainweb-node-client\@0.8.0 + - @kadena/client\@1.16.0 + - @kadena/client-utils\@0.11.1 + ## 0.1.9 ### Patch Changes diff --git a/packages/libs/client-examples/package.json b/packages/libs/client-examples/package.json index 86e229bf5a..60bcc73976 100644 --- a/packages/libs/client-examples/package.json +++ b/packages/libs/client-examples/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/client-examples", - "version": "0.1.9", + "version": "0.1.10", "private": true, "description": "Test project to verify pactjs-cli and pactjs-generator", "repository": { diff --git a/packages/libs/client-utils/CHANGELOG.md b/packages/libs/client-utils/CHANGELOG.md index b801be0e7b..14d7ae656b 100644 --- a/packages/libs/client-utils/CHANGELOG.md +++ b/packages/libs/client-utils/CHANGELOG.md @@ -1,5 +1,15 @@ # @kadena/client-utils +## 0.11.1 + +### Patch Changes + +- Updated dependencies \[5e9bfd0] +- Updated dependencies \[1f46bee] + - @kadena/chainweb-node-client\@0.8.0 + - @kadena/client\@1.16.0 + - @kadena/pactjs-cli\@1.16.0 + ## 0.11.0 ### Minor Changes diff --git a/packages/libs/client-utils/package.json b/packages/libs/client-utils/package.json index f48728b1f5..c6f636da4a 100644 --- a/packages/libs/client-utils/package.json +++ b/packages/libs/client-utils/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/client-utils", - "version": "0.11.0", + "version": "0.11.1", "description": "Utility functions build as a wrapper around @kadena/client", "repository": { "type": "git", diff --git a/packages/libs/client/CHANGELOG.md b/packages/libs/client/CHANGELOG.md index e31b4f8d88..8b915ba3fb 100644 --- a/packages/libs/client/CHANGELOG.md +++ b/packages/libs/client/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log - @kadena/client +## 1.16.0 + +### Minor Changes + +- 5e9bfd0: Support for passing a request init object to client functions + +### Patch Changes + +- 1f46bee: Add a default value `null` for the proof +- Updated dependencies \[5e9bfd0] + - @kadena/chainweb-node-client\@0.8.0 + ## 1.15.0 ### Minor Changes diff --git a/packages/libs/client/package.json b/packages/libs/client/package.json index 645ae76495..d0b056a1bd 100644 --- a/packages/libs/client/package.json +++ b/packages/libs/client/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/client", - "version": "1.15.0", + "version": "1.16.0", "description": "Core library for building Pact expressions to send to the blockchain in js. Makes use of .kadena/pactjs-generated", "repository": { "type": "git", diff --git a/packages/libs/hd-wallet/CHANGELOG.md b/packages/libs/hd-wallet/CHANGELOG.md index 93a3e5da56..01f626fad0 100644 --- a/packages/libs/hd-wallet/CHANGELOG.md +++ b/packages/libs/hd-wallet/CHANGELOG.md @@ -1,5 +1,11 @@ # @kadena/hd-wallet +## 0.6.1 + +### Patch Changes + +- 8615d09: Improved documentation in readme + ## 0.6.0 ### Minor Changes diff --git a/packages/libs/hd-wallet/package.json b/packages/libs/hd-wallet/package.json index a3f96347e9..312ecda6b9 100644 --- a/packages/libs/hd-wallet/package.json +++ b/packages/libs/hd-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/hd-wallet", - "version": "0.6.0", + "version": "0.6.1", "description": "Key derivation based on Hierarchical Deterministic (HD)/Mnemonic keys and BIP32, for Kadena", "repository": { "type": "git", diff --git a/packages/libs/kode-ui/CHANGELOG.md b/packages/libs/kode-ui/CHANGELOG.md index a086ba33eb..c64278ea32 100644 --- a/packages/libs/kode-ui/CHANGELOG.md +++ b/packages/libs/kode-ui/CHANGELOG.md @@ -1,5 +1,17 @@ # @kadena/kode-ui +## 0.20.0 + +### Minor Changes + +- 5c5c747: add context section in the sidebar layout header +- 4c684a2: add the SectionCard Component +- dbd9076: add an extra styling variant to the table component + +### Patch Changes + +- f35e30c: fix in the sidebar header layout + ## 0.19.0 ### Minor Changes diff --git a/packages/libs/kode-ui/package.json b/packages/libs/kode-ui/package.json index fb5ae7a8ce..a760f7ac48 100644 --- a/packages/libs/kode-ui/package.json +++ b/packages/libs/kode-ui/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/kode-ui", - "version": "0.19.0", + "version": "0.20.0", "description": "A react component library built on Kadena's Kode Design System", "repository": { "type": "git", diff --git a/packages/libs/pactjs-generator/CHANGELOG.md b/packages/libs/pactjs-generator/CHANGELOG.md index 35d8b17ab8..dadeba3d7f 100644 --- a/packages/libs/pactjs-generator/CHANGELOG.md +++ b/packages/libs/pactjs-generator/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log - @kadena/pactjs-generator +## 1.16.0 + ## 1.15.0 ## 1.14.0 diff --git a/packages/libs/pactjs-generator/package.json b/packages/libs/pactjs-generator/package.json index 662249e05d..3a755938fa 100644 --- a/packages/libs/pactjs-generator/package.json +++ b/packages/libs/pactjs-generator/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/pactjs-generator", - "version": "1.15.0", + "version": "1.16.0", "description": "Generates TypeScript definitions of Pact contracts, for use in @kadena/pactjs", "repository": { "type": "git", diff --git a/packages/libs/wallet-sdk/CHANGELOG.md b/packages/libs/wallet-sdk/CHANGELOG.md index e69de29bb2..929328aee0 100644 --- a/packages/libs/wallet-sdk/CHANGELOG.md +++ b/packages/libs/wallet-sdk/CHANGELOG.md @@ -0,0 +1,18 @@ +# @kadena/wallet-sdk + +## 0.1.0 + +### Minor Changes + +- 2b0b87d: The Kadena Wallet SDK provides a simple and unified interface to + integrate Kadena blockchain functionalities into your wallet applications. It + abstracts the complexities of interacting with the Kadena network, allowing + you to focus on building feature-rich wallet experiences without + re-implementing common integrations. + +### Patch Changes + +- Updated dependencies \[5e9bfd0] +- Updated dependencies \[1f46bee] + - @kadena/client\@1.16.0 + - @kadena/client-utils\@0.11.1 diff --git a/packages/libs/wallet-sdk/package.json b/packages/libs/wallet-sdk/package.json index aa5321fbe5..529a8bbb85 100644 --- a/packages/libs/wallet-sdk/package.json +++ b/packages/libs/wallet-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/wallet-sdk", - "version": "0.0.1", + "version": "0.1.0", "description": "", "repository": { "type": "git", diff --git a/packages/tools/kadena-cli/CHANGELOG.md b/packages/tools/kadena-cli/CHANGELOG.md index 0b7e06c832..b9924f4760 100644 --- a/packages/tools/kadena-cli/CHANGELOG.md +++ b/packages/tools/kadena-cli/CHANGELOG.md @@ -1,5 +1,18 @@ # @kadena/kadena-cli +## 1.3.8 + +### Patch Changes + +- Updated dependencies \[5e9bfd0] +- Updated dependencies \[8615d09] +- Updated dependencies \[1f46bee] + - @kadena/client\@1.16.0 + - @kadena/hd-wallet\@0.6.1 + - @kadena/client-utils\@0.11.1 + - @kadena/pactjs-cli\@1.16.0 + - @kadena/pactjs-generator\@1.16.0 + ## 1.3.7 ### Patch Changes diff --git a/packages/tools/kadena-cli/package.json b/packages/tools/kadena-cli/package.json index 7a7604c823..558633f729 100644 --- a/packages/tools/kadena-cli/package.json +++ b/packages/tools/kadena-cli/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/kadena-cli", - "version": "1.3.7", + "version": "1.3.8", "description": "Kadena CLI tool to interact with the Kadena blockchain (manage keys, transactions, etc.)", "keywords": [ "Kadena", diff --git a/packages/tools/pactjs-cli/CHANGELOG.md b/packages/tools/pactjs-cli/CHANGELOG.md index 47eb9e1173..d01788109b 100644 --- a/packages/tools/pactjs-cli/CHANGELOG.md +++ b/packages/tools/pactjs-cli/CHANGELOG.md @@ -1,5 +1,14 @@ # Change Log - @kadena/pactjs-cli +## 1.16.0 + +### Patch Changes + +- Updated dependencies \[5e9bfd0] +- Updated dependencies \[1f46bee] + - @kadena/client\@1.16.0 + - @kadena/pactjs-generator\@1.16.0 + ## 1.15.0 ### Patch Changes diff --git a/packages/tools/pactjs-cli/package.json b/packages/tools/pactjs-cli/package.json index 71faf7b005..3a4e8597e5 100644 --- a/packages/tools/pactjs-cli/package.json +++ b/packages/tools/pactjs-cli/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/pactjs-cli", - "version": "1.15.0", + "version": "1.16.0", "description": "CLI tool accompanying @kadena/pactjs-core and @kadena/pactjs-client to generate TypeScript definitions and Pact client", "repository": { "type": "git", From fa2cd31fe3c9cb075d0bd565247ea9589dff6afc Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 10 Dec 2024 07:22:05 +0100 Subject: [PATCH 103/103] feat(rwa): add asset (#2706) --- .changeset/curvy-mice-destroy.md | 2 + .changeset/popular-rice-search.md | 2 + .../rwa-demo/src/app/(app)/assets/page.tsx | 112 +- .../apps/rwa-demo/src/app/(app)/layout.tsx | 13 +- .../src/components/AgentForm/AgentForm.tsx | 5 + .../src/components/AgentsList/AgentsList.tsx | 11 +- .../AssetForm/AddExistingAssetForm.tsx | 52 + .../src/components/AssetForm/AssetForm.tsx | 51 + .../components/AssetForm/StepperAssetForm.tsx | 202 +++ .../src/components/AssetInfo/AssetInfo.tsx | 2 +- .../AssetProvider/AssetProvider.tsx | 79 +- .../src/components/AssetSwitch/AssetForm.tsx | 98 -- .../components/AssetSwitch/AssetSwitch.tsx | 36 +- .../TableFormatters/FormatAgentRoles.tsx | 34 + .../TransactionsProvider.tsx | 1 + .../apps/rwa-demo/src/hooks/createContract.ts | 46 + .../src/hooks/createPrincipalNamespace.ts | 41 + packages/apps/rwa-demo/src/hooks/freeze.ts | 2 +- .../apps/rwa-demo/src/hooks/getAgentRoles.ts | 24 + packages/apps/rwa-demo/src/hooks/getAgents.ts | 8 +- .../apps/rwa-demo/src/hooks/getInvestors.ts | 4 +- .../apps/rwa-demo/src/hooks/initContract.ts | 50 + packages/apps/rwa-demo/src/hooks/paused.ts | 4 +- packages/apps/rwa-demo/src/hooks/supply.ts | 2 +- .../apps/rwa-demo/src/services/addAgent.ts | 6 +- .../rwa-demo/src/services/createContract.ts | 28 + .../src/services/createPrincipalNamespace.ts | 37 + .../rwa-demo/src/services/deleteIdentity.ts | 4 +- .../rwa-demo/src/services/distributeTokens.ts | 15 +- .../rwa-demo/src/services/getAgentRoles.ts | 34 + .../src/services/getAssetMaxSupplyBalance.ts | 72 +- .../apps/rwa-demo/src/services/getBalance.ts | 2 +- .../rwa-demo/src/services/getFrozenTokens.ts | 4 +- .../rwa-demo/src/services/initContract.ts | 36 + .../apps/rwa-demo/src/services/isAgent.ts | 2 +- .../src/services/isComplianceOwner.ts | 10 +- .../apps/rwa-demo/src/services/isFrozen.ts | 2 +- .../apps/rwa-demo/src/services/isInvestor.ts | 2 +- .../apps/rwa-demo/src/services/isOwner.ts | 7 +- .../apps/rwa-demo/src/services/isPaused.ts | 2 +- .../src/services/pact/modalcontract.ts | 1154 +++++++++++++++++ packages/apps/rwa-demo/src/services/paused.ts | 2 +- .../rwa-demo/src/services/registerIdentity.ts | 6 +- .../apps/rwa-demo/src/services/removeAgent.ts | 4 +- .../rwa-demo/src/services/setAddressFrozen.ts | 4 +- .../rwa-demo/src/services/setCompliance.ts | 4 +- packages/apps/rwa-demo/src/services/supply.ts | 2 +- .../services/togglePartiallyFreezeTokens.ts | 4 +- .../apps/rwa-demo/src/services/togglePause.ts | 4 +- .../rwa-demo/src/services/transferTokens.ts | 4 +- packages/apps/rwa-demo/src/utils/getAsset.ts | 6 +- .../apps/rwa-demo/src/utils/store/index.ts | 15 +- .../LayoutProvider/NotificationsProvider.tsx | 6 +- 53 files changed, 2109 insertions(+), 250 deletions(-) create mode 100644 .changeset/curvy-mice-destroy.md create mode 100644 .changeset/popular-rice-search.md create mode 100644 packages/apps/rwa-demo/src/components/AssetForm/AddExistingAssetForm.tsx create mode 100644 packages/apps/rwa-demo/src/components/AssetForm/AssetForm.tsx create mode 100644 packages/apps/rwa-demo/src/components/AssetForm/StepperAssetForm.tsx delete mode 100644 packages/apps/rwa-demo/src/components/AssetSwitch/AssetForm.tsx create mode 100644 packages/apps/rwa-demo/src/components/TableFormatters/FormatAgentRoles.tsx create mode 100644 packages/apps/rwa-demo/src/hooks/createContract.ts create mode 100644 packages/apps/rwa-demo/src/hooks/createPrincipalNamespace.ts create mode 100644 packages/apps/rwa-demo/src/hooks/getAgentRoles.ts create mode 100644 packages/apps/rwa-demo/src/hooks/initContract.ts create mode 100644 packages/apps/rwa-demo/src/services/createContract.ts create mode 100644 packages/apps/rwa-demo/src/services/createPrincipalNamespace.ts create mode 100644 packages/apps/rwa-demo/src/services/getAgentRoles.ts create mode 100644 packages/apps/rwa-demo/src/services/initContract.ts create mode 100644 packages/apps/rwa-demo/src/services/pact/modalcontract.ts diff --git a/.changeset/curvy-mice-destroy.md b/.changeset/curvy-mice-destroy.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/curvy-mice-destroy.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.changeset/popular-rice-search.md b/.changeset/popular-rice-search.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/popular-rice-search.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/apps/rwa-demo/src/app/(app)/assets/page.tsx b/packages/apps/rwa-demo/src/app/(app)/assets/page.tsx index d5f383a94e..d6e5fd9379 100644 --- a/packages/apps/rwa-demo/src/app/(app)/assets/page.tsx +++ b/packages/apps/rwa-demo/src/app/(app)/assets/page.tsx @@ -1,34 +1,102 @@ 'use client'; +import { AssetForm } from '@/components/AssetForm/AssetForm'; +import { Confirmation } from '@/components/Confirmation/Confirmation'; import { useAsset } from '@/hooks/asset'; -import { CompactTable, CompactTableFormatters } from '@kadena/kode-ui/patterns'; +import { MonoAdd, MonoDelete } from '@kadena/kode-icons'; +import { Button } from '@kadena/kode-ui'; +import { + CompactTable, + CompactTableFormatters, + RightAside, + RightAsideContent, + RightAsideHeader, + SectionCard, + SectionCardBody, + SectionCardContentBlock, + SectionCardHeader, + useLayout, +} from '@kadena/kode-ui/patterns'; import Link from 'next/link'; +import { useState } from 'react'; const Assets = () => { - const { assets } = useAsset(); + const { assets, removeAsset } = useAsset(); + const [openSide, setOpenSide] = useState(false); + const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); + + const handleDelete = (value: any) => { + removeAsset(value); + }; return ( <> - + {isRightAsideExpanded && openSide && ( + { + setIsRightAsideExpanded(false); + setOpenSide(false); + }} + > + + + + )} + + + List of all your selected contracts} + actions={ + }> + Add Asset + + } + /> + } + /> + + } + /> + } + > + Are you sure you want to remove this asset? + + ), + }), + }, + ]} + data={assets} + /> + + + ); }; diff --git a/packages/apps/rwa-demo/src/app/(app)/layout.tsx b/packages/apps/rwa-demo/src/app/(app)/layout.tsx index 4b44513c56..6910989fb4 100644 --- a/packages/apps/rwa-demo/src/app/(app)/layout.tsx +++ b/packages/apps/rwa-demo/src/app/(app)/layout.tsx @@ -9,13 +9,15 @@ import { } from '@kadena/kode-ui/patterns'; import { ActiveTransactionsList } from '@/components/ActiveTransactionsList/ActiveTransactionsList'; +import { StepperAssetForm } from '@/components/AssetForm/StepperAssetForm'; import { AssetInfo } from '@/components/AssetInfo/AssetInfo'; -import { AssetForm } from '@/components/AssetSwitch/AssetForm'; import { TransactionPendingIcon } from '@/components/TransactionPendingIcon/TransactionPendingIcon'; +import { useAccount } from '@/hooks/account'; import { useTransactions } from '@/hooks/transactions'; import { getAsset } from '@/utils/getAsset'; import { MonoAccountBalanceWallet } from '@kadena/kode-icons'; import { Button, Heading, Link, Stack } from '@kadena/kode-ui'; +import { useRouter } from 'next/navigation'; import React, { useEffect, useRef, useState } from 'react'; import { KLogo } from './KLogo'; import { SideBar } from './SideBar'; @@ -25,12 +27,14 @@ const RootLayout = ({ }: Readonly<{ children: React.ReactNode; }>) => { + const { account, isMounted } = useAccount(); const [openTransactionsSide, setOpenTransactionsSide] = useState(false); const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); const { transactions, setTxsButtonRef, setTxsAnimationRef } = useTransactions(); const txsButtonRef = useRef(null); const transactionAnimationRef = useRef(null); + const router = useRouter(); useEffect(() => { if (!txsButtonRef.current || !transactionAnimationRef.current) return; @@ -38,6 +42,11 @@ const RootLayout = ({ setTxsAnimationRef(transactionAnimationRef.current); }, [txsButtonRef.current, transactionAnimationRef.current]); + if (isMounted && !account) { + router.replace('/login'); + return; + } + if (!getAsset()) { return (
Add new asset - +
); diff --git a/packages/apps/rwa-demo/src/components/AgentForm/AgentForm.tsx b/packages/apps/rwa-demo/src/components/AgentForm/AgentForm.tsx index 2b3b6c6928..4413c8ff5d 100644 --- a/packages/apps/rwa-demo/src/components/AgentForm/AgentForm.tsx +++ b/packages/apps/rwa-demo/src/components/AgentForm/AgentForm.tsx @@ -21,9 +21,13 @@ interface IProps { } export const AgentForm: FC = ({ onClose, agent, trigger }) => { + // const { data: userAgentRolesData } = useGetAgentRoles({ + // agent: agent?.accountName, + // }); const { submit } = useEditAgent(); const [isOpen, setIsOpen] = useState(false); const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); + const { handleSubmit, control, @@ -60,6 +64,7 @@ export const AgentForm: FC = ({ onClose, agent, trigger }) => { }; const onSubmit = async (data: IAddAgentProps) => { + console.log({ data }); await submit(data); handleOnClose(); }; diff --git a/packages/apps/rwa-demo/src/components/AgentsList/AgentsList.tsx b/packages/apps/rwa-demo/src/components/AgentsList/AgentsList.tsx index 81f6c7a975..ddf64812c5 100644 --- a/packages/apps/rwa-demo/src/components/AgentsList/AgentsList.tsx +++ b/packages/apps/rwa-demo/src/components/AgentsList/AgentsList.tsx @@ -19,6 +19,7 @@ import { useRouter } from 'next/navigation'; import type { FC } from 'react'; import { AgentForm } from '../AgentForm/AgentForm'; import { Confirmation } from '../Confirmation/Confirmation'; +import { FormatAgentRoles } from '../TableFormatters/FormatAgentRoles'; export const AgentsList: FC = () => { const { paused } = useAsset(); @@ -63,14 +64,20 @@ export const AgentsList: FC = () => { { label: 'Name', key: 'alias', - width: '30%', + width: '20%', }, { label: 'Account', key: 'accountName', - width: '50%', + width: '20%', render: CompactTableFormatters.FormatAccount(), }, + { + label: 'Roles', + key: 'accountName', + width: '40%', + render: FormatAgentRoles(), + }, { label: '', key: 'accountName', diff --git a/packages/apps/rwa-demo/src/components/AssetForm/AddExistingAssetForm.tsx b/packages/apps/rwa-demo/src/components/AssetForm/AddExistingAssetForm.tsx new file mode 100644 index 0000000000..914a9cf4af --- /dev/null +++ b/packages/apps/rwa-demo/src/components/AssetForm/AddExistingAssetForm.tsx @@ -0,0 +1,52 @@ +import { useAsset } from '@/hooks/asset'; +import { Button, Stack, TextField } from '@kadena/kode-ui'; +import { useRouter } from 'next/navigation'; +import type { FC } from 'react'; +import { Controller, useForm } from 'react-hook-form'; + +interface IAddExistingAssetProps { + name: string; +} + +export const AddExistingAssetForm: FC = () => { + const router = useRouter(); + const { addExistingAsset } = useAsset(); + const { + handleSubmit, + control, + formState: { isValid }, + } = useForm({ + values: { + name: '', + }, + }); + + const handleSave = async (data: IAddExistingAssetProps) => { + const asset = addExistingAsset(data.name); + if (!asset) return; + + router.refresh(); + }; + + return ( + + ( + + )} + /> + + + + ); +}; diff --git a/packages/apps/rwa-demo/src/components/AssetForm/AssetForm.tsx b/packages/apps/rwa-demo/src/components/AssetForm/AssetForm.tsx new file mode 100644 index 0000000000..2b7079b60b --- /dev/null +++ b/packages/apps/rwa-demo/src/components/AssetForm/AssetForm.tsx @@ -0,0 +1,51 @@ +import { + RightAside, + RightAsideContent, + RightAsideHeader, + useLayout, +} from '@kadena/kode-ui/patterns'; +import type { FC, ReactElement } from 'react'; +import { cloneElement, useState } from 'react'; +import type { IAsset } from '../AssetProvider/AssetProvider'; +import { StepperAssetForm } from './StepperAssetForm'; + +interface IProps { + asset?: IAsset; + trigger: ReactElement; + onClose?: () => void; +} + +export const AssetForm: FC = ({ trigger, onClose }) => { + const [isOpen, setIsOpen] = useState(false); + const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); + + const handleOpen = () => { + setIsRightAsideExpanded(true); + setIsOpen(true); + if (trigger.props.onPress) trigger.props.onPress(); + }; + + const handleOnClose = () => { + setIsRightAsideExpanded(false); + setIsOpen(false); + if (onClose) onClose(); + }; + + return ( + <> + {isRightAsideExpanded && isOpen && ( + + + + + + + )} + + {cloneElement(trigger, { ...trigger.props, onPress: handleOpen })} + + ); +}; diff --git a/packages/apps/rwa-demo/src/components/AssetForm/StepperAssetForm.tsx b/packages/apps/rwa-demo/src/components/AssetForm/StepperAssetForm.tsx new file mode 100644 index 0000000000..15182a7127 --- /dev/null +++ b/packages/apps/rwa-demo/src/components/AssetForm/StepperAssetForm.tsx @@ -0,0 +1,202 @@ +import { useAsset } from '@/hooks/asset'; +import { useCreateContract } from '@/hooks/createContract'; +import { useCreatePrincipalNamespace } from '@/hooks/createPrincipalNamespace'; +import { useInitContract } from '@/hooks/initContract'; +import type { IAddContractProps } from '@/services/createContract'; +import { + Button, + Notification, + NotificationHeading, + Stack, + Step, + Stepper, + TextField, +} from '@kadena/kode-ui'; +import { useRouter } from 'next/navigation'; +import type { FC } from 'react'; +import { useState } from 'react'; +import { Controller, useForm } from 'react-hook-form'; +import type { IAsset } from '../AssetProvider/AssetProvider'; +import { AddExistingAssetForm } from './AddExistingAssetForm'; + +interface IProps { + asset?: IAsset; +} + +const STEPS = { + CREATE_NAMESPACE: 0, + CREATE_CONTRACT: 1, + INIT_CONTRACT: 2, + DONE: 3, +} as const; + +export const StepperAssetForm: FC = () => { + const [contractData, setContractData] = useState< + IAddContractProps | undefined + >(); + const [step, setStep] = useState(STEPS.CREATE_NAMESPACE); + const { addAsset, setAsset } = useAsset(); + const { submit } = useCreatePrincipalNamespace(); + const { submit: submitInit } = useInitContract(); + const { submit: submitContract } = useCreateContract(); + const [namespace, setNamespace] = useState(''); + const [error, setError] = useState(''); + const router = useRouter(); + + const { + handleSubmit, + control, + formState: { isValid }, + } = useForm({ + values: { + contractName: 'asd', + owner: + 'k:9f6a3e6ed941c9abe2c9d12afea3fe55644282c2392fe7e9571e3822d21db229', + complianceOwner: + 'k:9f6a3e6ed941c9abe2c9d12afea3fe55644282c2392fe7e9571e3822d21db229', + namespace, + }, + }); + + const handleSave = async (data: IAddContractProps) => { + setContractData(data); + const tx = await submitContract(data); + if (tx?.result?.status === 'success') { + setStep(STEPS.INIT_CONTRACT); + } + }; + + return ( + + + = STEPS.CREATE_NAMESPACE ? 'active' : 'inactive'} + active={step === STEPS.CREATE_NAMESPACE} + > + Namespace + + = STEPS.CREATE_CONTRACT ? 'active' : 'inactive'} + active={step === STEPS.CREATE_CONTRACT} + > + Contract + + = STEPS.INIT_CONTRACT ? 'active' : 'inactive'} + active={step === STEPS.INIT_CONTRACT} + > + Init + + + + {error && ( + + There was an issue + {error} + + )} + + {step === STEPS.CREATE_NAMESPACE && ( + + + + + )} + {step === STEPS.INIT_CONTRACT && ( + + )} + + {step === STEPS.DONE && ( + + )} + + {step === STEPS.CREATE_CONTRACT && ( +
+ } + /> + + ( + + )} + /> + + } + /> + + ( + + )} + /> + + + + + )} +
+ ); +}; diff --git a/packages/apps/rwa-demo/src/components/AssetInfo/AssetInfo.tsx b/packages/apps/rwa-demo/src/components/AssetInfo/AssetInfo.tsx index 07e7a3f952..bad6f4f011 100644 --- a/packages/apps/rwa-demo/src/components/AssetInfo/AssetInfo.tsx +++ b/packages/apps/rwa-demo/src/components/AssetInfo/AssetInfo.tsx @@ -9,7 +9,7 @@ export const AssetInfo: FC = () => { if (!asset) return; return ( - {asset.name} + {asset.contractName}