hyperledger / web3j

Lightweight Java and Android library for integration with Ethereum clients
https://www.web3labs.com/web3j-sdk
Other
5.07k stars 1.68k forks source link

Can not generate a contract via $web3j generate solidity. Likely is know bug with external struct #1789

Closed Gelassen closed 1 year ago

Gelassen commented 1 year ago

_Bugtitle

Can not generate a contract via $web3j generate solidity with message

Generating com.example.wallet.contract.SwapValue ... Warning: Duplicate field(s) found: [FUNC_SAFETRANSFERFROM]. Please don't use names which will be the same in uppercase. not a valid name: struct Value

Likely it is #a known issue

Steps To Reproduce

  1. Take a contract
  2. Generate a contract abi and bin via hardhat compile
  3. Use command to generate java wrappers $web3j generate solidity -a SwapValue.abi -b SwapValue.bin -o . -p com.example.wallet.contract

Expected behavior

A contract java wrapper should appear in the root directory

Actual behavior

Message in console and there is no contract

Environment

Gelassen commented 1 year ago

@SweeXordious, could you please take a look? You had worked on similar issue, but a year later it is not in the release.

rach-id commented 1 year ago

Can you please try compiling the contract using solc and try again? Also, if you could share the bin and abi you have, would be awesome.

Gelassen commented 1 year ago

SwapValue.zip Here is existing .abi and .bin which had been extracted from .json generated over hardhat. I will work on solc compiler result in a minute.

Gelassen commented 1 year ago

Compiling over solc ($solc --bon SwapValue.sol) gives variety of errors linked to lack of imports:

/Workspace/Personal/Android/swap/blockchain/contracts$ solc --bin SwapValue.sol
Error: Source "@openzeppelin/contracts/token/ERC721/ERC721.sol" not found: File not found. Searched the following locations: "".
 --> SwapValue.sol:4:1:
  |
4 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol" not found: File not found. Searched the following locations: "".
 --> SwapValue.sol:5:1:
  |
5 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "@openzeppelin/contracts/access/Ownable.sol" not found: File not found. Searched the following locations: "".
 --> SwapValue.sol:6:1:
  |
6 | import "@openzeppelin/contracts/access/Ownable.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "@openzeppelin/contracts/utils/Counters.sol" not found: File not found. Searched the following locations: "".
 --> SwapValue.sol:7:1:
  |
7 | import "@openzeppelin/contracts/utils/Counters.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "contracts/structs/StructDeclaration.sol" not found: File not found. Searched the following locations: "".
 --> SwapValue.sol:8:1:
  |
8 | import { Value } from "../contracts/structs/StructDeclaration.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "contracts/ISwapValue.sol" not found: File not found. Searched the following locations: "".
 --> SwapValue.sol:9:1:
  |
9 | import "../contracts/ISwapValue.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "hardhat/console.sol" not found: File not found. Searched the following locations: "".
  --> SwapValue.sol:10:1:
   |
10 | import "hardhat/console.sol";
Gelassen commented 1 year ago

A quick search shows several workarounds on this issue. A one of them is to add direct paths to the command:

$ --allow-path "/path/to/folderOne" --allow-path "/path/to/folderTwo"

, but it should not help with import to non local files like @openzeppelin/contracts/token/ERC721/ERC721.sol

Do you have any suggestion here?

rach-id commented 1 year ago

For these:

@openzeppelin/contracts/token/ERC721/ERC721.sol

They should be downloaded locally and changing @openzeppelin to where the contracts are. I'll try doing it later today if I have time and come back to you

Gelassen commented 1 year ago

contract with local dependencies compiled over solc.zip I downloaded files to have them locally, changed paths to these local files and compile them via command $solc --abi --bin --optimize contracts/SwapValue.sol -o temp

Although running $web3j generate solidity command still returns the same issue with reference on invalid Value struct.

Checking official compiler docs only library import requires extra effort on final bytecode, the plain imports on local contracts should be compiled automatically.

Files added to this post if in case you need them.

A little bit more context regarding this issue. I came here when had faced with issue to run safeMint() on my contract (*). The balanceOf() call executes correctly, but safeMint() doesn't. Origin .sol contracts works well -- it was heavily tested locally over hardhat and this web service helped to verify it on Goerly testnet. There is no known issue with contract itself. The point is originally I implemented required by PoC logic manually as I had others issues with web3j java wrappers generators. When I faced with issue to run safeMint(), I made a list of possible bug causes where not correct implementation of java wrapper was one of them. That's why I have to return back to web3j java wrapper generator to confirm or exclude this possible root cause of the issue.

(*) the system returns error either 'Contract has been reverted' or "Transaction receipt was not generated after 600 seconds for transaction" when I doubled the gas passed with function.

rach-id commented 1 year ago

Okey, so I was able to use the web3j-gradle-plugin to generate the wrapper:

package org.web3j;

