Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
30 changes: 14 additions & 16 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 @@ -41,7 +40,7 @@
"main": "dist/main/index.js",
"module": "dist/module/index.js",
"peerDependencies": {
"@reduxjs/toolkit": "^1.7.0 || ^1.8.0 || ^1.9.0",
"@reduxjs/toolkit": ">=2",
"@superfluid-finance/sdk-core": ">0.7.0"
},
"repository": {
Expand All @@ -51,8 +50,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 Down
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,5 +1,5 @@
import {CreateApi} from '@reduxjs/toolkit/dist/query';
import type {ModuleName} from '@reduxjs/toolkit/dist/query/apiTypes';
import {type CreateApi} from '@reduxjs/toolkit/query';
import {coreModuleName} from '@reduxjs/toolkit/query';

import {typeGuard} from '../../../utils';
import {cacheTagTypes} from '../cacheTags/CacheTagTypes';
Expand All @@ -9,6 +9,8 @@ import {rpcBaseQuery} from './rpcBaseQuery';
import {RpcEndpointBuilder} from './rpcEndpointBuilder';
import {RpcReducerPath} from './rpcReducerPath';

type ModuleName = typeof coreModuleName;

export const createRpcApiSlice = <T extends ModuleName>(createRtkQueryApi: CreateApi<T>) =>
createRtkQueryApi({
reducerPath: typeGuard<RpcReducerPath>('superfluid_rpc'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {EndpointBuilder} from '@reduxjs/toolkit/dist/query/endpointDefinitions';
import {type EndpointBuilder} from '@reduxjs/toolkit/query';

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {CreateApi} from '@reduxjs/toolkit/dist/query';
import {ModuleName} from '@reduxjs/toolkit/dist/query/apiTypes';
import {type CreateApi} from '@reduxjs/toolkit/query';
import {coreModuleName} from '@reduxjs/toolkit/query';

import {typeGuard} from '../../../utils';
import {cacheTagTypes} from '../cacheTags/CacheTagTypes';
import {CacheTime} from '../cacheTime';
import {getSerializeQueryArgs} from '../getSerializeQueryArgs';

type ModuleName = typeof coreModuleName;

import {subgraphBaseQuery} from './subgraphBaseQuery';
import {SubgraphEndpointBuilder} from './subgraphEndpointBuilder';
import {SubgraphReducerPath} from './subgraphReducerPath';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {EndpointBuilder} from '@reduxjs/toolkit/dist/query/endpointDefinitions';
import {type EndpointBuilder} from '@reduxjs/toolkit/query';

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const initiateNewTransactionTrackingThunk = createAsyncThunk<

dispatch(
getTransactionTrackerSlice().actions.addTransaction({
id: transactionHash,
chainId: arg.chainId,
hash: transactionHash,
signerAddress: ethers.utils.getAddress(arg.signerAddress),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type TransactionStatus = 'Pending' | 'Succeeded' | 'Failed' | 'Replaced'

// "Redux" stuff needs to be serializable. Blockchain transaction object is unserializable.
export interface TrackedTransaction {
id: string;
chainId: number;
hash: string;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {TrackedTransaction} from './trackedTransaction';
import {TransactionTrackerReducer, transactionTrackerSlicePrefix} from './transactionTrackerSlice';

export const transactionTrackerAdapter = createEntityAdapter<TrackedTransaction>({
selectId: (transaction) => transaction.hash,
sortComparer: (a) => a.timestampMs,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {transactionTrackerAdapter} from './transactionTrackerAdapter';
export const transactionTrackerSlicePrefix = 'superfluid_transactions' as const;

export const createTransactionTrackerSlice = () => ({
reducerPath: transactionTrackerSlicePrefix,
...createSlice({
name: transactionTrackerSlicePrefix,
initialState: transactionTrackerAdapter.getInitialState(),
Expand All @@ -14,6 +13,7 @@ export const createTransactionTrackerSlice = () => ({
updateTransaction: transactionTrackerAdapter.updateOne,
},
}),
reducerPath: transactionTrackerSlicePrefix,
});

export type TransactionTrackerSlice = ReturnType<typeof createTransactionTrackerSlice>;
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-redux/src/sdkReduxConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Framework} from '@superfluid-finance/sdk-core';
import {Signer} from 'ethers';
import _ from 'lodash';
import {memoize} from 'lodash';

// NOTE: This file is marked for side-effects inside the package.json for efficient tree-shaking.

Expand Down Expand Up @@ -102,7 +102,7 @@ export default class SdkReduxConfig
? () => Promise.resolve(instanceOrFactory)
: instanceOrFactory;

this.memoizedFrameworkFactories.set(chainId, _.memoize(frameworkFactory));
this.memoizedFrameworkFactories.set(chainId, memoize(frameworkFactory));
}

setTransactionTrackerSlice(slice: TransactionTrackerSlice): void {
Expand Down
6 changes: 4 additions & 2 deletions packages/sdk-redux/src/sdkReduxInitialization.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {CreateApi} from '@reduxjs/toolkit/dist/query';
import type {ModuleName} from '@reduxjs/toolkit/dist/query/apiTypes';
import {CreateApi} from '@reduxjs/toolkit/query';
import {coreModuleName} from '@reduxjs/toolkit/query';
import {Framework} from '@superfluid-finance/sdk-core';

import {createRpcApiSlice} from './reduxSlices/rtkQuery/rpcApiSlice/rpcApiSlice';
import {createSubgraphApiSlice} from './reduxSlices/rtkQuery/subgraphApiSlice/subgraphApiSlice';
import {createTransactionTrackerSlice} from './reduxSlices/transactionTrackerSlice/transactionTrackerSlice';
import {getConfig} from './sdkReduxConfig';

type ModuleName = typeof coreModuleName;

/**
* For initializing "rpcApiSlice" Redux slice.
*
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-redux/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"compilerOptions": {
"incremental": true,
"target": "ES2019",
"target": "ESNext",
"outDir": "dist/main",
"rootDir": "src",
"moduleResolution": "node",
"module": "commonjs",
"module": "ESNext",
"lib": [ "DOM", "ESNext" ],
"declaration": true,
"declarationMap": true,
Expand Down
15 changes: 0 additions & 15 deletions packages/sdk-redux/tsconfig.module.json

This file was deleted.

Loading
Loading