Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/build upgrade #173

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['18.x', '20.x']
node: ['20.x']
os: [ubuntu-latest]

steps:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ build

src/*.js

dist
dist

*.log
29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
"singleQuote": true,
"trailingComma": "es5"
},
"jest": {},
"jest": {
"testEnvironment": "node"
},
"engines": {
"node": ">=12"
},
Expand All @@ -46,22 +48,22 @@
}
],
"devDependencies": {
"@size-limit/preset-small-lib": "^7.0.8",
"@tsconfig/recommended": "^1.0.1",
"@size-limit/preset-small-lib": "^11.1.5",
"@tsconfig/recommended": "^1.0.7",
"axios": "^1.1.3",
"dotenv": "^16.0.0",
"dts-cli": "^1.5.1",
"dts-cli": "^2.0.5",
"ethers": "^5.6.5",
"ganache": "^7.9.2",
"husky": "^7.0.4",
"husky": "^9.1.6",
"isomorphic-unfetch": "^3.1.0",
"size-limit": "^7.0.8",
"tslib": "^2.4.0",
"typedoc": "^0.23.7",
"typedoc-plugin-markdown": "^3.13.3",
"typedoc-plugin-missing-exports": "^0.23.0",
"typedoc-plugin-replace-text": "^2.0.0",
"typescript": "^4.6.4",
"size-limit": "^11.1.5",
"tslib": "^2.7.0",
"typedoc": "^0.26.7",
"typedoc-plugin-markdown": "^4.2.7",
"typedoc-plugin-missing-exports": "^3.0.0",
"typedoc-plugin-replace-text": "^4.0.0",
"typescript": "^5.6.2",
"web3": "^1.7.3"
},
"peerDependencies": {
Expand Down Expand Up @@ -111,6 +113,5 @@
"publishConfig": {
"access": "public"
},
"bugs": "https://github.com/paraswap/paraswap-sdk/issues",
"packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
"bugs": "https://github.com/paraswap/paraswap-sdk/issues"
}
2 changes: 1 addition & 1 deletion src/methods/nftOrders/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ export type NFTOrderApiResponse = {
order: NFTOrderFromAPI;
};

export type AssetTypeVariant = typeof AssetType[keyof typeof AssetType];
export type AssetTypeVariant = (typeof AssetType)[keyof typeof AssetType];
12 changes: 6 additions & 6 deletions src/methods/swap/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { constructPartialSDK, SDKConfig } from '../../sdk/partial';
import { ConstructProviderFetchInput } from '../../types';
import { constructGetAdapters, GetAdaptersFunctions } from './adapters';
import { ApproveTokenFunctions, constructApproveToken } from './approve';
import { constructGetBalances, GetBalancesFunctions } from './balance';
Expand All @@ -21,18 +20,19 @@ export type SwapSDKMethods<TxResponse> = GetBalancesFunctions &
/** @description construct SDK with every Swap-related method, fetching from API and token approval */
export const constructSwapSDK = <TxResponse>(
config: SDKConfig<TxResponse>
): SwapSDKMethods<TxResponse> =>
): SwapSDKMethods<TxResponse> => {
const constructApproveTokenWithTxResponse = constructApproveToken<TxResponse>;

// include all available Swap methods
constructPartialSDK(
return constructPartialSDK(
config,
constructGetBalances,
constructGetTokens,
constructGetSpender,
constructApproveToken as (
options: ConstructProviderFetchInput<TxResponse, 'transactCall'>
) => ApproveTokenFunctions<TxResponse>, // @TODO try Instantiation Expression when TS 4.7 `as constructApproveToken<TxResponse>`
constructApproveTokenWithTxResponse,
constructBuildTx,
constructGetAdapters,
constructGetRate,
constructSwapTx
);
};
2 changes: 1 addition & 1 deletion tests/__snapshots__/legacy.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ParaSwap SDK Get_Adapters: Get_Adapters 1`] = `
Array [
[
"Bancor",
"Compound",
"DODOV1",
Expand Down
84 changes: 42 additions & 42 deletions tests/__snapshots__/limitOrders.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Limit Orders Build_Swap+LO_Tx 1`] = `
Object {
"bestRoute": Array [
Object {
{
"bestRoute": [
{
"percent": 100,
"swaps": Array [
Object {
"swaps": [
{
"destDecimals": 18,
"destToken": "0x0d8775f648430679a709e98d2b0cb6250d2887ef",
"srcDecimals": 18,
"srcToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
"swapExchanges": Array [
Object {
"data": Object {
"swapExchanges": [
{
"data": {
"factory": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
"feeFactor": 10000,
"gasUSD": "---",
"initCode": "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",
"path": Array [
"path": [
"0x6b175474e89094c44da98b954eedeac495271d0f",
"0x0d8775f648430679a709e98d2b0cb6250d2887ef",
],
"pools": Array [
Object {
"pools": [
{
"address": "0x6929abD7931D0243777d3CD147fE863646A752ba",
"direction": false,
"fee": 30,
Expand All @@ -34,7 +34,7 @@ Object {
"destAmount": "6000000000000000000",
"exchange": "UniswapV2",
"percent": 100,
"poolAddresses": Array [
"poolAddresses": [
"0x6929abD7931D0243777d3CD147fE863646A752ba",
],
"srcAmount": "---",
Expand Down Expand Up @@ -69,8 +69,8 @@ Object {
`;

exports[`Limit Orders buildLimitOrder p2p: P2P_Order_Data_Snapshot 1`] = `
Object {
"data": Object {
{
"data": {
"expiry": 1766188800,
"maker": "0xaC39b311DCEb2A4b2f5d8461c1cdaF756F4F7Ae9",
"makerAmount": "1000000000000000000",
Expand All @@ -80,43 +80,43 @@ Object {
"takerAmount": "8000000000000000000",
"takerAsset": "0x2b591e99afe9f32eaa6214f7b7629768c40eeb39",
},
"domain": Object {
"domain": {
"chainId": 1,
"name": "AUGUSTUS RFQ",
"verifyingContract": "0xe92b586627ccA7a83dC919cc7127196d70f55a06",
"version": "1",
},
"types": Object {
"Order": Array [
Object {
"types": {
"Order": [
{
"name": "nonceAndMeta",
"type": "uint256",
},
Object {
{
"name": "expiry",
"type": "uint128",
},
Object {
{
"name": "makerAsset",
"type": "address",
},
Object {
{
"name": "takerAsset",
"type": "address",
},
Object {
{
"name": "maker",
"type": "address",
},
Object {
{
"name": "taker",
"type": "address",
},
Object {
{
"name": "makerAmount",
"type": "uint256",
},
Object {
{
"name": "takerAmount",
"type": "uint256",
},
Expand All @@ -126,8 +126,8 @@ Object {
`;

exports[`Limit Orders buildLimitOrder: Order_Data_Snapshot 1`] = `
Object {
"data": Object {
{
"data": {
"expiry": 1766188800,
"maker": "0xaC39b311DCEb2A4b2f5d8461c1cdaF756F4F7Ae9",
"makerAmount": "1000000000000000000",
Expand All @@ -137,43 +137,43 @@ Object {
"takerAmount": "8000000000000000000",
"takerAsset": "0x2b591e99afe9f32eaa6214f7b7629768c40eeb39",
},
"domain": Object {
"domain": {
"chainId": 1,
"name": "AUGUSTUS RFQ",
"verifyingContract": "0xe92b586627ccA7a83dC919cc7127196d70f55a06",
"version": "1",
},
"types": Object {
"Order": Array [
Object {
"types": {
"Order": [
{
"name": "nonceAndMeta",
"type": "uint256",
},
Object {
{
"name": "expiry",
"type": "uint128",
},
Object {
{
"name": "makerAsset",
"type": "address",
},
Object {
{
"name": "takerAsset",
"type": "address",
},
Object {
{
"name": "maker",
"type": "address",
},
Object {
{
"name": "taker",
"type": "address",
},
Object {
{
"name": "makerAmount",
"type": "uint256",
},
Object {
{
"name": "takerAmount",
"type": "uint256",
},
Expand All @@ -183,8 +183,8 @@ Object {
`;

exports[`Limit Orders getLimitOrders 1`] = `
Array [
Object {
[
{
"chainId": 137,
"createdAt": 1661185927,
"expiry": 0,
Expand All @@ -207,7 +207,7 @@ Array [
"type": "LIMIT",
"updatedAt": 1661186323,
},
Object {
{
"chainId": 137,
"createdAt": 1661102635,
"expiry": 0,
Expand All @@ -230,7 +230,7 @@ Array [
"type": "LIMIT",
"updatedAt": 1661162748,
},
Object {
{
"chainId": 137,
"createdAt": 1661102624,
"expiry": 0,
Expand Down
Loading
Loading