Skip to content

Commit

Permalink
fix write method calls
Browse files Browse the repository at this point in the history
  • Loading branch information
chadoh committed Jul 2, 2024
1 parent 4b9dfa6 commit 5ff07e6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
24 changes: 18 additions & 6 deletions components/molecules/form-pledge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -89,10 +93,18 @@ const FormPledge: FunctionComponent<IFormPledgeProps> = 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',
Expand Down
2 changes: 1 addition & 1 deletion components/organisms/pledge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const Pledge: FunctionComponent = () => {
...abundance!,
balance: crowdfundContract.spec.funcResToNative(
'balance',
event.value.xdr
event.value
),
})
},
Expand Down
2 changes: 1 addition & 1 deletion hooks/useSubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
2 changes: 2 additions & 0 deletions shared/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
})
Expand Down

0 comments on commit 5ff07e6

Please sign in to comment.