From 5ff07e6245d3ca4725c6957384baa156e347efc8 Mon Sep 17 00:00:00 2001 From: Chad Ostrowski <221614+chadoh@users.noreply.github.com> Date: Tue, 2 Jul 2024 16:00:31 -0400 Subject: [PATCH] fix write method calls --- components/molecules/form-pledge/index.tsx | 24 ++++++++++++++++------ components/organisms/pledge/index.tsx | 2 +- hooks/useSubscription.ts | 2 +- shared/contracts.ts | 2 ++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/components/molecules/form-pledge/index.tsx b/components/molecules/form-pledge/index.tsx index ff2f113..1239523 100644 --- a/components/molecules/form-pledge/index.tsx +++ b/components/molecules/form-pledge/index.tsx @@ -5,7 +5,7 @@ import { Utils } from '../../../shared/utils' import styles from './style.module.css' import { Spacer } from '../../atoms/spacer' import { abundance, crowdfund } from '../../../shared/contracts' -import { signTransaction } from '@stellar/freighter-api' +import { getPublicKey, signTransaction } from '@stellar/freighter-api' export interface IFormPledgeProps { account: string @@ -46,7 +46,11 @@ function MintButton({ title={`Mint ${displayAmount} ${symbol}`} onClick={async () => { setSubmitting(true) - const tx = await abundance.mint({ to: account, amount }) + const tx = await abundance.mint( + { to: account, amount }, + // @ts-expect-error publicKey gets passed along, but the types don't know that! + { publicKey: await getPublicKey() } + ) await tx.signAndSend({ signTransaction }) setSubmitting(false) onComplete() @@ -89,10 +93,18 @@ const FormPledge: FunctionComponent = props => { setSubmitting(true) try { - await crowdfund.deposit({ - user: props.account, - amount: BigInt(amount * 10 ** decimals), - }) + const tx = await crowdfund.deposit( + { + user: props.account, + amount: BigInt(amount * 10 ** decimals), + }, + { + // @ts-expect-error publicKey gets passed along, but the types don't know that! + publicKey: await getPublicKey(), + } + ) + + await tx.signAndSend({ signTransaction }) setResultSubmit({ status: 'success', diff --git a/components/organisms/pledge/index.tsx b/components/organisms/pledge/index.tsx index 9078b95..640457a 100644 --- a/components/organisms/pledge/index.tsx +++ b/components/organisms/pledge/index.tsx @@ -61,7 +61,7 @@ const Pledge: FunctionComponent = () => { ...abundance!, balance: crowdfundContract.spec.funcResToNative( 'balance', - event.value.xdr + event.value ), }) }, diff --git a/hooks/useSubscription.ts b/hooks/useSubscription.ts index bee7aec..a496955 100644 --- a/hooks/useSubscription.ts +++ b/hooks/useSubscription.ts @@ -28,7 +28,7 @@ const paging: Record< export function useSubscription( contractId: string, topic: string, - onEvent: (event: SorobanRpc.EventResponse) => void, + onEvent: (event: SorobanRpc.Api.EventResponse) => void, pollInterval = 5000 ) { const id = `${contractId}:${topic}` diff --git a/shared/contracts.ts b/shared/contracts.ts index 18d8daf..95d006f 100644 --- a/shared/contracts.ts +++ b/shared/contracts.ts @@ -5,11 +5,13 @@ import config from './config.json' const { network, rpcUrl } = config export const abundance = new Abundance.Client({ + allowHttp: rpcUrl.startsWith('http:'), rpcUrl, ...Abundance.networks[network as keyof typeof Abundance.networks], }) export const crowdfund = new Crowdfund.Client({ + allowHttp: rpcUrl.startsWith('http:'), rpcUrl, ...Crowdfund.networks[network as keyof typeof Crowdfund.networks], })