Skip to content

Commit

Permalink
Merge branch 'refs/heads/development' into rt/feature/transactions
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/apiCalls/transactions/getTransactionByHash.ts
#	src/apiCalls/transactions/getTransactionsByHashes.ts
#	src/constants/transactions.constants.ts
#	src/store/actions/network/initializeNetwork.ts
#	src/store/selectors/networkSelectors.ts
#	src/store/slices/index.ts
#	src/store/store.types.ts
#	src/types/index.ts
#	src/types/transactions.types.ts
#	src/utils/account/index.ts
#	src/utils/transactions/dataDecoders/smartContractTransaction.ts
  • Loading branch information
razvantomegea committed Dec 4, 2024
2 parents 2f46a5c + 7f8ed37 commit 01caef8
Show file tree
Hide file tree
Showing 132 changed files with 5,908 additions and 2,687 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ out
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.yarnrc
coverage
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- [Added custom web socket url support](https://github.com/multiversx/mx-sdk-dapp-core/pull/35)
- [Metamask integration](https://github.com/multiversx/mx-sdk-dapp-core/pull/27)
- [Extension integration](https://github.com/multiversx/mx-sdk-dapp-core/pull/26)
- [Ledger integration](https://github.com/multiversx/mx-sdk-dapp-core/pull/22)
- [Added sign, send, & track transactions with websocket connection](https://github.com/multiversx/mx-sdk-dapp-core/pull/21)
- [Added restore provider after page reload](https://github.com/multiversx/mx-sdk-dapp-core/pull/19)
- [Added signMessage](https://github.com/multiversx/mx-sdk-dapp-core/pull/18)

## [[0.0.0-alpha.9]](https://github.com/multiversx/mx-sdk-dapp-core)] - 2024-08-29

- [CrossWindow login](https://github.com/multiversx/mx-sdk-dapp-core/pull/13)

## [[v0.0.0-alpha.8]](https://github.com/multiversx/mx-sdk-dapp-core/pull/16) - 2024-08-27

- [Added sdk-web-wallet-cross-window-provider as peer dependency](https://github.com/multiversx/mx-sdk-dapp-core/pull/14)
- [Generic login + ExtensionProvider login](https://github.com/multiversx/mx-sdk-dapp-core/pull/12)
- [Make middlewares registration more scalable](https://github.com/multiversx/mx-sdk-dapp-core/pull/11)
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
## Usage

In your project, make sure to use the `preserveSymlinks` option in the server configuration to ensure that the symlinks are preserved, for ease of development.

``` js
resolve: {
preserveSymlinks: true, // 👈
alias: {
src: "/src",
},
},
```

// TODO: DEMONSTRATE API
Expand Down
67 changes: 42 additions & 25 deletions eslint.config.js → eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
[
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import importPlugin from 'eslint-plugin-import';
import prettierPlugin from 'eslint-plugin-prettier';
import jestPlugin from 'eslint-plugin-jest';

/** @type {import('eslint').Linter.Config[]} */
export default [
{
env: {
es2021: true,
node: true
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
ecmaFeatures: {
jsx: true
files: ['**/*.{js,mjs,cjs,ts,tsx}', '**/*.{test,spec}.{js,ts,tsx}'],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest
},
project: './tsconfig.json'
parser: tseslint.parser,
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
ecmaFeatures: {
jsx: true
},
project: './tsconfig.json'
}
},
plugins: {
import: importPlugin,
prettier: prettierPlugin,
jest: jestPlugin,
'@typescript-eslint': tseslint.plugin
},
settings: {
'import/parsers': {
Expand All @@ -27,13 +45,10 @@
}
}
},
extends: [
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:prettier/recommended'
],
plugins: ['prettier', 'import'],
rules: {
...jestPlugin.configs.recommended.rules,
...pluginJs.configs.recommended.rules,
...tseslint.configs.recommended.rules,
'import/order': [
'warn',
{
Expand All @@ -52,12 +67,7 @@
}
}
],
'prettier/prettier': [
'error',
{
endOfLine: 'lf'
}
],
'prettier/prettier': ['error', { endOfLine: 'lf' }],
'@typescript-eslint/indent': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-use-before-define': [
Expand All @@ -68,13 +78,20 @@
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_' }
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}
],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
semi: ['error', 'always'],
'no-unused-vars': ['off'],
'no-prototype-builtins': 'off',
'jest/no-mocks-import': 'off',
'no-async-promise-executor': 'off',
'object-curly-newline': 'off',
'arrow-body-style': 'off',
'implicit-arrow-linebreak': 'off',
Expand Down
69 changes: 41 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-dapp-core",
"version": "0.0.0-alpha.9",
"version": "0.0.0-alpha.11",
"main": "out/index.js",
"module": "out/index.js",
"types": "out/index.d.ts",
Expand All @@ -19,74 +19,87 @@
"url": "git+https://github.com/multiversx/mx-sdk-dapp-core.git"
},
"scripts": {
"unpublish-verdaccio": "npm unpublish @multiversx/sdk-dapp-core --force --registry http://localhost:4873",
"publish-verdaccio": "npm run unpublish-verdaccio && npm run compile-next && npm publish --registry http://localhost:4873/",
"compile": "tsc && tsc-alias",
"build-esbuild": "rimraf out && node esbuild.js",
"publish-verdaccio": "npm unpublish --registry http://localhost:4873 @multiversx/[email protected] && rimraf out && yarn compile && npm publish --registry http://localhost:4873",
"build": "yarn build-esbuild && yarn compile",
"test": "jest",
"lint": "eslint --fix src",
"compile-next": "rimraf out && tsc --p tsconfig.next.json && tsc-alias --project tsconfig.next.json"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@lifeomic/axios-fetch": "3.0.1",
"@multiversx/sdk-extension-provider": "3.0.0",
"@multiversx/sdk-hw-provider": "6.4.0",
"@multiversx/sdk-metamask-provider": "0.0.5",
"@multiversx/sdk-extension-provider": "4.0.0",
"@multiversx/sdk-hw-provider": "7.0.0",
"@multiversx/sdk-metamask-provider": "0.0.7",
"@multiversx/sdk-native-auth-client": "^1.0.8",
"@multiversx/sdk-opera-provider": "1.0.0-alpha.1",
"@multiversx/sdk-wallet": "4.5.1",
"@multiversx/sdk-wallet-connect-provider": "4.1.2",
"@multiversx/sdk-web-wallet-iframe-provider": "2.0.1",
"@multiversx/sdk-web-wallet-provider": "3.2.1",
"@types/lodash": "^4.17.4",
"isomorphic-fetch": "^3.0.0",
"lodash": "^4.17.21",
"zustand": "^4.4.7"
"isomorphic-fetch": "3.0.0",
"lodash": "4.17.21",
"protobufjs": "7.3.0",
"socket.io-client": "4.7.5",
"zustand": "4.4.7"
},
"peerDependencies": {
"@multiversx/sdk-core": ">= 13.0.0",
"@multiversx/sdk-dapp-utils": ">= 0.1.0",
"@multiversx/sdk-web-wallet-cross-window-provider": ">= 1.0.0",
"@multiversx/sdk-core": ">= 13.5.0",
"@multiversx/sdk-dapp-utils": ">= 1.0.0",
"@multiversx/sdk-web-wallet-cross-window-provider": ">= 2.0.1",
"axios": ">=1.6.5",
"bignumber.js": "9.x"
"bignumber.js": "9.x",
"immer": "10.x"
},
"optionalDependencies": {
"@multiversx/sdk-dapp-core-ui": "file:../mx-sdk-dapp-core-ui"
},
"resolutions": {
"string-width": "4.1.0"
},
"devDependencies": {
"@multiversx/sdk-core": ">= 13.0.0",
"@multiversx/sdk-dapp-utils": ">= 0.1.0",
"@multiversx/sdk-web-wallet-cross-window-provider": ">= 1.0.0",
"@eslint/js": "9.15.0",
"@multiversx/sdk-core": ">= 13.5.0",
"@multiversx/sdk-dapp-utils": "1.0.0",
"@multiversx/sdk-web-wallet-cross-window-provider": ">= 2.0.1",
"@swc/core": "^1.4.17",
"@swc/jest": "^0.2.36",
"@types/jest": "29.5.13",
"@types/lodash": "4.17.4",
"@types/node": "20.12.8",
"@typescript-eslint/eslint-plugin": "7.8.0",
"@typescript-eslint/parser": "7.8.0",
"@typescript-eslint/eslint-plugin": "8.15.0",
"@typescript-eslint/parser": "8.15.0",
"axios": ">=1.6.5",
"axios-mock-adapter": "^1.22.0",
"axios-mock-adapter": "1.22.0",
"bignumber.js": "9.x",
"esbuild": "^0.21.1",
"esbuild": "0.21.1",
"esbuild-node-externals": "1.14.0",
"eslint": "9.1.1",
"eslint": "9.15.0",
"eslint-config-prettier": "9.1.0",
"eslint-config-standard": "17.1.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-import": "2.29.1",
"eslint-import-resolver-typescript": "3.6.3",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-jest": "28.9.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-promise": "6.1.1",
"glob": "^10.3.14",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-promise": "7.1.0",
"glob": "10.3.14",
"immer": "^10.1.1",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"msw": "1.3.1",
"node-stdlib-browser": "1.2.0",
"prettier": "3.2.5",
"protobufjs": "^7.3.0",
"react": "^18.3.1",
"rimraf": "^5.0.6",
"ts-jest": "29.1.2",
"tsc-alias": "^1.8.9",
"typescript": "^5.4.5"
"typescript": "5.4.5",
"typescript-eslint": "8.15.0"
}
}
2 changes: 0 additions & 2 deletions src/__mocks__/utils/mockWindowHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ export const mockWindowHistory = () => {

const history = window.history;

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
delete window.history;

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
window.history = Object.defineProperties(
{},
Expand Down
2 changes: 0 additions & 2 deletions src/__mocks__/utils/mockWindowLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ export const mockWindowLocation = () => {

const location = window.location;

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
delete window.location;

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
window.location = Object.defineProperties(
{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const getAccountFromApi = async (address?: string) => {
try {
const { data } = await accountFetcher(address);
return data as AccountType;
} catch (err) {
} catch (_err) {
console.error('error fetching configuration for ', address);
}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/apiCalls/configuration/getNetworkConfigFromApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function getNetworkConfigFromApi() {
if (data != null) {
return data?.data?.config;
}
} catch (err) {
} catch (_err) {
console.error('error fetching configuration for ', configUrl);
}
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/apiCalls/configuration/getServerConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function getServerConfiguration(apiAddress: string) {
try {
const { data } = await axios.get<NetworkType>(configUrl);
return data;
} catch (err) {
} catch (_err) {
console.error('error fetching configuration for ', configUrl);
}
return null;
Expand Down
20 changes: 5 additions & 15 deletions src/apiCalls/transactions/getTransactionsByHashes.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import axios from 'axios';
import { TRANSACTIONS_ENDPOINT } from 'apiCalls/endpoints';
import { ServerTransactionType } from 'types';

import { networkSelector } from 'store/selectors';
import { getState } from 'store/store';
import {
GetTransactionsByHashesReturnType,
PendingTransactionsType
} from 'types/transactions.types';
import { apiAddressSelector } from 'store/selectors';
import { getState } from 'store/store';

export const getTransactionsByHashes = async (
pendingTransactions: PendingTransactionsType
): Promise<GetTransactionsByHashesReturnType> => {
const apiAddress = apiAddressSelector(getState());
const { apiAddress } = networkSelector(getState());
const hashes = pendingTransactions.map((tx) => tx.hash);

const { data: responseData } = await axios.get(
`${apiAddress}/${TRANSACTIONS_ENDPOINT}`,
{
Expand Down Expand Up @@ -41,14 +42,3 @@ export const getTransactionsByHashes = async (
};
});
};

export function getTransactionByHashPromise(hash: string) {
const apiAddress = apiAddressSelector(getState());

return axios.get<ServerTransactionType>(
`${apiAddress}/transactions/${hash}`,
{
timeout: 10000 // 10sec
}
);
}
4 changes: 2 additions & 2 deletions src/apiCalls/utils/getScamAddressData.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import axios from 'axios';
import { ScamInfoType } from 'types/account.types';
import { ACCOUNTS_ENDPOINT } from '../endpoints';
import { networkSelector } from 'store/selectors';
import { getState } from 'store/store';
import { ScamInfoType } from 'types/account.types';
import { ACCOUNTS_ENDPOINT } from '../endpoints';

export async function getScamAddressData(addressToVerify: string) {
const { apiAddress, apiTimeout } = networkSelector(getState());
Expand Down
13 changes: 13 additions & 0 deletions src/apiCalls/websocket/getWebsocketUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import axios from 'axios';

export async function getWebsocketUrl(apiAddress: string) {
try {
const { data } = await axios.get<{ url: string }>(
`${apiAddress}/websocket/config`
);
return `wss://${data.url}`;
} catch (err) {
console.error(err);
throw new Error('Can not get websocket url');
}
}
1 change: 1 addition & 0 deletions src/apiCalls/websocket/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './getWebsocketUrl';
1 change: 1 addition & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './browser.constants';
export * from './errorMessages.constants';
export * from './mvx.constants';
export * from './ledger.constants';
export * from './network.constants';
export * from './placeholders.constants';
Expand Down
Loading

0 comments on commit 01caef8

Please sign in to comment.