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

@glif/filecoin-wallet-provider

Package Overview
Dependencies
Maintainers
3
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glif/filecoin-wallet-provider - npm Package Compare versions

Comparing version 1.1.1-alpha.0 to 1.1.1-alpha.1

dist/utils/num1GreaterThanNum2.d.ts

11

dist/filecoin.d.ts

@@ -38,3 +38,3 @@ import LotusRpcEngine, { LotusRpcEngineConfig } from '@glif/filecoin-rpc-client';

gasCalcTxFee: (gasFeeCap: string, gasPremium: string, gasLimit: number, baseFee: string, gasUsed: string) => Promise<FilecoinNumber>;
getMinSpedUpGasParams: (message: LotusMessage) => Promise<{
getReplaceMessageGasParams: (message: LotusMessage, maxFee?: string) => Promise<{
gasFeeCap: string;

@@ -44,3 +44,12 @@ gasPremium: string;

}>;
/**
* Used for calculating the minimum boost in gas params to replace a message
* (1.25x prev gasPremium, bump fee cap as needed)
*/
getReplaceMessageMinGasParams: (message: LotusMessage) => Promise<{
gasFeeCap: string;
gasPremium: string;
gasLimit: number;
}>;
}
//# sourceMappingURL=filecoin.d.ts.map

@@ -30,2 +30,6 @@ "use strict";

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var Filecoin = function Filecoin(provider) {

@@ -500,5 +504,17 @@ var _this = this;

}());
(0, _defineProperty2["default"])(this, "getMinSpedUpGasParams", /*#__PURE__*/function () {
(0, _defineProperty2["default"])(this, "getReplaceMessageGasParams", /*#__PURE__*/function () {
var _ref12 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12(message) {
var newFeeCap, newPremium;
var maxFee,
_yield$_this$getRepla,
minGasFeeCap,
minGasLimit,
minGasPremium,
copiedMessage,
_yield$_this$gasEstim,
recommendedGasFeeCap,
recommendedGasLimit,
recommendedGasPremium,
takeMin,
_args12 = arguments;
return _regenerator["default"].wrap(function _callee12$(_context12) {

@@ -508,2 +524,68 @@ while (1) {

case 0:
maxFee = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : new _filecoinNumber.FilecoinNumber('0.1', 'fil').toAttoFil();
_context12.next = 3;
return _this.getReplaceMessageMinGasParams(message);
case 3:
_yield$_this$getRepla = _context12.sent;
minGasFeeCap = _yield$_this$getRepla.gasFeeCap;
minGasLimit = _yield$_this$getRepla.gasLimit;
minGasPremium = _yield$_this$getRepla.gasPremium;
copiedMessage = _objectSpread({}, message);
copiedMessage.GasFeeCap = '0';
copiedMessage.GasPremium = '0';
copiedMessage.GasLimit = 0;
_context12.next = 13;
return _this.gasEstimateMessageGas(copiedMessage, maxFee);
case 13:
_yield$_this$gasEstim = _context12.sent.toLotusType();
recommendedGasFeeCap = _yield$_this$gasEstim.GasFeeCap;
recommendedGasLimit = _yield$_this$gasEstim.GasLimit;
recommendedGasPremium = _yield$_this$gasEstim.GasPremium;
// assume we take the recommended prices
takeMin = false; // if any of the minimum amounts are greater than the recommended,
// take the minimum amounts
if ((0, _utils.num1GreaterThanNum2)(minGasFeeCap, recommendedGasFeeCap)) takeMin = true;
if ((0, _utils.num1GreaterThanNum2)(minGasLimit, recommendedGasLimit)) takeMin = true;
if ((0, _utils.num1GreaterThanNum2)(minGasPremium, recommendedGasPremium)) takeMin = true;
if (!takeMin) {
_context12.next = 23;
break;
}
return _context12.abrupt("return", {
gasFeeCap: minGasFeeCap,
gasLimit: minGasLimit,
gasPremium: minGasPremium
});
case 23:
return _context12.abrupt("return", {
gasFeeCap: recommendedGasFeeCap,
gasLimit: recommendedGasLimit,
gasPremium: recommendedGasPremium
});
case 24:
case "end":
return _context12.stop();
}
}
}, _callee12);
}));
return function (_x17) {
return _ref12.apply(this, arguments);
};
}());
(0, _defineProperty2["default"])(this, "getReplaceMessageMinGasParams", /*#__PURE__*/function () {
var _ref13 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13(message) {
var newFeeCap, newPremium;
return _regenerator["default"].wrap(function _callee13$(_context13) {
while (1) {
switch (_context13.prev = _context13.next) {
case 0:
newFeeCap = message.GasFeeCap;

@@ -516,3 +598,3 @@ newPremium = new _filecoinNumber.FilecoinNumber(message.GasPremium, 'fil').multipliedBy(125).dividedBy(100);

return _context12.abrupt("return", {
return _context13.abrupt("return", {
gasFeeCap: newFeeCap,

@@ -525,10 +607,10 @@ gasPremium: newPremium.toString(),

case "end":
return _context12.stop();
return _context13.stop();
}
}
}, _callee12);
}, _callee13);
}));
return function (_x17) {
return _ref12.apply(this, arguments);
return function (_x18) {
return _ref13.apply(this, arguments);
};

@@ -535,0 +617,0 @@ }());

@@ -5,2 +5,3 @@ export { default as validatePath } from './validatePath';

export { default as allCallsExitWithCode0 } from './allCallsExitWithCode0';
export * from './num1GreaterThanNum2';
//# sourceMappingURL=index.d.ts.map

@@ -51,2 +51,16 @@ "use strict";

var _allCallsExitWithCode = _interopRequireDefault(require("./allCallsExitWithCode0"));
var _num1GreaterThanNum = require("./num1GreaterThanNum2");
Object.keys(_num1GreaterThanNum).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _num1GreaterThanNum[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _num1GreaterThanNum[key];
}
});
});
//# sourceMappingURL=index.js.map

