@rarible/biconomy-middleware
Advanced tools
Comparing version 0.12.54 to 0.12.56
@@ -10,2 +10,3 @@ "use strict"; | ||
var provider_request_1 = require("./utils/provider-request"); | ||
var sign_typed_data_1 = require("./sign-typed-data"); | ||
function biconomyMiddleware(provider, registry, biconomyConfig) { | ||
@@ -21,6 +22,6 @@ var _this = this; | ||
return (0, json_rpc_engine_1.createAsyncMiddleware)(function (req, res, next) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { | ||
var tx, metadata, contract, interfaceHelper, dataToSign, _a, _b, _c, r, s, v, _d, _e, err_1; | ||
var _f, _g; | ||
return (0, tslib_1.__generator)(this, function (_h) { | ||
switch (_h.label) { | ||
var tx, metadata, contract, interfaceHelper, dataToSign, _a, _b, send, signature, _c, r, s, v, _d, err_1; | ||
var _e, _f; | ||
return (0, tslib_1.__generator)(this, function (_g) { | ||
switch (_g.label) { | ||
case 0: | ||
@@ -30,37 +31,38 @@ if (!(req.method === "eth_sendTransaction" && req.params)) return [3 /*break*/, 9]; | ||
if (!isTransactionParams(tx)) return [3 /*break*/, 9]; | ||
_h.label = 1; | ||
_g.label = 1; | ||
case 1: | ||
_h.trys.push([1, 8, , 9]); | ||
_g.trys.push([1, 8, , 9]); | ||
return [4 /*yield*/, registry.getMetadata(tx.to)]; | ||
case 2: | ||
metadata = _h.sent(); | ||
metadata = _g.sent(); | ||
if (!metadata) return [3 /*break*/, 7]; | ||
return [4 /*yield*/, biconomyState]; | ||
case 3: | ||
_h.sent(); | ||
_g.sent(); | ||
contract = new ethers_1.ethers.Contract(tx.to, methods_abi_1.MetaContractAbi, signer); | ||
interfaceHelper = new ethers_1.ethers.utils.Interface(methods_abi_1.MetaContractAbi); | ||
_a = [(0, tslib_1.__assign)({}, metadata)]; | ||
_e = {}; | ||
_f = {}; | ||
_g = {}; | ||
_b = parseInt; | ||
return [4 /*yield*/, contract.getNonce(tx.from)]; | ||
case 4: | ||
dataToSign = tslib_1.__assign.apply(void 0, _a.concat([(_f.message = (_g.nonce = _b.apply(void 0, [_h.sent()]), | ||
_g.from = tx.from, | ||
_g.functionSignature = tx.data, | ||
_g), _f)])); | ||
_d = getSignatureParameters; | ||
return [4 /*yield*/, (0, provider_request_1.providerRequest)(provider, "eth_signTypedData_v4", [tx.from, dataToSign])]; | ||
dataToSign = tslib_1.__assign.apply(void 0, _a.concat([(_e.message = (_f.nonce = _b.apply(void 0, [_g.sent()]), | ||
_f.from = tx.from, | ||
_f.functionSignature = tx.data, | ||
_f), _e)])); | ||
send = (function (method, params) { return (0, provider_request_1.providerRequest)(provider, method, params); }); | ||
return [4 /*yield*/, (0, sign_typed_data_1.signTypedData)(send, tx.from, dataToSign)]; | ||
case 5: | ||
_c = _d.apply(void 0, [_h.sent()]), r = _c.r, s = _c.s, v = _c.v; | ||
signature = _g.sent(); | ||
_c = getSignatureParameters(signature), r = _c.r, s = _c.s, v = _c.v; | ||
tx.data = interfaceHelper.encodeFunctionData("executeMetaTransaction", [tx.from, tx.data, r, s, v]); | ||
_e = res; | ||
_d = res; | ||
return [4 /*yield*/, (0, provider_request_1.providerRequest)(biconomy, "eth_sendTransaction", [tx])]; | ||
case 6: | ||
_e.result = _h.sent(); | ||
_d.result = _g.sent(); | ||
return [2 /*return*/]; | ||
case 7: return [3 /*break*/, 9]; | ||
case 8: | ||
err_1 = _h.sent(); | ||
err_1 = _g.sent(); | ||
res.error = err_1; | ||
@@ -70,3 +72,3 @@ return [3 /*break*/, 9]; | ||
case 10: | ||
_h.sent(); | ||
_g.sent(); | ||
return [2 /*return*/]; | ||
@@ -82,3 +84,3 @@ } | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
var probe = provider.send(); | ||
provider.send(); | ||
} | ||
@@ -85,0 +87,0 @@ else { |
{ | ||
"name": "@rarible/biconomy-middleware", | ||
"version": "0.12.54", | ||
"version": "0.12.56", | ||
"description": "Middleware for biconomy integration", | ||
@@ -45,3 +45,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "7e4f9db940c90a8a720632a7bb6a185958e49562" | ||
"gitHead": "62f1075d2d0717004bf0f1d3c9beec10b784d81e" | ||
} |
Sorry, the diff of this file is not supported yet
70755
22
454