Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/sdk-redux/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ All notable changes to the SDK-redux will be documented in this file.
### Changed
### Fixed

## [0.7.0]

### Changed
- [BREAKING] update to @reduxjs/toolkit 2
- [BREAKING] leave only ESM support (no CommonJS)
- use lodash's smaller direct libraries

## [0.6.1] - 2024-08-01

### Changed
Expand Down
35 changes: 16 additions & 19 deletions packages/sdk-redux/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@superfluid-finance/sdk-redux",
"description": "SDK Redux for streamlined front-end application development with Superfluid Protocol",
"version": "0.6.1",
"version": "0.7.0",
"bugs": "https://github.com/superfluid-finance/protocol-monorepo/issues",
"config": {
"commitizen": {
Expand All @@ -10,26 +10,25 @@
},
"dependencies": {
"graphql-request": "6.1.0",
"lodash": "4.17.21",
"promise-retry": "2.0.1"
"promise-retry": "2.0.1",
"lodash.memoize": "4.1.2",
"lodash.uniqby": "4.7.0"
},
"devDependencies": {
"@reduxjs/toolkit": "^1.9.7",
"@reduxjs/toolkit": "^2",
"@types/promise-retry": "^1.1.6",
"@types/react": "^18",
"@types/react-dom": "^18",
"react": "^18",
"react-dom": "^18",
"react-redux": "^8.1.3"
"@types/lodash.memoize": "^4.1.7",
"@types/lodash.uniqby": "^4.7.9",
"@types/react": "^19",
"@types/react-dom": "^19",
"react": "^19",
"react-dom": "^19",
"react-redux": "^9"
},
"directories": {
"test": "test"
},
"engines": {
"node": ">=12"
},
"files": [
"dist/main",
"dist/module",
"CHANGELOG.md",
"LICENSE",
Expand All @@ -38,11 +37,10 @@
"homepage": "https://docs.superfluid.finance/",
"keywords": [],
"license": "MIT",
"main": "dist/main/index.js",
"module": "dist/module/index.js",
"peerDependencies": {
"@reduxjs/toolkit": "^1.7.0 || ^1.8.0 || ^1.9.0",
"@superfluid-finance/sdk-core": ">0.7.0"
"@reduxjs/toolkit": ">=2",
"@superfluid-finance/sdk-core": ">=0.7.0"
},
"repository": {
"type": "git",
Expand All @@ -51,8 +49,7 @@
},
"scripts": {
"build": "rm -rf dist && run-p -l build:*",
"build:main": "tsc -p tsconfig.json",
"build:module": "tsc -p tsconfig.module.json",
"build:module": "tsc -p tsconfig.json",
"lint": "run-s lint:*",
"lint:eslint": "eslint src --ext .ts",
"fix": "run-s fix:*",
Expand All @@ -66,7 +63,7 @@
"cloc": "sh tasks/cloc.sh"
},
"sideEffects": [
"./src/sdkReduxConfig.ts"
"./dist/module/sdkReduxConfig.js"
],
"typings": "dist/module/index.d.ts"
}
4 changes: 2 additions & 2 deletions packages/sdk-redux/src/reduxSlices/argTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ISuperTokenModifyFlowParams} from '@superfluid-finance/sdk-core';
import {Signer} from 'ethers';
import {type ISuperTokenModifyFlowParams} from '@superfluid-finance/sdk-core';
import {type Signer} from 'ethers';

import {mutationOverridesKey, mutationSignerKey} from '../utils';

Expand Down
3 changes: 3 additions & 0 deletions packages/sdk-redux/src/reduxSlices/rtkQuery/ModuleName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {ApiModules} from '@reduxjs/toolkit/query';

export type ModuleName = keyof ApiModules<any, any, any, any>;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {insertIf, typeGuard} from '../../../utils';
import {NothingString} from '../../argTypes';
import {type NothingString} from '../../argTypes';

