@filoz/synapse-react 0.1.4 → 0.2.1
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 +4 -8
- 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 +7 -23
- 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 +7 -6
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +7 -11
- package/src/warm-storage/use-data-sets.ts +8 -30
- package/src/warm-storage/use-delete-piece.ts +9 -7
- package/src/warm-storage/use-providers.ts +4 -4
- package/src/warm-storage/use-service-price.ts +9 -9
- package/src/warm-storage/use-upload.ts +3 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-data-sets.js","sourceRoot":"","sources":["../../../src/warm-storage/use-data-sets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use-data-sets.js","sourceRoot":"","sources":["../../../src/warm-storage/use-data-sets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AACxE,OAAO,EAAE,cAAc,EAA2C,MAAM,kCAAkC,CAAA;AAC1G,OAAO,EAAE,SAAS,EAAwB,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEjF,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAajC,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;IAC7B,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,CAAC,gCAAgC,EAAE,OAAO,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;QAClF,OAAO,EAAE,OAAO;YACd,CAAC,CAAC,KAAK,IAAI,EAAE;gBACT,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;gBACtE,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,GAAG,CAC1C,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;oBAC7B,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE;wBAC7D,OAAO;wBACP,OAAO;qBACR,CAAC,CAAA;oBAEF,OAAO;wBACL,GAAG,OAAO;wBACV,MAAM,EAAE,MAAM,CAAC,MAAM;qBACtB,CAAA;gBACH,CAAC,CAAC,CACH,CAAA;gBACD,OAAO,kBAAkB,CAAA;YAC3B,CAAC;YACH,CAAC,CAAC,SAAS;KACd,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -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,16 +21,16 @@ 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
|
-
queryKey: ['synapse-warm-storage-data-sets', account.address],
|
|
33
|
+
queryKey: ['synapse-warm-storage-data-sets', account.address, config.getClient().chain.id],
|
|
33
34
|
});
|
|
34
35
|
return rsp;
|
|
35
36
|
},
|
|
@@ -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,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;aAC3F,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,13 +1,13 @@
|
|
|
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) {
|
|
5
5
|
const config = useConfig();
|
|
6
6
|
return useQuery({
|
|
7
7
|
...props?.query,
|
|
8
|
-
queryKey: ['synapse-warm-storage-providers'],
|
|
8
|
+
queryKey: ['synapse-warm-storage-providers', config.getClient().chain.id],
|
|
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,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;QACzE,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,13 +1,13 @@
|
|
|
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) {
|
|
5
5
|
const config = useConfig();
|
|
6
6
|
return useQuery({
|
|
7
7
|
...props?.query,
|
|
8
|
-
queryKey: ['synapse-warm-storage-get-service-price'],
|
|
8
|
+
queryKey: ['synapse-warm-storage-get-service-price', config.getClient().chain.id],
|
|
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,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;QACjF,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,9 +26,9 @@ 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
|
-
queryKey: ['synapse-warm-storage-data-sets', account.address],
|
|
31
|
+
queryKey: ['synapse-warm-storage-data-sets', account.address, config.getClient().chain.id],
|
|
32
32
|
});
|
|
33
33
|
return rsp;
|
|
34
34
|
},
|
|
@@ -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,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;aAC3F,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.1
|
|
3
|
+
"version": "0.2.1",
|
|
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)
|