import io.reactivex.Flowable;
import io.reactivex.functions.Function;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import org.web3j.abi.EventEncoder;
import org.web3j.abi.TypeReference;
import org.web3j.abi.datatypes.Address;
import org.web3j.abi.datatypes.Bool;
import org.web3j.abi.datatypes.DynamicArray;
import org.web3j.abi.datatypes.DynamicStruct;
import org.web3j.abi.datatypes.Event;
import org.web3j.abi.datatypes.Type;
import org.web3j.abi.datatypes.Utf8String;
import org.web3j.abi.datatypes.generated.Uint256;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameter;
import org.web3j.protocol.core.RemoteCall;
import org.web3j.protocol.core.RemoteFunctionCall;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.response.BaseEventResponse;
import org.web3j.protocol.core.methods.response.Log;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.tx.Contract;
import org.web3j.tx.TransactionManager;
import org.web3j.tx.gas.ContractGasProvider;

/**
 * <p>Auto generated code.
 * <p><strong>Do not modify!</strong>
 * <p>Please use the <a href="https://docs.web3j.io/command_line.html">web3j command line tools</a>,
 * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the 
 * <a href="https://github.com/web3j/web3j/tree/master/codegen">codegen module</a> to update.
 *
 * <p>Generated with web3j version 4.9.4.
 */
