UNPKG

@secux/app-eth

Version:
18 lines (15 loc) 3.94 kB
"use strict"; /*! Copyright 2022 SecuX Technology Inc Copyright Chen Wei-En Copyright Wu Tsung-Yu Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */var __importDefault=this&&this.__importDefault||function(mod){return mod&&mod.__esModule?mod:{default:mod}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.isJsonString=exports.ow_TypedMessage=exports.ow_EIP712TypedData=exports.ow_TypedDataV1=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 ow_1=__importDefault(require("ow")),utility_1=require("@secux/utility"),validate=require("wallet-address-validator").validate;exports.ow_address=ow_1.default.string.matches(/^0x[0-9A-Fa-f]{40}$/).validate((x=>({validator:validate(x,"ETH"),message:`ArgumentError: invalid address, got "${x}"`}))),exports.ow_hexString32=ow_1.default.string.matches(/^0x[a-fA-F0-9]{1,64}$/),exports.ow_gasPriceUnit=ow_1.default.any(ow_1.default.number.uint32.positive,utility_1.owTool.prefixedhexString);const ow_data=ow_1.default.string.matches(/^0x[0-9A-F-a-f]*$/),__tx155={chainId:ow_1.default.any(ow_1.default.number.positive,utility_1.owTool.prefixedhexString),nonce:ow_1.default.any(ow_1.default.number,utility_1.owTool.prefixedhexString),gasPrice:exports.ow_gasPriceUnit,gasLimit:ow_1.default.any(ow_1.default.number.positive,utility_1.owTool.prefixedhexString),to:exports.ow_address,value:ow_1.default.any(ow_1.default.number.not.negative,utility_1.owTool.prefixedhexString)};exports.ow_tx155_base=ow_1.default.object.partialShape(__tx155),exports.ow_tx155=ow_1.default.object.partialShape(Object.assign(Object.assign({},__tx155),{data:ow_1.default.any(ow_1.default.undefined,ow_data)}));const __tx1559={chainId:ow_1.default.any(ow_1.default.number.positive,utility_1.owTool.prefixedhexString),nonce:ow_1.default.any(ow_1.default.number,utility_1.owTool.prefixedhexString),maxPriorityFeePerGas:ow_1.default.any(ow_1.default.number.uint32.positive,utility_1.owTool.prefixedhexString),maxFeePerGas:exports.ow_gasPriceUnit,gasLimit:ow_1.default.any(ow_1.default.number.positive,utility_1.owTool.prefixedhexString),to:exports.ow_address,value:ow_1.default.any(ow_1.default.undefined,ow_1.default.number.not.negative,utility_1.owTool.prefixedhexString),accessList:ow_1.default.any(ow_1.default.undefined,ow_1.default.array.ofType(ow_1.default.any()))};exports.ow_tx1559_base=ow_1.default.object.partialShape(__tx1559),exports.ow_tx1559=ow_1.default.object.partialShape(Object.assign(Object.assign({},__tx1559),{data:ow_1.default.any(ow_1.default.undefined,ow_data)})),exports.ow_baseData=ow_1.default.any(exports.ow_tx155_base,exports.ow_tx1559_base),exports.ow_TypedDataV1=ow_1.default.object.exactShape({name:ow_1.default.string,type:ow_1.default.string,value:ow_1.default.string}),exports.ow_EIP712TypedData=ow_1.default.object.exactShape({name:ow_1.default.string,type:ow_1.default.string}),exports.ow_TypedMessage=ow_1.default.object.exactShape({types:ow_1.default.object.valuesOfType(ow_1.default.array.ofType(exports.ow_EIP712TypedData)),primaryType:ow_1.default.string,domain:ow_1.default.object.exactShape({name:ow_1.default.optional.string,version:ow_1.default.optional.string,chainId:ow_1.default.optional.number.not.negative,verifyingContract:ow_1.default.optional.string}),message:ow_1.default.object}),exports.isJsonString=function(str){try{JSON.parse(str)}catch(error){return!1}return!0};