From 3db077105a5f7b4b843e55ac649faf500b9227e5 Mon Sep 17 00:00:00 2001
From: zaidarain1
Date: Thu, 8 Aug 2024 15:57:19 +1000
Subject: [PATCH 01/29] feat: [DX-3086] Update TSConfig and fix ESLint for SDK
Packages (#2082)
---
.eslintrc | 4 +-
package.json | 2 +-
.../sdk/{.eslintrc => .eslintrc.cjs} | 4 +-
packages/blockchain-data/sdk/src/index.ts | 6 +-
packages/blockchain-data/sdk/tsconfig.json | 14 +--
packages/checkout/sdk-sample-app/.env | 1 +
packages/checkout/sdk-sample-app/.gitignore | 1 +
.../checkout/sdk/{.eslintrc => .eslintrc.cjs} | 6 +-
packages/checkout/sdk/src/index.ts | 17 ++-
packages/checkout/sdk/tsconfig.json | 14 +--
.../widgets-lib/{.eslintrc => .eslintrc.cjs} | 4 +-
packages/checkout/widgets-lib/package.json | 1 +
.../src/views/top-up/TopUpView.tsx | 3 +-
packages/checkout/widgets-lib/tsconfig.json | 18 +--
packages/config/.eslintrc.cjs | 11 ++
packages/config/tsconfig.json | 14 +--
.../.eslintrc => game-bridge/.eslintrc.cjs} | 4 +-
packages/game-bridge/tsconfig.json | 107 +-----------------
packages/internal/.eslintrc | 9 +-
packages/internal/bridge/sdk/.eslintrc | 4 +-
packages/internal/bridge/sdk/tsconfig.json | 20 +---
packages/internal/cryptofiat/tsconfig.json | 14 +--
packages/internal/dex/sdk/tsconfig.json | 20 +---
packages/internal/factory/sdk/.eslintrc | 2 +-
packages/internal/factory/sdk/tsconfig.json | 20 +---
.../.eslintrc.cjs} | 6 +-
.../internal/generated-clients/src/index.ts | 6 +-
.../internal/generated-clients/tsconfig.json | 14 +--
.../guardian/.eslintrc.cjs} | 7 +-
packages/internal/guardian/tsconfig.json | 20 +---
.../metrics/.eslintrc.cjs} | 6 +-
packages/internal/metrics/src/index.ts | 3 +-
packages/internal/metrics/tsconfig.json | 107 +-----------------
packages/internal/toolkit/package.json | 2 +-
packages/internal/toolkit/tsconfig.json | 14 +--
.../sdk/{.eslintrc => .eslintrc.cjs} | 4 +-
packages/minting-backend/sdk/tsconfig.json | 14 +--
.../orderbook/{.eslintrc => .eslintrc.cjs} | 6 +-
packages/orderbook/src/index.ts | 2 +-
packages/orderbook/tsconfig.json | 14 +--
.../passport/sdk/{.eslintrc => .eslintrc.cjs} | 4 +-
packages/passport/sdk/package.json | 2 +-
packages/passport/sdk/src/index.ts | 9 +-
packages/passport/sdk/tsconfig.json | 16 +--
.../webhook/sdk/{.eslintrc => .eslintrc.cjs} | 4 +-
packages/webhook/sdk/src/index.ts | 4 +-
packages/webhook/sdk/tsconfig.json | 14 +--
.../.eslintrc => x-client/.eslintrc.cjs} | 4 +-
packages/x-client/src/index.ts | 4 +-
packages/x-client/src/types/api.ts | 11 +-
packages/x-client/tsconfig.json | 13 +--
.../x-provider/{.eslintrc => .eslintrc.cjs} | 4 +-
packages/x-provider/package.json | 2 +-
packages/x-provider/src/index.ts | 2 +-
packages/x-provider/src/sample-app/.env | 1 +
packages/x-provider/src/sample-app/.gitignore | 1 +
packages/x-provider/tsconfig.json | 14 +--
sdk/{.eslintrc => .eslintrc.cjs} | 5 +-
sdk/package.json | 2 +-
sdk/tsconfig.json | 18 +--
tests/func-tests/zkevm/tsconfig.json | 11 ++
tsconfig.json => tsconfig.base.json | 7 +-
yarn.lock | 20 +++-
63 files changed, 161 insertions(+), 556 deletions(-)
rename packages/blockchain-data/sdk/{.eslintrc => .eslintrc.cjs} (79%)
create mode 100644 packages/checkout/sdk-sample-app/.env
rename packages/checkout/sdk/{.eslintrc => .eslintrc.cjs} (77%)
rename packages/checkout/widgets-lib/{.eslintrc => .eslintrc.cjs} (97%)
create mode 100644 packages/config/.eslintrc.cjs
rename packages/{x-client/.eslintrc => game-bridge/.eslintrc.cjs} (72%)
rename packages/internal/{metrics/.eslintrc => generated-clients/.eslintrc.cjs} (55%)
rename packages/{checkout/sdk-sample-app/.eslintrc => internal/guardian/.eslintrc.cjs} (55%)
rename packages/{game-bridge/.eslintrc => internal/metrics/.eslintrc.cjs} (55%)
rename packages/minting-backend/sdk/{.eslintrc => .eslintrc.cjs} (79%)
rename packages/orderbook/{.eslintrc => .eslintrc.cjs} (92%)
rename packages/passport/sdk/{.eslintrc => .eslintrc.cjs} (90%)
rename packages/webhook/sdk/{.eslintrc => .eslintrc.cjs} (79%)
rename packages/{checkout/.eslintrc => x-client/.eslintrc.cjs} (72%)
rename packages/x-provider/{.eslintrc => .eslintrc.cjs} (86%)
create mode 100644 packages/x-provider/src/sample-app/.env
rename sdk/{.eslintrc => .eslintrc.cjs} (75%)
create mode 100644 tests/func-tests/zkevm/tsconfig.json
rename tsconfig.json => tsconfig.base.json (80%)
diff --git a/.eslintrc b/.eslintrc
index dd819129f9..197e3b9049 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -7,7 +7,9 @@
"node_modules/",
"dist/",
"**sample-app**/",
- "**playground**/"
+ "**playground**/",
+ "*.cjs",
+ "tests/func-tests/"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
diff --git a/package.json b/package.json
index 166433557e..330eda0a33 100644
--- a/package.json
+++ b/package.json
@@ -106,4 +106,4 @@
"tests/**"
]
}
-}
\ No newline at end of file
+}
diff --git a/packages/blockchain-data/sdk/.eslintrc b/packages/blockchain-data/sdk/.eslintrc.cjs
similarity index 79%
rename from packages/blockchain-data/sdk/.eslintrc
rename to packages/blockchain-data/sdk/.eslintrc.cjs
index f77729693e..3193df85c8 100644
--- a/packages/blockchain-data/sdk/.eslintrc
+++ b/packages/blockchain-data/sdk/.eslintrc.cjs
@@ -1,9 +1,9 @@
-{
+module.exports = {
"extends": ["../../../.eslintrc"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": "."
+ "tsconfigRootDir": __dirname
},
"rules": {
"@typescript-eslint/comma-dangle": "off"
diff --git a/packages/blockchain-data/sdk/src/index.ts b/packages/blockchain-data/sdk/src/index.ts
index e86427ab7c..c41275b82d 100644
--- a/packages/blockchain-data/sdk/src/index.ts
+++ b/packages/blockchain-data/sdk/src/index.ts
@@ -14,7 +14,9 @@ type ActivityType = mr.ActivityType;
export {
Types,
APIError,
- BlockchainData,
+ BlockchainData
+};
+export type {
BlockchainDataModuleConfiguration,
- ActivityType,
+ ActivityType
};
diff --git a/packages/blockchain-data/sdk/tsconfig.json b/packages/blockchain-data/sdk/tsconfig.json
index 56c27e347a..e43a0c438f 100644
--- a/packages/blockchain-data/sdk/tsconfig.json
+++ b/packages/blockchain-data/sdk/tsconfig.json
@@ -1,20 +1,8 @@
{
+ "extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDirs": ["src"],
- "target": "es2022",
- "module": "esnext",
- "moduleResolution": "node",
- "noEmit": true,
- "allowJs": false,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": false,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "declaration": true,
- "resolveJsonModule": true,
- "skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
diff --git a/packages/checkout/sdk-sample-app/.env b/packages/checkout/sdk-sample-app/.env
new file mode 100644
index 0000000000..02269f00d9
--- /dev/null
+++ b/packages/checkout/sdk-sample-app/.env
@@ -0,0 +1 @@
+DISABLE_ESLINT_PLUGIN=true
diff --git a/packages/checkout/sdk-sample-app/.gitignore b/packages/checkout/sdk-sample-app/.gitignore
index 4d29575de8..e72ae06a01 100644
--- a/packages/checkout/sdk-sample-app/.gitignore
+++ b/packages/checkout/sdk-sample-app/.gitignore
@@ -17,6 +17,7 @@
.env.development.local
.env.test.local
.env.production.local
+!.env
npm-debug.log*
yarn-debug.log*
diff --git a/packages/checkout/sdk/.eslintrc b/packages/checkout/sdk/.eslintrc.cjs
similarity index 77%
rename from packages/checkout/sdk/.eslintrc
rename to packages/checkout/sdk/.eslintrc.cjs
index b4d4cad6cc..62a8693da0 100644
--- a/packages/checkout/sdk/.eslintrc
+++ b/packages/checkout/sdk/.eslintrc.cjs
@@ -1,10 +1,10 @@
-{
- "extends": ["../.eslintrc"],
+module.exports = {
+ "extends": ["../../../.eslintrc"],
"ignorePatterns": ["jest.config.*", "rollup.config.*"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": "."
+ "tsconfigRootDir": __dirname
},
"rules": {
"prefer-promise-reject-errors": "off",
diff --git a/packages/checkout/sdk/src/index.ts b/packages/checkout/sdk/src/index.ts
index 742b2b1f52..7b6a01091d 100644
--- a/packages/checkout/sdk/src/index.ts
+++ b/packages/checkout/sdk/src/index.ts
@@ -22,11 +22,7 @@ export {
ChainId,
ChainName,
ChainSlug,
- CheckoutStatus,
- EIP1193Provider,
- EIP6963ProviderInfo,
- EIP6963ProviderDetail,
- ExchangeType,
+ CheckoutStatus, ExchangeType,
FeeType,
FundingStepType,
GasEstimateType,
@@ -40,6 +36,11 @@ export {
WalletProviderName,
WalletProviderRdns,
} from './types';
+export type {
+ EIP1193Provider,
+ EIP6963ProviderInfo,
+ EIP6963ProviderDetail,
+} from './types';
export type {
AllowedNetworkConfig,
@@ -144,11 +145,9 @@ export type {
} from './types';
export {
- PostMessageHandler,
- PostMessageHandlerConfiguration,
- PostMessageHandlerEventType,
- PostMessageData,
+ PostMessageHandler, PostMessageHandlerEventType,
} from './postMessageHandler';
+export type { PostMessageHandlerConfiguration, PostMessageData } from './postMessageHandler';
export { isAddressSanctioned } from './sanctions';
diff --git a/packages/checkout/sdk/tsconfig.json b/packages/checkout/sdk/tsconfig.json
index 8c65238d9f..dfef981dd2 100644
--- a/packages/checkout/sdk/tsconfig.json
+++ b/packages/checkout/sdk/tsconfig.json
@@ -1,20 +1,8 @@
{
+ "extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDirs": ["src"],
- "target": "es2022",
- "module": "esnext",
- "moduleResolution": "node",
- "noEmit": true,
- "allowJs": false,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": false,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "declaration": true,
- "resolveJsonModule": true,
- "skipLibCheck": true,
},
"include": ["src", "test/__mocks__/window.ts"],
"exclude": ["node_modules", "dist", "test"]
diff --git a/packages/checkout/widgets-lib/.eslintrc b/packages/checkout/widgets-lib/.eslintrc.cjs
similarity index 97%
rename from packages/checkout/widgets-lib/.eslintrc
rename to packages/checkout/widgets-lib/.eslintrc.cjs
index 5214d4447b..96bdd2ff19 100644
--- a/packages/checkout/widgets-lib/.eslintrc
+++ b/packages/checkout/widgets-lib/.eslintrc.cjs
@@ -1,10 +1,10 @@
-{
+module.exports = {
"extends": ["../../../.eslintrc"],
"ignorePatterns": ["jest.config.*", "rollup.config.*"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": "."
+ "tsconfigRootDir": __dirname
},
"rules": {
"@typescript-eslint/naming-convention": [
diff --git a/packages/checkout/widgets-lib/package.json b/packages/checkout/widgets-lib/package.json
index 629ab890e2..1a77dbf39d 100644
--- a/packages/checkout/widgets-lib/package.json
+++ b/packages/checkout/widgets-lib/package.json
@@ -36,6 +36,7 @@
"i18next-browser-languagedetector": "^7.2.0",
"os-browserify": "^0.3.0",
"pako": "^2.1.0",
+ "pino-pretty": "^11.2.2",
"react-i18next": "^13.5.0",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
diff --git a/packages/checkout/widgets-lib/src/views/top-up/TopUpView.tsx b/packages/checkout/widgets-lib/src/views/top-up/TopUpView.tsx
index 1467e3c73c..38710b0f13 100644
--- a/packages/checkout/widgets-lib/src/views/top-up/TopUpView.tsx
+++ b/packages/checkout/widgets-lib/src/views/top-up/TopUpView.tsx
@@ -12,7 +12,6 @@ import {
import { Environment } from '@imtbl/config';
import { Web3Provider } from '@ethersproject/providers';
import { useTranslation } from 'react-i18next';
-import { $Dictionary } from 'i18next/typescript/helpers';
import {
UserJourney,
useAnalytics,
@@ -40,6 +39,8 @@ import { OnRampWidgetViews } from '../../context/view-context/OnRampViewContextT
import { EventTargetContext } from '../../context/event-target-context/EventTargetContext';
import { TopUpMenuItem, TopUpMenuItemProps } from './TopUpMenuItem';
+type $Dictionary = { [key: string]: T };
+
interface TopUpViewProps {
widgetEvent: IMTBLWidgetEvents;
checkout?: Checkout;
diff --git a/packages/checkout/widgets-lib/tsconfig.json b/packages/checkout/widgets-lib/tsconfig.json
index b7238c9141..fb0ee09b32 100644
--- a/packages/checkout/widgets-lib/tsconfig.json
+++ b/packages/checkout/widgets-lib/tsconfig.json
@@ -1,26 +1,16 @@
{
+ "extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
- "target": "es2022",
"lib": ["dom", "dom.iterable", "esnext"],
- "allowJs": true,
- "skipLibCheck": true,
- "esModuleInterop": true,
- "allowSyntheticDefaultImports": true,
- "strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
- "module": "esnext",
- "moduleResolution": "node",
- "resolveJsonModule": true,
- "isolatedModules": true,
- "noEmit": true,
- "declaration": true,
"jsx": "react-jsx",
"noImplicitAny": false,
"jsxImportSource": "@emotion/react",
- "experimentalDecorators": true
+ "experimentalDecorators": true,
+ "skipLibCheck": true
},
- "include": ["src", "babel.config.js"],
+ "include": ["src"],
"exclude": ["node_modules", "dist"]
}
diff --git a/packages/config/.eslintrc.cjs b/packages/config/.eslintrc.cjs
new file mode 100644
index 0000000000..11b2a3d1ba
--- /dev/null
+++ b/packages/config/.eslintrc.cjs
@@ -0,0 +1,11 @@
+module.exports = {
+ "extends": ["../../.eslintrc"],
+ "parser": "@typescript-eslint/parser",
+ "parserOptions": {
+ "project": "./tsconfig.json",
+ "tsconfigRootDir": __dirname
+ },
+ "rules": {
+ "@typescript-eslint/comma-dangle": "off"
+ }
+}
diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json
index 56c27e347a..ee6d658245 100644
--- a/packages/config/tsconfig.json
+++ b/packages/config/tsconfig.json
@@ -1,20 +1,8 @@
{
+ "extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDirs": ["src"],
- "target": "es2022",
- "module": "esnext",
- "moduleResolution": "node",
- "noEmit": true,
- "allowJs": false,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": false,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "declaration": true,
- "resolveJsonModule": true,
- "skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
diff --git a/packages/x-client/.eslintrc b/packages/game-bridge/.eslintrc.cjs
similarity index 72%
rename from packages/x-client/.eslintrc
rename to packages/game-bridge/.eslintrc.cjs
index f90c594b06..8b8a821f7e 100644
--- a/packages/x-client/.eslintrc
+++ b/packages/game-bridge/.eslintrc.cjs
@@ -1,8 +1,8 @@
-{
+module.exports = {
"extends": ["../../.eslintrc"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": "."
+ "tsconfigRootDir": __dirname
}
}
diff --git a/packages/game-bridge/tsconfig.json b/packages/game-bridge/tsconfig.json
index fc204f35c4..89d5c7b53d 100644
--- a/packages/game-bridge/tsconfig.json
+++ b/packages/game-bridge/tsconfig.json
@@ -1,109 +1,8 @@
{
+ "extends": "../../tsconfig.base.json",
"compilerOptions": {
- /* Visit https://aka.ms/tsconfig to read more about this file */
-
- /* Projects */
- // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
- // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
-
- /* Language and Environment */
- "target": "es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
- // "jsx": "preserve", /* Specify what JSX code is generated. */
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
- // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
- // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
-
- /* Modules */
- "module": "esnext", /* Specify what module code is generated. */
- // "rootDir": "./src", /* Specify the root folder within your source files. */
- "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
- "rootDirs": ["src"], /* Allow multiple folders to be treated as one when resolving modules. */
- // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
- // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
- // "resolveJsonModule": true, /* Enable importing .json files. */
- // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */
-
- /* JavaScript Support */
- // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
- // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
-
- /* Emit */
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
- "outDir": "./dist", /* Specify an output folder for all emitted files. */
- "removeComments": false, /* Disable emitting comments. */
- // "noEmit": true, /* Disable emitting files from a compilation. */
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
- // "newLine": "crlf", /* Set the newline character for emitting files. */
- // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
- // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
- // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
-
- /* Interop Constraints */
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
-
- /* Type Checking */
- "strict": true, /* Enable all strict type-checking options. */
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
- // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
- // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
- // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
- // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
- // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
-
- /* Completeness */
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
- "skipLibCheck": true, /* Skip type checking all .d.ts files. */
-
- /* Advanced */
- // "noEmit": true,
- // "allowJs": false,
- // "allowSyntheticDefaultImports": true,
- // "resolveJsonModule": true,
+ "outDir": "./dist",
+ "rootDirs": ["src"],
},
"include": ["src"],
"exclude": ["dist", "jest.config.js", "node_modules"]
diff --git a/packages/internal/.eslintrc b/packages/internal/.eslintrc
index a6393a1ed1..589b3bc659 100644
--- a/packages/internal/.eslintrc
+++ b/packages/internal/.eslintrc
@@ -1,9 +1,4 @@
{
"ignorePatterns": ["**sample-app**/"],
- "extends": ["../../.eslintrc"],
- "parser": "@typescript-eslint/parser",
- "parserOptions": {
- "project": "./tsconfig.json",
- "tsconfigRootDir": "."
- }
-}
+ "extends": ["../../.eslintrc"]
+}
\ No newline at end of file
diff --git a/packages/internal/bridge/sdk/.eslintrc b/packages/internal/bridge/sdk/.eslintrc
index 9c72b59200..3dae7773ec 100644
--- a/packages/internal/bridge/sdk/.eslintrc
+++ b/packages/internal/bridge/sdk/.eslintrc
@@ -1,7 +1,5 @@
{
- "extends": [
- "../../../../.eslintrc"
- ],
+ "extends": ["../../.eslintrc"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
diff --git a/packages/internal/bridge/sdk/tsconfig.json b/packages/internal/bridge/sdk/tsconfig.json
index 66365daa07..c13a94c467 100644
--- a/packages/internal/bridge/sdk/tsconfig.json
+++ b/packages/internal/bridge/sdk/tsconfig.json
@@ -1,24 +1,8 @@
{
+ "extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
- "rootDirs": [
- "src"
- ],
- "target": "es2022",
- "module": "es2022",
- "moduleResolution": "node",
- "allowJs": false,
- "skipLibCheck": true,
- "esModuleInterop": true,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": true,
- "allowSyntheticDefaultImports": true,
- "noFallthroughCasesInSwitch": true,
- "resolveJsonModule": true,
- "isolatedModules": true,
- "noEmit": true,
- "declaration": true,
+ "rootDirs": ["src"],
},
"include": [
"src"
diff --git a/packages/internal/cryptofiat/tsconfig.json b/packages/internal/cryptofiat/tsconfig.json
index 56c27e347a..e43a0c438f 100644
--- a/packages/internal/cryptofiat/tsconfig.json
+++ b/packages/internal/cryptofiat/tsconfig.json
@@ -1,20 +1,8 @@
{
+ "extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDirs": ["src"],
- "target": "es2022",
- "module": "esnext",
- "moduleResolution": "node",
- "noEmit": true,
- "allowJs": false,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": false,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "declaration": true,
- "resolveJsonModule": true,
- "skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
diff --git a/packages/internal/dex/sdk/tsconfig.json b/packages/internal/dex/sdk/tsconfig.json
index 7a7f818705..18cf2ecd20 100644
--- a/packages/internal/dex/sdk/tsconfig.json
+++ b/packages/internal/dex/sdk/tsconfig.json
@@ -1,24 +1,8 @@
{
+ "extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
- "rootDirs": [
- "src"
- ],
- "target": "es2022",
- "module": "es2022",
- "moduleResolution": "node",
- "allowJs": false,
- "skipLibCheck": true,
- "esModuleInterop": true,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": true,
- "allowSyntheticDefaultImports": true,
- "noFallthroughCasesInSwitch": true,
- "resolveJsonModule": true,
- "isolatedModules": true,
- "noEmit": true,
- "declaration": true
+ "rootDirs": ["src"],
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
diff --git a/packages/internal/factory/sdk/.eslintrc b/packages/internal/factory/sdk/.eslintrc
index 9c72b59200..e3881a722e 100644
--- a/packages/internal/factory/sdk/.eslintrc
+++ b/packages/internal/factory/sdk/.eslintrc
@@ -1,6 +1,6 @@
{
"extends": [
- "../../../../.eslintrc"
+ "../../.eslintrc"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
diff --git a/packages/internal/factory/sdk/tsconfig.json b/packages/internal/factory/sdk/tsconfig.json
index 66365daa07..c13a94c467 100644
--- a/packages/internal/factory/sdk/tsconfig.json
+++ b/packages/internal/factory/sdk/tsconfig.json
@@ -1,24 +1,8 @@
{
+ "extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
- "rootDirs": [
- "src"
- ],
- "target": "es2022",
- "module": "es2022",
- "moduleResolution": "node",
- "allowJs": false,
- "skipLibCheck": true,
- "esModuleInterop": true,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": true,
- "allowSyntheticDefaultImports": true,
- "noFallthroughCasesInSwitch": true,
- "resolveJsonModule": true,
- "isolatedModules": true,
- "noEmit": true,
- "declaration": true,
+ "rootDirs": ["src"],
},
"include": [
"src"
diff --git a/packages/internal/metrics/.eslintrc b/packages/internal/generated-clients/.eslintrc.cjs
similarity index 55%
rename from packages/internal/metrics/.eslintrc
rename to packages/internal/generated-clients/.eslintrc.cjs
index 9b6c8a5aef..cc10d70796 100644
--- a/packages/internal/metrics/.eslintrc
+++ b/packages/internal/generated-clients/.eslintrc.cjs
@@ -1,8 +1,8 @@
-{
- "extends": ["../../../.eslintrc"],
+module.exports = {
+ "extends": ["../.eslintrc"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": "."
+ "tsconfigRootDir": __dirname
}
}
diff --git a/packages/internal/generated-clients/src/index.ts b/packages/internal/generated-clients/src/index.ts
index 03e1bcb449..949fc689d4 100644
--- a/packages/internal/generated-clients/src/index.ts
+++ b/packages/internal/generated-clients/src/index.ts
@@ -4,9 +4,7 @@ export * as BlockchainData from './blockchain-data/index';
export { ImxApiClients } from './imx-api-clients';
export { MultiRollupApiClients } from './mr-api-clients';
export {
- ImmutableAPIConfiguration,
imxApiConfig,
- multiRollupConfig,
- MultiRollupAPIConfiguration,
- createConfig,
+ multiRollupConfig, createConfig,
} from './config';
+export type { ImmutableAPIConfiguration, MultiRollupAPIConfiguration } from './config';
diff --git a/packages/internal/generated-clients/tsconfig.json b/packages/internal/generated-clients/tsconfig.json
index 56c27e347a..e43a0c438f 100644
--- a/packages/internal/generated-clients/tsconfig.json
+++ b/packages/internal/generated-clients/tsconfig.json
@@ -1,20 +1,8 @@
{
+ "extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDirs": ["src"],
- "target": "es2022",
- "module": "esnext",
- "moduleResolution": "node",
- "noEmit": true,
- "allowJs": false,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": false,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "declaration": true,
- "resolveJsonModule": true,
- "skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
diff --git a/packages/checkout/sdk-sample-app/.eslintrc b/packages/internal/guardian/.eslintrc.cjs
similarity index 55%
rename from packages/checkout/sdk-sample-app/.eslintrc
rename to packages/internal/guardian/.eslintrc.cjs
index 664e0e3da5..cc10d70796 100644
--- a/packages/checkout/sdk-sample-app/.eslintrc
+++ b/packages/internal/guardian/.eslintrc.cjs
@@ -1,9 +1,8 @@
-{
+module.exports = {
+ "extends": ["../.eslintrc"],
"parser": "@typescript-eslint/parser",
- "ignorePatterns": ".",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": ".",
- "sourceType": "module"
+ "tsconfigRootDir": __dirname
}
}
diff --git a/packages/internal/guardian/tsconfig.json b/packages/internal/guardian/tsconfig.json
index f587a4939e..05087f2b94 100644
--- a/packages/internal/guardian/tsconfig.json
+++ b/packages/internal/guardian/tsconfig.json
@@ -1,24 +1,8 @@
{
+ "extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
- "rootDirs": [
- "src"
- ],
- "target": "es2022",
- "module": "es2022",
- "moduleResolution": "node",
- "allowJs": false,
- "skipLibCheck": true,
- "esModuleInterop": true,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": true,
- "allowSyntheticDefaultImports": true,
- "noFallthroughCasesInSwitch": true,
- "resolveJsonModule": true,
- "isolatedModules": true,
- "noEmit": true,
- "declaration": true
+ "rootDirs": ["src"],
},
"include": [
"src"
diff --git a/packages/game-bridge/.eslintrc b/packages/internal/metrics/.eslintrc.cjs
similarity index 55%
rename from packages/game-bridge/.eslintrc
rename to packages/internal/metrics/.eslintrc.cjs
index f90c594b06..cc10d70796 100644
--- a/packages/game-bridge/.eslintrc
+++ b/packages/internal/metrics/.eslintrc.cjs
@@ -1,8 +1,8 @@
-{
- "extends": ["../../.eslintrc"],
+module.exports = {
+ "extends": ["../.eslintrc"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": "."
+ "tsconfigRootDir": __dirname
}
}
diff --git a/packages/internal/metrics/src/index.ts b/packages/internal/metrics/src/index.ts
index 323f48a335..e5ea7db07d 100644
--- a/packages/internal/metrics/src/index.ts
+++ b/packages/internal/metrics/src/index.ts
@@ -3,7 +3,8 @@ import * as localStorage from './utils/localStorage';
export { track } from './track';
export { trackDuration } from './performance';
-export { Flow, trackFlow } from './flow';
+export { trackFlow } from './flow';
+export type { Flow } from './flow';
export { trackError } from './error';
export { identify } from './identify';
export {
diff --git a/packages/internal/metrics/tsconfig.json b/packages/internal/metrics/tsconfig.json
index fc204f35c4..f09a2d6e5c 100644
--- a/packages/internal/metrics/tsconfig.json
+++ b/packages/internal/metrics/tsconfig.json
@@ -1,109 +1,8 @@
{
+ "extends": "../../../tsconfig.base.json",
"compilerOptions": {
- /* Visit https://aka.ms/tsconfig to read more about this file */
-
- /* Projects */
- // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
- // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
-
- /* Language and Environment */
- "target": "es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
- // "jsx": "preserve", /* Specify what JSX code is generated. */
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
- // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
- // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
-
- /* Modules */
- "module": "esnext", /* Specify what module code is generated. */
- // "rootDir": "./src", /* Specify the root folder within your source files. */
- "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
- "rootDirs": ["src"], /* Allow multiple folders to be treated as one when resolving modules. */
- // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
- // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
- // "resolveJsonModule": true, /* Enable importing .json files. */
- // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */
-
- /* JavaScript Support */
- // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
- // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
-
- /* Emit */
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
- "outDir": "./dist", /* Specify an output folder for all emitted files. */
- "removeComments": false, /* Disable emitting comments. */
- // "noEmit": true, /* Disable emitting files from a compilation. */
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
- // "newLine": "crlf", /* Set the newline character for emitting files. */
- // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
- // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
- // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
-
- /* Interop Constraints */
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
-
- /* Type Checking */
- "strict": true, /* Enable all strict type-checking options. */
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
- // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
- // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
- // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
- // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
- // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
-
- /* Completeness */
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
- "skipLibCheck": true, /* Skip type checking all .d.ts files. */
-
- /* Advanced */
- // "noEmit": true,
- // "allowJs": false,
- // "allowSyntheticDefaultImports": true,
- // "resolveJsonModule": true,
+ "outDir": "./dist",
+ "rootDirs": ["src"],
},
"include": ["src"],
"exclude": ["dist", "jest.config.js", "node_modules"]
diff --git a/packages/internal/toolkit/package.json b/packages/internal/toolkit/package.json
index e015d69f35..760318f448 100644
--- a/packages/internal/toolkit/package.json
+++ b/packages/internal/toolkit/package.json
@@ -9,7 +9,7 @@
"@ethersproject/providers": "^5.7.2",
"@ethersproject/wallet": "^5.7.0",
"@imtbl/x-client": "0.0.0",
- "@magic-ext/oidc": "4.2.0",
+ "@magic-ext/oidc": "4.3.1",
"@metamask/detect-provider": "^2.0.0",
"axios": "^1.6.5",
"bn.js": "^5.2.1",
diff --git a/packages/internal/toolkit/tsconfig.json b/packages/internal/toolkit/tsconfig.json
index 7dbb9f1fb9..0813bd4336 100644
--- a/packages/internal/toolkit/tsconfig.json
+++ b/packages/internal/toolkit/tsconfig.json
@@ -1,20 +1,8 @@
{
+ "extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDirs": ["src"],
- "target": "es2022",
- "module": "esnext",
- "moduleResolution": "node",
- "noEmit": true,
- "allowJs": false,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": false,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "declaration": true,
- "resolveJsonModule": true,
- "skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist", "src/sample-app"]
diff --git a/packages/minting-backend/sdk/.eslintrc b/packages/minting-backend/sdk/.eslintrc.cjs
similarity index 79%
rename from packages/minting-backend/sdk/.eslintrc
rename to packages/minting-backend/sdk/.eslintrc.cjs
index f77729693e..3193df85c8 100644
--- a/packages/minting-backend/sdk/.eslintrc
+++ b/packages/minting-backend/sdk/.eslintrc.cjs
@@ -1,9 +1,9 @@
-{
+module.exports = {
"extends": ["../../../.eslintrc"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": "."
+ "tsconfigRootDir": __dirname
},
"rules": {
"@typescript-eslint/comma-dangle": "off"
diff --git a/packages/minting-backend/sdk/tsconfig.json b/packages/minting-backend/sdk/tsconfig.json
index 56c27e347a..e43a0c438f 100644
--- a/packages/minting-backend/sdk/tsconfig.json
+++ b/packages/minting-backend/sdk/tsconfig.json
@@ -1,20 +1,8 @@
{
+ "extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDirs": ["src"],
- "target": "es2022",
- "module": "esnext",
- "moduleResolution": "node",
- "noEmit": true,
- "allowJs": false,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": false,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "declaration": true,
- "resolveJsonModule": true,
- "skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
diff --git a/packages/orderbook/.eslintrc b/packages/orderbook/.eslintrc.cjs
similarity index 92%
rename from packages/orderbook/.eslintrc
rename to packages/orderbook/.eslintrc.cjs
index 38e5c14091..aaaaae145f 100644
--- a/packages/orderbook/.eslintrc
+++ b/packages/orderbook/.eslintrc.cjs
@@ -1,10 +1,10 @@
-{
- "extends": ["airbnb", "airbnb-typescript"],
+module.exports = {
+ "extends": ["../../.eslintrc", "airbnb", "airbnb-typescript"],
"ignorePatterns": ["jest.config.*"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": "."
+ "tsconfigRootDir": __dirname
},
"rules": {
"@typescript-eslint/naming-convention": [
diff --git a/packages/orderbook/src/index.ts b/packages/orderbook/src/index.ts
index 2d42a79ff8..e92417f45d 100644
--- a/packages/orderbook/src/index.ts
+++ b/packages/orderbook/src/index.ts
@@ -1,4 +1,4 @@
export { Orderbook } from './orderbook';
export { constants } from './constants';
-export { OrderbookModuleConfiguration, OrderbookOverrides } from './config';
+export type { OrderbookModuleConfiguration, OrderbookOverrides } from './config';
export * from './types';
diff --git a/packages/orderbook/tsconfig.json b/packages/orderbook/tsconfig.json
index 56c27e347a..ee6d658245 100644
--- a/packages/orderbook/tsconfig.json
+++ b/packages/orderbook/tsconfig.json
@@ -1,20 +1,8 @@
{
+ "extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDirs": ["src"],
- "target": "es2022",
- "module": "esnext",
- "moduleResolution": "node",
- "noEmit": true,
- "allowJs": false,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": false,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "declaration": true,
- "resolveJsonModule": true,
- "skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
diff --git a/packages/passport/sdk/.eslintrc b/packages/passport/sdk/.eslintrc.cjs
similarity index 90%
rename from packages/passport/sdk/.eslintrc
rename to packages/passport/sdk/.eslintrc.cjs
index 4fd603ea90..a617575b17 100644
--- a/packages/passport/sdk/.eslintrc
+++ b/packages/passport/sdk/.eslintrc.cjs
@@ -1,9 +1,9 @@
-{
+module.exports = {
"extends": ["../../../.eslintrc"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": "."
+ "tsconfigRootDir": __dirname
},
"rules": {
"@typescript-eslint/naming-convention": [
diff --git a/packages/passport/sdk/package.json b/packages/passport/sdk/package.json
index 464636ec92..a64bae0ffe 100644
--- a/packages/passport/sdk/package.json
+++ b/packages/passport/sdk/package.json
@@ -15,7 +15,7 @@
"@imtbl/toolkit": "0.0.0",
"@imtbl/x-client": "0.0.0",
"@imtbl/x-provider": "0.0.0",
- "@magic-ext/oidc": "4.2.0",
+ "@magic-ext/oidc": "4.3.1",
"@metamask/detect-provider": "^2.0.0",
"axios": "^1.6.5",
"ethers": "^5.7.2",
diff --git a/packages/passport/sdk/src/index.ts b/packages/passport/sdk/src/index.ts
index 7a782c1ed8..f9411a0dc6 100644
--- a/packages/passport/sdk/src/index.ts
+++ b/packages/passport/sdk/src/index.ts
@@ -1,13 +1,14 @@
export { PassportError } from './errors/passportError';
export { Passport } from './Passport';
export {
+ ProviderEvent,
+} from './zkEvm/types';
+export type {
RequestArguments,
JsonRpcRequestPayload,
JsonRpcResponsePayload,
JsonRpcRequestCallback,
- Provider,
- ProviderEvent,
- AccountsChangedEvent,
+ Provider, AccountsChangedEvent,
TypedDataPayload,
} from './zkEvm/types';
export {
@@ -15,7 +16,7 @@ export {
ProviderErrorCode,
RpcErrorCode,
} from './zkEvm/JsonRpcError';
-export {
+export type {
LinkWalletParams,
LinkedWallet,
UserProfile,
diff --git a/packages/passport/sdk/tsconfig.json b/packages/passport/sdk/tsconfig.json
index 34907d4105..313a445552 100644
--- a/packages/passport/sdk/tsconfig.json
+++ b/packages/passport/sdk/tsconfig.json
@@ -1,26 +1,12 @@
{
+ "extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDirs": ["src"],
- "target": "es2022",
- "module": "esnext",
- "moduleResolution": "node",
- "noEmit": true,
- "allowJs": false,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": false,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "declaration": true,
- "resolveJsonModule": true,
- "skipLibCheck": true
},
"include": ["src", "src/types.ts"],
"exclude": [
"node_modules",
"dist",
- "src/modules/provider/sample-app",
- "src/modules/checkout"
]
}
diff --git a/packages/webhook/sdk/.eslintrc b/packages/webhook/sdk/.eslintrc.cjs
similarity index 79%
rename from packages/webhook/sdk/.eslintrc
rename to packages/webhook/sdk/.eslintrc.cjs
index f77729693e..3193df85c8 100644
--- a/packages/webhook/sdk/.eslintrc
+++ b/packages/webhook/sdk/.eslintrc.cjs
@@ -1,9 +1,9 @@
-{
+module.exports = {
"extends": ["../../../.eslintrc"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": "."
+ "tsconfigRootDir": __dirname
},
"rules": {
"@typescript-eslint/comma-dangle": "off"
diff --git a/packages/webhook/sdk/src/index.ts b/packages/webhook/sdk/src/index.ts
index d1149bdc6b..7943f8d197 100644
--- a/packages/webhook/sdk/src/index.ts
+++ b/packages/webhook/sdk/src/index.ts
@@ -19,6 +19,6 @@ export type {
} from './event-types';
export {
- handle,
- WebhookHandlers
+ handle
};
+export type { WebhookHandlers };
diff --git a/packages/webhook/sdk/tsconfig.json b/packages/webhook/sdk/tsconfig.json
index 56c27e347a..e43a0c438f 100644
--- a/packages/webhook/sdk/tsconfig.json
+++ b/packages/webhook/sdk/tsconfig.json
@@ -1,20 +1,8 @@
{
+ "extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDirs": ["src"],
- "target": "es2022",
- "module": "esnext",
- "moduleResolution": "node",
- "noEmit": true,
- "allowJs": false,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": false,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "declaration": true,
- "resolveJsonModule": true,
- "skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
diff --git a/packages/checkout/.eslintrc b/packages/x-client/.eslintrc.cjs
similarity index 72%
rename from packages/checkout/.eslintrc
rename to packages/x-client/.eslintrc.cjs
index f90c594b06..8b8a821f7e 100644
--- a/packages/checkout/.eslintrc
+++ b/packages/x-client/.eslintrc.cjs
@@ -1,8 +1,8 @@
-{
+module.exports = {
"extends": ["../../.eslintrc"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": "."
+ "tsconfigRootDir": __dirname
}
}
diff --git a/packages/x-client/src/index.ts b/packages/x-client/src/index.ts
index 54dffc49bd..f484a40791 100644
--- a/packages/x-client/src/index.ts
+++ b/packages/x-client/src/index.ts
@@ -6,9 +6,9 @@ export * from './types';
/**
* aliased exports to maintain backwards compatibility
*/
-export { ImxModuleConfiguration as ImxClientModuleConfiguration } from './config';
+export type { ImxModuleConfiguration as ImxClientModuleConfiguration } from './config';
export {
generateLegacyStarkPrivateKey as imxClientGenerateLegacyStarkPrivateKey,
createStarkSigner as imxClientCreateStarkSigner,
} from './exportUtils';
-export { WalletConnection as ImxClientWalletConnection } from './types';
+export type { WalletConnection as ImxClientWalletConnection } from './types';
diff --git a/packages/x-client/src/types/api.ts b/packages/x-client/src/types/api.ts
index 9509146795..669119d3f5 100644
--- a/packages/x-client/src/types/api.ts
+++ b/packages/x-client/src/types/api.ts
@@ -2,7 +2,7 @@
/* eslint-disable max-len */
import { imx } from '@imtbl/generated-clients';
-export { TransactionResponse } from '@ethersproject/providers';
+export type { TransactionResponse } from '@ethersproject/providers';
/**
* Need to specifically export the classes and interfaces from the generated
@@ -99,4 +99,11 @@ export interface UpdateCollectionRequest extends imx.UpdateCollectionRequest {}
export interface WithdrawalsApiGetWithdrawalRequest extends imx.WithdrawalsApiGetWithdrawalRequest {}
export interface WithdrawalsApiListWithdrawalsRequest extends imx.WithdrawalsApiListWithdrawalsRequest {}
-export const { MetadataSchemaRequestTypeEnum } = imx;
+// eslint-disable-next-line prefer-destructuring
+export const MetadataSchemaRequestTypeEnum: {
+ readonly Enum: 'enum';
+ readonly Text: 'text';
+ readonly Boolean: 'boolean';
+ readonly Continuous: 'continuous';
+ readonly Discrete: 'discrete';
+} = imx.MetadataSchemaRequestTypeEnum;
diff --git a/packages/x-client/tsconfig.json b/packages/x-client/tsconfig.json
index 6a6643584c..f42e62aedc 100644
--- a/packages/x-client/tsconfig.json
+++ b/packages/x-client/tsconfig.json
@@ -1,19 +1,8 @@
{
+ "extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDirs": ["src"],
- "target": "es2022",
- "module": "esnext",
- "moduleResolution": "node",
- "noEmit": true,
- "allowJs": false,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": false,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "declaration": true,
- "resolveJsonModule": true,
"skipLibCheck": true
},
"include": ["src"],
diff --git a/packages/x-provider/.eslintrc b/packages/x-provider/.eslintrc.cjs
similarity index 86%
rename from packages/x-provider/.eslintrc
rename to packages/x-provider/.eslintrc.cjs
index 214bef5de8..a43b4737b9 100644
--- a/packages/x-provider/.eslintrc
+++ b/packages/x-provider/.eslintrc.cjs
@@ -1,9 +1,9 @@
-{
+module.exports = {
"extends": ["../../.eslintrc"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": "."
+ "tsconfigRootDir": __dirname
},
"rules": {
"@typescript-eslint/naming-convention": [
diff --git a/packages/x-provider/package.json b/packages/x-provider/package.json
index cbd9c2ed38..39760dc8e7 100644
--- a/packages/x-provider/package.json
+++ b/packages/x-provider/package.json
@@ -9,7 +9,7 @@
"@imtbl/generated-clients": "0.0.0",
"@imtbl/toolkit": "0.0.0",
"@imtbl/x-client": "0.0.0",
- "@magic-ext/oidc": "4.2.0",
+ "@magic-ext/oidc": "4.3.1",
"@metamask/detect-provider": "^2.0.0",
"axios": "^1.6.5",
"ethers": "^5.7.2",
diff --git a/packages/x-provider/src/index.ts b/packages/x-provider/src/index.ts
index de85e1a08b..99bc94293d 100644
--- a/packages/x-provider/src/index.ts
+++ b/packages/x-provider/src/index.ts
@@ -1,4 +1,4 @@
-export { IMXProvider } from './imxProvider';
+export type { IMXProvider } from './imxProvider';
export { GenericIMXProvider } from './genericImxProvider';
export { MetaMaskIMXProvider } from './l1-providers/metaMaskWrapper';
export { ProviderConfiguration } from './config';
diff --git a/packages/x-provider/src/sample-app/.env b/packages/x-provider/src/sample-app/.env
new file mode 100644
index 0000000000..02269f00d9
--- /dev/null
+++ b/packages/x-provider/src/sample-app/.env
@@ -0,0 +1 @@
+DISABLE_ESLINT_PLUGIN=true
diff --git a/packages/x-provider/src/sample-app/.gitignore b/packages/x-provider/src/sample-app/.gitignore
index 0d956b3213..d170858507 100644
--- a/packages/x-provider/src/sample-app/.gitignore
+++ b/packages/x-provider/src/sample-app/.gitignore
@@ -17,6 +17,7 @@ node_modules
.env.development.local
.env.test.local
.env.production.local
+!.env
npm-debug.log*
yarn-debug.log*
diff --git a/packages/x-provider/tsconfig.json b/packages/x-provider/tsconfig.json
index 7dbb9f1fb9..6d8bc46f04 100644
--- a/packages/x-provider/tsconfig.json
+++ b/packages/x-provider/tsconfig.json
@@ -1,20 +1,8 @@
{
+ "extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDirs": ["src"],
- "target": "es2022",
- "module": "esnext",
- "moduleResolution": "node",
- "noEmit": true,
- "allowJs": false,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": false,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "declaration": true,
- "resolveJsonModule": true,
- "skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist", "src/sample-app"]
diff --git a/sdk/.eslintrc b/sdk/.eslintrc.cjs
similarity index 75%
rename from sdk/.eslintrc
rename to sdk/.eslintrc.cjs
index 9cf76ec00c..515261c86d 100644
--- a/sdk/.eslintrc
+++ b/sdk/.eslintrc.cjs
@@ -1,9 +1,10 @@
-{
+module.exports = {
"ignorePatterns": ["jest.config.*"],
+ "extends": ["../.eslintrc"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
- "tsconfigRootDir": ".",
+ "tsconfigRootDir": __dirname,
"sourceType": "module"
},
"rules": {
diff --git a/sdk/package.json b/sdk/package.json
index ae744e072b..b6ff70fb86 100644
--- a/sdk/package.json
+++ b/sdk/package.json
@@ -18,7 +18,7 @@
"@ethersproject/wallet": "^5.7.0",
"@imtbl/react-analytics": "0.2.1-alpha",
"@jest/globals": "^29.5.0",
- "@magic-ext/oidc": "4.2.0",
+ "@magic-ext/oidc": "4.3.1",
"@metamask/detect-provider": "^2.0.0",
"@opensea/seaport-js": "4.0.3",
"@rive-app/react-canvas-lite": "^4.9.0",
diff --git a/sdk/tsconfig.json b/sdk/tsconfig.json
index 2057e61172..30f13daf53 100644
--- a/sdk/tsconfig.json
+++ b/sdk/tsconfig.json
@@ -1,26 +1,12 @@
{
+ "extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDirs": ["src"],
- "target": "es2022",
- "module": "esnext",
- "moduleResolution": "node",
- "noEmit": true,
- "allowJs": false,
- "removeComments": false,
- "strict": true,
- "forceConsistentCasingInFileNames": false,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "declaration": false,
- "resolveJsonModule": true,
- "skipLibCheck": false
},
"include": ["src"],
"exclude": [
"node_modules",
- "dist",
- "src/modules/provider/sample-app",
- "src/modules/checkout"
+ "dist"
]
}
diff --git a/tests/func-tests/zkevm/tsconfig.json b/tests/func-tests/zkevm/tsconfig.json
new file mode 100644
index 0000000000..e05ca5f05c
--- /dev/null
+++ b/tests/func-tests/zkevm/tsconfig.json
@@ -0,0 +1,11 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "rootDirs": ["src"],
+ },
+ "include": ["src"],
+ "exclude": [
+ "node_modules",
+ "dist"
+ ]
+}
diff --git a/tsconfig.json b/tsconfig.base.json
similarity index 80%
rename from tsconfig.json
rename to tsconfig.base.json
index 333e556c0f..f6bd61966a 100644
--- a/tsconfig.json
+++ b/tsconfig.base.json
@@ -1,6 +1,5 @@
{
"compilerOptions": {
- "jsx": "react",
"target": "es2022",
"module": "esnext",
"moduleResolution": "node",
@@ -11,9 +10,11 @@
"forceConsistentCasingInFileNames": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
- "declaration": false,
+ "declaration": true,
"resolveJsonModule": true,
- "skipLibCheck": true
+ "skipLibCheck": false,
+ "isolatedModules": true,
+ "incremental": true
},
"ts-node": {
"compilerOptions": {
diff --git a/yarn.lock b/yarn.lock
index dad3d6bc7e..1cb4b81ffc 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4381,6 +4381,7 @@ __metadata:
local-cypress: ^1.2.6
os-browserify: ^0.3.0
pako: ^2.1.0
+ pino-pretty: ^11.2.2
react-app-rewired: ^2.2.1
react-i18next: ^13.5.0
react-scripts: 5.0.1
@@ -4685,7 +4686,7 @@ __metadata:
"@imtbl/toolkit": 0.0.0
"@imtbl/x-client": 0.0.0
"@imtbl/x-provider": 0.0.0
- "@magic-ext/oidc": 4.2.0
+ "@magic-ext/oidc": 4.3.1
"@metamask/detect-provider": ^2.0.0
"@rollup/plugin-typescript": ^11.1.6
"@swc/core": ^1.3.36
@@ -4761,7 +4762,7 @@ __metadata:
"@imtbl/x-client": 0.0.0
"@imtbl/x-provider": 0.0.0
"@jest/globals": ^29.5.0
- "@magic-ext/oidc": 4.2.0
+ "@magic-ext/oidc": 4.3.1
"@metamask/detect-provider": ^2.0.0
"@opensea/seaport-js": 4.0.3
"@rive-app/react-canvas-lite": ^4.9.0
@@ -4901,7 +4902,7 @@ __metadata:
"@ethersproject/providers": ^5.7.2
"@ethersproject/wallet": ^5.7.0
"@imtbl/x-client": 0.0.0
- "@magic-ext/oidc": 4.2.0
+ "@magic-ext/oidc": 4.3.1
"@metamask/detect-provider": ^2.0.0
"@rollup/plugin-typescript": ^11.1.6
"@swc/core": ^1.3.36
@@ -4990,7 +4991,7 @@ __metadata:
"@imtbl/generated-clients": 0.0.0
"@imtbl/toolkit": 0.0.0
"@imtbl/x-client": 0.0.0
- "@magic-ext/oidc": 4.2.0
+ "@magic-ext/oidc": 4.3.1
"@metamask/detect-provider": ^2.0.0
"@rollup/plugin-typescript": ^11.1.6
"@swc/core": ^1.3.36
@@ -6231,6 +6232,13 @@ __metadata:
languageName: node
linkType: hard
+"@magic-ext/oidc@npm:4.3.1":
+ version: 4.3.1
+ resolution: "@magic-ext/oidc@npm:4.3.1"
+ checksum: 1eb1e2869b4acdb035b6e17244c835cd9a1c6d464ef666c827007e431da65c6fc7cd3e8c657b690f74ac01e4659336687aa336df57a315d5f34832721390b002
+ languageName: node
+ linkType: hard
+
"@magic-sdk/commons@npm:^17.2.0":
version: 17.2.0
resolution: "@magic-sdk/commons@npm:17.2.0"
@@ -21705,7 +21713,7 @@ __metadata:
languageName: node
linkType: hard
-"eslint@npm:^8":
+"eslint@npm:^8, eslint@npm:^8.40.0":
version: 8.57.0
resolution: "eslint@npm:8.57.0"
dependencies:
@@ -21753,7 +21761,7 @@ __metadata:
languageName: node
linkType: hard
-"eslint@npm:^8.3.0, eslint@npm:^8.40.0":
+"eslint@npm:^8.3.0":
version: 8.45.0
resolution: "eslint@npm:8.45.0"
dependencies:
From 50b953c68ae66507ff4ee1380620a87f877fba29 Mon Sep 17 00:00:00 2001
From: Nik <2661899+CodeSchwert@users.noreply.github.com>
Date: Thu, 8 Aug 2024 18:40:14 +1200
Subject: [PATCH 02/29] fix: x client missing response types (#2083)
---
.husky/pre-commit | 3 +
packages/x-client/src/IMXClient.ts | 171 ++++++++++++------
packages/x-client/src/types/api.ts | 45 ++++-
.../x-client/src/workflows/primarySales.ts | 6 +-
packages/x-client/src/workflows/workflows.ts | 6 +
5 files changed, 171 insertions(+), 60 deletions(-)
diff --git a/.husky/pre-commit b/.husky/pre-commit
index 5a182ef106..5571608bdd 100755
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -1,4 +1,7 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
+# prevent heap limit allocation errors
+export NODE_OPTIONS="--max-old-space-size=4096"
+
yarn lint-staged
diff --git a/packages/x-client/src/IMXClient.ts b/packages/x-client/src/IMXClient.ts
index 85971ccd09..cdef8f66f3 100644
--- a/packages/x-client/src/IMXClient.ts
+++ b/packages/x-client/src/IMXClient.ts
@@ -4,65 +4,108 @@ import {
ImxModuleConfiguration,
} from './config';
import { formatError } from './utils/formatError';
-import {
+import type {
AddMetadataSchemaToCollectionRequest,
+ Asset,
AssetsApi,
AssetsApiGetAssetRequest,
AssetsApiListAssetsRequest,
+ Balance,
BalancesApi,
BalancesApiGetBalanceRequest,
BalancesApiListBalancesRequest,
+ Collection,
+ CollectionFilter,
CollectionsApi,
CollectionsApiGetCollectionRequest,
CollectionsApiListCollectionFiltersRequest,
CollectionsApiListCollectionsRequest,
CreateCollectionRequest,
CreateMetadataRefreshRequest,
+ CreateMetadataRefreshResponse,
+ CreateTransferResponseV1,
+ CurrencyWithLimits,
+ Deposit,
DepositsApi,
DepositsApiGetDepositRequest,
DepositsApiListDepositsRequest,
EncodingApi,
EthSigner,
+ Exchange,
+ ExchangeCreateExchangeAndURLResponse,
ExchangesApi,
ExchangesApiCreateExchangeRequest,
ExchangesApiGetExchangeRequest,
ExchangesApiGetExchangesRequest,
- MintsApi,
- MintsApiGetMintRequest,
- MintsApiListMintsRequest,
+ GetMetadataRefreshErrorsResponse,
+ GetMetadataRefreshes,
+ GetMetadataRefreshResponse,
+ GetTransactionsResponse,
+ GetUsersApiResponse,
+ ListAssetsResponse,
+ ListBalancesResponse,
+ ListCollectionsResponse,
+ ListDepositsResponse,
+ ListMintsResponse,
+ ListOrdersResponseV3,
+ ListTokensResponse,
+ ListTradesResponse,
+ ListTransfersResponse,
+ ListWithdrawalsResponse,
MetadataApi,
MetadataApiGetMetadataSchemaRequest,
MetadataRefreshesApi,
+ MetadataSchemaProperty,
MetadataSchemaRequest,
+ Mint,
+ MintsApi,
+ MintsApiGetMintRequest,
+ MintsApiListMintsRequest,
+ MintTokensResponse,
NftCheckoutPrimaryApi,
NftCheckoutPrimaryApiCreateNftPrimaryRequest,
NftCheckoutPrimaryApiGetCurrenciesNFTCheckoutPrimaryRequest,
NftCheckoutPrimaryApiGetNftPrimaryTransactionRequest,
NftCheckoutPrimaryApiGetNftPrimaryTransactionsRequest,
+ NftprimarytransactionCreateResponse,
+ NftprimarytransactionGetResponse,
+ NftprimarytransactionListTransactionsResponse,
OrdersApi,
OrdersApiGetOrderV3Request,
OrdersApiListOrdersV3Request,
+ OrderV3,
PrimarySalesApi,
PrimarySalesApiSignableCreatePrimarySaleRequest,
+ Project,
ProjectsApi,
+ SuccessResponse,
+ TokenDetails,
TokensApi,
TokensApiGetTokenRequest,
TokensApiListTokensRequest,
+ Trade,
TradesApi,
TradesApiGetTradeV3Request,
TradesApiListTradesV3Request,
+ Transfer,
TransfersApi,
TransfersApiGetTransferRequest,
TransfersApiListTransfersRequest,
- UpdateCollectionRequest,
- UnsignedMintRequest,
- WalletConnection,
UnsignedExchangeTransferRequest,
+ UnsignedMintRequest,
+ UpdateCollectionRequest,
UsersApi,
+ WalletConnection,
+ Withdrawal,
WithdrawalsApi,
WithdrawalsApiGetWithdrawalRequest,
WithdrawalsApiListWithdrawalsRequest,
} from './types';
+import type {
+ AcceptPrimarySaleResponse,
+ CreatePrimarySaleResponse,
+ RejectPrimarySaleResponse,
+} from './workflows';
import { Workflows } from './workflows';
export class IMXClient {
@@ -147,7 +190,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested Deposit
* @throws {@link IMXError}
*/
- public getDeposit(request: DepositsApiGetDepositRequest) {
+ public getDeposit(request: DepositsApiGetDepositRequest): Promise {
return this.depositsApi
.getDeposit(request)
.then((res) => res.data)
@@ -162,7 +205,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested list of Deposits
* @throws {@link IMXError}
*/
- public listDeposits(request?: DepositsApiListDepositsRequest) {
+ public listDeposits(request?: DepositsApiListDepositsRequest): Promise {
return this.depositsApi
.listDeposits(request)
.then((res) => res.data)
@@ -177,7 +220,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested User
* @throws {@link IMXError}
*/
- public getUser(ethAddress: string) {
+ public getUser(ethAddress: string): Promise {
return this.usersApi
.getUsers({ user: ethAddress })
.then((res) => res.data)
@@ -192,7 +235,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested Asset
* @throws {@link IMXError}
*/
- public getAsset(request: AssetsApiGetAssetRequest) {
+ public getAsset(request: AssetsApiGetAssetRequest): Promise {
return this.assetApi
.getAsset(request)
.then((res) => res.data)
@@ -207,7 +250,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested list of Assets
* @throws {@link IMXError}
*/
- public listAssets(request?: AssetsApiListAssetsRequest) {
+ public listAssets(request?: AssetsApiListAssetsRequest): Promise {
return this.assetApi
.listAssets(request)
.then((res) => res.data)
@@ -226,7 +269,7 @@ export class IMXClient {
public createCollection(
ethSigner: EthSigner,
request: CreateCollectionRequest,
- ) {
+ ): Promise {
return this.workflows
.createCollection(ethSigner, request)
.then((res) => res.data)
@@ -241,7 +284,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested Collection
* @throws {@link IMXError}
*/
- public getCollection(request: CollectionsApiGetCollectionRequest) {
+ public getCollection(request: CollectionsApiGetCollectionRequest): Promise {
return this.collectionApi
.getCollection(request)
.then((res) => res.data)
@@ -258,7 +301,7 @@ export class IMXClient {
*/
public listCollectionFilters(
request: CollectionsApiListCollectionFiltersRequest,
- ) {
+ ): Promise {
return this.collectionApi
.listCollectionFilters(request)
.then((res) => res.data)
@@ -273,7 +316,9 @@ export class IMXClient {
* @returns a promise that resolves with the requested list of Collections
* @throws {@link IMXError}
*/
- public listCollections(request?: CollectionsApiListCollectionsRequest) {
+ public listCollections(
+ request?: CollectionsApiListCollectionsRequest,
+ ): Promise {
return this.collectionApi
.listCollections(request)
.then((res) => res.data)
@@ -294,7 +339,7 @@ export class IMXClient {
ethSigner: EthSigner,
collectionAddress: string,
request: UpdateCollectionRequest,
- ) {
+ ): Promise {
return this.workflows
.updateCollection(ethSigner, collectionAddress, request)
.then((res) => res.data)
@@ -315,7 +360,7 @@ export class IMXClient {
ethSigner: EthSigner,
collectionAddress: string,
request: AddMetadataSchemaToCollectionRequest,
- ) {
+ ): Promise {
return this.workflows
.addMetadataSchemaToCollection(ethSigner, collectionAddress, request)
.then((res) => res.data)
@@ -330,7 +375,9 @@ export class IMXClient {
* @returns a promise that resolves with the requested Metadata schema
* @throws {@link IMXError}
*/
- public getMetadataSchema(request: MetadataApiGetMetadataSchemaRequest) {
+ public getMetadataSchema(
+ request: MetadataApiGetMetadataSchemaRequest,
+ ): Promise {
return this.metadataApi
.getMetadataSchema(request)
.then((res) => res.data)
@@ -345,7 +392,7 @@ export class IMXClient {
* @param collectionAddress - the Collection contract address
* @param name - the Metadata schema name
* @param request - the request object containing the parameters to be provided in the API request
- * @returns a promise that resolves with the SuccessResponse if successful
+ * @returns a promise that resolves with the {@link SuccessResponse}
* @throws {@link IMXError}
*/
public updateMetadataSchemaByName(
@@ -353,7 +400,7 @@ export class IMXClient {
collectionAddress: string,
name: string,
request: MetadataSchemaRequest,
- ) {
+ ): Promise {
return this.workflows
.updateMetadataSchemaByName(ethSigner, collectionAddress, name, request)
.then((res) => res.data)
@@ -376,7 +423,7 @@ export class IMXClient {
collectionAddress?: string,
pageSize?: number,
cursor?: string,
- ) {
+ ): Promise {
return this.workflows
.listMetadataRefreshes(ethSigner, collectionAddress, pageSize, cursor)
.then((res) => res.data)
@@ -399,7 +446,7 @@ export class IMXClient {
refreshId: string,
pageSize?: number,
cursor?: string,
- ) {
+ ): Promise {
return this.workflows
.getMetadataRefreshErrors(ethSigner, refreshId, pageSize, cursor)
.then((res) => res.data)
@@ -415,7 +462,10 @@ export class IMXClient {
* @returns a promise that resolves with the requested metadata refresh results
* @throws {@link IMXError}
*/
- public getMetadataRefreshResults(ethSigner: EthSigner, refreshId: string) {
+ public getMetadataRefreshResults(
+ ethSigner: EthSigner,
+ refreshId: string,
+ ): Promise {
return this.workflows
.getMetadataRefreshResults(ethSigner, refreshId)
.then((res) => res.data)
@@ -434,7 +484,7 @@ export class IMXClient {
public createMetadataRefresh(
ethSigner: EthSigner,
request: CreateMetadataRefreshRequest,
- ) {
+ ): Promise {
return this.workflows
.createMetadataRefresh(ethSigner, request)
.then((res) => res.data)
@@ -450,7 +500,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested Project
* @throws {@link IMXError}
*/
- public async getProject(ethSigner: EthSigner, id: string) {
+ public async getProject(ethSigner: EthSigner, id: string): Promise {
return this.workflows
.getProject(ethSigner, id)
.then((res) => res.data)
@@ -465,7 +515,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested Balance
* @throws {@link IMXError}
*/
- public getBalance(request: BalancesApiGetBalanceRequest) {
+ public getBalance(request: BalancesApiGetBalanceRequest): Promise {
return this.balanceApi
.getBalance(request)
.then((res) => res.data)
@@ -480,7 +530,9 @@ export class IMXClient {
* @returns a promise that resolves with the requested list of Balances
* @throws {@link IMXError}
*/
- public listBalances(request: BalancesApiListBalancesRequest) {
+ public listBalances(
+ request: BalancesApiListBalancesRequest,
+ ): Promise {
return this.balanceApi
.listBalances(request)
.then((res) => res.data)
@@ -495,7 +547,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested Mint
* @throws {@link IMXError}
*/
- public getMint(request: MintsApiGetMintRequest) {
+ public getMint(request: MintsApiGetMintRequest): Promise {
return this.mintsApi
.getMint(request)
.then((res) => res.data)
@@ -510,7 +562,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested list of Mints
* @throws {@link IMXError}
*/
- public listMints(request?: MintsApiListMintsRequest) {
+ public listMints(request?: MintsApiListMintsRequest): Promise {
return this.mintsApi
.listMints(request)
.then((res) => res.data)
@@ -526,7 +578,10 @@ export class IMXClient {
* @returns a promise that resolves with the minted tokens
* @throws {@link IMXError}
*/
- public mint(ethSigner: EthSigner, request: UnsignedMintRequest) {
+ public mint(
+ ethSigner: EthSigner,
+ request: UnsignedMintRequest,
+ ): Promise {
return this.workflows.mint(ethSigner, request);
}
@@ -536,7 +591,9 @@ export class IMXClient {
* @returns a promise that resolves with the requested list of Withdrawals
* @throws {@link IMXError}
*/
- public listWithdrawals(request?: WithdrawalsApiListWithdrawalsRequest) {
+ public listWithdrawals(
+ request?: WithdrawalsApiListWithdrawalsRequest,
+ ): Promise {
return this.withdrawalsApi
.listWithdrawals(request)
.then((res) => res.data)
@@ -551,7 +608,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested Withdrawal
* @throws {@link IMXError}
*/
- public getWithdrawal(request: WithdrawalsApiGetWithdrawalRequest) {
+ public getWithdrawal(request: WithdrawalsApiGetWithdrawalRequest): Promise {
return this.withdrawalsApi
.getWithdrawal(request)
.then((res) => res.data)
@@ -566,7 +623,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested Order
* @throws {@link IMXError}
*/
- public getOrder(request: OrdersApiGetOrderV3Request) {
+ public getOrder(request: OrdersApiGetOrderV3Request): Promise {
return this.ordersApi
.getOrderV3(request)
.then((res) => res.data)
@@ -581,7 +638,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested list of Orders
* @throws {@link IMXError}
*/
- public listOrders(request?: OrdersApiListOrdersV3Request) {
+ public listOrders(request?: OrdersApiListOrdersV3Request): Promise {
return this.ordersApi
.listOrdersV3(request)
.then((res) => res.data)
@@ -596,7 +653,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested Trade
* @throws {@link IMXError}
*/
- public getTrade(request: TradesApiGetTradeV3Request) {
+ public getTrade(request: TradesApiGetTradeV3Request): Promise {
return this.tradesApi
.getTradeV3(request)
.then((res) => res.data)
@@ -611,7 +668,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested list of Trades
* @throws {@link IMXError}
*/
- public listTrades(request?: TradesApiListTradesV3Request) {
+ public listTrades(request?: TradesApiListTradesV3Request): Promise {
return this.tradesApi
.listTradesV3(request)
.then((res) => res.data)
@@ -626,7 +683,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested Token
* @throws {@link IMXError}
*/
- public getToken(request: TokensApiGetTokenRequest) {
+ public getToken(request: TokensApiGetTokenRequest): Promise {
return this.tokensApi
.getToken(request)
.then((res) => res.data)
@@ -641,7 +698,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested list of Tokens
* @throws {@link IMXError}
*/
- public listTokens(request?: TokensApiListTokensRequest) {
+ public listTokens(request?: TokensApiListTokensRequest): Promise {
return this.tokensApi
.listTokens(request)
.then((res) => res.data)
@@ -656,7 +713,7 @@ export class IMXClient {
* @returns a promise that resolves with the requested Transfer
* @throws {@link IMXError}
*/
- public getTransfer(request: TransfersApiGetTransferRequest) {
+ public getTransfer(request: TransfersApiGetTransferRequest): Promise {
return this.transfersApi
.getTransfer(request)
.then((res) => res.data)
@@ -671,7 +728,9 @@ export class IMXClient {
* @returns a promise that resolves with the requested list of Transfers
* @throws {@link IMXError}
*/
- public listTransfers(request?: TransfersApiListTransfersRequest) {
+ public listTransfers(
+ request?: TransfersApiListTransfersRequest,
+ ): Promise {
return this.transfersApi
.listTransfers(request)
.then((res) => res.data)
@@ -686,7 +745,9 @@ export class IMXClient {
* @returns a promise that resolves with the created Exchange Transaction
* @throws {@link IMXError}
*/
- public createExchange(request: ExchangesApiCreateExchangeRequest) {
+ public createExchange(
+ request: ExchangesApiCreateExchangeRequest,
+ ): Promise {
return this.exchangeApi.createExchange(request)
.then((res) => res.data)
.catch((err) => {
@@ -700,7 +761,7 @@ export class IMXClient {
* @returns a promise that resolves with the Exchange Transaction
* @throws {@link IMXError}
*/
- public getExchange(request: ExchangesApiGetExchangeRequest) {
+ public getExchange(request: ExchangesApiGetExchangeRequest): Promise {
return this.exchangeApi.getExchange(request)
.then((res) => res.data)
.catch((err) => {
@@ -714,7 +775,7 @@ export class IMXClient {
* @returns a promise that resolves with Exchange Transactions
* @throws {@link IMXError}
*/
- public getExchanges(request: ExchangesApiGetExchangesRequest) {
+ public getExchanges(request: ExchangesApiGetExchangesRequest): Promise {
return this.exchangeApi.getExchanges(request)
.then((res) => res.data)
.catch((err) => {
@@ -732,7 +793,7 @@ export class IMXClient {
public exchangeTransfer(
walletConnection: WalletConnection,
request: UnsignedExchangeTransferRequest,
- ) {
+ ): Promise {
return this.workflows.exchangeTransfer(walletConnection, request);
}
@@ -744,7 +805,7 @@ export class IMXClient {
*/
public createNftPrimary(
request: NftCheckoutPrimaryApiCreateNftPrimaryRequest,
- ) {
+ ): Promise {
return this.nftCheckoutPrimaryApi.createNftPrimary(request)
.then((res) => res.data)
.catch((err) => {
@@ -760,7 +821,7 @@ export class IMXClient {
*/
public getCurrenciesNFTCheckoutPrimary(
request: NftCheckoutPrimaryApiGetCurrenciesNFTCheckoutPrimaryRequest,
- ) {
+ ): Promise {
return this.nftCheckoutPrimaryApi
.getCurrenciesNFTCheckoutPrimary(request)
.then((res) => res.data)
@@ -777,7 +838,7 @@ export class IMXClient {
*/
public getNftPrimaryTransaction(
request: NftCheckoutPrimaryApiGetNftPrimaryTransactionRequest,
- ) {
+ ): Promise {
return this.nftCheckoutPrimaryApi
.getNftPrimaryTransaction(request)
.then((res) => res.data)
@@ -794,7 +855,7 @@ export class IMXClient {
*/
public getNftPrimaryTransactions(
request: NftCheckoutPrimaryApiGetNftPrimaryTransactionsRequest,
- ) {
+ ): Promise {
return this.nftCheckoutPrimaryApi
.getNftPrimaryTransactions(request)
.then((res) => res.data)
@@ -813,7 +874,7 @@ export class IMXClient {
public createPrimarySale(
walletConnection: WalletConnection,
request: PrimarySalesApiSignableCreatePrimarySaleRequest,
- ) {
+ ): Promise {
return this.workflows
.createPrimarySale(walletConnection, request)
.catch((err) => {
@@ -828,7 +889,10 @@ export class IMXClient {
* @returns a promise that resolves with the created Trade
* @throws {@link IMXError}
*/
- public acceptPrimarySale(ethSigner: EthSigner, primarySaleId: number) {
+ public acceptPrimarySale(
+ ethSigner: EthSigner,
+ primarySaleId: number,
+ ): Promise {
return this.workflows
.acceptPrimarySale(ethSigner, primarySaleId)
.catch((err) => {
@@ -843,7 +907,10 @@ export class IMXClient {
* @returns a promise that resolves with the rejected PrimarySale
* @throws {@link IMXError}
*/
- public rejectPrimarySale(ethSigner: EthSigner, primarySaleId: number) {
+ public rejectPrimarySale(
+ ethSigner: EthSigner,
+ primarySaleId: number,
+ ): Promise {
return this.workflows
.rejectPrimarySale(ethSigner, primarySaleId)
.catch((err) => {
diff --git a/packages/x-client/src/types/api.ts b/packages/x-client/src/types/api.ts
index 669119d3f5..2c7a7eecad 100644
--- a/packages/x-client/src/types/api.ts
+++ b/packages/x-client/src/types/api.ts
@@ -28,24 +28,28 @@ export class TransfersApi extends imx.TransfersApi {}
export class UsersApi extends imx.UsersApi {}
export class WithdrawalsApi extends imx.WithdrawalsApi {}
-export interface APIError extends imx.APIError {}
export interface AcceptPrimarySaleBadRequestBody extends imx.AcceptPrimarySaleBadRequestBody {}
export interface AcceptPrimarySaleForbiddenBody extends imx.AcceptPrimarySaleForbiddenBody {}
export interface AcceptPrimarySaleNotFoundBody extends imx.AcceptPrimarySaleNotFoundBody {}
export interface AcceptPrimarySaleOKBody extends imx.AcceptPrimarySaleOKBody {}
export interface AcceptPrimarySaleUnauthorizedBody extends imx.AcceptPrimarySaleUnauthorizedBody {}
export interface AddMetadataSchemaToCollectionRequest extends imx.AddMetadataSchemaToCollectionRequest {}
+export interface APIError extends imx.APIError {}
+export interface Asset extends imx.Asset {}
export interface AssetsApiGetAssetRequest extends imx.AssetsApiGetAssetRequest {}
export interface AssetsApiListAssetsRequest extends imx.AssetsApiListAssetsRequest {}
export interface Balance extends imx.Balance {}
export interface BalancesApiGetBalanceRequest extends imx.BalancesApiGetBalanceRequest {}
export interface BalancesApiListBalancesRequest extends imx.BalancesApiListBalancesRequest {}
export interface CancelOrderResponse extends imx.CancelOrderResponse {}
+export interface Collection extends imx.Collection {}
+export interface CollectionFilter extends imx.CollectionFilter {}
export interface CollectionsApiGetCollectionRequest extends imx.CollectionsApiGetCollectionRequest {}
export interface CollectionsApiListCollectionFiltersRequest extends imx.CollectionsApiListCollectionFiltersRequest {}
export interface CollectionsApiListCollectionsRequest extends imx.CollectionsApiListCollectionsRequest {}
export interface CreateCollectionRequest extends imx.CreateCollectionRequest {}
export interface CreateMetadataRefreshRequest extends imx.CreateMetadataRefreshRequest {}
+export interface CreateMetadataRefreshResponse extends imx.CreateMetadataRefreshResponse {}
export interface CreateOrderResponse extends imx.CreateOrderResponse {}
export interface CreatePrimarySaleBadRequestBody extends imx.CreatePrimarySaleBadRequestBody {}
export interface CreatePrimarySaleCreatedBody extends imx.CreatePrimarySaleCreatedBody {}
@@ -55,47 +59,78 @@ export interface CreatePrimarySaleUnauthorizedBody extends imx.CreatePrimarySale
export interface CreateTradeResponse extends imx.CreateTradeResponse {}
export interface CreateTransferResponseV1 extends imx.CreateTransferResponseV1 {}
export interface CreateWithdrawalResponse extends imx.CreateWithdrawalResponse {}
+export interface CurrencyWithLimits extends imx.CurrencyWithLimits {}
+export interface Deposit extends imx.Deposit {}
export interface DepositsApiGetDepositRequest extends imx.DepositsApiGetDepositRequest {}
export interface DepositsApiListDepositsRequest extends imx.DepositsApiListDepositsRequest {}
+export interface Exchange extends imx.Exchange {}
+export interface ExchangeCreateExchangeAndURLResponse extends imx.ExchangeCreateExchangeAndURLResponse {}
export interface ExchangesApiCreateExchangeRequest extends imx.ExchangesApiCreateExchangeRequest {}
export interface ExchangesApiGetExchangeRequest extends imx.ExchangesApiGetExchangeRequest {}
export interface ExchangesApiGetExchangesRequest extends imx.ExchangesApiGetExchangesRequest {}
+export interface GetMetadataRefreshes extends imx.GetMetadataRefreshes {}
+export interface GetMetadataRefreshErrorsResponse extends imx.GetMetadataRefreshErrorsResponse {}
+export interface GetMetadataRefreshResponse extends imx.GetMetadataRefreshResponse {}
export interface GetSignableCancelOrderRequest extends imx.GetSignableCancelOrderRequest {}
export interface GetSignableOrderRequest extends imx.GetSignableOrderRequest {}
export interface GetSignableTradeRequest extends imx.GetSignableTradeRequest {}
+export interface GetTransactionsResponse extends imx.GetTransactionsResponse {}
+export interface GetUsersApiResponse extends imx.GetUsersApiResponse {}
+export interface ListAssetsResponse extends imx.ListAssetsResponse {}
+export interface ListBalancesResponse extends imx.ListBalancesResponse {}
+export interface ListCollectionsResponse extends imx.ListCollectionsResponse {}
+export interface ListDepositsResponse extends imx.ListDepositsResponse {}
+export interface ListMintsResponse extends imx.ListMintsResponse {}
+export interface ListOrdersResponseV3 extends imx.ListOrdersResponseV3 {}
+export interface ListTokensResponse extends imx.ListTokensResponse {}
+export interface ListTradesResponse extends imx.ListTradesResponse {}
+export interface ListTransfersResponse extends imx.ListTransfersResponse {}
+export interface ListWithdrawalsResponse extends imx.ListWithdrawalsResponse {}
export interface MetadataApiGetMetadataSchemaRequest extends imx.MetadataApiGetMetadataSchemaRequest {}
+export interface MetadataSchemaProperty extends imx.MetadataSchemaProperty {}
export interface MetadataSchemaRequest extends imx.MetadataSchemaRequest {}
+export interface Mint extends imx.Mint {}
export interface MintFee extends imx.MintFee {}
-export interface MintResultDetails extends imx.MintResultDetails {}
export interface MintRequest extends imx.MintRequest {}
-export interface MintTokenDataV2 extends imx.MintTokenDataV2 {}
-export interface MintTokensResponse extends imx.MintTokensResponse {}
-export interface MintUser extends imx.MintUser {}
+export interface MintResultDetails extends imx.MintResultDetails {}
export interface MintsApiGetMintRequest extends imx.MintsApiGetMintRequest {}
export interface MintsApiListMintsRequest extends imx.MintsApiListMintsRequest {}
export interface MintsApiMintTokensRequest extends imx.MintsApiMintTokensRequest {}
+export interface MintTokenDataV2 extends imx.MintTokenDataV2 {}
+export interface MintTokensResponse extends imx.MintTokensResponse {}
+export interface MintUser extends imx.MintUser {}
export interface NftCheckoutPrimaryApiCreateNftPrimaryRequest extends imx.NftCheckoutPrimaryApiCreateNftPrimaryRequest {}
export interface NftCheckoutPrimaryApiGetCurrenciesNFTCheckoutPrimaryRequest extends imx.NftCheckoutPrimaryApiGetCurrenciesNFTCheckoutPrimaryRequest {}
export interface NftCheckoutPrimaryApiGetNftPrimaryTransactionRequest extends imx.NftCheckoutPrimaryApiGetNftPrimaryTransactionRequest {}
export interface NftCheckoutPrimaryApiGetNftPrimaryTransactionsRequest extends imx.NftCheckoutPrimaryApiGetNftPrimaryTransactionsRequest {}
+export interface NftprimarytransactionCreateResponse extends imx.NftprimarytransactionCreateResponse {}
+export interface NftprimarytransactionGetResponse extends imx.NftprimarytransactionGetResponse {}
+export interface NftprimarytransactionListTransactionsResponse extends imx.NftprimarytransactionListTransactionsResponse {}
export interface OrdersApiCreateOrderV3Request extends imx.OrdersApiCreateOrderV3Request {}
export interface OrdersApiGetOrderV3Request extends imx.OrdersApiGetOrderV3Request {}
export interface OrdersApiListOrdersV3Request extends imx.OrdersApiListOrdersV3Request {}
+export interface OrderV3 extends imx.OrderV3 {}
export interface PrimarySalesApiCreatePrimarySaleRequest extends imx.PrimarySalesApiCreatePrimarySaleRequest {}
export interface PrimarySalesApiSignableCreatePrimarySaleRequest extends imx.PrimarySalesApiSignableCreatePrimarySaleRequest {}
+export interface Project extends imx.Project {}
export interface RejectPrimarySaleBadRequestBody extends imx.RejectPrimarySaleBadRequestBody {}
export interface RejectPrimarySaleForbiddenBody extends imx.RejectPrimarySaleForbiddenBody {}
export interface RejectPrimarySaleNotFoundBody extends imx.RejectPrimarySaleNotFoundBody {}
export interface RejectPrimarySaleOKBody extends imx.RejectPrimarySaleOKBody {}
export interface RejectPrimarySaleUnauthorizedBody extends imx.RejectPrimarySaleUnauthorizedBody {}
export interface SignableToken extends imx.SignableToken {}
+export interface SuccessResponse extends imx.SuccessResponse {}
+export interface TokenDetails extends imx.TokenDetails {}
export interface TokensApiGetTokenRequest extends imx.TokensApiGetTokenRequest {}
export interface TokensApiListTokensRequest extends imx.TokensApiListTokensRequest {}
+export interface Trade extends imx.Trade {}
export interface TradesApiGetTradeV3Request extends imx.TradesApiGetTradeV3Request {}
export interface TradesApiListTradesV3Request extends imx.TradesApiListTradesV3Request {}
+export interface Transfer extends imx.Transfer {}
export interface TransfersApiGetTransferRequest extends imx.TransfersApiGetTransferRequest {}
export interface TransfersApiListTransfersRequest extends imx.TransfersApiListTransfersRequest {}
export interface UpdateCollectionRequest extends imx.UpdateCollectionRequest {}
+export interface Withdrawal extends imx.Withdrawal {}
export interface WithdrawalsApiGetWithdrawalRequest extends imx.WithdrawalsApiGetWithdrawalRequest {}
export interface WithdrawalsApiListWithdrawalsRequest extends imx.WithdrawalsApiListWithdrawalsRequest {}
diff --git a/packages/x-client/src/workflows/primarySales.ts b/packages/x-client/src/workflows/primarySales.ts
index 406dfcf52c..c9c826ac2a 100644
--- a/packages/x-client/src/workflows/primarySales.ts
+++ b/packages/x-client/src/workflows/primarySales.ts
@@ -39,21 +39,21 @@ type RejectPrimarySaleWorkflowParams = {
primarySalesApi: PrimarySalesApi;
};
-type CreatePrimarySaleResponse =
+export type CreatePrimarySaleResponse =
| CreatePrimarySaleBadRequestBody
| CreatePrimarySaleCreatedBody
| CreatePrimarySaleForbiddenBody
| CreatePrimarySaleUnauthorizedBody
| CreatePrimarySaleNotFoundBody;
-type AcceptPrimarySaleResponse =
+export type AcceptPrimarySaleResponse =
| AcceptPrimarySaleOKBody
| AcceptPrimarySaleBadRequestBody
| AcceptPrimarySaleForbiddenBody
| AcceptPrimarySaleNotFoundBody
| AcceptPrimarySaleUnauthorizedBody;
-type RejectPrimarySaleResponse =
+export type RejectPrimarySaleResponse =
| RejectPrimarySaleOKBody
| RejectPrimarySaleBadRequestBody
| RejectPrimarySaleForbiddenBody
diff --git a/packages/x-client/src/workflows/workflows.ts b/packages/x-client/src/workflows/workflows.ts
index f7ea821e70..7d44bd15df 100644
--- a/packages/x-client/src/workflows/workflows.ts
+++ b/packages/x-client/src/workflows/workflows.ts
@@ -32,6 +32,12 @@ import {
RejectPrimarySalesWorkflow,
} from './primarySales';
+export type {
+ AcceptPrimarySaleResponse,
+ CreatePrimarySaleResponse,
+ RejectPrimarySaleResponse,
+} from './primarySales';
+
export class Workflows {
private readonly mintsApi: MintsApi;
From dab5b30537a7632ebb90e8afbf8378048778471e Mon Sep 17 00:00:00 2001
From: zaidarain1
Date: Fri, 9 Aug 2024 15:32:17 +1000
Subject: [PATCH 03/29] fix: [DX-3092] Use rollup build instead of swc d for
watch mode (#2085)
---
.eslintrc | 2 +-
build-dependents.js | 2 +-
dev.sh | 2 +-
examples/passport/identity-with-nextjs/.eslintrc.json | 1 +
examples/passport/next-connect-kit/.eslintrc.json | 1 +
examples/passport/next-rainbow-kit/.eslintrc.json | 1 +
examples/passport/next-wagmi/.eslintrc.json | 1 +
examples/passport/next-web3-modal/.eslintrc.json | 1 +
examples/passport/wallets-connect-with-nextjs/.eslintrc.json | 1 +
examples/passport/wallets-signing-with-nextjs/.eslintrc.json | 1 +
.../passport/wallets-transactions-with-nextjs/.eslintrc.json | 1 +
11 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/.eslintrc b/.eslintrc
index 197e3b9049..d0f3978f40 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -13,7 +13,7 @@
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
- "project": "./tsconfig.json",
+ "project": "./tsconfig.base.json",
"tsconfigRootDir": "."
},
"rules": {
diff --git a/build-dependents.js b/build-dependents.js
index fb53b404a1..f61bf583d3 100755
--- a/build-dependents.js
+++ b/build-dependents.js
@@ -23,7 +23,7 @@ try {
if (isDependent || changedProject === currentProject) {
// Rebuild the current project
- const command = `nx run-many --target=d --projects=${currentProject} --parallel=5`;
+ const command = `nx run-many --target=build --projects=${currentProject} --parallel=5`;
console.log(`Running command: ${command}`);
execSync(command, { stdio: 'inherit' });
diff --git a/dev.sh b/dev.sh
index 44ad4a48d0..4c11ccb701 100755
--- a/dev.sh
+++ b/dev.sh
@@ -28,5 +28,5 @@ fi
# Run nx commands with the selected or provided package name
echo "Running commands for package: $PACKAGE_NAME"
-nx run $PACKAGE_NAME:d --parallel=5
+nx run $PACKAGE_NAME:build --parallel=5
nx watch --all -- node ./build-dependents.js \$NX_PROJECT_NAME $(echo $PACKAGE_NAME)
\ No newline at end of file
diff --git a/examples/passport/identity-with-nextjs/.eslintrc.json b/examples/passport/identity-with-nextjs/.eslintrc.json
index bffb357a71..a2569c2c7c 100644
--- a/examples/passport/identity-with-nextjs/.eslintrc.json
+++ b/examples/passport/identity-with-nextjs/.eslintrc.json
@@ -1,3 +1,4 @@
{
+ "root": true,
"extends": "next/core-web-vitals"
}
diff --git a/examples/passport/next-connect-kit/.eslintrc.json b/examples/passport/next-connect-kit/.eslintrc.json
index bffb357a71..a2569c2c7c 100644
--- a/examples/passport/next-connect-kit/.eslintrc.json
+++ b/examples/passport/next-connect-kit/.eslintrc.json
@@ -1,3 +1,4 @@
{
+ "root": true,
"extends": "next/core-web-vitals"
}
diff --git a/examples/passport/next-rainbow-kit/.eslintrc.json b/examples/passport/next-rainbow-kit/.eslintrc.json
index bffb357a71..a2569c2c7c 100644
--- a/examples/passport/next-rainbow-kit/.eslintrc.json
+++ b/examples/passport/next-rainbow-kit/.eslintrc.json
@@ -1,3 +1,4 @@
{
+ "root": true,
"extends": "next/core-web-vitals"
}
diff --git a/examples/passport/next-wagmi/.eslintrc.json b/examples/passport/next-wagmi/.eslintrc.json
index bffb357a71..a2569c2c7c 100644
--- a/examples/passport/next-wagmi/.eslintrc.json
+++ b/examples/passport/next-wagmi/.eslintrc.json
@@ -1,3 +1,4 @@
{
+ "root": true,
"extends": "next/core-web-vitals"
}
diff --git a/examples/passport/next-web3-modal/.eslintrc.json b/examples/passport/next-web3-modal/.eslintrc.json
index bffb357a71..a2569c2c7c 100644
--- a/examples/passport/next-web3-modal/.eslintrc.json
+++ b/examples/passport/next-web3-modal/.eslintrc.json
@@ -1,3 +1,4 @@
{
+ "root": true,
"extends": "next/core-web-vitals"
}
diff --git a/examples/passport/wallets-connect-with-nextjs/.eslintrc.json b/examples/passport/wallets-connect-with-nextjs/.eslintrc.json
index 6cb73ba8c6..e7564bddde 100644
--- a/examples/passport/wallets-connect-with-nextjs/.eslintrc.json
+++ b/examples/passport/wallets-connect-with-nextjs/.eslintrc.json
@@ -1,3 +1,4 @@
{
+ "root": true,
"extends": ["next/core-web-vitals", "next"]
}
diff --git a/examples/passport/wallets-signing-with-nextjs/.eslintrc.json b/examples/passport/wallets-signing-with-nextjs/.eslintrc.json
index 6cb73ba8c6..e7564bddde 100644
--- a/examples/passport/wallets-signing-with-nextjs/.eslintrc.json
+++ b/examples/passport/wallets-signing-with-nextjs/.eslintrc.json
@@ -1,3 +1,4 @@
{
+ "root": true,
"extends": ["next/core-web-vitals", "next"]
}
diff --git a/examples/passport/wallets-transactions-with-nextjs/.eslintrc.json b/examples/passport/wallets-transactions-with-nextjs/.eslintrc.json
index bffb357a71..a2569c2c7c 100644
--- a/examples/passport/wallets-transactions-with-nextjs/.eslintrc.json
+++ b/examples/passport/wallets-transactions-with-nextjs/.eslintrc.json
@@ -1,3 +1,4 @@
{
+ "root": true,
"extends": "next/core-web-vitals"
}
From 9a82d59c73b5caa504e7e5de2b2e685274053d05 Mon Sep 17 00:00:00 2001
From: "Craig M."
Date: Mon, 12 Aug 2024 12:40:37 +1200
Subject: [PATCH 04/29] docs: Examples/readme updates (#2084)
Co-authored-by: Matt Muscat
Co-authored-by: zaidarain1
---
examples/README.md | 353 +++++++++++++++++++++++++++++----------------
1 file changed, 231 insertions(+), 122 deletions(-)
diff --git a/examples/README.md b/examples/README.md
index f7d57ec1b4..139facd03b 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -1,15 +1,75 @@
-## Contribution Guidelines
+
+
+
+
-Important information on how to create examples, pull them through to the docs site and ensure they are covered by tests in the CI CD pipeline.
+
Immutable Code Examples
+
+ Immutable's code examples as used for the code snippets in the Immutable Docs
+
+ Explore the docs »
+
+
+
+
-## Example Scope
+**Table of Contents**
-When creating an example app it should contain only examples about one particular feature to prevent overloading the example. If there are multiple ways to use the feature then it is okay to include those in one sample app.
+- [Introduction](#introduction)
+- [Running examples locally](#running-examples-locally)
+- [Contribution guidelines](#contribution-guidelines)
+- [Adding examples](#adding-examples)
+- [End to end testing](#end-to-end-testing)
+- [Using code examples in the docs site](#using-code-examples-in-the-docs-site)
+
-For example;
+# Introduction
-the app in `examples/passport/wallets-connect-with-nextjs` show how to connect passport in the nextjs framework. It contains a default route that has links to each of the examples. Inside there are three routes, one for each way to connect (EIP-1193, EtherJS and Wagmi). These are okay to be part of one sample app since they show how to use one feature but using 3 different libraries.
+The example apps in this examples directory are compiled and tested as part of our CI CD pipeline. The goal of this is to ensure the examples found here are always able to run against the latest version of the Immutable Typescript SDK.
+
+Selected portions of code from these example apps are then displayed as code snippets in our docs site, which means our code snippets in the docs are inherently always accurate as well. How to include the code from here in the docs site is explained below.
+
+These example apps can also be used directly as a reference and run locally to test and develop with.
+
+# Running examples locally
+
+First you need to clone or fork the `ts-immutable-sdk` repo. The examples are a part of the root workspace and running yarn install from anywhere in the workspace will install the node modules required by the examples to the root `node_modules` directory. By default, the examples pull the latest sdk version from NPM instead of building the SDK locally.
+
+If you want to run the examples against your local build of the SDK instead, from the project root run;
+
+```bash
+yarn prepare:examples
+```
+
+and it will build the SDK first then use that build instead of what is on NPM. This is what our CI CD pipeline does to ensure it's compiling and testing the examples against the latest changes rather than what's already on NPM.
+
+Take a look at the README.md file of the example you want to run e.g. the [Passport Connect Readme](/examples/passport/wallets-connect-with-nextjs/README.md)
+
+This should include the steps required to run the example. Generally you will need to;
+
+1. Copy the `.env.example` file to `.env` and populate it with the environment variables as per the readme.
+1. Then `yarn install` and `yarn dev`
+
+And the app should be served on https://localhost:3000 unless otherwise stated in the example app.
+
+# Contribution guidelines
+
+This section explains some of the core concepts for how we want to structure the examples so they can be more easily digested in the docs and by our partners.
+
+The goal is to have easy to read, well commented examples that focus on showing how to use a singular feature without being overly long or complicated. They should not include overly opinionated framework implementations as it can make it unclear to the reader what is required and what is optional. They should be compilable and tested with e2e tests as much as is practical.
+
+In the long run we want these apps to run in a code blitz frame inside the docs site much like on the [Checkout Connect Widget](https://docs.immutable.com/products/zkEVM/checkout/widgets/connect#sample-code) docs page. So aim to create an example which can be runnable like this.
+
+We also want to eventually index these examples and serve them in a searchable and filterable page on the docs site, so feel free to add more examples here which are not necessarily used as code snippets in the docs site.
+
+## Examples scope
+
+When creating an example app it should contain only examples about one particular feature to prevent overloading the example. If there are multiple ways to use the feature then it is okay to include those in one example app.
+
+For example, the [Passport Connect with NextJS](/examples/passport/wallets-connect-with-nextjs) app shows how to connect passport in the NextJS framework.
+
+It contains a default route that has links to each of the examples. Inside there are three routes, one for each way to connect (EIP-1193, EtherJS and Wagmi). These are okay to be part of one example app since they show how to use one feature but using 3 different libraries.
If you want to show a different feature e.g signing with passport, you should create a new example app. Even though it also requires passport to connect you should not add the signing example to the connect example app.
@@ -44,20 +104,57 @@ examples
│ └── ...
```
-If you need to create a new example follow the steps below;
+# Adding examples
-## Creating a New Example
+Depending on the scope of the example you're trying to add, you may be able to add it to an existing example app, or you might have to create a new example app. If you're not sure, read the [Examples Scope](#examples-scope) section above to help you decide.
-create the nextjs project
+If you need to add a new example or add to an existing example, please follow the [Folder Structure](#folder-structure) guidelines above.
-```
+## Add to an existing example app
+
+The process may differ depending on how the example app is setup, but the recommendations we have made around creating a new example should follow the same structure as we've implemented for the [[Passport Connect with NextJS](/examples/passport/wallets-connect-with-nextjs) and [Passport Signing with NextJS](/examples/passport/wallets-signing-with-nextjs) examples.
+
+So if you need to add a new example to an existing example app you should create a branch in `ts-immutable-sdk` to add your example to and follow these steps;
+
+### Setup example in existing app
+
+1. Create new route folder inside the example app and add the `page.tsx` file.
+1. Add the new route you created to the app's home page
+1. Add any packages you require
+1. Add any environment variables your example requires to the `.env.example` file
+1. Add instructions in the `README.md` file about how to populate the `.env` file and any other build instructions.
+
+### Add your example
+
+Once you've done this you can go ahead and write your example code in the `page.tsx` file.
+
+You can run the example locally to test your code by following the steps in the [Running examples locally](#running-examples-locally) section.
+
+You will also need to create e2e tests for your example as covered in the [End to end testing](#end-to-end-testing) section.
+
+Creating code snippets in the docs site using your example code is covered in the [Using code examples in the docs site](#using-code-examples-in-the-docs-site) section.
+
+If your code example is going to be used as code snippets in the docs site, before merging your branch to main in `ts-immutable-sdk` you should follow the steps in [Using code examples in the docs site](#using-code-examples-in-the-docs-site). These steps help you to test the code snippets in the docs site before you merge your PR which avoids double handling and multiple pull requests across both repos.
+
+## Creating a new example app
+
+The process may differ if you're using a different Javascript Framework, but this assumes you will be creating a new example app using NextJS. These steps which were implemented to create the [Passport Connect](/examples/passport/wallets-connect-with-nextjs) example. It is a good reference point in terms of route structure and page layouts. If you need to copy code from there to help with your layouts then please go ahead.
+
+### Setup example app
+
+If you want to make a new NextJS app from scratch this is the process;
+
+Create a branch in `ts-immutable-sdk` to add your example to.
+
+In the console navigate to the product directory where your example will live (or create one if it doesn't exist). Then use `yarn dlx` to create the app.
+```bash
cd examples/
yarn dlx create-next-app@latest
```
-use the default options
-```
-✔ What is your project named? -with- e.g. wallets-with-nextjs
+use the default options;
+```bash
+✔ What is your project named? @examples//-with- e.g. @examples/passport/connect-with-nextjs
✔ Would you like to use TypeScript? … Yes
✔ Would you like to use ESLint? … Yes
✔ Would you like to use Tailwind CSS? … Yes
@@ -66,162 +163,85 @@ use the default options
✔ Would you like to customize the default import alias (@/*)? No
```
-install dependencies
+Install `@imtbl/sdk` and any other dependencies your example needs e.g.
-```
-yarn install
-```
-
-install `@imtbl/sdk` and any other dependencies your example needs e.g.
-
-```
+```bash
yarn add @imtbl/sdk
yarn add @ethersproject/providers@^5.7.2
```
-create a `.env.example` file in the root of the example. This will be committed to git so don't fill in the values
+Create a `.env.example` file in the root of the example. This will be committed to git so don't fill in the values
-add a template for any environment variables you need to the `.env.example` file e.g.
+Add a template for any environment variables you need to the `.env.example` file e.g.
-```
+```js
NEXT_PUBLIC_PUBLISHABLE_KEY=
NEXT_PUBLIC_CLIENT_ID=
```
-copy the `.env.example` file to `.env` in the root of the example. The `.env` file should be automatically ignored by git.
-
-populate any API keys and secrets e.g.
-
-```
-NEXT_PUBLIC_PUBLISHABLE_KEY="ABC"
-NEXT_PUBLIC_CLIENT_ID="XYZ"
-```
+Copy the `.env.example` file to `.env` in the root of the example (the `.env` file should be automatically ignored by git). Then populate any API keys and secrets you need to use in your application into the `.env` file.
-note: variables must be prefixed with `NEXT_PUBLIC_` to be piped into the browser env.
+Note: variables must be prefixed with `NEXT_PUBLIC_` to be piped into the browser env.
-Update the readme with any instructions required to run the app, and include what required env variables there are with any instructions on what to populate there.
+Update the readme with any instructions required to run the app, and include what required env variables there are with any instructions on what to populate there e.g.
-```
+```md
## Required Environment Variables
- NEXT_PUBLIC_PUBLISHABLE_KEY // replace with your publishable API key from Hub
- NEXT_PUBLIC_CLIENT_ID // replace with your client ID from Hub
```
-start the project with hot reloading
+Delete the any unused imports in `app/page.tsx`
-```
-yarn dev
-```
+Delete the contents of the return statement in `app/page.tsx` and replace with `
My Example` or whatever you like, just render something to the screen so you can tell its working when you run the app.
-check `http://localhost:3000/` in the browser to confirm it compiled and ran
+Start the project with hot reloading by running;
-delete the contents of `src/app/globals.css`
-
-delete the any unused imports in `src/app/page.tsx`
+```bash
+yarn dev
+```
-delete the contents of the return statement in `src/app/page.tsx` and replace with `<>>`
+Check `http://localhost:3000/` in the browser to confirm it compiled and ran
-update the title and description in `src/app/layout.tsx` to match the examples in your app e.g.
+Update the title and description in `app/layout.tsx` to match the examples in your app e.g.
-```
+```ts
export const metadata: Metadata = {
- title: "Passport Wallets Connect",
+ title: "Passport Connect",
description: "Examples of how to connect wallets to Passport with NextJS",
};
```
-create a home page for your example app with links to all the examples in `src/app/page.tsx`
-
-e.g. `examples/passport/wallets-connect-with-nextjs/src/app/page.tsx`
+Create a home page for your example app with links to all the examples in `src/app/page.tsx` e.g. [Passport Connect Home Page](/examples/passport/wallets-connect-with-nextjs/app/page.tsx)
-create a route for each example using the naming convention `-with-` e.g. `wallets-with-etherjs`
+Create a route for each example using the naming convention `-with-` e.g. `wallets-with-etherjs`
-start building your examplesin the `page.tsx` in each of your example's route folders
+### Add your example
-e.g. `examples/passport/wallets-connect-with-nextjs/src/app/connect-with-etherjs/page.tsx`
+Once you've done this you can go ahead and write your example code in the `page.tsx` file in your examples route.
+You can run the example locally to test your code by following the steps in the [Running examples locally](#running-examples-locally) section.
-## Creating Code Snippets
+You will also need to create e2e tests for your example as covered in the [End to end testing](#end-to-end-testing) section.
-In your examples find the parts of the code you want to use as code snippets and wrap them in the `#doc` and `#enddoc` comments while providing a unique label.
+Creating code snippets in the docs site using your example code is covered in the [Using code examples in the docs site](#using-code-examples-in-the-docs-site) section.
-Labels only have to be unique in the file, but they should be verbose so it makes it easy to know what they are e.g.
+If your code example is going to be used as code snippets in the docs site, before merging your branch to main in `ts-immutable-sdk` you should follow the steps in [Using code examples in the docs site](#using-code-examples-in-the-docs-site). These steps help you to test the code snippets in the docs site before you merge your PR which avoids double handling and multiple pull requests across both repos.
-e.g. `-----`
-
-```
-// #doc passport-wallets-nextjs-connect-eip1193-create
-const passportProvider = passportInstance.connectEvm()
-// #enddoc passport-wallets-nextjs-connect-eip1193-create
-```
-
-## Using Code Snippets in the Docs site
-
-It's very simple, you just add a code block with the reference to the file you want to display e.g.
-
-````
-```js reference=examples/passport/wallets-connect-with-nextjs/src/app/connect-with-etherjs/page.tsx title="Connect Passport to Immutable zkEVM and create the Provider"
-```
-````
-
-Or if you only want to display part of the file, add the `#` label of the snippet you want to display e.g.
-
-````
-```js reference=examples/passport/wallets-connect-with-nextjs/src/app/connect-with-etherjs/page.tsx#passport-wallets-nextjs-connect-etherjs-create title="Connect Passport to Immutable zkEVM and create the Provider"
-```
-````
-
-All snippets should have a title, usually this can just be the file name the snippet comes from. Don't be shy adding extra context before or after the snippet explaining any key points which are necessary.
-
-## Development process
-
-Since the docs site by default is pulling the code examples from the main branch of `ts-immutable-sdk` they will not be available until they are merged. To get around this and view the snippets in the docs site before you merge the example to main you can point the docs site to use the branch you are working on in the sdk repo while you work on them.
-
-Create a branch for your example in `ts-immutable-sdk` repo and a branch for your code snippets in `docs` repo.
-
-Create your example in your `ts-immutable-sdk` branch and push it up to GitHub.
-
-In your `docs` branch modify the file `/src/remark/import-code.mjs`
-
-Update the `BRANCH` constant from `main` to your branch name e.g.
-
-```
-const BRANCH = 'DVR-193-passport-signing-example';
-```
-
-Now your docs branch will be pulling the code examples from your branch in `ts-immutable-sdk` and you can use them locally in your `docs` branch to make sure they make sense in the page.
-
-Once you're happy with your examples, make the PR for your `ts-immutable-sdk` and get it merged into main.
-
-Then change the `BRANCH` constant back to `main` in the `/src/remark/import-code.mjs` file.
-
-Now your examples are merged they will appear locally in your `docs` branch from main on `ts-immutable-sdk` and you can make any other updates you need to give the code examples context in the docs site.
-
-Create your PR for your `docs` branch and get it merged into main.
-
-### WARNING
-
-Do **NOT** merge your `docs` branch to main without pointing the code import back to the main branch on `ts-immutable-sdk` or it will break things when the branch is deleted and new code examples merged to main will not show in the docs site.
-
-
-## Comments
-
-All examples should be heavily commented and the comments should make sense in the context the snippet is appearing in the docs site.
-
-## Tests
+# End to end testing
All examples should be covered by basic e2e tests to ensure they at least render the examples. Ideally they would also have e2e tests that prove the functionality that you're trying to show works. Depending on what you're doing in the examples, it may be difficult to e2e test certain things e.g. logging in with Passport. For this reason, testing of functionality with e2e testing is recommended if practical, but not required.
Install `@playwright/test` as a dev dependency for the e2e tests.
-```
+```bash
yarn add -D @playwright/test
```
Create a `playwright.config.ts` file in the root of the example app and add this configuration;
-```
+```ts
import { defineConfig, devices } from "@playwright/test";
export default defineConfig({
@@ -258,12 +278,101 @@ Make sure you update the localhost urls `http://localhost:3000` in the above exa
Create a `tests` directory in the root of the example app and start adding tests.
-Example of the base level of testing required can be found in `/examples/passport/wallets-signing-with-nextjs/tests/base.spec.ts`
+Example of the base level of testing required can be found in the [Passport Connect e2e Tests](/examples/passport/wallets-connect-with-nextjs/tests/base.spec.ts) spec file.
Add the test runner to the scripts in your package.json
-```
+```json
"test": "playwright test"
```
Run your tests with `yarn test`
+
+# Using code examples in the docs site
+
+Creating and using code snippets is relatively straight forward. You can pull in a whole file or by adding some comments you can pull in just a particular few lines of a file as necessary.
+
+To streamline the PR process, you should create a branch in the `docs` repo to add your code snippets before your branch for the code example in `ts-immutable-sdk` is merged to main. This way we can point the docs site to your branch for the code snippets and you can see your code example in situ and make any changes required to your code example before going through the PR process.
+
+## Update import code branch
+
+In your `docs` branch modify the file `/src/remark/import-code.mjs` and update the `BRANCH` constant from `main` to the name of your branch on `ts-immutable-sdk` e.g.
+
+```ts
+const BRANCH = 'DVR-193-passport-signing-example';
+```
+
+Now your `docs` branch will be pulling the code examples from your branch in `ts-immutable-sdk` and you can use them locally in your `docs` branch to make sure they make sense in the page.
+
+⚠️ ⚠️ ⚠️ **IMPORTANT** ⚠️ ⚠️ ⚠️
+
+Make sure to change the branch back to `main` before merging your `docs` branch or it will **BREAK** the docs site.
+
+## Creating code snippets
+
+In your code examples in `ts-immutable-sdk` find the parts of the code you want to use as code snippets and wrap them in the `#doc` and `#enddoc` comments while providing a label.
+
+Labels have to be unique within a file so you should use a simple naming convention to avoid clashes within the file e.g.
+
+e.g. `-`
+
+```ts
+// #doc eip1193-create
+const passportProvider = passportInstance.connectEvm()
+// #enddoc eip1193-create
+```
+
+Make sure to commit and push the labels to your `ts-immutable-sdk` branch on GitHub so they can be pulled down into your `docs` local build from there.
+
+## Using code snippets
+
+It's very simple to use the code snippet in the docs site, you just add a code block with the reference to the file and the `#` of the label you want to display e.g.
+
+````md
+```tsx reference=examples/passport/wallets-connect-with-nextjs/src/app/connect-with-eip1193/page.tsx#eip1193-create title="Create the Passport Provider"
+```
+````
+Or if you want to display the whole file just don't include a `#` label at the end of the file reference e.g.
+
+````md
+```tsx reference=examples/passport/wallets-connect-with-nextjs/src/app/connect-with-eip1193/page.tsx title="Create the Passport Provider"
+```
+````
+
+Just like regular code snippets, you can set language for syntax highlighting by adding it's alias directly after the opening backticks. In the above example we are setting the syntax highlighting to be for `tsx`. For more information on syntax highlighting, visit the [GitHub Documentation](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks).
+
+Some popular syntaxes you are likely to want to use syntax highlighting for are;
+
+| Language | Alias |
+|------------|-------------|
+| Javascript | js |
+| Typescript | ts |
+| Typescript with JSX | tsx
+| Solidity | solidity |
+| C# | csharp |
+| C++ | cpp |
+
+For the full list of supported syntaxes and their aliases [Linguist's languages YAML file](https://github.com/github-linguist/linguist/blob/master/lib/linguist/languages.yml).
+
+
+The other available parameters are;
+
+| parameter | type | description |
+|------------|---------|-------------|
+| reference | string | the location of the code example file in the `ts-immutable-sdk` with optional `#` label of the snippet |
+| title | string | the title that will appear above the code snippet block in the docs website |
+| githubLink | boolean | true by default, set to false to hide the link to file on GitHub in the header |
+
+Make sure the language and parameters are all set on the first line of the code snippet otherwise it will display the text as a regular inline code snippet.
+
+## Finishing up
+
+Once you're happy with your code examples on `ts-immutable-sdk` and you've tried them locally in the `docs` site from your branch on Github. Create a PR for your code examples branch in `ts-immutable-sdk` and get it merged to main.
+
+Now in your `docs` branch change the `BRANCH` constant in the `/src/remark/import-code.mjs` file from your branch name, back to `main`.
+
+You can now double check the code snippets in your `docs` branch are all pulling through correctly from main on `ts-immutable-sdk` and create the PR for your `docs` branch.
+
+Once your `docs` PR is merged, Netlify should automatically build and deploy the docs site. If your updates are not reflected on the docs site within 10 minutes of the PR being merged, it's likely the build has failed in Netlify. Because we are now pulling in content dynamically for the code snippets, the GET requests to fetch the code examples can sometimes randomly timeout which fails the build.
+
+If this happens you will need to log into the Netlify site, check the error and retry the build. Usually this will fix the deployment issue, otherwise follow up on the error message shown by Netlify.
\ No newline at end of file
From 58d312fb55f790eaadb4b1ab33998375ed99ae15 Mon Sep 17 00:00:00 2001
From: Naveen <116692862+naveen-imtb@users.noreply.github.com>
Date: Tue, 13 Aug 2024 11:28:36 +1000
Subject: [PATCH 05/29] bugfix: TD-1577 bulk listing support with multi pop ups
for smart contract wallets. (#2081)
Co-authored-by: Sam Jeston
---
packages/orderbook/package.json | 1 +
packages/orderbook/src/orderbook.ts | 112 ++++++++++++++++--
.../orderbook/src/test/bulk-listings.e2e.ts | 17 +--
packages/orderbook/src/types.ts | 7 +-
.../zkevm/step-definitions/shared.ts | 2 +-
yarn.lock | 5 +-
6 files changed, 121 insertions(+), 23 deletions(-)
diff --git a/packages/orderbook/package.json b/packages/orderbook/package.json
index cf8713368c..527496d2f5 100644
--- a/packages/orderbook/package.json
+++ b/packages/orderbook/package.json
@@ -5,6 +5,7 @@
"bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
"dependencies": {
"@imtbl/config": "0.0.0",
+ "@imtbl/metrics": "0.0.0",
"@opensea/seaport-js": "4.0.3",
"axios": "^1.6.5",
"ethers": "^5.7.2",
diff --git a/packages/orderbook/src/orderbook.ts b/packages/orderbook/src/orderbook.ts
index 29501dd650..74b5a7e039 100644
--- a/packages/orderbook/src/orderbook.ts
+++ b/packages/orderbook/src/orderbook.ts
@@ -1,4 +1,5 @@
import { ModuleConfiguration } from '@imtbl/config';
+import { track } from '@imtbl/metrics';
import { ImmutableApiClient, ImmutableApiClientFactory } from './api-client';
import {
getConfiguredProvider,
@@ -36,7 +37,7 @@ import {
PrepareBulkListingsResponse,
PrepareListingResponse,
SignablePurpose,
- TradeResult,
+ TradeResult, Action,
} from './types';
/**
@@ -99,6 +100,11 @@ export class Orderbook {
);
}
+ // Default order expiry to 2 years from now
+ static defaultOrderExpiry(): Date {
+ return new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 2);
+ }
+
/**
* Return the configuration for the orderbook module.
* @return {OrderbookModuleConfiguration} The configuration for the orderbook module.
@@ -168,11 +174,16 @@ export class Orderbook {
* Once the transactions are submitted and the message signed, call the completeListings method
* provided in the return type with the signature. This method supports up to 20 listing creations
* at a time. It can also be used for individual listings to simplify integration code paths.
+ *
+ * Bulk listings created using an EOA (Metamask) will require a single listing confirmation
+ * signature.
+ * Bulk listings creating using a smart contract wallet will require multiple listing confirmation
+ * signatures(as many as the number of orders).
* @param {PrepareBulkListingsParams} prepareBulkListingsParams - Details about the listings
* to be created.
* @return {PrepareBulkListingsResponse} PrepareListingResponse includes
* any unsigned approval transactions, the typed bulk order message for signing and
- * the createListings method that can be called with the signature to create the listings.
+ * the createListings method that can be called with the signature(s) to create the listings.
*/
async prepareBulkListings(
{
@@ -185,6 +196,8 @@ export class Orderbook {
throw new Error('Bulk listing creation is limited to 20 orders');
}
+ // Bulk listings (with single listing) code path common for both Smart contract
+ // wallets and EOAs.
// In the event of a single order, delegate to prepareListing as the signature is more
// gas efficient
if (listingParams.length === 1) {
@@ -193,17 +206,17 @@ export class Orderbook {
listingParams[0].sell,
listingParams[0].buy,
new Date(),
- listingParams[0].orderExpiry || new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 2),
+ listingParams[0].orderExpiry || Orderbook.defaultOrderExpiry(),
);
return {
actions: prepareListingResponse.actions,
- completeListings: async (signature: string) => {
+ completeListings: async (signatures: string | string[]) => {
const createListingResult = await this.createListing({
makerFees: listingParams[0].makerFees,
orderComponents: prepareListingResponse.orderComponents,
orderHash: prepareListingResponse.orderHash,
- orderSignature: signature,
+ orderSignature: typeof signatures === 'string' ? signatures : signatures[0],
});
return {
@@ -217,28 +230,105 @@ export class Orderbook {
};
}
+ // Bulk listings (with multiple listings) code path for Smart contract wallets.
+ // Code check to determine wallet type is not fool-proof but scenarios where smart
+ // contract wallet is not deployed will be an edge case
+ const isSmartContractWallet: boolean = await this.orderbookConfig.provider.getCode(makerAddress) !== '0x';
+ if (isSmartContractWallet) {
+ track('orderbookmr', 'bulkListings', { walletType: 'Passport', makerAddress, listingsCount: listingParams.length });
+
+ // eslint-disable-next-line max-len
+ const prepareListingResponses = await Promise.all(listingParams.map((listing) => this.seaport.prepareSeaportOrder(
+ makerAddress,
+ listing.sell,
+ listing.buy,
+ new Date(),
+ listing.orderExpiry || Orderbook.defaultOrderExpiry(),
+ )));
+
+ const pendingApproval: string[] = [];
+ const actions = prepareListingResponses.flatMap((response) => {
+ // de-dupe approval transactions to ensure every contract has
+ // a maximum of 1 approval transaction
+ const dedupedActions: Action[] = [];
+ response.actions.forEach((action) => {
+ if (action.type === ActionType.TRANSACTION) {
+ // Assuming only a single item is on offer per listing
+ const contractAddress = response.orderComponents.offer[0].token;
+ if (!pendingApproval.includes(contractAddress)) {
+ pendingApproval.push(contractAddress);
+ dedupedActions.push(action);
+ }
+ } else {
+ dedupedActions.push(action);
+ }
+ });
+ return dedupedActions;
+ });
+
+ return {
+ actions,
+ completeListings: async (signatures: string | string[]) => {
+ const signatureIsString = typeof signatures === 'string';
+ if (signatureIsString) {
+ throw new Error('A signature per listing must be provided for smart contract wallets');
+ }
+
+ const createListingsApiResponses = await Promise.all(
+ prepareListingResponses.map((prepareListingResponse, i) => {
+ const signature = signatures[i];
+ return this.apiClient.createListing({
+ makerFees: listingParams[i].makerFees,
+ orderComponents: prepareListingResponse.orderComponents,
+ orderHash: prepareListingResponse.orderHash,
+ orderSignature: signature,
+ // Swallow failed creations,this gets mapped in the response to the caller as failed
+ }).catch(() => undefined);
+ }),
+ );
+
+ return {
+ result: createListingsApiResponses.map((apiListingResponse, i) => ({
+ success: !!apiListingResponse,
+ orderHash: prepareListingResponses[i].orderHash,
+ // eslint-disable-next-line max-len
+ order: apiListingResponse ? mapFromOpenApiOrder(apiListingResponse.result) : undefined,
+ })),
+ };
+ },
+ };
+ }
+
+ // Bulk listings (with multiple listings) code path for EOA wallets.
+ track('orderbookmr', 'bulkListings', { walletType: 'EOA', makerAddress, listingsCount: listingParams.length });
const { actions, preparedListings } = await this.seaport.prepareBulkSeaportOrders(
makerAddress,
listingParams.map((orderParam) => ({
listingItem: orderParam.sell,
considerationItem: orderParam.buy,
orderStart: new Date(),
- orderExpiry: orderParam.orderExpiry || new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 2),
+ orderExpiry: orderParam.orderExpiry || Orderbook.defaultOrderExpiry(),
})),
);
return {
actions,
- completeListings: async (bulkOrderSignature: string) => {
+ completeListings: async (signatures: string | string[]) => {
+ const signatureIsArray = typeof signatures === 'object';
+ if (signatureIsArray && signatures.length !== 1) {
+ throw new Error('Only a single signature is expected for bulk listing creation');
+ }
+
const orderComponents = preparedListings.map((orderParam) => orderParam.orderComponents);
- const signatures = getBulkSeaportOrderSignatures(
- bulkOrderSignature,
+ const signature = signatureIsArray ? signatures[0] : signatures;
+ const bulkOrderSignatures = getBulkSeaportOrderSignatures(
+ signature,
orderComponents,
);
const createOrdersApiListingResponse = await Promise.all(
orderComponents.map((orderComponent, i) => {
- const sig = signatures[i];
+ const sig = bulkOrderSignatures[i];
const listing = preparedListings[i];
const listingParam = listingParams[i];
return this.apiClient.createListing({
@@ -283,7 +373,7 @@ export class Orderbook {
// Default order start to now
new Date(),
// Default order expiry to 2 years from now
- orderExpiry || new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 2),
+ orderExpiry || Orderbook.defaultOrderExpiry(),
);
}
diff --git a/packages/orderbook/src/test/bulk-listings.e2e.ts b/packages/orderbook/src/test/bulk-listings.e2e.ts
index bb0896c769..6d10582a32 100644
--- a/packages/orderbook/src/test/bulk-listings.e2e.ts
+++ b/packages/orderbook/src/test/bulk-listings.e2e.ts
@@ -10,6 +10,7 @@ import { waitForOrderToBeOfStatus } from './helpers/order';
import { getConfigFromEnv } from './helpers';
import { actionAll } from './helpers/actions';
import { PrepareBulkListingsParams } from '../types';
+import { GAS_OVERRIDES } from './helpers/gas';
// An array of each number between 1 and 20
const supportedListings = Array.from({ length: 20 }, (_, i) => i + 1);
@@ -35,7 +36,7 @@ describe('prepareListing and createOrder bulk e2e', () => {
const orderParams: PrepareBulkListingsParams['listingParams'] = [];
let i = 0;
while (i < numberOfListings) {
- await contract.safeMint(offerer.address);
+ await contract.safeMint(offerer.address, GAS_OVERRIDES);
orderParams.push({
buy: {
@@ -56,15 +57,15 @@ describe('prepareListing and createOrder bulk e2e', () => {
i++;
}
- await contract.safeMint(offerer.address);
+ await contract.safeMint(offerer.address, GAS_OVERRIDES);
const { actions, completeListings } = await sdk.prepareBulkListings({
makerAddress: offerer.address,
listingParams: orderParams,
});
- const [bulkOrderSignature] = await actionAll(actions, offerer);
- const res = await completeListings(bulkOrderSignature);
+ const bulkOrderSignatures = await actionAll(actions, offerer);
+ const res = await completeListings(bulkOrderSignatures);
for (const result of res.result) {
if (!result.order) {
@@ -72,7 +73,7 @@ describe('prepareListing and createOrder bulk e2e', () => {
}
await waitForOrderToBeOfStatus(sdk, result.order.id, OrderStatusName.ACTIVE);
}
- }, 30_000);
+ }, 60_000);
it('should create fail to prepare more than 20 listings', async () => {
const provider = getLocalhostProvider();
@@ -95,7 +96,7 @@ describe('prepareListing and createOrder bulk e2e', () => {
let i = 0;
const tooManyListings = 21;
while (i < tooManyListings) {
- await contract.safeMint(offerer.address);
+ await contract.safeMint(offerer.address, GAS_OVERRIDES);
orderParams.push({
buy: {
@@ -113,11 +114,11 @@ describe('prepareListing and createOrder bulk e2e', () => {
i++;
}
- await contract.safeMint(offerer.address);
+ await contract.safeMint(offerer.address, GAS_OVERRIDES);
await expect(sdk.prepareBulkListings({
makerAddress: offerer.address,
listingParams: orderParams,
})).rejects.toEqual(new Error('Bulk listing creation is limited to 20 orders'));
- }, 30_000);
+ }, 60_000);
});
diff --git a/packages/orderbook/src/types.ts b/packages/orderbook/src/types.ts
index 7e103390fa..d33328958b 100644
--- a/packages/orderbook/src/types.ts
+++ b/packages/orderbook/src/types.ts
@@ -59,7 +59,12 @@ export interface PrepareBulkListingsParams {
export interface PrepareBulkListingsResponse {
actions: Action[];
- completeListings: (signature: string) => Promise;
+ completeListings(signatures: string[]): Promise;
+ /**
+ * @deprecated Pass a string[] to `completeListings` instead to enable
+ * smart contract wallets
+ */
+ completeListings(signature: string): Promise;
}
export interface PrepareBulkSeaportOrders {
diff --git a/tests/func-tests/zkevm/step-definitions/shared.ts b/tests/func-tests/zkevm/step-definitions/shared.ts
index 6a02582541..57c455df31 100644
--- a/tests/func-tests/zkevm/step-definitions/shared.ts
+++ b/tests/func-tests/zkevm/step-definitions/shared.ts
@@ -198,7 +198,7 @@ export const whenICreateABulkListing = (
});
const signatures = await actionAll(actions, offerer);
- const { result } = await completeListings(signatures[0]);
+ const { result } = await completeListings(signatures);
for (const res of result) {
if (!res.success) {
diff --git a/yarn.lock b/yarn.lock
index 1cb4b81ffc..b4eec49355 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4616,6 +4616,7 @@ __metadata:
resolution: "@imtbl/orderbook@workspace:packages/orderbook"
dependencies:
"@imtbl/config": 0.0.0
+ "@imtbl/metrics": 0.0.0
"@opensea/seaport-js": 4.0.3
"@rollup/plugin-typescript": ^11.1.6
"@swc/jest": ^0.2.24
@@ -35990,7 +35991,7 @@ __metadata:
resolution: "seaport-core@https://github.com/immutable/seaport-core.git#commit=0633350ec34f21fcede657ff812f11cf7d19144e"
dependencies:
seaport-types: ^0.0.1
- checksum: 392bce86bbfc4f7c00b65575b238825f4c696bddf5af08be7aa496862e63879375387fd4400f6e900ffee08d65c1f75cf3adad9c6c41ddcf7a3b0389cd73c3c7
+ checksum: d8adba0d54106c6fe9370f0775fadef2198e5eab440b36919d1f917705ce2f0a7028e4da021b6df049aa3ca35d7e673a28b78a731130f0ff9fdf7a8bd32e3b94
languageName: node
linkType: hard
@@ -36034,7 +36035,7 @@ __metadata:
seaport-sol: ^1.5.0
seaport-types: ^0.0.1
solady: ^0.0.84
- checksum: f31a7443a50fa1c35ec03ea031743d1d10896653ae443fa15ab8e6f5b4a2ca43f6743d523ae4e1f14df867451e5b2b2130b0bfa58a1085b0bcae3fceb8dfdc9b
+ checksum: a77e141e4ab5d2c4bb190a38fbb6cda3011fdf5f350b250fbeb4d82ae81cf917a966a2dcb8d9e4fd1bed29e5510ede9b15941b0ac77aeb4272dab94c9f51e7ff
languageName: node
linkType: hard
From ab97d3c20b9f1160fef72dd3176d432bf2ab6aa1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lu=C3=A3=20de=20Souza?=
Date: Wed, 14 Aug 2024 11:11:45 +1000
Subject: [PATCH 06/29] fix: Update FAQs link (#2088)
---
packages/checkout/widgets-lib/src/lib/constants.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/checkout/widgets-lib/src/lib/constants.ts b/packages/checkout/widgets-lib/src/lib/constants.ts
index e830330218..a90f7768d6 100644
--- a/packages/checkout/widgets-lib/src/lib/constants.ts
+++ b/packages/checkout/widgets-lib/src/lib/constants.ts
@@ -20,7 +20,7 @@ export const ETH_TOKEN_SYMBOL = 'ETH';
export const ZERO_BALANCE_STRING = '0.0';
-export const FAQS_LINK = 'https://support.immutable.com/en/';
+export const FAQS_LINK = 'https://support.immutable.com/hc/en-us/categories/9383180060815-FAQs';
/**
* Delay between retries (milliseconds)
From f7de60b2bea9b1d7aed56e9187a5cdfc14b5a1d6 Mon Sep 17 00:00:00 2001
From: Alejandro Loaiza
Date: Wed, 14 Aug 2024 18:56:43 +1000
Subject: [PATCH 07/29] feat: Adding Wombat Wallet to whitelist of wallet
connect (#2078)
Co-authored-by: Jhonatan Gonzalez
---
packages/checkout/widgets-lib/src/lib/walletConnect.ts | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/packages/checkout/widgets-lib/src/lib/walletConnect.ts b/packages/checkout/widgets-lib/src/lib/walletConnect.ts
index 5c65f947fb..46383d8dfd 100644
--- a/packages/checkout/widgets-lib/src/lib/walletConnect.ts
+++ b/packages/checkout/widgets-lib/src/lib/walletConnect.ts
@@ -54,16 +54,17 @@ const lightThemeVariables = {
'--wcm-overlay-background-color': 'rgba(255, 255, 255, 0.1)',
};
-// Whitelisted wallet ids on WalletConnect explorer API
+// Whitelisted wallet ids on WalletConnect explorer (https://explorer.walletconnect.com/)
const metamaskId = 'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96';
const frontierId = '85db431492aa2e8672e93f4ea7acf10c88b97b867b0d373107af63dc4880f041';
const ledgerLiveId = '19177a98252e07ddfc9af2083ba8e07ef627cb6103467ffebb3f8f4205fd7927';
+const wombatId = 'cb604c517064f096976972384dc89948a5c850bca9b04866a443e10171d5965d';
// const coinbaseId = 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa';
// const phantomId = 'a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393';
// const rainbowId = '1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369';
-const productionWalletWhitelist = [metamaskId, frontierId, ledgerLiveId];
-const sandboxWalletWhitelist = [metamaskId];
+const productionWalletWhitelist = [metamaskId, frontierId, ledgerLiveId, wombatId];
+const sandboxWalletWhitelist = [metamaskId, wombatId];
export class WalletConnectManager {
private static instance: WalletConnectManager;
From 7d2a65b0c13f1fdc575c3d517bd506a53b35e7c6 Mon Sep 17 00:00:00 2001
From: Naveen <116692862+naveen-imtb@users.noreply.github.com>
Date: Thu, 15 Aug 2024 12:17:22 +1000
Subject: [PATCH 08/29] chore: TD-1596: optimize use of banker funds in E2E
tests. (#2091)
---
tests/func-tests/zkevm/features/order.feature | 9 ++++-
.../zkevm/step-definitions/order.steps.ts | 16 +++++++-
.../zkevm/step-definitions/shared.ts | 39 ++++++++++++++++++-
3 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/tests/func-tests/zkevm/features/order.feature b/tests/func-tests/zkevm/features/order.feature
index 7ce1f65fc9..b0c42034c1 100644
--- a/tests/func-tests/zkevm/features/order.feature
+++ b/tests/func-tests/zkevm/features/order.feature
@@ -12,6 +12,7 @@ Feature: orderbook
Then the listing should be of status filled
And 1 ERC721 token should be transferred to the fulfiller
And 1 trade should be available
+ And any remaining funds are returned to the banker
Scenario: bulk creating and fulfilling ERC721 listings
Given I have a funded offerer account
@@ -23,6 +24,7 @@ Feature: orderbook
Then the listing should be of status filled
And 1 ERC721 token should be transferred to the fulfiller
And 1 trade should be available
+ And any remaining funds are returned to the banker
Scenario: create and completely fill a ERC1155 listing
Given I have a funded offerer account
@@ -34,6 +36,7 @@ Feature: orderbook
Then the listing should be of status filled
And 100 ERC1155 tokens should be transferred to the fulfiller
And 1 trade should be available
+ And any remaining funds are returned to the banker
Scenario: create and partially fill a ERC1155 listing
Given I have a funded offerer account
@@ -50,6 +53,7 @@ Feature: orderbook
# Checks for the total amount of tokens transferred - 100 = 90 from first fulfilment + 10 from second fulfilment
And 100 ERC1155 tokens should be transferred to the fulfiller
And 2 trades should be available
+ And any remaining funds are returned to the banker
Scenario: create and bulk fill multiple listings
Given I have a funded offerer account
@@ -67,6 +71,7 @@ Feature: orderbook
Then the listing should be of status active
# Assert only the ERC1155 trade in this scenario
And 1 trade should be available
+ And any remaining funds are returned to the banker
Scenario: create and fully fill a ERC1155 listing without an explicit fulfill amount
Given I have a funded offerer account
@@ -78,6 +83,7 @@ Feature: orderbook
Then the listing should be of status filled
And 100 ERC1155 tokens should be transferred to the fulfiller
And 1 trade should be available
+ And any remaining funds are returned to the banker
Scenario: create and partially fill a ERC1155 listing, second fill without explicit amount
Given I have a funded offerer account
@@ -93,4 +99,5 @@ Feature: orderbook
Then the listing should be of status filled
# Checks for the total amount of tokens transferred - 100 = 90 from first fulfilment + 10 from second fulfilment
And 100 ERC1155 tokens should be transferred to the fulfiller
- And 2 trades should be available
\ No newline at end of file
+ And 2 trades should be available
+ And any remaining funds are returned to the banker
\ No newline at end of file
diff --git a/tests/func-tests/zkevm/step-definitions/order.steps.ts b/tests/func-tests/zkevm/step-definitions/order.steps.ts
index 16a1b46727..95ba967efc 100644
--- a/tests/func-tests/zkevm/step-definitions/order.steps.ts
+++ b/tests/func-tests/zkevm/step-definitions/order.steps.ts
@@ -14,7 +14,7 @@ import {
whenICreateAListing, whenIFulfillTheListingToBuy, andERC1155TokensShouldBeTransferredToTheFulfiller,
thenTheListingsShouldBeOfStatus,
whenIFulfillBulkListings, whenIFulfillTheListingToBuyWithoutExplicitFulfillmentAmt,
- whenICreateABulkListing,
+ whenICreateABulkListing, andAnyRemainingFundsAreReturnedToBanker,
} from './shared';
const feature = loadFeature('features/order.feature', { tagFilter: process.env.TAGS });
@@ -78,6 +78,8 @@ defineFeature(feature, (test) => {
andERC721TokenShouldBeTransferredToTheFulfiller(and, bankerWallet, erc721ContractAddress, testTokenId, fulfiller);
andTradeShouldBeAvailable(and, sdk, fulfiller, getListingId);
+
+ andAnyRemainingFundsAreReturnedToBanker(and, bankerWallet, offerer, fulfiller);
}, 120_000);
test('bulk creating and fulfilling ERC721 listings', async ({
@@ -117,6 +119,8 @@ defineFeature(feature, (test) => {
andERC721TokenShouldBeTransferredToTheFulfiller(and, bankerWallet, erc721ContractAddress, testTokenId2, fulfiller);
andTradeShouldBeAvailable(and, sdk, fulfiller, getListingId);
+
+ andAnyRemainingFundsAreReturnedToBanker(and, bankerWallet, offerer, fulfiller);
}, 120_000);
test('create and completely fill a ERC1155 listing', ({
@@ -156,6 +160,8 @@ defineFeature(feature, (test) => {
andERC1155TokensShouldBeTransferredToTheFulfiller(and, bankerWallet, erc1155ContractAddress, testTokenId, fulfiller);
andTradeShouldBeAvailable(and, sdk, fulfiller, getListingId);
+
+ andAnyRemainingFundsAreReturnedToBanker(and, bankerWallet, offerer, fulfiller);
}, 120_000);
test('create and partially fill a ERC1155 listing', ({
@@ -203,6 +209,8 @@ defineFeature(feature, (test) => {
andERC1155TokensShouldBeTransferredToTheFulfiller(and, bankerWallet, erc1155ContractAddress, testTokenId, fulfiller);
andTradeShouldBeAvailable(and, sdk, fulfiller, getListingId);
+
+ andAnyRemainingFundsAreReturnedToBanker(and, bankerWallet, offerer, fulfiller);
}, 120_000);
test('create and bulk fill multiple listings', ({
@@ -256,6 +264,8 @@ defineFeature(feature, (test) => {
thenTheListingShouldBeOfStatus(then, sdk, getERC1155ListingId);
andTradeShouldBeAvailable(and, sdk, fulfiller, getERC1155ListingId);
+
+ andAnyRemainingFundsAreReturnedToBanker(and, bankerWallet, offerer, fulfiller);
}, 120_000);
test('create and fully fill a ERC1155 listing without an explicit fulfill amount', ({
@@ -294,6 +304,8 @@ defineFeature(feature, (test) => {
andERC1155TokensShouldBeTransferredToTheFulfiller(and, bankerWallet, erc1155ContractAddress, testTokenId, fulfiller);
andTradeShouldBeAvailable(and, sdk, fulfiller, getListingId);
+
+ andAnyRemainingFundsAreReturnedToBanker(and, bankerWallet, offerer, fulfiller);
}, 120_000);
test('create and partially fill a ERC1155 listing, second fill without explicit amount', ({
@@ -341,5 +353,7 @@ defineFeature(feature, (test) => {
andERC1155TokensShouldBeTransferredToTheFulfiller(and, bankerWallet, erc1155ContractAddress, testTokenId, fulfiller);
andTradeShouldBeAvailable(and, sdk, fulfiller, getListingId);
+
+ andAnyRemainingFundsAreReturnedToBanker(and, bankerWallet, offerer, fulfiller);
}, 120_000);
});
diff --git a/tests/func-tests/zkevm/step-definitions/shared.ts b/tests/func-tests/zkevm/step-definitions/shared.ts
index 57c455df31..af12739852 100644
--- a/tests/func-tests/zkevm/step-definitions/shared.ts
+++ b/tests/func-tests/zkevm/step-definitions/shared.ts
@@ -1,6 +1,6 @@
import { orderbook } from '@imtbl/sdk';
import { DefineStepFunction } from 'jest-cucumber';
-import { Wallet } from 'ethers';
+import { BigNumber, Wallet } from 'ethers';
import {
bulkFulfillListings,
connectToTestERC1155Token,
@@ -14,6 +14,7 @@ import { actionAll } from '../utils/orderbook/actions';
const imxForApproval = 0.03 * 1e18;
const imxForFulfillment = 0.08 * 1e18;
const listingPrice = 0.0001 * 1e18;
+const transferTxnFee = 0.0035 * 1e18;
// Workaround to retry banker on-chain actions which can race with test runs on other PRs
// eslint-disable-next-line consistent-return
@@ -332,3 +333,39 @@ export const andTradeShouldBeAvailable = (
expect(targetTrades?.length === count);
});
};
+
+export const andAnyRemainingFundsAreReturnedToBanker = (
+ and: DefineStepFunction,
+ banker: Wallet,
+ offerer: Wallet,
+ fulfiller: Wallet,
+) => {
+ and(/^any remaining funds are returned to the banker$/, async () => {
+ await withBankerRetry(async () => {
+ const fulfillerBalance = await fulfiller.getBalance();
+ const offererBalance = await offerer.getBalance();
+
+ if (fulfillerBalance.gt(BigNumber.from(transferTxnFee))) {
+ // fulfiller returns funds
+ const fulfillerReturnTxn = await fulfiller.sendTransaction({
+ to: banker.address,
+ value: `${fulfillerBalance.sub(BigNumber.from(transferTxnFee)).toString()}`,
+ ...GAS_OVERRIDES,
+ });
+
+ await fulfillerReturnTxn.wait(1);
+ }
+
+ if (offererBalance.gt(BigNumber.from(transferTxnFee))) {
+ // offerer returns funds
+ const offererReturnTxn = await offerer.sendTransaction({
+ to: banker.address,
+ value: `${offererBalance.sub(BigNumber.from(transferTxnFee)).toString()}`,
+ ...GAS_OVERRIDES,
+ });
+
+ await offererReturnTxn.wait(1);
+ }
+ });
+ });
+};
From 1f0df7281c2a3ea092b338bbb7b16d735e75f868 Mon Sep 17 00:00:00 2001
From: Jhonatan Gonzalez
Date: Thu, 15 Aug 2024 13:52:22 +0800
Subject: [PATCH 09/29] Feat: [NO CHANGELOG][Checkout Widget] Add iframe
permissions policy (#2092)
---
.../src/postMessageHandler/postMessageHandler.ts | 10 +++++-----
.../widgets/checkout/views/CheckoutAppIframe.tsx | 15 +++++++++++++++
.../src/components/ui/checkout/checkout.tsx | 5 +----
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/packages/checkout/sdk/src/postMessageHandler/postMessageHandler.ts b/packages/checkout/sdk/src/postMessageHandler/postMessageHandler.ts
index 7a295faf37..686094643c 100644
--- a/packages/checkout/sdk/src/postMessageHandler/postMessageHandler.ts
+++ b/packages/checkout/sdk/src/postMessageHandler/postMessageHandler.ts
@@ -31,9 +31,6 @@ export class PostMessageHandler {
private logger: (...args: any[]) => void;
- static isSynOrAck = (type: PostMessageHandlerEventType): boolean => type === PostMessageHandlerEventType.SYN
- || type === PostMessageHandlerEventType.ACK;
-
constructor({
targetOrigin,
eventTarget,
@@ -66,11 +63,14 @@ export class PostMessageHandler {
this.logger = logger;
}
- private handshake = (): void => {
+ static isSynOrAck = (type: PostMessageHandlerEventType): boolean => type === PostMessageHandlerEventType.SYN
+ || type === PostMessageHandlerEventType.ACK;
+
+ protected handshake = (): void => {
this.postMessage(PostMessageHandlerEventType.SYN, null);
};
- private onMessage = (event: MessageEvent): void => {
+ protected onMessage = (event: MessageEvent): void => {
if (event.origin !== this.targetOrigin) return;
if (this.init) {
diff --git a/packages/checkout/widgets-lib/src/widgets/checkout/views/CheckoutAppIframe.tsx b/packages/checkout/widgets-lib/src/widgets/checkout/views/CheckoutAppIframe.tsx
index b74f061938..07a5170a17 100644
--- a/packages/checkout/widgets-lib/src/widgets/checkout/views/CheckoutAppIframe.tsx
+++ b/packages/checkout/widgets-lib/src/widgets/checkout/views/CheckoutAppIframe.tsx
@@ -18,6 +18,19 @@ import { LoadingView } from '../../../views/loading/LoadingView';
import { ErrorView } from '../../../views/error/ErrorView';
import { IFRAME_INIT_TIMEOUT_MS } from '../utils/config';
+const permissions = `
+ accelerometer;
+ camera;
+ microphone;
+ geolocation;
+ gyroscope;
+ fullscreen;
+ autoplay;
+ encrypted-media;
+ picture-in-picture;
+ clipboard-write;
+ clipboard-read;
+`;
export interface LoadingHandoverProps {
text: string;
duration?: number;
@@ -125,6 +138,8 @@ export function CheckoutAppIframe() {
ref={iframeRef}
src={iframeURL}
onLoad={onIframeLoad}
+ allow={permissions.trim().replace(/\n/g, '')}
+ loading="lazy"
/>
)}
sx={{
diff --git a/packages/checkout/widgets-sample-app/src/components/ui/checkout/checkout.tsx b/packages/checkout/widgets-sample-app/src/components/ui/checkout/checkout.tsx
index c04201c999..1e3df64669 100644
--- a/packages/checkout/widgets-sample-app/src/components/ui/checkout/checkout.tsx
+++ b/packages/checkout/widgets-sample-app/src/components/ui/checkout/checkout.tsx
@@ -58,10 +58,7 @@ function CheckoutUI() {
useEffect(() => {
passport.connectEvm();
checkoutWidget.mount("checkout", {
- flow: CheckoutFlowType.SWAP,
- amount: "0.1",
- fromTokenAddress: "0x3B2d8A1931736Fc321C24864BceEe981B11c3c57", // usdc
- toTokenAddress: "native",
+ flow: CheckoutFlowType.WALLET,
});
}, []);
From b0b671e3b2907c331bb2a9e5cc48cfaf32e1e2af Mon Sep 17 00:00:00 2001
From: Natalie
Date: Fri, 16 Aug 2024 11:49:23 +1200
Subject: [PATCH 10/29] [DX-3122] fix: get transaction receipt success check
(#2093)
---
packages/game-bridge/src/index.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/game-bridge/src/index.ts b/packages/game-bridge/src/index.ts
index 60927c2230..c098197185 100644
--- a/packages/game-bridge/src/index.ts
+++ b/packages/game-bridge/src/index.ts
@@ -716,7 +716,7 @@ window.callFunction = async (jsonData: string) => {
method: 'eth_getTransactionReceipt',
params: [request.txHash],
});
- const success = response !== null && response !== undefined;
+ const success = response !== undefined;
if (!success) {
throw new Error('Failed to get transaction receipt');
From 549a631a18338e1beac51af4fc7709b88654e789 Mon Sep 17 00:00:00 2001
From: Ji Young Lee <641712+jiyounglee@users.noreply.github.com>
Date: Fri, 16 Aug 2024 10:18:12 +1000
Subject: [PATCH 11/29] Feat: [NO CHANGELOG][Add Funds Widget] Create Add Funds
Widget by surfacing Top Up View (#2089)
Co-authored-by: Mimi Tran
---
.../definitions/configurations/addFunds.ts | 8 ++
.../widgets/definitions/events/addFunds.ts | 11 ++
.../src/widgets/definitions/events/index.ts | 1 +
.../definitions/events/orchestration.ts | 7 ++
.../src/widgets/definitions/events/widgets.ts | 1 +
.../definitions/parameters/addFunds.ts | 21 ++++
.../sdk/src/widgets/definitions/types.ts | 18 +++
.../SegmentAnalyticsProvider.ts | 1 +
.../view-context/AddFundsViewContextTypes.ts | 11 ++
packages/checkout/widgets-lib/src/factory.ts | 7 ++
.../src/widgets/add-funds/AddFundsRoot.tsx | 100 ++++++++++++++++
.../src/widgets/add-funds/AddFundsWidget.tsx | 60 ++++++++++
.../widgets/add-funds/AddFundsWidgetEvents.ts | 38 ++++++
.../checkout/widgets-sample-app/src/App.tsx | 4 +
.../src/components/ui/add-funds/addFunds.tsx | 108 ++++++++++++++++++
.../checkout/widgets-sample-app/src/index.tsx | 5 +
16 files changed, 401 insertions(+)
create mode 100644 packages/checkout/sdk/src/widgets/definitions/configurations/addFunds.ts
create mode 100644 packages/checkout/sdk/src/widgets/definitions/events/addFunds.ts
create mode 100644 packages/checkout/sdk/src/widgets/definitions/parameters/addFunds.ts
create mode 100644 packages/checkout/widgets-lib/src/context/view-context/AddFundsViewContextTypes.ts
create mode 100644 packages/checkout/widgets-lib/src/widgets/add-funds/AddFundsRoot.tsx
create mode 100644 packages/checkout/widgets-lib/src/widgets/add-funds/AddFundsWidget.tsx
create mode 100644 packages/checkout/widgets-lib/src/widgets/add-funds/AddFundsWidgetEvents.ts
create mode 100644 packages/checkout/widgets-sample-app/src/components/ui/add-funds/addFunds.tsx
diff --git a/packages/checkout/sdk/src/widgets/definitions/configurations/addFunds.ts b/packages/checkout/sdk/src/widgets/definitions/configurations/addFunds.ts
new file mode 100644
index 0000000000..7e2aeff97a
--- /dev/null
+++ b/packages/checkout/sdk/src/widgets/definitions/configurations/addFunds.ts
@@ -0,0 +1,8 @@
+import { WidgetConfiguration } from './widget';
+
+/**
+ * Add Funds Widget Configuration represents the configuration options for the Add Funds Widget.
+ */
+export type AddFundsWidgetConfiguration = {
+// TODO : [ADD_FUNDS] - What are the configuration needed?
+} & WidgetConfiguration;
diff --git a/packages/checkout/sdk/src/widgets/definitions/events/addFunds.ts b/packages/checkout/sdk/src/widgets/definitions/events/addFunds.ts
new file mode 100644
index 0000000000..39a624628b
--- /dev/null
+++ b/packages/checkout/sdk/src/widgets/definitions/events/addFunds.ts
@@ -0,0 +1,11 @@
+/**
+ * Enum of possible Add Funds Widget event types.
+ */
+export enum AddFundsEventType {
+ CLOSE_WIDGET = 'close-widget',
+ LANGUAGE_CHANGED = 'language-changed',
+ REQUEST_BRIDGE = 'request-bridge',
+ REQUEST_ONRAMP = 'request-onramp',
+ REQUEST_SWAP = 'request-swap',
+ GO_BACK = 'go-back',
+}
diff --git a/packages/checkout/sdk/src/widgets/definitions/events/index.ts b/packages/checkout/sdk/src/widgets/definitions/events/index.ts
index 60579cdead..fecd91d320 100644
--- a/packages/checkout/sdk/src/widgets/definitions/events/index.ts
+++ b/packages/checkout/sdk/src/widgets/definitions/events/index.ts
@@ -7,3 +7,4 @@ export * from './bridge';
export * from './orchestration';
export * from './onramp';
export * from './checkout';
+export * from './addFunds';
diff --git a/packages/checkout/sdk/src/widgets/definitions/events/orchestration.ts b/packages/checkout/sdk/src/widgets/definitions/events/orchestration.ts
index 41c48ca9e6..295e04e5de 100644
--- a/packages/checkout/sdk/src/widgets/definitions/events/orchestration.ts
+++ b/packages/checkout/sdk/src/widgets/definitions/events/orchestration.ts
@@ -7,6 +7,7 @@ export enum OrchestrationEventType {
REQUEST_SWAP = 'request-swap',
REQUEST_BRIDGE = 'request-bridge',
REQUEST_ONRAMP = 'request-onramp',
+ REQUEST_ADD_FUNDS = 'request-add-funds',
}
/**
@@ -66,6 +67,12 @@ export type RequestOnrampEvent = {
amount: string;
};
+/**
+ * Represents the add funds event object when the add funds widget is requested.
+ */
+export type RequestAddFundsEvent = {
+};
+
/*
* Type representing the orchestration events.
*/
diff --git a/packages/checkout/sdk/src/widgets/definitions/events/widgets.ts b/packages/checkout/sdk/src/widgets/definitions/events/widgets.ts
index e790a72a00..531a5e0d3d 100644
--- a/packages/checkout/sdk/src/widgets/definitions/events/widgets.ts
+++ b/packages/checkout/sdk/src/widgets/definitions/events/widgets.ts
@@ -13,6 +13,7 @@ export enum IMTBLWidgetEvents {
IMTBL_ONRAMP_WIDGET_EVENT = 'imtbl-onramp-widget',
IMTBL_SALE_WIDGET_EVENT = 'imtbl-sale-widget',
IMTBL_CHECKOUT_WIDGET_EVENT = 'imtbl-checkout-widget',
+ IMTBL_ADD_FUNDS_WIDGET_EVENT = 'imtbl-add-funds-widget',
}
/**
diff --git a/packages/checkout/sdk/src/widgets/definitions/parameters/addFunds.ts b/packages/checkout/sdk/src/widgets/definitions/parameters/addFunds.ts
new file mode 100644
index 0000000000..d3f4e83bf4
--- /dev/null
+++ b/packages/checkout/sdk/src/widgets/definitions/parameters/addFunds.ts
@@ -0,0 +1,21 @@
+import { WidgetLanguage } from '../configurations';
+
+export type AddFundsWidgetParams = {
+ /** The language to use for the Add Funds widget */
+ language?: WidgetLanguage;
+
+ /** Configure to show on-ramp option */
+ showOnrampOption?: boolean;
+
+ /** Configure to show swap option */
+ showSwapOption?: boolean;
+
+ /** Configure to show on bridge option */
+ showBridgeOption?: boolean;
+
+ /** Token address of the fund to be added */
+ tokenAddress?: string;
+
+ /** Amount of the fund to be added */
+ amount?: string;
+};
diff --git a/packages/checkout/sdk/src/widgets/definitions/types.ts b/packages/checkout/sdk/src/widgets/definitions/types.ts
index 1084f6a3dd..c9e9a12d0e 100644
--- a/packages/checkout/sdk/src/widgets/definitions/types.ts
+++ b/packages/checkout/sdk/src/widgets/definitions/types.ts
@@ -39,6 +39,7 @@ import {
CheckoutSuccessEvent,
CheckoutFailureEvent,
CheckoutUserActionEvent,
+ RequestAddFundsEvent,
} from './events';
import {
BridgeWidgetParams,
@@ -59,6 +60,9 @@ import {
CheckoutWidgetConfiguration,
} from './configurations';
import { WidgetTheme } from './configurations/theme';
+import { AddFundsWidgetConfiguration } from './configurations/addFunds';
+import { AddFundsWidgetParams } from './parameters/addFunds';
+import { AddFundsEventType } from './events/addFunds';
/**
* Enum representing the list of widget types.
@@ -71,6 +75,7 @@ export enum WidgetType {
ONRAMP = 'onramp',
SALE = 'sale',
CHECKOUT = 'checkout',
+ ADD_FUNDS = 'addFunds',
}
/**
@@ -89,6 +94,7 @@ export type WidgetConfigurations = {
[WidgetType.ONRAMP]: OnrampWidgetConfiguration;
[WidgetType.SALE]: SaleWidgetConfiguration;
[WidgetType.CHECKOUT]: CheckoutWidgetConfiguration;
+ [WidgetType.ADD_FUNDS]: AddFundsWidgetConfiguration;
};
// Mapping each widget type to their parameters
@@ -100,6 +106,7 @@ export type WidgetParameters = {
[WidgetType.ONRAMP]: OnRampWidgetParams;
[WidgetType.SALE]: SaleWidgetParams;
[WidgetType.CHECKOUT]: CheckoutWidgetParams;
+ [WidgetType.ADD_FUNDS]: AddFundsWidgetParams;
};
/**
@@ -113,6 +120,7 @@ export type WidgetEventTypes = {
[WidgetType.ONRAMP]: OnRampEventType | OrchestrationEventType;
[WidgetType.SALE]: SaleEventType | OrchestrationEventType;
[WidgetType.CHECKOUT]: CheckoutEventType | OrchestrationEventType;
+ [WidgetType.ADD_FUNDS]: AddFundsEventType | OrchestrationEventType;
};
// Mapping of Orchestration events to their payloads
@@ -122,6 +130,7 @@ type OrchestrationMapping = {
[OrchestrationEventType.REQUEST_SWAP]: RequestSwapEvent;
[OrchestrationEventType.REQUEST_BRIDGE]: RequestBridgeEvent;
[OrchestrationEventType.REQUEST_ONRAMP]: RequestOnrampEvent;
+ [OrchestrationEventType.REQUEST_ADD_FUNDS]: RequestAddFundsEvent;
};
type ProviderEventMapping = {
@@ -196,6 +205,15 @@ export type WidgetEventData = {
[CheckoutEventType.DISCONNECTED]: {};
[CheckoutEventType.USER_ACTION]: CheckoutUserActionEvent;
};
+
+ [WidgetType.ADD_FUNDS]: {
+ [AddFundsEventType.CLOSE_WIDGET]: {};
+ [AddFundsEventType.GO_BACK]: {};
+ [AddFundsEventType.REQUEST_BRIDGE]: {};
+ [AddFundsEventType.REQUEST_SWAP]: {};
+ [AddFundsEventType.REQUEST_ONRAMP]: {};
+ } & OrchestrationMapping &
+ ProviderEventMapping;
};
/**
diff --git a/packages/checkout/widgets-lib/src/context/analytics-provider/SegmentAnalyticsProvider.ts b/packages/checkout/widgets-lib/src/context/analytics-provider/SegmentAnalyticsProvider.ts
index 9e802f3249..2edbc88583 100644
--- a/packages/checkout/widgets-lib/src/context/analytics-provider/SegmentAnalyticsProvider.ts
+++ b/packages/checkout/widgets-lib/src/context/analytics-provider/SegmentAnalyticsProvider.ts
@@ -11,6 +11,7 @@ export enum UserJourney {
SWAP = 'Swap',
BRIDGE = 'Bridge',
SALE = 'PrimarySale',
+ ADD_FUNDS = 'AddFunds',
}
export type AnalyticsControlTypes =
diff --git a/packages/checkout/widgets-lib/src/context/view-context/AddFundsViewContextTypes.ts b/packages/checkout/widgets-lib/src/context/view-context/AddFundsViewContextTypes.ts
new file mode 100644
index 0000000000..3f42e7534c
--- /dev/null
+++ b/packages/checkout/widgets-lib/src/context/view-context/AddFundsViewContextTypes.ts
@@ -0,0 +1,11 @@
+import { ViewType } from './ViewType';
+
+export enum AddFundsWidgetViews {
+ ADD_FUNDS = 'ADD_FUNDS',
+}
+
+export type AddFundsWidgetView = AddFundsView;
+
+interface AddFundsView extends ViewType {
+ type: AddFundsWidgetViews.ADD_FUNDS;
+}
diff --git a/packages/checkout/widgets-lib/src/factory.ts b/packages/checkout/widgets-lib/src/factory.ts
index 9bb2cd36c8..c7eeb8ab80 100644
--- a/packages/checkout/widgets-lib/src/factory.ts
+++ b/packages/checkout/widgets-lib/src/factory.ts
@@ -23,6 +23,7 @@ import {
} from './lib';
import './i18n';
import { CheckoutWidgetRoot } from './widgets/checkout/CheckoutWidgetRoot';
+import { AddFunds } from './widgets/add-funds/AddFundsRoot';
export class WidgetsFactory implements IWidgetsFactory {
private sdk: Checkout;
@@ -103,6 +104,12 @@ export class WidgetsFactory implements IWidgetsFactory {
provider,
}) as Widget as Widget;
}
+ case WidgetType.ADD_FUNDS: {
+ return new AddFunds(this.sdk, {
+ config: { ...this.widgetConfig, ...(config) },
+ provider,
+ }) as Widget as Widget;
+ }
default:
throw new Error('widget type not supported');
}
diff --git a/packages/checkout/widgets-lib/src/widgets/add-funds/AddFundsRoot.tsx b/packages/checkout/widgets-lib/src/widgets/add-funds/AddFundsRoot.tsx
new file mode 100644
index 0000000000..aeee4dbbad
--- /dev/null
+++ b/packages/checkout/widgets-lib/src/widgets/add-funds/AddFundsRoot.tsx
@@ -0,0 +1,100 @@
+import {
+ ChainId,
+ IMTBLWidgetEvents,
+ WidgetConfiguration,
+ WidgetProperties,
+ WidgetTheme,
+ WidgetType,
+} from '@imtbl/checkout-sdk';
+import React, { Suspense } from 'react';
+import { AddFundsWidgetParams } from '@imtbl/checkout-sdk/dist/widgets/definitions/parameters/addFunds';
+import { Base } from '../BaseWidgetRoot';
+import { CustomAnalyticsProvider } from '../../context/analytics-provider/CustomAnalyticsProvider';
+import { HandoverProvider } from '../../context/handover-context/HandoverProvider';
+import i18n from '../../i18n';
+import { LoadingView } from '../../views/loading/LoadingView';
+import { ThemeProvider } from '../../components/ThemeProvider/ThemeProvider';
+import {
+ ConnectLoader,
+ ConnectLoaderParams,
+} from '../../components/ConnectLoader/ConnectLoader';
+import { getL1ChainId, getL2ChainId } from '../../lib';
+import { sendAddFundsCloseEvent } from './AddFundsWidgetEvents';
+
+const AddFundsWidget = React.lazy(() => import('./AddFundsWidget'));
+
+export class AddFunds extends Base {
+ protected eventTopic: IMTBLWidgetEvents = IMTBLWidgetEvents.IMTBL_ADD_FUNDS_WIDGET_EVENT;
+
+ protected getValidatedProperties({
+ config,
+ }: WidgetProperties): WidgetProperties {
+ let validatedConfig: WidgetConfiguration | undefined;
+
+ if (config) {
+ validatedConfig = config;
+ if (config.theme === WidgetTheme.LIGHT) validatedConfig.theme = WidgetTheme.LIGHT;
+ else validatedConfig.theme = WidgetTheme.DARK;
+ }
+
+ return {
+ config: validatedConfig,
+ };
+ }
+
+ protected getValidatedParameters(
+ params: AddFundsWidgetParams,
+ ): AddFundsWidgetParams {
+ const validatedParams = params;
+ return validatedParams;
+ }
+
+ protected render() {
+ if (!this.reactRoot) return;
+
+ const { t } = i18n;
+ const connectLoaderParams: ConnectLoaderParams = {
+ targetChainId: this.checkout.config.isProduction
+ ? ChainId.IMTBL_ZKEVM_MAINNET
+ : ChainId.IMTBL_ZKEVM_TESTNET,
+ web3Provider: this.web3Provider,
+ checkout: this.checkout,
+ allowedChains: [
+ getL1ChainId(this.checkout.config),
+ getL2ChainId(this.checkout.config),
+ ],
+ };
+
+ this.reactRoot.render(
+
+
+
+
+ sendAddFundsCloseEvent(window)}
+ >
+
+ }
+ >
+
+
+
+
+
+
+ ,
+ );
+ }
+}
diff --git a/packages/checkout/widgets-lib/src/widgets/add-funds/AddFundsWidget.tsx b/packages/checkout/widgets-lib/src/widgets/add-funds/AddFundsWidget.tsx
new file mode 100644
index 0000000000..9827f30cf7
--- /dev/null
+++ b/packages/checkout/widgets-lib/src/widgets/add-funds/AddFundsWidget.tsx
@@ -0,0 +1,60 @@
+import { AddFundsWidgetParams } from '@imtbl/checkout-sdk/dist/widgets/definitions/parameters/addFunds';
+import { Checkout, IMTBLWidgetEvents } from '@imtbl/checkout-sdk';
+import { Web3Provider } from '@ethersproject/providers';
+import { useContext, useMemo, useReducer } from 'react';
+import { UserJourney } from '../../context/analytics-provider/SegmentAnalyticsProvider';
+import { TopUpView } from '../../views/top-up/TopUpView';
+import {
+ sendAddFundsCloseEvent,
+ sendAddFundsGoBackEvent,
+} from './AddFundsWidgetEvents';
+import { EventTargetContext } from '../../context/event-target-context/EventTargetContext';
+import {
+ ViewContext,
+ initialViewState,
+ viewReducer,
+} from '../../context/view-context/ViewContext';
+
+export type AddFundsWidgetInputs = AddFundsWidgetParams & {
+ checkout: Checkout;
+ web3Provider?: Web3Provider;
+};
+
+export default function AddFundsWidget({
+ checkout,
+ web3Provider,
+ showOnrampOption = true,
+ showSwapOption = true,
+ showBridgeOption = true,
+ tokenAddress,
+ amount,
+}: AddFundsWidgetInputs) {
+ const [viewState, viewDispatch] = useReducer(viewReducer, initialViewState);
+
+ const viewReducerValues = useMemo(
+ () => ({ viewState, viewDispatch }),
+ [viewState, viewReducer],
+ );
+
+ const {
+ eventTargetState: { eventTarget },
+ } = useContext(EventTargetContext);
+
+ return (
+
+ sendAddFundsCloseEvent(eventTarget)}
+ onBackButtonClick={() => sendAddFundsGoBackEvent(eventTarget)}
+ />
+
+ );
+}
diff --git a/packages/checkout/widgets-lib/src/widgets/add-funds/AddFundsWidgetEvents.ts b/packages/checkout/widgets-lib/src/widgets/add-funds/AddFundsWidgetEvents.ts
new file mode 100644
index 0000000000..6f03661e54
--- /dev/null
+++ b/packages/checkout/widgets-lib/src/widgets/add-funds/AddFundsWidgetEvents.ts
@@ -0,0 +1,38 @@
+import {
+ WidgetEvent,
+ WidgetType,
+ AddFundsEventType,
+ IMTBLWidgetEvents,
+} from '@imtbl/checkout-sdk';
+
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+export function sendAddFundsCloseEvent(eventTarget: Window | EventTarget) {
+ const closeWidgetEvent = new CustomEvent<
+ WidgetEvent
+ >(IMTBLWidgetEvents.IMTBL_ADD_FUNDS_WIDGET_EVENT, {
+ detail: {
+ type: AddFundsEventType.CLOSE_WIDGET,
+ data: {},
+ },
+ });
+ // TODO: please remove or if necessary keep the eslint ignore
+ // eslint-disable-next-line no-console
+ console.log('close widget event:', closeWidgetEvent);
+ if (eventTarget !== undefined) eventTarget.dispatchEvent(closeWidgetEvent);
+}
+
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+export function sendAddFundsGoBackEvent(eventTarget: Window | EventTarget) {
+ const closeWidgetEvent = new CustomEvent<
+ WidgetEvent
+ >(IMTBLWidgetEvents.IMTBL_ADD_FUNDS_WIDGET_EVENT, {
+ detail: {
+ type: AddFundsEventType.GO_BACK,
+ data: {},
+ },
+ });
+ // TODO: please remove or if necessary keep the eslint ignore
+ // eslint-disable-next-line no-console
+ console.log('go back event:', closeWidgetEvent);
+ if (eventTarget !== undefined) eventTarget.dispatchEvent(closeWidgetEvent);
+}
diff --git a/packages/checkout/widgets-sample-app/src/App.tsx b/packages/checkout/widgets-sample-app/src/App.tsx
index 605d251aaf..c210693a42 100644
--- a/packages/checkout/widgets-sample-app/src/App.tsx
+++ b/packages/checkout/widgets-sample-app/src/App.tsx
@@ -31,6 +31,10 @@ function App() {
Checkout Widget
+