Skip to content

Commit

Permalink
Merge pull request #75 from AbstractSDK/fix/peer-deps
Browse files Browse the repository at this point in the history
fix: peer dependency and deprecate `AccountIdProvider`
  • Loading branch information
dalechyn authored Mar 12, 2024
2 parents a605ff1 + fb4f0c4 commit fc751aa
Show file tree
Hide file tree
Showing 47 changed files with 200 additions and 509 deletions.
12 changes: 12 additions & 0 deletions .changeset/fast-forks-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@abstract-money/react": minor
"wagemos-cosmoskit-nextjs": patch
"wagemos-graz-nextjs": patch
"@abstract-money/cli": patch
"@abstract-money/provider-graz": patch
---

Deprecated `AbstractAccountIdProvider` in favor of custom client's accountId state management.
Introduced consequent changes to types involving `accountId`.
Fixes the peer-dependency issue in `provider-graz` package.
Dropped `@cosmjs/amino` in favor of `@cosmjs/stargate`
1 change: 0 additions & 1 deletion examples/wagemos-cosmoskit-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"@abstract-money/provider-cosmoskit": "workspace:*",
"@abstract-money/react": "workspace:*",
"@chain-registry/types": "^0.13.1",
"@cosmjs/amino": "^0.32.2",
"@cosmjs/stargate": "^0.32.2",
"@cosmos-kit/keplr": "^2.4.15",
"@cosmos-kit/react": "^2.6.0",
Expand Down
44 changes: 31 additions & 13 deletions examples/wagemos-cosmoskit-nextjs/src/_generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ export const betting = {
}: Omit<
Parameters<typeof useBettingBetsQuery<BettingTypes.BetsResponse>>[0],
'client'
> & { accountId?: AccountId; chainName: string | undefined }) => {
> & {
accountId: AccountId | undefined
chainName: string | undefined
}) => {
const {
data: bettingAppQueryClient,
isLoading: isBettingAppQueryClientLoading,
Expand Down Expand Up @@ -122,7 +125,10 @@ export const betting = {
}: Omit<
Parameters<typeof useBettingConfigQuery<BettingTypes.ConfigResponse>>[0],
'client'
> & { accountId?: AccountId; chainName: string | undefined }) => {
> & {
accountId: AccountId | undefined
chainName: string | undefined
}) => {
const {
data: bettingAppQueryClient,
isLoading: isBettingAppQueryClientLoading,
Expand Down Expand Up @@ -186,7 +192,10 @@ export const betting = {
typeof useBettingListOddsQuery<BettingTypes.ListOddsResponse>
>[0],
'client'
> & { accountId?: AccountId; chainName: string | undefined }) => {
> & {
accountId: AccountId | undefined
chainName: string | undefined
}) => {
const {
data: bettingAppQueryClient,
isLoading: isBettingAppQueryClientLoading,
Expand Down Expand Up @@ -249,7 +258,10 @@ export const betting = {
}: Omit<
Parameters<typeof useBettingOddsQuery<BettingTypes.OddsResponse>>[0],
'client'
> & { accountId?: AccountId; chainName: string | undefined }) => {
> & {
accountId: AccountId | undefined
chainName: string | undefined
}) => {
const {
data: bettingAppQueryClient,
isLoading: isBettingAppQueryClientLoading,
Expand Down Expand Up @@ -314,7 +326,10 @@ export const betting = {
typeof useBettingListRoundsQuery<BettingTypes.RoundsResponse>
>[0],
'client'
> & { accountId?: AccountId; chainName: string | undefined }) => {
> & {
accountId: AccountId | undefined
chainName: string | undefined
}) => {
const {
data: bettingAppQueryClient,
isLoading: isBettingAppQueryClientLoading,
Expand Down Expand Up @@ -377,7 +392,10 @@ export const betting = {
}: Omit<
Parameters<typeof useBettingRoundQuery<BettingTypes.RoundResponse>>[0],
'client'
> & { accountId?: AccountId; chainName: string | undefined }) => {
> & {
accountId: AccountId | undefined
chainName: string | undefined
}) => {
const {
data: bettingAppQueryClient,
isLoading: isBettingAppQueryClientLoading,
Expand Down Expand Up @@ -439,7 +457,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down Expand Up @@ -493,7 +511,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down Expand Up @@ -547,7 +565,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down Expand Up @@ -601,7 +619,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down Expand Up @@ -655,7 +673,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down Expand Up @@ -709,7 +727,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down Expand Up @@ -763,7 +781,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client'

import { coin } from '@cosmjs/amino'
import { stringToAccountId } from '@abstract-money/core'
import { coin } from '@cosmjs/stargate'
import { useChain } from '@cosmos-kit/react'
import { zodResolver } from '@hookform/resolvers/zod'
import { DialogDescription } from '@radix-ui/react-dialog'
Expand Down Expand Up @@ -61,7 +62,10 @@ export function PlaceBetDialog({ round }: { round: RoundResponse }) {
const { isWalletConnected } = useChain('neutron')

const { mutateAsync: placeBetAsync, isLoading } =
betting.mutations.usePlaceBet({ chainName: 'neutron' })
betting.mutations.usePlaceBet({
chainName: 'neutron',
accountId: stringToAccountId('neutron-18'),
})

const onSubmit: SubmitHandler<z.infer<typeof placeBetSchema>> = useCallback(
async ({ amount, accountSeq }) => {
Expand Down
20 changes: 6 additions & 14 deletions examples/wagemos-cosmoskit-nextjs/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import { stringToAccountId } from '@abstract-money/core'
import { cosmosKitProvider } from '@abstract-money/provider-cosmoskit'
import {
AbstractAccountIdProvider,
AbstractProvider,
createConfig,
} from '@abstract-money/react'
import { AbstractProvider, createConfig } from '@abstract-money/react'
import '@interchain-ui/react/styles'
import { Inter, Poppins } from 'next/font/google'
import { Toaster } from '../components/ui/toaster'
Expand All @@ -32,15 +28,11 @@ export default function RootLayout({
<CosmosKitProvider>
<body className={cn(inter.variable, poppins.variable)}>
<AbstractProvider config={abstractConfig}>
<AbstractAccountIdProvider
accountId={stringToAccountId('neutron-18')}
>
<main className="flex flex-col items-center p-24 min-h-screen">
<section className="mt-10">
<div className="mt-10">{children}</div>
</section>
</main>
</AbstractAccountIdProvider>
<main className="flex flex-col items-center p-24 min-h-screen">
<section className="mt-10">
<div className="mt-10">{children}</div>
</section>
</main>
</AbstractProvider>
<Toaster />
</body>
Expand Down
2 changes: 2 additions & 0 deletions examples/wagemos-cosmoskit-nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client'

import { stringToAccountId } from '@abstract-money/core'
import { betting } from '../_generated'
import { PlaceBetDialog } from './_components/place-bet-dialog'
import {
Expand All @@ -22,6 +23,7 @@ export default function Home() {
const { data, isLoading, isError } = betting.queries.useListRounds({
args: {},
chainName: 'neutron',
accountId: stringToAccountId('neutron-18'),
})
if (isLoading) return <p>Loading...</p>
if (isError) return <p>Error</p>
Expand Down
2 changes: 1 addition & 1 deletion examples/wagemos-graz-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@abstract-money/core": "workspace:*",
"@abstract-money/provider-graz": "workspace:*",
"@abstract-money/react": "workspace:*",
"@cosmjs/amino": "^0.32.2",
"@cosmjs/stargate": "^0.32.2",
"@hookform/resolvers": "^3.3.2",
"@osmosis-labs/math": "^5.1.0",
"@osmosis-labs/proto-codecs": "^5.1.0",
Expand Down
44 changes: 31 additions & 13 deletions examples/wagemos-graz-nextjs/src/_generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ export const betting = {
}: Omit<
Parameters<typeof useBettingBetsQuery<BettingTypes.BetsResponse>>[0],
'client'
> & { accountId?: AccountId; chainName: string | undefined }) => {
> & {
accountId: AccountId | undefined
chainName: string | undefined
}) => {
const {
data: bettingAppQueryClient,
isLoading: isBettingAppQueryClientLoading,
Expand Down Expand Up @@ -122,7 +125,10 @@ export const betting = {
}: Omit<
Parameters<typeof useBettingConfigQuery<BettingTypes.ConfigResponse>>[0],
'client'
> & { accountId?: AccountId; chainName: string | undefined }) => {
> & {
accountId: AccountId | undefined
chainName: string | undefined
}) => {
const {
data: bettingAppQueryClient,
isLoading: isBettingAppQueryClientLoading,
Expand Down Expand Up @@ -186,7 +192,10 @@ export const betting = {
typeof useBettingListOddsQuery<BettingTypes.ListOddsResponse>
>[0],
'client'
> & { accountId?: AccountId; chainName: string | undefined }) => {
> & {
accountId: AccountId | undefined
chainName: string | undefined
}) => {
const {
data: bettingAppQueryClient,
isLoading: isBettingAppQueryClientLoading,
Expand Down Expand Up @@ -249,7 +258,10 @@ export const betting = {
}: Omit<
Parameters<typeof useBettingOddsQuery<BettingTypes.OddsResponse>>[0],
'client'
> & { accountId?: AccountId; chainName: string | undefined }) => {
> & {
accountId: AccountId | undefined
chainName: string | undefined
}) => {
const {
data: bettingAppQueryClient,
isLoading: isBettingAppQueryClientLoading,
Expand Down Expand Up @@ -314,7 +326,10 @@ export const betting = {
typeof useBettingListRoundsQuery<BettingTypes.RoundsResponse>
>[0],
'client'
> & { accountId?: AccountId; chainName: string | undefined }) => {
> & {
accountId: AccountId | undefined
chainName: string | undefined
}) => {
const {
data: bettingAppQueryClient,
isLoading: isBettingAppQueryClientLoading,
Expand Down Expand Up @@ -377,7 +392,10 @@ export const betting = {
}: Omit<
Parameters<typeof useBettingRoundQuery<BettingTypes.RoundResponse>>[0],
'client'
> & { accountId?: AccountId; chainName: string | undefined }) => {
> & {
accountId: AccountId | undefined
chainName: string | undefined
}) => {
const {
data: bettingAppQueryClient,
isLoading: isBettingAppQueryClientLoading,
Expand Down Expand Up @@ -439,7 +457,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down Expand Up @@ -493,7 +511,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down Expand Up @@ -547,7 +565,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down Expand Up @@ -601,7 +619,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down Expand Up @@ -655,7 +673,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down Expand Up @@ -709,7 +727,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down Expand Up @@ -763,7 +781,7 @@ export const betting = {
{
chainName,
accountId,
}: { chainName: string | undefined; accountId?: AccountId },
}: { chainName: string | undefined; accountId: AccountId | undefined },
options?: Omit<
UseMutationOptions<
ExecuteResult,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client'

import { coin } from '@cosmjs/amino'
import { stringToAccountId } from '@abstract-money/core'
import { coin } from '@cosmjs/stargate'
import { zodResolver } from '@hookform/resolvers/zod'
import { DialogDescription } from '@radix-ui/react-dialog'
import { useAccount } from 'graz'
Expand Down Expand Up @@ -61,7 +62,10 @@ export function PlaceBetDialog({ round }: { round: RoundResponse }) {
const { toast } = useToast()

const { mutateAsync: placeBetAsync, isLoading } =
betting.mutations.usePlaceBet({ chainName: 'neutron' })
betting.mutations.usePlaceBet({
chainName: 'neutron',
accountId: stringToAccountId('neutron-18'),
})

const onSubmit: SubmitHandler<z.infer<typeof placeBetSchema>> = useCallback(
async ({ amount, accountSeq }) => {
Expand Down
Loading

0 comments on commit fc751aa

Please sign in to comment.