Skip to content

Commit

Permalink
fix: example
Browse files Browse the repository at this point in the history
  • Loading branch information
dalechyn committed Feb 22, 2024
1 parent b56c2db commit 8bee38c
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions examples/wagemos-graz-nextjs/src/app/authz-osmosis/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
useCreateAccountMonarchy,
useSignAndBroadcast,
} from '@abstract-money/react'
import { useModuleInstantiate2AddressFromApi } from '@abstract-money/react'
import { useModuleInstantiate2AddressAndVersionFromApi } from '@abstract-money/react'
import { useAccount } from 'graz'
import React, { useCallback, useEffect, useMemo } from 'react'
import { Button } from '../../components/ui/button'
Expand Down Expand Up @@ -59,26 +59,27 @@ export default function AuthzPage() {
})
}, [accountFactory])

const { data: savingsAppAddress } = useModuleInstantiate2AddressFromApi(
{
accountId: stringToAccountId(TEST_SAVINGS_ACCOUNT_ID, CHAIN_NAME),
args: {
moduleId: SAVINGS_APP_MODULE_ID,
const { data: savingsAppData } =
useModuleInstantiate2AddressAndVersionFromApi(
{
accountId: stringToAccountId(TEST_SAVINGS_ACCOUNT_ID, CHAIN_NAME),
args: {
moduleId: SAVINGS_APP_MODULE_ID,
},
},
},
{
enabled: true,
},
)
{
enabled: true,
},
)

console.log('calculated savings app address', savingsAppAddress)
console.log('calculated savings app address', savingsAppData)

const onGrantAuthzClick = useMemo(() => {
if (!account) {
console.error('no account')
return undefined
}
if (!savingsAppAddress) {
if (!savingsAppData) {
console.error('no module grantee')
return undefined
}
Expand All @@ -99,18 +100,18 @@ export default function AuthzPage() {
].map((typeUrl) =>
encodeAuthzGrantGenericAuthorizationMsg(
account.bech32Address,
savingsAppAddress,
savingsAppData.address,
typeUrl,
),
),
encodeAuthzGrantGenericAuthorizationMsg(
account.bech32Address,
savingsAppAddress,
savingsAppData.address,
BankTransactionTypeUrl.Send,
),
encodeAuthzGrantSendAuthorizationMsg(
account.bech32Address,
savingsAppAddress,
savingsAppData.address,
{ spendLimit: [{ denom: 'uosmo', amount: '100' }] },
),
],
Expand Down

0 comments on commit 8bee38c

Please sign in to comment.