Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@uniswap/conedison

Package Overview
Dependencies
Maintainers
17
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniswap/conedison - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

dist/walletconnect.d.ts

8

dist/provider.d.ts
import type { TypedDataDomain, TypedDataField } from '@ethersproject/abstract-signer';
import type { JsonRpcSigner } from '@ethersproject/providers';
export declare const INVALID_PARAMS_CODE = -32602;
/**
* Calls into the eth_signTypedData methods to add support for wallets with spotty EIP-712 support (eg Safepal) or without any (eg Zerion),
* by first trying eth_signTypedData, and then falling back to either eth_signTyepdData_v4 or eth_sign.
* The implementation is copied from ethers (and linted).
* Signs TypedData with EIP-712, if available, or else by falling back to eth_sign.
* Calls eth_signTypedData_v4, or eth_signTypedData for wallets with incomplete EIP-712 support.
*
* @see https://github.com/ethers-io/ethers.js/blob/c80fcddf50a9023486e9f9acb1848aba4c19f7b6/packages/providers/src.ts/json-rpc-provider.ts#L334
* TODO(https://github.com/ethers-io/ethers.js/pull/3667): Remove if upstreamed.
*/
export declare function signTypedData(signer: JsonRpcSigner, domain: TypedDataDomain, types: Record<string, TypedDataField[]>, value: Record<string, any>): Promise<any>;

@@ -38,10 +38,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { _TypedDataEncoder } from '@ethersproject/hash';
// See https://github.com/MetaMask/eth-rpc-errors/blob/b19c8724168eec4ce3f8b1f87642f231f0dd27b2/src/error-constants.ts#L12
export var INVALID_PARAMS_CODE = -32602;
import { getPeerMeta } from './walletconnect';
// These are wallets which do not implement eth_signTypedData_v4, but *do* implement eth_signTypedData.
// They are special-cased so that signing will still use EIP-712 (which is safer for the user).
var WALLETS_LACKING_V4_SUPPORT = ['SafePal Wallet'];
function supportsV4(provider) {
var _a;
var name = (_a = getPeerMeta(provider)) === null || _a === void 0 ? void 0 : _a.name;
// By default, we assume v4 support.
if (name && WALLETS_LACKING_V4_SUPPORT.includes(name)) {
return false;
}
return true;
}
/**
* Calls into the eth_signTypedData methods to add support for wallets with spotty EIP-712 support (eg Safepal) or without any (eg Zerion),
* by first trying eth_signTypedData, and then falling back to either eth_signTyepdData_v4 or eth_sign.
* The implementation is copied from ethers (and linted).
* Signs TypedData with EIP-712, if available, or else by falling back to eth_sign.
* Calls eth_signTypedData_v4, or eth_signTypedData for wallets with incomplete EIP-712 support.
*
* @see https://github.com/ethers-io/ethers.js/blob/c80fcddf50a9023486e9f9acb1848aba4c19f7b6/packages/providers/src.ts/json-rpc-provider.ts#L334
* TODO(https://github.com/ethers-io/ethers.js/pull/3667): Remove if upstreamed.
*/

@@ -53,3 +63,3 @@ export function signTypedData(signer, domain, types,

return __awaiter(this, void 0, void 0, function () {
var populated, address, error_1, error_2, hash;
var populated, method, address, message, error_1, hash;
return __generator(this, function (_a) {

@@ -62,38 +72,21 @@ switch (_a.label) {

populated = _a.sent();
method = supportsV4(signer.provider) ? 'eth_signTypedData_v4' : 'eth_signTypedData';
return [4 /*yield*/, signer.getAddress()];
case 2:
address = _a.sent();
address = (_a.sent()).toLowerCase();
message = JSON.stringify(_TypedDataEncoder.getPayload(populated.domain, types, populated.value));
_a.label = 3;
case 3:
_a.trys.push([3, 10, , 13]);
_a.label = 4;
case 4:
_a.trys.push([4, 6, , 9]);
return [4 /*yield*/, signer.provider.send('eth_signTypedData', [
address.toLowerCase(),
JSON.stringify(_TypedDataEncoder.getPayload(populated.domain, types, populated.value)),
])];
case 5:
// We must try the unversioned eth_signTypedData first, because some wallets (eg SafePal) will hang on _v4.
return [2 /*return*/, _a.sent()];
case 6:
_a.trys.push([3, 5, , 8]);
return [4 /*yield*/, signer.provider.send(method, [address, message])];
case 4: return [2 /*return*/, _a.sent()];
case 5:
error_1 = _a.sent();
if (!(error_1.code === INVALID_PARAMS_CODE)) return [3 /*break*/, 8];
console.warn('eth_signTypedData failed, falling back to eth_signTypedData_v4:', error_1);
return [4 /*yield*/, signer.provider.send('eth_signTypedData_v4', [
address.toLowerCase(),
JSON.stringify(_TypedDataEncoder.getPayload(populated.domain, types, populated.value)),
])];
case 7: return [2 /*return*/, _a.sent()];
case 8: throw error_1;
case 9: return [3 /*break*/, 13];
case 10:
error_2 = _a.sent();
if (!(typeof error_2.message === 'string' && error_2.message.match(/not found/i))) return [3 /*break*/, 12];
console.warn('eth_signTypedData_* failed, falling back to eth_sign:', error_2);
if (!(typeof error_1.message === 'string' && error_1.message.match(/not (found|implemented)/i))) return [3 /*break*/, 7];
console.warn('signTypedData: wallet does not implement EIP-712, falling back to eth_sign', error_1.message);
hash = _TypedDataEncoder.hash(populated.domain, types, populated.value);
return [4 /*yield*/, signer.provider.send('eth_sign', [address, hash])];
case 11: return [2 /*return*/, _a.sent()];
case 12: throw error_2;
case 13: return [2 /*return*/];
case 6: return [2 /*return*/, _a.sent()];
case 7: throw error_1;
case 8: return [2 /*return*/];
}

@@ -100,0 +93,0 @@ });

{
"name": "@uniswap/conedison",
"version": "1.2.1",
"version": "1.3.0",
"description": "Utilities for Uniswap front-end development",

@@ -51,2 +51,3 @@ "repository": "https://github.com/Uniswap/conedison",

"@uniswap/sdk-core": "^3.1.0",
"@walletconnect/ethereum-provider": "^1.8.0",
"babel-jest": "^29.3.0",

@@ -68,4 +69,5 @@ "eslint": "^8.27.0",

"@uniswap/sdk-core": ">=3",
"@walletconnect/ethereum-provider": "^1.8.0",
"ethers": "^5.6.1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc