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.10 to 3.0.11

2

lib/app-eth.d.ts

@@ -171,3 +171,3 @@ /*!

}
export declare function prepareSign(path: string, builder: ETHTransactionBuilder, isBlind: boolean, tp?: TransactionType): {
export declare function prepareSign(path: string, builder: ETHTransactionBuilder, tp?: TransactionType): {
commandData: communicationData;

@@ -174,0 +174,0 @@ rawTx: communicationData;

@@ -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.prepareSign=exports.SecuxETH=void 0;const t=require("js-sha3"),r=require("secp256k1/elliptic"),a=e(require("ow")),i=require("@secux/utility"),n=require("@secux/protocol-transaction"),s=require("@secux/protocol-transaction/lib/interface"),o=require("./interface"),u=require("./transaction"),c=require("eth-sig-util"),l=require("@secux/utility/lib/communication"),f=require("./erc20"),p=require("./erc721"),g=require("./erc1155"),d=require("@secux/transport"),x=null===i.Logger||void 0===i.Logger?void 0:i.Logger.child({id:"ethereum"}),T=(0,i.ow_strictPath)(60,44),S={crypto:"2.12",nifty:"0.02.1"};class h{static addressConvert(e){const n=function(e){(0,a.default)(e,a.default.any(i.owTool.hexString,a.default.buffer));const t="string"==typeof e?Buffer.from(e,"hex"):e;if((0,a.default)(t,a.default.buffer.is((e=>33===e.length||65===e.length))),!r.publicKeyVerify(t))throw Error(`ArgumentError: invalid secp256k1 publickey, got "${t.toString("hex")}"`);return t}(e),s=r.publicKeyConvert(n,!1),o=function(e){e=e.toLowerCase().replace(/^0x/,"");const r=(0,t.keccak256)(e);let a="0x";for(let t=0;t<e.length;t++)parseInt(r[t],16)>=8?a+=e[t].toUpperCase():a+=e[t];return a}((0,t.keccak256)(s.slice(1)).slice(-40));return o}static prepareAddress(e){return this.preparePublickey(e)}static resolveAddress(e){(0,a.default)(e,l.ow_communicationData);const t=h.resolvePublickey(e);return h.addressConvert(t)}static preparePublickey(e){return(0,a.default)(e,T),n.SecuxTransactionTool.getPublickey(e,s.EllipticCurve.SECP256K1)}static resolvePublickey(e){const t=n.SecuxTransactionTool.resolvePublickey(e,s.EllipticCurve.SECP256K1);return Buffer.from(t,"base64").toString("hex")}static prepareXPublickey(e){return(0,a.default)(e,T),n.SecuxTransactionTool.getXPublickey(e)}static resolveXPublickey(e,t){return(0,a.default)(t,T),n.SecuxTransactionTool.resolveXPublickey(e,t)}static prepareSignSerialized(e,t){var r;(0,a.default)(t,l.ow_communicationData);const i=(0,l.getBuffer)(t);null==x||x.debug(`- prepareSignSerialized\ninput serialized tx: ${i.toString("hex")}`);const n=u.ETHTransactionBuilder.deserialize(i);return y(e,n,(null===(r=n.tx.data)||void 0===r?void 0:r.length)>0).commandData}static resolveSignature(e){return Buffer.from(n.SecuxTransactionTool.resolveSignature(e),"base64").toString("hex")}static resolveTransaction(e,t){(0,a.default)(e,l.ow_communicationData),(0,a.default)(t,l.ow_communicationData);const r=(0,l.getBuffer)(t),i=u.ETHTransactionBuilder.deserialize(r),n=Buffer.from(h.resolveSignature(e),"hex");return null==x||x.debug(`- resolveTransaction\ninput serialized tx: ${r.toString("hex")}`),`0x${i.withSignature(n).toString("hex")}`}static prepareSignEIP155(e,t){(0,a.default)(t,o.ow_tx155);return y(e,(0,u.getBuilder)(t),!1)}static resolveSignatureEIP155(e,t){(0,a.default)(e,l.ow_communicationData),(0,a.default)(t,a.default.optional.number.positive);const r=Buffer.from(h.resolveSignature(e),"hex"),i=r[64];return void 0===t?r.writeUInt8(27+i,64):r.writeUInt8(35+2*t+i,64),r.toString("hex")}static prepareSignEIP1559(e,t){(0,a.default)(t,o.ow_tx1559);return y(e,(0,u.getBuilder)(t),!1)}static prepareSignMessage(e,t){let r;return(0,i.checkFWVersion)("mcu",S[d.ITransport.deviceType],d.ITransport.mcuVersion),(0,a.default)(e,T),(0,a.default)(t,a.default.any(a.default.string.nonEmpty,a.default.buffer)),"string"==typeof t&&(r=t.startsWith("0x")?Buffer.from(t.slice(2),"hex"):Buffer.from(t)),n.SecuxTransactionTool.signMessage(e,null!=r?r:t)}static prepareSignTypedData(e,t){(0,i.checkFWVersion)("mcu",S[d.ITransport.deviceType],d.ITransport.mcuVersion),(0,a.default)(e,T),(0,a.default)(t,a.default.string);const r=JSON.parse(t),s=c.TypedDataUtils.sanitizeData(r),o=[];o.push(c.TypedDataUtils.hashStruct("EIP712Domain",s.domain,s.types,!0)),"EIP712Domain"!==s.primaryType&&o.push(c.TypedDataUtils.hashStruct(s.primaryType.toString(),s.message,s.types,!0));const u=Buffer.concat(o);return n.SecuxTransactionTool.signTypedMessage(e,u)}static prepareSignWalletConnectTransaction(e,t){(0,a.default)(e,T),(0,a.default)(t,a.default.any(o.ow_tx155,o.ow_tx1559));return y(e,(0,u.getBuilder)(t),!0)}static async getAddress(e){const t=h.prepareAddress(e),r=await this.Exchange((0,l.getBuffer)(t));return h.resolveAddress(r)}static async getPublickey(e){const t=h.preparePublickey(e),r=await this.Exchange((0,l.getBuffer)(t));return h.resolvePublickey(r)}static async getXPublickey(e){const t=h.prepareXPublickey(e),r=await this.Exchange((0,l.getBuffer)(t));return h.resolveXPublickey(r,e)}static async sign(e,t,r){const a=async()=>{const r=h.prepareSignSerialized(e,t),a=await this.Exchange((0,l.getBuffer)(r));let i=Buffer.from(h.resolveSignature(a),"hex");return i=u.ETHTransactionBuilder.deserialize((0,l.getBuffer)(t)).getSignature(i),{raw_tx:h.resolveTransaction(a,t),signature:`0x${i.toString("hex")}`}};if("string"==typeof t){if(t.match(l.base64_regexp))return a();const i=((0,o.isJsonString)(t)?h.prepareSignTypedData:h.prepareSignMessage)(e,t),n=await this.Exchange((0,l.getBuffer)(i));return{raw_tx:void 0,signature:`0x${h.resolveSignatureEIP155(n,r)}`}}if(Buffer.isBuffer(t))return a();let i=h.prepareSignEIP155;"boolean"==typeof r&&r&&(i=h.prepareSignWalletConnectTransaction),(t.accessList||t.maxPriorityFeePerGas||t.maxFeePerGas)&&(i=h.prepareSignEIP1559);const{commandData:n,rawTx:s}=i(e,t),c=await this.Exchange((0,l.getBuffer)(n));let f=Buffer.from(h.resolveSignature(c),"hex");return f=u.ETHTransactionBuilder.deserialize((0,l.getBuffer)(s)).getSignature(f),{raw_tx:h.resolveTransaction(c,s),signature:`0x${f.toString("hex")}`}}}function y(e,t,r,o){(0,i.checkFWVersion)("mcu",S[d.ITransport.deviceType],d.ITransport.mcuVersion),(0,a.default)(e,T),void 0===o&&(o=void 0===t.tx.value||"0"==t.tx.value?s.TransactionType.TOKEN:s.TransactionType.NORMAL),r&&(o=s.TransactionType.NORMAL);const u={tp:o,curve:s.EllipticCurve.SECP256K1,chainId:t.chainId||1};u.chainId>65535&&(u.chainId=65535);const c=r?n.SecuxTransactionTool.signTransaction(e,t.serialize(!0),u):n.SecuxTransactionTool.signRawTransaction(e,t.serialize(),u);return(0,l.wrapResult)({commandData:c,rawTx:(0,l.toCommunicationData)(t.serialize())})}exports.SecuxETH=h,h.ERC20=f.ERC20,h.ERC721=p.ERC721,h.ERC1155=g.ERC1155,(0,i.loadPlugin)(h,"SecuxETH"),exports.prepareSign=y;
*/var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.prepareSign=exports.SecuxETH=void 0;const t=require("js-sha3"),r=require("secp256k1/elliptic"),i=e(require("ow")),a=require("@secux/utility"),n=require("@secux/protocol-transaction"),s=require("@secux/protocol-transaction/lib/interface"),o=require("./interface"),u=require("./transaction"),c=require("eth-sig-util"),l=require("@secux/utility/lib/communication"),f=require("./erc20"),p=require("./erc721"),g=require("./erc1155"),d=require("@secux/transport"),x=null===a.Logger||void 0===a.Logger?void 0:a.Logger.child({id:"ethereum"}),h=(0,a.ow_strictPath)(60,44),T={crypto:"2.12",nifty:"0.02.1"};class y{static addressConvert(e){const n=function(e){(0,i.default)(e,i.default.any(a.owTool.hexString,i.default.buffer));const t="string"==typeof e?Buffer.from(e,"hex"):e;if((0,i.default)(t,i.default.buffer.is((e=>33===e.length||65===e.length))),!r.publicKeyVerify(t))throw Error(`ArgumentError: invalid secp256k1 publickey, got "${t.toString("hex")}"`);return t}(e),s=r.publicKeyConvert(n,!1),o=function(e){e=e.toLowerCase().replace(/^0x/,"");const r=(0,t.keccak256)(e);let i="0x";for(let t=0;t<e.length;t++)parseInt(r[t],16)>=8?i+=e[t].toUpperCase():i+=e[t];return i}((0,t.keccak256)(s.slice(1)).slice(-40));return o}static prepareAddress(e){return this.preparePublickey(e)}static resolveAddress(e){(0,i.default)(e,l.ow_communicationData);const t=y.resolvePublickey(e);return y.addressConvert(t)}static preparePublickey(e){return(0,i.default)(e,h),n.SecuxTransactionTool.getPublickey(e,s.EllipticCurve.SECP256K1)}static resolvePublickey(e){const t=n.SecuxTransactionTool.resolvePublickey(e,s.EllipticCurve.SECP256K1);return Buffer.from(t,"base64").toString("hex")}static prepareXPublickey(e){return(0,i.default)(e,h),n.SecuxTransactionTool.getXPublickey(e)}static resolveXPublickey(e,t){return(0,i.default)(t,h),n.SecuxTransactionTool.resolveXPublickey(e,t)}static prepareSignSerialized(e,t){(0,i.default)(t,l.ow_communicationData);const r=(0,l.getBuffer)(t);null==x||x.debug(`- prepareSignSerialized\ninput serialized tx: ${r.toString("hex")}`);return S(e,u.ETHTransactionBuilder.deserialize(r)).commandData}static resolveSignature(e){return Buffer.from(n.SecuxTransactionTool.resolveSignature(e),"base64").toString("hex")}static resolveTransaction(e,t){(0,i.default)(e,l.ow_communicationData),(0,i.default)(t,l.ow_communicationData);const r=(0,l.getBuffer)(t),a=u.ETHTransactionBuilder.deserialize(r),n=Buffer.from(y.resolveSignature(e),"hex");return null==x||x.debug(`- resolveTransaction\ninput serialized tx: ${r.toString("hex")}`),`0x${a.withSignature(n).toString("hex")}`}static prepareSignEIP155(e,t){(0,i.default)(t,o.ow_tx155);return S(e,(0,u.getBuilder)(t))}static resolveSignatureEIP155(e,t){(0,i.default)(e,l.ow_communicationData),(0,i.default)(t,i.default.optional.number.positive);const r=Buffer.from(y.resolveSignature(e),"hex"),a=r[64];return void 0===t?r.writeUInt8(27+a,64):r.writeUInt8(35+2*t+a,64),r.toString("hex")}static prepareSignEIP1559(e,t){(0,i.default)(t,o.ow_tx1559);return S(e,(0,u.getBuilder)(t))}static prepareSignMessage(e,t){let r;return(0,a.checkFWVersion)("mcu",T[d.ITransport.deviceType],d.ITransport.mcuVersion),(0,i.default)(e,h),(0,i.default)(t,i.default.any(i.default.string.nonEmpty,i.default.buffer)),"string"==typeof t&&(r=t.startsWith("0x")?Buffer.from(t.slice(2),"hex"):Buffer.from(t)),n.SecuxTransactionTool.signMessage(e,null!=r?r:t)}static prepareSignTypedData(e,t){(0,a.checkFWVersion)("mcu",T[d.ITransport.deviceType],d.ITransport.mcuVersion),(0,i.default)(e,h),(0,i.default)(t,i.default.string);const r=JSON.parse(t),s=c.TypedDataUtils.sanitizeData(r),o=[];o.push(c.TypedDataUtils.hashStruct("EIP712Domain",s.domain,s.types,!0)),"EIP712Domain"!==s.primaryType&&o.push(c.TypedDataUtils.hashStruct(s.primaryType.toString(),s.message,s.types,!0));const u=Buffer.concat(o);return n.SecuxTransactionTool.signTypedMessage(e,u)}static prepareSignWalletConnectTransaction(e,t){(0,i.default)(e,h),(0,i.default)(t,i.default.any(o.ow_tx155,o.ow_tx1559));return S(e,(0,u.getBuilder)(t))}static async getAddress(e){const t=y.prepareAddress(e),r=await this.Exchange((0,l.getBuffer)(t));return y.resolveAddress(r)}static async getPublickey(e){const t=y.preparePublickey(e),r=await this.Exchange((0,l.getBuffer)(t));return y.resolvePublickey(r)}static async getXPublickey(e){const t=y.prepareXPublickey(e),r=await this.Exchange((0,l.getBuffer)(t));return y.resolveXPublickey(r,e)}static async sign(e,t,r){const i=async()=>{const r=y.prepareSignSerialized(e,t),i=await this.Exchange((0,l.getBuffer)(r));let a=Buffer.from(y.resolveSignature(i),"hex");return a=u.ETHTransactionBuilder.deserialize((0,l.getBuffer)(t)).getSignature(a),{raw_tx:y.resolveTransaction(i,t),signature:`0x${a.toString("hex")}`}};if("string"==typeof t){if(t.match(l.base64_regexp))return i();const a=((0,o.isJsonString)(t)?y.prepareSignTypedData:y.prepareSignMessage)(e,t),n=await this.Exchange((0,l.getBuffer)(a));return{raw_tx:void 0,signature:`0x${y.resolveSignatureEIP155(n,r)}`}}if(Buffer.isBuffer(t))return i();let a=y.prepareSignEIP155;"boolean"==typeof r&&r&&(a=y.prepareSignWalletConnectTransaction),(t.accessList||t.maxPriorityFeePerGas||t.maxFeePerGas)&&(a=y.prepareSignEIP1559);const{commandData:n,rawTx:s}=a(e,t),c=await this.Exchange((0,l.getBuffer)(n));let f=Buffer.from(y.resolveSignature(c),"hex");return f=u.ETHTransactionBuilder.deserialize((0,l.getBuffer)(s)).getSignature(f),{raw_tx:y.resolveTransaction(c,s),signature:`0x${f.toString("hex")}`}}}function S(e,t,r){(0,a.checkFWVersion)("mcu",T[d.ITransport.deviceType],d.ITransport.mcuVersion),(0,i.default)(e,h),void 0===r&&(r=void 0===t.tx.value||"0"==t.tx.value?s.TransactionType.TOKEN:s.TransactionType.NORMAL);const o=function(e){const t=[{identify:"a9059cbb",length:136},{identify:"23b872dd",length:200},{identify:"095ea7b3",length:136},{identify:"42842e0e",length:200}],r=Buffer.isBuffer(e)?e.toString("hex"):null==e?void 0:e.replace(/^0x/,"");if(!r)return!1;for(const e of t)if(r.startsWith(e.identify)&&r.length===e.length)return!1;return!0}(t.tx.data);o&&(r=s.TransactionType.NORMAL);const u={tp:r,curve:s.EllipticCurve.SECP256K1,chainId:t.chainId||1};u.chainId>65535&&(u.chainId=65535);const c=o?n.SecuxTransactionTool.signTransaction(e,t.serialize(!0),u):n.SecuxTransactionTool.signRawTransaction(e,t.serialize(),u);return(0,l.wrapResult)({commandData:c,rawTx:(0,l.toCommunicationData)(t.serialize())})}exports.SecuxETH=y,y.ERC20=f.ERC20,y.ERC721=p.ERC721,y.ERC1155=g.ERC1155,(0,a.loadPlugin)(y,"SecuxETH"),exports.prepareSign=S;

