Skip to content

Commit

Permalink
fixup! lint
Browse files Browse the repository at this point in the history
  • Loading branch information
amessbee committed Jan 2, 2025
1 parent 63ef0db commit 5b7c6a7
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Trade } from './components/Trade';

const { entries, fromEntries } = Object;

type Wallet = Awaited<ReturnType<typeof makeAgoricWalletConnection>>;
type Wallet = Awaited;

const ENDPOINTS = {
RPC: 'http://localhost:26657',
Expand Down Expand Up @@ -47,14 +47,14 @@ const watcher = makeAgoricChainStorageWatcher(ENDPOINTS.API, 'agoriclocal');
interface AppState {
wallet?: Wallet;
offerUpInstance?: unknown;
brands?: Record<string, unknown>;
purses?: Array<Purse>;
brands?: Record;
purses?: Array;
}

const useAppStore = create<AppState>(() => ({}));

const setup = async () => {
watcher.watchLatest<Array<[string, unknown]>>(
watcher.watchLatest<Array>(
[Kind.Data, 'published.agoricNames.instance'],
instances => {
console.log('got instances', instances);
Expand All @@ -64,7 +64,7 @@ const setup = async () => {
},
);

watcher.watchLatest<Array<[string, unknown]>>(
watcher.watchLatest<Array>(
[Kind.Data, 'published.agoricNames.brand'],
brands => {
console.log('Got brands', brands);
Expand All @@ -90,29 +90,27 @@ const connectWallet = async () => {
useAppStore.setState({ purses });
}
} catch (error) {
throw new Error(`Chain is not running. Please start the chain first.: ${error}`);
throw new Error(
`Chain is not running. Please start the chain first.: ${error}`,
);
}
};

const makeOffer = (giveValue: bigint, wantChoices: Record<string, bigint>) => {
const makeOffer = (giveValue: bigint, wantChoices: Record) => {
const { wallet, offerUpInstance, brands } = useAppStore.getState();
if (!offerUpInstance) {

alert('No contract instance found on the chain RPC: ' + ENDPOINTS.RPC);
throw Error('no contract instance');
}
if (!(brands && brands.IST && brands.Item)) {

alert('Brands not available');
throw Error('brands not available');
}


const value = makeCopyBag(entries(wantChoices));
const want = { Items: { brand: brands.Item, value } };
const give = { Price: { brand: brands.IST, value: giveValue } };


wallet?.makeOffer(
{
source: 'contract',
Expand Down

0 comments on commit 5b7c6a7

Please sign in to comment.