/**
* Cache tag types for queries. Read more about caching from RTK-Query documentation: https://redux-toolkit.js.org/rtk-query/usage/automated-refetching#cache-tags
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {AnyAction, ThunkDispatch} from '@reduxjs/toolkit';
import {AllEvents} from '@superfluid-finance/sdk-core';
import {uniqBy} from 'lodash';
import {type ThunkDispatch, type UnknownAction} from '@reduxjs/toolkit';
import {type AllEvents} from '@superfluid-finance/sdk-core';
import uniqBy from 'lodash.uniqby';

import {getRpcApiSlice, getSubgraphApiSlice} from '../../../sdkReduxConfig';

Expand All @@ -21,7 +21,7 @@ export const getSpecificCacheTagsToInvalidateForEvents = (chainId: number, event
export const invalidateSpecificCacheTagsForEvents = (
chainId: number,
events: AllEvents[],
dispatch: ThunkDispatch<any, any, AnyAction>
dispatch: ThunkDispatch<any, any, UnknownAction>
) => {
const tagsToInvalidate = getSpecificCacheTagsToInvalidateForEvents(chainId, events);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {AnyAction} from '@reduxjs/toolkit';
import {ThunkDispatch} from '@reduxjs/toolkit';
import {type ThunkDispatch, type UnknownAction} from '@reduxjs/toolkit';

import {getFramework} from '../../../sdkReduxConfig';
import {MillisecondTimes} from '../../../utils';
import {TransactionInfo} from '../../argTypes';
import {type TransactionInfo} from '../../argTypes';

import {invalidateSpecificCacheTagsForEvents} from './invalidateSpecificCacheTagsForEvents';

Expand All @@ -16,7 +15,7 @@ import {invalidateSpecificCacheTagsForEvents} from './invalidateSpecificCacheTag
export const monitorAddressForNextEventToInvalidateCache = async (
address: string,
transactionInfo: TransactionInfo,
dispatch: ThunkDispatch<any, any, AnyAction>
dispatch: ThunkDispatch<any, any, UnknownAction>
) => {
const framework = await getFramework(transactionInfo.chainId);
framework.query.on(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import {createApi} from '@reduxjs/toolkit/query/react';

import {initializeRpcApiSlice} from '../../sdkReduxInitialization';

/**
* For creating RTK-Query API (e.g. "sfApi") with auto-generated React Hooks.
*
* Read more: https://redux-toolkit.js.org/rtk-query/api/created-api/hooks
*/
export const createApiWithReactHooks = createApi;

initializeRpcApiSlice((options) => createApi(options));
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {isPlainObject} from '@reduxjs/toolkit';
import {SerializeQueryArgs} from '@reduxjs/toolkit/dist/query/defaultSerializeQueryArgs';
import {type SerializeQueryArgs} from '@reduxjs/toolkit/query';

import {mutationOverridesKey, mutationSignerKey} from '../../utils';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {RpcEndpointBuilder} from '../rpcEndpointBuilder';
import {type RpcEndpointBuilder} from '../rpcEndpointBuilder';

import {createFlowEndpoints} from './flowEndpoints';
import {createIndexEndpoints} from './indexEndpoints';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BaseSuperTokenMutation, NothingString} from '../../../argTypes';
import {type BaseSuperTokenMutation, type NothingString} from '../../../argTypes';