@SuppressWarnings("rawtypes")
public class SwapValue extends Contract {
    public static final String BINARY = "60806040523480156200001157600080fd5b5060408051808201825260098152685377617056616c756560b81b60208083019182528351808501909452600384526229abab60e91b9084015281519192916200005e91600091620000ed565b50805162000074906001906020840190620000ed565b505050620000916200008b6200009760201b60201c565b6200009b565b620001cf565b3390565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b828054620000fb9062000193565b90600052602060002090601f0160209004810192826200011f57600085556200016a565b82601f106200013a57805160ff19168380011785556200016a565b828001600101855582156200016a579182015b828111156200016a5782518255916020019190600101906200014d565b50620001789291506200017c565b5090565b5b808211156200017857600081556001016200017d565b600181811c90821680620001a857607f821691505b602082108103620001c957634e487b7160e01b600052602260045260246000fd5b50919050565b6121eb80620001df6000396000f3fe608060405234801561001057600080fd5b50600436106101425760003560e01c8063715018a6116100b8578063a22cb4651161007c578063a22cb465146102b8578063b88d4fde146102cb578063baa34110146102de578063c87b56dd146102f1578063e985e9c514610304578063f2fde38b1461031757600080fd5b8063715018a614610264578063761610fc1461026c5780638da5cb5b1461028c57806395d89b411461029d5780639dc29fac146102a557600080fd5b806323b872dd1161010a57806323b872dd146101d75780632b910aa2146101ea57806342842e0e146101fd578063442342a6146102105780636352211e1461023057806370a082311461024357600080fd5b806301ffc9a71461014757806306fdde031461016f578063081812fc14610184578063095ea7b3146101af5780631a1a1fb1146101c4575b600080fd5b61015a61015536600461195c565b61032a565b60405190151581526020015b60405180910390f35b61017761037c565b60405161016691906119d1565b6101976101923660046119e4565b61040e565b6040516001600160a01b039091168152602001610166565b6101c26101bd366004611a19565b610435565b005b6101c26101d2366004611acf565b61054f565b6101c26101e5366004611b5f565b610596565b6101c26101f83660046119e4565b6105ac565b6101c261020b366004611b5f565b610634565b61022361021e366004611b9b565b61064f565b6040516101669190611bb6565b61019761023e3660046119e4565b6106bb565b610256610251366004611b9b565b61071b565b604051908152602001610166565b6101c26107a1565b61027f61027a3660046119e4565b6107b5565b6040516101669190611bfa565b6007546001600160a01b0316610197565b61017761092b565b6101c26102b3366004611a19565b61093a565b6101c26102c6366004611c5a565b610951565b6101c26102d9366004611c91565b61095c565b6101c26102ec366004611d0d565b61098e565b6101776102ff3660046119e4565b610a02565b61015a610312366004611d2f565b610a0d565b6101c2610325366004611b9b565b610a3b565b60006001600160e01b031982166380ac58cd60e01b148061035b57506001600160e01b03198216635b5e139f60e01b145b8061037657506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606000805461038b90611d62565b80601f01602080910402602001604051908101604052809291908181526020018280546103b790611d62565b80156104045780601f106103d957610100808354040283529160200191610404565b820191906000526020600020905b8154815290600101906020018083116103e757829003601f168201915b5050505050905090565b600061041982610ab4565b506000908152600460205260409020546001600160a01b031690565b6000610440826106bb565b9050806001600160a01b0316836001600160a01b0316036104b25760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b03821614806104ce57506104ce8133610a0d565b6105405760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c000060648201526084016104a9565b61054a8383610b13565b505050565b610557610b81565b600061056260085490565b9050610572600880546001019055565b61057c8482610bdb565b6105868183610c11565b6105908382610cab565b50505050565b6105a1838383610cc5565b61054a838383610cf6565b80336105b7826106bb565b6001600160a01b031614806105dc5750336105d18261040e565b6001600160a01b0316145b806105f457506105f46105ee826106bb565b33610a0d565b6106105760405162461bcd60e51b81526004016104a990611d9c565b50600090815260096020526040812060038101805460ff1916600117905560040155565b61054a8383836040518060200160405280600081525061095c565b6001600160a01b0381166000908152600a60209081526040918290208054835181840281018401909452808452606093928301828280156106af57602002820191906000526020600020905b81548152602001906001019080831161069b575b50505050509050919050565b6000818152600260205260408120546001600160a01b0316806103765760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016104a9565b60006001600160a01b0382166107855760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b60648201526084016104a9565b506001600160a01b031660009081526003602052604090205490565b6107a9610b81565b6107b36000610da5565b565b6107e96040518060a00160405280606081526020016000815260200160008152602001600015158152602001600081525090565b6000828152600260205260409020546001600160a01b031661084d5760405162461bcd60e51b815260206004820152601a60248201527f5468697320746f6b656e20646f6573206e6f742065786973742e00000000000060448201526064016104a9565b60008281526009602052604090819020815160a0810190925280548290829061087590611d62565b80601f01602080910402602001604051908101604052809291908181526020018280546108a190611d62565b80156108ee5780601f106108c3576101008083540402835291602001916108ee565b820191906000526020600020905b8154815290600101906020018083116108d157829003601f168201915b50505091835250506001820154602082015260028201546040820152600382015460ff161515606082015260049091015460809091015292915050565b60606001805461038b90611d62565b61094381610df7565b61094d8282610e00565b5050565b61094d338383610ea4565b6109663383610f72565b6109825760405162461bcd60e51b81526004016104a990611e0f565b61059084848484610fd1565b8133610999826106bb565b6001600160a01b031614806109be5750336109b38261040e565b6001600160a01b0316145b806109d057506109d06105ee826106bb565b6109ec5760405162461bcd60e51b81526004016104a990611d9c565b5060009182526009602052604090912060040155565b606061037682611004565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b610a43610b81565b6001600160a01b038116610aa85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016104a9565b610ab181610da5565b50565b6000818152600260205260409020546001600160a01b0316610ab15760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016104a9565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610b48826106bb565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6007546001600160a01b031633146107b35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104a9565b610be58282611131565b6001600160a01b039091166000908152600a602090815260408220805460018101825590835291200155565b6000828152600260205260409020546001600160a01b0316610c8c5760405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b60648201526084016104a9565b6000828152600660209081526040909120825161054a92840190611877565b600081815260096020526040902082906105908282611f79565b610ccf3382610f72565b610ceb5760405162461bcd60e51b81526004016104a990611e0f565b61054a83838361114b565b6001600160a01b0383166000908152600a60205260408120905b8154811015610d835782828281548110610d2c57610d2c612012565b906000526020600020015403610d71576001600160a01b0384166000908152600a6020908152604082208054600181018255908352912001839055610d7181836112e7565b80610d7b8161203e565b915050610d10565b50506000908152600960205260409020600301805460ff191660011790555050565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610ab18161138c565b6001600160a01b0382166000908152600a60205260408120905b8154811015610e625782828281548110610e3657610e36612012565b906000526020600020015403610e5057610e5081836112e7565b80610e5a8161203e565b915050610e1a565b50600082815260096020526040812090610e7c82826118fb565b506000600182018190556002820181905560038201805460ff19169055600490910155505050565b816001600160a01b0316836001600160a01b031603610f055760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016104a9565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b600080610f7e836106bb565b9050806001600160a01b0316846001600160a01b03161480610fa55750610fa58185610a0d565b80610fc95750836001600160a01b0316610fbe8461040e565b6001600160a01b0316145b949350505050565b610fdc84848461114b565b610fe8848484846113cc565b6105905760405162461bcd60e51b81526004016104a990612057565b606061100f82610ab4565b6000828152600660205260408120805461102890611d62565b80601f016020809104026020016040519081016040528092919081815260200182805461105490611d62565b80156110a15780601f10611076576101008083540402835291602001916110a1565b820191906000526020600020905b81548152906001019060200180831161108457829003601f168201915b5050505050905060006110e46040805180820190915260208082527f68747470733a2f2f67656c617373656e2e6769746875622e696f2f626c6f672f9082015290565b905080516000036110f6575092915050565b8151156111285780826040516020016111109291906120a9565b60405160208183030381529060405292505050919050565b610fc9846114cd565b61094d828260405180602001604052806000815250611566565b826001600160a01b031661115e826106bb565b6001600160a01b0316146111c25760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b60648201526084016104a9565b6001600160a01b0382166112245760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016104a9565b61122f600082610b13565b6001600160a01b03831660009081526003602052604081208054600192906112589084906120d8565b90915550506001600160a01b03821660009081526003602052604081208054600192906112869084906120ef565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b805482106112f3575050565b815b8154611303906001906120d8565b81101561136157816113168260016120ef565b8154811061132657611326612012565b906000526020600020015482828154811061134357611343612012565b600091825260209091200155806113598161203e565b9150506112f5565b508080548061137257611372612107565b600190038181906000526020600020016000905590555050565b61139581611599565b600081815260066020526040902080546113ae90611d62565b159050610ab1576000818152600660205260408120610ab1916118fb565b60006001600160a01b0384163b156114c257604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061141090339089908890889060040161211d565b6020604051808303816000875af192505050801561144b575060408051601f3d908101601f191682019092526114489181019061215a565b60015b6114a8573d808015611479576040519150601f19603f3d011682016040523d82523d6000602084013e61147e565b606091505b5080516000036114a05760405162461bcd60e51b81526004016104a990612057565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610fc9565b506001949350505050565b60606114d882610ab4565b60006115146040805180820190915260208082527f68747470733a2f2f67656c617373656e2e6769746875622e696f2f626c6f672f9082015290565b90506000815111611534576040518060200160405280600081525061155f565b8061153e84611634565b60405160200161154f9291906120a9565b6040516020818303038152906040525b9392505050565b6115708383611735565b61157d60008484846113cc565b61054a5760405162461bcd60e51b81526004016104a990612057565b60006115a4826106bb565b90506115b1600083610b13565b6001600160a01b03811660009081526003602052604081208054600192906115da9084906120d8565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60608160000361165b5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611685578061166f8161203e565b915061167e9050600a8361218d565b915061165f565b60008167ffffffffffffffff8111156116a0576116a0611a43565b6040519080825280601f01601f1916602001820160405280156116ca576020820181803683370190505b5090505b8415610fc9576116df6001836120d8565b91506116ec600a866121a1565b6116f79060306120ef565b60f81b81838151811061170c5761170c612012565b60200101906001600160f81b031916908160001a90535061172e600a8661218d565b94506116ce565b6001600160a01b03821661178b5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016104a9565b6000818152600260205260409020546001600160a01b0316156117f05760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016104a9565b6001600160a01b03821660009081526003602052604081208054600192906118199084906120ef565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461188390611d62565b90600052602060002090601f0160209004810192826118a557600085556118eb565b82601f106118be57805160ff19168380011785556118eb565b828001600101855582156118eb579182015b828111156118eb5782518255916020019190600101906118d0565b506118f7929150611931565b5090565b50805461190790611d62565b6000825580601f10611917575050565b601f016020900490600052602060002090810190610ab191905b5b808211156118f75760008155600101611932565b6001600160e01b031981168114610ab157600080fd5b60006020828403121561196e57600080fd5b813561155f81611946565b60005b8381101561199457818101518382015260200161197c565b838111156105905750506000910152565b600081518084526119bd816020860160208601611979565b601f01601f19169290920160200192915050565b60208152600061155f60208301846119a5565b6000602082840312156119f657600080fd5b5035919050565b80356001600160a01b0381168114611a1457600080fd5b919050565b60008060408385031215611a2c57600080fd5b611a35836119fd565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115611a7457611a74611a43565b604051601f8501601f19908116603f01168101908282118183101715611a9c57611a9c611a43565b81604052809350858152868686011115611ab557600080fd5b858560208301376000602087830101525050509392505050565b600080600060608486031215611ae457600080fd5b611aed846119fd565b9250602084013567ffffffffffffffff80821115611b0a57600080fd5b9085019060a08288031215611b1e57600080fd5b90925060408501359080821115611b3457600080fd5b508401601f81018613611b4657600080fd5b611b5586823560208401611a59565b9150509250925092565b600080600060608486031215611b7457600080fd5b611b7d846119fd565b9250611b8b602085016119fd565b9150604084013590509250925092565b600060208284031215611bad57600080fd5b61155f826119fd565b6020808252825182820181905260009190848201906040850190845b81811015611bee57835183529284019291840191600101611bd2565b50909695505050505050565b602081526000825160a06020840152611c1660c08401826119a5565b90506020840151604084015260408401516060840152606084015115156080840152608084015160a08401528091505092915050565b8015158114610ab157600080fd5b60008060408385031215611c6d57600080fd5b611c76836119fd565b91506020830135611c8681611c4c565b809150509250929050565b60008060008060808587031215611ca757600080fd5b611cb0856119fd565b9350611cbe602086016119fd565b925060408501359150606085013567ffffffffffffffff811115611ce157600080fd5b8501601f81018713611cf257600080fd5b611d0187823560208401611a59565b91505092959194509250565b60008060408385031215611d2057600080fd5b50508035926020909101359150565b60008060408385031215611d4257600080fd5b611d4b836119fd565b9150611d59602084016119fd565b90509250929050565b600181811c90821680611d7657607f821691505b602082108103611d9657634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252604d908201527f4f6e6c7920746f6b656e206f776e6572206f72206163746f7220617070726f7660408201527f6564206279206f776e657220697320616c6c6f77656420746f2063616c6c207460608201526c3434b990333ab731ba34b7b71760991b608082015260a00190565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b601f82111561054a57600081815260208120601f850160051c81016020861015611e845750805b601f850160051c820191505b81811015611ea357828155600101611e90565b505050505050565b67ffffffffffffffff831115611ec357611ec3611a43565b611ed783611ed18354611d62565b83611e5d565b6000601f841160018114611f0b5760008515611ef35750838201355b600019600387901b1c1916600186901b178355611f65565b600083815260209020601f19861690835b82811015611f3c5786850135825560209485019460019092019101611f1c565b5086821015611f595760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b6000813561037681611c4c565b8135601e19833603018112611f8d57600080fd5b8201803567ffffffffffffffff811115611fa657600080fd5b602082019150803603821315611fbb57600080fd5b611fc6818385611eab565b50506020820135600182015560408201356002820155612004611feb60608401611f6c565b6003830160ff1981541660ff8315151681178255505050565b608082013560048201555050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001820161205057612050612028565b5060010190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b600083516120bb818460208801611979565b8351908301906120cf818360208801611979565b01949350505050565b6000828210156120ea576120ea612028565b500390565b6000821982111561210257612102612028565b500190565b634e487b7160e01b600052603160045260246000fd5b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612150908301846119a5565b9695505050505050565b60006020828403121561216c57600080fd5b815161155f81611946565b634e487b7160e01b600052601260045260246000fd5b60008261219c5761219c612177565b500490565b6000826121b0576121b0612177565b50069056fea26469706673582212204f6a347309d9cd495a4b6e6417648ca47990bb237ee16b35513b7f583200d04664736f6c634300080d0033";