@@ -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.erc1155_def=exports.ERC1155=void 0;const a=require("@ethersproject/abi"),r=require("./app-eth"),t=e(require("ow")),d=require("./interface"),s=require("./transaction"),n=require("@secux/utility");exports.ERC1155=class{static prepareSafeTransferFrom(e,a,n){var i;(0,t.default)(a,d.ow_baseData),(0,t.default)(n,o);const u=exports.erc1155_def.encodeFunctionData("safeTransferFrom",[n.fromAddress,n.toAddress,n.id,n.value,null!==(i=n.data)&&void 0!==i?i:Buffer.alloc(0)]),l=(0,s.getBuilder)(Object.assign(Object.assign({},a),{data:u}));return(0,r.prepareSign)(e,l,!1)}static prepareSafeBatchTransferFrom(e,a,n){var o;(0,t.default)(a,d.ow_baseData),(0,t.default)(n,u);const i=[...n.items].sort(((e,a)=>{const r=l(e.id)-l(a.id);if(0===r)throw Error(`ArgumentError: duplicate id found, got "${l(e.id)}"`);return r})),f=exports.erc1155_def.encodeFunctionData("safeBatchTransferFrom",[n.fromAddress,n.toAddress,i.map((e=>e.id)),i.map((e=>e.value)),null!==(o=n.data)&&void 0!==o?o:Buffer.alloc(0)]),c=(0,s.getBuilder)(Object.assign(Object.assign({},a),{data:f}));return(0,r.prepareSign)(e,c,!0)}},exports.erc1155_def=new a.Interface(["function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data)","function safeBatchTransferFrom(address _from, address _to, uint256[] calldata _ids, uint256[] calldata _values, bytes calldata _data)","function balanceOf(address _owner, uint256 _id) external view returns (uint256)","function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids) external view returns (uint256[] memory)","function setApprovalForAll(address _operator, bool _approved)","function isApprovedForAll(address _owner, address _operator) external view returns (bool)","event TransferSingle(address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value)","event TransferBatch(address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values)","event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved)","event URI(string _value, uint256 indexed _id)","function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data) external returns(bytes4)","function onERC1155BatchReceived(address _operator, address _from, uint256[] calldata _ids, uint256[] calldata _values, bytes calldata _data) external returns(bytes4)"]);const o=t.default.object.exactShape({fromAddress:d.ow_address,toAddress:d.ow_address,id:t.default.any(t.default.number.positive,d.ow_hexString32),value:t.default.any(t.default.number.positive,d.ow_hexString32),data:t.default.any(t.default.undefined,n.owTool.prefixedhexString,t.default.buffer)}),i=t.default.object.exactShape({id:t.default.any(t.default.number.positive,d.ow_hexString32),value:t.default.any(t.default.number.positive,d.ow_hexString32)}),u=t.default.object.exactShape({fromAddress:d.ow_address,toAddress:d.ow_address,items:t.default.array.ofType(i),data:t.default.any(t.default.undefined,n.owTool.prefixedhexString,t.default.buffer)});function l(e){return"number"==typeof e?e:parseInt(e.slice(2),16)}
*/var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.erc1155_def=exports.ERC1155=void 0;const a=require("@ethersproject/abi"),r=require("./app-eth"),t=e(require("ow")),d=require("./interface"),s=require("./transaction"),n=require("@secux/utility");exports.ERC1155=class{static prepareSafeTransferFrom(e,a,n){var i;(0,t.default)(a,d.ow_baseData),(0,t.default)(n,o);const u=exports.erc1155_def.encodeFunctionData("safeTransferFrom",[n.fromAddress,n.toAddress,n.id,n.value,null!==(i=n.data)&&void 0!==i?i:Buffer.alloc(0)]),l=(0,s.getBuilder)(Object.assign(Object.assign({},a),{data:u}));return(0,r.prepareSign)(e,l)}static prepareSafeBatchTransferFrom(e,a,n){var o;(0,t.default)(a,d.ow_baseData),(0,t.default)(n,u);const i=[...n.items].sort(((e,a)=>{const r=l(e.id)-l(a.id);if(0===r)throw Error(`ArgumentError: duplicate id found, got "${l(e.id)}"`);return r})),f=exports.erc1155_def.encodeFunctionData("safeBatchTransferFrom",[n.fromAddress,n.toAddress,i.map((e=>e.id)),i.map((e=>e.value)),null!==(o=n.data)&&void 0!==o?o:Buffer.alloc(0)]),c=(0,s.getBuilder)(Object.assign(Object.assign({},a),{data:f}));return(0,r.prepareSign)(e,c)}},exports.erc1155_def=new a.Interface(["function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data)","function safeBatchTransferFrom(address _from, address _to, uint256[] calldata _ids, uint256[] calldata _values, bytes calldata _data)","function balanceOf(address _owner, uint256 _id) external view returns (uint256)","function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids) external view returns (uint256[] memory)","function setApprovalForAll(address _operator, bool _approved)","function isApprovedForAll(address _owner, address _operator) external view returns (bool)","event TransferSingle(address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value)","event TransferBatch(address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values)","event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved)","event URI(string _value, uint256 indexed _id)","function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data) external returns(bytes4)","function onERC1155BatchReceived(address _operator, address _from, uint256[] calldata _ids, uint256[] calldata _values, bytes calldata _data) external returns(bytes4)"]);const o=t.default.object.exactShape({fromAddress:d.ow_address,toAddress:d.ow_address,id:t.default.any(t.default.number.positive,d.ow_hexString32),value:t.default.any(t.default.number.positive,d.ow_hexString32),data:t.default.any(t.default.undefined,n.owTool.prefixedhexString,t.default.buffer)}),i=t.default.object.exactShape({id:t.default.any(t.default.number.positive,d.ow_hexString32),value:t.default.any(t.default.number.positive,d.ow_hexString32)}),u=t.default.object.exactShape({fromAddress:d.ow_address,toAddress:d.ow_address,items:t.default.array.ofType(i),data:t.default.any(t.default.undefined,n.owTool.prefixedhexString,t.default.buffer)});function l(e){return"number"==typeof e?e:parseInt(e.slice(2),16)}

