@filoz/synapse-react 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/calibration.d.ts +1 -2
- package/dist/src/calibration.d.ts.map +1 -1
- package/dist/src/calibration.js.map +1 -1
- package/dist/src/erc20.d.ts +6 -7
- package/dist/src/erc20.d.ts.map +1 -1
- package/dist/src/erc20.js +1 -1
- package/dist/src/erc20.js.map +1 -1
- package/dist/src/filsnap.d.ts.map +1 -1
- package/dist/src/filsnap.js +3 -0
- package/dist/src/filsnap.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/payments/index.d.ts +13 -14
- package/dist/src/payments/index.d.ts.map +1 -1
- package/dist/src/payments/index.js +19 -20
- package/dist/src/payments/index.js.map +1 -1
- package/dist/src/payments/use-deposit-and-approve.d.ts +4 -5
- package/dist/src/payments/use-deposit-and-approve.d.ts.map +1 -1
- package/dist/src/payments/use-deposit-and-approve.js +1 -1
- package/dist/src/payments/use-deposit-and-approve.js.map +1 -1
- package/dist/src/warm-storage/use-create-data-set.d.ts +11 -5
- package/dist/src/warm-storage/use-create-data-set.d.ts.map +1 -1
- package/dist/src/warm-storage/use-create-data-set.js +3 -4
- package/dist/src/warm-storage/use-create-data-set.js.map +1 -1
- package/dist/src/warm-storage/use-data-sets.d.ts +11 -21
- package/dist/src/warm-storage/use-data-sets.d.ts.map +1 -1
- package/dist/src/warm-storage/use-data-sets.js +6 -22
- package/dist/src/warm-storage/use-data-sets.js.map +1 -1
- package/dist/src/warm-storage/use-delete-piece.d.ts +3 -3
- package/dist/src/warm-storage/use-delete-piece.d.ts.map +1 -1
- package/dist/src/warm-storage/use-delete-piece.js +6 -5
- package/dist/src/warm-storage/use-delete-piece.js.map +1 -1
- package/dist/src/warm-storage/use-providers.d.ts +3 -3
- package/dist/src/warm-storage/use-providers.d.ts.map +1 -1
- package/dist/src/warm-storage/use-providers.js +2 -2
- package/dist/src/warm-storage/use-providers.js.map +1 -1
- package/dist/src/warm-storage/use-service-price.d.ts +4 -4
- package/dist/src/warm-storage/use-service-price.d.ts.map +1 -1
- package/dist/src/warm-storage/use-service-price.js +2 -2
- package/dist/src/warm-storage/use-service-price.js.map +1 -1
- package/dist/src/warm-storage/use-upload.d.ts +10 -2
- package/dist/src/warm-storage/use-upload.d.ts.map +1 -1
- package/dist/src/warm-storage/use-upload.js +2 -2
- package/dist/src/warm-storage/use-upload.js.map +1 -1
- package/package.json +23 -9
- package/src/calibration.ts +3 -5
- package/src/erc20.ts +7 -7
- package/src/filsnap.ts +4 -0
- package/src/index.ts +0 -1
- package/src/payments/index.ts +36 -59
- package/src/payments/use-deposit-and-approve.ts +8 -12
- package/src/warm-storage/use-create-data-set.ts +6 -7
- package/src/warm-storage/use-data-sets.ts +7 -29
- package/src/warm-storage/use-delete-piece.ts +8 -6
- package/src/warm-storage/use-providers.ts +3 -3
- package/src/warm-storage/use-service-price.ts +8 -8
- package/src/warm-storage/use-upload.ts +2 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SessionKey } from '@filoz/synapse-core/session-key';
|
|
2
|
-
import {
|
|
2
|
+
import type { PdpDataSet } from '@filoz/synapse-core/warm-storage';
|
|
3
3
|
import { type MutateOptions } from '@tanstack/react-query';
|
|
4
4
|
import type { TransactionReceipt } from 'viem';
|
|
5
5
|
export interface UseDeletePieceProps {
|
|
@@ -8,8 +8,8 @@ export interface UseDeletePieceProps {
|
|
|
8
8
|
mutation?: Omit<MutateOptions<TransactionReceipt, Error, UseDeletePieceVariables>, 'mutationFn'>;
|
|
9
9
|
}
|
|
10
10
|
export interface UseDeletePieceVariables {
|
|
11
|
-
dataSet:
|
|
11
|
+
dataSet: PdpDataSet;
|
|
12
12
|
pieceId: bigint;
|
|
13
13
|
}
|
|
14
|
-
export declare function useDeletePiece(props: UseDeletePieceProps): import("@tanstack/react-query").UseMutationResult<TransactionReceipt
|
|
14
|
+
export declare function useDeletePiece(props: UseDeletePieceProps): import("@tanstack/react-query").UseMutationResult<TransactionReceipt, Error, UseDeletePieceVariables, unknown>;
|
|
15
15
|
//# sourceMappingURL=use-delete-piece.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-delete-piece.d.ts","sourceRoot":"","sources":["../../../src/warm-storage/use-delete-piece.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"use-delete-piece.d.ts","sourceRoot":"","sources":["../../../src/warm-storage/use-delete-piece.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAE,KAAK,aAAa,EAA+B,MAAM,uBAAuB,CAAA;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAK9C,MAAM,WAAW,mBAAmB;IAIlC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/B,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,kBAAkB,EAAE,KAAK,EAAE,uBAAuB,CAAC,EAAE,YAAY,CAAC,CAAA;CACjG;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,UAAU,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CAChB;AACD,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,kHAoCxD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getChain } from '@filoz/synapse-core/chains';
|
|
2
|
-
import
|
|
2
|
+
import * as SP from '@filoz/synapse-core/sp';
|
|
3
3
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { waitForTransactionReceipt } from 'viem/actions';
|
|
4
5
|
import { useAccount, useChainId, useConfig } from 'wagmi';
|
|
5
6
|
import { getConnectorClient } from 'wagmi/actions';
|
|
6
7
|
export function useDeletePiece(props) {
|
|
@@ -20,14 +21,14 @@ export function useDeletePiece(props) {
|
|
|
20
21
|
if (props?.sessionKey && (await props?.sessionKey.isValid(connectorClient, 'SchedulePieceRemovals'))) {
|
|
21
22
|
connectorClient = props?.sessionKey.client(chain, client.transport);
|
|
22
23
|
}
|
|
23
|
-
const deletePieceRsp = await
|
|
24
|
-
|
|
24
|
+
const deletePieceRsp = await SP.schedulePieceDeletion(connectorClient, {
|
|
25
|
+
serviceURL: dataSet.provider.pdp.serviceURL,
|
|
25
26
|
dataSetId: dataSet.dataSetId,
|
|
26
27
|
clientDataSetId: dataSet.clientDataSetId,
|
|
27
28
|
pieceId,
|
|
28
29
|
});
|
|
29
|
-
props?.onHash?.(deletePieceRsp.
|
|
30
|
-
const rsp = await
|
|
30
|
+
props?.onHash?.(deletePieceRsp.hash);
|
|
31
|
+
const rsp = await waitForTransactionReceipt(client, deletePieceRsp);
|
|
31
32
|
queryClient.invalidateQueries({
|
|
32
33
|
queryKey: ['synapse-warm-storage-data-sets', account.address],
|
|
33
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-delete-piece.js","sourceRoot":"","sources":["../../../src/warm-storage/use-delete-piece.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD,OAAO,
|
|
1
|
+
{"version":3,"file":"use-delete-piece.js","sourceRoot":"","sources":["../../../src/warm-storage/use-delete-piece.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD,OAAO,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAE5C,OAAO,EAAsB,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAelD,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,OAAO,GAAG,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC/B,MAAM,OAAO,GAAG,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IACtC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;IAEjC,OAAO,WAAW,CAAC;QACjB,GAAG,KAAK,EAAE,QAAQ;QAClB,UAAU,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAA2B,EAAE,EAAE;YAClE,IAAI,eAAe,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE;gBACrD,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,OAAO;aACR,CAAC,CAAA;YAEF,IAAI,KAAK,EAAE,UAAU,IAAI,CAAC,MAAM,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC;gBACrG,eAAe,GAAG,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,CAAA;YACrE,CAAC;YAED,MAAM,cAAc,GAAG,MAAM,EAAE,CAAC,qBAAqB,CAAC,eAAe,EAAE;gBACrE,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU;gBAC3C,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,eAAe,EAAE,OAAO,CAAC,eAAe;gBACxC,OAAO;aACR,CAAC,CAAA;YAEF,KAAK,EAAE,MAAM,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;YACpC,MAAM,GAAG,GAAG,MAAM,yBAAyB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;YAEnE,WAAW,CAAC,iBAAiB,CAAC;gBAC5B,QAAQ,EAAE,CAAC,gCAAgC,EAAE,OAAO,CAAC,OAAO,CAAC;aAC9D,CAAC,CAAA;YACF,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getApprovedPDPProviders } from '@filoz/synapse-core/sp-registry';
|
|
2
2
|
import { type UseQueryOptions } from '@tanstack/react-query';
|
|
3
3
|
export interface UseProvidersProps {
|
|
4
4
|
query?: Omit<UseQueryOptions<UseProvidersResult>, 'queryKey' | 'queryFn'>;
|
|
5
5
|
}
|
|
6
|
-
export type UseProvidersResult =
|
|
7
|
-
export declare function useProviders(props?: UseProvidersProps): import("@tanstack/react-query").UseQueryResult<
|
|
6
|
+
export type UseProvidersResult = getApprovedPDPProviders.OutputType;
|
|
7
|
+
export declare function useProviders(props?: UseProvidersProps): import("@tanstack/react-query").UseQueryResult<getApprovedPDPProviders.OutputType, Error>;
|
|
8
8
|
//# sourceMappingURL=use-providers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-providers.d.ts","sourceRoot":"","sources":["../../../src/warm-storage/use-providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use-providers.d.ts","sourceRoot":"","sources":["../../../src/warm-storage/use-providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AACzE,OAAO,EAAE,KAAK,eAAe,EAAY,MAAM,uBAAuB,CAAA;AAGtE,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC,CAAA;CAC1E;AAED,MAAM,MAAM,kBAAkB,GAAG,uBAAuB,CAAC,UAAU,CAAA;AAEnE,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,iBAAiB,6FAUrD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getApprovedPDPProviders } from '@filoz/synapse-core/sp-registry';
|
|
2
2
|
import { useQuery } from '@tanstack/react-query';
|
|
3
3
|
import { useConfig } from 'wagmi';
|
|
4
4
|
export function useProviders(props) {
|
|
@@ -7,7 +7,7 @@ export function useProviders(props) {
|
|
|
7
7
|
...props?.query,
|
|
8
8
|
queryKey: ['synapse-warm-storage-providers'],
|
|
9
9
|
queryFn: () => {
|
|
10
|
-
return
|
|
10
|
+
return getApprovedPDPProviders(config.getClient());
|
|
11
11
|
},
|
|
12
12
|
});
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-providers.js","sourceRoot":"","sources":["../../../src/warm-storage/use-providers.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"use-providers.js","sourceRoot":"","sources":["../../../src/warm-storage/use-providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AACzE,OAAO,EAAwB,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAQjC,MAAM,UAAU,YAAY,CAAC,KAAyB;IACpD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAE1B,OAAO,QAAQ,CAAC;QACd,GAAG,KAAK,EAAE,KAAK;QACf,QAAQ,EAAE,CAAC,gCAAgC,CAAC;QAC5C,OAAO,EAAE,GAAG,EAAE;YACZ,OAAO,uBAAuB,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAA;QACpD,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getServicePrice } from '@filoz/synapse-core/warm-storage';
|
|
2
2
|
import { type UseQueryOptions } from '@tanstack/react-query';
|
|
3
|
+
export type UseServicePriceResult = getServicePrice.OutputType;
|
|
3
4
|
export interface UseServicePriceProps {
|
|
4
|
-
query?: Omit<UseQueryOptions<
|
|
5
|
+
query?: Omit<UseQueryOptions<UseServicePriceResult>, 'queryKey' | 'queryFn'>;
|
|
5
6
|
}
|
|
6
|
-
export
|
|
7
|
-
export declare function useServicePrice(props?: UseServicePriceProps): import("@tanstack/react-query").UseQueryResult<ServicePriceResult, Error>;
|
|
7
|
+
export declare function useServicePrice(props?: UseServicePriceProps): import("@tanstack/react-query").UseQueryResult<getServicePrice.OutputType, Error>;
|
|
8
8
|
//# sourceMappingURL=use-service-price.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-service-price.d.ts","sourceRoot":"","sources":["../../../src/warm-storage/use-service-price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use-service-price.d.ts","sourceRoot":"","sources":["../../../src/warm-storage/use-service-price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAE,KAAK,eAAe,EAAY,MAAM,uBAAuB,CAAA;AAMtE,MAAM,MAAM,qBAAqB,GAAG,eAAe,CAAC,UAAU,CAAA;AAK9D,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,qBAAqB,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC,CAAA;CAC7E;AAQD,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,oBAAoB,qFAW3D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getServicePrice } from '@filoz/synapse-core/warm-storage';
|
|
2
2
|
import { useQuery } from '@tanstack/react-query';
|
|
3
3
|
import { useConfig } from 'wagmi';
|
|
4
4
|
export function useServicePrice(props) {
|
|
@@ -7,7 +7,7 @@ export function useServicePrice(props) {
|
|
|
7
7
|
...props?.query,
|
|
8
8
|
queryKey: ['synapse-warm-storage-get-service-price'],
|
|
9
9
|
queryFn: async () => {
|
|
10
|
-
const result = await
|
|
10
|
+
const result = await getServicePrice(config.getClient());
|
|
11
11
|
return result;
|
|
12
12
|
},
|
|
13
13
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-service-price.js","sourceRoot":"","sources":["../../../src/warm-storage/use-service-price.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"use-service-price.js","sourceRoot":"","sources":["../../../src/warm-storage/use-service-price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAwB,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAoBjC,MAAM,UAAU,eAAe,CAAC,KAA4B;IAC1D,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAE1B,OAAO,QAAQ,CAAC;QACd,GAAG,KAAK,EAAE,KAAK;QACf,QAAQ,EAAE,CAAC,wCAAwC,CAAC;QACpD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAA;YACxD,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SessionKey } from '@filoz/synapse-core/session-key';
|
|
2
|
-
import type
|
|
2
|
+
import { type AddPiecesSuccess } from '@filoz/synapse-core/sp';
|
|
3
3
|
import { type MutateOptions } from '@tanstack/react-query';
|
|
4
4
|
export interface UseUploadProps {
|
|
5
5
|
onHash?: (hash: string) => void;
|
|
@@ -10,5 +10,13 @@ export interface UseUploadVariables {
|
|
|
10
10
|
files: File[];
|
|
11
11
|
dataSetId: bigint;
|
|
12
12
|
}
|
|
13
|
-
export declare function useUpload(props: UseUploadProps): import("@tanstack/react-query").UseMutationResult<
|
|
13
|
+
export declare function useUpload(props: UseUploadProps): import("@tanstack/react-query").UseMutationResult<{
|
|
14
|
+
txHash: `0x${string}`;
|
|
15
|
+
txStatus: "confirmed";
|
|
16
|
+
dataSetId: bigint;
|
|
17
|
+
pieceCount: number;
|
|
18
|
+
addMessageOk: true;
|
|
19
|
+
piecesAdded: true;
|
|
20
|
+
confirmedPieceIds: bigint[];
|
|
21
|
+
}, Error, UseUploadVariables, unknown>;
|
|
14
22
|
//# sourceMappingURL=use-upload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["../../../src/warm-storage/use-upload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["../../../src/warm-storage/use-upload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAEjE,OAAO,EAAE,KAAK,gBAAgB,EAAU,MAAM,wBAAwB,CAAA;AACtE,OAAO,EAAE,KAAK,aAAa,EAA+B,MAAM,uBAAuB,CAAA;AAIvF,MAAM,WAAW,cAAc;IAI7B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/B,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE,KAAK,EAAE,kBAAkB,CAAC,EAAE,YAAY,CAAC,CAAA;CAC1F;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;CAClB;AACD,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc;;;;;;;;uCAiC9C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getChain } from '@filoz/synapse-core/chains';
|
|
2
2
|
import * as SP from '@filoz/synapse-core/sp';
|
|
3
|
-
import { upload } from '@filoz/synapse-core/
|
|
3
|
+
import { upload } from '@filoz/synapse-core/sp';
|
|
4
4
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
5
5
|
import { useAccount, useChainId, useConfig } from 'wagmi';
|
|
6
6
|
import { getConnectorClient } from 'wagmi/actions';
|
|
@@ -26,7 +26,7 @@ export function useUpload(props) {
|
|
|
26
26
|
data: files,
|
|
27
27
|
});
|
|
28
28
|
props?.onHash?.(uploadRsp.txHash);
|
|
29
|
-
const rsp = await SP.
|
|
29
|
+
const rsp = await SP.waitForAddPieces(uploadRsp);
|
|
30
30
|
queryClient.invalidateQueries({
|
|
31
31
|
queryKey: ['synapse-warm-storage-data-sets', account.address],
|
|
32
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-upload.js","sourceRoot":"","sources":["../../../src/warm-storage/use-upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"use-upload.js","sourceRoot":"","sources":["../../../src/warm-storage/use-upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD,OAAO,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC5C,OAAO,EAAyB,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACtE,OAAO,EAAsB,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACvF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAelD,MAAM,UAAU,SAAS,CAAC,KAAqB;IAC7C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,OAAO,GAAG,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC/B,MAAM,OAAO,GAAG,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IACtC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;IAEjC,OAAO,WAAW,CAAC;QACjB,GAAG,KAAK,EAAE,QAAQ;QAClB,UAAU,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAsB,EAAE,EAAE;YAC7D,IAAI,eAAe,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE;gBACrD,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,OAAO;aACR,CAAC,CAAA;YACF,IAAI,KAAK,EAAE,UAAU,IAAI,CAAC,MAAM,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC;gBACzF,eAAe,GAAG,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,CAAA;YACrE,CAAC;YAED,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,eAAe,EAAE;gBAC9C,SAAS;gBACT,IAAI,EAAE,KAAK;aACZ,CAAC,CAAA;YAEF,KAAK,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;YACjC,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAA;YAEhD,WAAW,CAAC,iBAAiB,CAAC;gBAC5B,QAAQ,EAAE,CAAC,gCAAgC,EAAE,OAAO,CAAC,OAAO,CAAC;aAC9D,CAAC,CAAA;YACF,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@filoz/synapse-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React hooks for interacting with Filecoin Onchain Cloud smart contracts",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,6 +29,17 @@
|
|
|
29
29
|
".": {
|
|
30
30
|
"types": "./dist/src/index.d.ts",
|
|
31
31
|
"default": "./dist/src/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./filsnap": {
|
|
34
|
+
"types": "./dist/src/filsnap.d.ts",
|
|
35
|
+
"default": "./dist/src/filsnap.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"typesVersions": {
|
|
39
|
+
"*": {
|
|
40
|
+
"filsnap": [
|
|
41
|
+
"./dist/src/filsnap"
|
|
42
|
+
]
|
|
32
43
|
}
|
|
33
44
|
},
|
|
34
45
|
"files": [
|
|
@@ -53,7 +64,7 @@
|
|
|
53
64
|
]
|
|
54
65
|
},
|
|
55
66
|
"lint": {
|
|
56
|
-
"command": "biome check
|
|
67
|
+
"command": "biome check .",
|
|
57
68
|
"files": [
|
|
58
69
|
"src/**/*.ts",
|
|
59
70
|
"../../biome.json"
|
|
@@ -66,13 +77,14 @@
|
|
|
66
77
|
},
|
|
67
78
|
"dependencies": {
|
|
68
79
|
"@hugomrdias/filsnap-adapter": "^3.3.8",
|
|
69
|
-
"@filoz/synapse-core": "^0.
|
|
80
|
+
"@filoz/synapse-core": "^0.2.0"
|
|
70
81
|
},
|
|
71
82
|
"devDependencies": {
|
|
72
|
-
"@biomejs/biome": "2.3.
|
|
73
|
-
"@types/node": "^
|
|
74
|
-
"type-fest": "^5.
|
|
75
|
-
"typescript": "5.9.3"
|
|
83
|
+
"@biomejs/biome": "2.3.13",
|
|
84
|
+
"@types/node": "^25.1.0",
|
|
85
|
+
"type-fest": "^5.4.3",
|
|
86
|
+
"typescript": "5.9.3",
|
|
87
|
+
"viem": "^2.45.1"
|
|
76
88
|
},
|
|
77
89
|
"publishConfig": {
|
|
78
90
|
"access": "public"
|
|
@@ -84,11 +96,13 @@
|
|
|
84
96
|
},
|
|
85
97
|
"peerDependencies": {
|
|
86
98
|
"@tanstack/react-query": "5.x",
|
|
99
|
+
"@wagmi/core": "3.x",
|
|
87
100
|
"viem": "2.x",
|
|
88
|
-
"wagmi": "
|
|
101
|
+
"wagmi": "3.x"
|
|
89
102
|
},
|
|
90
103
|
"scripts": {
|
|
91
104
|
"build": "wireit",
|
|
92
|
-
"lint": "wireit"
|
|
105
|
+
"lint": "wireit",
|
|
106
|
+
"lint:fix": "biome check --fix ."
|
|
93
107
|
}
|
|
94
108
|
}
|
package/src/calibration.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { waitForTransactionReceipt } from 'viem/actions'
|
|
|
5
5
|
import { useChainId, useConfig } from 'wagmi'
|
|
6
6
|
import { getConnectorClient } from 'wagmi/actions'
|
|
7
7
|
|
|
8
|
-
interface UseFundWalletProps {
|
|
8
|
+
export interface UseFundWalletProps {
|
|
9
9
|
/**
|
|
10
10
|
* The mutation options.
|
|
11
11
|
*/
|
|
@@ -19,10 +19,8 @@ interface UseFundWalletProps {
|
|
|
19
19
|
/**
|
|
20
20
|
* Fund the wallet with USDFC and FIL.
|
|
21
21
|
*
|
|
22
|
-
* @param props - The props for the fund wallet.
|
|
23
|
-
* @
|
|
24
|
-
* @param props.onHash - The callback to call when the hash is available.
|
|
25
|
-
* @returns
|
|
22
|
+
* @param props - The props for the fund wallet. {@link UseFundWalletProps}
|
|
23
|
+
* @returns The mutation to fund the wallet.
|
|
26
24
|
*/
|
|
27
25
|
export function useFundWallet(props?: UseFundWalletProps) {
|
|
28
26
|
const config = useConfig()
|
package/src/erc20.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getChain } from '@filoz/synapse-core/chains'
|
|
2
|
-
import type {
|
|
2
|
+
import type { balance } from '@filoz/synapse-core/erc20'
|
|
3
3
|
import * as erc20 from '@filoz/synapse-core/erc20'
|
|
4
4
|
import {
|
|
5
5
|
type MutateOptions,
|
|
@@ -15,8 +15,8 @@ import { waitForTransactionReceipt } from 'viem/actions'
|
|
|
15
15
|
import { useAccount, useChainId, useConfig } from 'wagmi'
|
|
16
16
|
import { getConnectorClient } from 'wagmi/actions'
|
|
17
17
|
|
|
18
|
-
interface UseERC20BalanceProps extends SetOptional<
|
|
19
|
-
query?: Omit<UseQueryOptions<
|
|
18
|
+
export interface UseERC20BalanceProps extends SetOptional<balance.OptionsType, 'address'> {
|
|
19
|
+
query?: Omit<UseQueryOptions<balance.OutputType>, 'queryKey' | 'queryFn'>
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -48,9 +48,9 @@ export function useERC20Balance(props: UseERC20BalanceProps) {
|
|
|
48
48
|
return result
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
type UseApproveAllowanceVariables = Pick<erc20.
|
|
51
|
+
export type UseApproveAllowanceVariables = Pick<erc20.approve.OptionsType, 'amount'>
|
|
52
52
|
|
|
53
|
-
interface UseApproveAllowanceProps extends Omit<erc20.
|
|
53
|
+
export interface UseApproveAllowanceProps extends Omit<erc20.approve.OptionsType, 'amount'> {
|
|
54
54
|
/**
|
|
55
55
|
* The mutation options.
|
|
56
56
|
*/
|
|
@@ -64,7 +64,7 @@ interface UseApproveAllowanceProps extends Omit<erc20.ERC20ApproveAllowanceOptio
|
|
|
64
64
|
/**
|
|
65
65
|
* Approve the allowance of the ERC20 token to the payments contract.
|
|
66
66
|
*
|
|
67
|
-
* @param props - The props to use.
|
|
67
|
+
* @param props - The props to use. {@link UseApproveAllowanceProps}
|
|
68
68
|
* @returns The mutation to approve the allowance of the ERC20 token to the payments contract.
|
|
69
69
|
*/
|
|
70
70
|
export function useApproveAllowance(props?: UseApproveAllowanceProps) {
|
|
@@ -84,7 +84,7 @@ export function useApproveAllowance(props?: UseApproveAllowanceProps) {
|
|
|
84
84
|
connector: account.connector,
|
|
85
85
|
})
|
|
86
86
|
|
|
87
|
-
const approve = await erc20.
|
|
87
|
+
const approve = await erc20.approve(client, {
|
|
88
88
|
token: props?.token,
|
|
89
89
|
amount,
|
|
90
90
|
})
|
package/src/filsnap.ts
CHANGED
|
@@ -7,6 +7,10 @@ const SNAP_ID = 'npm:filsnap' //'local:http://localhost:8080'
|
|
|
7
7
|
export const useFilsnap = ({ version, force }: { version?: string; force?: boolean } = {}) => {
|
|
8
8
|
useAccountEffect({
|
|
9
9
|
onConnect: async (data) => {
|
|
10
|
+
if (!data.connector || !('getProvider' in data.connector)) {
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
const provider = (await data.connector.getProvider()) as EIP1193Provider
|
|
11
15
|
if (provider.isMetaMask) {
|
|
12
16
|
await getOrInstallSnap(provider, SNAP_ID, version ?? '*', force)
|
package/src/index.ts
CHANGED
package/src/payments/index.ts
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import { getChain } from '@filoz/synapse-core/chains'
|
|
2
|
-
import {
|
|
3
|
-
type AccountInfoOptions,
|
|
4
|
-
type AccountInfoResult,
|
|
5
|
-
accountInfo,
|
|
6
|
-
type DepositOptions,
|
|
7
|
-
deposit,
|
|
8
|
-
type OperatorApprovalsOptions,
|
|
9
|
-
type OperatorApprovalsResult,
|
|
10
|
-
operatorApprovals,
|
|
11
|
-
setOperatorApproval,
|
|
12
|
-
type WithdrawOptions,
|
|
13
|
-
withdraw,
|
|
14
|
-
} from '@filoz/synapse-core/pay'
|
|
2
|
+
import { accounts, deposit, operatorApprovals, setOperatorApproval, withdraw } from '@filoz/synapse-core/pay'
|
|
15
3
|
import {
|
|
16
4
|
type MutateOptions,
|
|
17
5
|
skipToken,
|
|
@@ -23,16 +11,16 @@ import {
|
|
|
23
11
|
import type { SetOptional } from 'type-fest'
|
|
24
12
|
import type { Address, TransactionReceipt } from 'viem'
|
|
25
13
|
import { waitForTransactionReceipt } from 'viem/actions'
|
|
26
|
-
import { useAccount, useBlock, useChainId, useConfig } from 'wagmi'
|
|
14
|
+
import { useAccount, useBlock, useChainId, useConfig, useConnection } from 'wagmi'
|
|
27
15
|
import { getConnectorClient } from 'wagmi/actions'
|
|
28
16
|
|
|
29
|
-
interface UseAccountInfoProps extends SetOptional<
|
|
17
|
+
export interface UseAccountInfoProps extends SetOptional<accounts.OptionsType, 'address'> {
|
|
30
18
|
/**
|
|
31
19
|
* Whether to watch blocks.
|
|
32
20
|
* @default false
|
|
33
21
|
*/
|
|
34
22
|
watch?: boolean
|
|
35
|
-
query?: Omit<UseQueryOptions<
|
|
23
|
+
query?: Omit<UseQueryOptions<accounts.OutputType>, 'queryKey' | 'queryFn'>
|
|
36
24
|
}
|
|
37
25
|
|
|
38
26
|
/**
|
|
@@ -50,7 +38,7 @@ export function useAccountInfo(props?: UseAccountInfoProps) {
|
|
|
50
38
|
const chainId = useChainId({ config })
|
|
51
39
|
const chain = getChain(chainId)
|
|
52
40
|
const token = props?.token ?? chain.contracts.usdfc.address
|
|
53
|
-
const
|
|
41
|
+
const owner = props?.address
|
|
54
42
|
const { data } = useBlock({
|
|
55
43
|
blockTag: 'latest',
|
|
56
44
|
chainId,
|
|
@@ -59,12 +47,13 @@ export function useAccountInfo(props?: UseAccountInfoProps) {
|
|
|
59
47
|
|
|
60
48
|
const result = useQuery({
|
|
61
49
|
...props?.query,
|
|
62
|
-
queryKey: ['synapse-payments-account-info',
|
|
63
|
-
queryFn:
|
|
50
|
+
queryKey: ['synapse-payments-account-info', owner, token, data?.number?.toString()],
|
|
51
|
+
queryFn: owner
|
|
64
52
|
? async () => {
|
|
65
|
-
return await
|
|
53
|
+
return await accounts(config.getClient(), {
|
|
66
54
|
token,
|
|
67
|
-
address,
|
|
55
|
+
address: owner,
|
|
56
|
+
|
|
68
57
|
blockNumber: data?.number,
|
|
69
58
|
})
|
|
70
59
|
}
|
|
@@ -73,12 +62,10 @@ export function useAccountInfo(props?: UseAccountInfoProps) {
|
|
|
73
62
|
return result
|
|
74
63
|
}
|
|
75
64
|
|
|
76
|
-
export interface UseOperatorApprovalsProps extends SetOptional<
|
|
77
|
-
query?: Omit<UseQueryOptions<
|
|
65
|
+
export interface UseOperatorApprovalsProps extends SetOptional<operatorApprovals.OptionsType, 'address'> {
|
|
66
|
+
query?: Omit<UseQueryOptions<operatorApprovals.OutputType>, 'queryKey' | 'queryFn'>
|
|
78
67
|
}
|
|
79
68
|
|
|
80
|
-
export type { OperatorApprovalsResult } from '@filoz/synapse-core/pay'
|
|
81
|
-
|
|
82
69
|
/**
|
|
83
70
|
* Get the operator approvals from the payments contract.
|
|
84
71
|
*
|
|
@@ -90,7 +77,7 @@ export function useOperatorApprovals(props?: UseOperatorApprovalsProps) {
|
|
|
90
77
|
const chainId = useChainId({ config })
|
|
91
78
|
const chain = getChain(chainId)
|
|
92
79
|
const token = props?.token ?? chain.contracts.usdfc.address
|
|
93
|
-
const operator = props?.operator ?? chain.contracts.
|
|
80
|
+
const operator = props?.operator ?? chain.contracts.fwss.address
|
|
94
81
|
const address = props?.address
|
|
95
82
|
|
|
96
83
|
const result = useQuery({
|
|
@@ -109,8 +96,8 @@ export function useOperatorApprovals(props?: UseOperatorApprovalsProps) {
|
|
|
109
96
|
return result
|
|
110
97
|
}
|
|
111
98
|
|
|
112
|
-
type UseDepositVariables = Pick<
|
|
113
|
-
interface UseDepositProps extends Omit<
|
|
99
|
+
export type UseDepositVariables = Pick<deposit.OptionsType, 'amount'>
|
|
100
|
+
export interface UseDepositProps extends Omit<deposit.OptionsType, 'amount'> {
|
|
114
101
|
/**
|
|
115
102
|
* The mutation options.
|
|
116
103
|
*/
|
|
@@ -124,21 +111,17 @@ interface UseDepositProps extends Omit<DepositOptions, 'amount'> {
|
|
|
124
111
|
/**
|
|
125
112
|
* Deposit ERC20 tokens into the payments contract.
|
|
126
113
|
*
|
|
127
|
-
* @param props - The props for the deposit.
|
|
128
|
-
* @param props.address - The address of the account to deposit from.
|
|
129
|
-
* @param props.token - The address of the ERC20 token to deposit.
|
|
130
|
-
* @param props.mutation - The mutation options.
|
|
131
|
-
* @param props.onHash - The callback to call when the hash is available.
|
|
114
|
+
* @param props - The props for the deposit. {@link UseDepositProps}
|
|
132
115
|
* @returns The deposit mutation.
|
|
133
116
|
*/
|
|
134
117
|
export function useDeposit(props?: UseDepositProps) {
|
|
135
118
|
const config = useConfig()
|
|
136
119
|
const chainId = useChainId({ config })
|
|
137
120
|
const chain = getChain(chainId)
|
|
138
|
-
const account =
|
|
121
|
+
const account = useConnection({ config })
|
|
139
122
|
const queryClient = useQueryClient()
|
|
140
123
|
const token = props?.token ?? chain.contracts.usdfc.address
|
|
141
|
-
const
|
|
124
|
+
const to = props?.to ?? account.address
|
|
142
125
|
|
|
143
126
|
return useMutation({
|
|
144
127
|
mutationFn: async ({ amount }: UseDepositVariables) => {
|
|
@@ -149,8 +132,9 @@ export function useDeposit(props?: UseDepositProps) {
|
|
|
149
132
|
|
|
150
133
|
const hash = await deposit(client, {
|
|
151
134
|
amount,
|
|
152
|
-
|
|
135
|
+
to,
|
|
153
136
|
token,
|
|
137
|
+
contractAddress: props?.contractAddress,
|
|
154
138
|
})
|
|
155
139
|
|
|
156
140
|
props?.onHash?.(hash)
|
|
@@ -159,10 +143,10 @@ export function useDeposit(props?: UseDepositProps) {
|
|
|
159
143
|
})
|
|
160
144
|
|
|
161
145
|
queryClient.invalidateQueries({
|
|
162
|
-
queryKey: ['synapse-payments-account-info',
|
|
146
|
+
queryKey: ['synapse-payments-account-info', to, token],
|
|
163
147
|
})
|
|
164
148
|
queryClient.invalidateQueries({
|
|
165
|
-
queryKey: ['synapse-erc20-balance',
|
|
149
|
+
queryKey: ['synapse-erc20-balance', to, token],
|
|
166
150
|
})
|
|
167
151
|
return transactionReceipt
|
|
168
152
|
},
|
|
@@ -170,8 +154,8 @@ export function useDeposit(props?: UseDepositProps) {
|
|
|
170
154
|
})
|
|
171
155
|
}
|
|
172
156
|
|
|
173
|
-
type UseWithdrawVariables = Pick<
|
|
174
|
-
type UseWithdrawProps = Omit<
|
|
157
|
+
export type UseWithdrawVariables = Pick<withdraw.OptionsType, 'amount'>
|
|
158
|
+
export type UseWithdrawProps = Omit<withdraw.OptionsType, 'amount'> & {
|
|
175
159
|
mutation?: Omit<MutateOptions<TransactionReceipt, Error, UseWithdrawVariables>, 'mutationFn'>
|
|
176
160
|
onHash?: (hash: string) => void
|
|
177
161
|
}
|
|
@@ -185,10 +169,9 @@ export function useWithdraw(props?: UseWithdrawProps) {
|
|
|
185
169
|
const config = useConfig()
|
|
186
170
|
const chainId = useChainId({ config })
|
|
187
171
|
const chain = getChain(chainId)
|
|
188
|
-
const account =
|
|
172
|
+
const account = useConnection({ config })
|
|
189
173
|
const queryClient = useQueryClient()
|
|
190
174
|
const token = props?.token ?? chain.contracts.usdfc.address
|
|
191
|
-
const from = props?.address ?? account.address
|
|
192
175
|
|
|
193
176
|
return useMutation({
|
|
194
177
|
mutationFn: async ({ amount }: UseWithdrawVariables) => {
|
|
@@ -199,7 +182,6 @@ export function useWithdraw(props?: UseWithdrawProps) {
|
|
|
199
182
|
|
|
200
183
|
const hash = await withdraw(client, {
|
|
201
184
|
amount,
|
|
202
|
-
address: account.address,
|
|
203
185
|
token,
|
|
204
186
|
})
|
|
205
187
|
props?.onHash?.(hash)
|
|
@@ -208,10 +190,10 @@ export function useWithdraw(props?: UseWithdrawProps) {
|
|
|
208
190
|
})
|
|
209
191
|
|
|
210
192
|
queryClient.invalidateQueries({
|
|
211
|
-
queryKey: ['synapse-payments-account-info',
|
|
193
|
+
queryKey: ['synapse-payments-account-info', account.address, token],
|
|
212
194
|
})
|
|
213
195
|
queryClient.invalidateQueries({
|
|
214
|
-
queryKey: ['synapse-erc20-balance',
|
|
196
|
+
queryKey: ['synapse-erc20-balance', account.address, token],
|
|
215
197
|
})
|
|
216
198
|
return transactionReceipt
|
|
217
199
|
},
|
|
@@ -219,7 +201,7 @@ export function useWithdraw(props?: UseWithdrawProps) {
|
|
|
219
201
|
})
|
|
220
202
|
}
|
|
221
203
|
|
|
222
|
-
type ApproveOperatorProps =
|
|
204
|
+
export type ApproveOperatorProps =
|
|
223
205
|
| {
|
|
224
206
|
/**
|
|
225
207
|
* The address of the operator to approve.
|
|
@@ -242,11 +224,7 @@ type ApproveOperatorProps =
|
|
|
242
224
|
/**
|
|
243
225
|
* Approve a service contract to act as an operator for payment rails.
|
|
244
226
|
*
|
|
245
|
-
* @param props - The props for the deposit.
|
|
246
|
-
* @param props.operator - The address of the operator to approve.
|
|
247
|
-
* @param props.token - The address of the ERC20 token to deposit.
|
|
248
|
-
* @param props.mutation - The mutation options.
|
|
249
|
-
* @param props.onHash - The callback to call when the hash is available.
|
|
227
|
+
* @param props - The props for the deposit. {@link ApproveOperatorProps}
|
|
250
228
|
* @returns The deposit mutation.
|
|
251
229
|
*/
|
|
252
230
|
export function useApproveOperator(props?: ApproveOperatorProps) {
|
|
@@ -256,7 +234,7 @@ export function useApproveOperator(props?: ApproveOperatorProps) {
|
|
|
256
234
|
const account = useAccount({ config })
|
|
257
235
|
const queryClient = useQueryClient()
|
|
258
236
|
const token = props?.token ?? chain.contracts.usdfc.address
|
|
259
|
-
const operator = props?.operator ?? chain.contracts.
|
|
237
|
+
const operator = props?.operator ?? chain.contracts.fwss.address
|
|
260
238
|
|
|
261
239
|
return useMutation({
|
|
262
240
|
...props?.mutation,
|
|
@@ -288,7 +266,7 @@ export function useApproveOperator(props?: ApproveOperatorProps) {
|
|
|
288
266
|
})
|
|
289
267
|
}
|
|
290
268
|
|
|
291
|
-
type RevokeOperatorProps =
|
|
269
|
+
export type RevokeOperatorProps =
|
|
292
270
|
| {
|
|
293
271
|
/**
|
|
294
272
|
* The address of the operator to revoke.
|
|
@@ -304,6 +282,9 @@ type RevokeOperatorProps =
|
|
|
304
282
|
* The mutation options.
|
|
305
283
|
*/
|
|
306
284
|
mutation?: Omit<MutateOptions<TransactionReceipt, Error>, 'mutationFn'>
|
|
285
|
+
/**
|
|
286
|
+
* The callback to call when the hash is available.
|
|
287
|
+
*/
|
|
307
288
|
onHash?: (hash: string) => void
|
|
308
289
|
}
|
|
309
290
|
| undefined
|
|
@@ -311,11 +292,7 @@ type RevokeOperatorProps =
|
|
|
311
292
|
/**
|
|
312
293
|
* Revoke the operator to deposit and withdraw ERC20 tokens from the payments contract.
|
|
313
294
|
*
|
|
314
|
-
* @param props - The props for the deposit.
|
|
315
|
-
* @param props.operator - The address of the operator to approve.
|
|
316
|
-
* @param props.token - The address of the ERC20 token to deposit.
|
|
317
|
-
* @param props.mutation - The mutation options.
|
|
318
|
-
* @param props.onHash - The callback to call when the hash is available.
|
|
295
|
+
* @param props - The props for the deposit. {@link RevokeOperatorProps}
|
|
319
296
|
* @returns The deposit mutation.
|
|
320
297
|
*/
|
|
321
298
|
export function useRevokeOperator(props?: RevokeOperatorProps) {
|
|
@@ -325,7 +302,7 @@ export function useRevokeOperator(props?: RevokeOperatorProps) {
|
|
|
325
302
|
const account = useAccount({ config })
|
|
326
303
|
const queryClient = useQueryClient()
|
|
327
304
|
const token = props?.token ?? chain.contracts.usdfc.address
|
|
328
|
-
const operator = props?.operator ?? chain.contracts.
|
|
305
|
+
const operator = props?.operator ?? chain.contracts.fwss.address
|
|
329
306
|
|
|
330
307
|
return useMutation({
|
|
331
308
|
...props?.mutation,
|