    public static final String FUNC_APPROVE = "approve";

    public static final String FUNC_BALANCEOF = "balanceOf";

    public static final String FUNC_BURN = "burn";

    public static final String FUNC_GETAPPROVED = "getApproved";

    public static final String FUNC_GETTOKENSIDSFORUSER = "getTokensIdsForUser";

    public static final String FUNC_ISAPPROVEDFORALL = "isApprovedForAll";

    public static final String FUNC_LOCKTOKEN = "lockToken";

    public static final String FUNC_MAKETOKENCONSUMED = "makeTokenConsumed";

    public static final String FUNC_NAME = "name";

    public static final String FUNC_OFFER = "offer";

    public static final String FUNC_OWNER = "owner";

    public static final String FUNC_OWNEROF = "ownerOf";

    public static final String FUNC_RENOUNCEOWNERSHIP = "renounceOwnership";

    public static final String FUNC_SAFEMINT = "safeMint";

    public static final String FUNC_safeTransferFrom = "safeTransferFrom";

    public static final String FUNC_SETAPPROVALFORALL = "setApprovalForAll";

    public static final String FUNC_SUPPORTSINTERFACE = "supportsInterface";

    public static final String FUNC_SYMBOL = "symbol";

    public static final String FUNC_TOKENURI = "tokenURI";