@@ -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.erc20_def=exports.ERC20=void 0;const r=require("@ethersproject/abi"),t=e(require("ow")),s=require("./app-eth"),a=require("./interface"),n=require("./transaction"),o=require("@secux/protocol-transaction/lib/interface");exports.ERC20=class{static prepareTransfer(e,r,u){(0,t.default)(r,a.ow_baseData),(0,t.default)(u,i);const d=exports.erc20_def.encodeFunctionData("transfer",[u.toAddress,u.amount]),c=(0,n.getBuilder)(Object.assign(Object.assign({},r),{data:d}));return(0,s.prepareSign)(e,c,!1,o.TransactionType.TOKEN)}static prepareTransferFrom(e,r,i){(0,t.default)(r,a.ow_baseData),(0,t.default)(i,u);const d=exports.erc20_def.encodeFunctionData("transferFrom",[i.fromAddress,i.toAddress,i.amount]),c=(0,n.getBuilder)(Object.assign(Object.assign({},r),{data:d}));return(0,s.prepareSign)(e,c,!1,o.TransactionType.TOKEN)}static prepareApprove(e,r,u){(0,t.default)(r,a.ow_baseData),(0,t.default)(u,i);const d=exports.erc20_def.encodeFunctionData("approve",[u.toAddress,u.amount]),c=(0,n.getBuilder)(Object.assign(Object.assign({},r),{data:d}));return(0,s.prepareSign)(e,c,!1,o.TransactionType.TOKEN)}},exports.erc20_def=new r.Interface(["function name() public view returns (string)","function symbol() public view returns (string)","function decimals() public view returns (uint8)","function totalSupply() public view returns (uint256)","function balanceOf(address _owner) public view returns (uint256 balance)","function transfer(address _to, uint256 _value) public returns (bool success)","function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)","function approve(address _spender, uint256 _value) public returns (bool success)","function allowance(address _owner, address _spender) public view returns (uint256 remaining)","event Transfer(address indexed _from, address indexed _to, uint256 _value)","event Approval(address indexed _owner, address indexed _spender, uint256 _value)"]);const i=t.default.object.exactShape({toAddress:a.ow_address,amount:t.default.any(t.default.number.positive,a.ow_hexString32)}),u=t.default.object.exactShape({fromAddress:a.ow_address,toAddress:a.ow_address,amount:t.default.any(t.default.number.positive,a.ow_hexString32)});
*/var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.erc20_def=exports.ERC20=void 0;const r=require("@ethersproject/abi"),t=e(require("ow")),s=require("./app-eth"),a=require("./interface"),n=require("./transaction"),o=require("@secux/protocol-transaction/lib/interface");exports.ERC20=class{static prepareTransfer(e,r,u){(0,t.default)(r,a.ow_baseData),(0,t.default)(u,i);const d=exports.erc20_def.encodeFunctionData("transfer",[u.toAddress,u.amount]),c=(0,n.getBuilder)(Object.assign(Object.assign({},r),{data:d}));return(0,s.prepareSign)(e,c,o.TransactionType.TOKEN)}static prepareTransferFrom(e,r,i){(0,t.default)(r,a.ow_baseData),(0,t.default)(i,u);const d=exports.erc20_def.encodeFunctionData("transferFrom",[i.fromAddress,i.toAddress,i.amount]),c=(0,n.getBuilder)(Object.assign(Object.assign({},r),{data:d}));return(0,s.prepareSign)(e,c,o.TransactionType.TOKEN)}static prepareApprove(e,r,u){(0,t.default)(r,a.ow_baseData),(0,t.default)(u,i);const d=exports.erc20_def.encodeFunctionData("approve",[u.toAddress,u.amount]),c=(0,n.getBuilder)(Object.assign(Object.assign({},r),{data:d}));return(0,s.prepareSign)(e,c,o.TransactionType.TOKEN)}},exports.erc20_def=new r.Interface(["function name() public view returns (string)","function symbol() public view returns (string)","function decimals() public view returns (uint8)","function totalSupply() public view returns (uint256)","function balanceOf(address _owner) public view returns (uint256 balance)","function transfer(address _to, uint256 _value) public returns (bool success)","function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)","function approve(address _spender, uint256 _value) public returns (bool success)","function allowance(address _owner, address _spender) public view returns (uint256 remaining)","event Transfer(address indexed _from, address indexed _to, uint256 _value)","event Approval(address indexed _owner, address indexed _spender, uint256 _value)"]);const i=t.default.object.exactShape({toAddress:a.ow_address,amount:t.default.any(t.default.number.positive,a.ow_hexString32)}),u=t.default.object.exactShape({fromAddress:a.ow_address,toAddress:a.ow_address,amount:t.default.any(t.default.number.positive,a.ow_hexString32)});

