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

@secux/app-eth

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@secux/app-eth - npm Package Compare versions

Comparing version 3.0.11 to 3.0.12

2

lib/interface.js

@@ -18,2 +18,2 @@ "use strict";

limitations under the License.
*/var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.isJsonString=exports.ow_TypedMessage=exports.ow_EIP712TypedData=exports.ow_baseData=exports.ow_tx1559=exports.ow_tx1559_base=exports.ow_tx155=exports.ow_tx155_base=exports.ow_gasPriceUnit=exports.ow_hexString32=exports.ow_address=void 0;const t=e(require("ow")),a=require("@secux/utility"),o=require("wallet-address-validator").validate;exports.ow_address=t.default.string.matches(/^0x[0-9A-fa-f]{40}$/).validate((e=>({validator:o(e,"ETH"),message:`ArgumentError: invalid address, got "${e}"`}))),exports.ow_hexString32=t.default.string.matches(/^0x[a-fA-F0-9]{1,64}$/),exports.ow_gasPriceUnit=t.default.any(t.default.number.uint32.greaterThanOrEqual(1e9),a.owTool.prefixedhexString);const r={chainId:t.default.any(t.default.number.positive,a.owTool.prefixedhexString),nonce:t.default.any(t.default.number,a.owTool.prefixedhexString),gasPrice:exports.ow_gasPriceUnit,gasLimit:t.default.any(t.default.number.positive,a.owTool.prefixedhexString),to:exports.ow_address,value:t.default.any(t.default.number.not.negative,a.owTool.prefixedhexString)};exports.ow_tx155_base=t.default.object.partialShape(r),exports.ow_tx155=t.default.object.exactShape(Object.assign(Object.assign({},r),{data:t.default.any(t.default.undefined,a.owTool.prefixedhexString)}));const s={chainId:t.default.any(t.default.number.positive,a.owTool.prefixedhexString),nonce:t.default.any(t.default.number,a.owTool.prefixedhexString),maxPriorityFeePerGas:t.default.any(t.default.number.uint32.positive,a.owTool.prefixedhexString),maxFeePerGas:exports.ow_gasPriceUnit,gasLimit:t.default.any(t.default.number.positive,a.owTool.prefixedhexString),to:exports.ow_address,value:t.default.any(t.default.undefined,t.default.number.not.negative,a.owTool.prefixedhexString),accessList:t.default.any(t.default.undefined,t.default.array.ofType(t.default.any()))};exports.ow_tx1559_base=t.default.object.partialShape(s),exports.ow_tx1559=t.default.object.exactShape(Object.assign(Object.assign({},s),{data:t.default.any(t.default.undefined,a.owTool.prefixedhexString)})),exports.ow_baseData=t.default.any(exports.ow_tx155_base,exports.ow_tx1559_base),exports.ow_EIP712TypedData=t.default.object.exactShape({name:t.default.string,type:t.default.string}),exports.ow_TypedMessage=t.default.object.exactShape({types:t.default.object.valuesOfType(t.default.array.ofType(exports.ow_EIP712TypedData)),primaryType:t.default.string,domain:t.default.object.exactShape({name:t.default.optional.string,version:t.default.optional.string,chainId:t.default.optional.number.not.negative,verifyingContract:t.default.optional.string}),message:t.default.object}),exports.isJsonString=function(e){try{JSON.parse(e)}catch(e){return!1}return!0};
*/var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.isJsonString=exports.ow_TypedMessage=exports.ow_EIP712TypedData=exports.ow_baseData=exports.ow_tx1559=exports.ow_tx1559_base=exports.ow_tx155=exports.ow_tx155_base=exports.ow_gasPriceUnit=exports.ow_hexString32=exports.ow_address=void 0;const t=e(require("ow")),a=require("@secux/utility"),o=require("wallet-address-validator").validate;exports.ow_address=t.default.string.matches(/^0x[0-9A-Fa-f]{40}$/).validate((e=>({validator:o(e,"ETH"),message:`ArgumentError: invalid address, got "${e}"`}))),exports.ow_hexString32=t.default.string.matches(/^0x[a-fA-F0-9]{1,64}$/),exports.ow_gasPriceUnit=t.default.any(t.default.number.uint32.greaterThanOrEqual(1e9),a.owTool.prefixedhexString);const r={chainId:t.default.any(t.default.number.positive,a.owTool.prefixedhexString),nonce:t.default.any(t.default.number,a.owTool.prefixedhexString),gasPrice:exports.ow_gasPriceUnit,gasLimit:t.default.any(t.default.number.positive,a.owTool.prefixedhexString),to:exports.ow_address,value:t.default.any(t.default.number.not.negative,a.owTool.prefixedhexString)};exports.ow_tx155_base=t.default.object.partialShape(r),exports.ow_tx155=t.default.object.exactShape(Object.assign(Object.assign({},r),{data:t.default.any(t.default.undefined,a.owTool.prefixedhexString)}));const s={chainId:t.default.any(t.default.number.positive,a.owTool.prefixedhexString),nonce:t.default.any(t.default.number,a.owTool.prefixedhexString),maxPriorityFeePerGas:t.default.any(t.default.number.uint32.positive,a.owTool.prefixedhexString),maxFeePerGas:exports.ow_gasPriceUnit,gasLimit:t.default.any(t.default.number.positive,a.owTool.prefixedhexString),to:exports.ow_address,value:t.default.any(t.default.undefined,t.default.number.not.negative,a.owTool.prefixedhexString),accessList:t.default.any(t.default.undefined,t.default.array.ofType(t.default.any()))};exports.ow_tx1559_base=t.default.object.partialShape(s),exports.ow_tx1559=t.default.object.exactShape(Object.assign(Object.assign({},s),{data:t.default.any(t.default.undefined,a.owTool.prefixedhexString)})),exports.ow_baseData=t.default.any(exports.ow_tx155_base,exports.ow_tx1559_base),exports.ow_EIP712TypedData=t.default.object.exactShape({name:t.default.string,type:t.default.string}),exports.ow_TypedMessage=t.default.object.exactShape({types:t.default.object.valuesOfType(t.default.array.ofType(exports.ow_EIP712TypedData)),primaryType:t.default.string,domain:t.default.object.exactShape({name:t.default.optional.string,version:t.default.optional.string,chainId:t.default.optional.number.not.negative,verifyingContract:t.default.optional.string}),message:t.default.object}),exports.isJsonString=function(e){try{JSON.parse(e)}catch(e){return!1}return!0};

