Skip to content

Commit e5f852e

Browse files
authored
Merge pull request #24 from AbstractSDK/adair/readme
Update readmes and add graphql config for type resolution
2 parents f6acc2c + 7a6bcb6 commit e5f852e

File tree

10 files changed

+63
-15
lines changed

10 files changed

+63
-15
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
This monorepo contains the Typescript-based SDKs for AbstractSDK.
44

5+
## Development
6+
7+
1. Install the Abstract CLI:
8+
9+
```bash
10+
npm i -g @abstract-money/cli
11+
```
12+
513
## Prerequisites
614

715
- Ensure you have Node.js installed.

graphql.config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Allows the IDE to resolve the schema and provide autocomplete
2+
schema: "https://api.abstract.money/graphql"

packages/cli/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Abstract CLI
2+
3+
The Abstract CLI is a command-line tool for working with AbstractSDK apps and modules.
4+
5+
## Installation
6+
7+
```bash
8+
npm i -g @abstract-money/cli
9+
```
10+
11+
## Usage

packages/react/src/contexts/account-id.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export function AbstractAccountIdProvider({
2929
})
3030
}
3131

32+
/**
33+
* Hook to retrieve the provided Account id from the {@link AbstractAccountIdProvider} context.
34+
* @param accountId the Account id to set if the context is not provided.
35+
*/
3236
export function useAccountId({
3337
accountId,
3438
}: { accountId?: AbstractAccountId } = {}) {

packages/react/src/contexts/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const ConfigContext = React.createContext<Config | undefined>(undefined)
1010
export type AbstractConfigProps = {
1111
config?: Config
1212
}
13+
1314
export function AbstractConfigContext({
1415
children,
1516
config = { apiUrl: ABSTRACT_API_URL },
@@ -22,6 +23,9 @@ export function AbstractConfigContext({
2223
})
2324
}
2425

26+
/**
27+
* Internal hook to retrieve the Abstract configuration from the {@link AbstractConfigContext} context.
28+
*/
2529
export function useConfig() {
2630
const config = React.useContext(ConfigContext)
2731
if (!config)

packages/react/src/contexts/provider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ const client = new QueryClient({
1717
})
1818

1919
export type AbstractProviderProps = AbstractConfigProps
20+
21+
/**
22+
* Provide abstract configuration for the application.
23+
* @param config configuration.
24+
*/
2025
export function AbstractProvider({
2126
children,
2227
config,

packages/react/src/hooks/use-accounts.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { AbstractAccountId, AbstractQueryClient } from '@abstract-money/core'
22
import { UseQueryOptions, useQuery } from '@tanstack/react-query'
33
import React from 'react'
44

5+
/**
6+
* Loads all accounts for a given owner and chain.
7+
* @param owner address of the owner. Will automatically translate to other chains' addresses.
8+
* @param chain chain to load accounts for.
9+
* @param client
10+
*/
511
export function useAccounts(
612
{
713
owner,

packages/react/src/hooks/use-deposit.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ async function deposit({
2222
memo?: string
2323
}
2424
}) {
25-
const abstractAccountClient = AbstractAccountClient.fromQueryClient(
26-
await AbstractAccountQueryClient.load(abstractClient, accountId),
27-
abstractClient,
28-
)
25+
const accountClient = (
26+
await AbstractAccountQueryClient.load(abstractClient, accountId)
27+
).connectAbstractClient(abstractClient)
2928

30-
return abstractAccountClient.deposit(assets, args.fee, args.memo)
29+
return accountClient.deposit(assets, args.fee, args.memo)
3130
}
3231

3332
type DepositMutation = {
@@ -40,6 +39,10 @@ type DepositMutation = {
4039
}
4140
}
4241

42+
/**
43+
* Hook to deposit assets to an Account.
44+
* @param options deposit options.
45+
*/
4346
export function useDeposit(
4447
options: UseMutationOptions<DeliverTxResponse, unknown, DepositMutation> = {},
4548
) {

packages/react/src/hooks/use-execute.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
AbstractAccountClient,
32
AbstractAccountId,
43
AbstractAccountQueryClient,
54
AbstractClient,
@@ -20,12 +19,11 @@ async function execute({
2019
msgs: CosmosMsgForEmpty[]
2120
funds: Coin[]
2221
}) {
23-
const abstractAccountClient = AbstractAccountClient.fromQueryClient(
24-
await AbstractAccountQueryClient.load(abstractClient, accountId),
25-
abstractClient,
26-
)
22+
const accountClient = (
23+
await AbstractAccountQueryClient.load(abstractClient, accountId)
24+
).connectAbstractClient(abstractClient)
2725

28-
return abstractAccountClient.execute(msgs, funds)
26+
return accountClient.execute(msgs, funds)
2927
}
3028

3129
type ExecuteMutation = {
@@ -35,6 +33,10 @@ type ExecuteMutation = {
3533
abstractClient: AbstractClient
3634
}
3735

36+
/**
37+
* Hook to execute a transaction on an Account.
38+
* @param options execute options.
39+
*/
3840
export function useExecute(
3941
options: UseMutationOptions<ExecuteResult, Error, ExecuteMutation> = {},
4042
) {

packages/react/src/hooks/use-withdraw.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ async function withdraw({
2424
memo?: string
2525
}
2626
}) {
27-
const abstractAccountClient = AbstractAccountClient.fromQueryClient(
28-
await AbstractAccountQueryClient.load(abstractClient, accountId),
29-
abstractClient,
30-
)
27+
const abstractAccountClient = (
28+
await AbstractAccountQueryClient.load(abstractClient, accountId)
29+
).connectAbstractClient(abstractClient)
3130

3231
return abstractAccountClient.withdraw(assets, recipient, args.fee, args.memo)
3332
}
@@ -43,6 +42,10 @@ type WithdrawMutation = {
4342
}
4443
}
4544

45+
/**
46+
* Hook to withdraw assets from an Account.
47+
* @param options withdraw options.
48+
*/
4649
export function useWithdraw(
4750
options: UseMutationOptions<
4851
DeliverTxResponse,

0 commit comments

Comments
 (0)