Skip to content

Commit

Permalink
fix!: improve purse types (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsiegart authored Mar 8, 2024
1 parent 09ca26c commit c1c43a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
17 changes: 12 additions & 5 deletions packages/react-components/src/lib/context/AgoricContext.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { createContext } from 'react';
import { makeAgoricWalletConnection } from '@agoric/web-components';
import {
type AmountValue,
makeAgoricWalletConnection,
} from '@agoric/web-components';
import type { ChainStorageWatcher } from '@agoric/rpc';
import type { Brand, Amount, AssetKind } from '@agoric/ertp/src/types';

export type PursesJSONState<T extends AssetKind> = {
export type PurseJSONState<T extends AssetKind> = {
brand: Brand;
/** The board ID for this purse's brand */
brandBoardId: string;
Expand All @@ -14,9 +17,13 @@ export type PursesJSONState<T extends AssetKind> = {
/** The petname for this purse */
pursePetname: string;
/** The brand's displayInfo */
displayInfo: unknown;
// XXX Copied from @agoric/ertp/src/types-ambient.js
displayInfo: {
assetKind: AssetKind;
decimalPlaces?: number;
};
/** The purse's current balance */
value: unknown;
value: AmountValue;
currentAmountSlots: unknown;
currentAmount: Amount<T>;
};
Expand All @@ -31,7 +38,7 @@ export type AgoricState = {
connect?: () => Promise<void>;
chainStorageWatcher?: ChainStorageWatcher;
walletConnection?: AgoricWalletConnection;
purses?: PursesJSONState<AssetKind>[];
purses?: PurseJSONState<AssetKind>[];
offerIdsToPublicSubscribers?: Record<string, Record<string, string>>;
isSmartWalletProvisioned?: boolean;
provisionSmartWallet?: AgoricWalletConnection['provisionSmartWallet'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PropsWithChildren, useState } from 'react';
import {
AgoricContext,
type PursesJSONState,
type PurseJSONState,
type AgoricWalletConnection,
} from './AgoricContext';
import { SigningStargateClient } from '@cosmjs/stargate';
Expand Down Expand Up @@ -55,9 +55,9 @@ export const AgoricProviderLite = ({
const [chainStorageWatcher, setChainStorageWatcher] = useState<
ChainStorageWatcher | undefined
>(undefined);
const [purses, setPurses] = useState<
PursesJSONState<AssetKind>[] | undefined
>(undefined);
const [purses, setPurses] = useState<PurseJSONState<AssetKind>[] | undefined>(
undefined,
);
const [offerIdsToPublicSubscribers, setOfferIdsToPublicSubscribers] =
useState<Record<string, Record<string, string>> | undefined>(undefined);
const [isSmartWalletProvisioned, setIsSmartWalletProvisioned] = useState<
Expand Down

0 comments on commit c1c43a1

Please sign in to comment.