@@ -18,2 +18,2 @@ "use strict";

limitations under the License.
*/var e,t=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var i={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&t(i,e,n);return r(i,e),i},n=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.EIP1559Builder=exports.ETHTransactionBuilder=exports.getBuilder=void 0;const o=require("secp256k1/elliptic"),c=require("js-sha3"),u=i(require("rlp")),l=require("bignumber.js"),f=s(require("ow")),h=require("./interface"),d=Buffer.from([2]);exports.getBuilder=function(e){try{return(0,f.default)(e,h.ow_tx1559),new p(e)}catch(e){}return new g(e)};class g{constructor(t){if(e.set(this,void 0),n(this,e,Object.assign({},t),"f"),"string"==typeof t.chainId)a(this,e,"f").chainId=Buffer.from(t.chainId.slice(2),"hex");else if("number"==typeof t.chainId){let r=t.chainId.toString(16);r.length%2!=0&&(r=`0${r}`),a(this,e,"f").chainId=Buffer.from(r,"hex")}if(t.gasPrice){const e=x(t.gasPrice);if(e.lt(1e9))throw Error(`Minimal gas price is 1 Gwei, but got ${e.div(1e9).toString()} Gwei.`)}if(t.maxPriorityFeePerGas){if(x(t.maxPriorityFeePerGas).lt(1))throw Error("[maxPriorityFeePerGas] Minimal priority fee is 1 wei.")}if(t.maxFeePerGas){const e=x(t.maxFeePerGas);if(e.lt(1e9))throw Error(`[maxFeePerGas] Minimal fee is 1 Gwei, but got ${e.div(1e9).toString()} Gwei.`)}let r=21e3;t.data&&("string"==typeof t.data?r+=68*(t.data.length/2-1):r+=68*t.data.length);const i=x(t.gasLimit);if(i.lt(r))throw Error(`Minimal gas is ${r}, but got ${i.toString()}.`)}static deserialize(e){if(e[0]>=192){const t=u.decode(e);if(!Array.isArray(t))throw new Error("Invalid serialized tx input. Must be array");if(6!==t.length&&9!==t.length)throw new Error("Invalid transaction. Only expecting unsigned tx with 6 values (legacy) or 9 values (EIP155).");const[r,i,n,a,s,o,c,l,f]=t,h=parseInt(Buffer.from(c).toString("hex"),16);let d;return[0,27,28].includes(h)||(d=c),new g({nonce:r,gasPrice:i,gasLimit:n,to:a,value:s,data:o,chainId:d})}if(e[0]<=127){const t=u.decode(e.slice(1));if(!Array.isArray(t))throw new Error("Invalid serialized tx input. Must be array");if(9!==t.length&&12!==t.length)throw new Error("Invalid transaction. Only expecting unsigned tx with 9 or 12 values (EIP1559).");const[r,i,n,a,s,o,c,l]=t;return new p({chainId:r,nonce:i,maxPriorityFeePerGas:n,maxFeePerGas:a,gasLimit:s,to:o,value:c,data:l})}throw Error(`Invalid serialized tx input, got "${e.toString("hex")}"`)}serialize(t=!1){var r;const i=[...this.prepare(),w(null!==(r=a(this,e,"f").chainId)&&void 0!==r?r:0),0,0],n=u.encode(i);return t?Buffer.from(c.keccak256.update(n).digest()):n}withSignature(e){if(!this.verify(e))throw Error("invalid signature");e=this.getSignature(e);const t=[...this.prepare(),w(e.slice(64)),v(e.slice(0,32)),v(e.slice(32,64))];return u.encode(t)}getSignature(t){var r;const i=parseInt(Buffer.from(null!==(r=a(this,e,"f").chainId)&&void 0!==r?r:[0]).toString("hex"),16),n=i>0?2*i+35:27;let s=(t[64]+n).toString(16);s.length%2!=0&&(s=`0${s}`);const o=Buffer.from(s,"hex");return Buffer.concat([t.slice(0,64),o])}prepare(){var t;return[w(a(this,e,"f").nonce),w(a(this,e,"f").gasPrice),w(a(this,e,"f").gasLimit),a(this,e,"f").to,w(a(this,e,"f").value),null!==(t=a(this,e,"f").data)&&void 0!==t?t:""]}verify(e){const t=e.slice(0,64);try{o.ecdsaRecover(t,e.readUint8(64),this.serialize(!0))}catch(e){return!1}return!0}get chainId(){if(a(this,e,"f").chainId)return parseInt(Buffer.from(a(this,e,"f").chainId).toString("hex"),16)}get tx(){return a(this,e,"f")}}exports.ETHTransactionBuilder=g,e=new WeakMap;class p extends g{serialize(e=!1){const t=this.prepare(),r=Buffer.concat([d,u.encode(t)]);return e?Buffer.from(c.keccak256.update(r).digest()):r}withSignature(e){if(!this.verify(e))throw Error("invalid signature");const t=[...this.prepare(),w(e[64]),v(e.slice(0,32)),v(e.slice(32,64))],r=u.encode(t);return Buffer.concat([d,r])}getSignature(e){return e}prepare(){var e,t;return[w(this.tx.chainId),w(this.tx.nonce),w(this.tx.maxPriorityFeePerGas),w(this.tx.maxFeePerGas),w(this.tx.gasLimit),this.tx.to,w(this.tx.value),null!==(e=this.tx.data)&&void 0!==e?e:"",null!==(t=this.tx.accessList)&&void 0!==t?t:[]]}}function w(e){if("string"==typeof e){if(e.startsWith("0x")&&function(e){let t=e.startsWith("0x")?e.slice(2):e;const r=/^[0-9a-fA-F]+$/;return t=t.length%2==0?t:`0${t}`,r.test(t)}(e))return"0x0"==e||"0x00"==e?0:e;throw Error("Invalid handleRLPValue string")}return e}function v(e){var t;const r=(null!==(t=e.toString("hex").match(/^(00)+/g))&&void 0!==t?t:[""])[0].length/2;return e.slice(r)}function x(e){return"number"==typeof e?new l.BigNumber(e):"string"==typeof e?e.startsWith("0x")?new l.BigNumber(e.slice(2),16):new l.BigNumber(e):new l.BigNumber(Buffer.from(e).toString("hex"),16)}exports.EIP1559Builder=p;
*/var e,t=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var i={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&t(i,e,n);return r(i,e),i},n=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.EIP1559Builder=exports.ETHTransactionBuilder=exports.getBuilder=void 0;const o=require("secp256k1/elliptic"),c=require("js-sha3"),u=i(require("rlp")),l=require("bignumber.js"),f=s(require("ow")),h=require("./interface"),d=Buffer.from([2]);exports.getBuilder=function(e){try{return(0,f.default)(e,h.ow_tx1559),new p(e)}catch(e){}return new g(e)};class g{constructor(t){if(e.set(this,void 0),n(this,e,Object.assign({},t),"f"),"string"==typeof t.chainId)a(this,e,"f").chainId=Buffer.from(t.chainId.slice(2),"hex");else if("number"==typeof t.chainId){let r=t.chainId.toString(16);r.length%2!=0&&(r=`0${r}`),a(this,e,"f").chainId=Buffer.from(r,"hex")}if(t.gasPrice){const e=x(t.gasPrice);if(e.lt(1e9))throw Error(`Minimal gas price is 1 Gwei, but got ${e.div(1e9).toString()} Gwei.`)}if(t.maxPriorityFeePerGas){if(x(t.maxPriorityFeePerGas).lt(1))throw Error("[maxPriorityFeePerGas] Minimal priority fee is 1 wei.")}if(t.maxFeePerGas){const e=x(t.maxFeePerGas);if(e.lt(1e9))throw Error(`[maxFeePerGas] Minimal fee is 1 Gwei, but got ${e.div(1e9).toString()} Gwei.`)}let r=21e3;t.data&&("string"==typeof t.data?r+=68*(t.data.length/2-1):r+=68*t.data.length);const i=x(t.gasLimit);i.lt(r)&&console.warn(`Minimal gas is ${r}, but got ${i.toString()}.`)}static deserialize(e){if(e[0]>=192){const t=u.decode(e);if(!Array.isArray(t))throw new Error("Invalid serialized tx input. Must be array");if(6!==t.length&&9!==t.length)throw new Error("Invalid transaction. Only expecting unsigned tx with 6 values (legacy) or 9 values (EIP155).");const[r,i,n,a,s,o,c,l,f]=t,h=parseInt(Buffer.from(c).toString("hex"),16);let d;return[0,27,28].includes(h)||(d=c),new g({nonce:r,gasPrice:i,gasLimit:n,to:a,value:s,data:o,chainId:d})}if(e[0]<=127){const t=u.decode(e.slice(1));if(!Array.isArray(t))throw new Error("Invalid serialized tx input. Must be array");if(9!==t.length&&12!==t.length)throw new Error("Invalid transaction. Only expecting unsigned tx with 9 or 12 values (EIP1559).");const[r,i,n,a,s,o,c,l]=t;return new p({chainId:r,nonce:i,maxPriorityFeePerGas:n,maxFeePerGas:a,gasLimit:s,to:o,value:c,data:l})}throw Error(`Invalid serialized tx input, got "${e.toString("hex")}"`)}serialize(t=!1){var r;const i=[...this.prepare(),w(null!==(r=a(this,e,"f").chainId)&&void 0!==r?r:0),0,0],n=u.encode(i);return t?Buffer.from(c.keccak256.update(n).digest()):n}withSignature(e){if(!this.verify(e))throw Error("invalid signature");e=this.getSignature(e);const t=[...this.prepare(),w(e.slice(64)),v(e.slice(0,32)),v(e.slice(32,64))];return u.encode(t)}getSignature(t){var r;const i=parseInt(Buffer.from(null!==(r=a(this,e,"f").chainId)&&void 0!==r?r:[0]).toString("hex"),16),n=i>0?2*i+35:27;let s=(t[64]+n).toString(16);s.length%2!=0&&(s=`0${s}`);const o=Buffer.from(s,"hex");return Buffer.concat([t.slice(0,64),o])}prepare(){var t;return[w(a(this,e,"f").nonce),w(a(this,e,"f").gasPrice),w(a(this,e,"f").gasLimit),a(this,e,"f").to,w(a(this,e,"f").value),null!==(t=a(this,e,"f").data)&&void 0!==t?t:""]}verify(e){const t=e.slice(0,64);try{o.ecdsaRecover(t,e.readUint8(64),this.serialize(!0))}catch(e){return!1}return!0}get chainId(){if(a(this,e,"f").chainId)return parseInt(Buffer.from(a(this,e,"f").chainId).toString("hex"),16)}get tx(){return a(this,e,"f")}}exports.ETHTransactionBuilder=g,e=new WeakMap;class p extends g{serialize(e=!1){const t=this.prepare(),r=Buffer.concat([d,u.encode(t)]);return e?Buffer.from(c.keccak256.update(r).digest()):r}withSignature(e){if(!this.verify(e))throw Error("invalid signature");const t=[...this.prepare(),w(e[64]),v(e.slice(0,32)),v(e.slice(32,64))],r=u.encode(t);return Buffer.concat([d,r])}getSignature(e){return e}prepare(){var e,t;return[w(this.tx.chainId),w(this.tx.nonce),w(this.tx.maxPriorityFeePerGas),w(this.tx.maxFeePerGas),w(this.tx.gasLimit),this.tx.to,w(this.tx.value),null!==(e=this.tx.data)&&void 0!==e?e:"",null!==(t=this.tx.accessList)&&void 0!==t?t:[]]}}function w(e){if("string"==typeof e){if(e.startsWith("0x")&&function(e){let t=e.startsWith("0x")?e.slice(2):e;const r=/^[0-9a-fA-F]+$/;return t=t.length%2==0?t:`0${t}`,r.test(t)}(e))return"0x0"==e||"0x00"==e?0:e;throw Error("Invalid handleRLPValue string")}return e}function v(e){var t;const r=(null!==(t=e.toString("hex").match(/^(00)+/g))&&void 0!==t?t:[""])[0].length/2;return e.slice(r)}function x(e){return"number"==typeof e?new l.BigNumber(e):"string"==typeof e?e.startsWith("0x")?new l.BigNumber(e.slice(2),16):new l.BigNumber(e):new l.BigNumber(Buffer.from(e).toString("hex"),16)}exports.EIP1559Builder=p;
{
"name": "@secux/app-eth",
"version": "3.0.11",
"version": "3.0.12",
"description": "SecuX Hardware Wallet ETH API",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is too big to display

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