Data processing method and device of mock service, electronic equipment and storage medium
By using the data processing method of mock services, deployable contracts are generated and relevant information is saved to the database. This solves the problem that the front end cannot obtain contract call data in Dapp development, realizes collaborative development between the front end and the back end, and improves development efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2022-06-24
- Publication Date
- 2026-05-26
AI Technical Summary
During DApp development, before the contract is completed and deployed on the blockchain, front-end developers cannot obtain contract call data in advance, which restricts the overall project development progress and prevents front-end and back-end developers from effectively collaborating to complete the development.
This paper provides a data processing method for mock services. By obtaining contract material information, compiling it to obtain ABI information, rewriting the contract material information, generating a deployable contract and deploying it to the test chain, the ABI information, the call address information of the test chain, and the call address of the deployable contract are saved to the mock service database so that front-end developers can obtain contract call data in advance.
It solves the problem of collaborative development between front-end and back-end developers, improves development efficiency, and ensures that front-end developers can obtain contract call data in advance, enabling collaborative work between the front-end and back-end.
Smart Images

Figure CN115220823B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of mock service technology, and in particular to a data processing method, apparatus, electronic device and storage medium for mock services. Background Technology
[0002] This section is intended to provide background or context for the embodiments of this application as set forth in the claims. The description herein is not intended to be a prior art simply because it is included in this section.
[0003] DApps (Decentralized Applications) are applications developed using blockchain technology. During DApp development, backend developers design and implement smart contracts; after the smart contracts are deployed to the blockchain, frontend developers can call the smart contract interfaces to connect with data, providing users with a visual interface to complete DApp functionalities.
[0004] In the current DApp development process, the design and implementation of contracts by contract backend developers often takes a very long time. Before the contract is completed and deployed on the chain, frontend developers cannot obtain the contract call data in advance, which restricts the overall project development progress and makes it difficult for both parties to work together to complete the DApp function development. Summary of the Invention
[0005] In view of this, the purpose of this application is to provide a data processing method, apparatus, electronic device and storage medium for mock services.
[0006] To achieve the above objectives, this application provides a data processing method for a mock service, comprising:
[0007] Obtain contract material information;
[0008] The contract material information is compiled to obtain the ABI information of the contract material information;
[0009] The contract material information is rewritten based on the ABI information to obtain a deployable contract, and the deployable contract is deployed to the test chain;
[0010] The ABI information, the call address information of the test chain, and the call address of the deployed contract are saved to the database of the mock service.
[0011] In some embodiments, the contract material information is rewritten based on the ABI information to obtain a deployable contract, specifically including:
[0012] Based on the ABI information, determine whether the target method function in the contract material information has a return value;
[0013] In response to determining that the target method function has a return value, the return value portion of the target method function is replaced with a preset variable, and a deployable contract is obtained based on the replaced target method function.
[0014] In some embodiments, the contract material information is rewritten based on the ABI information to obtain a deployable contract, specifically including:
[0015] The ABI information is rewritten to obtain rewritten ABI information corresponding to the deployable contract;
[0016] The deployable contract is obtained based on the rewritten ABI information.
[0017] In some embodiments, the ABI information is rewritten to obtain rewritten ABI information corresponding to the deployable contract, which includes:
[0018] Identify all read methods in the ABI information, wherein each read method corresponds to a method function with a return value;
[0019] Add preset variable information to all read methods in the ABI information to obtain the rewritten ABI information corresponding to the deployable contract.
[0020] In some embodiments, obtaining the deployable contract based on the rewritten ABI information specifically includes:
[0021] Obtain the variable type and variable name for each method in the rewritten ABI information;
[0022] The deployable contract is obtained based on the preset template and the variable type and variable name of each method.
[0023] In some embodiments, rewriting the contract material information based on the ABI information further includes:
[0024] Add a rewrite function at a preset position in the target method function, and make the input value of the rewrite function equal to the preset variable.
[0025] In some embodiments, the ABI information is rewritten to obtain rewritten ABI information corresponding to the deployable contract, specifically including:
[0026] Add a corresponding write method for each read method in the ABI information so that the preset variable information can be modified;
[0027] Each write method corresponds to a rewrite function.
[0028] In some embodiments, the ABI information of the contract material information is obtained by compiling the contract material information, specifically including:
[0029] The ABI information of the contract material information is obtained by compiling the contract material information using the blockchain compiler SDK.
[0030] In some embodiments, after saving the ABI information, the call address information and ID of the test chain, and the call address of the deployed contract to the mock service's database, the method further includes:
[0031] In response to receiving a contract invocation instruction sent via the contract invocation SDK;
[0032] The SDK is invoked to return scenario data corresponding to the contract invocation instruction.
[0033] Based on the same inventive concept, an exemplary embodiment of this application also provides a data processing apparatus for a mock service, including:
[0034] The module retrieves contract material information;
[0035] The compilation module compiles the contract material information to obtain the ABI information of the contract material information;
[0036] The rewrite module rewrites the contract material information based on the ABI information to obtain a deployable contract, and then deploys the deployable contract to the test chain.
[0037] The storage module saves the ABI information, the call address information of the test chain, and the call address of the deployed contract after deployment to the database of the mock service.
[0038] Based on the same inventive concept, an exemplary embodiment of this application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable by the processor, wherein the processor executes the program to implement a data processing method for the mock service as described above.
[0039] Based on the same inventive concept, an exemplary embodiment of this application also provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the data processing method of the mock service as described above.
[0040] As can be seen from the above, the data processing method, apparatus, electronic device, and storage medium of the mock service provided in this application, after obtaining the contract material information uploaded by the backend developers, compiles the contract material information to obtain the ABI information of the contract material information; rewrites the contract material information based on the ABI information to obtain a deployable contract, and deploys the deployable contract to the test chain; saves the ABI information, the call address information of the test chain, and the call address of the deployed deployable contract to the mock service database. By rewriting the contract material information uploaded by the backend developers to obtain a deployable contract, the deployable contract can be deployed to the blockchain test chain. Then, the ABI information, the call address information of the test chain, and the call address of the deployed deployable contract are saved to the mock service database, so that frontend developers can obtain contract call data in advance through the mock service, thereby solving the problem of collaborative development between frontend and backend personnel and improving development efficiency. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in this application or related technologies, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is a flowchart illustrating a data processing method for a mock service according to an embodiment of this application.
[0043] Figure 2 This is a schematic diagram illustrating a process for collaborative development using a mock service, according to an embodiment of this application.
[0044] Figure 3 This is a schematic diagram of the structure of a data processing device for a mock service according to an embodiment of this application;
[0045] Figure 4 This is a schematic diagram of the structure of a specific electronic device according to an embodiment of this application. Detailed Implementation
[0046] The principles and spirit of this application will now be described with reference to several exemplary embodiments. It should be understood that these embodiments are provided merely to enable those skilled in the art to better understand and implement this application, and are not intended to limit the scope of this application in any way. Rather, these embodiments are provided to make this application more thorough and complete, and to fully convey the scope of this application to those skilled in the art.
[0047] According to embodiments of this application, a data processing method, apparatus, electronic device, and storage medium for mock services are proposed.
[0048] In this article, it is important to understand that any number of elements in the accompanying figures is for illustrative purposes and not for limitation, and any naming is for distinction only and has no limiting meaning.
[0049] The principles and spirit of this application will be explained in detail below with reference to several representative embodiments. Invention Overview
[0051] Currently, in related technologies, for DApp development, front-end developers cannot obtain contract call data in advance before the contract is developed and deployed on the chain. This restricts the overall project development progress and makes it difficult for front-end and back-end developers to collaborate effectively.
[0052] Currently, centralized applications typically use HTTP / HTTPS protocols for front-end and back-end data interaction, which raises the issue of collaborative development between front-end and back-end developers. In centralized applications, mock services are generally used to address this collaborative development challenge. A mock service simulates the request and response information of an interface defined by back-end developers, including the key interface information mentioned above, and allows developers to customize response information as needed for data testing and verification. This way, even without implementing the interface, front-end developers can still access the data interface and obtain the necessary scenario data, enabling collaborative development and significantly improving efficiency.
[0053] However, DApp development relies on blockchain services. Therefore, the development process requires a blockchain environment and smart contract interface services. The definition of blockchain interfaces is different from that of HTTP / HTTPS interfaces. As a result, the requirements for request and response information are also different. Consequently, it is impossible to use the mock services in centralized application development collaboration solutions for direct collaborative development during the DApp development process.
[0054] To address the aforementioned issues, this application provides a data processing method for mock services, specifically including:
[0055] After obtaining the contract material information uploaded by backend developers, the contract material information is compiled to obtain its ABI information. Based on the ABI information, the contract material information is rewritten to obtain a deployable contract, which is then deployed to the test chain. The ABI information, the test chain's call address information and ID, and the call address of the deployed deployable contract are saved to the mock service's database. By rewriting the contract material information uploaded by backend developers to obtain a deployable contract, the deployable contract can be deployed to the blockchain's test chain. The ABI information, the test chain's call address information, and the call address of the deployed deployable contract are then saved to the mock service's database. This allows frontend developers to obtain contract call data in advance through the mock service, thereby solving the collaborative development problem between frontend and backend developers and improving development efficiency.
[0056] After introducing the basic principles of this application, the various non-limiting embodiments of this application will be described in detail below.
[0057] Application Scenarios Overview
[0058] In some specific application scenarios, the data processing method of the mock service in this application can be applied to various contract systems that include mock services. Optionally, the contract system can be a blockchain-based contract system.
[0059] The following describes a data processing method for a mock service according to an exemplary embodiment of this application, using specific application scenarios. It should be noted that the above application scenarios are shown only to facilitate understanding of the spirit and principles of this application, and the embodiments of this application are not limited in any way. Rather, the embodiments of this application can be applied to any applicable scenario.
[0060] Exemplary methods
[0061] refer to Figure 1 This application provides a data processing method for a mock service, comprising the following steps:
[0062] S101, Obtain contract material information.
[0063] In practice, the contract material information uploaded by the backend developers is first obtained. It should be noted that this contract material information only defines the key information of the interface and does not include the actual implementation. Optionally, this key information includes the contract name and contract methods, and the contract methods include the input parameters, output parameters, and method name, etc.
[0064] S102, the contract material information is compiled to obtain the ABI information of the contract material information.
[0065] In practice, after obtaining the contract material information uploaded by the backend developers, the contract material information is compiled to obtain the ABI information of the contract material information. The ABI is a description of the contract interface. Optionally, the ABI information includes a list of contract interfaces, which includes one or more interfaces. Each interface includes at least an interface name, interface type, a description of the input parameters, and a description of the output parameters. Optionally, this information is saved in JSON format.
[0066] In some embodiments, the contract material information can be compiled using a blockchain compiler SDK to obtain the ABI information of the contract material information. Optionally, the blockchain compiler SDK is started via a Node.js service thread.
[0067] S103, based on the ABI information, the contract material information is rewritten to obtain a deployable contract, and the deployable contract is deployed to the test chain.
[0068] In practice, after obtaining the ABI information of the contract materials, the contract materials uploaded by the backend developers are rewritten based on this ABI information to obtain a deployable contract. This deployable contract is then deployed to a test chain, which is a type of test blockchain. Optionally, the test chain can be selected as needed; no specific restrictions are imposed here. For example, Ethereum's Ganache can be used as the test chain.
[0069] It's important to note that the contract material information uploaded by backend developers is relatively simple and cannot be deployed on the blockchain. For example, the uploaded contract material might include a read method with a return value, but the actual return value isn't provided in the uploaded contract material; that is, the part corresponding to the return value is in an incomplete state. Directly uploading such contract material to the blockchain for deployment will result in blockchain errors and deployment failure. Therefore, the contract material information uploaded by backend developers needs to be rewritten to obtain a deployable contract.
[0070] S104, save the ABI information, the call address information of the test chain, and the call address of the deployed contract to the database of the mock service.
[0071] In practice, after deploying the deployable contract to the test chain, the ABI information of the contract materials, the call address information of the test chain, and the call address of the deployed deployable contract are saved to the mock service's database. This allows front-end developers to retrieve the data in advance via the mock service. It should be noted that the call address information of the test chain is used to call the test chain that has deployed the deployable contract. When calling the deployable contract through the mock service, the test chain must first be called using its call address information, and then the deployable contract can be retrieved within the test chain using its call address. Optionally, the ID of the test chain can also be saved to the mock service's database. Each test chain has a unique ID, and the test chain to which the deployable contract is deployed can be retrieved using the test chain ID.
[0072] In some embodiments, the contract material information is rewritten based on the ABI information to obtain a deployable contract, specifically including:
[0073] Based on the ABI information, determine whether the target method function in the contract material information has a return value;
[0074] In response to determining that the target method function has a return value, the return value portion of the target method function is replaced with a preset variable, and a deployable contract is obtained based on the replaced target method function.
[0075] In specific implementation, when rewriting the contract material information, firstly, based on the ABI information, it is determined whether the target method function in the contract material information has a return value. When it is determined that the target method function has a return value, the return value portion of the target method function is replaced with a preset variable, and a deployable contract is obtained based on the replaced target method function. Optionally, the preset variable can be set as needed, and is not limited here. Generally, the numerical type of the preset variable needs to be consistent with the numerical type of the return value of the target method function. Optionally, after determining that the target method function has a return value, a regular expression can be used to match the target method function, and the return value portion (characters) of the target method function can be replaced with the preset variable.
[0076] In some embodiments, the contract material information is rewritten based on the ABI information to obtain a deployable contract, specifically including:
[0077] The ABI information is rewritten to obtain rewritten ABI information corresponding to the deployable contract;
[0078] The deployable contract is obtained based on the rewritten ABI information.
[0079] In practice, the ABI information of the contract material information can be rewritten first to obtain the rewritten ABI information corresponding to the deployable contract. Then, the deployable contract can be obtained based on the rewritten ABI information, thereby avoiding multiple replacements of the return value of the target method function and improving the efficiency of rewriting the contract material information.
[0080] In some embodiments, the ABI information is rewritten to obtain rewritten ABI information corresponding to the deployable contract, which includes:
[0081] Identify all read methods in the ABI information, wherein each read method corresponds to a method function with a return value;
[0082] Add preset variable information to all read methods in the ABI information to obtain the rewritten ABI information corresponding to the deployable contract.
[0083] In specific implementation, the ABI information is traversed to determine all read methods within it. Each read method corresponds to a function with a return value. Optionally, in some ABI information, methods with a return value are identified by querying for methods where the value after "type" is "function," the array length of "outputs" is not 0 (indicating a return value), and the field after "stateMutability" is "view." After determining all read methods in the ABI information, preset variable information is added to each read method to obtain the rewritten ABI information corresponding to the deployable contract. Optionally, this preset variable information can be set as needed. Generally, the data type of the preset variable information is consistent with the data type of the return value of the read method, and the name of the preset variable information is the same as the name of the return value of the read method.
[0084] In some embodiments, obtaining the deployable contract based on the rewritten ABI information specifically includes:
[0085] Obtain the variable type and variable name for each method in the rewritten ABI information;
[0086] The deployable contract is obtained based on the preset template and the variable type and variable name of each method.
[0087] In specific implementation, after obtaining the rewritten ABI information, the variable type and variable name of each method in the rewritten ABI information are first obtained. Optionally, the methods here include read methods and write methods. Then, the variable type and variable name corresponding to each method are filled into the preset template to obtain the deployable contract. It should be noted that the preset template can be set according to the deployment requirements. For example, the preset template for a certain method may include:
[0088] function<methodName>() public view returns(<returnType>){
[0089] return<method_name_value>
[0090] }”
[0091] In some embodiments, rewriting the contract material information based on the ABI information further includes:
[0092] Add a rewrite function at a preset position in the target method function, and make the input value of the rewrite function equal to the preset variable.
[0093] In practice, replacing the return value of the target method function with a preset variable ensures that the rewritten contract material information can be deployed. However, since the return value is replaced with a preset variable, the return value cannot be customized. This means that front-end developers may not be able to modify the response data (returned scenario data) to their current needs. To enable the response data to be customized according to their own needs, a rewriting function is added at a preset position in the target method function, and the input value of the rewriting function is equal to the preset variable.
[0094] In order to allow for the customization of deployable contract material information, in some embodiments, the ABI information is rewritten to obtain rewritten ABI information corresponding to the deployable contract, specifically including:
[0095] Add a corresponding write method for each read method in the ABI information so that the preset variable information can be modified;
[0096] Each write method corresponds to a rewrite function.
[0097] In some embodiments, after saving the ABI information, the call address information and ID of the test chain, and the call address of the deployed contract to the mock service's database, the method further includes:
[0098] In response to receiving a contract invocation instruction sent via the contract invocation SDK;
[0099] The SDK is invoked to return scenario data corresponding to the contract invocation instruction.
[0100] In specific implementation, refer to Figure 2 Backend developers upload contract material information via a web interface console. The mock service then rewrites the uploaded contract material information to obtain a deployable contract and deploys it to the test chain. The ABI information, the test chain's call address information, and the call address of the deployed deployable contract are then stored in the mock service's database. When frontend developers want to retrieve scenario data from the mock service, they send a contract call instruction to the mock service via the contract call SDK to obtain the corresponding scenario data. Optionally, the contract call instruction includes the call address information of the target contract and the target method in the target contract; the scenario data corresponds to the contract call instruction. The contract invocation SDK stores the IDs of multiple deployable contracts. Front-end developers only need to send the ID of the target contract they want to invoke and the name of the target method within that contract to the SDK. The SDK then determines the ABI information associated with the target contract ID, the call address information of the test chain, and the call address of the deployed deployable contract. It then sends the contract invocation instructions, including the call address information of the test chain, the call address of the target contract, and the target method within the target contract, to the mock service. The SDK retrieves the corresponding scenario data from the mock service. This scenario data corresponds to the target method in the target contract that the front-end developer wants to access. For example, if the front-end developer wants to access a read method, the scenario data is the current return value of that read method. The contract invocation SDK is a further encapsulation of web3.js, with two main functions: 1. Determining the invocation environment: using the contract mock service during development and switching to the production chain service in the production environment. 2. Establishing data integration with the mock service during development. Contract API calls require certain dependency information, including the chain address, contract address, contract methods, and contract API parameters. The contract API SDK can obtain this information from the contract mock service, eliminating the need for users to manually fill it in, thus improving development efficiency. For the production environment, users only need to manually configure the production chain address and contract address; other information remains unchanged. This ensures maximum consistency in development.
[0101] The data processing method for the mock service provided in this application, after obtaining contract material information uploaded by backend developers, compiles the contract material information to obtain ABI information; rewrites the contract material information based on the ABI information to obtain a deployable contract, and deploys the deployable contract to the test chain; saves the ABI information, the call address information and ID of the test chain, and the call address of the deployed deployable contract to the mock service database. By rewriting the contract material information uploaded by backend developers to obtain a deployable contract, the deployable contract can be deployed to the blockchain test chain. The ABI information, the call address information and ID of the test chain, and the call address of the deployed deployable contract are then saved to the mock service database. This allows frontend developers to obtain contract call data in advance through the mock service, thereby solving the collaborative development problem between frontend and backend developers and improving development efficiency.
[0102] Exemplary device
[0103] Based on the same inventive concept, corresponding to any of the above embodiments, this application also provides a data processing device for mock services.
[0104] refer to Figure 3 The data processing device for the mock service includes:
[0105] Module 201 retrieves contract material information;
[0106] Compilation module 202 compiles the contract material information to obtain the ABI information of the contract material information;
[0107] The rewrite module 203 rewrites the contract material information based on the ABI information to obtain a deployable contract, and then deploys the deployable contract to the test chain.
[0108] Storage module 204 saves the ABI information, the call address information of the test chain, and the call address of the deployed contract to the database of the mock service.
[0109] In some embodiments, the rewriting module is specifically configured as follows:
[0110] Based on the ABI information, determine whether the target method function in the contract material information has a return value;
[0111] In response to determining that the target method function has a return value, the return value portion of the target method function is replaced with a preset variable, and a deployable contract is obtained based on the replaced target method function.
[0112] In some embodiments, the rewriting module is specifically configured as follows:
[0113] The ABI information is rewritten to obtain rewritten ABI information corresponding to the deployable contract;
[0114] The deployable contract is obtained based on the rewritten ABI information.
[0115] In some embodiments, the rewriting module is specifically configured as follows:
[0116] Identify all read methods in the ABI information, wherein each read method corresponds to a method function with a return value;
[0117] Add preset variable information to all read methods in the ABI information to obtain the rewritten ABI information corresponding to the deployable contract.
[0118] In some embodiments, the rewriting module is specifically configured as follows:
[0119] Obtain the variable type and variable name for each method in the rewritten ABI information;
[0120] The deployable contract is obtained based on the preset template and the variable type and variable name of each method.
[0121] In some embodiments, the rewriting module is further configured to:
[0122] Add a rewrite function at a preset position in the target method function, and make the input value of the rewrite function equal to the preset variable.
[0123] In some embodiments, the rewriting module is further configured to:
[0124] Add a corresponding write method for each read method in the ABI information so that the preset variable information can be modified;
[0125] Each write method corresponds to a rewrite function.
[0126] In some embodiments, the compilation module is specifically configured as follows:
[0127] The ABI information of the contract material information is obtained by compiling the contract material information using the blockchain compiler SDK.
[0128] In some embodiments, the apparatus further includes a contract invocation module, which is configured to:
[0129] In response to receiving a contract invocation instruction sent via the contract invocation SDK;
[0130] The SDK is invoked to return scenario data corresponding to the contract invocation instruction.
[0131] For ease of description, the above devices are described in terms of function, divided into various modules. Of course, in implementing this application, the functions of each module can be implemented in one or more software and / or hardware.
[0132] The apparatus described above is used to implement the data processing method of the corresponding mock service in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0133] Based on the same inventive concept, corresponding to the methods of any of the above embodiments, this application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the data processing method of the mock service described in any of the above embodiments.
[0134] Figure 4 This embodiment illustrates a more specific hardware structure of an electronic device, which may include a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, memory 1020, input / output interface 1030, and communication interface 1040 are interconnected internally via the bus 1050.
[0135] The processor 1010 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0136] The memory 1020 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program code is stored in the memory 1020 and is called and executed by the processor 1010.
[0137] The input / output interface 1030 is used to connect input / output modules to realize information input and output. Input / output modules can be configured as components within the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Input devices may include keyboards, mice, touchscreens, microphones, various sensors, etc., while output devices may include displays, speakers, vibrators, indicator lights, etc.
[0138] The communication interface 1040 is used to connect a communication module (not shown in the figure) to enable communication between this device and other devices. The communication module can communicate via wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0139] Bus 1050 includes a pathway for transmitting information between various components of the device, such as processor 1010, memory 1020, input / output interface 1030, and communication interface 1040.
[0140] It should be noted that although the above-described device only shows the processor 1010, memory 1020, input / output interface 1030, communication interface 1040, and bus 1050, in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the embodiments of this specification, and not necessarily all the components shown in the figures.
[0141] The electronic devices described above are used to implement the data processing methods of the corresponding mock services in any of the foregoing embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0142] Exemplary program product
[0143] Based on the same inventive concept, corresponding to the methods of any of the above embodiments, this application also provides a non-transitory computer-readable storage medium that stores computer instructions for causing the computer to execute the data processing method of the mock service as described in any of the above embodiments.
[0144] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.
[0145] The computer instructions stored in the storage medium of the above embodiments are used to cause the computer to execute the data processing method of the mock service as described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0146] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of this application (including the claims) is limited to these examples; within the framework of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of the embodiments of this application as described above, which are not provided in the details for the sake of brevity.
[0147] Additionally, to simplify the description and discussion, and to avoid obscuring the embodiments of this application, the well-known power / ground connections to integrated circuit (IC) chips and other components may or may not be shown in the provided drawings. Furthermore, the apparatus may be shown in block diagram form to avoid obscuring the embodiments of this application, and this also takes into account the fact that the details of the implementation of these block diagram apparatuses are highly dependent on the platform on which the embodiments of this application will be implemented (i.e., these details should be fully understood by those skilled in the art). While specific details (e.g., circuits) have been set forth to describe exemplary embodiments of this application, it will be apparent to those skilled in the art that the embodiments of this application can be implemented without these specific details or with variations thereof. Therefore, these descriptions should be considered illustrative rather than restrictive.
[0148] Although this application has been described in conjunction with specific embodiments thereof, many substitutions, modifications, and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may be used with the embodiments discussed.
[0149] The embodiments of this application are intended to cover all such substitutions, modifications, and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the embodiments of this application should be included within the protection scope of this application.
Claims
1. A data processing method for a mock service, characterized in that, include: Obtain contract material information; the contract material information defines key information for the interface but is not specifically implemented. The contract material information is compiled to obtain the ABI information of the contract material information; Based on the ABI information, determine whether the target method function in the contract material information has a return value; in response to determining that the target method function has a return value, replace the return value portion of the target method function with a preset variable, and obtain a deployable contract based on the replaced target method function; or, The ABI information is rewritten to obtain rewritten ABI information corresponding to the deployable contract; the variable type and variable name of each method in the rewritten ABI information are obtained. Enter the variable type and variable name of each method into the preset template to obtain the deployable contract; Deploy the deployable contract to the test chain; The ABI information, the call address information of the test chain, and the call address of the deployed contract are saved to the database of the mock service.
2. The method according to claim 1, characterized in that, The ABI information is rewritten to obtain rewritten ABI information corresponding to the deployable contract, which includes: Identify all read methods in the ABI information, wherein each read method corresponds to a method function with a return value; Add preset variable information to all read methods in the ABI information to obtain the rewritten ABI information corresponding to the deployable contract.
3. The method according to claim 1, characterized in that, The rewriting of the contract material information based on the ABI information specifically includes: Add a rewrite function at a preset position in the target method function, and make the input value of the rewrite function equal to the preset variable.
4. The method according to claim 2, characterized in that, The ABI information is rewritten to obtain rewritten ABI information corresponding to the deployable contract, specifically including: Add a corresponding write method for each read method in the ABI information so that the preset variable information can be modified; Each write method corresponds to a rewrite function.
5. The method according to claim 1, characterized in that, The ABI information of the contract material information is obtained by compiling the contract material information, specifically including: The ABI information of the contract material information is obtained by compiling the contract material information using the blockchain compiler SDK.
6. The method according to claim 1, characterized in that, After saving the ABI information, the call address information of the test chain, and the call address of the deployed contract to the mock service's database, the method further includes: In response to receiving a contract invocation instruction sent via the contract invocation SDK; The SDK is invoked to return scenario data corresponding to the contract invocation instruction.
7. A data processing device for a mock service, characterized in that, include: The acquisition module acquires contract material information; the contract material information defines key information for the interface but is not specifically implemented. The compilation module compiles the contract material information to obtain the ABI information of the contract material information; The rewrite module determines, based on the ABI information, whether the target method function in the contract material information has a return value; in response to determining that the target method function has a return value, it replaces the return value portion of the target method function with a preset variable, and obtains a deployable contract based on the replaced target method function; or, The ABI information is rewritten to obtain rewritten ABI information corresponding to the deployable contract; the variable type and variable name of each method in the rewritten ABI information are obtained. Enter the variable type and variable name of each method into the preset template to obtain the deployable contract; Deploy the deployable contract to the test chain; The storage module saves the ABI information, the call address information of the test chain, and the call address of the deployed contract after deployment to the database of the mock service.
8. An electronic device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and executable by the processor, wherein the processor, when executing the program, implements the method as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium stores computer instructions for causing a computer to perform the method according to any one of claims 1 to 6.