@celo/connect
Advanced tools
Comparing version 5.1.1 to 5.1.2-beta.0
# @celo/connect | ||
## 5.1.2-beta.0 | ||
### Patch Changes | ||
- Updated dependencies [[`6b2e34c`](https://github.com/celo-org/developer-tooling/commit/6b2e34c973290da221aaabdc2bf4c6654ef9f99c)]: | ||
- @celo/utils@6.0.0-beta.0 | ||
## 5.1.1 | ||
@@ -4,0 +11,0 @@ |
import { EventLog } from './types'; | ||
/** @internal */ | ||
export declare type ABIType = 'uint256' | 'boolean' | 'string' | 'bytes' | string; | ||
export type ABIType = 'uint256' | 'boolean' | 'string' | 'bytes' | string; | ||
/** @internal */ | ||
@@ -13,4 +13,4 @@ export interface DecodedParamsArray { | ||
} | ||
declare type AbiType = 'function' | 'constructor' | 'event' | 'fallback'; | ||
declare type StateMutabilityType = 'pure' | 'view' | 'nonpayable' | 'payable'; | ||
type AbiType = 'function' | 'constructor' | 'event' | 'fallback'; | ||
type StateMutabilityType = 'pure' | 'view' | 'nonpayable' | 'payable'; | ||
/** @internal */ | ||
@@ -17,0 +17,0 @@ export interface AbiInput { |
@@ -11,29 +11,2 @@ "use strict"; | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -44,11 +17,11 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
exports.CeloProvider = exports.assertIsCeloProvider = void 0; | ||
var lock_1 = require("@celo/base/lib/lock"); | ||
var debug_1 = __importDefault(require("debug")); | ||
var provider_utils_1 = require("./utils/provider-utils"); | ||
var rpc_caller_1 = require("./utils/rpc-caller"); | ||
var debug = (0, debug_1.default)('provider:connection'); | ||
var debugPayload = (0, debug_1.default)('provider:payload'); | ||
var debugTxToSend = (0, debug_1.default)('provider:tx-to-send'); | ||
var debugEncodedTx = (0, debug_1.default)('provider:encoded-tx'); | ||
var debugResponse = (0, debug_1.default)('provider:response'); | ||
const lock_1 = require("@celo/base/lib/lock"); | ||
const debug_1 = __importDefault(require("debug")); | ||
const provider_utils_1 = require("./utils/provider-utils"); | ||
const rpc_caller_1 = require("./utils/rpc-caller"); | ||
const debug = (0, debug_1.default)('provider:connection'); | ||
const debugPayload = (0, debug_1.default)('provider:payload'); | ||
const debugTxToSend = (0, debug_1.default)('provider:tx-to-send'); | ||
const debugEncodedTx = (0, debug_1.default)('provider:encoded-tx'); | ||
const debugResponse = (0, debug_1.default)('provider:response'); | ||
var InterceptedMethods; | ||
@@ -76,4 +49,4 @@ (function (InterceptedMethods) { | ||
*/ | ||
var CeloProvider = /** @class */ (function () { | ||
function CeloProvider(existingProvider, connection) { | ||
class CeloProvider { | ||
constructor(existingProvider, connection) { | ||
this.existingProvider = existingProvider; | ||
@@ -90,28 +63,26 @@ this.connection = connection; | ||
// @deprecated Use the `addAccount` from the Connection | ||
CeloProvider.prototype.addAccount = function (privateKey) { | ||
addAccount(privateKey) { | ||
this.connection.addAccount(privateKey); | ||
}; | ||
} | ||
// @deprecated Use the `removeAccount` from the Connection | ||
CeloProvider.prototype.removeAccount = function (address) { | ||
removeAccount(address) { | ||
this.connection.removeAccount(address); | ||
}; | ||
} | ||
// @deprecated Use the `getAccounts` from the Connection | ||
CeloProvider.prototype.getAccounts = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.connection.getAccounts()]; | ||
}); | ||
getAccounts() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.connection.getAccounts(); | ||
}); | ||
}; | ||
CeloProvider.prototype.isLocalAccount = function (address) { | ||
} | ||
isLocalAccount(address) { | ||
return this.connection.wallet != null && this.connection.wallet.hasAccount(address); | ||
}; | ||
} | ||
/** | ||
* Send method as expected by web3.js | ||
*/ | ||
CeloProvider.prototype.send = function (payload, callback) { | ||
var txParams; | ||
var address; | ||
send(payload, callback) { | ||
let txParams; | ||
let address; | ||
debugPayload('%O', payload); | ||
var decoratedCallback = function (error, result) { | ||
const decoratedCallback = (error, result) => { | ||
debugResponse('%O', result); | ||
@@ -182,4 +153,4 @@ callback(error, result); | ||
} | ||
}; | ||
CeloProvider.prototype.stop = function () { | ||
} | ||
stop() { | ||
if (this.alreadyStopped) { | ||
@@ -193,91 +164,60 @@ return; | ||
catch (error) { | ||
debug("Failed to close the connection: ".concat(error)); | ||
debug(`Failed to close the connection: ${error}`); | ||
} | ||
}; | ||
CeloProvider.prototype.handleAccounts = function (_payload) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.connection.getAccounts()]; | ||
}); | ||
} | ||
handleAccounts(_payload) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.connection.getAccounts(); | ||
}); | ||
}; | ||
CeloProvider.prototype.handleSignTypedData = function (payload) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, address, typedData, signature; | ||
return __generator(this, function (_b) { | ||
_a = payload.params, address = _a[0], typedData = _a[1]; | ||
signature = this.connection.wallet.signTypedData(address, typedData); | ||
return [2 /*return*/, signature]; | ||
}); | ||
} | ||
handleSignTypedData(payload) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const [address, typedData] = payload.params; | ||
const signature = this.connection.wallet.signTypedData(address, typedData); | ||
return signature; | ||
}); | ||
}; | ||
CeloProvider.prototype.handleSignPersonalMessage = function (payload) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var address, data, ecSignatureHex; | ||
return __generator(this, function (_a) { | ||
address = payload.method === 'eth_sign' ? payload.params[0] : payload.params[1]; | ||
data = payload.method === 'eth_sign' ? payload.params[1] : payload.params[0]; | ||
ecSignatureHex = this.connection.wallet.signPersonalMessage(address, data); | ||
return [2 /*return*/, ecSignatureHex]; | ||
}); | ||
} | ||
handleSignPersonalMessage(payload) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const address = payload.method === 'eth_sign' ? payload.params[0] : payload.params[1]; | ||
const data = payload.method === 'eth_sign' ? payload.params[1] : payload.params[0]; | ||
const ecSignatureHex = this.connection.wallet.signPersonalMessage(address, data); | ||
return ecSignatureHex; | ||
}); | ||
}; | ||
CeloProvider.prototype.handleSignTransaction = function (payload) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var txParams, filledParams, signedTx; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
txParams = payload.params[0]; | ||
return [4 /*yield*/, this.connection.paramsPopulator.populate(txParams)]; | ||
case 1: | ||
filledParams = _a.sent(); | ||
debugTxToSend('%O', filledParams); | ||
return [4 /*yield*/, this.connection.wallet.signTransaction(filledParams)]; | ||
case 2: | ||
signedTx = _a.sent(); | ||
debugEncodedTx('%O', signedTx); | ||
return [2 /*return*/, signedTx]; | ||
} | ||
}); | ||
} | ||
handleSignTransaction(payload) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const txParams = payload.params[0]; | ||
const filledParams = yield this.connection.paramsPopulator.populate(txParams); | ||
debugTxToSend('%O', filledParams); | ||
const signedTx = yield this.connection.wallet.signTransaction(filledParams); | ||
debugEncodedTx('%O', signedTx); | ||
return signedTx; | ||
}); | ||
}; | ||
CeloProvider.prototype.handleSendTransaction = function (payload) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var signedTx, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.nonceLock.acquire()]; | ||
case 1: | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: | ||
_a.trys.push([2, , 5, 6]); | ||
return [4 /*yield*/, this.handleSignTransaction(payload)]; | ||
case 3: | ||
signedTx = _a.sent(); | ||
return [4 /*yield*/, this.connection.rpcCaller.call('eth_sendRawTransaction', [ | ||
signedTx.raw, | ||
])]; | ||
case 4: | ||
response = _a.sent(); | ||
return [2 /*return*/, response.result]; | ||
case 5: | ||
this.nonceLock.release(); | ||
return [7 /*endfinally*/]; | ||
case 6: return [2 /*return*/]; | ||
} | ||
}); | ||
} | ||
handleSendTransaction(payload) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.nonceLock.acquire(); | ||
try { | ||
const signedTx = yield this.handleSignTransaction(payload); | ||
const response = yield this.connection.rpcCaller.call('eth_sendRawTransaction', [ | ||
signedTx.raw, | ||
]); | ||
return response.result; | ||
} | ||
finally { | ||
this.nonceLock.release(); | ||
} | ||
}); | ||
}; | ||
CeloProvider.prototype.forwardSend = function (payload, callback) { | ||
} | ||
forwardSend(payload, callback) { | ||
this.connection.rpcCaller.send(payload, callback); | ||
}; | ||
CeloProvider.prototype.checkPayloadWithAtLeastNParams = function (payload, n) { | ||
} | ||
checkPayloadWithAtLeastNParams(payload, n) { | ||
if (!payload.params || payload.params.length < n) { | ||
throw Error('Invalid params'); | ||
} | ||
}; | ||
} | ||
// Functions required to act as a delefator for the existingProvider | ||
CeloProvider.prototype.addProviderDelegatedFunctions = function () { | ||
addProviderDelegatedFunctions() { | ||
if ((0, provider_utils_1.hasProperty)(this.existingProvider, 'on')) { | ||
@@ -303,36 +243,31 @@ // @ts-ignore | ||
} | ||
}; | ||
Object.defineProperty(CeloProvider.prototype, "connected", { | ||
get: function () { | ||
return this.existingProvider.connected; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
CeloProvider.prototype.supportsSubscriptions = function () { | ||
} | ||
get connected() { | ||
return this.existingProvider.connected; | ||
} | ||
supportsSubscriptions() { | ||
return this.existingProvider.supportsSubscriptions(); | ||
}; | ||
CeloProvider.prototype.defaultOn = function (type, callback) { | ||
} | ||
defaultOn(type, callback) { | ||
; | ||
this.existingProvider.on(type, callback); | ||
}; | ||
CeloProvider.prototype.defaultOnce = function (type, callback) { | ||
} | ||
defaultOnce(type, callback) { | ||
; | ||
this.existingProvider.once(type, callback); | ||
}; | ||
CeloProvider.prototype.defaultRemoveListener = function (type, callback) { | ||
} | ||
defaultRemoveListener(type, callback) { | ||
; | ||
this.existingProvider.removeListener(type, callback); | ||
}; | ||
CeloProvider.prototype.defaultRemoveAllListeners = function (type) { | ||
} | ||
defaultRemoveAllListeners(type) { | ||
; | ||
this.existingProvider.removeAllListeners(type); | ||
}; | ||
CeloProvider.prototype.defaultReset = function () { | ||
} | ||
defaultReset() { | ||
; | ||
this.existingProvider.reset(); | ||
}; | ||
return CeloProvider; | ||
}()); | ||
} | ||
} | ||
exports.CeloProvider = CeloProvider; | ||
//# sourceMappingURL=celo-provider.js.map |
@@ -10,3 +10,3 @@ import { EIP712TypedData } from '@celo/utils/lib/sign-typed-data-utils'; | ||
import { ReadOnlyWallet } from './wallet'; | ||
declare type BN = ReturnType<Web3['utils']['toBN']>; | ||
type BN = ReturnType<Web3['utils']['toBN']>; | ||
export interface ConnectionOptions { | ||
@@ -13,0 +13,0 @@ gasInflationFactor: number; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -22,29 +11,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -56,16 +18,16 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
// tslint:disable: ordered-imports | ||
var address_1 = require("@celo/utils/lib/address"); | ||
var sign_typed_data_utils_1 = require("@celo/utils/lib/sign-typed-data-utils"); | ||
var signatureUtils_1 = require("@celo/utils/lib/signatureUtils"); | ||
var util_1 = require("@ethereumjs/util"); | ||
var debug_1 = __importDefault(require("debug")); | ||
var web3_1 = __importDefault(require("web3")); | ||
var celo_provider_1 = require("./celo-provider"); | ||
var abi_utils_1 = require("./utils/abi-utils"); | ||
var formatter_1 = require("./utils/formatter"); | ||
var provider_utils_1 = require("./utils/provider-utils"); | ||
var rpc_caller_1 = require("./utils/rpc-caller"); | ||
var tx_params_normalizer_1 = require("./utils/tx-params-normalizer"); | ||
var tx_result_1 = require("./utils/tx-result"); | ||
var debugGasEstimation = (0, debug_1.default)('connection:gas-estimation'); | ||
const address_1 = require("@celo/utils/lib/address"); | ||
const sign_typed_data_utils_1 = require("@celo/utils/lib/sign-typed-data-utils"); | ||
const signatureUtils_1 = require("@celo/utils/lib/signatureUtils"); | ||
const util_1 = require("@ethereumjs/util"); | ||
const debug_1 = __importDefault(require("debug")); | ||
const web3_1 = __importDefault(require("web3")); | ||
const celo_provider_1 = require("./celo-provider"); | ||
const abi_utils_1 = require("./utils/abi-utils"); | ||
const formatter_1 = require("./utils/formatter"); | ||
const provider_utils_1 = require("./utils/provider-utils"); | ||
const rpc_caller_1 = require("./utils/rpc-caller"); | ||
const tx_params_normalizer_1 = require("./utils/tx-params-normalizer"); | ||
const tx_result_1 = require("./utils/tx-result"); | ||
const debugGasEstimation = (0, debug_1.default)('connection:gas-estimation'); | ||
/** | ||
@@ -77,14 +39,12 @@ * Connection is a Class for connecting to Celo, sending Transactions, etc | ||
*/ | ||
var Connection = /** @class */ (function () { | ||
function Connection(web3, wallet, handleRevert) { | ||
if (handleRevert === void 0) { handleRevert = true; } | ||
var _this = this; | ||
class Connection { | ||
constructor(web3, wallet, handleRevert = true) { | ||
var _a; | ||
this.web3 = web3; | ||
this.wallet = wallet; | ||
this.keccak256 = function (value) { | ||
return _this.web3.utils.keccak256(value); | ||
this.keccak256 = (value) => { | ||
return this.web3.utils.keccak256(value); | ||
}; | ||
this.hexToAscii = function (hex) { | ||
return _this.web3.utils.hexToAscii(hex); | ||
this.hexToAscii = (hex) => { | ||
return this.web3.utils.hexToAscii(hex); | ||
}; | ||
@@ -99,41 +59,24 @@ /** | ||
*/ | ||
this.sendTransaction = function (tx) { return __awaiter(_this, void 0, void 0, function () { | ||
var gas; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
tx = this.fillTxDefaults(tx); | ||
gas = tx.gas; | ||
if (!(gas == null)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.estimateGasWithInflationFactor(tx)]; | ||
case 1: | ||
gas = _a.sent(); | ||
_a.label = 2; | ||
case 2: return [2 /*return*/, (0, tx_result_1.toTxResult)(this.web3.eth.sendTransaction(__assign(__assign({}, tx), { gas: gas })))]; | ||
} | ||
}); | ||
}); }; | ||
this.sendTransactionObject = function (txObj, tx) { return __awaiter(_this, void 0, void 0, function () { | ||
var gas, gasEstimator, getCallTx_1, caller; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
tx = this.fillTxDefaults(tx); | ||
gas = tx.gas; | ||
if (!(gas == null)) return [3 /*break*/, 2]; | ||
gasEstimator = function (_tx) { return txObj.estimateGas(__assign({}, _tx)); }; | ||
getCallTx_1 = function (_tx) { | ||
// @ts-ignore missing _parent property from TransactionObject type. | ||
return __assign(__assign({}, _tx), { data: txObj.encodeABI(), to: txObj._parent._address }); | ||
}; | ||
caller = function (_tx) { return _this.web3.eth.call(getCallTx_1(_tx)); }; | ||
return [4 /*yield*/, this.estimateGasWithInflationFactor(tx, gasEstimator, caller)]; | ||
case 1: | ||
gas = _a.sent(); | ||
_a.label = 2; | ||
case 2: return [2 /*return*/, (0, tx_result_1.toTxResult)(txObj.send(__assign(__assign({}, tx), { gas: gas })))]; | ||
} | ||
}); | ||
}); }; | ||
this.sendTransaction = (tx) => __awaiter(this, void 0, void 0, function* () { | ||
tx = this.fillTxDefaults(tx); | ||
let gas = tx.gas; | ||
if (gas == null) { | ||
gas = yield this.estimateGasWithInflationFactor(tx); | ||
} | ||
return (0, tx_result_1.toTxResult)(this.web3.eth.sendTransaction(Object.assign(Object.assign({}, tx), { gas }))); | ||
}); | ||
this.sendTransactionObject = (txObj, tx) => __awaiter(this, void 0, void 0, function* () { | ||
tx = this.fillTxDefaults(tx); | ||
let gas = tx.gas; | ||
if (gas == null) { | ||
const gasEstimator = (_tx) => txObj.estimateGas(Object.assign({}, _tx)); | ||
const getCallTx = (_tx) => { | ||
// @ts-ignore missing _parent property from TransactionObject type. | ||
return Object.assign(Object.assign({}, _tx), { data: txObj.encodeABI(), to: txObj._parent._address }); | ||
}; | ||
const caller = (_tx) => this.web3.eth.call(getCallTx(_tx)); | ||
gas = yield this.estimateGasWithInflationFactor(tx, gasEstimator, caller); | ||
} | ||
return (0, tx_result_1.toTxResult)(txObj.send(Object.assign(Object.assign({}, tx), { gas }))); | ||
}); | ||
/* | ||
@@ -146,308 +89,193 @@ * @param signer - The address of account signing this data | ||
*/ | ||
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: | ||
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: | ||
signature = _a.sent(); | ||
messageHash = (0, util_1.bufferToHex)((0, sign_typed_data_utils_1.generateTypedDataHash)(typedData)); | ||
return [2 /*return*/, (0, signatureUtils_1.parseSignatureWithoutPrefix)(messageHash, signature, signer)]; | ||
} | ||
}); | ||
}); }; | ||
this.sign = function (dataToSign, address) { return __awaiter(_this, void 0, void 0, function () { | ||
var signature; | ||
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_sign', | ||
params: [(0, formatter_1.inputAddressFormatter)(address.toString()), (0, formatter_1.inputSignFormatter)(dataToSign)], | ||
}, function (error, resp) { | ||
if (error) { | ||
reject(error); | ||
} | ||
else if (resp) { | ||
resolve(resp.result); | ||
} | ||
else { | ||
reject(new Error('empty-response')); | ||
} | ||
}); | ||
})]; | ||
case 1: | ||
signature = _a.sent(); | ||
return [2 /*return*/, signature]; | ||
} | ||
}); | ||
}); }; | ||
this.sendSignedTransaction = function (signedTransactionData) { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, tx_result_1.toTxResult)(this.web3.eth.sendSignedTransaction(signedTransactionData))]; | ||
}); | ||
}); }; | ||
// if neither gas price nor feeMarket fields are present set them. | ||
this.setFeeMarketGas = function (tx) { return __awaiter(_this, void 0, void 0, function () { | ||
var calls, _a, maxFeePerGas, maxPriorityFeePerGas; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
calls = [Promise.resolve(tx.maxFeePerGas), Promise.resolve(tx.maxPriorityFeePerGas)]; | ||
if (isEmpty(tx.maxFeePerGas)) { | ||
calls[0] = this.gasPrice(tx.feeCurrency); | ||
} | ||
if (isEmpty(tx.maxPriorityFeePerGas)) { | ||
calls[1] = this.rpcCaller | ||
.call('eth_maxPriorityFeePerGas', [tx.feeCurrency]) | ||
.then(function (rpcResponse) { | ||
return rpcResponse.result; | ||
}); | ||
} | ||
return [4 /*yield*/, Promise.all(calls)]; | ||
case 1: | ||
_a = _b.sent(), maxFeePerGas = _a[0], maxPriorityFeePerGas = _a[1]; | ||
return [2 /*return*/, __assign(__assign({}, tx), { gasPrice: undefined, maxFeePerGas: maxFeePerGas, maxPriorityFeePerGas: maxPriorityFeePerGas })]; | ||
} | ||
}); | ||
}); }; | ||
this.estimateGas = function (tx, gasEstimator, caller) { | ||
if (gasEstimator === void 0) { gasEstimator = _this.web3.eth.estimateGas; } | ||
if (caller === void 0) { caller = _this.web3.eth.call; } | ||
return __awaiter(_this, void 0, void 0, function () { | ||
var gas, e_1, called, revertReason; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 4]); | ||
return [4 /*yield*/, gasEstimator(__assign({}, tx))]; | ||
case 1: | ||
gas = _a.sent(); | ||
debugGasEstimation('estimatedGas: %s', gas.toString()); | ||
return [2 /*return*/, gas]; | ||
case 2: | ||
e_1 = _a.sent(); | ||
return [4 /*yield*/, caller({ data: tx.data, to: tx.to, from: tx.from })]; | ||
case 3: | ||
called = _a.sent(); | ||
revertReason = 'Could not decode transaction failure reason'; | ||
if (called.startsWith('0x08c379a')) { | ||
revertReason = (0, abi_utils_1.decodeStringParameter)(this.getAbiCoder(), called.substring(10)); | ||
} | ||
debugGasEstimation('Recover transaction failure reason', { | ||
called: called, | ||
data: tx.data, | ||
to: tx.to, | ||
from: tx.from, | ||
error: e_1, | ||
revertReason: revertReason, | ||
}); | ||
return [2 /*return*/, Promise.reject("Gas estimation failed: ".concat(revertReason, " or ").concat(e_1))]; | ||
case 4: return [2 /*return*/]; | ||
this.signTypedData = (signer, typedData, version) => __awaiter(this, void 0, void 0, function* () { | ||
// stringify data for v3 & v4 based on https://github.com/MetaMask/metamask-extension/blob/c72199a1a6e4151c40c22f79d0f3b6ed7a2d59a7/app/scripts/lib/typed-message-manager.js#L185 | ||
const shouldStringify = version === 3 || version === 4; | ||
// Uses the Provider and not the RpcCaller, because this method should be intercepted | ||
// by the CeloProvider if there is a local wallet that could sign it. The RpcCaller | ||
// would just forward it to the node | ||
const signature = yield new Promise((resolve, reject) => { | ||
const method = version ? `eth_signTypedData_v${version}` : 'eth_signTypedData'; | ||
this.web3.currentProvider.send({ | ||
id: (0, rpc_caller_1.getRandomId)(), | ||
jsonrpc: '2.0', | ||
method, | ||
params: [ | ||
(0, formatter_1.inputAddressFormatter)(signer), | ||
shouldStringify ? JSON.stringify(typedData) : typedData, | ||
], | ||
}, (error, resp) => { | ||
if (error) { | ||
reject(error); | ||
} | ||
else if (resp) { | ||
resolve(resp.result); | ||
} | ||
else { | ||
reject(new Error('empty-response')); | ||
} | ||
}); | ||
}); | ||
}; | ||
this.estimateGasWithInflationFactor = function (tx, gasEstimator, caller) { return __awaiter(_this, void 0, void 0, function () { | ||
var gas, _a, _b, e_2; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
_c.trys.push([0, 2, , 3]); | ||
_b = (_a = Math).round; | ||
return [4 /*yield*/, this.estimateGas(tx, gasEstimator, caller)]; | ||
case 1: | ||
gas = _b.apply(_a, [(_c.sent()) * this.config.gasInflationFactor]); | ||
debugGasEstimation('estimatedGasWithInflationFactor: %s', gas); | ||
return [2 /*return*/, gas]; | ||
case 2: | ||
e_2 = _c.sent(); | ||
throw new Error(e_2); | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
// An instance of Connection will only change chain id if provider is changed. | ||
this.chainId = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var response, chainID; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (this._chainID) { | ||
return [2 /*return*/, this._chainID]; | ||
} | ||
return [4 /*yield*/, this.rpcCaller.call('net_version', [])]; | ||
case 1: | ||
response = _a.sent(); | ||
chainID = parseInt(response.result.toString(), 10); | ||
this._chainID = chainID; | ||
return [2 /*return*/, chainID]; | ||
} | ||
}); | ||
}); }; | ||
this.getTransactionCount = function (address) { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.rpcCaller.call('eth_getTransactionCount', [address, 'pending'])]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, (0, formatter_1.hexToNumber)(response.result)]; | ||
} | ||
}); | ||
}); }; | ||
this.nonce = function (address) { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.getTransactionCount(address)]; | ||
}); | ||
}); }; | ||
this.coinbase = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.rpcCaller.call('eth_coinbase', [])]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response.result.toString()]; | ||
} | ||
}); | ||
}); }; | ||
this.gasPrice = function (feeCurrency) { return __awaiter(_this, void 0, void 0, function () { | ||
var parameter, response, gasPriceInHex; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
parameter = feeCurrency ? [feeCurrency] : []; | ||
return [4 /*yield*/, this.rpcCaller.call('eth_gasPrice', parameter)]; | ||
case 1: | ||
response = _a.sent(); | ||
gasPriceInHex = response.result.toString(); | ||
return [2 /*return*/, gasPriceInHex]; | ||
} | ||
}); | ||
}); }; | ||
this.getBlockNumber = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.rpcCaller.call('eth_blockNumber', [])]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, (0, formatter_1.hexToNumber)(response.result)]; | ||
} | ||
}); | ||
}); }; | ||
this.isBlockNumberHash = function (blockNumber) { | ||
return blockNumber instanceof String && blockNumber.indexOf('0x') === 0; | ||
}; | ||
this.getBlock = function (blockHashOrBlockNumber, fullTxObjects) { | ||
if (fullTxObjects === void 0) { fullTxObjects = true; } | ||
return __awaiter(_this, void 0, void 0, function () { | ||
var endpoint, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
endpoint = this.isBlockNumberHash(blockHashOrBlockNumber) | ||
? 'eth_getBlockByHash' // Reference: https://eth.wiki/json-rpc/API#eth_getBlockByHash | ||
: 'eth_getBlockByNumber' // Reference: https://eth.wiki/json-rpc/API#eth_getBlockByNumber | ||
; | ||
return [4 /*yield*/, this.rpcCaller.call(endpoint, [ | ||
(0, formatter_1.inputBlockNumberFormatter)(blockHashOrBlockNumber), | ||
fullTxObjects, | ||
])]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, (0, formatter_1.outputBlockFormatter)(response.result)]; | ||
const messageHash = (0, util_1.bufferToHex)((0, sign_typed_data_utils_1.generateTypedDataHash)(typedData)); | ||
return (0, signatureUtils_1.parseSignatureWithoutPrefix)(messageHash, signature, signer); | ||
}); | ||
this.sign = (dataToSign, address) => __awaiter(this, void 0, void 0, function* () { | ||
// Uses the Provider and not the RpcCaller, because this method should be intercepted | ||
// by the CeloProvider if there is a local wallet that could sign it. The RpcCaller | ||
// would just forward it to the node | ||
const signature = yield new Promise((resolve, reject) => { | ||
; | ||
this.web3.currentProvider.send({ | ||
id: (0, rpc_caller_1.getRandomId)(), | ||
jsonrpc: '2.0', | ||
method: 'eth_sign', | ||
params: [(0, formatter_1.inputAddressFormatter)(address.toString()), (0, formatter_1.inputSignFormatter)(dataToSign)], | ||
}, (error, resp) => { | ||
if (error) { | ||
reject(error); | ||
} | ||
else if (resp) { | ||
resolve(resp.result); | ||
} | ||
else { | ||
reject(new Error('empty-response')); | ||
} | ||
}); | ||
}); | ||
}; | ||
this.getBlockHeader = function (blockHashOrBlockNumber) { return __awaiter(_this, void 0, void 0, function () { | ||
var endpoint, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
endpoint = this.isBlockNumberHash(blockHashOrBlockNumber) | ||
? 'eth_getHeaderByHash' | ||
: 'eth_getHeaderByNumber'; | ||
return [4 /*yield*/, this.rpcCaller.call(endpoint, [ | ||
(0, formatter_1.inputBlockNumberFormatter)(blockHashOrBlockNumber), | ||
])]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, (0, formatter_1.outputBlockHeaderFormatter)(response.result)]; | ||
return signature; | ||
}); | ||
this.sendSignedTransaction = (signedTransactionData) => __awaiter(this, void 0, void 0, function* () { | ||
return (0, tx_result_1.toTxResult)(this.web3.eth.sendSignedTransaction(signedTransactionData)); | ||
}); | ||
// if neither gas price nor feeMarket fields are present set them. | ||
this.setFeeMarketGas = (tx) => __awaiter(this, void 0, void 0, function* () { | ||
// default to the current values | ||
const calls = [Promise.resolve(tx.maxFeePerGas), Promise.resolve(tx.maxPriorityFeePerGas)]; | ||
if (isEmpty(tx.maxFeePerGas)) { | ||
calls[0] = this.gasPrice(tx.feeCurrency); | ||
} | ||
if (isEmpty(tx.maxPriorityFeePerGas)) { | ||
calls[1] = this.rpcCaller | ||
.call('eth_maxPriorityFeePerGas', [tx.feeCurrency]) | ||
.then((rpcResponse) => { | ||
return rpcResponse.result; | ||
}); | ||
} | ||
const [maxFeePerGas, maxPriorityFeePerGas] = yield Promise.all(calls); | ||
return Object.assign(Object.assign({}, tx), { gasPrice: undefined, maxFeePerGas, | ||
maxPriorityFeePerGas }); | ||
}); | ||
this.estimateGas = (tx, gasEstimator = this.web3.eth.estimateGas, caller = this.web3.eth.call) => __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const gas = yield gasEstimator(Object.assign({}, tx)); | ||
debugGasEstimation('estimatedGas: %s', gas.toString()); | ||
return gas; | ||
} | ||
catch (e) { | ||
const called = yield caller({ data: tx.data, to: tx.to, from: tx.from }); | ||
let revertReason = 'Could not decode transaction failure reason'; | ||
if (called.startsWith('0x08c379a')) { | ||
revertReason = (0, abi_utils_1.decodeStringParameter)(this.getAbiCoder(), called.substring(10)); | ||
} | ||
}); | ||
}); }; | ||
this.getBalance = function (address, defaultBlock) { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.rpcCaller.call('eth_getBalance', [ | ||
(0, formatter_1.inputAddressFormatter)(address), | ||
(0, formatter_1.inputDefaultBlockNumberFormatter)(defaultBlock), | ||
])]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, (0, formatter_1.outputBigNumberFormatter)(response.result)]; | ||
} | ||
}); | ||
}); }; | ||
this.getTransaction = function (transactionHash) { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.rpcCaller.call('eth_getTransactionByHash', [ | ||
(0, address_1.ensureLeading0x)(transactionHash), | ||
])]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, (0, formatter_1.outputCeloTxFormatter)(response.result)]; | ||
} | ||
}); | ||
}); }; | ||
this.getTransactionReceipt = function (txhash) { return __awaiter(_this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.rpcCaller.call('eth_getTransactionReceipt', [ | ||
(0, address_1.ensureLeading0x)(txhash), | ||
])]; | ||
case 1: | ||
response = _a.sent(); | ||
if (response.result === null) { | ||
return [2 /*return*/, null]; | ||
} | ||
return [2 /*return*/, (0, formatter_1.outputCeloTxReceiptFormatter)(response.result)]; | ||
} | ||
}); | ||
}); }; | ||
debugGasEstimation('Recover transaction failure reason', { | ||
called, | ||
data: tx.data, | ||
to: tx.to, | ||
from: tx.from, | ||
error: e, | ||
revertReason, | ||
}); | ||
return Promise.reject(`Gas estimation failed: ${revertReason} or ${e}`); | ||
} | ||
}); | ||
this.estimateGasWithInflationFactor = (tx, gasEstimator, caller) => __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const gas = Math.round((yield this.estimateGas(tx, gasEstimator, caller)) * this.config.gasInflationFactor); | ||
debugGasEstimation('estimatedGasWithInflationFactor: %s', gas); | ||
return gas; | ||
} | ||
catch (e) { | ||
throw new Error(e); | ||
} | ||
}); | ||
// An instance of Connection will only change chain id if provider is changed. | ||
this.chainId = () => __awaiter(this, void 0, void 0, function* () { | ||
if (this._chainID) { | ||
return this._chainID; | ||
} | ||
// Reference: https://eth.wiki/json-rpc/API#net_version | ||
const response = yield this.rpcCaller.call('net_version', []); | ||
const chainID = parseInt(response.result.toString(), 10); | ||
this._chainID = chainID; | ||
return chainID; | ||
}); | ||
this.getTransactionCount = (address) => __awaiter(this, void 0, void 0, function* () { | ||
// Reference: https://eth.wiki/json-rpc/API#eth_gettransactioncount | ||
const response = yield this.rpcCaller.call('eth_getTransactionCount', [address, 'pending']); | ||
return (0, formatter_1.hexToNumber)(response.result); | ||
}); | ||
this.nonce = (address) => __awaiter(this, void 0, void 0, function* () { | ||
return this.getTransactionCount(address); | ||
}); | ||
this.coinbase = () => __awaiter(this, void 0, void 0, function* () { | ||
// Reference: https://eth.wiki/json-rpc/API#eth_coinbase | ||
const response = yield this.rpcCaller.call('eth_coinbase', []); | ||
return response.result.toString(); | ||
}); | ||
this.gasPrice = (feeCurrency) => __awaiter(this, void 0, void 0, function* () { | ||
// Required otherwise is not backward compatible | ||
const parameter = feeCurrency ? [feeCurrency] : []; | ||
// Reference: https://eth.wiki/json-rpc/API#eth_gasprice | ||
const response = yield this.rpcCaller.call('eth_gasPrice', parameter); | ||
const gasPriceInHex = response.result.toString(); | ||
return gasPriceInHex; | ||
}); | ||
this.getBlockNumber = () => __awaiter(this, void 0, void 0, function* () { | ||
const response = yield this.rpcCaller.call('eth_blockNumber', []); | ||
return (0, formatter_1.hexToNumber)(response.result); | ||
}); | ||
this.isBlockNumberHash = (blockNumber) => blockNumber instanceof String && blockNumber.indexOf('0x') === 0; | ||
this.getBlock = (blockHashOrBlockNumber, fullTxObjects = true) => __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = this.isBlockNumberHash(blockHashOrBlockNumber) | ||
? 'eth_getBlockByHash' // Reference: https://eth.wiki/json-rpc/API#eth_getBlockByHash | ||
: 'eth_getBlockByNumber'; // Reference: https://eth.wiki/json-rpc/API#eth_getBlockByNumber | ||
const response = yield this.rpcCaller.call(endpoint, [ | ||
(0, formatter_1.inputBlockNumberFormatter)(blockHashOrBlockNumber), | ||
fullTxObjects, | ||
]); | ||
return (0, formatter_1.outputBlockFormatter)(response.result); | ||
}); | ||
this.getBlockHeader = (blockHashOrBlockNumber) => __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = this.isBlockNumberHash(blockHashOrBlockNumber) | ||
? 'eth_getHeaderByHash' | ||
: 'eth_getHeaderByNumber'; | ||
const response = yield this.rpcCaller.call(endpoint, [ | ||
(0, formatter_1.inputBlockNumberFormatter)(blockHashOrBlockNumber), | ||
]); | ||
return (0, formatter_1.outputBlockHeaderFormatter)(response.result); | ||
}); | ||
this.getBalance = (address, defaultBlock) => __awaiter(this, void 0, void 0, function* () { | ||
// Reference: https://eth.wiki/json-rpc/API#eth_getBalance | ||
const response = yield this.rpcCaller.call('eth_getBalance', [ | ||
(0, formatter_1.inputAddressFormatter)(address), | ||
(0, formatter_1.inputDefaultBlockNumberFormatter)(defaultBlock), | ||
]); | ||
return (0, formatter_1.outputBigNumberFormatter)(response.result); | ||
}); | ||
this.getTransaction = (transactionHash) => __awaiter(this, void 0, void 0, function* () { | ||
// Reference: https://eth.wiki/json-rpc/API#eth_getTransactionByHash | ||
const response = yield this.rpcCaller.call('eth_getTransactionByHash', [ | ||
(0, address_1.ensureLeading0x)(transactionHash), | ||
]); | ||
return (0, formatter_1.outputCeloTxFormatter)(response.result); | ||
}); | ||
this.getTransactionReceipt = (txhash) => __awaiter(this, void 0, void 0, function* () { | ||
// Reference: https://eth.wiki/json-rpc/API#eth_getTransactionReceipt | ||
const response = yield this.rpcCaller.call('eth_getTransactionReceipt', [ | ||
(0, address_1.ensureLeading0x)(txhash), | ||
]); | ||
if (response.result === null) { | ||
return null; | ||
} | ||
return (0, formatter_1.outputCeloTxReceiptFormatter)(response.result); | ||
}); | ||
web3.eth.handleRevert = handleRevert; | ||
@@ -457,3 +285,3 @@ this.config = { | ||
}; | ||
var existingProvider = web3.currentProvider; | ||
const existingProvider = web3.currentProvider; | ||
this.setProvider(existingProvider); | ||
@@ -465,3 +293,3 @@ // TODO: Add this line with the wallets separation completed | ||
} | ||
Connection.prototype.setProvider = function (provider) { | ||
setProvider(provider) { | ||
if (!provider) { | ||
@@ -480,55 +308,43 @@ throw new Error('Must have a valid Provider'); | ||
catch (error) { | ||
console.error("could not attach provider", error); | ||
console.error(`could not attach provider`, error); | ||
return false; | ||
} | ||
}; | ||
Object.defineProperty(Connection.prototype, "defaultAccount", { | ||
/** | ||
* Default account for generated transactions (eg. tx.from) | ||
*/ | ||
get: function () { | ||
return this.config.from; | ||
}, | ||
/** | ||
* Set default account for generated transactions (eg. tx.from ) | ||
*/ | ||
set: function (address) { | ||
this.config.from = address; | ||
this.web3.eth.defaultAccount = address ? address : null; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Connection.prototype, "defaultGasInflationFactor", { | ||
get: function () { | ||
return this.config.gasInflationFactor; | ||
}, | ||
set: function (factor) { | ||
this.config.gasInflationFactor = factor; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Connection.prototype, "defaultFeeCurrency", { | ||
get: function () { | ||
return this.config.feeCurrency; | ||
}, | ||
/** | ||
* Set the ERC20 address for the token to use to pay for transaction fees. | ||
* The ERC20 must be whitelisted for gas. | ||
* | ||
* Set to `null` to use CELO | ||
* | ||
* @param address ERC20 address | ||
*/ | ||
set: function (address) { | ||
this.config.feeCurrency = address; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Connection.prototype.isLocalAccount = function (address) { | ||
} | ||
/** | ||
* Set default account for generated transactions (eg. tx.from ) | ||
*/ | ||
set defaultAccount(address) { | ||
this.config.from = address; | ||
this.web3.eth.defaultAccount = address ? address : null; | ||
} | ||
/** | ||
* Default account for generated transactions (eg. tx.from) | ||
*/ | ||
get defaultAccount() { | ||
return this.config.from; | ||
} | ||
set defaultGasInflationFactor(factor) { | ||
this.config.gasInflationFactor = factor; | ||
} | ||
get defaultGasInflationFactor() { | ||
return this.config.gasInflationFactor; | ||
} | ||
/** | ||
* Set the ERC20 address for the token to use to pay for transaction fees. | ||
* The ERC20 must be whitelisted for gas. | ||
* | ||
* Set to `null` to use CELO | ||
* | ||
* @param address ERC20 address | ||
*/ | ||
set defaultFeeCurrency(address) { | ||
this.config.feeCurrency = address; | ||
} | ||
get defaultFeeCurrency() { | ||
return this.config.feeCurrency; | ||
} | ||
isLocalAccount(address) { | ||
return this.wallet != null && this.wallet.hasAccount(address); | ||
}; | ||
Connection.prototype.addAccount = function (privateKey) { | ||
} | ||
addAccount(privateKey) { | ||
if (this.wallet) { | ||
@@ -545,4 +361,4 @@ if ((0, provider_utils_1.hasProperty)(this.wallet, 'addAccount')) { | ||
} | ||
}; | ||
Connection.prototype.removeAccount = function (address) { | ||
} | ||
removeAccount(address) { | ||
if (this.wallet) { | ||
@@ -559,42 +375,29 @@ if ((0, provider_utils_1.hasProperty)(this.wallet, 'removeAccount')) { | ||
} | ||
}; | ||
Connection.prototype.getNodeAccounts = function () { | ||
} | ||
getNodeAccounts() { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var nodeAccountsResp; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.rpcCaller.call('eth_accounts', [])]; | ||
case 1: | ||
nodeAccountsResp = _b.sent(); | ||
return [2 /*return*/, this.toChecksumAddresses((_a = nodeAccountsResp.result) !== null && _a !== void 0 ? _a : [])]; | ||
} | ||
}); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const nodeAccountsResp = yield this.rpcCaller.call('eth_accounts', []); | ||
return this.toChecksumAddresses((_a = nodeAccountsResp.result) !== null && _a !== void 0 ? _a : []); | ||
}); | ||
}; | ||
Connection.prototype.getLocalAccounts = function () { | ||
} | ||
getLocalAccounts() { | ||
return this.wallet ? this.toChecksumAddresses(this.wallet.getAccounts()) : []; | ||
}; | ||
Connection.prototype.getAccounts = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.getNodeAccounts()]; | ||
case 1: return [2 /*return*/, (_a.sent()).concat(this.getLocalAccounts())]; | ||
} | ||
}); | ||
} | ||
getAccounts() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return (yield this.getNodeAccounts()).concat(this.getLocalAccounts()); | ||
}); | ||
}; | ||
Connection.prototype.toChecksumAddresses = function (addresses) { | ||
return addresses.map(function (value) { return (0, address_1.toChecksumAddress)(value); }); | ||
}; | ||
Connection.prototype.isListening = function () { | ||
} | ||
toChecksumAddresses(addresses) { | ||
return addresses.map((value) => (0, address_1.toChecksumAddress)(value)); | ||
} | ||
isListening() { | ||
return this.web3.eth.net.isListening(); | ||
}; | ||
Connection.prototype.isSyncing = function () { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.web3.eth | ||
} | ||
isSyncing() { | ||
return new Promise((resolve, reject) => { | ||
this.web3.eth | ||
.isSyncing() | ||
.then(function (response) { | ||
.then((response) => { | ||
// isSyncing returns a syncProgress object when it's still syncing | ||
@@ -610,19 +413,18 @@ if (typeof response === 'boolean') { | ||
}); | ||
}; | ||
Connection.prototype.getAbiCoder = function () { | ||
} | ||
getAbiCoder() { | ||
return this.web3.eth.abi; | ||
}; | ||
Connection.prototype.fillTxDefaults = function (tx) { | ||
var defaultTx = { | ||
} | ||
fillTxDefaults(tx) { | ||
const defaultTx = { | ||
from: this.config.from, | ||
feeCurrency: this.config.feeCurrency, | ||
}; | ||
return __assign(__assign({}, defaultTx), tx); | ||
}; | ||
Connection.prototype.stop = function () { | ||
return Object.assign(Object.assign({}, defaultTx), tx); | ||
} | ||
stop() { | ||
(0, celo_provider_1.assertIsCeloProvider)(this.web3.currentProvider); | ||
this.web3.currentProvider.stop(); | ||
}; | ||
return Connection; | ||
}()); | ||
} | ||
} | ||
exports.Connection = Connection; | ||
@@ -629,0 +431,0 @@ function isEmpty(value) { |
import { AccessList, PromiEvent, Transaction, TransactionConfig, TransactionReceipt } from 'web3-core'; | ||
import { Contract } from 'web3-eth-contract'; | ||
export declare type Address = string; | ||
export declare type Hex = `0x${string}`; | ||
export type Address = string; | ||
export type Hex = `0x${string}`; | ||
export interface CeloParams { | ||
@@ -10,4 +10,4 @@ feeCurrency: string; | ||
} | ||
export declare type AccessListRaw = Array<[string, string[]]>; | ||
export declare type HexOrMissing = Hex | undefined; | ||
export type AccessListRaw = [string, string[]][]; | ||
export type HexOrMissing = Hex | undefined; | ||
export interface FormattedCeloTx { | ||
@@ -30,7 +30,7 @@ chainId: number; | ||
} | ||
export declare type CeloTx = TransactionConfig & Partial<CeloParams> & { | ||
export type CeloTx = TransactionConfig & Partial<CeloParams> & { | ||
accessList?: AccessList; | ||
type?: TransactionTypes; | ||
}; | ||
export declare type CeloTxWithSig = CeloTx & { | ||
export type CeloTxWithSig = CeloTx & { | ||
v: number; | ||
@@ -52,3 +52,3 @@ s: string; | ||
export { Contract, ContractSendMethod, PastEventOptions } from 'web3-eth-contract'; | ||
export declare type TransactionTypes = 'eip1559' | 'celo-legacy' | 'cip42' | 'cip64'; | ||
export type TransactionTypes = 'eip1559' | 'celo-legacy' | 'cip42' | 'cip64'; | ||
interface CommonTXProperties { | ||
@@ -95,5 +95,5 @@ nonce: string; | ||
} | ||
export declare type CeloTxPending = Transaction & Partial<CeloParams>; | ||
export declare type CeloTxReceipt = TransactionReceipt & Partial<CeloParams>; | ||
export declare type Callback<T> = (error: Error | null, result?: T) => void; | ||
export type CeloTxPending = Transaction & Partial<CeloParams>; | ||
export type CeloTxReceipt = TransactionReceipt & Partial<CeloParams>; | ||
export type Callback<T> = (error: Error | null, result?: T) => void; | ||
export interface JsonRpcResponse { | ||
@@ -100,0 +100,0 @@ jsonrpc: string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decodeStringParameter = exports.signatureToAbiDefinition = exports.parseDecodedParams = exports.getAbiByName = void 0; | ||
var address_1 = require("@celo/base/lib/address"); | ||
const address_1 = require("@celo/base/lib/address"); | ||
/** @internal */ | ||
var getAbiByName = function (abi, methodName) { | ||
return abi.find(function (entry) { return entry.name === methodName; }); | ||
}; | ||
const getAbiByName = (abi, methodName) => abi.find((entry) => entry.name === methodName); | ||
exports.getAbiByName = getAbiByName; | ||
/** @internal */ | ||
var parseDecodedParams = function (params) { | ||
var args = new Array(params.__length__); | ||
Object.keys(params).forEach(function (key) { | ||
const parseDecodedParams = (params) => { | ||
const args = new Array(params.__length__); | ||
Object.keys(params).forEach((key) => { | ||
if (key === '__length__') { | ||
return; | ||
} | ||
var argIndex = parseInt(key, 10); | ||
const argIndex = parseInt(key, 10); | ||
if (argIndex >= 0) { | ||
@@ -23,13 +21,13 @@ args[argIndex] = params[key]; | ||
}); | ||
return { args: args, params: params }; | ||
return { args, params }; | ||
}; | ||
exports.parseDecodedParams = parseDecodedParams; | ||
/** @internal */ | ||
var signatureToAbiDefinition = function (fnSignature) { | ||
var matches = /(?<method>[^\(]+)\((?<args>.*)\)/.exec(fnSignature); | ||
const signatureToAbiDefinition = (fnSignature) => { | ||
const matches = /(?<method>[^\(]+)\((?<args>.*)\)/.exec(fnSignature); | ||
if (matches == null) { | ||
throw new Error("".concat(fnSignature, " is malformed")); | ||
throw new Error(`${fnSignature} is malformed`); | ||
} | ||
var method = matches.groups.method; | ||
var args = matches.groups.args.split(','); | ||
const method = matches.groups.method; | ||
const args = matches.groups.args.split(','); | ||
return { | ||
@@ -39,12 +37,12 @@ name: method, | ||
type: 'function', | ||
inputs: args.map(function (type, index) { | ||
var parts = type | ||
inputs: args.map((type, index) => { | ||
const parts = type | ||
.trim() | ||
.split(' ') | ||
.map(function (p) { return p.trim(); }); | ||
.map((p) => p.trim()); | ||
if (parts.length > 2) { | ||
throw new Error("".concat(fnSignature, " is malformed")); | ||
throw new Error(`${fnSignature} is malformed`); | ||
} | ||
return { | ||
name: parts.length > 1 ? parts[1] : "a".concat(index), | ||
name: parts.length > 1 ? parts[1] : `a${index}`, | ||
type: parts[0], | ||
@@ -57,6 +55,4 @@ }; | ||
/** @internal */ | ||
var decodeStringParameter = function (ethAbi, str) { | ||
return ethAbi.decodeParameter('string', (0, address_1.ensureLeading0x)(str)); | ||
}; | ||
const decodeStringParameter = (ethAbi, str) => ethAbi.decodeParameter('string', (0, address_1.ensureLeading0x)(str)); | ||
exports.decodeStringParameter = decodeStringParameter; | ||
//# sourceMappingURL=abi-utils.js.map |
import { Connection } from '../connection'; | ||
import { CeloTx, CeloTxObject, CeloTxReceipt } from '../types'; | ||
import { TransactionResult } from './tx-result'; | ||
export declare type CeloTransactionParams = Omit<CeloTx, 'data'>; | ||
export type CeloTransactionParams = Omit<CeloTx, 'data'>; | ||
export declare function toTransactionObject<O>(connection: Connection, txo: CeloTxObject<O>, defaultParams?: CeloTransactionParams): CeloTransactionObject<O>; | ||
@@ -6,0 +6,0 @@ export declare class CeloTransactionObject<O> { |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -19,5 +8,4 @@ exports.CeloTransactionObject = exports.toTransactionObject = void 0; | ||
exports.toTransactionObject = toTransactionObject; | ||
var CeloTransactionObject = /** @class */ (function () { | ||
function CeloTransactionObject(connection, txo, defaultParams) { | ||
var _this = this; | ||
class CeloTransactionObject { | ||
constructor(connection, txo, defaultParams) { | ||
this.connection = connection; | ||
@@ -27,13 +15,10 @@ this.txo = txo; | ||
/** send the transaction to the chain */ | ||
this.send = function (params) { | ||
return _this.connection.sendTransactionObject(_this.txo, __assign(__assign({}, _this.defaultParams), params)); | ||
this.send = (params) => { | ||
return this.connection.sendTransactionObject(this.txo, Object.assign(Object.assign({}, this.defaultParams), params)); | ||
}; | ||
/** send the transaction and waits for the receipt */ | ||
this.sendAndWaitForReceipt = function (params) { | ||
return _this.send(params).then(function (result) { return result.waitReceipt(); }); | ||
}; | ||
this.sendAndWaitForReceipt = (params) => this.send(params).then((result) => result.waitReceipt()); | ||
} | ||
return CeloTransactionObject; | ||
}()); | ||
} | ||
exports.CeloTransactionObject = CeloTransactionObject; | ||
//# sourceMappingURL=celo-transaction-object.js.map |
@@ -18,7 +18,7 @@ "use strict"; | ||
exports.inputSignFormatter = exports.inputAddressFormatter = exports.inputAccessListFormatter = exports.parseAccessList = exports.outputBigNumberFormatter = exports.outputLogFormatter = exports.hexToNumber = exports.outputBlockFormatter = exports.outputBlockHeaderFormatter = exports.inputBlockNumberFormatter = exports.inputDefaultBlockNumberFormatter = exports.outputCeloTxReceiptFormatter = exports.outputCeloTxFormatter = exports.inputCeloTxFormatter = void 0; | ||
var address_1 = require("@celo/base/lib/address"); | ||
var address_2 = require("@celo/utils/lib/address"); | ||
var solidity_1 = require("@celo/utils/lib/solidity"); | ||
var bignumber_js_1 = __importDefault(require("bignumber.js")); | ||
var utf8_1 = require("utf8"); | ||
const address_1 = require("@celo/base/lib/address"); | ||
const address_2 = require("@celo/utils/lib/address"); | ||
const solidity_1 = require("@celo/utils/lib/solidity"); | ||
const bignumber_js_1 = __importDefault(require("bignumber.js")); | ||
const utf8_1 = require("utf8"); | ||
/** | ||
@@ -28,4 +28,4 @@ * Formats the input of a transaction and converts all values to HEX | ||
function inputCeloTxFormatter(tx) { | ||
var from = tx.from, chainId = tx.chainId, nonce = tx.nonce, to = tx.to, gas = tx.gas, gasPrice = tx.gasPrice, maxFeePerGas = tx.maxFeePerGas, maxPriorityFeePerGas = tx.maxPriorityFeePerGas, feeCurrency = tx.feeCurrency, gatewayFee = tx.gatewayFee, gatewayFeeRecipient = tx.gatewayFeeRecipient, data = tx.data, value = tx.value, accessList = tx.accessList, common = tx.common, chain = tx.chain, hardfork = tx.hardfork, rest = __rest(tx, ["from", "chainId", "nonce", "to", "gas", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "feeCurrency", "gatewayFee", "gatewayFeeRecipient", "data", "value", "accessList", "common", "chain", "hardfork"]); | ||
var formattedTX = rest; | ||
const { from, chainId, nonce, to, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, feeCurrency, gatewayFee, gatewayFeeRecipient, data, value, accessList, common, chain, hardfork } = tx, rest = __rest(tx, ["from", "chainId", "nonce", "to", "gas", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "feeCurrency", "gatewayFee", "gatewayFeeRecipient", "data", "value", "accessList", "common", "chain", "hardfork"]); | ||
const formattedTX = rest; | ||
formattedTX.from = inputAddressFormatter(from === null || from === void 0 ? void 0 : from.toString()); | ||
@@ -176,3 +176,3 @@ formattedTX.to = inputAddressFormatter(to); | ||
if (Array.isArray(block.transactions)) { | ||
block.transactions.forEach(function (item) { | ||
block.transactions.forEach((item) => { | ||
if (typeof item !== 'string' && !(item instanceof String)) { | ||
@@ -198,3 +198,3 @@ return outputCeloTxFormatter(item); | ||
typeof log.logIndex === 'string') { | ||
var shaId = (0, solidity_1.sha3)((0, address_1.trimLeading0x)(log.blockHash) + | ||
const shaId = (0, solidity_1.sha3)((0, address_1.trimLeading0x)(log.blockHash) + | ||
(0, address_1.trimLeading0x)(log.transactionHash) + | ||
@@ -230,13 +230,12 @@ (0, address_1.trimLeading0x)(log.logIndex)); | ||
function parseAccessList(accessListRaw) { | ||
var accessList = []; | ||
const accessList = []; | ||
if (!accessListRaw) { | ||
return accessList; | ||
} | ||
for (var _i = 0, accessListRaw_1 = accessListRaw; _i < accessListRaw_1.length; _i++) { | ||
var entry = accessListRaw_1[_i]; | ||
var address = entry[0], storageKeys = entry[1]; | ||
for (const entry of accessListRaw) { | ||
const [address, storageKeys] = entry; | ||
throwIfInvalidAddress(address); | ||
accessList.push({ | ||
address: address, | ||
storageKeys: storageKeys.map(function (key) { | ||
address, | ||
storageKeys: storageKeys.map((key) => { | ||
if (isHash(key)) { | ||
@@ -247,3 +246,3 @@ return key; | ||
// same behavior as web3 | ||
throw new Error("Invalid storage key: ".concat(key)); | ||
throw new Error(`Invalid storage key: ${key}`); | ||
} | ||
@@ -258,3 +257,3 @@ }), | ||
if (!(0, address_2.isValidAddress)(address)) { | ||
throw new Error("Invalid address: ".concat(address)); | ||
throw new Error(`Invalid address: ${address}`); | ||
} | ||
@@ -266,8 +265,7 @@ } | ||
} | ||
return accessList.reduce(function (acc, _a) { | ||
var address = _a.address, storageKeys = _a.storageKeys; | ||
return accessList.reduce((acc, { address, storageKeys }) => { | ||
throwIfInvalidAddress(address); | ||
storageKeys.forEach(function (storageKey) { | ||
storageKeys.forEach((storageKey) => { | ||
if (storageKey.length - 2 !== 64) { | ||
throw new Error("Invalid storage key: ".concat(storageKey)); | ||
throw new Error(`Invalid storage key: ${storageKey}`); | ||
} | ||
@@ -287,3 +285,3 @@ }); | ||
} | ||
throw new Error("Provided address ".concat(address, " is invalid, the capitalization checksum test failed")); | ||
throw new Error(`Provided address ${address} is invalid, the capitalization checksum test failed`); | ||
} | ||
@@ -297,3 +295,3 @@ exports.inputAddressFormatter = inputAddressFormatter; | ||
str = (0, utf8_1.encode)(str); | ||
var hex = ''; | ||
let hex = ''; | ||
// remove \u0000 padding from either side | ||
@@ -304,6 +302,6 @@ str = str.replace(/^(?:\u0000)*/, ''); | ||
str = str.split('').reverse().join(''); | ||
for (var i = 0; i < str.length; i++) { | ||
var code = str.charCodeAt(i); | ||
for (let i = 0; i < str.length; i++) { | ||
const code = str.charCodeAt(i); | ||
// if (code !== 0) { | ||
var n = code.toString(16); | ||
const n = code.toString(16); | ||
hex += n.length < 2 ? '0' + n : n; | ||
@@ -322,6 +320,6 @@ // } | ||
if (value) { | ||
var numberValue = new bignumber_js_1.default(value); | ||
var result = (0, address_1.ensureLeading0x)(new bignumber_js_1.default(value).toString(16)); | ||
const numberValue = new bignumber_js_1.default(value); | ||
const result = (0, address_1.ensureLeading0x)(new bignumber_js_1.default(value).toString(16)); | ||
// Seen in web3, copied just in case | ||
return (numberValue.lt(new bignumber_js_1.default(0)) ? "-".concat(result) : result); | ||
return (numberValue.lt(new bignumber_js_1.default(0)) ? `-${result}` : result); | ||
} | ||
@@ -328,0 +326,0 @@ return undefined; |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (hasProperty(defaultProvider, 'connection')) { | ||
var connection = defaultProvider.connection; | ||
const connection = defaultProvider.connection; | ||
// WS | ||
@@ -20,0 +20,0 @@ if (hasProperty(connection, 'close')) { |
@@ -11,29 +11,2 @@ "use strict"; | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -44,17 +17,17 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
exports.HttpRpcCaller = exports.getRandomId = exports.rpcCallHandler = void 0; | ||
var debug_1 = __importDefault(require("debug")); | ||
var debugRpcPayload = (0, debug_1.default)('rpc:payload'); | ||
var debugRpcResponse = (0, debug_1.default)('rpc:response'); | ||
var debugRpcCallback = (0, debug_1.default)('rpc:callback:exception'); | ||
const debug_1 = __importDefault(require("debug")); | ||
const debugRpcPayload = (0, debug_1.default)('rpc:payload'); | ||
const debugRpcResponse = (0, debug_1.default)('rpc:response'); | ||
const debugRpcCallback = (0, debug_1.default)('rpc:callback:exception'); | ||
function rpcCallHandler(payload, handler, callback) { | ||
try { | ||
handler(payload) | ||
.then(function (result) { | ||
.then((result) => { | ||
callback(null, toRPCResponse(payload, result)); | ||
}, | ||
// Called if the Promise of the 'handler' fails | ||
function (error) { | ||
(error) => { | ||
callback(error, toRPCResponse(payload, null, error)); | ||
}) | ||
.catch(function (error) { | ||
.catch((error) => { | ||
// Called if the 'callback' fails | ||
@@ -73,8 +46,8 @@ debugRpcCallback('Callback for handling the JsonRpcResponse fails'); | ||
function getRandomId() { | ||
var extraDigits = 3; | ||
var baseTen = 10; | ||
const extraDigits = 3; | ||
const baseTen = 10; | ||
// 13 time digits | ||
var datePart = new Date().getTime() * Math.pow(baseTen, extraDigits); | ||
const datePart = new Date().getTime() * Math.pow(baseTen, extraDigits); | ||
// 3 random digits | ||
var extraPart = Math.floor(Math.random() * Math.pow(baseTen, extraDigits)); | ||
const extraPart = Math.floor(Math.random() * Math.pow(baseTen, extraDigits)); | ||
// 16 digits | ||
@@ -85,6 +58,6 @@ return datePart + extraPart; | ||
function toRPCResponse(payload, result, error) { | ||
var response = { | ||
const response = { | ||
id: Number(payload.id), | ||
jsonrpc: payload.jsonrpc, | ||
result: result, | ||
result, | ||
}; | ||
@@ -99,35 +72,31 @@ if (error != null) { | ||
} | ||
var HttpRpcCaller = /** @class */ (function () { | ||
function HttpRpcCaller(httpProvider, jsonrpcVersion) { | ||
if (jsonrpcVersion === void 0) { jsonrpcVersion = '2.0'; } | ||
class HttpRpcCaller { | ||
constructor(httpProvider, jsonrpcVersion = '2.0') { | ||
this.httpProvider = httpProvider; | ||
this.jsonrpcVersion = jsonrpcVersion; | ||
} | ||
HttpRpcCaller.prototype.call = function (method, params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
var payload = { | ||
id: getRandomId(), | ||
jsonrpc: _this.jsonrpcVersion, | ||
method: method, | ||
params: params, | ||
}; | ||
_this.send(payload, function (err, response) { | ||
if (err != null || !response) { | ||
reject(err); | ||
} | ||
else { | ||
resolve(response); | ||
} | ||
}); | ||
})]; | ||
call(method, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => { | ||
const payload = { | ||
id: getRandomId(), | ||
jsonrpc: this.jsonrpcVersion, | ||
method, | ||
params, | ||
}; | ||
this.send(payload, (err, response) => { | ||
if (err != null || !response) { | ||
reject(err); | ||
} | ||
else { | ||
resolve(response); | ||
} | ||
}); | ||
}); | ||
}); | ||
}; | ||
HttpRpcCaller.prototype.send = function (payload, callback) { | ||
} | ||
send(payload, callback) { | ||
debugRpcPayload('%O', payload); | ||
var decoratedCallback = function (error, result) { | ||
var err = null; | ||
const decoratedCallback = (error, result) => { | ||
let err = null; | ||
// error could be false | ||
@@ -152,6 +121,5 @@ if (error) { | ||
} | ||
}; | ||
return HttpRpcCaller; | ||
}()); | ||
} | ||
} | ||
exports.HttpRpcCaller = HttpRpcCaller; | ||
//# sourceMappingURL=rpc-caller.js.map |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -22,29 +11,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -55,3 +17,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
exports.TxParamsNormalizer = void 0; | ||
var bignumber_js_1 = __importDefault(require("bignumber.js")); | ||
const bignumber_js_1 = __importDefault(require("bignumber.js")); | ||
function isEmpty(value) { | ||
@@ -67,4 +29,4 @@ return (value === undefined || | ||
} | ||
var TxParamsNormalizer = /** @class */ (function () { | ||
function TxParamsNormalizer(connection) { | ||
class TxParamsNormalizer { | ||
constructor(connection) { | ||
this.connection = connection; | ||
@@ -74,106 +36,72 @@ this.chainId = null; | ||
} | ||
TxParamsNormalizer.prototype.populate = function (celoTxParams) { | ||
populate(celoTxParams) { | ||
var _a, _b, _c, _d; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var txParams, _e, chainId, nonce, gas, maxFeePerGas, clientMaxPriorityFeePerGas; | ||
var _this = this; | ||
return __generator(this, function (_f) { | ||
switch (_f.label) { | ||
case 0: | ||
txParams = __assign({}, celoTxParams); | ||
if (isPresent(txParams.gatewayFeeRecipient) || isPresent(txParams.gatewayFee)) { | ||
console.warn('Gateway fee has been deprecated and will be removed see: https://github.com/celo-org/celo-proposals/blob/master/CIPs/cip-0057.md'); | ||
} | ||
return [4 /*yield*/, Promise.all([ | ||
function () { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
if (txParams.chainId == null) { | ||
return [2 /*return*/, this.getChainId()]; | ||
} | ||
return [2 /*return*/, txParams.chainId]; | ||
}); | ||
}); }, | ||
function () { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
if (txParams.nonce == null) { | ||
return [2 /*return*/, this.connection.nonce(txParams.from.toString())]; | ||
} | ||
return [2 /*return*/, txParams.nonce]; | ||
}); | ||
}); }, | ||
function () { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
if (!txParams.gas || isEmpty(txParams.gas.toString())) { | ||
return [2 /*return*/, this.connection.estimateGas(txParams)]; | ||
} | ||
return [2 /*return*/, txParams.gas]; | ||
}); | ||
}); }, | ||
function () { return __awaiter(_this, void 0, void 0, function () { | ||
var suggestedPrice, priceWithRoom; | ||
var _a, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
if (!(isEmpty((_a = txParams.gasPrice) === null || _a === void 0 ? void 0 : _a.toString()) && | ||
isEmpty((_b = txParams.maxFeePerGas) === null || _b === void 0 ? void 0 : _b.toString()))) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.connection.gasPrice(txParams.feeCurrency) | ||
// add small buffer to suggested price like other libraries do | ||
]; | ||
case 1: | ||
suggestedPrice = _c.sent(); | ||
priceWithRoom = new bignumber_js_1.default(suggestedPrice) | ||
.times(120) | ||
.dividedBy(100) | ||
.integerValue() | ||
.toString(16); | ||
return [2 /*return*/, "0x".concat(priceWithRoom)]; | ||
case 2: return [2 /*return*/, txParams.maxFeePerGas]; | ||
} | ||
}); | ||
}); }, | ||
].map(function (fn) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, fn()]; | ||
}); }); }))]; | ||
case 1: | ||
_e = _f.sent(), chainId = _e[0], nonce = _e[1], gas = _e[2], maxFeePerGas = _e[3]; | ||
txParams.chainId = chainId; | ||
txParams.nonce = nonce; | ||
txParams.gas = gas; | ||
txParams.maxFeePerGas = maxFeePerGas; | ||
if (!(isPresent((_a = txParams.maxFeePerGas) === null || _a === void 0 ? void 0 : _a.toString()) && | ||
isEmpty((_b = txParams.maxPriorityFeePerGas) === null || _b === void 0 ? void 0 : _b.toString()))) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, this.connection.rpcCaller.call('eth_maxPriorityFeePerGas', [])]; | ||
case 2: | ||
clientMaxPriorityFeePerGas = _f.sent(); | ||
txParams.maxPriorityFeePerGas = clientMaxPriorityFeePerGas.result; | ||
_f.label = 3; | ||
case 3: | ||
// remove gasPrice if maxFeePerGas is set | ||
if (isPresent((_c = txParams.gasPrice) === null || _c === void 0 ? void 0 : _c.toString()) && isPresent((_d = txParams.maxFeePerGas) === null || _d === void 0 ? void 0 : _d.toString())) { | ||
txParams.gasPrice = undefined; | ||
delete txParams.gasPrice; | ||
} | ||
return [2 /*return*/, txParams]; | ||
} | ||
}); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const txParams = Object.assign({}, celoTxParams); | ||
if (isPresent(txParams.gatewayFeeRecipient) || isPresent(txParams.gatewayFee)) { | ||
console.warn('Gateway fee has been deprecated and will be removed see: https://github.com/celo-org/celo-proposals/blob/master/CIPs/cip-0057.md'); | ||
} | ||
const [chainId, nonce, gas, maxFeePerGas] = yield Promise.all([ | ||
() => __awaiter(this, void 0, void 0, function* () { | ||
if (txParams.chainId == null) { | ||
return this.getChainId(); | ||
} | ||
return txParams.chainId; | ||
}), | ||
() => __awaiter(this, void 0, void 0, function* () { | ||
if (txParams.nonce == null) { | ||
return this.connection.nonce(txParams.from.toString()); | ||
} | ||
return txParams.nonce; | ||
}), | ||
() => __awaiter(this, void 0, void 0, function* () { | ||
if (!txParams.gas || isEmpty(txParams.gas.toString())) { | ||
return this.connection.estimateGas(txParams); | ||
} | ||
return txParams.gas; | ||
}), | ||
() => __awaiter(this, void 0, void 0, function* () { | ||
var _e, _f; | ||
// if gasPrice is not set and maxFeePerGas is not set, set maxFeePerGas | ||
if (isEmpty((_e = txParams.gasPrice) === null || _e === void 0 ? void 0 : _e.toString()) && | ||
isEmpty((_f = txParams.maxFeePerGas) === null || _f === void 0 ? void 0 : _f.toString())) { | ||
const suggestedPrice = yield this.connection.gasPrice(txParams.feeCurrency); | ||
// add small buffer to suggested price like other libraries do | ||
const priceWithRoom = new bignumber_js_1.default(suggestedPrice) | ||
.times(120) | ||
.dividedBy(100) | ||
.integerValue() | ||
.toString(16); | ||
return `0x${priceWithRoom}`; | ||
} | ||
return txParams.maxFeePerGas; | ||
}), | ||
].map((fn) => __awaiter(this, void 0, void 0, function* () { return fn(); }))); | ||
txParams.chainId = chainId; | ||
txParams.nonce = nonce; | ||
txParams.gas = gas; | ||
txParams.maxFeePerGas = maxFeePerGas; | ||
// need to wait until after gas price has been handled | ||
// if maxFeePerGas is set make sure maxPriorityFeePerGas is also set | ||
if (isPresent((_a = txParams.maxFeePerGas) === null || _a === void 0 ? void 0 : _a.toString()) && | ||
isEmpty((_b = txParams.maxPriorityFeePerGas) === null || _b === void 0 ? void 0 : _b.toString())) { | ||
const clientMaxPriorityFeePerGas = yield this.connection.rpcCaller.call('eth_maxPriorityFeePerGas', []); | ||
txParams.maxPriorityFeePerGas = clientMaxPriorityFeePerGas.result; | ||
} | ||
// remove gasPrice if maxFeePerGas is set | ||
if (isPresent((_c = txParams.gasPrice) === null || _c === void 0 ? void 0 : _c.toString()) && isPresent((_d = txParams.maxFeePerGas) === null || _d === void 0 ? void 0 : _d.toString())) { | ||
txParams.gasPrice = undefined; | ||
delete txParams.gasPrice; | ||
} | ||
return txParams; | ||
}); | ||
}; | ||
TxParamsNormalizer.prototype.getChainId = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (!(this.chainId === null)) return [3 /*break*/, 2]; | ||
_a = this; | ||
return [4 /*yield*/, this.connection.chainId()]; | ||
case 1: | ||
_a.chainId = _b.sent(); | ||
_b.label = 2; | ||
case 2: return [2 /*return*/, this.chainId]; | ||
} | ||
}); | ||
} | ||
getChainId() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.chainId === null) { | ||
this.chainId = yield this.connection.chainId(); | ||
} | ||
return this.chainId; | ||
}); | ||
}; | ||
} | ||
// Right now, Forno does not expose a node's coinbase so we can't | ||
@@ -183,27 +111,16 @@ // set the gatewayFeeRecipient. Once that is fixed, we can reenable | ||
// @ts-ignore - see comment above | ||
TxParamsNormalizer.prototype.getCoinbase = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (!(this.gatewayFeeRecipient === null)) return [3 /*break*/, 2]; | ||
_a = this; | ||
return [4 /*yield*/, this.connection.coinbase()]; | ||
case 1: | ||
_a.gatewayFeeRecipient = _b.sent(); | ||
_b.label = 2; | ||
case 2: | ||
if (this.gatewayFeeRecipient == null) { | ||
throw new Error('missing-tx-params-populator@getCoinbase: Coinbase is null, we are not connected to a full ' + | ||
'node, cannot sign transactions locally'); | ||
} | ||
return [2 /*return*/, this.gatewayFeeRecipient]; | ||
} | ||
}); | ||
getCoinbase() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.gatewayFeeRecipient === null) { | ||
this.gatewayFeeRecipient = yield this.connection.coinbase(); | ||
} | ||
if (this.gatewayFeeRecipient == null) { | ||
throw new Error('missing-tx-params-populator@getCoinbase: Coinbase is null, we are not connected to a full ' + | ||
'node, cannot sign transactions locally'); | ||
} | ||
return this.gatewayFeeRecipient; | ||
}); | ||
}; | ||
return TxParamsNormalizer; | ||
}()); | ||
} | ||
} | ||
exports.TxParamsNormalizer = TxParamsNormalizer; | ||
//# sourceMappingURL=tx-params-normalizer.js.map |
@@ -11,29 +11,2 @@ "use strict"; | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -44,5 +17,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
exports.TransactionResult = exports.toTxResult = void 0; | ||
var future_1 = require("@celo/base/lib/future"); | ||
var debug_1 = __importDefault(require("debug")); | ||
var debug = (0, debug_1.default)('connection:tx:result'); | ||
const future_1 = require("@celo/base/lib/future"); | ||
const debug_1 = __importDefault(require("debug")); | ||
const debug = (0, debug_1.default)('connection:tx:result'); | ||
/** | ||
@@ -60,19 +33,19 @@ * Transforms a `PromiEvent` to a `TransactionResult`. | ||
*/ | ||
var TransactionResult = /** @class */ (function () { | ||
function TransactionResult(pe) { | ||
var _this = this; | ||
class TransactionResult { | ||
constructor(pe) { | ||
this.hashFuture = new future_1.Future(); | ||
this.receiptFuture = new future_1.Future(); | ||
pe.on('transactionHash', function (hash) { | ||
void pe | ||
.on('transactionHash', (hash) => { | ||
debug('hash: %s', hash); | ||
_this.hashFuture.resolve(hash); | ||
this.hashFuture.resolve(hash); | ||
}) | ||
.on('receipt', function (receipt) { | ||
.on('receipt', (receipt) => { | ||
debug('receipt: %O', receipt); | ||
_this.receiptFuture.resolve(receipt); | ||
this.receiptFuture.resolve(receipt); | ||
}) | ||
.on('error', (function (error, receipt) { | ||
.on('error', ((error, receipt) => { | ||
if (!receipt) { | ||
debug('send-error: %o', error); | ||
_this.hashFuture.reject(error); | ||
this.hashFuture.reject(error); | ||
} | ||
@@ -82,12 +55,11 @@ else { | ||
} | ||
_this.receiptFuture.reject(error); | ||
this.receiptFuture.reject(error); | ||
})); | ||
} | ||
/** Get (& wait for) transaction hash */ | ||
TransactionResult.prototype.getHash = function () { | ||
var _this = this; | ||
return this.hashFuture.wait().catch(function (err) { | ||
getHash() { | ||
return this.hashFuture.wait().catch((err) => { | ||
// if hashFuture fails => receiptFuture also fails | ||
// we wait for it here; so not UnhandlePromise error occurrs | ||
_this.receiptFuture.wait().catch(function () { | ||
this.receiptFuture.wait().catch(() => { | ||
// ignore | ||
@@ -97,22 +69,13 @@ }); | ||
}); | ||
}; | ||
} | ||
/** Get (& wait for) transaction receipt */ | ||
TransactionResult.prototype.waitReceipt = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
// Make sure `getHash()` promise is consumed | ||
return [4 /*yield*/, this.getHash()]; | ||
case 1: | ||
// Make sure `getHash()` promise is consumed | ||
_a.sent(); | ||
return [2 /*return*/, this.receiptFuture.wait()]; | ||
} | ||
}); | ||
waitReceipt() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// Make sure `getHash()` promise is consumed | ||
yield this.getHash(); | ||
return this.receiptFuture.wait(); | ||
}); | ||
}; | ||
return TransactionResult; | ||
}()); | ||
} | ||
} | ||
exports.TransactionResult = TransactionResult; | ||
//# sourceMappingURL=tx-result.js.map |
{ | ||
"name": "@celo/connect", | ||
"version": "5.1.1", | ||
"version": "5.1.2-beta.0", | ||
"description": "Light Toolkit for connecting with the Celo network", | ||
@@ -11,3 +11,3 @@ "main": "./lib/index.js", | ||
"homepage": "https://celo-sdk-docs.readthedocs.io/en/latest/connect", | ||
"repository": "https://github.com/celo-org/celo-monorepo/tree/master/packages/sdk/connect", | ||
"repository": "https://github.com/celo-org/developer-tooling/tree/master/packages/sdk/connect", | ||
"keywords": [ | ||
@@ -20,13 +20,13 @@ "celo", | ||
"clean": "tsc -b . --clean", | ||
"docs": "typedoc", | ||
"test": "jest --runInBand", | ||
"lint": "tslint -c tslint.json --project .", | ||
"docs": "yarn run --top-level typedoc", | ||
"test": "yarn run --top-level jest --runInBand --silent", | ||
"lint": "yarn run --top-level eslint -c .eslintrc.js ", | ||
"prepublishOnly": "yarn build" | ||
}, | ||
"dependencies": { | ||
"@celo/base": "^6.0.0", | ||
"@celo/utils": "^6.0.0-beta.0", | ||
"@ethereumjs/util": "8.0.5", | ||
"@types/debug": "^4.1.5", | ||
"@types/utf8": "^2.1.6", | ||
"@celo/base": "^6.0.0", | ||
"@celo/utils": "^5.0.6", | ||
"bignumber.js": "^9.0.0", | ||
@@ -52,2 +52,2 @@ "debug": "^4.1.1", | ||
} | ||
} | ||
} |
{ | ||
"mode": "modules", | ||
"exclude": ["**/generated/*.ts", "**/*+(index|.test).ts"], | ||
"excludeNotExported": true, | ||
"excludePrivate": true, | ||
"excludeProtected": true, | ||
"includeDeclarations": false, | ||
"ignoreCompilerErrors": true, | ||
"hideGenerator": "true", | ||
"out": "../../docs/sdk/docs/connect", | ||
"gitRevision": "master", | ||
"readme": "./README.md" | ||
} | ||
"exclude": [ | ||
"**/generated/*.ts", | ||
"**/*+(index|.test).ts" | ||
], | ||
"excludePrivate": true, | ||
"excludeProtected": true, | ||
"hideGenerator": true, | ||
"out": "../../docs/sdk/docs/connect", | ||
"gitRevision": "master", | ||
"readme": "./README.md", | ||
"entryPoints": [ | ||
"./src" | ||
], | ||
"githubPages": false, | ||
"plugin": [ | ||
"typedoc-plugin-markdown" | ||
], | ||
"entryPointStrategy": "expand" | ||
} |
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 repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
33
97808
1949
2
+ Added@celo/utils@6.0.1(transitive)
+ Added@ethereumjs/util@8.1.0(transitive)
+ Added@noble/curves@1.4.2(transitive)
+ Added@noble/hashes@1.4.0(transitive)
+ Added@scure/bip32@1.4.0(transitive)
+ Added@scure/bip39@1.3.0(transitive)
+ Addedethereum-cryptography@2.2.1(transitive)
+ Addedmicro-ftch@0.3.1(transitive)
+ Addedweb3-eth-abi@1.10.4(transitive)
+ Addedweb3-utils@1.10.4(transitive)
- Removed@celo/utils@5.0.6(transitive)
- Removedbn.js@4.11.9(transitive)
Updated@celo/utils@^6.0.0-beta.0