/**
* Create a flow of the token of this class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {getFramework} from '../../../../sdkReduxConfig';
import {TransactionInfo} from '../../../argTypes';
import {type TransactionInfo} from '../../../argTypes';
import {registerNewTransactionAndReturnQueryFnResult} from '../../../transactionTrackerSlice/registerNewTransaction';
import {RpcEndpointBuilder} from '../rpcEndpointBuilder';
import {type RpcEndpointBuilder} from '../rpcEndpointBuilder';

import {FlowCreateMutation, FlowDeleteMutation, FlowUpdateMutation} from './flowArgs';
import {type FlowCreateMutation, type FlowDeleteMutation, type FlowUpdateMutation} from './flowArgs';

export const createFlowEndpoints = (builder: RpcEndpointBuilder) => ({
flowCreate: builder.mutation<TransactionInfo, FlowCreateMutation>({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BaseSuperTokenMutation, NothingString} from '../../../argTypes';
import {type BaseSuperTokenMutation, type NothingString} from '../../../argTypes';

/**
* Creates an IDA Index.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {getFramework} from '../../../../sdkReduxConfig';
import {TransactionInfo} from '../../../argTypes';
import {type TransactionInfo} from '../../../argTypes';
import {registerNewTransactionAndReturnQueryFnResult} from '../../../transactionTrackerSlice/registerNewTransaction';
import {RpcEndpointBuilder} from '../rpcEndpointBuilder';
import {type RpcEndpointBuilder} from '../rpcEndpointBuilder';

import {
IndexCreateMutation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BaseQuery, BaseSuperTokenMutation} from '../../../argTypes';
import {type BaseQuery, type BaseSuperTokenMutation} from '../../../argTypes';

/**
* Downgrade `amount` SuperToken's.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {NativeAssetSuperToken, WrapperSuperToken} from '@superfluid-finance/sdk-core';

import {getFramework} from '../../../../sdkReduxConfig';
import {TransactionInfo} from '../../../argTypes';
import {type TransactionInfo} from '../../../argTypes';
import {registerNewTransactionAndReturnQueryFnResult} from '../../../transactionTrackerSlice/registerNewTransaction';
import {createGeneralTags, createSpecificTags} from '../../cacheTags/CacheTagTypes';
import {RpcEndpointBuilder} from '../rpcEndpointBuilder';
import {type RpcEndpointBuilder} from '../rpcEndpointBuilder';

import {
SuperTokenDowngradeMutation,
SuperTokenTransferMutation,
SuperTokenUpgradeAllowanceQuery,
SuperTokenUpgradeMutation,
type SuperTokenDowngradeMutation,
type SuperTokenTransferMutation,
type SuperTokenUpgradeAllowanceQuery,
type SuperTokenUpgradeMutation,
} from './superTokenArgs';

export const createSuperTokenEndpoints = (builder: RpcEndpointBuilder) => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {CreateApi} from '@reduxjs/toolkit/dist/query';
import type {ModuleName} from '@reduxjs/toolkit/dist/query/apiTypes';
import {type CreateApi} from '@reduxjs/toolkit/query';

import {typeGuard} from '../../../utils';
import {type ModuleName} from '../ModuleName';
import {cacheTagTypes} from '../cacheTags/CacheTagTypes';
import {getSerializeQueryArgs} from '../getSerializeQueryArgs';

import {rpcBaseQuery} from './rpcBaseQuery';
import {RpcEndpointBuilder} from './rpcEndpointBuilder';
import {RpcReducerPath} from './rpcReducerPath';
import {type RpcEndpointBuilder} from './rpcEndpointBuilder';
import {type RpcReducerPath} from './rpcReducerPath';

export const createRpcApiSlice = <T extends ModuleName>(createRtkQueryApi: CreateApi<T>) =>
createRtkQueryApi({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {SerializedError} from '@reduxjs/toolkit';
import {BaseQueryFn} from '@reduxjs/toolkit/dist/query';
import {type SerializedError} from '@reduxjs/toolkit';
import {type BaseQueryFn} from '@reduxjs/toolkit/query';

export const rpcBaseQuery = (): BaseQueryFn<void, unknown, SerializedError, Record<string, unknown>> => () => {
throw new Error('All queries & mutations must use the `queryFn` definition syntax.');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {EndpointBuilder} from '@reduxjs/toolkit/dist/query/endpointDefinitions';
import {type EndpointBuilder} from '@reduxjs/toolkit/query';

import {CacheTagType} from '../cacheTags/CacheTagTypes';
import {type CacheTagType} from '../cacheTags/CacheTagTypes';

import {RpcBaseQuery} from './rpcBaseQuery';
import {RpcReducerPath} from './rpcReducerPath';
import {type RpcBaseQuery} from './rpcBaseQuery';
import {type RpcReducerPath} from './rpcReducerPath';

export type RpcEndpointBuilder = EndpointBuilder<RpcBaseQuery, CacheTagType, RpcReducerPath>;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SubgraphEndpointBuilder} from '../subgraphEndpointBuilder';
import {type SubgraphEndpointBuilder} from '../subgraphEndpointBuilder';

import {createBaseEndpoints} from './baseEndpoints';
import {createEntityEndpoints} from './entityEndpoints';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {DocumentNode} from 'graphql';
import {type DocumentNode} from 'graphql';

import {BaseQuery, NothingString} from '../../../argTypes';
import {type BaseQuery, type NothingString} from '../../../argTypes';

export interface CustomSubgraphQuery extends BaseQuery<unknown> {
document: string | DocumentNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {getFramework, getSubgraphClient} from '../../../../sdkReduxConfig';
import {MillisecondTimes} from '../../../../utils';
import {invalidateSpecificCacheTagsForEvents} from '../../cacheTags/invalidateSpecificCacheTagsForEvents';
import {CacheTime} from '../../cacheTime';
import {SubgraphEndpointBuilder} from '../subgraphEndpointBuilder';
import {type SubgraphEndpointBuilder} from '../subgraphEndpointBuilder';

import {CustomSubgraphQuery, MonitorForEventsToInvalidateCacheMutation} from './baseArgs';
import {type CustomSubgraphQuery, type MonitorForEventsToInvalidateCacheMutation} from './baseArgs';

export const createBaseEndpoints = (builder: SubgraphEndpointBuilder) => ({
custom: builder.query<unknown, CustomSubgraphQuery>({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {
AccountListQuery,
AccountTokenSnapshotListQuery,
AccountTokenSnapshotLogListQuery,
FlowOperatorListQuery,
IndexListQuery,
IndexSubscriptionsListQuery,
PoolDistributorsListQuery,
PoolListQuery,
PoolMembersListQuery,
StreamListQuery,
StreamPeriodListQuery,
SubgraphGetQuery,
TokenListQuery,
TokenStatisticListQuery,
TokenStatisticLogListQuery,
type AccountListQuery,
type AccountTokenSnapshotListQuery,
type AccountTokenSnapshotLogListQuery,
type FlowOperatorListQuery,
type IndexListQuery,
type IndexSubscriptionsListQuery,
type PoolDistributorsListQuery,
type PoolListQuery,
type PoolMembersListQuery,
type StreamListQuery,
type StreamPeriodListQuery,
type SubgraphGetQuery,
type TokenListQuery,
type TokenStatisticListQuery,
type TokenStatisticLogListQuery,
} from '@superfluid-finance/sdk-core';

export interface AccountTokenSnapshotQuery extends SubgraphGetQuery {
Expand Down
Loading
Loading