    public static final String FUNC_TRANSFERFROM = "transferFrom";

    public static final String FUNC_TRANSFEROWNERSHIP = "transferOwnership";

    public static final Event APPROVAL_EVENT = new Event("Approval", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}, new TypeReference<Uint256>(true) {}));
    ;

    public static final Event APPROVALFORALL_EVENT = new Event("ApprovalForAll", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}, new TypeReference<Bool>() {}));
    ;

    public static final Event OWNERSHIPTRANSFERRED_EVENT = new Event("OwnershipTransferred", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}));
    ;

    public static final Event TRANSFER_EVENT = new Event("Transfer", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}, new TypeReference<Uint256>(true) {}));
    ;

    @Deprecated
    protected SwapValue(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    protected SwapValue(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
    }

    @Deprecated
    protected SwapValue(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    protected SwapValue(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public static List<ApprovalEventResponse> getApprovalEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = staticExtractEventParametersWithLog(APPROVAL_EVENT, transactionReceipt);
        ArrayList<ApprovalEventResponse> responses = new ArrayList<ApprovalEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            ApprovalEventResponse typedResponse = new ApprovalEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.approved = (String) eventValues.getIndexedValues().get(1).getValue();
            typedResponse.tokenId = (BigInteger) eventValues.getIndexedValues().get(2).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public Flowable<ApprovalEventResponse> approvalEventFlowable(EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(new Function<Log, ApprovalEventResponse>() {
            @Override
            public ApprovalEventResponse apply(Log log) {
                Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(APPROVAL_EVENT, log);
                ApprovalEventResponse typedResponse = new ApprovalEventResponse();
                typedResponse.log = log;
                typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue();
                typedResponse.approved = (String) eventValues.getIndexedValues().get(1).getValue();
                typedResponse.tokenId = (BigInteger) eventValues.getIndexedValues().get(2).getValue();
                return typedResponse;
            }
        });
    }

    public Flowable<ApprovalEventResponse> approvalEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(APPROVAL_EVENT));
        return approvalEventFlowable(filter);
    }

    public static List<ApprovalForAllEventResponse> getApprovalForAllEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = staticExtractEventParametersWithLog(APPROVALFORALL_EVENT, transactionReceipt);
        ArrayList<ApprovalForAllEventResponse> responses = new ArrayList<ApprovalForAllEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            ApprovalForAllEventResponse typedResponse = new ApprovalForAllEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.operator = (String) eventValues.getIndexedValues().get(1).getValue();
            typedResponse.approved = (Boolean) eventValues.getNonIndexedValues().get(0).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public Flowable<ApprovalForAllEventResponse> approvalForAllEventFlowable(EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(new Function<Log, ApprovalForAllEventResponse>() {
            @Override
            public ApprovalForAllEventResponse apply(Log log) {
                Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(APPROVALFORALL_EVENT, log);
                ApprovalForAllEventResponse typedResponse = new ApprovalForAllEventResponse();
                typedResponse.log = log;
                typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue();
                typedResponse.operator = (String) eventValues.getIndexedValues().get(1).getValue();
                typedResponse.approved = (Boolean) eventValues.getNonIndexedValues().get(0).getValue();
                return typedResponse;
            }
        });
    }

    public Flowable<ApprovalForAllEventResponse> approvalForAllEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(APPROVALFORALL_EVENT));
        return approvalForAllEventFlowable(filter);
    }

    public static List<OwnershipTransferredEventResponse> getOwnershipTransferredEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = staticExtractEventParametersWithLog(OWNERSHIPTRANSFERRED_EVENT, transactionReceipt);
        ArrayList<OwnershipTransferredEventResponse> responses = new ArrayList<OwnershipTransferredEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            OwnershipTransferredEventResponse typedResponse = new OwnershipTransferredEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.previousOwner = (String) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.newOwner = (String) eventValues.getIndexedValues().get(1).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public Flowable<OwnershipTransferredEventResponse> ownershipTransferredEventFlowable(EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(new Function<Log, OwnershipTransferredEventResponse>() {
            @Override
            public OwnershipTransferredEventResponse apply(Log log) {
                Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(OWNERSHIPTRANSFERRED_EVENT, log);
                OwnershipTransferredEventResponse typedResponse = new OwnershipTransferredEventResponse();
                typedResponse.log = log;
                typedResponse.previousOwner = (String) eventValues.getIndexedValues().get(0).getValue();
                typedResponse.newOwner = (String) eventValues.getIndexedValues().get(1).getValue();
                return typedResponse;
            }
        });
    }

    public Flowable<OwnershipTransferredEventResponse> ownershipTransferredEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(OWNERSHIPTRANSFERRED_EVENT));
        return ownershipTransferredEventFlowable(filter);
    }

    public static List<TransferEventResponse> getTransferEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = staticExtractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt);
        ArrayList<TransferEventResponse> responses = new ArrayList<TransferEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            TransferEventResponse typedResponse = new TransferEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue();
            typedResponse.tokenId = (BigInteger) eventValues.getIndexedValues().get(2).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public Flowable<TransferEventResponse> transferEventFlowable(EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(new Function<Log, TransferEventResponse>() {
            @Override
            public TransferEventResponse apply(Log log) {
                Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(TRANSFER_EVENT, log);
                TransferEventResponse typedResponse = new TransferEventResponse();
                typedResponse.log = log;
                typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue();
                typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue();
                typedResponse.tokenId = (BigInteger) eventValues.getIndexedValues().get(2).getValue();
                return typedResponse;
            }
        });
    }

    public Flowable<TransferEventResponse> transferEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(TRANSFER_EVENT));
        return transferEventFlowable(filter);
    }

    public RemoteFunctionCall<TransactionReceipt> approve(String to, BigInteger tokenId) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_APPROVE, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(to), 
                new org.web3j.abi.datatypes.generated.Uint256(tokenId)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<BigInteger> balanceOf(String owner) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_BALANCEOF, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(owner)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeRemoteCallSingleValueReturn(function, BigInteger.class);
    }

    public RemoteFunctionCall<TransactionReceipt> burn(String owner, BigInteger tokenId) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_BURN, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(owner), 
                new org.web3j.abi.datatypes.generated.Uint256(tokenId)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<String> getApproved(BigInteger tokenId) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_GETAPPROVED, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(tokenId)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteFunctionCall<List> getTokensIdsForUser(String user) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_GETTOKENSIDSFORUSER, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(user)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Uint256>>() {}));
        return new RemoteFunctionCall<List>(function,
                new Callable<List>() {
                    @Override
                    @SuppressWarnings("unchecked")
                    public List call() throws Exception {
                        List<Type> result = (List<Type>) executeCallSingleValueReturn(function, List.class);
                        return convertToNative(result);
                    }
                });
    }

    public RemoteFunctionCall<Boolean> isApprovedForAll(String owner, String operator) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_ISAPPROVEDFORALL, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(owner), 
                new org.web3j.abi.datatypes.Address(operator)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {}));
        return executeRemoteCallSingleValueReturn(function, Boolean.class);
    }

    public RemoteFunctionCall<TransactionReceipt> lockToken(BigInteger tokenId, BigInteger timeOfLockEnds) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_LOCKTOKEN, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(tokenId), 
                new org.web3j.abi.datatypes.generated.Uint256(timeOfLockEnds)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<TransactionReceipt> makeTokenConsumed(BigInteger tokenId) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_MAKETOKENCONSUMED, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(tokenId)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<String> name() {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_NAME, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteFunctionCall<Value> offer(BigInteger tokenId) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_OFFER, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(tokenId)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Value>() {}));
        return executeRemoteCallSingleValueReturn(function, Value.class);
    }

    public RemoteFunctionCall<String> owner() {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_OWNER, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteFunctionCall<String> ownerOf(BigInteger tokenId) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_OWNEROF, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(tokenId)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteFunctionCall<TransactionReceipt> renounceOwnership() {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_RENOUNCEOWNERSHIP, 
                Arrays.<Type>asList(), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<TransactionReceipt> safeMint(String to, Value value, String uri) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_SAFEMINT, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(to), 
                value, 
                new org.web3j.abi.datatypes.Utf8String(uri)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<TransactionReceipt> safeTransferFrom(String from, String to, BigInteger tokenId) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_safeTransferFrom, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(from), 
                new org.web3j.abi.datatypes.Address(to), 
                new org.web3j.abi.datatypes.generated.Uint256(tokenId)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<TransactionReceipt> safeTransferFrom(String from, String to, BigInteger tokenId, byte[] data) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_safeTransferFrom, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(from), 
                new org.web3j.abi.datatypes.Address(to), 
                new org.web3j.abi.datatypes.generated.Uint256(tokenId), 
                new org.web3j.abi.datatypes.DynamicBytes(data)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<TransactionReceipt> setApprovalForAll(String operator, Boolean approved) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_SETAPPROVALFORALL, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(operator), 
                new org.web3j.abi.datatypes.Bool(approved)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<Boolean> supportsInterface(byte[] interfaceId) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_SUPPORTSINTERFACE, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes4(interfaceId)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {}));
        return executeRemoteCallSingleValueReturn(function, Boolean.class);
    }

    public RemoteFunctionCall<String> symbol() {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_SYMBOL, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteFunctionCall<String> tokenURI(BigInteger tokenId) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_TOKENURI, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(tokenId)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}));
        return executeRemoteCallSingleValueReturn(function, String.class);
    }

    public RemoteFunctionCall<TransactionReceipt> transferFrom(String from, String to, BigInteger tokenId) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_TRANSFERFROM, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(from), 
                new org.web3j.abi.datatypes.Address(to), 
                new org.web3j.abi.datatypes.generated.Uint256(tokenId)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<TransactionReceipt> transferOwnership(String newOwner) {
        final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(
                FUNC_TRANSFEROWNERSHIP, 
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(newOwner)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    @Deprecated
    public static SwapValue load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return new SwapValue(contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    @Deprecated
    public static SwapValue load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return new SwapValue(contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    public static SwapValue load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
        return new SwapValue(contractAddress, web3j, credentials, contractGasProvider);
    }

    public static SwapValue load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        return new SwapValue(contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public static RemoteCall<SwapValue> deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
        return deployRemoteCall(SwapValue.class, web3j, credentials, contractGasProvider, BINARY, "");
    }

    public static RemoteCall<SwapValue> deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        return deployRemoteCall(SwapValue.class, web3j, transactionManager, contractGasProvider, BINARY, "");
    }

    @Deprecated
    public static RemoteCall<SwapValue> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(SwapValue.class, web3j, credentials, gasPrice, gasLimit, BINARY, "");
    }

    @Deprecated
    public static RemoteCall<SwapValue> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(SwapValue.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "");
    }

    public static class Value extends DynamicStruct {
        public String _offer;

        public BigInteger _availableSince;

        public BigInteger _availabilityEnd;

        public Boolean _isConsumed;

        public BigInteger _lockedUntil;

        public Value(String _offer, BigInteger _availableSince, BigInteger _availabilityEnd, Boolean _isConsumed, BigInteger _lockedUntil) {
            super(new org.web3j.abi.datatypes.Utf8String(_offer), 
                    new org.web3j.abi.datatypes.generated.Uint256(_availableSince), 
                    new org.web3j.abi.datatypes.generated.Uint256(_availabilityEnd), 
                    new org.web3j.abi.datatypes.Bool(_isConsumed), 
                    new org.web3j.abi.datatypes.generated.Uint256(_lockedUntil));
            this._offer = _offer;
            this._availableSince = _availableSince;
            this._availabilityEnd = _availabilityEnd;
            this._isConsumed = _isConsumed;
            this._lockedUntil = _lockedUntil;
        }

        public Value(Utf8String _offer, Uint256 _availableSince, Uint256 _availabilityEnd, Bool _isConsumed, Uint256 _lockedUntil) {
            super(_offer, _availableSince, _availabilityEnd, _isConsumed, _lockedUntil);
            this._offer = _offer.getValue();
            this._availableSince = _availableSince.getValue();
            this._availabilityEnd = _availabilityEnd.getValue();
            this._isConsumed = _isConsumed.getValue();
            this._lockedUntil = _lockedUntil.getValue();
        }
    }

    public static class ApprovalEventResponse extends BaseEventResponse {
        public String owner;

        public String approved;

        public BigInteger tokenId;
    }

    public static class ApprovalForAllEventResponse extends BaseEventResponse {
        public String owner;

        public String operator;

        public Boolean approved;
    }

    public static class OwnershipTransferredEventResponse extends BaseEventResponse {
        public String previousOwner;

        public String newOwner;
    }

    public static class TransferEventResponse extends BaseEventResponse {
        public String from;

        public String to;

        public BigInteger tokenId;
    }
}

