@celo/connect
Advanced tools
Comparing version 2.1.0 to 2.2.0-alpha.1
@@ -60,2 +60,6 @@ "use strict"; | ||
InterceptedMethods["signTypedData"] = "eth_signTypedData"; | ||
InterceptedMethods["signTypedDataV1"] = "eth_signTypedData_v1"; | ||
InterceptedMethods["signTypedDataV3"] = "eth_signTypedData_v3"; | ||
InterceptedMethods["signTypedDataV4"] = "eth_signTypedData_v4"; | ||
InterceptedMethods["signTypedDataV5"] = "eth_signTypedData_v5"; | ||
})(InterceptedMethods || (InterceptedMethods = {})); | ||
@@ -155,3 +159,7 @@ function assertIsCeloProvider(provider) { | ||
} | ||
case InterceptedMethods.signTypedData: { | ||
case InterceptedMethods.signTypedData: | ||
case InterceptedMethods.signTypedDataV1: | ||
case InterceptedMethods.signTypedDataV3: | ||
case InterceptedMethods.signTypedDataV4: | ||
case InterceptedMethods.signTypedDataV5: { | ||
this.checkPayloadWithAtLeastNParams(payload, 1); | ||
@@ -182,3 +190,3 @@ address = payload.params[0]; | ||
catch (error) { | ||
debug("Failed to close the connection: " + error); | ||
debug("Failed to close the connection: ".concat(error)); | ||
} | ||
@@ -185,0 +193,0 @@ }; |
@@ -75,4 +75,4 @@ import { EIP712TypedData } from '@celo/utils/lib/sign-typed-data-utils'; | ||
sendTransaction: (tx: CeloTx) => Promise<TransactionResult>; | ||
sendTransactionObject: (txObj: CeloTxObject<any>, tx?: Omit<CeloTx, "data"> | undefined) => Promise<TransactionResult>; | ||
signTypedData: (signer: string, typedData: EIP712TypedData) => Promise<Signature>; | ||
sendTransactionObject: (txObj: CeloTxObject<any>, tx?: Omit<CeloTx, 'data'>) => Promise<TransactionResult>; | ||
signTypedData: (signer: string, typedData: EIP712TypedData, version?: 1 | 3 | 4 | 5) => Promise<Signature>; | ||
sign: (dataToSign: string, address: Address | number) => Promise<string>; | ||
@@ -91,3 +91,3 @@ sendSignedTransaction: (signedTransactionData: string) => Promise<TransactionResult>; | ||
coinbase: () => Promise<string>; | ||
gasPrice: (feeCurrency?: string | undefined) => Promise<string>; | ||
gasPrice: (feeCurrency?: Address) => Promise<string>; | ||
getBlockNumber: () => Promise<number>; | ||
@@ -97,3 +97,3 @@ private isBlockNumberHash; | ||
getBlockHeader: (blockHashOrBlockNumber: BlockNumber) => Promise<BlockHeader>; | ||
getBalance: (address: Address, defaultBlock?: BlockNumber | undefined) => Promise<string>; | ||
getBalance: (address: Address, defaultBlock?: BlockNumber) => Promise<string>; | ||
getTransaction: (transactionHash: string) => Promise<CeloTxPending>; | ||
@@ -100,0 +100,0 @@ getTransactionReceipt: (txhash: string) => Promise<CeloTxReceipt | null>; |
@@ -74,4 +74,4 @@ "use strict"; | ||
function Connection(web3, wallet, handleRevert) { | ||
if (handleRevert === void 0) { handleRevert = true; } | ||
var _this = this; | ||
if (handleRevert === void 0) { handleRevert = true; } | ||
var _a; | ||
@@ -137,26 +137,38 @@ this.web3 = web3; | ||
}); }; | ||
this.signTypedData = function (signer, typedData) { return __awaiter(_this, void 0, void 0, function () { | ||
var signature, messageHash; | ||
/* | ||
* @param signer - The address of account signing this data | ||
* @param typedData - Structured data to be signed | ||
* @param version - Optionally provide a version which will be appended to the method. E.G. (4) becomes 'eth_signTypedData_v4' | ||
* @remarks Some providers like Metamask treat eth_signTypedData differently from versioned method eth_signTypedData_v4 | ||
* @see [Metamask info in signing Typed Data](https://docs.metamask.io/guide/signing-data.html) | ||
*/ | ||
this.signTypedData = function (signer, typedData, version) { return __awaiter(_this, void 0, void 0, function () { | ||
var shouldStringify, signature, messageHash; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) { | ||
; | ||
_this.web3.currentProvider.send({ | ||
id: (0, rpc_caller_1.getRandomId)(), | ||
jsonrpc: '2.0', | ||
method: 'eth_signTypedData', | ||
params: [(0, formatter_1.inputAddressFormatter)(signer), typedData], | ||
}, function (error, resp) { | ||
if (error) { | ||
reject(error); | ||
} | ||
else if (resp) { | ||
resolve(resp.result); | ||
} | ||
else { | ||
reject(new Error('empty-response')); | ||
} | ||
}); | ||
})]; | ||
case 0: | ||
shouldStringify = version === 3 || version === 4; | ||
return [4 /*yield*/, new Promise(function (resolve, reject) { | ||
var method = version ? "eth_signTypedData_v".concat(version) : 'eth_signTypedData'; | ||
_this.web3.currentProvider.send({ | ||
id: (0, rpc_caller_1.getRandomId)(), | ||
jsonrpc: '2.0', | ||
method: method, | ||
params: [ | ||
(0, formatter_1.inputAddressFormatter)(signer), | ||
shouldStringify ? JSON.stringify(typedData) : typedData, | ||
], | ||
}, function (error, resp) { | ||
if (error) { | ||
reject(error); | ||
} | ||
else if (resp) { | ||
resolve(resp.result); | ||
} | ||
else { | ||
reject(new Error('empty-response')); | ||
} | ||
}); | ||
})]; | ||
case 1: | ||
@@ -235,3 +247,3 @@ signature = _a.sent(); | ||
}); | ||
return [2 /*return*/, Promise.reject("Gas estimation failed: " + revertReason + " or " + e_1)]; | ||
return [2 /*return*/, Promise.reject("Gas estimation failed: ".concat(revertReason, " or ").concat(e_1))]; | ||
case 4: return [2 /*return*/]; | ||
@@ -238,0 +250,0 @@ } |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -30,3 +30,3 @@ "use strict"; | ||
if (matches == null) { | ||
throw new Error(fnSignature + " is malformed"); | ||
throw new Error("".concat(fnSignature, " is malformed")); | ||
} | ||
@@ -45,6 +45,6 @@ var method = matches.groups.method; | ||
if (parts.length > 2) { | ||
throw new Error(fnSignature + " is malformed"); | ||
throw new Error("".concat(fnSignature, " is malformed")); | ||
} | ||
return { | ||
name: parts.length > 1 ? parts[1] : "a" + index, | ||
name: parts.length > 1 ? parts[1] : "a".concat(index), | ||
type: parts[0], | ||
@@ -51,0 +51,0 @@ }; |
@@ -12,5 +12,5 @@ import { Connection } from '../connection'; | ||
/** send the transaction to the chain */ | ||
send: (params?: CeloTransactionParams | undefined) => Promise<TransactionResult>; | ||
send: (params?: CeloTransactionParams) => Promise<TransactionResult>; | ||
/** send the transaction and waits for the receipt */ | ||
sendAndWaitForReceipt: (params?: CeloTransactionParams | undefined) => Promise<CeloTxReceipt>; | ||
sendAndWaitForReceipt: (params?: CeloTransactionParams) => Promise<CeloTxReceipt>; | ||
} |
@@ -192,3 +192,3 @@ "use strict"; | ||
} | ||
throw new Error("Provided address " + address + " is invalid, the capitalization checksum test failed"); | ||
throw new Error("Provided address ".concat(address, " is invalid, the capitalization checksum test failed")); | ||
} | ||
@@ -228,3 +228,3 @@ exports.inputAddressFormatter = inputAddressFormatter; | ||
// Seen in web3, copied just in case | ||
return numberValue.lt(new bignumber_js_1.default(0)) ? "-" + result : result; | ||
return numberValue.lt(new bignumber_js_1.default(0)) ? "-".concat(result) : result; | ||
} | ||
@@ -231,0 +231,0 @@ return undefined; |
{ | ||
"name": "@celo/connect", | ||
"version": "2.1.0", | ||
"version": "2.2.0-alpha.1", | ||
"description": "Light Toolkit for connecting with the Celo network", | ||
@@ -27,3 +27,4 @@ "main": "./lib/index.js", | ||
"@types/utf8": "^2.1.6", | ||
"@celo/utils": "2.1.0", | ||
"@celo/base": "2.2.0-alpha.1", | ||
"@celo/utils": "2.2.0-alpha.1", | ||
"bignumber.js": "^9.0.0", | ||
@@ -30,0 +31,0 @@ "debug": "^4.1.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
149410
43
2151
8
2
+ Added@celo/base@2.2.0-alpha.1
+ Added@celo/base@2.2.0-alpha.1(transitive)
+ Added@celo/utils@2.2.0-alpha.1(transitive)
- Removed@celo/base@2.1.0(transitive)
- Removed@celo/utils@2.1.0(transitive)
Updated@celo/utils@2.2.0-alpha.1