Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitayutanov committed Jul 25, 2024
1 parent fe757c7 commit 6139088
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useAccount } from '@gear-js/react-hooks';
import { web3FromSource } from '@polkadot/extension-dapp';
import { useMutation } from '@tanstack/react-query';
import { useContext } from 'react';

import { AccountContext } from 'context';

import {
FunctionName,
Expand All @@ -24,7 +25,7 @@ function usePrepareProgramTransaction<
serviceName,
functionName,
}: UsePrepareProgramTransactionParameters<TProgram, TServiceName, TFunctionName>) {
const { account: connectedAccount } = useAccount();
const { account: connectedAccount } = useContext(AccountContext);

const prepareTransaction = async ({
args,
Expand Down
1 change: 0 additions & 1 deletion utils/gear-hooks/src/hooks/sails/use-program-event.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useEffect } from 'react';
import { EventReturn, FunctionName, ServiceName, Event, EventCallbackArgs } from './types';

Expand Down
9 changes: 5 additions & 4 deletions utils/gear-hooks/src/hooks/sails/use-program-query.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { HexString, ICalculateReplyForHandleOptions } from '@gear-js/api';
import { useAccount, useApi } from '@gear-js/react-hooks';
import { useQueryClient, UseQueryOptions, useQuery } from '@tanstack/react-query';
import { useEffect } from 'react';
import { useContext, useEffect } from 'react';
import { ZERO_ADDRESS } from 'sails-js';

import { AccountContext, ApiContext } from 'context';

import { Query, QueryArgs, QueryName, QueryReturn, ServiceName } from './types';

type CalculateReplyOptions = Pick<ICalculateReplyForHandleOptions, 'at' | 'value'>;
Expand Down Expand Up @@ -36,10 +37,10 @@ function useProgramQuery<
query,
watch,
}: UseProgramQueryParameters<TProgram, TServiceName, TQueryName, TArgs, TQueryReturn>) {
const { api, isApiReady } = useApi();
const { api, isApiReady } = useContext(ApiContext);
const queryClient = useQueryClient();

const { account } = useAccount();
const { account } = useContext(AccountContext);
const originAddress = account?.decodedAddress || ZERO_ADDRESS;

const getQuery = () => {
Expand Down
6 changes: 4 additions & 2 deletions utils/gear-hooks/src/hooks/sails/use-program.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useApi } from '@gear-js/react-hooks';
import { GearApi, HexString } from '@gear-js/api';
import { UseQueryOptions, useQuery } from '@tanstack/react-query';
import { useContext } from 'react';

import { ApiContext } from 'context';

type Program<T> = {
new (api: GearApi, programId?: HexString): T;
Expand All @@ -15,7 +17,7 @@ type UseProgramParameters<T> = {
};

function useProgram<T>({ library, id, query }: UseProgramParameters<T>) {
const { api, isApiReady } = useApi();
const { api, isApiReady } = useContext(ApiContext);

const getProgram = () => {
if (!isApiReady) throw new Error('API is not initialized');
Expand Down
6 changes: 4 additions & 2 deletions utils/gear-hooks/src/hooks/sails/use-sails.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { HexString } from '@gear-js/api';
import { useApi } from '@gear-js/react-hooks';
import { useQuery } from '@tanstack/react-query';
import { useContext } from 'react';
import { Sails } from 'sails-js';

import { ApiContext } from 'context';

type UseSailsParameters = {
programId?: HexString | undefined;
idl?: string | undefined;
Expand All @@ -14,7 +16,7 @@ const DEFAULT_PARAMETERS = {
} as const;

function useSails({ programId, idl }: UseSailsParameters = DEFAULT_PARAMETERS) {
const { api, isApiReady } = useApi();
const { api, isApiReady } = useContext(ApiContext);

const getSails = async () => {
if (!isApiReady) throw new Error('API is not initialized');
Expand Down

0 comments on commit 6139088

Please sign in to comment.