The way I did was:

With the @openzeppelin folder containing the contracts downloaded from: https://www.npmjs.com/package/@openzeppelin/contracts

And I had the above wrapper.

This can be done is more elegant ways, but that is not the purpose of this issue. Let me know if this is what's needed.

Gelassen commented 1 year ago

Thank you, I am able to mint a token by using wrapper above. However there are variety of issues with web3g-cli new project command.

Thank you for your help with this. I will continue work on generating or writing java wrapper to make sure I am able to introduce new changes in any time with this version of library. Leave this issue opened or closed is up to you.

rach-id commented 1 year ago

it is not an android project, mixing web3j plugin with the rest android plugins gives a compile error

even when generating a kotlin project?

I had an issue to build hello world project, the root cause issue would require more investigation

can you share some logs?

the origin post's root cause issue is not clear and would take more efforts to figure it out.

That one needs a bit more work to support generating projects for a set of contracts, and not only one.

Gelassen commented 1 year ago

I am able to create hello world project via command $web3j new HelloWorld in isolated environment in VM. The root cause was incompatibility issue between modern Java (jdk-16 has been installed) and gradle version used by web3j-cli (gradle-5.6).

it is not an android project, mixing web3j plugin with the rest android plugins gives a compile error

even when generating a kotlin project?

