diff --git a/.changeset/ninety-news-retire.md b/.changeset/ninety-news-retire.md new file mode 100644 index 00000000..6272a1b2 --- /dev/null +++ b/.changeset/ninety-news-retire.md @@ -0,0 +1,6 @@ +--- +'@gnosis.pm/safe-apps-provider': minor +'@gnosis.pm/safe-apps-sdk': minor +--- + +Support eth_gasPrice rpc method diff --git a/package.json b/package.json index 0dfea107..d9cd5cd8 100644 --- a/package.json +++ b/package.json @@ -19,14 +19,14 @@ "lerna": "^4.0.0" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^4.28.4", - "@typescript-eslint/parser": "^4.28.4", - "eslint": "7.31.0", + "@typescript-eslint/eslint-plugin": "^4.28.5", + "@typescript-eslint/parser": "^4.28.5", + "eslint": "7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^3.4.0", "jest": "27.0.6", "prettier": "^2.3.2", - "ts-jest": "^27.0.3", + "ts-jest": "^27.0.4", "typescript": "^4.3.5" } } diff --git a/packages/safe-apps-provider/src/provider.ts b/packages/safe-apps-provider/src/provider.ts index 5368ad62..59c10f09 100644 --- a/packages/safe-apps-provider/src/provider.ts +++ b/packages/safe-apps-provider/src/provider.ts @@ -149,6 +149,9 @@ export class SafeAppProvider implements EIP1193Provider { case 'eth_getLogs': return this.sdk.eth.getPastLogs([params[0]]); + case 'eth_gasPrice': + return this.sdk.eth.getGasPrice(); + default: throw Error(`"${request.method}" not implemented`); } diff --git a/packages/safe-apps-react-sdk/package.json b/packages/safe-apps-react-sdk/package.json index 03bb02df..1aa4d0e6 100644 --- a/packages/safe-apps-react-sdk/package.json +++ b/packages/safe-apps-react-sdk/package.json @@ -23,7 +23,7 @@ "@types/jest": "^26.0.24", "@types/react-dom": "^17.0.9", "eslint-config-react-app": "^6.0.0", - "eslint-plugin-flowtype": "^5.8.0", + "eslint-plugin-flowtype": "^5.8.2", "eslint-plugin-import": "^2.23.4", "eslint-plugin-jsx-a11y": "^6.3.1", "eslint-plugin-react": "^7.24.0", diff --git a/packages/safe-apps-sdk/dist/package.json b/packages/safe-apps-sdk/dist/package.json index 7ebec842..f03716d5 100644 --- a/packages/safe-apps-sdk/dist/package.json +++ b/packages/safe-apps-sdk/dist/package.json @@ -1,38 +1,41 @@ { - "name": "@gnosis.pm/safe-apps-sdk", - "version": "4.0.0", - "description": "SDK developed to integrate third-party apps with Safe-Multisig app.", - "main": "dist/src/index.js", - "typings": "dist/src/index.d.ts", - "_files": [ - "dist/**/*", - "README.md" - ], - "keywords": [ - "Gnosis", - "sdk", - "apps" - ], - "scripts": { - "test": "jest", - "format-dist": "sed -i '' 's/\"files\":/\"_files\":/' dist/package.json", - "build": "yarn rimraf dist && tsc && yarn format-dist", - "lint": "tslint -p tsconfig.json" - }, - "author": "Gnosis (https://gnosis.io)", - "license": "MIT", - "dependencies": {}, - "devDependencies": { - "@types/jest": "^26.0.24", - "@types/node": "^16.3.2", - "rimraf": "^3.0.2" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/gnosis/safe-apps-sdk.git" - }, - "bugs": { - "url": "https://github.com/gnosis/safe-apps-sdk/issues" - }, - "homepage": "https://github.com/gnosis/safe-apps-sdk#readme" + "name": "@gnosis.pm/safe-apps-sdk", + "version": "4.1.0-next.0", + "description": "SDK developed to integrate third-party apps with Safe-Multisig app.", + "main": "dist/src/index.js", + "typings": "dist/src/index.d.ts", + "_files": [ + "dist/**/*", + "README.md" + ], + "keywords": [ + "Gnosis", + "sdk", + "apps" + ], + "scripts": { + "test": "jest", + "format-dist": "sed -i '' 's/\"files\":/\"_files\":/' dist/package.json", + "build": "yarn rimraf dist && tsc && yarn format-dist", + "lint": "tslint -p tsconfig.json" + }, + "author": "Gnosis (https://gnosis.io)", + "license": "MIT", + "dependencies": {}, + "devDependencies": { + "@types/jest": "^26.0.24", + "@types/node": "^16.4.10", + "rimraf": "^3.0.2" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/gnosis/safe-apps-sdk.git" + }, + "bugs": { + "url": "https://github.com/gnosis/safe-apps-sdk/issues" + }, + "homepage": "https://github.com/gnosis/safe-apps-sdk#readme", + "publishConfig": { + "access": "public" + } } diff --git a/packages/safe-apps-sdk/dist/src/eth/constants.d.ts b/packages/safe-apps-sdk/dist/src/eth/constants.d.ts index 9b796733..d6d871ab 100644 --- a/packages/safe-apps-sdk/dist/src/eth/constants.d.ts +++ b/packages/safe-apps-sdk/dist/src/eth/constants.d.ts @@ -1,5 +1,6 @@ export declare const RPC_CALLS: { readonly eth_call: "eth_call"; + readonly eth_gasPrice: "eth_gasPrice"; readonly eth_getLogs: "eth_getLogs"; readonly eth_getBalance: "eth_getBalance"; readonly eth_getCode: "eth_getCode"; diff --git a/packages/safe-apps-sdk/dist/src/eth/constants.js b/packages/safe-apps-sdk/dist/src/eth/constants.js index 7e72d964..de7caf2f 100644 --- a/packages/safe-apps-sdk/dist/src/eth/constants.js +++ b/packages/safe-apps-sdk/dist/src/eth/constants.js @@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.RPC_CALLS = void 0; exports.RPC_CALLS = { eth_call: 'eth_call', + eth_gasPrice: 'eth_gasPrice', eth_getLogs: 'eth_getLogs', eth_getBalance: 'eth_getBalance', eth_getCode: 'eth_getCode', diff --git a/packages/safe-apps-sdk/dist/src/eth/constants.js.map b/packages/safe-apps-sdk/dist/src/eth/constants.js.map index 63b05637..0a23e6df 100644 --- a/packages/safe-apps-sdk/dist/src/eth/constants.js.map +++ b/packages/safe-apps-sdk/dist/src/eth/constants.js.map @@ -1 +1 @@ -{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/eth/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACvB,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,aAAa;IAC1B,cAAc,EAAE,gBAAgB;IAChC,WAAW,EAAE,aAAa;IAC1B,kBAAkB,EAAE,oBAAoB;IACxC,oBAAoB,EAAE,sBAAsB;IAC5C,gBAAgB,EAAE,kBAAkB;IACpC,wBAAwB,EAAE,0BAA0B;IACpD,yBAAyB,EAAE,2BAA2B;IACtD,uBAAuB,EAAE,yBAAyB;CAC1C,CAAC"} \ No newline at end of file +{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/eth/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACvB,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,cAAc;IAC5B,WAAW,EAAE,aAAa;IAC1B,cAAc,EAAE,gBAAgB;IAChC,WAAW,EAAE,aAAa;IAC1B,kBAAkB,EAAE,oBAAoB;IACxC,oBAAoB,EAAE,sBAAsB;IAC5C,gBAAgB,EAAE,kBAAkB;IACpC,wBAAwB,EAAE,0BAA0B;IACpD,yBAAyB,EAAE,2BAA2B;IACtD,uBAAuB,EAAE,yBAAyB;CAC1C,CAAC"} \ No newline at end of file diff --git a/packages/safe-apps-sdk/dist/src/eth/index.d.ts b/packages/safe-apps-sdk/dist/src/eth/index.d.ts index 7560bedf..ab7fa560 100644 --- a/packages/safe-apps-sdk/dist/src/eth/index.d.ts +++ b/packages/safe-apps-sdk/dist/src/eth/index.d.ts @@ -1,15 +1,16 @@ import { BlockNumberArg, Communicator, Log, BlockTransactionString, BlockTransactionObject, Web3TransactionObject, TransactionConfig, Web3TransactionReceiptObject, PastLogsOptions } from '../types'; declare class Eth { - call: (params: [TransactionConfig, (string | undefined)?]) => Promise; - getBalance: (params: [string, (string | undefined)?]) => Promise; - getCode: (params: [string, (string | undefined)?]) => Promise; - getStorageAt: (params: [string, number, (string | undefined)?]) => Promise; - getPastLogs: (params: [PastLogsOptions]) => Promise; - getBlockByHash: (params: [string, (boolean | undefined)?]) => Promise; - getBlockByNumber: (params: [BlockNumberArg, (boolean | undefined)?]) => Promise; - getTransactionByHash: (params: [string]) => Promise; - getTransactionReceipt: (params: [string]) => Promise; - getTransactionCount: (params: [string, (string | undefined)?]) => Promise; + call: (params?: [TransactionConfig, (string | undefined)?] | undefined) => Promise; + getBalance: (params?: [string, (string | undefined)?] | undefined) => Promise; + getCode: (params?: [string, (string | undefined)?] | undefined) => Promise; + getStorageAt: (params?: [string, number, (string | undefined)?] | undefined) => Promise; + getPastLogs: (params?: [PastLogsOptions] | undefined) => Promise; + getBlockByHash: (params?: [string, (boolean | undefined)?] | undefined) => Promise; + getBlockByNumber: (params?: [BlockNumberArg, (boolean | undefined)?] | undefined) => Promise; + getTransactionByHash: (params?: [string] | undefined) => Promise; + getTransactionReceipt: (params?: [string] | undefined) => Promise; + getTransactionCount: (params?: [string, (string | undefined)?] | undefined) => Promise; + getGasPrice: (params?: never[] | undefined) => Promise; private readonly communicator; constructor(communicator: Communicator); private buildRequest; diff --git a/packages/safe-apps-sdk/dist/src/eth/index.js b/packages/safe-apps-sdk/dist/src/eth/index.js index b97ef8a7..3d3feaaa 100644 --- a/packages/safe-apps-sdk/dist/src/eth/index.js +++ b/packages/safe-apps-sdk/dist/src/eth/index.js @@ -48,8 +48,12 @@ class Eth { call: constants_1.RPC_CALLS.eth_getTransactionCount, formatters: [null, inputFormatters.defaultBlockParam], }); + this.getGasPrice = this.buildRequest({ + call: constants_1.RPC_CALLS.eth_gasPrice, + }); } - buildRequest({ call, formatters }) { + buildRequest(args) { + const { call, formatters } = args; return async (params) => { if (formatters && Array.isArray(params)) { formatters.forEach((formatter, i) => { @@ -60,7 +64,7 @@ class Eth { } const payload = { call, - params, + params: params || [], }; const response = await this.communicator.send(methods_1.Methods.rpcCall, payload); return response.data; diff --git a/packages/safe-apps-sdk/dist/src/eth/index.js.map b/packages/safe-apps-sdk/dist/src/eth/index.js.map index 279a23c9..f36c222e 100644 --- a/packages/safe-apps-sdk/dist/src/eth/index.js.map +++ b/packages/safe-apps-sdk/dist/src/eth/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/eth/index.ts"],"names":[],"mappings":";;;AAAA,gDAA6C;AAc7C,sDAAmD;AAKnD,MAAM,eAAe,GAA8B;IACjD,iBAAiB,EAAE,CAAC,GAAG,GAAG,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,IAAsB;QACnE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAElC,OAAO,KAAK,EAAE,MAAU,EAAc,EAAE;YACtC,IAAI,UAAU,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBACvC,UAAU,CAAC,OAAO,CAAC,CAAC,SAAmD,EAAE,CAAC,EAAE,EAAE;oBAC5E,IAAI,SAAS,EAAE;wBACb,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;qBAClC;gBACH,CAAC,CAAC,CAAC;aACJ;YAED,MAAM,OAAO,GAAkB;gBAC7B,IAAI;gBACJ,MAAM,EAAE,MAAM,IAAI,EAAE;aACrB,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAoC,iBAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAE3G,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC,CAAC;IACJ,CAAC;CACF;AAEQ,kBAAG"} \ No newline at end of file diff --git a/packages/safe-apps-sdk/dist/src/types/rpc.d.ts b/packages/safe-apps-sdk/dist/src/types/rpc.d.ts index 2fc270ff..20267460 100644 --- a/packages/safe-apps-sdk/dist/src/types/rpc.d.ts +++ b/packages/safe-apps-sdk/dist/src/types/rpc.d.ts @@ -2,7 +2,7 @@ import { RPC_CALLS } from '../eth/constants'; export declare type RpcCallNames = keyof typeof RPC_CALLS; export declare type RPCPayload

= { call: RpcCallNames; - params: P; + params: P | never[]; }; export interface Log { address: string; diff --git a/packages/safe-apps-sdk/package.json b/packages/safe-apps-sdk/package.json index b6544ef9..792eb044 100644 --- a/packages/safe-apps-sdk/package.json +++ b/packages/safe-apps-sdk/package.json @@ -24,7 +24,7 @@ "dependencies": {}, "devDependencies": { "@types/jest": "^26.0.24", - "@types/node": "^16.3.3", + "@types/node": "^16.4.10", "rimraf": "^3.0.2" }, "repository": { diff --git a/packages/safe-apps-sdk/src/eth/constants.ts b/packages/safe-apps-sdk/src/eth/constants.ts index 2d649535..fe044849 100644 --- a/packages/safe-apps-sdk/src/eth/constants.ts +++ b/packages/safe-apps-sdk/src/eth/constants.ts @@ -1,5 +1,6 @@ export const RPC_CALLS = { eth_call: 'eth_call', + eth_gasPrice: 'eth_gasPrice', eth_getLogs: 'eth_getLogs', eth_getBalance: 'eth_getBalance', eth_getCode: 'eth_getCode', diff --git a/packages/safe-apps-sdk/src/eth/eth.test.ts b/packages/safe-apps-sdk/src/eth/eth.test.ts index bf00b147..41bf7415 100644 --- a/packages/safe-apps-sdk/src/eth/eth.test.ts +++ b/packages/safe-apps-sdk/src/eth/eth.test.ts @@ -335,4 +335,21 @@ describe('Safe Apps SDK Read RPC Requests', () => { ); }); }); + + describe('gasPrice', () => { + it('Should send a valid message to the interface', () => { + sdkInstance.eth.getGasPrice(); + + expect(spy).toHaveBeenCalledWith( + expect.objectContaining({ + method: Methods.rpcCall, + params: { + call: 'eth_gasPrice', + params: [], + }, + }), + '*', + ); + }); + }); }); diff --git a/packages/safe-apps-sdk/src/eth/index.ts b/packages/safe-apps-sdk/src/eth/index.ts index 606ab48b..ea024ecd 100644 --- a/packages/safe-apps-sdk/src/eth/index.ts +++ b/packages/safe-apps-sdk/src/eth/index.ts @@ -40,6 +40,7 @@ class Eth { public getTransactionByHash; public getTransactionReceipt; public getTransactionCount; + public getGasPrice; private readonly communicator: Communicator; constructor(communicator: Communicator) { @@ -80,14 +81,19 @@ class Eth { this.getTransactionReceipt = this.buildRequest<[string], Web3TransactionReceiptObject>({ call: RPC_CALLS.eth_getTransactionReceipt, }); - this.getTransactionCount = this.buildRequest<[string, string?], number>({ + this.getTransactionCount = this.buildRequest<[string, string?], string>({ call: RPC_CALLS.eth_getTransactionCount, formatters: [null, inputFormatters.defaultBlockParam], }); + this.getGasPrice = this.buildRequest({ + call: RPC_CALLS.eth_gasPrice, + }); } - private buildRequest

({ call, formatters }: BuildRequestArgs) { - return async (params: P): Promise => { + private buildRequest

(args: BuildRequestArgs) { + const { call, formatters } = args; + + return async (params?: P): Promise => { if (formatters && Array.isArray(params)) { formatters.forEach((formatter: ((...args: unknown[]) => unknown) | null, i) => { if (formatter) { @@ -98,7 +104,7 @@ class Eth { const payload: RPCPayload

= { call, - params, + params: params || [], }; const response = await this.communicator.send, R>(Methods.rpcCall, payload); diff --git a/packages/safe-apps-sdk/src/types/rpc.ts b/packages/safe-apps-sdk/src/types/rpc.ts index 3dbbcf4a..16b87de3 100644 --- a/packages/safe-apps-sdk/src/types/rpc.ts +++ b/packages/safe-apps-sdk/src/types/rpc.ts @@ -4,7 +4,7 @@ export type RpcCallNames = keyof typeof RPC_CALLS; export type RPCPayload

= { call: RpcCallNames; - params: P; + params: P | never[]; }; export interface Log { diff --git a/packages/safe-apps-web3-react/package.json b/packages/safe-apps-web3-react/package.json index fd272a6b..35fbfa86 100644 --- a/packages/safe-apps-web3-react/package.json +++ b/packages/safe-apps-web3-react/package.json @@ -31,7 +31,7 @@ }, "devDependencies": { "@types/jest": "^26.0.24", - "@types/node": "^16.3.3", + "@types/node": "^16.4.10", "@web3-react/core": "6.1.9", "react": "17.0.2", "rimraf": "^3.0.2" diff --git a/packages/safe-apps-web3modal/package.json b/packages/safe-apps-web3modal/package.json index 8349bcd2..7caf57bc 100644 --- a/packages/safe-apps-web3modal/package.json +++ b/packages/safe-apps-web3modal/package.json @@ -25,7 +25,7 @@ "devDependencies": { "@gnosis.pm/safe-apps-sdk": "4.1.0-next.0", "rimraf": "^3.0.2", - "web3modal": "^1.9.3" + "web3modal": "^1.9.4" }, "peerDependencies": { "@gnosis.pm/safe-apps-sdk": "4.1.0-next.0", diff --git a/yarn.lock b/yarn.lock index 9264551c..ffefbac5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1790,10 +1790,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.15.tgz#10ee6a6a3f971966fddfa3f6e89ef7a73ec622df" integrity sha512-F6S4Chv4JicJmyrwlDkxUdGNSplsQdGwp1A0AJloEVDirWdZOAiRHhovDlsFkKUrquUXhz1imJhXHsf59auyAg== -"@types/node@^16.3.3": - version "16.3.3" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.3.3.tgz#0c30adff37bbbc7a50eb9b58fae2a504d0d88038" - integrity sha512-8h7k1YgQKxKXWckzFCMfsIwn0Y61UK6tlD6y2lOb3hTOIMlK3t9/QwHOhc81TwU+RMf0As5fj7NPjroERCnejQ== +"@types/node@^16.4.10": + version "16.4.10" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.4.10.tgz#e57e2a54fc6da58da94b3571b1cb456d39f88597" + integrity sha512-TmVHsm43br64js9BqHWqiDZA+xMtbUpI1MBIA0EyiBmoV9pcEYFOSdj5fr6enZNfh4fChh+AGOLIzGwJnkshyQ== "@types/normalize-package-data@^2.4.0": version "2.4.0" @@ -1865,73 +1865,73 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@^4.28.4": - version "4.28.4" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.28.4.tgz#e73c8cabbf3f08dee0e1bda65ed4e622ae8f8921" - integrity sha512-s1oY4RmYDlWMlcV0kKPBaADn46JirZzvvH7c2CtAqxCY96S538JRBAzt83RrfkDheV/+G/vWNK0zek+8TB3Gmw== +"@typescript-eslint/eslint-plugin@^4.28.5": + version "4.28.5" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.28.5.tgz#8197f1473e7da8218c6a37ff308d695707835684" + integrity sha512-m31cPEnbuCqXtEZQJOXAHsHvtoDi9OVaeL5wZnO2KZTnkvELk+u6J6jHg+NzvWQxk+87Zjbc4lJS4NHmgImz6Q== dependencies: - "@typescript-eslint/experimental-utils" "4.28.4" - "@typescript-eslint/scope-manager" "4.28.4" + "@typescript-eslint/experimental-utils" "4.28.5" + "@typescript-eslint/scope-manager" "4.28.5" debug "^4.3.1" functional-red-black-tree "^1.0.1" regexpp "^3.1.0" semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/experimental-utils@4.28.4": - version "4.28.4" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.28.4.tgz#9c70c35ebed087a5c70fb0ecd90979547b7fec96" - integrity sha512-OglKWOQRWTCoqMSy6pm/kpinEIgdcXYceIcH3EKWUl4S8xhFtN34GQRaAvTIZB9DD94rW7d/U7tUg3SYeDFNHA== +"@typescript-eslint/experimental-utils@4.28.5": + version "4.28.5" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.28.5.tgz#66c28bef115b417cf9d80812a713e0e46bb42a64" + integrity sha512-bGPLCOJAa+j49hsynTaAtQIWg6uZd8VLiPcyDe4QPULsvQwLHGLSGKKcBN8/lBxIX14F74UEMK2zNDI8r0okwA== dependencies: "@types/json-schema" "^7.0.7" - "@typescript-eslint/scope-manager" "4.28.4" - "@typescript-eslint/types" "4.28.4" - "@typescript-eslint/typescript-estree" "4.28.4" + "@typescript-eslint/scope-manager" "4.28.5" + "@typescript-eslint/types" "4.28.5" + "@typescript-eslint/typescript-estree" "4.28.5" eslint-scope "^5.1.1" eslint-utils "^3.0.0" -"@typescript-eslint/parser@^4.28.4": - version "4.28.4" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.28.4.tgz#bc462dc2779afeefdcf49082516afdc3e7b96fab" - integrity sha512-4i0jq3C6n+og7/uCHiE6q5ssw87zVdpUj1k6VlVYMonE3ILdFApEzTWgppSRG4kVNB/5jxnH+gTeKLMNfUelQA== +"@typescript-eslint/parser@^4.28.5": + version "4.28.5" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.28.5.tgz#9c971668f86d1b5c552266c47788a87488a47d1c" + integrity sha512-NPCOGhTnkXGMqTznqgVbA5LqVsnw+i3+XA1UKLnAb+MG1Y1rP4ZSK9GX0kJBmAZTMIktf+dTwXToT6kFwyimbw== dependencies: - "@typescript-eslint/scope-manager" "4.28.4" - "@typescript-eslint/types" "4.28.4" - "@typescript-eslint/typescript-estree" "4.28.4" + "@typescript-eslint/scope-manager" "4.28.5" + "@typescript-eslint/types" "4.28.5" + "@typescript-eslint/typescript-estree" "4.28.5" debug "^4.3.1" -"@typescript-eslint/scope-manager@4.28.4": - version "4.28.4" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.28.4.tgz#bdbce9b6a644e34f767bd68bc17bb14353b9fe7f" - integrity sha512-ZJBNs4usViOmlyFMt9X9l+X0WAFcDH7EdSArGqpldXu7aeZxDAuAzHiMAeI+JpSefY2INHrXeqnha39FVqXb8w== +"@typescript-eslint/scope-manager@4.28.5": + version "4.28.5" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.28.5.tgz#3a1b70c50c1535ac33322786ea99ebe403d3b923" + integrity sha512-PHLq6n9nTMrLYcVcIZ7v0VY1X7dK309NM8ya9oL/yG8syFINIMHxyr2GzGoBYUdv3NUfCOqtuqps0ZmcgnZTfQ== dependencies: - "@typescript-eslint/types" "4.28.4" - "@typescript-eslint/visitor-keys" "4.28.4" + "@typescript-eslint/types" "4.28.5" + "@typescript-eslint/visitor-keys" "4.28.5" -"@typescript-eslint/types@4.28.4": - version "4.28.4" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.28.4.tgz#41acbd79b5816b7c0dd7530a43d97d020d3aeb42" - integrity sha512-3eap4QWxGqkYuEmVebUGULMskR6Cuoc/Wii0oSOddleP4EGx1tjLnZQ0ZP33YRoMDCs5O3j56RBV4g14T4jvww== +"@typescript-eslint/types@4.28.5": + version "4.28.5" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.28.5.tgz#d33edf8e429f0c0930a7c3d44e9b010354c422e9" + integrity sha512-MruOu4ZaDOLOhw4f/6iudyks/obuvvZUAHBDSW80Trnc5+ovmViLT2ZMDXhUV66ozcl6z0LJfKs1Usldgi/WCA== -"@typescript-eslint/typescript-estree@4.28.4": - version "4.28.4" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.28.4.tgz#252e6863278dc0727244be9e371eb35241c46d00" - integrity sha512-z7d8HK8XvCRyN2SNp+OXC2iZaF+O2BTquGhEYLKLx5k6p0r05ureUtgEfo5f6anLkhCxdHtCf6rPM1p4efHYDQ== +"@typescript-eslint/typescript-estree@4.28.5": + version "4.28.5" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.28.5.tgz#4906d343de693cf3d8dcc301383ed638e0441cd1" + integrity sha512-FzJUKsBX8poCCdve7iV7ShirP8V+ys2t1fvamVeD1rWpiAnIm550a+BX/fmTHrjEpQJ7ZAn+Z7ZZwJjytk9rZw== dependencies: - "@typescript-eslint/types" "4.28.4" - "@typescript-eslint/visitor-keys" "4.28.4" + "@typescript-eslint/types" "4.28.5" + "@typescript-eslint/visitor-keys" "4.28.5" debug "^4.3.1" globby "^11.0.3" is-glob "^4.0.1" semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/visitor-keys@4.28.4": - version "4.28.4" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.28.4.tgz#92dacfefccd6751cbb0a964f06683bfd72d0c4d3" - integrity sha512-NIAXAdbz1XdOuzqkJHjNKXKj8QQ4cv5cxR/g0uQhCYf/6//XrmfpaYsM7PnBcNbfvTDLUkqQ5TPNm1sozDdTWg== +"@typescript-eslint/visitor-keys@4.28.5": + version "4.28.5" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.28.5.tgz#ffee2c602762ed6893405ee7c1144d9cc0a29675" + integrity sha512-dva/7Rr+EkxNWdJWau26xU/0slnFlkh88v3TsyTgRS/IIYFi5iIfpCFM4ikw0vQTFUR9FYSSyqgK4w64gsgxhg== dependencies: - "@typescript-eslint/types" "4.28.4" + "@typescript-eslint/types" "4.28.5" eslint-visitor-keys "^2.0.0" "@web3-react/abstract-connector@6.0.7", "@web3-react/abstract-connector@^6.0.7": @@ -3325,10 +3325,10 @@ eslint-module-utils@^2.6.1: debug "^3.2.7" pkg-dir "^2.0.0" -eslint-plugin-flowtype@^5.8.0: - version "5.8.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-5.8.0.tgz#35b55e4ce559b90efbe913ed33630e391e301481" - integrity sha512-feK1xnUTsMSNTOw9jFw7aVgZl7Ep+ghpta/YEoaV6jbXU6Yso30B7BIj9ObHLzZ5TFJL7D98az080wfykLCrcw== +eslint-plugin-flowtype@^5.8.2: + version "5.8.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-5.8.2.tgz#e8c4429f2d39d93ccb0732f581b159da16fa0bda" + integrity sha512-/aPTnNKNAYJbEU07HwvohnXp0itBT+P0r+7s80IG5eqfsrx4NLN+0rXNztJBc56u1RJegSn0GMt1cZnGZpCThw== dependencies: lodash "^4.17.15" string-natural-compare "^3.0.1" @@ -3433,10 +3433,10 @@ eslint-visitor-keys@^2.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== -eslint@7.31.0: - version "7.31.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.31.0.tgz#f972b539424bf2604907a970860732c5d99d3aca" - integrity sha512-vafgJpSh2ia8tnTkNUkwxGmnumgckLh5aAbLa1xRmIn9+owi8qBNGKL+B881kNKNTy7FFqTEkpNkUvmw0n6PkA== +eslint@7.32.0: + version "7.32.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.32.0.tgz#c6d328a14be3fb08c8d1d21e12c02fdb7a2a812d" + integrity sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA== dependencies: "@babel/code-frame" "7.12.11" "@eslint/eslintrc" "^0.4.3" @@ -7617,10 +7617,10 @@ trim-off-newlines@^1.0.0: resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= -ts-jest@^27.0.3: - version "27.0.3" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.0.3.tgz#808492f022296cde19390bb6ad627c8126bf93f8" - integrity sha512-U5rdMjnYam9Ucw+h0QvtNDbc5+88nxt7tbIvqaZUhFrfG4+SkWhMXjejCLVGcpILTPuV+H3W/GZDZrnZFpPeXw== +ts-jest@^27.0.4: + version "27.0.4" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.0.4.tgz#df49683535831560ccb58f94c023d831b1b80df0" + integrity sha512-c4E1ECy9Xz2WGfTMyHbSaArlIva7Wi2p43QOMmCqjSSjHP06KXv+aT+eSY+yZMuqsMi3k7pyGsGj2q5oSl5WfQ== dependencies: bs-logger "0.x" buffer-from "1.x" @@ -7899,10 +7899,10 @@ wcwidth@^1.0.0, wcwidth@^1.0.1: dependencies: defaults "^1.0.3" -web3modal@^1.9.3: - version "1.9.3" - resolved "https://registry.yarnpkg.com/web3modal/-/web3modal-1.9.3.tgz#d965e565875ad70684fb7e735a69c719eb5e8d07" - integrity sha512-Z8mVHeTFa9eBNKvRipJfZDoJgeHBbh/WDLjzZZLgFmoBJgT81mc5blnh4mUjtButLCJAouV8iN4+2c5ebYvJFA== +web3modal@^1.9.4: + version "1.9.4" + resolved "https://registry.yarnpkg.com/web3modal/-/web3modal-1.9.4.tgz#c5f9b88ec38b22f1efd6960968c68fbdf1e0c4c8" + integrity sha512-hnbdbOjkntVFcFliXT9whb8rMk8FJ+dkQIyZlDxTnQ3pHnGTEMNCsWetA6j7CTQd5xwzdq1lYgcswXeFmSf/mA== dependencies: detect-browser "^5.1.0" prop-types "^15.7.2"