@@ -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.erc721_def=exports.ERC721=void 0;const t=require("@ethersproject/abi"),r=require("./app-eth"),n=e(require("ow")),a=require("./interface"),s=require("./transaction"),d=require("@secux/utility"),o=require("@secux/protocol-transaction/lib/interface");exports.ERC721=class{static prepareSafeTransferFrom(e,t,d){(0,n.default)(t,a.ow_baseData),(0,n.default)(d,f);const i=d.data?exports.erc721_def.encodeFunctionData("safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data)",[d.fromAddress,d.toAddress,d.tokenId,d.data]):exports.erc721_def.encodeFunctionData("safeTransferFrom(address _from, address _to, uint256 _tokenId)",[d.fromAddress,d.toAddress,d.tokenId]),u=(0,s.getBuilder)(Object.assign(Object.assign({},t),{data:i}));return(0,r.prepareSign)(e,u,!1,o.TransactionType.NFT)}static prepareTransferFrom(e,t,d){(0,n.default)(t,a.ow_baseData),(0,n.default)(d,u);const i=exports.erc721_def.encodeFunctionData("transferFrom",[d.fromAddress,d.toAddress,d.tokenId]),f=(0,s.getBuilder)(Object.assign(Object.assign({},t),{data:i}));return(0,r.prepareSign)(e,f,!1,o.TransactionType.NFT)}static prepareApprove(e,t,d){(0,n.default)(t,a.ow_baseData),(0,n.default)(d,c);const i=exports.erc721_def.encodeFunctionData("approve",[d.toAddress,d.tokenId]),u=(0,s.getBuilder)(Object.assign(Object.assign({},t),{data:i}));return(0,r.prepareSign)(e,u,!1,o.TransactionType.NFT)}},exports.erc721_def=new t.Interface(["function balanceOf(address _owner) external view returns (uint256)","function ownerOf(uint256 _tokenId) external view returns (address)","function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable","function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable","function transferFrom(address _from, address _to, uint256 _tokenId) external payable","function approve(address _approved, uint256 _tokenId) external payable","function setApprovalForAll(address _operator, bool _approved) external","function getApproved(uint256 _tokenId) external view returns (address)","function isApprovedForAll(address _owner, address _operator) external view returns (bool)","function supportsInterface(bytes4 interfaceID) external view returns (bool)","function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes _data) external returns(bytes4)","event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId)","event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId)","event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved)","function name() external view returns (string _name)","function symbol() external view returns (string _symbol)","function tokenURI(uint256 _tokenId) external view returns (string)","function totalSupply() external view returns (uint256)","function tokenByIndex(uint256 _index) external view returns (uint256)","function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256)"]);const i={fromAddress:a.ow_address,toAddress:a.ow_address,tokenId:n.default.any(n.default.number.positive,a.ow_hexString32)},u=n.default.object.exactShape(i),f=n.default.object.exactShape(Object.assign(Object.assign({},i),{data:n.default.any(n.default.undefined,d.owTool.prefixedhexString,n.default.buffer)})),c=n.default.object.exactShape({toAddress:a.ow_address,tokenId:n.default.any(n.default.number.positive,a.ow_hexString32)});
*/var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.erc721_def=exports.ERC721=void 0;const t=require("@ethersproject/abi"),r=require("./app-eth"),n=e(require("ow")),a=require("./interface"),s=require("./transaction"),d=require("@secux/utility"),o=require("@secux/protocol-transaction/lib/interface");exports.ERC721=class{static prepareSafeTransferFrom(e,t,d){(0,n.default)(t,a.ow_baseData),(0,n.default)(d,f);const i=d.data?exports.erc721_def.encodeFunctionData("safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data)",[d.fromAddress,d.toAddress,d.tokenId,d.data]):exports.erc721_def.encodeFunctionData("safeTransferFrom(address _from, address _to, uint256 _tokenId)",[d.fromAddress,d.toAddress,d.tokenId]),u=(0,s.getBuilder)(Object.assign(Object.assign({},t),{data:i}));return(0,r.prepareSign)(e,u,o.TransactionType.NFT)}static prepareTransferFrom(e,t,d){(0,n.default)(t,a.ow_baseData),(0,n.default)(d,u);const i=exports.erc721_def.encodeFunctionData("transferFrom",[d.fromAddress,d.toAddress,d.tokenId]),f=(0,s.getBuilder)(Object.assign(Object.assign({},t),{data:i}));return(0,r.prepareSign)(e,f,o.TransactionType.NFT)}static prepareApprove(e,t,d){(0,n.default)(t,a.ow_baseData),(0,n.default)(d,c);const i=exports.erc721_def.encodeFunctionData("approve",[d.toAddress,d.tokenId]),u=(0,s.getBuilder)(Object.assign(Object.assign({},t),{data:i}));return(0,r.prepareSign)(e,u,o.TransactionType.NFT)}},exports.erc721_def=new t.Interface(["function balanceOf(address _owner) external view returns (uint256)","function ownerOf(uint256 _tokenId) external view returns (address)","function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable","function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable","function transferFrom(address _from, address _to, uint256 _tokenId) external payable","function approve(address _approved, uint256 _tokenId) external payable","function setApprovalForAll(address _operator, bool _approved) external","function getApproved(uint256 _tokenId) external view returns (address)","function isApprovedForAll(address _owner, address _operator) external view returns (bool)","function supportsInterface(bytes4 interfaceID) external view returns (bool)","function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes _data) external returns(bytes4)","event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId)","event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId)","event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved)","function name() external view returns (string _name)","function symbol() external view returns (string _symbol)","function tokenURI(uint256 _tokenId) external view returns (string)","function totalSupply() external view returns (uint256)","function tokenByIndex(uint256 _index) external view returns (uint256)","function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256)"]);const i={fromAddress:a.ow_address,toAddress:a.ow_address,tokenId:n.default.any(n.default.number.positive,a.ow_hexString32)},u=n.default.object.exactShape(i),f=n.default.object.exactShape(Object.assign(Object.assign({},i),{data:n.default.any(n.default.undefined,d.owTool.prefixedhexString,n.default.buffer)})),c=n.default.object.exactShape({toAddress:a.ow_address,tokenId:n.default.any(n.default.number.positive,a.ow_hexString32)});
{
"name": "@secux/app-eth",
"version": "3.0.10",
"version": "3.0.11",
"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