The issue appears when I add id 'org.web3j' version '4.8.4'. It is common piece of code for java and kotlin versions of web3j newly started projects. A whole list of plugin for this module is:

plugins {
    id("com.android.library")
    id("org.jetbrains.kotlin.android")
    id("org.web3j") version "4.8.4"
}

IMO, you have to add in web3j docs the disclaimer at this stage the library does not support contracts which imports others contracts under the hood.

rach-id commented 1 year ago

jdk-16 is not supported. That's why it's giving you the issue. Go for jdk-11 or 1.8. Other versions also might be supported, but I didn't check that for some time now.

For android project, I have the following build.gradle which was generated using web3j new --kotlin :

plugins {
    id 'java'
    id 'org.jetbrains.kotlin.jvm' version '1.3.61'
    id 'application'
    id "com.github.johnrengelman.shadow" version "5.2.0"
    id 'org.web3j' version '4.8.4'
}

group 'org.web3j'
version '0.1.0'

sourceCompatibility = 11

repositories {
    mavenCentral()
    jcenter()
}

web3j {
    generatedPackageName = 'org.web3j.generated.contracts'
    excludedContracts = ['Mortal']
}

ext {
    web3jVersion = '4.8.4'
    logbackVersion = '1.2.3'
}

dependencies {
    implementation "org.web3j:core:$web3jVersion",
            "ch.qos.logback:logback-core:$logbackVersion",
            "ch.qos.logback:logback-classic:$logbackVersion"
    implementation("org.web3j:web3j-unit:$web3jVersion")
    implementation("org.web3j:web3j-evm:$web3jVersion")
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
}

