@secux/app-eth
Advanced tools
Comparing version 3.0.5 to 3.0.6
@@ -154,3 +154,3 @@ /// <reference types="node" /> | ||
} | ||
export declare function prepareSign(path: string, builder: ETHTransactionBuilder, tp?: TransactionType): { | ||
export declare function prepareSign(path: string, builder: ETHTransactionBuilder, isBlind: boolean, tp?: TransactionType): { | ||
commandData: communicationData; | ||
@@ -157,0 +157,0 @@ rawTx: communicationData; |
@@ -1,1 +0,1 @@ | ||
"use strict";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=null===i.Logger||void 0===i.Logger?void 0:i.Logger.child({id:"ethereum"}),x=(0,i.ow_strictPath)(60,44);class S{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=S.resolvePublickey(e);return S.addressConvert(t)}static preparePublickey(e){return(0,a.default)(e,x),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,x),n.SecuxTransactionTool.getXPublickey(e)}static resolveXPublickey(e,t){return(0,a.default)(t,x),n.SecuxTransactionTool.resolveXPublickey(e,t)}static prepareSignSerialized(e,t){(0,a.default)(t,l.ow_communicationData);const r=(0,l.getBuffer)(t);null==d||d.debug(`- prepareSignSerialized\ninput serialized tx: ${r.toString("hex")}`);const i=u.ETHTransactionBuilder.deserialize(r);return(0,a.default)(i.tx.to,o.ow_address),T(e,i).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(S.resolveSignature(e),"hex");return null==d||d.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 T(e,(0,u.getBuilder)(t))}static resolveSignatureEIP155(e,t){(0,a.default)(e,l.ow_communicationData),(0,a.default)(t,a.default.optional.number.positive);const r=Buffer.from(S.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 T(e,(0,u.getBuilder)(t))}static prepareSignMessage(e,t){let r;return(0,a.default)(e,x),(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,a.default)(e,x);const r=JSON.parse(t);(0,a.default)(r,a.default.any(o.ow_EIP712TypedData,o.ow_TypedMessage));const i=c.TypedDataUtils.sanitizeData(r),s=[];s.push(c.TypedDataUtils.hashStruct("EIP712Domain",i.domain,i.types,!0)),"EIP712Domain"!==i.primaryType&&s.push(c.TypedDataUtils.hashStruct(i.primaryType.toString(),i.message,i.types,!0));const u=Buffer.concat(s);return n.SecuxTransactionTool.signTypedMessage(e,u)}static prepareSignWalletConnectTransaction(e,t){(0,a.default)(e,x),(0,a.default)(t,a.default.any(o.ow_tx155,o.ow_tx1559));const r=(0,u.getBuilder)(t),i=r.serialize(!0),c=n.SecuxTransactionTool.signTransaction(e,i,{tp:s.TransactionType.NORMAL,curve:s.EllipticCurve.SECP256K1,chainId:t.chainId});return(0,l.wrapResult)({commandData:c,rawTx:(0,l.toCommunicationData)(r.serialize())})}static async getAddress(e){const t=S.prepareAddress(e),r=await this.Exchange((0,l.getBuffer)(t));return S.resolveAddress(r)}static async getPublickey(e){const t=S.preparePublickey(e),r=await this.Exchange((0,l.getBuffer)(t));return S.resolvePublickey(r)}static async getXPublickey(e){const t=S.prepareXPublickey(e),r=await this.Exchange((0,l.getBuffer)(t));return S.resolveXPublickey(r,e)}static async sign(e,t,r){const a=async()=>{const r=S.prepareSignSerialized(e,t),a=await this.Exchange((0,l.getBuffer)(r));let i=Buffer.from(S.resolveSignature(a),"hex");return i=u.ETHTransactionBuilder.deserialize((0,l.getBuffer)(t)).getSignature(i),{raw_tx:S.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)?S.prepareSignTypedData:S.prepareSignMessage)(e,t),n=await this.Exchange((0,l.getBuffer)(i));return{raw_tx:void 0,signature:`0x${S.resolveSignatureEIP155(n,r)}`}}if(Buffer.isBuffer(t))return a();let i=S.prepareSignEIP155;"boolean"==typeof r&&r&&(i=S.prepareSignWalletConnectTransaction),(t.accessList||t.maxPriorityFeePerGas||t.maxFeePerGas)&&(i=S.prepareSignEIP1559);const{commandData:n,rawTx:s}=i(e,t),c=await this.Exchange((0,l.getBuffer)(n));let f=Buffer.from(S.resolveSignature(c),"hex");return f=u.ETHTransactionBuilder.deserialize((0,l.getBuffer)(s)).getSignature(f),{raw_tx:S.resolveTransaction(c,s),signature:`0x${f.toString("hex")}`}}}function T(e,t,r){var i;(0,a.default)(e,x),void 0===r&&(r=void 0===t.tx.value||"0"==t.tx.value?s.TransactionType.TOKEN:s.TransactionType.NORMAL);const o=n.SecuxTransactionTool.signRawTransaction(e,t.serialize(),{tp:r,curve:s.EllipticCurve.SECP256K1,chainId:null!==(i=t.tx.chainId)&&void 0!==i?i:1});return(0,l.wrapResult)({commandData:o,rawTx:(0,l.toCommunicationData)(t.serialize())})}exports.SecuxETH=S,S.ERC20=f.ERC20,S.ERC721=p.ERC721,S.ERC1155=g.ERC1155,(0,i.loadPlugin)(S,"SecuxETH"),exports.prepareSign=T; | ||
"use strict";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"),g=require("./erc721"),p=require("./erc1155"),d=null===i.Logger||void 0===i.Logger?void 0:i.Logger.child({id:"ethereum"}),x=(0,i.ow_strictPath)(60,44);class S{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=S.resolvePublickey(e);return S.addressConvert(t)}static preparePublickey(e){return(0,a.default)(e,x),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,x),n.SecuxTransactionTool.getXPublickey(e)}static resolveXPublickey(e,t){return(0,a.default)(t,x),n.SecuxTransactionTool.resolveXPublickey(e,t)}static prepareSignSerialized(e,t){(0,a.default)(t,l.ow_communicationData);const r=(0,l.getBuffer)(t);null==d||d.debug(`- prepareSignSerialized\ninput serialized tx: ${r.toString("hex")}`);const i=u.ETHTransactionBuilder.deserialize(r);return(0,a.default)(i.tx.to,o.ow_address),T(e,i,!1).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(S.resolveSignature(e),"hex");return null==d||d.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 T(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(S.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 T(e,(0,u.getBuilder)(t),!1)}static prepareSignMessage(e,t){let r;return(0,a.default)(e,x),(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,a.default)(e,x);const r=JSON.parse(t);(0,a.default)(r,a.default.any(o.ow_EIP712TypedData,o.ow_TypedMessage));const i=c.TypedDataUtils.sanitizeData(r),s=[];s.push(c.TypedDataUtils.hashStruct("EIP712Domain",i.domain,i.types,!0)),"EIP712Domain"!==i.primaryType&&s.push(c.TypedDataUtils.hashStruct(i.primaryType.toString(),i.message,i.types,!0));const u=Buffer.concat(s);return n.SecuxTransactionTool.signTypedMessage(e,u)}static prepareSignWalletConnectTransaction(e,t){(0,a.default)(e,x),(0,a.default)(t,a.default.any(o.ow_tx155,o.ow_tx1559));return T(e,(0,u.getBuilder)(t),!0)}static async getAddress(e){const t=S.prepareAddress(e),r=await this.Exchange((0,l.getBuffer)(t));return S.resolveAddress(r)}static async getPublickey(e){const t=S.preparePublickey(e),r=await this.Exchange((0,l.getBuffer)(t));return S.resolvePublickey(r)}static async getXPublickey(e){const t=S.prepareXPublickey(e),r=await this.Exchange((0,l.getBuffer)(t));return S.resolveXPublickey(r,e)}static async sign(e,t,r){const a=async()=>{const r=S.prepareSignSerialized(e,t),a=await this.Exchange((0,l.getBuffer)(r));let i=Buffer.from(S.resolveSignature(a),"hex");return i=u.ETHTransactionBuilder.deserialize((0,l.getBuffer)(t)).getSignature(i),{raw_tx:S.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)?S.prepareSignTypedData:S.prepareSignMessage)(e,t),n=await this.Exchange((0,l.getBuffer)(i));return{raw_tx:void 0,signature:`0x${S.resolveSignatureEIP155(n,r)}`}}if(Buffer.isBuffer(t))return a();let i=S.prepareSignEIP155;"boolean"==typeof r&&r&&(i=S.prepareSignWalletConnectTransaction),(t.accessList||t.maxPriorityFeePerGas||t.maxFeePerGas)&&(i=S.prepareSignEIP1559);const{commandData:n,rawTx:s}=i(e,t),c=await this.Exchange((0,l.getBuffer)(n));let f=Buffer.from(S.resolveSignature(c),"hex");return f=u.ETHTransactionBuilder.deserialize((0,l.getBuffer)(s)).getSignature(f),{raw_tx:S.resolveTransaction(c,s),signature:`0x${f.toString("hex")}`}}}function T(e,t,r,i){var o;(0,a.default)(e,x),void 0===i&&(i=void 0===t.tx.value||"0"==t.tx.value?s.TransactionType.TOKEN:s.TransactionType.NORMAL),r&&(i=s.TransactionType.NORMAL);const u={tp:i,curve:s.EllipticCurve.SECP256K1,chainId:null!==(o=t.tx.chainId)&&void 0!==o?o:1},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=S,S.ERC20=f.ERC20,S.ERC721=g.ERC721,S.ERC1155=p.ERC1155,(0,i.loadPlugin)(S,"SecuxETH"),exports.prepareSign=T; |
@@ -1,1 +0,1 @@ | ||
"use strict";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)} | ||
"use strict";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,!0)}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)} |
@@ -1,1 +0,1 @@ | ||
"use strict";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)}); | ||
"use strict";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)}); |
@@ -1,1 +0,1 @@ | ||
"use strict";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)}); | ||
"use strict";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)}); |
{ | ||
"name": "@secux/app-eth", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "SecuX Hardware Wallet ETH API", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
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
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
823997