@@ -5,2 +5,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

import _defineProperty from "@babel/runtime/helpers/defineProperty";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
import LotusRpcEngine from '@glif/filecoin-rpc-client';

@@ -12,2 +17,3 @@ import { FilecoinNumber } from '@glif/filecoin-number';

import { BigNumber } from 'bignumber.js';
import { num1GreaterThanNum2 } from './utils';
export var Filecoin = function Filecoin(provider) {

@@ -497,5 +503,17 @@ var _this = this;

_defineProperty(this, "getMinSpedUpGasParams", /*#__PURE__*/function () {
_defineProperty(this, "getReplaceMessageGasParams", /*#__PURE__*/function () {
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(message) {
var newFeeCap, newPremium;
var maxFee,
_yield$_this$getRepla,
minGasFeeCap,
minGasLimit,
minGasPremium,
copiedMessage,
_yield$_this$gasEstim,
recommendedGasFeeCap,
recommendedGasLimit,
recommendedGasPremium,
takeMin,
_args12 = arguments;
return _regeneratorRuntime.wrap(function _callee12$(_context12) {

@@ -505,2 +523,69 @@ while (1) {

case 0:
maxFee = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : new FilecoinNumber('0.1', 'fil').toAttoFil();
_context12.next = 3;
return _this.getReplaceMessageMinGasParams(message);
case 3:
_yield$_this$getRepla = _context12.sent;
minGasFeeCap = _yield$_this$getRepla.gasFeeCap;
minGasLimit = _yield$_this$getRepla.gasLimit;
minGasPremium = _yield$_this$getRepla.gasPremium;
copiedMessage = _objectSpread({}, message);
copiedMessage.GasFeeCap = '0';
copiedMessage.GasPremium = '0';
copiedMessage.GasLimit = 0;
_context12.next = 13;
return _this.gasEstimateMessageGas(copiedMessage, maxFee);
case 13:
_yield$_this$gasEstim = _context12.sent.toLotusType();
recommendedGasFeeCap = _yield$_this$gasEstim.GasFeeCap;
recommendedGasLimit = _yield$_this$gasEstim.GasLimit;
recommendedGasPremium = _yield$_this$gasEstim.GasPremium;
// assume we take the recommended prices
takeMin = false; // if any of the minimum amounts are greater than the recommended,
// take the minimum amounts
if (num1GreaterThanNum2(minGasFeeCap, recommendedGasFeeCap)) takeMin = true;
if (num1GreaterThanNum2(minGasLimit, recommendedGasLimit)) takeMin = true;
if (num1GreaterThanNum2(minGasPremium, recommendedGasPremium)) takeMin = true;
if (!takeMin) {
_context12.next = 23;
break;
}
return _context12.abrupt("return", {
gasFeeCap: minGasFeeCap,
gasLimit: minGasLimit,
gasPremium: minGasPremium
});
case 23:
return _context12.abrupt("return", {
gasFeeCap: recommendedGasFeeCap,
gasLimit: recommendedGasLimit,
gasPremium: recommendedGasPremium
});
case 24:
case "end":
return _context12.stop();
}
}
}, _callee12);
}));
return function (_x17) {
return _ref12.apply(this, arguments);
};
}());
_defineProperty(this, "getReplaceMessageMinGasParams", /*#__PURE__*/function () {
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(message) {
var newFeeCap, newPremium;
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
while (1) {
switch (_context13.prev = _context13.next) {
case 0:
newFeeCap = message.GasFeeCap;

@@ -513,3 +598,3 @@ newPremium = new FilecoinNumber(message.GasPremium, 'fil').multipliedBy(125).dividedBy(100);

return _context12.abrupt("return", {
return _context13.abrupt("return", {
gasFeeCap: newFeeCap,

@@ -522,10 +607,10 @@ gasPremium: newPremium.toString(),

case "end":
return _context12.stop();
return _context13.stop();
}
}
}, _callee12);
}, _callee13);
}));
return function (_x17) {
return _ref12.apply(this, arguments);
return function (_x18) {
return _ref13.apply(this, arguments);
};

@@ -532,0 +617,0 @@ }());