jar {
    manifest {
        attributes(
                'Main-Class': 'org.web3j.Web3App',
                'Multi-Release':'true'
        )
    }
}
application {
    mainClassName = 'org.web3j.Web3App'
}

test {
    useJUnitPlatform()
}

compileKotlin {
    kotlinOptions.jvmTarget = "11"
}

compileTestKotlin {
    kotlinOptions.jvmTarget = "11"
}

which should work for android.

IMO, you have to add in web3j docs the disclaimer at this stage the library does not support contracts which imports others contracts under the hood.

It does support them, using the web3j-gradle-plugin. It even downloads some classic libraries for you. Except that the support is still a bit not thaaat user-friendly. It needs more work on that. I used the web3j-gradle-plugin to generate the above wrapper. Also, for projects, you can import them straight up using web3j import --kotlin -s <path to solidity file/folder>. Except, that it needs a bit of gymnastics to work correctly. The functionality is there, tho.

rach-id commented 1 year ago

For the issue, if you're able to close it yourself, please do. I don't have those permissions at the moment. Thanks

Gelassen commented 1 year ago

I do not want to sound critical - thank you for all your efforts on writing this - my aim is to make it work on my side at minimum and at most - contribute to library readiness as a mature product.

This is a default gradle config file generate by Android Studio:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    // id 'org.web3j' version '4.8.4'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.example.web3jplugintest"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

Adding web3j plugin to this script leads to compile error. This dsl config file is some standard we have to follow.

Anyway, it is a secondary issue. Regarding the primary issue I just finished experiment with approach suggested above and still get unknown struct Value and unknown struct Match (the Match is used in another contract SwapChain.sol). It is the same issue the topic is started. (note: it is done VM's fresh installed Ubuntu server)

I will try to put my struct inside the contract to see if web3j would be able generate wrapper in this case.

Also please note EVmVersion file lacks the latest evm such as 'London' it would be good to extend it.

rach-id commented 1 year ago

Got you :+1:

Also please note EVmVersion file lacks the latest evm such as 'London' it would be good to extend it.

Please create an issue for this in https://github.com/web3j/solidity-gradle-plugin and hopefully someone picks it up.

I am no longer actively contributing to the library as I have other stuff on my plate now. However, if you see some ways of improvements to the general usability, it would be awesome if you could open relevant issues/PRs and I will be glad to approve them.

mohamedelshami commented 1 year ago

Closing this, as the issue is now being addressed in solidity-gradle-plugin