@@ -5,2 +5,3 @@ export { default as validatePath } from './validatePath';

export { default as allCallsExitWithCode0 } from './allCallsExitWithCode0';
export * from './num1GreaterThanNum2';
//# sourceMappingURL=index.js.map
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
import LotusRpcEngine from '@glif/filecoin-rpc-client';

@@ -9,2 +14,3 @@ import { FilecoinNumber } from '@glif/filecoin-number';

import { BigNumber } from 'bignumber.js';
import { num1GreaterThanNum2 } from './utils';
export class Filecoin {

@@ -225,4 +231,50 @@ constructor(provider, config = {

_defineProperty(this, "getMinSpedUpGasParams", /*#__PURE__*/function () {
var _ref12 = _asyncToGenerator(function* (message) {
_defineProperty(this, "getReplaceMessageGasParams", /*#__PURE__*/function () {
var _ref12 = _asyncToGenerator(function* (message, maxFee = new FilecoinNumber('0.1', 'fil').toAttoFil()) {
const {
gasFeeCap: minGasFeeCap,
gasLimit: minGasLimit,
gasPremium: minGasPremium
} = yield _this.getReplaceMessageMinGasParams(message);
const copiedMessage = _objectSpread({}, message);
copiedMessage.GasFeeCap = '0';
copiedMessage.GasPremium = '0';
copiedMessage.GasLimit = 0;
const {
GasFeeCap: recommendedGasFeeCap,
GasLimit: recommendedGasLimit,
GasPremium: recommendedGasPremium
} = (yield _this.gasEstimateMessageGas(copiedMessage, maxFee)).toLotusType(); // assume we take the recommended prices
let takeMin = false; // if any of the minimum amounts are greater than the recommended,
// take the minimum amounts
if (num1GreaterThanNum2(minGasFeeCap, recommendedGasFeeCap)) takeMin = true;
if (num1GreaterThanNum2(minGasLimit, recommendedGasLimit)) takeMin = true;
if (num1GreaterThanNum2(minGasPremium, recommendedGasPremium)) takeMin = true;
if (takeMin) {
return {
gasFeeCap: minGasFeeCap,
gasLimit: minGasLimit,
gasPremium: minGasPremium
};
}
return {
gasFeeCap: recommendedGasFeeCap,
gasLimit: recommendedGasLimit,
gasPremium: recommendedGasPremium
};
});
return function (_x17) {
return _ref12.apply(this, arguments);
};
}());
_defineProperty(this, "getReplaceMessageMinGasParams", /*#__PURE__*/function () {
var _ref13 = _asyncToGenerator(function* (message) {
let newFeeCap = message.GasFeeCap;

@@ -242,4 +294,4 @@ const newPremium = new FilecoinNumber(message.GasPremium, 'fil').multipliedBy(125).dividedBy(100);

return function (_x17) {
return _ref12.apply(this, arguments);
return function (_x18) {
return _ref13.apply(this, arguments);
};

@@ -246,0 +298,0 @@ }());

@@ -5,2 +5,3 @@ export { default as validatePath } from './validatePath';

export { default as allCallsExitWithCode0 } from './allCallsExitWithCode0';
export * from './num1GreaterThanNum2';
//# sourceMappingURL=index.js.map

4

package.json
{
"name": "@glif/filecoin-wallet-provider",
"version": "1.1.1-alpha.0",
"version": "1.1.1-alpha.1",
"description": "a javascript package to send filecoin to addresses",

@@ -47,3 +47,3 @@ "main": "./dist/index.js",

},
"gitHead": "96c61fa1e2e1c9fcc71bf2190a26fa29e0251a31"
"gitHead": "49618c4d0c993e13a6b901aac71d52af18d03c10"
}

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

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc