diff --git a/circom/PostMessage.wasm b/circom/PostMessage.wasm new file mode 100644 index 0000000..d7ae72b Binary files /dev/null and b/circom/PostMessage.wasm differ diff --git a/circom/PostMessage.zkey b/circom/PostMessage.zkey new file mode 100644 index 0000000..555fd5d Binary files /dev/null and b/circom/PostMessage.zkey differ diff --git a/circom/VerifiableCommitment.wasm b/circom/VerifiableCommitment.wasm new file mode 100644 index 0000000..136e25e Binary files /dev/null and b/circom/VerifiableCommitment.wasm differ diff --git a/circom/VerifiableCommitment.zkey b/circom/VerifiableCommitment.zkey new file mode 100644 index 0000000..eb04209 Binary files /dev/null and b/circom/VerifiableCommitment.zkey differ diff --git a/contracts/auth_storage.go b/contracts/auth_storage.go new file mode 100644 index 0000000..7467f55 --- /dev/null +++ b/contracts/auth_storage.go @@ -0,0 +1,1112 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contracts + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// VerifierHelperProofPoints is an auto generated low-level Go binding around an user-defined struct. +type VerifierHelperProofPoints struct { + A [2]*big.Int + B [2][2]*big.Int + C [2]*big.Int +} + +// AuthenticationStorageMetaData contains all meta data concerning the AuthenticationStorage contract. +var AuthenticationStorageMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"AddressEmptyCode\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"credentialId\",\"type\":\"bytes32\"}],\"name\":\"CredentialExpired\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxDeadline\",\"type\":\"uint256\"}],\"name\":\"DeadlineExceedsMax\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"ERC1967InvalidImplementation\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ERC1967NonPayable\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FailedInnerCall\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidZKProof\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotNFTOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UUPSUnauthorizedCallContext\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"slot\",\"type\":\"bytes32\"}],\"name\":\"UUPSUnsupportedProxiableUUID\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"nft\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"nftOwner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"credentialId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"Registered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAX_DEADLINE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"UPGRADE_INTERFACE_VERSION\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"credentialRegistry_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"verifier_\",\"type\":\"address\"}],\"name\":\"__AuthenticationStorage_init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"credentialRegistry\",\"outputs\":[{\"internalType\":\"contractPoseidonSMT\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proxiableUUID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractIERC721\",\"name\":\"nft_\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId_\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"nftOwner_\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"credentialId_\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"deadline_\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256[2]\",\"name\":\"a\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[2][2]\",\"name\":\"b\",\"type\":\"uint256[2][2]\"},{\"internalType\":\"uint256[2]\",\"name\":\"c\",\"type\":\"uint256[2]\"}],\"internalType\":\"structVerifierHelper.ProofPoints\",\"name\":\"zkPoints_\",\"type\":\"tuple\"}],\"name\":\"register\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"credentialRegistry_\",\"type\":\"address\"}],\"name\":\"setCredentialRegistry\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"verifier_\",\"type\":\"address\"}],\"name\":\"setVerifier\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"verifier\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + Bin: "0x60a06040523060805234801561001457600080fd5b5061001d610022565b6100d4565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100725760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100d15780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6080516116726100fd600039600081816106cb015281816106f4015261083a01526116726000f3fe6080604052600436106100c25760003560e01c80638da5cb5b1161007f578063b948c3d411610059578063b948c3d414610223578063bbb9d4b014610243578063c93a985c14610263578063f2fde38b1461028357600080fd5b80638da5cb5b14610188578063a7013707146101c5578063ad3cb1cc146101e557600080fd5b80632b7ac3f3146100c75780634f1ef2861461010457806352d1902d146101195780635437988d1461013c5780636f0e530f1461015c578063715018a614610173575b600080fd5b3480156100d357600080fd5b506001546100e7906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610117610112366004611156565b6102a3565b005b34801561012557600080fd5b5061012e6102c2565b6040519081526020016100fb565b34801561014857600080fd5b506101176101573660046111fe565b6102df565b34801561016857600080fd5b5061012e622a300081565b34801561017f57600080fd5b50610117610309565b34801561019457600080fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b03166100e7565b3480156101d157600080fd5b506101176101e03660046111fe565b61031d565b3480156101f157600080fd5b50610216604051806040016040528060058152602001640352e302e360dc1b81525081565b6040516100fb919061123f565b34801561022f57600080fd5b506000546100e7906001600160a01b031681565b34801561024f57600080fd5b5061011761025e366004611272565b610347565b34801561026f57600080fd5b5061011761027e3660046112ab565b610489565b34801561028f57600080fd5b5061011761029e3660046111fe565b610682565b6102ab6106c0565b6102b482610765565b6102be828261076d565b5050565b60006102cc61082f565b5060008051602061161d83398151915290565b6102e7610878565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b610311610878565b61031b60006108d3565b565b610325610878565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff1660008115801561038d5750825b905060008267ffffffffffffffff1660011480156103aa5750303b155b9050811580156103b8575080155b156103d65760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561040057845460ff60401b1916600160401b1785555b61040933610944565b600180546001600160a01b038089166001600160a01b03199283161790925560008054928a1692909116919091179055831561048057845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2906020015b60405180910390a15b50505050505050565b610496622a30004261131c565b8211156104c7576040516379b11a2f60e11b815260048101839052622a300060248201526044015b60405180910390fd5b6104d18686610955565b814211156104fb5760405163fb98715560e01b8152336004820152602481018490526044016104be565b610509868686868686610a56565b610526576040516303b2487b60e11b815260040160405180910390fd5b604080516060810182526001600160a01b0380891682526020820188905286168183015290516304b98e1d60e31b815260009173__$03320550cd1b629da90608251571b2532e$__916325cc70e8916105819160040161133d565b602060405180830381865af415801561059e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c2919061136e565b6000546040516368ef2c9560e11b815260048101879052602481018390529192506001600160a01b03169063d1de592a90604401600060405180830381600087803b15801561061057600080fd5b505af1158015610624573d6000803e3d6000fd5b5050604080516001600160a01b03808c168252602082018b905289169181019190915260608101879052608081018690527fdc72f447eb6c32bde8c6dcd2d09f5b297b4d780aaf6ab9fb99d3d083b4b0058c925060a0019050610477565b61068a610878565b6001600160a01b0381166106b457604051631e4fbdf760e01b8152600060048201526024016104be565b6106bd816108d3565b50565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148061074757507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661073b60008051602061161d833981519152546001600160a01b031690565b6001600160a01b031614155b1561031b5760405163703e46dd60e11b815260040160405180910390fd5b6106bd610878565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156107c7575060408051601f3d908101601f191682019092526107c49181019061136e565b60015b6107ef57604051634c9c8ce360e01b81526001600160a01b03831660048201526024016104be565b60008051602061161d833981519152811461082057604051632a87526960e21b8152600481018290526024016104be565b61082a8383610b62565b505050565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461031b5760405163703e46dd60e11b815260040160405180910390fd5b336108aa7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b03161461031b5760405163118cdaa760e01b81523360048201526024016104be565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b61094c610bb8565b6106bd81610c01565b600080836001600160a01b0316636352211e60e01b8460405160240161097d91815260200190565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516109bb9190611387565b600060405180830381855afa9150503d80600081146109f6576040519150601f19603f3d011682016040523d82523d6000602084013e6109fb565b606091505b5091509150811580610a325750336001600160a01b031681806020019051810190610a2691906113a3565b6001600160a01b031614155b15610a5057604051631022318760e21b815260040160405180910390fd5b50505050565b60408051600580825260c082019092526000918291906020820160a0803683370190505090508460001c81600081518110610a9357610a936113c0565b602002602001018181525050876001600160a01b031681600181518110610abc57610abc6113c0565b6020026020010181815250508681600281518110610adc57610adc6113c0565b602002602001018181525050856001600160a01b031681600381518110610b0557610b056113c0565b6020026020010181815250508381600481518110610b2557610b256113c0565b6020908102919091010152610b5681610b4336869003860186611426565b6001546001600160a01b03169190610c09565b98975050505050505050565b610b6b82610c30565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115610bb05761082a8282610c95565b6102be610d0d565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661031b57604051631afcd79f60e31b815260040160405180910390fd5b61068a610bb8565b6000610c2684836000015184602001518560400151878851610d2c565b90505b9392505050565b806001600160a01b03163b600003610c6657604051634c9c8ce360e01b81526001600160a01b03821660048201526024016104be565b60008051602061161d83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b031684604051610cb29190611387565b600060405180830381855af49150503d8060008114610ced576040519150601f19603f3d011682016040523d82523d6000602084013e610cf2565b606091505b5091509150610d02858383610ebe565b925050505b92915050565b341561031b5760405163b398979f60e01b815260040160405180910390fd5b600080610d3883610f1a565b604051602001610d4891906114c0565b6040516020818303038152906040529050600080896001600160a01b0316838a8a8a604051602401610d7c9392919061155a565b60408051601f198184030181529082905291610d9791611387565b60405180910390206001600160e01b0319166020820180516001600160e01b03838183161783525050505087604051602001610dd49291906115b2565b60408051601f1981840301815290829052610dee91611387565b600060405180830381855afa9150503d8060008114610e29576040519150601f19603f3d011682016040523d82523d6000602084013e610e2e565b606091505b509150915081610e9c5760405162461bcd60e51b815260206004820152603360248201527f566572696669657248656c7065723a206661696c656420746f2063616c6c207660448201527232b934b33ca83937b7b310333ab731ba34b7b760691b60648201526084016104be565b80806020019051810190610eb091906115fa565b9a9950505050505050505050565b606082610ed357610ece82610fad565b610c29565b8151158015610eea57506001600160a01b0384163b155b15610f1357604051639996b31560e01b81526001600160a01b03851660048201526024016104be565b5080610c29565b60606000610f2783610fd6565b600101905060008167ffffffffffffffff811115610f4757610f476110c3565b6040519080825280601f01601f191660200182016040528015610f71576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084610f7b57509392505050565b805115610fbd5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106110155772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310611041576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061105f57662386f26fc10000830492506010015b6305f5e1008310611077576305f5e100830492506008015b612710831061108b57612710830492506004015b6064831061109d576064830492506002015b600a8310610d075760010192915050565b6001600160a01b03811681146106bd57600080fd5b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff811182821017156110fc576110fc6110c3565b60405290565b6040805190810167ffffffffffffffff811182821017156110fc576110fc6110c3565b604051601f8201601f1916810167ffffffffffffffff8111828210171561114e5761114e6110c3565b604052919050565b6000806040838503121561116957600080fd5b8235611174816110ae565b915060208381013567ffffffffffffffff8082111561119257600080fd5b818601915086601f8301126111a657600080fd5b8135818111156111b8576111b86110c3565b6111ca601f8201601f19168501611125565b915080825287848285010111156111e057600080fd5b80848401858401376000848284010152508093505050509250929050565b60006020828403121561121057600080fd5b8135610c29816110ae565b60005b8381101561123657818101518382015260200161121e565b50506000910152565b602081526000825180602084015261125e81604085016020870161121b565b601f01601f19169190910160400192915050565b6000806040838503121561128557600080fd5b8235611290816110ae565b915060208301356112a0816110ae565b809150509250929050565b6000806000806000808688036101a08112156112c657600080fd5b87356112d1816110ae565b96506020880135955060408801356112e8816110ae565b94506060880135935060808801359250610100609f198201121561130b57600080fd5b5060a0870190509295509295509295565b80820180821115610d0757634e487b7160e01b600052601160045260246000fd5b60608101818360005b6003811015611365578151835260209283019290910190600101611346565b50505092915050565b60006020828403121561138057600080fd5b5051919050565b6000825161139981846020870161121b565b9190910192915050565b6000602082840312156113b557600080fd5b8151610c29816110ae565b634e487b7160e01b600052603260045260246000fd5b600082601f8301126113e757600080fd5b6113ef611102565b80604084018581111561140157600080fd5b845b8181101561141b578035845260209384019301611403565b509095945050505050565b6000610100828403121561143957600080fd5b6114416110d9565b61144b84846113d6565b8152604084605f85011261145e57600080fd5b611466611102565b8060c086018781111561147857600080fd5b8387015b8181101561149d5761148e89826113d6565b8452602090930192840161147c565b508160208601526114ae88826113d6565b84860152505050508091505092915050565b7f76657269667950726f6f662875696e743235365b325d2c75696e743235365b3281527f5d5b325d2c75696e743235365b325d2c75696e743235365b000000000000000060208201526000825161151e81603885016020870161121b565b615d2960f01b6038939091019283015250603a01919050565b8060005b6002811015610a5057815184526020938401939091019060010161153b565b61010081016115698286611537565b60408083018560005b600281101561159957611586838351611537565b9183019160209190910190600101611572565b505050506115aa60c0830184611537565b949350505050565b6000835160206115c5828583890161121b565b84519184019181860160005b828110156115ed578151855293830193908301906001016115d1565b5092979650505050505050565b60006020828403121561160c57600080fd5b81518015158114610c2957600080fdfe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca26469706673582212200d8ee8d9c2a3d875a90ae9da34cd9dc506f7bbde82ba643b8d5a53ceda5fcdf964736f6c63430008140033", +} + +// AuthenticationStorageABI is the input ABI used to generate the binding from. +// Deprecated: Use AuthenticationStorageMetaData.ABI instead. +var AuthenticationStorageABI = AuthenticationStorageMetaData.ABI + +// AuthenticationStorageBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use AuthenticationStorageMetaData.Bin instead. +var AuthenticationStorageBin = AuthenticationStorageMetaData.Bin + +// DeployAuthenticationStorage deploys a new Ethereum contract, binding an instance of AuthenticationStorage to it. +func DeployAuthenticationStorage(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *AuthenticationStorage, error) { + parsed, err := AuthenticationStorageMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(AuthenticationStorageBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &AuthenticationStorage{AuthenticationStorageCaller: AuthenticationStorageCaller{contract: contract}, AuthenticationStorageTransactor: AuthenticationStorageTransactor{contract: contract}, AuthenticationStorageFilterer: AuthenticationStorageFilterer{contract: contract}}, nil +} + +// AuthenticationStorage is an auto generated Go binding around an Ethereum contract. +type AuthenticationStorage struct { + AuthenticationStorageCaller // Read-only binding to the contract + AuthenticationStorageTransactor // Write-only binding to the contract + AuthenticationStorageFilterer // Log filterer for contract events +} + +// AuthenticationStorageCaller is an auto generated read-only Go binding around an Ethereum contract. +type AuthenticationStorageCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AuthenticationStorageTransactor is an auto generated write-only Go binding around an Ethereum contract. +type AuthenticationStorageTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AuthenticationStorageFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type AuthenticationStorageFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AuthenticationStorageSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type AuthenticationStorageSession struct { + Contract *AuthenticationStorage // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// AuthenticationStorageCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type AuthenticationStorageCallerSession struct { + Contract *AuthenticationStorageCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// AuthenticationStorageTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type AuthenticationStorageTransactorSession struct { + Contract *AuthenticationStorageTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// AuthenticationStorageRaw is an auto generated low-level Go binding around an Ethereum contract. +type AuthenticationStorageRaw struct { + Contract *AuthenticationStorage // Generic contract binding to access the raw methods on +} + +// AuthenticationStorageCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type AuthenticationStorageCallerRaw struct { + Contract *AuthenticationStorageCaller // Generic read-only contract binding to access the raw methods on +} + +// AuthenticationStorageTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type AuthenticationStorageTransactorRaw struct { + Contract *AuthenticationStorageTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewAuthenticationStorage creates a new instance of AuthenticationStorage, bound to a specific deployed contract. +func NewAuthenticationStorage(address common.Address, backend bind.ContractBackend) (*AuthenticationStorage, error) { + contract, err := bindAuthenticationStorage(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &AuthenticationStorage{AuthenticationStorageCaller: AuthenticationStorageCaller{contract: contract}, AuthenticationStorageTransactor: AuthenticationStorageTransactor{contract: contract}, AuthenticationStorageFilterer: AuthenticationStorageFilterer{contract: contract}}, nil +} + +// NewAuthenticationStorageCaller creates a new read-only instance of AuthenticationStorage, bound to a specific deployed contract. +func NewAuthenticationStorageCaller(address common.Address, caller bind.ContractCaller) (*AuthenticationStorageCaller, error) { + contract, err := bindAuthenticationStorage(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &AuthenticationStorageCaller{contract: contract}, nil +} + +// NewAuthenticationStorageTransactor creates a new write-only instance of AuthenticationStorage, bound to a specific deployed contract. +func NewAuthenticationStorageTransactor(address common.Address, transactor bind.ContractTransactor) (*AuthenticationStorageTransactor, error) { + contract, err := bindAuthenticationStorage(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &AuthenticationStorageTransactor{contract: contract}, nil +} + +// NewAuthenticationStorageFilterer creates a new log filterer instance of AuthenticationStorage, bound to a specific deployed contract. +func NewAuthenticationStorageFilterer(address common.Address, filterer bind.ContractFilterer) (*AuthenticationStorageFilterer, error) { + contract, err := bindAuthenticationStorage(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &AuthenticationStorageFilterer{contract: contract}, nil +} + +// bindAuthenticationStorage binds a generic wrapper to an already deployed contract. +func bindAuthenticationStorage(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := AuthenticationStorageMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_AuthenticationStorage *AuthenticationStorageRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _AuthenticationStorage.Contract.AuthenticationStorageCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_AuthenticationStorage *AuthenticationStorageRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.AuthenticationStorageTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_AuthenticationStorage *AuthenticationStorageRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.AuthenticationStorageTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_AuthenticationStorage *AuthenticationStorageCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _AuthenticationStorage.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_AuthenticationStorage *AuthenticationStorageTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_AuthenticationStorage *AuthenticationStorageTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.contract.Transact(opts, method, params...) +} + +// MAXDEADLINE is a free data retrieval call binding the contract method 0x6f0e530f. +// +// Solidity: function MAX_DEADLINE() view returns(uint256) +func (_AuthenticationStorage *AuthenticationStorageCaller) MAXDEADLINE(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _AuthenticationStorage.contract.Call(opts, &out, "MAX_DEADLINE") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MAXDEADLINE is a free data retrieval call binding the contract method 0x6f0e530f. +// +// Solidity: function MAX_DEADLINE() view returns(uint256) +func (_AuthenticationStorage *AuthenticationStorageSession) MAXDEADLINE() (*big.Int, error) { + return _AuthenticationStorage.Contract.MAXDEADLINE(&_AuthenticationStorage.CallOpts) +} + +// MAXDEADLINE is a free data retrieval call binding the contract method 0x6f0e530f. +// +// Solidity: function MAX_DEADLINE() view returns(uint256) +func (_AuthenticationStorage *AuthenticationStorageCallerSession) MAXDEADLINE() (*big.Int, error) { + return _AuthenticationStorage.Contract.MAXDEADLINE(&_AuthenticationStorage.CallOpts) +} + +// UPGRADEINTERFACEVERSION is a free data retrieval call binding the contract method 0xad3cb1cc. +// +// Solidity: function UPGRADE_INTERFACE_VERSION() view returns(string) +func (_AuthenticationStorage *AuthenticationStorageCaller) UPGRADEINTERFACEVERSION(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _AuthenticationStorage.contract.Call(opts, &out, "UPGRADE_INTERFACE_VERSION") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// UPGRADEINTERFACEVERSION is a free data retrieval call binding the contract method 0xad3cb1cc. +// +// Solidity: function UPGRADE_INTERFACE_VERSION() view returns(string) +func (_AuthenticationStorage *AuthenticationStorageSession) UPGRADEINTERFACEVERSION() (string, error) { + return _AuthenticationStorage.Contract.UPGRADEINTERFACEVERSION(&_AuthenticationStorage.CallOpts) +} + +// UPGRADEINTERFACEVERSION is a free data retrieval call binding the contract method 0xad3cb1cc. +// +// Solidity: function UPGRADE_INTERFACE_VERSION() view returns(string) +func (_AuthenticationStorage *AuthenticationStorageCallerSession) UPGRADEINTERFACEVERSION() (string, error) { + return _AuthenticationStorage.Contract.UPGRADEINTERFACEVERSION(&_AuthenticationStorage.CallOpts) +} + +// CredentialRegistry is a free data retrieval call binding the contract method 0xb948c3d4. +// +// Solidity: function credentialRegistry() view returns(address) +func (_AuthenticationStorage *AuthenticationStorageCaller) CredentialRegistry(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _AuthenticationStorage.contract.Call(opts, &out, "credentialRegistry") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// CredentialRegistry is a free data retrieval call binding the contract method 0xb948c3d4. +// +// Solidity: function credentialRegistry() view returns(address) +func (_AuthenticationStorage *AuthenticationStorageSession) CredentialRegistry() (common.Address, error) { + return _AuthenticationStorage.Contract.CredentialRegistry(&_AuthenticationStorage.CallOpts) +} + +// CredentialRegistry is a free data retrieval call binding the contract method 0xb948c3d4. +// +// Solidity: function credentialRegistry() view returns(address) +func (_AuthenticationStorage *AuthenticationStorageCallerSession) CredentialRegistry() (common.Address, error) { + return _AuthenticationStorage.Contract.CredentialRegistry(&_AuthenticationStorage.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_AuthenticationStorage *AuthenticationStorageCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _AuthenticationStorage.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_AuthenticationStorage *AuthenticationStorageSession) Owner() (common.Address, error) { + return _AuthenticationStorage.Contract.Owner(&_AuthenticationStorage.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_AuthenticationStorage *AuthenticationStorageCallerSession) Owner() (common.Address, error) { + return _AuthenticationStorage.Contract.Owner(&_AuthenticationStorage.CallOpts) +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_AuthenticationStorage *AuthenticationStorageCaller) ProxiableUUID(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _AuthenticationStorage.contract.Call(opts, &out, "proxiableUUID") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_AuthenticationStorage *AuthenticationStorageSession) ProxiableUUID() ([32]byte, error) { + return _AuthenticationStorage.Contract.ProxiableUUID(&_AuthenticationStorage.CallOpts) +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_AuthenticationStorage *AuthenticationStorageCallerSession) ProxiableUUID() ([32]byte, error) { + return _AuthenticationStorage.Contract.ProxiableUUID(&_AuthenticationStorage.CallOpts) +} + +// Verifier is a free data retrieval call binding the contract method 0x2b7ac3f3. +// +// Solidity: function verifier() view returns(address) +func (_AuthenticationStorage *AuthenticationStorageCaller) Verifier(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _AuthenticationStorage.contract.Call(opts, &out, "verifier") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Verifier is a free data retrieval call binding the contract method 0x2b7ac3f3. +// +// Solidity: function verifier() view returns(address) +func (_AuthenticationStorage *AuthenticationStorageSession) Verifier() (common.Address, error) { + return _AuthenticationStorage.Contract.Verifier(&_AuthenticationStorage.CallOpts) +} + +// Verifier is a free data retrieval call binding the contract method 0x2b7ac3f3. +// +// Solidity: function verifier() view returns(address) +func (_AuthenticationStorage *AuthenticationStorageCallerSession) Verifier() (common.Address, error) { + return _AuthenticationStorage.Contract.Verifier(&_AuthenticationStorage.CallOpts) +} + +// AuthenticationStorageInit is a paid mutator transaction binding the contract method 0xbbb9d4b0. +// +// Solidity: function __AuthenticationStorage_init(address credentialRegistry_, address verifier_) returns() +func (_AuthenticationStorage *AuthenticationStorageTransactor) AuthenticationStorageInit(opts *bind.TransactOpts, credentialRegistry_ common.Address, verifier_ common.Address) (*types.Transaction, error) { + return _AuthenticationStorage.contract.Transact(opts, "__AuthenticationStorage_init", credentialRegistry_, verifier_) +} + +// AuthenticationStorageInit is a paid mutator transaction binding the contract method 0xbbb9d4b0. +// +// Solidity: function __AuthenticationStorage_init(address credentialRegistry_, address verifier_) returns() +func (_AuthenticationStorage *AuthenticationStorageSession) AuthenticationStorageInit(credentialRegistry_ common.Address, verifier_ common.Address) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.AuthenticationStorageInit(&_AuthenticationStorage.TransactOpts, credentialRegistry_, verifier_) +} + +// AuthenticationStorageInit is a paid mutator transaction binding the contract method 0xbbb9d4b0. +// +// Solidity: function __AuthenticationStorage_init(address credentialRegistry_, address verifier_) returns() +func (_AuthenticationStorage *AuthenticationStorageTransactorSession) AuthenticationStorageInit(credentialRegistry_ common.Address, verifier_ common.Address) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.AuthenticationStorageInit(&_AuthenticationStorage.TransactOpts, credentialRegistry_, verifier_) +} + +// Register is a paid mutator transaction binding the contract method 0xc93a985c. +// +// Solidity: function register(address nft_, uint256 tokenId_, address nftOwner_, bytes32 credentialId_, uint256 deadline_, (uint256[2],uint256[2][2],uint256[2]) zkPoints_) returns() +func (_AuthenticationStorage *AuthenticationStorageTransactor) Register(opts *bind.TransactOpts, nft_ common.Address, tokenId_ *big.Int, nftOwner_ common.Address, credentialId_ [32]byte, deadline_ *big.Int, zkPoints_ VerifierHelperProofPoints) (*types.Transaction, error) { + return _AuthenticationStorage.contract.Transact(opts, "register", nft_, tokenId_, nftOwner_, credentialId_, deadline_, zkPoints_) +} + +// Register is a paid mutator transaction binding the contract method 0xc93a985c. +// +// Solidity: function register(address nft_, uint256 tokenId_, address nftOwner_, bytes32 credentialId_, uint256 deadline_, (uint256[2],uint256[2][2],uint256[2]) zkPoints_) returns() +func (_AuthenticationStorage *AuthenticationStorageSession) Register(nft_ common.Address, tokenId_ *big.Int, nftOwner_ common.Address, credentialId_ [32]byte, deadline_ *big.Int, zkPoints_ VerifierHelperProofPoints) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.Register(&_AuthenticationStorage.TransactOpts, nft_, tokenId_, nftOwner_, credentialId_, deadline_, zkPoints_) +} + +// Register is a paid mutator transaction binding the contract method 0xc93a985c. +// +// Solidity: function register(address nft_, uint256 tokenId_, address nftOwner_, bytes32 credentialId_, uint256 deadline_, (uint256[2],uint256[2][2],uint256[2]) zkPoints_) returns() +func (_AuthenticationStorage *AuthenticationStorageTransactorSession) Register(nft_ common.Address, tokenId_ *big.Int, nftOwner_ common.Address, credentialId_ [32]byte, deadline_ *big.Int, zkPoints_ VerifierHelperProofPoints) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.Register(&_AuthenticationStorage.TransactOpts, nft_, tokenId_, nftOwner_, credentialId_, deadline_, zkPoints_) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_AuthenticationStorage *AuthenticationStorageTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _AuthenticationStorage.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_AuthenticationStorage *AuthenticationStorageSession) RenounceOwnership() (*types.Transaction, error) { + return _AuthenticationStorage.Contract.RenounceOwnership(&_AuthenticationStorage.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_AuthenticationStorage *AuthenticationStorageTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _AuthenticationStorage.Contract.RenounceOwnership(&_AuthenticationStorage.TransactOpts) +} + +// SetCredentialRegistry is a paid mutator transaction binding the contract method 0xa7013707. +// +// Solidity: function setCredentialRegistry(address credentialRegistry_) returns() +func (_AuthenticationStorage *AuthenticationStorageTransactor) SetCredentialRegistry(opts *bind.TransactOpts, credentialRegistry_ common.Address) (*types.Transaction, error) { + return _AuthenticationStorage.contract.Transact(opts, "setCredentialRegistry", credentialRegistry_) +} + +// SetCredentialRegistry is a paid mutator transaction binding the contract method 0xa7013707. +// +// Solidity: function setCredentialRegistry(address credentialRegistry_) returns() +func (_AuthenticationStorage *AuthenticationStorageSession) SetCredentialRegistry(credentialRegistry_ common.Address) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.SetCredentialRegistry(&_AuthenticationStorage.TransactOpts, credentialRegistry_) +} + +// SetCredentialRegistry is a paid mutator transaction binding the contract method 0xa7013707. +// +// Solidity: function setCredentialRegistry(address credentialRegistry_) returns() +func (_AuthenticationStorage *AuthenticationStorageTransactorSession) SetCredentialRegistry(credentialRegistry_ common.Address) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.SetCredentialRegistry(&_AuthenticationStorage.TransactOpts, credentialRegistry_) +} + +// SetVerifier is a paid mutator transaction binding the contract method 0x5437988d. +// +// Solidity: function setVerifier(address verifier_) returns() +func (_AuthenticationStorage *AuthenticationStorageTransactor) SetVerifier(opts *bind.TransactOpts, verifier_ common.Address) (*types.Transaction, error) { + return _AuthenticationStorage.contract.Transact(opts, "setVerifier", verifier_) +} + +// SetVerifier is a paid mutator transaction binding the contract method 0x5437988d. +// +// Solidity: function setVerifier(address verifier_) returns() +func (_AuthenticationStorage *AuthenticationStorageSession) SetVerifier(verifier_ common.Address) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.SetVerifier(&_AuthenticationStorage.TransactOpts, verifier_) +} + +// SetVerifier is a paid mutator transaction binding the contract method 0x5437988d. +// +// Solidity: function setVerifier(address verifier_) returns() +func (_AuthenticationStorage *AuthenticationStorageTransactorSession) SetVerifier(verifier_ common.Address) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.SetVerifier(&_AuthenticationStorage.TransactOpts, verifier_) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_AuthenticationStorage *AuthenticationStorageTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _AuthenticationStorage.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_AuthenticationStorage *AuthenticationStorageSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.TransferOwnership(&_AuthenticationStorage.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_AuthenticationStorage *AuthenticationStorageTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.TransferOwnership(&_AuthenticationStorage.TransactOpts, newOwner) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_AuthenticationStorage *AuthenticationStorageTransactor) UpgradeToAndCall(opts *bind.TransactOpts, newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _AuthenticationStorage.contract.Transact(opts, "upgradeToAndCall", newImplementation, data) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_AuthenticationStorage *AuthenticationStorageSession) UpgradeToAndCall(newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.UpgradeToAndCall(&_AuthenticationStorage.TransactOpts, newImplementation, data) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_AuthenticationStorage *AuthenticationStorageTransactorSession) UpgradeToAndCall(newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _AuthenticationStorage.Contract.UpgradeToAndCall(&_AuthenticationStorage.TransactOpts, newImplementation, data) +} + +// AuthenticationStorageInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the AuthenticationStorage contract. +type AuthenticationStorageInitializedIterator struct { + Event *AuthenticationStorageInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AuthenticationStorageInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AuthenticationStorageInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AuthenticationStorageInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AuthenticationStorageInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AuthenticationStorageInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AuthenticationStorageInitialized represents a Initialized event raised by the AuthenticationStorage contract. +type AuthenticationStorageInitialized struct { + Version uint64 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2. +// +// Solidity: event Initialized(uint64 version) +func (_AuthenticationStorage *AuthenticationStorageFilterer) FilterInitialized(opts *bind.FilterOpts) (*AuthenticationStorageInitializedIterator, error) { + + logs, sub, err := _AuthenticationStorage.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &AuthenticationStorageInitializedIterator{contract: _AuthenticationStorage.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2. +// +// Solidity: event Initialized(uint64 version) +func (_AuthenticationStorage *AuthenticationStorageFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *AuthenticationStorageInitialized) (event.Subscription, error) { + + logs, sub, err := _AuthenticationStorage.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AuthenticationStorageInitialized) + if err := _AuthenticationStorage.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2. +// +// Solidity: event Initialized(uint64 version) +func (_AuthenticationStorage *AuthenticationStorageFilterer) ParseInitialized(log types.Log) (*AuthenticationStorageInitialized, error) { + event := new(AuthenticationStorageInitialized) + if err := _AuthenticationStorage.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// AuthenticationStorageOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the AuthenticationStorage contract. +type AuthenticationStorageOwnershipTransferredIterator struct { + Event *AuthenticationStorageOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AuthenticationStorageOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AuthenticationStorageOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AuthenticationStorageOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AuthenticationStorageOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AuthenticationStorageOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AuthenticationStorageOwnershipTransferred represents a OwnershipTransferred event raised by the AuthenticationStorage contract. +type AuthenticationStorageOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_AuthenticationStorage *AuthenticationStorageFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*AuthenticationStorageOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _AuthenticationStorage.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &AuthenticationStorageOwnershipTransferredIterator{contract: _AuthenticationStorage.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_AuthenticationStorage *AuthenticationStorageFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *AuthenticationStorageOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _AuthenticationStorage.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AuthenticationStorageOwnershipTransferred) + if err := _AuthenticationStorage.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_AuthenticationStorage *AuthenticationStorageFilterer) ParseOwnershipTransferred(log types.Log) (*AuthenticationStorageOwnershipTransferred, error) { + event := new(AuthenticationStorageOwnershipTransferred) + if err := _AuthenticationStorage.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// AuthenticationStorageRegisteredIterator is returned from FilterRegistered and is used to iterate over the raw logs and unpacked data for Registered events raised by the AuthenticationStorage contract. +type AuthenticationStorageRegisteredIterator struct { + Event *AuthenticationStorageRegistered // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AuthenticationStorageRegisteredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AuthenticationStorageRegistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AuthenticationStorageRegistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AuthenticationStorageRegisteredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AuthenticationStorageRegisteredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AuthenticationStorageRegistered represents a Registered event raised by the AuthenticationStorage contract. +type AuthenticationStorageRegistered struct { + Nft common.Address + TokenId *big.Int + NftOwner common.Address + CredentialId [32]byte + Deadline *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRegistered is a free log retrieval operation binding the contract event 0xdc72f447eb6c32bde8c6dcd2d09f5b297b4d780aaf6ab9fb99d3d083b4b0058c. +// +// Solidity: event Registered(address nft, uint256 tokenId, address nftOwner, bytes32 credentialId, uint256 deadline) +func (_AuthenticationStorage *AuthenticationStorageFilterer) FilterRegistered(opts *bind.FilterOpts) (*AuthenticationStorageRegisteredIterator, error) { + + logs, sub, err := _AuthenticationStorage.contract.FilterLogs(opts, "Registered") + if err != nil { + return nil, err + } + return &AuthenticationStorageRegisteredIterator{contract: _AuthenticationStorage.contract, event: "Registered", logs: logs, sub: sub}, nil +} + +// WatchRegistered is a free log subscription operation binding the contract event 0xdc72f447eb6c32bde8c6dcd2d09f5b297b4d780aaf6ab9fb99d3d083b4b0058c. +// +// Solidity: event Registered(address nft, uint256 tokenId, address nftOwner, bytes32 credentialId, uint256 deadline) +func (_AuthenticationStorage *AuthenticationStorageFilterer) WatchRegistered(opts *bind.WatchOpts, sink chan<- *AuthenticationStorageRegistered) (event.Subscription, error) { + + logs, sub, err := _AuthenticationStorage.contract.WatchLogs(opts, "Registered") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AuthenticationStorageRegistered) + if err := _AuthenticationStorage.contract.UnpackLog(event, "Registered", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRegistered is a log parse operation binding the contract event 0xdc72f447eb6c32bde8c6dcd2d09f5b297b4d780aaf6ab9fb99d3d083b4b0058c. +// +// Solidity: event Registered(address nft, uint256 tokenId, address nftOwner, bytes32 credentialId, uint256 deadline) +func (_AuthenticationStorage *AuthenticationStorageFilterer) ParseRegistered(log types.Log) (*AuthenticationStorageRegistered, error) { + event := new(AuthenticationStorageRegistered) + if err := _AuthenticationStorage.contract.UnpackLog(event, "Registered", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// AuthenticationStorageUpgradedIterator is returned from FilterUpgraded and is used to iterate over the raw logs and unpacked data for Upgraded events raised by the AuthenticationStorage contract. +type AuthenticationStorageUpgradedIterator struct { + Event *AuthenticationStorageUpgraded // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AuthenticationStorageUpgradedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AuthenticationStorageUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AuthenticationStorageUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AuthenticationStorageUpgradedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AuthenticationStorageUpgradedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AuthenticationStorageUpgraded represents a Upgraded event raised by the AuthenticationStorage contract. +type AuthenticationStorageUpgraded struct { + Implementation common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterUpgraded is a free log retrieval operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_AuthenticationStorage *AuthenticationStorageFilterer) FilterUpgraded(opts *bind.FilterOpts, implementation []common.Address) (*AuthenticationStorageUpgradedIterator, error) { + + var implementationRule []interface{} + for _, implementationItem := range implementation { + implementationRule = append(implementationRule, implementationItem) + } + + logs, sub, err := _AuthenticationStorage.contract.FilterLogs(opts, "Upgraded", implementationRule) + if err != nil { + return nil, err + } + return &AuthenticationStorageUpgradedIterator{contract: _AuthenticationStorage.contract, event: "Upgraded", logs: logs, sub: sub}, nil +} + +// WatchUpgraded is a free log subscription operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_AuthenticationStorage *AuthenticationStorageFilterer) WatchUpgraded(opts *bind.WatchOpts, sink chan<- *AuthenticationStorageUpgraded, implementation []common.Address) (event.Subscription, error) { + + var implementationRule []interface{} + for _, implementationItem := range implementation { + implementationRule = append(implementationRule, implementationItem) + } + + logs, sub, err := _AuthenticationStorage.contract.WatchLogs(opts, "Upgraded", implementationRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AuthenticationStorageUpgraded) + if err := _AuthenticationStorage.contract.UnpackLog(event, "Upgraded", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseUpgraded is a log parse operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_AuthenticationStorage *AuthenticationStorageFilterer) ParseUpgraded(log types.Log) (*AuthenticationStorageUpgraded, error) { + event := new(AuthenticationStorageUpgraded) + if err := _AuthenticationStorage.contract.UnpackLog(event, "Upgraded", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/contracts/chat.go b/contracts/chat.go new file mode 100644 index 0000000..9a3095f --- /dev/null +++ b/contracts/chat.go @@ -0,0 +1,1139 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contracts + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// ChatMessage is an auto generated low-level Go binding around an user-defined struct. +type ChatMessage struct { + Message string + Timestamp *big.Int +} + +// ChatMetaData contains all meta data concerning the Chat contract. +var ChatMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"AddressEmptyCode\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CredentialRootInvalid\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"deadline_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"currectTime_\",\"type\":\"uint256\"}],\"name\":\"DeadlineNotMet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"ERC1967InvalidImplementation\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ERC1967NonPayable\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FailedInnerCall\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidZKProof\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UUPSUnauthorizedCallContext\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"slot\",\"type\":\"bytes32\"}],\"name\":\"UUPSUnsupportedProxiableUUID\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"contractIERC721\",\"name\":\"nft\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"}],\"name\":\"MessagePosted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEADLINE_VALIDITY_WINDOW\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"UPGRADE_INTERFACE_VERSION\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"authenticationStorage_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"postMessageVerifier_\",\"type\":\"address\"}],\"name\":\"__Chat_init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"credentialStorage\",\"outputs\":[{\"internalType\":\"contractPoseidonSMT\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nft_\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"offset_\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"limit_\",\"type\":\"uint256\"}],\"name\":\"listMessages\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"message\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"internalType\":\"structChat.Message[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractIERC721\",\"name\":\"nft_\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"message_\",\"type\":\"string\"},{\"internalType\":\"bytes32\",\"name\":\"root_\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"expectedMessageTime_\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256[2]\",\"name\":\"a\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[2][2]\",\"name\":\"b\",\"type\":\"uint256[2][2]\"},{\"internalType\":\"uint256[2]\",\"name\":\"c\",\"type\":\"uint256[2]\"}],\"internalType\":\"structVerifierHelper.ProofPoints\",\"name\":\"zkPoints_\",\"type\":\"tuple\"}],\"name\":\"postMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"postMessageVerifier\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proxiableUUID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"credentialStorage_\",\"type\":\"address\"}],\"name\":\"setCredentialStorage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"postMessageVerifier_\",\"type\":\"address\"}],\"name\":\"setPostMessageVerifier\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}]", + Bin: "0x60a06040523060805234801561001457600080fd5b5061001d610022565b6100d4565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100725760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100d15780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b608051611c126100fd600039600081816109a6015281816109cf0152610b150152611c126000f3fe6080604052600436106100dd5760003560e01c80637524ac3d1161007f578063ad3cb1cc11610059578063ad3cb1cc1461025a578063d09ce7cc14610298578063e0d30bb3146102b8578063f2fde38b146102ce57600080fd5b80637524ac3d146101dd5780637873dd5f146101fd5780638da5cb5b1461021d57600080fd5b806351d85c10116100bb57806351d85c101461014d57806352d1902d146101855780635af8bfc6146101a8578063715018a6146101c857600080fd5b806306b7702f146100e25780631e9d3959146101185780634f1ef2861461013a575b600080fd5b3480156100ee57600080fd5b506101026100fd366004611436565b6102ee565b60405161010f91906114bb565b60405180910390f35b34801561012457600080fd5b50610138610133366004611531565b610433565b005b610138610148366004611626565b61045d565b34801561015957600080fd5b5060015461016d906001600160a01b031681565b6040516001600160a01b03909116815260200161010f565b34801561019157600080fd5b5061019a61047c565b60405190815260200161010f565b3480156101b457600080fd5b506101386101c336600461168a565b610499565b3480156101d457600080fd5b50610138610610565b3480156101e957600080fd5b506101386101f8366004611720565b610624565b34801561020957600080fd5b50610138610218366004611531565b610765565b34801561022957600080fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031661016d565b34801561026657600080fd5b5061028b604051806040016040528060058152602001640352e302e360dc1b81525081565b60405161010f9190611759565b3480156102a457600080fd5b5060005461016d906001600160a01b031681565b3480156102c457600080fd5b5061019a610e1081565b3480156102da57600080fd5b506101386102e9366004611531565b61078f565b6001600160a01b0383166000908152600260205260408120606091906103159085856107cd565b6001600160a01b03861660009081526003602052604081209192509061033c908686610894565b90506000825167ffffffffffffffff81111561035a5761035a61154e565b6040519080825280602002602001820160405280156103a057816020015b6040805180820190915260608152600060208201528152602001906001900390816103785790505b50905060005b83518110156104265760405180604001604052808583815181106103cc576103cc61176c565b602002602001015181526020018483815181106103eb576103eb61176c565b60200260200101518152508282815181106104085761040861176c565b6020026020010181905250808061041e90611798565b9150506103a6565b50925050505b9392505050565b61043b610940565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b61046561099b565b61046e82610a40565b6104788282610a48565b5050565b6000610486610b0a565b50600080516020611bbd83398151915290565b600154604051630c3bd06d60e21b8152600481018590526001600160a01b03909116906330ef41b490602401602060405180830381865afa1580156104e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050691906117b1565b6105235760405163a0e51db960e01b815260040160405180910390fd5b42821015610552576040516339b0da6b60e01b8152600481018390524260248201526044015b60405180910390fd5b61056d8585858561056836879003870187611823565b610b53565b61058a576040516303b2487b60e11b815260040160405180910390fd5b6001600160a01b03851660009081526002602052604090206105ac9085610c5b565b506001600160a01b03851660009081526003602052604090206105cf9042610c70565b507ffe7cdc2459269b5bc10478528a21029a11424d593a2c88471f4f5cfb582765b785856040516106019291906118bd565b60405180910390a15050505050565b610618610940565b6106226000610c7c565b565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff1660008115801561066a5750825b905060008267ffffffffffffffff1660011480156106875750303b155b905081158015610695575080155b156106b35760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156106dd57845460ff60401b1916600160401b1785555b6106e633610ced565b600080546001600160a01b038089166001600160a01b03199283161790925560018054928a1692909116919091179055831561075c57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b61076d610940565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b610797610940565b6001600160a01b0381166107c157604051631e4fbdf760e01b815260006004820152602401610549565b6107ca81610c7c565b50565b606060006107e46107dd86610cfe565b8585610d08565b90506107f084826118e1565b67ffffffffffffffff8111156108085761080861154e565b60405190808252806020026020018201604052801561083b57816020015b60608152602001906001900390816108265790505b509150835b8181101561088b576108528682610d31565b8361085d87846118e1565b8151811061086d5761086d61176c565b6020026020010181905250808061088390611798565b915050610840565b50509392505050565b606060006108a46107dd86610cfe565b90506108b084826118e1565b67ffffffffffffffff8111156108c8576108c861154e565b6040519080825280602002602001820160405280156108f1578160200160208202803683370190505b509150835b8181101561088b576109088682610d3d565b8361091387846118e1565b815181106109235761092361176c565b60209081029190910101528061093881611798565b9150506108f6565b336109727f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b0316146106225760405163118cdaa760e01b8152336004820152602401610549565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480610a2257507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610a16600080516020611bbd833981519152546001600160a01b031690565b6001600160a01b031614155b156106225760405163703e46dd60e11b815260040160405180910390fd5b6107ca610940565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015610aa2575060408051601f3d908101601f19168201909252610a9f918101906118f4565b60015b610aca57604051634c9c8ce360e01b81526001600160a01b0383166004820152602401610549565b600080516020611bbd8339815191528114610afb57604051632a87526960e21b815260048101829052602401610549565b610b058383610d49565b505050565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146106225760405163703e46dd60e11b815260040160405180910390fd5b60408051600480825260a0820190925260009182919060208201608080368337019050509050866001600160a01b031681600081518110610b9657610b9661176c565b6020026020010181815250508460001c81600181518110610bb957610bb961176c565b60200260200101818152505085604051602001610bd6919061190d565b604051602081830303815290604052805190602001206001600160f81b0360001b1660001c81600281518110610c0e57610c0e61176c565b6020026020010181815250508381600381518110610c2e57610c2e61176c565b6020908102919091010152600054610c50906001600160a01b03168285610d9f565b979650505050505050565b6000610c678383610dc4565b90505b92915050565b6000610c678383610e31565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b610cf5610e78565b6107ca81610ec1565b6000610c6a825490565b6000610d148284611929565b905083811115610d215750825b8083111561042c57509092915050565b6060610c678383610ec9565b6000610c678383610f7b565b610d5282610fa5565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115610d9757610b05828261100a565b610478611080565b6000610dbc8483600001518460200151856040015187885161109f565b949350505050565b80516020808301919091206000908152600184019091526040812054610e2957825460018101845560008481526020902001610e0083826119c4565b505081548151602080840191909120600090815260018086019092526040902091909155610c6a565b506000610c6a565b6000818152600183016020526040812054610e2957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610c6a565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661062257604051631afcd79f60e31b815260040160405180910390fd5b610797610e78565b6060826000018281548110610ee057610ee061176c565b906000526020600020018054610ef59061193c565b80601f0160208091040260200160405190810160405280929190818152602001828054610f219061193c565b8015610f6e5780601f10610f4357610100808354040283529160200191610f6e565b820191906000526020600020905b815481529060010190602001808311610f5157829003601f168201915b5050505050905092915050565b6000826000018281548110610f9257610f9261176c565b9060005260206000200154905092915050565b806001600160a01b03163b600003610fdb57604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610549565b600080516020611bbd83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b031684604051611027919061190d565b600060405180830381855af49150503d8060008114611062576040519150601f19603f3d011682016040523d82523d6000602084013e611067565b606091505b5091509150611077858383611231565b95945050505050565b34156106225760405163b398979f60e01b815260040160405180910390fd5b6000806110ab8361128d565b6040516020016110bb9190611a84565b6040516020818303038152906040529050600080896001600160a01b0316838a8a8a6040516024016110ef93929190611b24565b60408051601f19818403018152908290529161110a9161190d565b60405180910390206001600160e01b0319166020820180516001600160e01b03838183161783525050505087604051602001611147929190611b74565b60408051601f19818403018152908290526111619161190d565b600060405180830381855afa9150503d806000811461119c576040519150601f19603f3d011682016040523d82523d6000602084013e6111a1565b606091505b50915091508161120f5760405162461bcd60e51b815260206004820152603360248201527f566572696669657248656c7065723a206661696c656420746f2063616c6c207660448201527232b934b33ca83937b7b310333ab731ba34b7b760691b6064820152608401610549565b8080602001905181019061122391906117b1565b9a9950505050505050505050565b6060826112465761124182611320565b61042c565b815115801561125d57506001600160a01b0384163b155b1561128657604051639996b31560e01b81526001600160a01b0385166004820152602401610549565b508061042c565b6060600061129a83611349565b600101905060008167ffffffffffffffff8111156112ba576112ba61154e565b6040519080825280601f01601f1916602001820160405280156112e4576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846112ee57509392505050565b8051156113305780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106113885772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106113b4576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106113d257662386f26fc10000830492506010015b6305f5e10083106113ea576305f5e100830492506008015b61271083106113fe57612710830492506004015b60648310611410576064830492506002015b600a8310610c6a5760010192915050565b6001600160a01b03811681146107ca57600080fd5b60008060006060848603121561144b57600080fd5b833561145681611421565b95602085013595506040909401359392505050565b60005b8381101561148657818101518382015260200161146e565b50506000910152565b600081518084526114a781602086016020860161146b565b601f01601f19169290920160200192915050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b8381101561152357888303603f19018552815180518785526115068886018261148f565b9189015194890194909452948701949250908601906001016114e2565b509098975050505050505050565b60006020828403121561154357600080fd5b813561042c81611421565b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff811182821017156115875761158761154e565b60405290565b6040805190810167ffffffffffffffff811182821017156115875761158761154e565b600067ffffffffffffffff808411156115cb576115cb61154e565b604051601f8501601f19908116603f011681019082821181831017156115f3576115f361154e565b8160405280935085815286868601111561160c57600080fd5b858560208301376000602087830101525050509392505050565b6000806040838503121561163957600080fd5b823561164481611421565b9150602083013567ffffffffffffffff81111561166057600080fd5b8301601f8101851361167157600080fd5b611680858235602084016115b0565b9150509250929050565b60008060008060008587036101808112156116a457600080fd5b86356116af81611421565b9550602087013567ffffffffffffffff8111156116cb57600080fd5b8701601f810189136116dc57600080fd5b6116eb898235602084016115b0565b9550506040870135935060608701359250610100607f198201121561170f57600080fd5b506080860190509295509295909350565b6000806040838503121561173357600080fd5b823561173e81611421565b9150602083013561174e81611421565b809150509250929050565b602081526000610c67602083018461148f565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016117aa576117aa611782565b5060010190565b6000602082840312156117c357600080fd5b8151801515811461042c57600080fd5b600082601f8301126117e457600080fd5b6117ec61158d565b8060408401858111156117fe57600080fd5b845b81811015611818578035845260209384019301611800565b509095945050505050565b6000610100828403121561183657600080fd5b61183e611564565b61184884846117d3565b8152604084605f85011261185b57600080fd5b61186361158d565b8060c086018781111561187557600080fd5b8387015b8181101561189a5761188b89826117d3565b84526020909301928401611879565b508160208601526118ab88826117d3565b84860152505050508091505092915050565b6001600160a01b0383168152604060208201819052600090610dbc9083018461148f565b81810381811115610c6a57610c6a611782565b60006020828403121561190657600080fd5b5051919050565b6000825161191f81846020870161146b565b9190910192915050565b80820180821115610c6a57610c6a611782565b600181811c9082168061195057607f821691505b60208210810361197057634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115610b0557600081815260208120601f850160051c8101602086101561199d5750805b601f850160051c820191505b818110156119bc578281556001016119a9565b505050505050565b815167ffffffffffffffff8111156119de576119de61154e565b6119f2816119ec845461193c565b84611976565b602080601f831160018114611a275760008415611a0f5750858301515b600019600386901b1c1916600185901b1785556119bc565b600085815260208120601f198616915b82811015611a5657888601518255948401946001909101908401611a37565b5085821015611a745787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b7f76657269667950726f6f662875696e743235365b325d2c75696e743235365b3281527f5d5b325d2c75696e743235365b325d2c75696e743235365b0000000000000000602082015260008251611ae281603885016020870161146b565b615d2960f01b6038939091019283015250603a01919050565b8060005b6002811015611b1e578151845260209384019390910190600101611aff565b50505050565b6101008101611b338286611afb565b60408083018560005b6002811015611b6357611b50838351611afb565b9183019160209190910190600101611b3c565b50505050610dbc60c0830184611afb565b600083516020611b87828583890161146b565b84519184019181860160005b82811015611baf57815185529383019390830190600101611b93565b509297965050505050505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca26469706673582212209f20d16ba3e09539803ee8ac866314bb0c9aa11e7ee02bb7d754202c7591571f64736f6c63430008140033", +} + +// ChatABI is the input ABI used to generate the binding from. +// Deprecated: Use ChatMetaData.ABI instead. +var ChatABI = ChatMetaData.ABI + +// ChatBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use ChatMetaData.Bin instead. +var ChatBin = ChatMetaData.Bin + +// DeployChat deploys a new Ethereum contract, binding an instance of Chat to it. +func DeployChat(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Chat, error) { + parsed, err := ChatMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(ChatBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &Chat{ChatCaller: ChatCaller{contract: contract}, ChatTransactor: ChatTransactor{contract: contract}, ChatFilterer: ChatFilterer{contract: contract}}, nil +} + +// Chat is an auto generated Go binding around an Ethereum contract. +type Chat struct { + ChatCaller // Read-only binding to the contract + ChatTransactor // Write-only binding to the contract + ChatFilterer // Log filterer for contract events +} + +// ChatCaller is an auto generated read-only Go binding around an Ethereum contract. +type ChatCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ChatTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ChatTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ChatFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ChatFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ChatSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ChatSession struct { + Contract *Chat // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ChatCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ChatCallerSession struct { + Contract *ChatCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ChatTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ChatTransactorSession struct { + Contract *ChatTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ChatRaw is an auto generated low-level Go binding around an Ethereum contract. +type ChatRaw struct { + Contract *Chat // Generic contract binding to access the raw methods on +} + +// ChatCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ChatCallerRaw struct { + Contract *ChatCaller // Generic read-only contract binding to access the raw methods on +} + +// ChatTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ChatTransactorRaw struct { + Contract *ChatTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewChat creates a new instance of Chat, bound to a specific deployed contract. +func NewChat(address common.Address, backend bind.ContractBackend) (*Chat, error) { + contract, err := bindChat(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Chat{ChatCaller: ChatCaller{contract: contract}, ChatTransactor: ChatTransactor{contract: contract}, ChatFilterer: ChatFilterer{contract: contract}}, nil +} + +// NewChatCaller creates a new read-only instance of Chat, bound to a specific deployed contract. +func NewChatCaller(address common.Address, caller bind.ContractCaller) (*ChatCaller, error) { + contract, err := bindChat(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ChatCaller{contract: contract}, nil +} + +// NewChatTransactor creates a new write-only instance of Chat, bound to a specific deployed contract. +func NewChatTransactor(address common.Address, transactor bind.ContractTransactor) (*ChatTransactor, error) { + contract, err := bindChat(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ChatTransactor{contract: contract}, nil +} + +// NewChatFilterer creates a new log filterer instance of Chat, bound to a specific deployed contract. +func NewChatFilterer(address common.Address, filterer bind.ContractFilterer) (*ChatFilterer, error) { + contract, err := bindChat(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ChatFilterer{contract: contract}, nil +} + +// bindChat binds a generic wrapper to an already deployed contract. +func bindChat(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := ChatMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Chat *ChatRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Chat.Contract.ChatCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Chat *ChatRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Chat.Contract.ChatTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Chat *ChatRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Chat.Contract.ChatTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Chat *ChatCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Chat.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Chat *ChatTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Chat.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Chat *ChatTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Chat.Contract.contract.Transact(opts, method, params...) +} + +// DEADLINEVALIDITYWINDOW is a free data retrieval call binding the contract method 0xe0d30bb3. +// +// Solidity: function DEADLINE_VALIDITY_WINDOW() view returns(uint256) +func (_Chat *ChatCaller) DEADLINEVALIDITYWINDOW(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Chat.contract.Call(opts, &out, "DEADLINE_VALIDITY_WINDOW") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// DEADLINEVALIDITYWINDOW is a free data retrieval call binding the contract method 0xe0d30bb3. +// +// Solidity: function DEADLINE_VALIDITY_WINDOW() view returns(uint256) +func (_Chat *ChatSession) DEADLINEVALIDITYWINDOW() (*big.Int, error) { + return _Chat.Contract.DEADLINEVALIDITYWINDOW(&_Chat.CallOpts) +} + +// DEADLINEVALIDITYWINDOW is a free data retrieval call binding the contract method 0xe0d30bb3. +// +// Solidity: function DEADLINE_VALIDITY_WINDOW() view returns(uint256) +func (_Chat *ChatCallerSession) DEADLINEVALIDITYWINDOW() (*big.Int, error) { + return _Chat.Contract.DEADLINEVALIDITYWINDOW(&_Chat.CallOpts) +} + +// UPGRADEINTERFACEVERSION is a free data retrieval call binding the contract method 0xad3cb1cc. +// +// Solidity: function UPGRADE_INTERFACE_VERSION() view returns(string) +func (_Chat *ChatCaller) UPGRADEINTERFACEVERSION(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _Chat.contract.Call(opts, &out, "UPGRADE_INTERFACE_VERSION") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// UPGRADEINTERFACEVERSION is a free data retrieval call binding the contract method 0xad3cb1cc. +// +// Solidity: function UPGRADE_INTERFACE_VERSION() view returns(string) +func (_Chat *ChatSession) UPGRADEINTERFACEVERSION() (string, error) { + return _Chat.Contract.UPGRADEINTERFACEVERSION(&_Chat.CallOpts) +} + +// UPGRADEINTERFACEVERSION is a free data retrieval call binding the contract method 0xad3cb1cc. +// +// Solidity: function UPGRADE_INTERFACE_VERSION() view returns(string) +func (_Chat *ChatCallerSession) UPGRADEINTERFACEVERSION() (string, error) { + return _Chat.Contract.UPGRADEINTERFACEVERSION(&_Chat.CallOpts) +} + +// CredentialStorage is a free data retrieval call binding the contract method 0x51d85c10. +// +// Solidity: function credentialStorage() view returns(address) +func (_Chat *ChatCaller) CredentialStorage(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Chat.contract.Call(opts, &out, "credentialStorage") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// CredentialStorage is a free data retrieval call binding the contract method 0x51d85c10. +// +// Solidity: function credentialStorage() view returns(address) +func (_Chat *ChatSession) CredentialStorage() (common.Address, error) { + return _Chat.Contract.CredentialStorage(&_Chat.CallOpts) +} + +// CredentialStorage is a free data retrieval call binding the contract method 0x51d85c10. +// +// Solidity: function credentialStorage() view returns(address) +func (_Chat *ChatCallerSession) CredentialStorage() (common.Address, error) { + return _Chat.Contract.CredentialStorage(&_Chat.CallOpts) +} + +// ListMessages is a free data retrieval call binding the contract method 0x06b7702f. +// +// Solidity: function listMessages(address nft_, uint256 offset_, uint256 limit_) view returns((string,uint256)[]) +func (_Chat *ChatCaller) ListMessages(opts *bind.CallOpts, nft_ common.Address, offset_ *big.Int, limit_ *big.Int) ([]ChatMessage, error) { + var out []interface{} + err := _Chat.contract.Call(opts, &out, "listMessages", nft_, offset_, limit_) + + if err != nil { + return *new([]ChatMessage), err + } + + out0 := *abi.ConvertType(out[0], new([]ChatMessage)).(*[]ChatMessage) + + return out0, err + +} + +// ListMessages is a free data retrieval call binding the contract method 0x06b7702f. +// +// Solidity: function listMessages(address nft_, uint256 offset_, uint256 limit_) view returns((string,uint256)[]) +func (_Chat *ChatSession) ListMessages(nft_ common.Address, offset_ *big.Int, limit_ *big.Int) ([]ChatMessage, error) { + return _Chat.Contract.ListMessages(&_Chat.CallOpts, nft_, offset_, limit_) +} + +// ListMessages is a free data retrieval call binding the contract method 0x06b7702f. +// +// Solidity: function listMessages(address nft_, uint256 offset_, uint256 limit_) view returns((string,uint256)[]) +func (_Chat *ChatCallerSession) ListMessages(nft_ common.Address, offset_ *big.Int, limit_ *big.Int) ([]ChatMessage, error) { + return _Chat.Contract.ListMessages(&_Chat.CallOpts, nft_, offset_, limit_) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Chat *ChatCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Chat.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Chat *ChatSession) Owner() (common.Address, error) { + return _Chat.Contract.Owner(&_Chat.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Chat *ChatCallerSession) Owner() (common.Address, error) { + return _Chat.Contract.Owner(&_Chat.CallOpts) +} + +// PostMessageVerifier is a free data retrieval call binding the contract method 0xd09ce7cc. +// +// Solidity: function postMessageVerifier() view returns(address) +func (_Chat *ChatCaller) PostMessageVerifier(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Chat.contract.Call(opts, &out, "postMessageVerifier") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// PostMessageVerifier is a free data retrieval call binding the contract method 0xd09ce7cc. +// +// Solidity: function postMessageVerifier() view returns(address) +func (_Chat *ChatSession) PostMessageVerifier() (common.Address, error) { + return _Chat.Contract.PostMessageVerifier(&_Chat.CallOpts) +} + +// PostMessageVerifier is a free data retrieval call binding the contract method 0xd09ce7cc. +// +// Solidity: function postMessageVerifier() view returns(address) +func (_Chat *ChatCallerSession) PostMessageVerifier() (common.Address, error) { + return _Chat.Contract.PostMessageVerifier(&_Chat.CallOpts) +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_Chat *ChatCaller) ProxiableUUID(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _Chat.contract.Call(opts, &out, "proxiableUUID") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_Chat *ChatSession) ProxiableUUID() ([32]byte, error) { + return _Chat.Contract.ProxiableUUID(&_Chat.CallOpts) +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_Chat *ChatCallerSession) ProxiableUUID() ([32]byte, error) { + return _Chat.Contract.ProxiableUUID(&_Chat.CallOpts) +} + +// ChatInit is a paid mutator transaction binding the contract method 0x7524ac3d. +// +// Solidity: function __Chat_init(address authenticationStorage_, address postMessageVerifier_) returns() +func (_Chat *ChatTransactor) ChatInit(opts *bind.TransactOpts, authenticationStorage_ common.Address, postMessageVerifier_ common.Address) (*types.Transaction, error) { + return _Chat.contract.Transact(opts, "__Chat_init", authenticationStorage_, postMessageVerifier_) +} + +// ChatInit is a paid mutator transaction binding the contract method 0x7524ac3d. +// +// Solidity: function __Chat_init(address authenticationStorage_, address postMessageVerifier_) returns() +func (_Chat *ChatSession) ChatInit(authenticationStorage_ common.Address, postMessageVerifier_ common.Address) (*types.Transaction, error) { + return _Chat.Contract.ChatInit(&_Chat.TransactOpts, authenticationStorage_, postMessageVerifier_) +} + +// ChatInit is a paid mutator transaction binding the contract method 0x7524ac3d. +// +// Solidity: function __Chat_init(address authenticationStorage_, address postMessageVerifier_) returns() +func (_Chat *ChatTransactorSession) ChatInit(authenticationStorage_ common.Address, postMessageVerifier_ common.Address) (*types.Transaction, error) { + return _Chat.Contract.ChatInit(&_Chat.TransactOpts, authenticationStorage_, postMessageVerifier_) +} + +// PostMessage is a paid mutator transaction binding the contract method 0x5af8bfc6. +// +// Solidity: function postMessage(address nft_, string message_, bytes32 root_, uint256 expectedMessageTime_, (uint256[2],uint256[2][2],uint256[2]) zkPoints_) returns() +func (_Chat *ChatTransactor) PostMessage(opts *bind.TransactOpts, nft_ common.Address, message_ string, root_ [32]byte, expectedMessageTime_ *big.Int, zkPoints_ VerifierHelperProofPoints) (*types.Transaction, error) { + return _Chat.contract.Transact(opts, "postMessage", nft_, message_, root_, expectedMessageTime_, zkPoints_) +} + +// PostMessage is a paid mutator transaction binding the contract method 0x5af8bfc6. +// +// Solidity: function postMessage(address nft_, string message_, bytes32 root_, uint256 expectedMessageTime_, (uint256[2],uint256[2][2],uint256[2]) zkPoints_) returns() +func (_Chat *ChatSession) PostMessage(nft_ common.Address, message_ string, root_ [32]byte, expectedMessageTime_ *big.Int, zkPoints_ VerifierHelperProofPoints) (*types.Transaction, error) { + return _Chat.Contract.PostMessage(&_Chat.TransactOpts, nft_, message_, root_, expectedMessageTime_, zkPoints_) +} + +// PostMessage is a paid mutator transaction binding the contract method 0x5af8bfc6. +// +// Solidity: function postMessage(address nft_, string message_, bytes32 root_, uint256 expectedMessageTime_, (uint256[2],uint256[2][2],uint256[2]) zkPoints_) returns() +func (_Chat *ChatTransactorSession) PostMessage(nft_ common.Address, message_ string, root_ [32]byte, expectedMessageTime_ *big.Int, zkPoints_ VerifierHelperProofPoints) (*types.Transaction, error) { + return _Chat.Contract.PostMessage(&_Chat.TransactOpts, nft_, message_, root_, expectedMessageTime_, zkPoints_) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Chat *ChatTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Chat.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Chat *ChatSession) RenounceOwnership() (*types.Transaction, error) { + return _Chat.Contract.RenounceOwnership(&_Chat.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Chat *ChatTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _Chat.Contract.RenounceOwnership(&_Chat.TransactOpts) +} + +// SetCredentialStorage is a paid mutator transaction binding the contract method 0x1e9d3959. +// +// Solidity: function setCredentialStorage(address credentialStorage_) returns() +func (_Chat *ChatTransactor) SetCredentialStorage(opts *bind.TransactOpts, credentialStorage_ common.Address) (*types.Transaction, error) { + return _Chat.contract.Transact(opts, "setCredentialStorage", credentialStorage_) +} + +// SetCredentialStorage is a paid mutator transaction binding the contract method 0x1e9d3959. +// +// Solidity: function setCredentialStorage(address credentialStorage_) returns() +func (_Chat *ChatSession) SetCredentialStorage(credentialStorage_ common.Address) (*types.Transaction, error) { + return _Chat.Contract.SetCredentialStorage(&_Chat.TransactOpts, credentialStorage_) +} + +// SetCredentialStorage is a paid mutator transaction binding the contract method 0x1e9d3959. +// +// Solidity: function setCredentialStorage(address credentialStorage_) returns() +func (_Chat *ChatTransactorSession) SetCredentialStorage(credentialStorage_ common.Address) (*types.Transaction, error) { + return _Chat.Contract.SetCredentialStorage(&_Chat.TransactOpts, credentialStorage_) +} + +// SetPostMessageVerifier is a paid mutator transaction binding the contract method 0x7873dd5f. +// +// Solidity: function setPostMessageVerifier(address postMessageVerifier_) returns() +func (_Chat *ChatTransactor) SetPostMessageVerifier(opts *bind.TransactOpts, postMessageVerifier_ common.Address) (*types.Transaction, error) { + return _Chat.contract.Transact(opts, "setPostMessageVerifier", postMessageVerifier_) +} + +// SetPostMessageVerifier is a paid mutator transaction binding the contract method 0x7873dd5f. +// +// Solidity: function setPostMessageVerifier(address postMessageVerifier_) returns() +func (_Chat *ChatSession) SetPostMessageVerifier(postMessageVerifier_ common.Address) (*types.Transaction, error) { + return _Chat.Contract.SetPostMessageVerifier(&_Chat.TransactOpts, postMessageVerifier_) +} + +// SetPostMessageVerifier is a paid mutator transaction binding the contract method 0x7873dd5f. +// +// Solidity: function setPostMessageVerifier(address postMessageVerifier_) returns() +func (_Chat *ChatTransactorSession) SetPostMessageVerifier(postMessageVerifier_ common.Address) (*types.Transaction, error) { + return _Chat.Contract.SetPostMessageVerifier(&_Chat.TransactOpts, postMessageVerifier_) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Chat *ChatTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _Chat.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Chat *ChatSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Chat.Contract.TransferOwnership(&_Chat.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Chat *ChatTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Chat.Contract.TransferOwnership(&_Chat.TransactOpts, newOwner) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_Chat *ChatTransactor) UpgradeToAndCall(opts *bind.TransactOpts, newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _Chat.contract.Transact(opts, "upgradeToAndCall", newImplementation, data) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_Chat *ChatSession) UpgradeToAndCall(newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _Chat.Contract.UpgradeToAndCall(&_Chat.TransactOpts, newImplementation, data) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_Chat *ChatTransactorSession) UpgradeToAndCall(newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _Chat.Contract.UpgradeToAndCall(&_Chat.TransactOpts, newImplementation, data) +} + +// ChatInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the Chat contract. +type ChatInitializedIterator struct { + Event *ChatInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ChatInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ChatInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ChatInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ChatInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ChatInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ChatInitialized represents a Initialized event raised by the Chat contract. +type ChatInitialized struct { + Version uint64 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2. +// +// Solidity: event Initialized(uint64 version) +func (_Chat *ChatFilterer) FilterInitialized(opts *bind.FilterOpts) (*ChatInitializedIterator, error) { + + logs, sub, err := _Chat.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &ChatInitializedIterator{contract: _Chat.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2. +// +// Solidity: event Initialized(uint64 version) +func (_Chat *ChatFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *ChatInitialized) (event.Subscription, error) { + + logs, sub, err := _Chat.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ChatInitialized) + if err := _Chat.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2. +// +// Solidity: event Initialized(uint64 version) +func (_Chat *ChatFilterer) ParseInitialized(log types.Log) (*ChatInitialized, error) { + event := new(ChatInitialized) + if err := _Chat.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ChatMessagePostedIterator is returned from FilterMessagePosted and is used to iterate over the raw logs and unpacked data for MessagePosted events raised by the Chat contract. +type ChatMessagePostedIterator struct { + Event *ChatMessagePosted // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ChatMessagePostedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ChatMessagePosted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ChatMessagePosted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ChatMessagePostedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ChatMessagePostedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ChatMessagePosted represents a MessagePosted event raised by the Chat contract. +type ChatMessagePosted struct { + Nft common.Address + Message string + Raw types.Log // Blockchain specific contextual infos +} + +// FilterMessagePosted is a free log retrieval operation binding the contract event 0xfe7cdc2459269b5bc10478528a21029a11424d593a2c88471f4f5cfb582765b7. +// +// Solidity: event MessagePosted(address nft, string message) +func (_Chat *ChatFilterer) FilterMessagePosted(opts *bind.FilterOpts) (*ChatMessagePostedIterator, error) { + + logs, sub, err := _Chat.contract.FilterLogs(opts, "MessagePosted") + if err != nil { + return nil, err + } + return &ChatMessagePostedIterator{contract: _Chat.contract, event: "MessagePosted", logs: logs, sub: sub}, nil +} + +// WatchMessagePosted is a free log subscription operation binding the contract event 0xfe7cdc2459269b5bc10478528a21029a11424d593a2c88471f4f5cfb582765b7. +// +// Solidity: event MessagePosted(address nft, string message) +func (_Chat *ChatFilterer) WatchMessagePosted(opts *bind.WatchOpts, sink chan<- *ChatMessagePosted) (event.Subscription, error) { + + logs, sub, err := _Chat.contract.WatchLogs(opts, "MessagePosted") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ChatMessagePosted) + if err := _Chat.contract.UnpackLog(event, "MessagePosted", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseMessagePosted is a log parse operation binding the contract event 0xfe7cdc2459269b5bc10478528a21029a11424d593a2c88471f4f5cfb582765b7. +// +// Solidity: event MessagePosted(address nft, string message) +func (_Chat *ChatFilterer) ParseMessagePosted(log types.Log) (*ChatMessagePosted, error) { + event := new(ChatMessagePosted) + if err := _Chat.contract.UnpackLog(event, "MessagePosted", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ChatOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the Chat contract. +type ChatOwnershipTransferredIterator struct { + Event *ChatOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ChatOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ChatOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ChatOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ChatOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ChatOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ChatOwnershipTransferred represents a OwnershipTransferred event raised by the Chat contract. +type ChatOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Chat *ChatFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ChatOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Chat.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &ChatOwnershipTransferredIterator{contract: _Chat.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Chat *ChatFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ChatOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Chat.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ChatOwnershipTransferred) + if err := _Chat.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Chat *ChatFilterer) ParseOwnershipTransferred(log types.Log) (*ChatOwnershipTransferred, error) { + event := new(ChatOwnershipTransferred) + if err := _Chat.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ChatUpgradedIterator is returned from FilterUpgraded and is used to iterate over the raw logs and unpacked data for Upgraded events raised by the Chat contract. +type ChatUpgradedIterator struct { + Event *ChatUpgraded // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ChatUpgradedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ChatUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ChatUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ChatUpgradedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ChatUpgradedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ChatUpgraded represents a Upgraded event raised by the Chat contract. +type ChatUpgraded struct { + Implementation common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterUpgraded is a free log retrieval operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_Chat *ChatFilterer) FilterUpgraded(opts *bind.FilterOpts, implementation []common.Address) (*ChatUpgradedIterator, error) { + + var implementationRule []interface{} + for _, implementationItem := range implementation { + implementationRule = append(implementationRule, implementationItem) + } + + logs, sub, err := _Chat.contract.FilterLogs(opts, "Upgraded", implementationRule) + if err != nil { + return nil, err + } + return &ChatUpgradedIterator{contract: _Chat.contract, event: "Upgraded", logs: logs, sub: sub}, nil +} + +// WatchUpgraded is a free log subscription operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_Chat *ChatFilterer) WatchUpgraded(opts *bind.WatchOpts, sink chan<- *ChatUpgraded, implementation []common.Address) (event.Subscription, error) { + + var implementationRule []interface{} + for _, implementationItem := range implementation { + implementationRule = append(implementationRule, implementationItem) + } + + logs, sub, err := _Chat.contract.WatchLogs(opts, "Upgraded", implementationRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ChatUpgraded) + if err := _Chat.contract.UnpackLog(event, "Upgraded", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseUpgraded is a log parse operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_Chat *ChatFilterer) ParseUpgraded(log types.Log) (*ChatUpgraded, error) { + event := new(ChatUpgraded) + if err := _Chat.contract.UnpackLog(event, "Upgraded", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/contracts/erc721.go b/contracts/erc721.go index c3ee88b..40065ca 100644 --- a/contracts/erc721.go +++ b/contracts/erc721.go @@ -31,8 +31,8 @@ var ( // ERC721MockMetaData contains all meta data concerning the ERC721Mock contract. var ERC721MockMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name_\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol_\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ERC721EnumerableForbiddenBatchMint\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"ERC721IncorrectOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ERC721InsufficientApproval\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"approver\",\"type\":\"address\"}],\"name\":\"ERC721InvalidApprover\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"ERC721InvalidOperator\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"ERC721InvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"ERC721InvalidReceiver\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"ERC721InvalidSender\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ERC721NonexistentToken\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"ERC721OutOfBoundsIndex\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_fromTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_toTokenId\",\"type\":\"uint256\"}],\"name\":\"BatchMetadataUpdate\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"MetadataUpdate\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId_\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to_\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId_\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenOfOwnerByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60806040523480156200001157600080fd5b50604051620019af380380620019af8339810160408190526200003491620001b1565b3382826000620000458382620002aa565b506001620000548282620002aa565b5050506001600160a01b0381166200008657604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b62000091816200009a565b50505062000376565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200011457600080fd5b81516001600160401b0380821115620001315762000131620000ec565b604051601f8301601f19908116603f011681019082821181831017156200015c576200015c620000ec565b816040528381526020925086838588010111156200017957600080fd5b600091505b838210156200019d57858201830151818301840152908201906200017e565b600093810190920192909252949350505050565b60008060408385031215620001c557600080fd5b82516001600160401b0380821115620001dd57600080fd5b620001eb8683870162000102565b935060208501519150808211156200020257600080fd5b50620002118582860162000102565b9150509250929050565b600181811c908216806200023057607f821691505b6020821081036200025157634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620002a557600081815260208120601f850160051c81016020861015620002805750805b601f850160051c820191505b81811015620002a1578281556001016200028c565b5050505b505050565b81516001600160401b03811115620002c657620002c6620000ec565b620002de81620002d784546200021b565b8462000257565b602080601f831160018114620003165760008415620002fd5750858301515b600019600386901b1c1916600185901b178555620002a1565b600085815260208120601f198616915b82811015620003475788860151825594840194600190910190840162000326565b5085821015620003665787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61162980620003866000396000f3fe608060405234801561001057600080fd5b50600436106101375760003560e01c80634f6ccce7116100b857806395d89b411161007c57806395d89b411461027c578063a22cb46514610284578063b88d4fde14610297578063c87b56dd146102aa578063e985e9c5146102bd578063f2fde38b146102d057600080fd5b80634f6ccce71461022a5780636352211e1461023d57806370a0823114610250578063715018a6146102635780638da5cb5b1461026b57600080fd5b806323b872dd116100ff57806323b872dd146101cb5780632f745c59146101de57806340c10f19146101f157806342842e0e1461020457806342966c681461021757600080fd5b806301ffc9a71461013c57806306fdde0314610164578063081812fc14610179578063095ea7b3146101a457806318160ddd146101b9575b600080fd5b61014f61014a36600461124c565b6102e3565b60405190151581526020015b60405180910390f35b61016c6102f4565b60405161015b91906112b9565b61018c6101873660046112cc565b610386565b6040516001600160a01b03909116815260200161015b565b6101b76101b2366004611301565b6103af565b005b6008545b60405190815260200161015b565b6101b76101d936600461132b565b6103be565b6101bd6101ec366004611301565b61044e565b6101b76101ff366004611301565b6104b3565b6101b761021236600461132b565b6104bd565b6101b76102253660046112cc565b6104dd565b6101bd6102383660046112cc565b6104e9565b61018c61024b3660046112cc565b610542565b6101bd61025e366004611367565b61054d565b6101b7610595565b600b546001600160a01b031661018c565b61016c6105a9565b6101b7610292366004611382565b6105b8565b6101b76102a53660046113d4565b6105c3565b61016c6102b83660046112cc565b6105da565b61014f6102cb3660046114b0565b6105e5565b6101b76102de366004611367565b610613565b60006102ee8261064e565b92915050565b606060008054610303906114e3565b80601f016020809104026020016040519081016040528092919081815260200182805461032f906114e3565b801561037c5780601f106103515761010080835404028352916020019161037c565b820191906000526020600020905b81548152906001019060200180831161035f57829003601f168201915b5050505050905090565b600061039182610673565b506000828152600460205260409020546001600160a01b03166102ee565b6103ba8282336106ac565b5050565b6001600160a01b0382166103ed57604051633250574960e11b8152600060048201526024015b60405180910390fd5b60006103fa8383336106b9565b9050836001600160a01b0316816001600160a01b031614610448576040516364283d7b60e01b81526001600160a01b03808616600483015260248201849052821660448201526064016103e4565b50505050565b60006104598361054d565b821061048a5760405163295f44f760e21b81526001600160a01b0384166004820152602481018390526044016103e4565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6103ba82826106ce565b6104d8838383604051806020016040528060008152506105c3565b505050565b6104e681610733565b50565b60006104f460085490565b821061051d5760405163295f44f760e21b815260006004820152602481018390526044016103e4565b600882815481106105305761053061151d565b90600052602060002001549050919050565b60006102ee82610673565b60006001600160a01b038216610579576040516322718ad960e21b8152600060048201526024016103e4565b506001600160a01b031660009081526003602052604090205490565b61059d61076e565b6105a7600061079b565b565b606060018054610303906114e3565b6103ba3383836107ed565b6105ce8484846103be565b6104488484848461088c565b60606102ee826109b5565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b61061b61076e565b6001600160a01b03811661064557604051631e4fbdf760e01b8152600060048201526024016103e4565b6104e68161079b565b60006001600160e01b03198216632483248360e11b14806102ee57506102ee82610abe565b6000818152600260205260408120546001600160a01b0316806102ee57604051637e27328960e01b8152600481018490526024016103e4565b6104d88383836001610ae3565b60006106c6848484610be9565b949350505050565b6001600160a01b0382166106f857604051633250574960e11b8152600060048201526024016103e4565b6000610706838360006106b9565b90506001600160a01b038116156104d8576040516339e3563760e11b8152600060048201526024016103e4565b600061074260008360006106b9565b90506001600160a01b0381166103ba57604051637e27328960e01b8152600481018390526024016103e4565b600b546001600160a01b031633146105a75760405163118cdaa760e01b81523360048201526024016103e4565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b03821661081f57604051630b61174360e31b81526001600160a01b03831660048201526024016103e4565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0383163b1561044857604051630a85bd0160e11b81526001600160a01b0384169063150b7a02906108ce903390889087908790600401611533565b6020604051808303816000875af1925050508015610909575060408051601f3d908101601f1916820190925261090691810190611570565b60015b610972573d808015610937576040519150601f19603f3d011682016040523d82523d6000602084013e61093c565b606091505b50805160000361096a57604051633250574960e11b81526001600160a01b03851660048201526024016103e4565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b146109ae57604051633250574960e11b81526001600160a01b03851660048201526024016103e4565b5050505050565b60606109c082610673565b506000828152600a6020526040812080546109da906114e3565b80601f0160208091040260200160405190810160405280929190818152602001828054610a06906114e3565b8015610a535780601f10610a2857610100808354040283529160200191610a53565b820191906000526020600020905b815481529060010190602001808311610a3657829003601f168201915b505050505090506000610a7160408051602081019091526000815290565b90508051600003610a83575092915050565b815115610ab5578082604051602001610a9d92919061158d565b60405160208183030381529060405292505050919050565b6106c684610cb6565b60006001600160e01b0319821663780e9d6360e01b14806102ee57506102ee82610d2b565b8080610af757506001600160a01b03821615155b15610bb9576000610b0784610673565b90506001600160a01b03831615801590610b335750826001600160a01b0316816001600160a01b031614155b8015610b465750610b4481846105e5565b155b15610b6f5760405163a9fbf51f60e01b81526001600160a01b03841660048201526024016103e4565b8115610bb75783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b5050600090815260046020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b600080610bf7858585610d7b565b90506001600160a01b038116610c5457610c4f84600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b610c77565b846001600160a01b0316816001600160a01b031614610c7757610c778185610e74565b6001600160a01b038516610c9357610c8e84610f05565b6106c6565b846001600160a01b0316816001600160a01b0316146106c6576106c68585610fb4565b6060610cc182610673565b506000610cd960408051602081019091526000815290565b90506000815111610cf95760405180602001604052806000815250610d24565b80610d0384611004565b604051602001610d1492919061158d565b6040516020818303038152906040525b9392505050565b60006001600160e01b031982166380ac58cd60e01b1480610d5c57506001600160e01b03198216635b5e139f60e01b145b806102ee57506301ffc9a760e01b6001600160e01b03198316146102ee565b6000828152600260205260408120546001600160a01b0390811690831615610da857610da8818486611097565b6001600160a01b03811615610de657610dc5600085600080610ae3565b6001600160a01b038116600090815260036020526040902080546000190190555b6001600160a01b03851615610e15576001600160a01b0385166000908152600360205260409020805460010190555b60008481526002602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b6000610e7f8361054d565b600083815260076020526040902054909150808214610ed2576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090610f17906001906115bc565b60008381526009602052604081205460088054939450909284908110610f3f57610f3f61151d565b906000526020600020015490508060088381548110610f6057610f6061151d565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480610f9857610f986115dd565b6001900381819060005260206000200160009055905550505050565b60006001610fc18461054d565b610fcb91906115bc565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b60606000611011836110fb565b600101905060008167ffffffffffffffff811115611031576110316113be565b6040519080825280601f01601f19166020018201604052801561105b576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461106557509392505050565b6110a28383836111d3565b6104d8576001600160a01b0383166110d057604051637e27328960e01b8152600481018290526024016103e4565b60405163177e802f60e01b81526001600160a01b0383166004820152602481018290526044016103e4565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b831061113a5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310611166576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061118457662386f26fc10000830492506010015b6305f5e100831061119c576305f5e100830492506008015b61271083106111b057612710830492506004015b606483106111c2576064830492506002015b600a83106102ee5760010192915050565b60006001600160a01b038316158015906106c65750826001600160a01b0316846001600160a01b0316148061120d575061120d84846105e5565b806106c65750506000908152600460205260409020546001600160a01b03908116911614919050565b6001600160e01b0319811681146104e657600080fd5b60006020828403121561125e57600080fd5b8135610d2481611236565b60005b8381101561128457818101518382015260200161126c565b50506000910152565b600081518084526112a5816020860160208601611269565b601f01601f19169290920160200192915050565b602081526000610d24602083018461128d565b6000602082840312156112de57600080fd5b5035919050565b80356001600160a01b03811681146112fc57600080fd5b919050565b6000806040838503121561131457600080fd5b61131d836112e5565b946020939093013593505050565b60008060006060848603121561134057600080fd5b611349846112e5565b9250611357602085016112e5565b9150604084013590509250925092565b60006020828403121561137957600080fd5b610d24826112e5565b6000806040838503121561139557600080fd5b61139e836112e5565b9150602083013580151581146113b357600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600080600080608085870312156113ea57600080fd5b6113f3856112e5565b9350611401602086016112e5565b925060408501359150606085013567ffffffffffffffff8082111561142557600080fd5b818701915087601f83011261143957600080fd5b81358181111561144b5761144b6113be565b604051601f8201601f19908116603f01168101908382118183101715611473576114736113be565b816040528281528a602084870101111561148c57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b600080604083850312156114c357600080fd5b6114cc836112e5565b91506114da602084016112e5565b90509250929050565b600181811c908216806114f757607f821691505b60208210810361151757634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906115669083018461128d565b9695505050505050565b60006020828403121561158257600080fd5b8151610d2481611236565b6000835161159f818460208801611269565b8351908301906115b3818360208801611269565b01949350505050565b818103818111156102ee57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fdfea26469706673582212203fdfdffd4078a26d4987d84ddf1a9883d07f7f78a1729a04baa987b803a305a464736f6c63430008140033", + ABI: "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name_\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol_\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ERC721EnumerableForbiddenBatchMint\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"ERC721IncorrectOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ERC721InsufficientApproval\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"approver\",\"type\":\"address\"}],\"name\":\"ERC721InvalidApprover\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"ERC721InvalidOperator\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"ERC721InvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"ERC721InvalidReceiver\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"ERC721InvalidSender\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ERC721NonexistentToken\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"ERC721OutOfBoundsIndex\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_fromTokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_toTokenId\",\"type\":\"uint256\"}],\"name\":\"BatchMetadataUpdate\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"MetadataUpdate\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId_\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner_\",\"type\":\"address\"}],\"name\":\"getTokensByOwner\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"tokens_\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to_\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId_\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenOfOwnerByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60806040523480156200001157600080fd5b5060405162001adc38038062001adc8339810160408190526200003491620001b1565b3382826000620000458382620002aa565b506001620000548282620002aa565b5050506001600160a01b0381166200008657604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b62000091816200009a565b50505062000376565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200011457600080fd5b81516001600160401b0380821115620001315762000131620000ec565b604051601f8301601f19908116603f011681019082821181831017156200015c576200015c620000ec565b816040528381526020925086838588010111156200017957600080fd5b600091505b838210156200019d57858201830151818301840152908201906200017e565b600093810190920192909252949350505050565b60008060408385031215620001c557600080fd5b82516001600160401b0380821115620001dd57600080fd5b620001eb8683870162000102565b935060208501519150808211156200020257600080fd5b50620002118582860162000102565b9150509250929050565b600181811c908216806200023057607f821691505b6020821081036200025157634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620002a557600081815260208120601f850160051c81016020861015620002805750805b601f850160051c820191505b81811015620002a1578281556001016200028c565b5050505b505050565b81516001600160401b03811115620002c657620002c6620000ec565b620002de81620002d784546200021b565b8462000257565b602080601f831160018114620003165760008415620002fd5750858301515b600019600386901b1c1916600185901b178555620002a1565b600085815260208120601f198616915b82811015620003475788860151825594840194600190910190840162000326565b5085821015620003665787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61175680620003866000396000f3fe608060405234801561001057600080fd5b50600436106101425760003560e01c80634f6ccce7116100b857806395d89b411161007c57806395d89b41146102a7578063a22cb465146102af578063b88d4fde146102c2578063c87b56dd146102d5578063e985e9c5146102e8578063f2fde38b146102fb57600080fd5b80634f6ccce7146102555780636352211e1461026857806370a082311461027b578063715018a61461028e5780638da5cb5b1461029657600080fd5b806323b872dd1161010a57806323b872dd146101d65780632f745c59146101e957806340398d67146101fc57806340c10f191461021c57806342842e0e1461022f57806342966c681461024257600080fd5b806301ffc9a71461014757806306fdde031461016f578063081812fc14610184578063095ea7b3146101af57806318160ddd146101c4575b600080fd5b61015a610155366004611314565b61030e565b60405190151581526020015b60405180910390f35b61017761031f565b6040516101669190611381565b610197610192366004611394565b6103b1565b6040516001600160a01b039091168152602001610166565b6101c26101bd3660046113c9565b6103da565b005b6008545b604051908152602001610166565b6101c26101e43660046113f3565b6103e9565b6101c86101f73660046113c9565b610479565b61020f61020a36600461142f565b6104de565b604051610166919061144a565b6101c261022a3660046113c9565b61057b565b6101c261023d3660046113f3565b610585565b6101c2610250366004611394565b6105a5565b6101c8610263366004611394565b6105b1565b610197610276366004611394565b61060a565b6101c861028936600461142f565b610615565b6101c261065d565b600b546001600160a01b0316610197565b610177610671565b6101c26102bd36600461148e565b610680565b6101c26102d03660046114e0565b61068b565b6101776102e3366004611394565b6106a2565b61015a6102f63660046115bc565b6106ad565b6101c261030936600461142f565b6106db565b600061031982610716565b92915050565b60606000805461032e906115ef565b80601f016020809104026020016040519081016040528092919081815260200182805461035a906115ef565b80156103a75780601f1061037c576101008083540402835291602001916103a7565b820191906000526020600020905b81548152906001019060200180831161038a57829003601f168201915b5050505050905090565b60006103bc8261073b565b506000828152600460205260409020546001600160a01b0316610319565b6103e5828233610774565b5050565b6001600160a01b03821661041857604051633250574960e11b8152600060048201526024015b60405180910390fd5b6000610425838333610781565b9050836001600160a01b0316816001600160a01b031614610473576040516364283d7b60e01b81526001600160a01b038086166004830152602482018490528216604482015260640161040f565b50505050565b600061048483610615565b82106104b55760405163295f44f760e21b81526001600160a01b03841660048201526024810183905260440161040f565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b606060006104eb83610615565b90508067ffffffffffffffff811115610506576105066114ca565b60405190808252806020026020018201604052801561052f578160200160208202803683370190505b50915060005b81811015610574576105478482610479565b83828151811061055957610559611629565b602090810291909101015261056d81611655565b9050610535565b5050919050565b6103e58282610796565b6105a08383836040518060200160405280600081525061068b565b505050565b6105ae816107fb565b50565b60006105bc60085490565b82106105e55760405163295f44f760e21b8152600060048201526024810183905260440161040f565b600882815481106105f8576105f8611629565b90600052602060002001549050919050565b60006103198261073b565b60006001600160a01b038216610641576040516322718ad960e21b81526000600482015260240161040f565b506001600160a01b031660009081526003602052604090205490565b610665610836565b61066f6000610863565b565b60606001805461032e906115ef565b6103e53383836108b5565b6106968484846103e9565b61047384848484610954565b606061031982610a7d565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6106e3610836565b6001600160a01b03811661070d57604051631e4fbdf760e01b81526000600482015260240161040f565b6105ae81610863565b60006001600160e01b03198216632483248360e11b1480610319575061031982610b86565b6000818152600260205260408120546001600160a01b03168061031957604051637e27328960e01b81526004810184905260240161040f565b6105a08383836001610bab565b600061078e848484610cb1565b949350505050565b6001600160a01b0382166107c057604051633250574960e11b81526000600482015260240161040f565b60006107ce83836000610781565b90506001600160a01b038116156105a0576040516339e3563760e11b81526000600482015260240161040f565b600061080a6000836000610781565b90506001600160a01b0381166103e557604051637e27328960e01b81526004810183905260240161040f565b600b546001600160a01b0316331461066f5760405163118cdaa760e01b815233600482015260240161040f565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0382166108e757604051630b61174360e31b81526001600160a01b038316600482015260240161040f565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0383163b1561047357604051630a85bd0160e11b81526001600160a01b0384169063150b7a029061099690339088908790879060040161166e565b6020604051808303816000875af19250505080156109d1575060408051601f3d908101601f191682019092526109ce918101906116ab565b60015b610a3a573d8080156109ff576040519150601f19603f3d011682016040523d82523d6000602084013e610a04565b606091505b508051600003610a3257604051633250574960e11b81526001600160a01b038516600482015260240161040f565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b14610a7657604051633250574960e11b81526001600160a01b038516600482015260240161040f565b5050505050565b6060610a888261073b565b506000828152600a602052604081208054610aa2906115ef565b80601f0160208091040260200160405190810160405280929190818152602001828054610ace906115ef565b8015610b1b5780601f10610af057610100808354040283529160200191610b1b565b820191906000526020600020905b815481529060010190602001808311610afe57829003601f168201915b505050505090506000610b3960408051602081019091526000815290565b90508051600003610b4b575092915050565b815115610b7d578082604051602001610b659291906116c8565b60405160208183030381529060405292505050919050565b61078e84610d7e565b60006001600160e01b0319821663780e9d6360e01b1480610319575061031982610df3565b8080610bbf57506001600160a01b03821615155b15610c81576000610bcf8461073b565b90506001600160a01b03831615801590610bfb5750826001600160a01b0316816001600160a01b031614155b8015610c0e5750610c0c81846106ad565b155b15610c375760405163a9fbf51f60e01b81526001600160a01b038416600482015260240161040f565b8115610c7f5783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b5050600090815260046020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b600080610cbf858585610e43565b90506001600160a01b038116610d1c57610d1784600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b610d3f565b846001600160a01b0316816001600160a01b031614610d3f57610d3f8185610f3c565b6001600160a01b038516610d5b57610d5684610fcd565b61078e565b846001600160a01b0316816001600160a01b03161461078e5761078e858561107c565b6060610d898261073b565b506000610da160408051602081019091526000815290565b90506000815111610dc15760405180602001604052806000815250610dec565b80610dcb846110cc565b604051602001610ddc9291906116c8565b6040516020818303038152906040525b9392505050565b60006001600160e01b031982166380ac58cd60e01b1480610e2457506001600160e01b03198216635b5e139f60e01b145b8061031957506301ffc9a760e01b6001600160e01b0319831614610319565b6000828152600260205260408120546001600160a01b0390811690831615610e7057610e7081848661115f565b6001600160a01b03811615610eae57610e8d600085600080610bab565b6001600160a01b038116600090815260036020526040902080546000190190555b6001600160a01b03851615610edd576001600160a01b0385166000908152600360205260409020805460010190555b60008481526002602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b6000610f4783610615565b600083815260076020526040902054909150808214610f9a576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090610fdf906001906116f7565b6000838152600960205260408120546008805493945090928490811061100757611007611629565b90600052602060002001549050806008838154811061102857611028611629565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806110605761106061170a565b6001900381819060005260206000200160009055905550505050565b6000600161108984610615565b61109391906116f7565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b606060006110d9836111c3565b600101905060008167ffffffffffffffff8111156110f9576110f96114ca565b6040519080825280601f01601f191660200182016040528015611123576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461112d57509392505050565b61116a83838361129b565b6105a0576001600160a01b03831661119857604051637e27328960e01b81526004810182905260240161040f565b60405163177e802f60e01b81526001600160a01b03831660048201526024810182905260440161040f565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106112025772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef8100000000831061122e576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061124c57662386f26fc10000830492506010015b6305f5e1008310611264576305f5e100830492506008015b612710831061127857612710830492506004015b6064831061128a576064830492506002015b600a83106103195760010192915050565b60006001600160a01b0383161580159061078e5750826001600160a01b0316846001600160a01b031614806112d557506112d584846106ad565b8061078e5750506000908152600460205260409020546001600160a01b03908116911614919050565b6001600160e01b0319811681146105ae57600080fd5b60006020828403121561132657600080fd5b8135610dec816112fe565b60005b8381101561134c578181015183820152602001611334565b50506000910152565b6000815180845261136d816020860160208601611331565b601f01601f19169290920160200192915050565b602081526000610dec6020830184611355565b6000602082840312156113a657600080fd5b5035919050565b80356001600160a01b03811681146113c457600080fd5b919050565b600080604083850312156113dc57600080fd5b6113e5836113ad565b946020939093013593505050565b60008060006060848603121561140857600080fd5b611411846113ad565b925061141f602085016113ad565b9150604084013590509250925092565b60006020828403121561144157600080fd5b610dec826113ad565b6020808252825182820181905260009190848201906040850190845b8181101561148257835183529284019291840191600101611466565b50909695505050505050565b600080604083850312156114a157600080fd5b6114aa836113ad565b9150602083013580151581146114bf57600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600080600080608085870312156114f657600080fd5b6114ff856113ad565b935061150d602086016113ad565b925060408501359150606085013567ffffffffffffffff8082111561153157600080fd5b818701915087601f83011261154557600080fd5b813581811115611557576115576114ca565b604051601f8201601f19908116603f0116810190838211818310171561157f5761157f6114ca565b816040528281528a602084870101111561159857600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b600080604083850312156115cf57600080fd5b6115d8836113ad565b91506115e6602084016113ad565b90509250929050565b600181811c9082168061160357607f821691505b60208210810361162357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016116675761166761163f565b5060010190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906116a190830184611355565b9695505050505050565b6000602082840312156116bd57600080fd5b8151610dec816112fe565b600083516116da818460208801611331565b8351908301906116ee818360208801611331565b01949350505050565b818103818111156103195761031961163f565b634e487b7160e01b600052603160045260246000fdfea26469706673582212205d637c50630fcfe1a78f4481d363b7cb78960a952b80737a51f5665f34a6f75164736f6c63430008140033", } // ERC721MockABI is the input ABI used to generate the binding from. @@ -264,6 +264,37 @@ func (_ERC721Mock *ERC721MockCallerSession) GetApproved(tokenId *big.Int) (commo return _ERC721Mock.Contract.GetApproved(&_ERC721Mock.CallOpts, tokenId) } +// GetTokensByOwner is a free data retrieval call binding the contract method 0x40398d67. +// +// Solidity: function getTokensByOwner(address owner_) view returns(uint256[] tokens_) +func (_ERC721Mock *ERC721MockCaller) GetTokensByOwner(opts *bind.CallOpts, owner_ common.Address) ([]*big.Int, error) { + var out []interface{} + err := _ERC721Mock.contract.Call(opts, &out, "getTokensByOwner", owner_) + + if err != nil { + return *new([]*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new([]*big.Int)).(*[]*big.Int) + + return out0, err + +} + +// GetTokensByOwner is a free data retrieval call binding the contract method 0x40398d67. +// +// Solidity: function getTokensByOwner(address owner_) view returns(uint256[] tokens_) +func (_ERC721Mock *ERC721MockSession) GetTokensByOwner(owner_ common.Address) ([]*big.Int, error) { + return _ERC721Mock.Contract.GetTokensByOwner(&_ERC721Mock.CallOpts, owner_) +} + +// GetTokensByOwner is a free data retrieval call binding the contract method 0x40398d67. +// +// Solidity: function getTokensByOwner(address owner_) view returns(uint256[] tokens_) +func (_ERC721Mock *ERC721MockCallerSession) GetTokensByOwner(owner_ common.Address) ([]*big.Int, error) { + return _ERC721Mock.Contract.GetTokensByOwner(&_ERC721Mock.CallOpts, owner_) +} + // IsApprovedForAll is a free data retrieval call binding the contract method 0xe985e9c5. // // Solidity: function isApprovedForAll(address owner, address operator) view returns(bool) diff --git a/go.mod b/go.mod index bdffa8b..5329e78 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,10 @@ require ( github.com/go-chi/chi v4.1.2+incompatible github.com/go-ozzo/ozzo-validation/v4 v4.2.1 github.com/google/uuid v1.4.0 + github.com/iden3/go-iden3-crypto v0.0.15 + github.com/iden3/go-rapidsnark/prover v0.0.10 + github.com/iden3/go-rapidsnark/witness/v2 v2.0.0 + github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e github.com/pkg/errors v0.9.1 github.com/rubenv/sql-migrate v1.6.1 gitlab.com/distributed_lab/ape v1.7.1 @@ -25,6 +29,7 @@ require ( github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect github.com/certifi/gocertifi v0.0.0-20200211180108-c7c1fbc02894 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/dchest/blake512 v1.0.0 // indirect github.com/deckarep/golang-set v1.8.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect @@ -40,6 +45,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect github.com/holiman/uint256 v1.2.0 // indirect + github.com/iden3/go-rapidsnark/types v0.0.3 // indirect github.com/jmoiron/sqlx v1.3.5 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect @@ -63,6 +69,7 @@ require ( github.com/spf13/viper v1.18.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect + github.com/tetratelabs/wazero v1.1.0 // indirect github.com/tklauser/go-sysconf v0.3.11 // indirect github.com/tklauser/numcpus v0.6.0 // indirect gitlab.com/distributed_lab/figure/v3 v3.1.4 // indirect diff --git a/go.sum b/go.sum index 0729799..9053f55 100644 --- a/go.sum +++ b/go.sum @@ -1275,6 +1275,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dchest/blake512 v1.0.0 h1:oDFEQFIqFSeuA34xLtXZ/rWxCXdSjirjzPhey5EUvmA= +github.com/dchest/blake512 v1.0.0/go.mod h1:FV1x7xPPLWukZlpDpWQ88rF/SFwZ5qbskrzhLMB92JI= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= @@ -1612,6 +1614,16 @@ github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3 github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/iden3/go-iden3-crypto v0.0.15 h1:4MJYlrot1l31Fzlo2sF56u7EVFeHHJkxGXXZCtESgK4= +github.com/iden3/go-iden3-crypto v0.0.15/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E= +github.com/iden3/go-rapidsnark/prover v0.0.10 h1:NvOfRPpex/k646UsqOcUy7a7uVl17t4ok9kWvpQg4+k= +github.com/iden3/go-rapidsnark/prover v0.0.10/go.mod h1:wgDsmKOGCuWGtgVtuW9ARWNguNr4NJAIyg2G7+uTax0= +github.com/iden3/go-rapidsnark/types v0.0.3 h1:f0s1Qdut1qHe1O67+m+xUVRBPwSXnq5j0xSrBi0jqM4= +github.com/iden3/go-rapidsnark/types v0.0.3/go.mod h1:ApgcaUxKIgSRA6fAeFxK7p+lgXXfG4oA2HN5DhFlfF4= +github.com/iden3/go-rapidsnark/witness/v2 v2.0.0 h1:mkY6VDfwKVJc83QGKmwVXY2LYepidPrFAxskrjr8UCs= +github.com/iden3/go-rapidsnark/witness/v2 v2.0.0/go.mod h1:3JRjqUfW1hgI9hzLDO0v8z/DUkR0ZUehhYLlnIfRxnA= +github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e h1:WeiFCrpj5pLRtSA4Mg03yTrSZhHHqN/k5b6bwxd9/tY= +github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e/go.mod h1:UEBifEzw62T6VzIHJeHuUgeLg2U/J9ttf7hOwQEqnYk= github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/flux v0.65.1/go.mod h1:J754/zds0vvpfwuq7Gc2wRdVwEodfpCFM7mYlOw2LqY= @@ -1699,6 +1711,7 @@ github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o= github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk= github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -1996,6 +2009,8 @@ github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502/go.mod h1:p9lPs github.com/tdewolff/minify/v2 v2.12.4/go.mod h1:h+SRvSIX3kwgwTFOpSckvSxgax3uy8kZTSF1Ojrr3bk= github.com/tdewolff/parse/v2 v2.6.4/go.mod h1:woz0cgbLwFdtbjJu8PIKxhW05KplTFQkOdX78o+Jgrs= github.com/tdewolff/test v1.0.7/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= +github.com/tetratelabs/wazero v1.1.0 h1:EByoAhC+QcYpwSZJSs/aV0uokxPwBgKxfiokSUwAknQ= +github.com/tetratelabs/wazero v1.1.0/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= diff --git a/internal/config/circom.go b/internal/config/circom.go new file mode 100644 index 0000000..40327fd --- /dev/null +++ b/internal/config/circom.go @@ -0,0 +1,26 @@ +package config + +import ( + "gitlab.com/distributed_lab/figure" + "gitlab.com/distributed_lab/kit/kv" + "gitlab.com/distributed_lab/logan/v3/errors" +) + +type CircomConfig struct { + PathToCircuits string `fig:"path_to_circuits,required"` //nolint +} + +func (c *config) Circom() *CircomConfig { + return c.circom.Do(func() interface{} { + config := CircomConfig{} + err := figure. + Out(&config). + From(kv.MustGetStringMap(c.getter, "circom")). + Please() + if err != nil { + panic(errors.Wrap(err, "failed to figure out ethereum config")) + } + + return &config + }).(*CircomConfig) +} diff --git a/internal/config/ethclient.go b/internal/config/ethclient.go index d28c611..92bda38 100644 --- a/internal/config/ethclient.go +++ b/internal/config/ethclient.go @@ -3,6 +3,7 @@ package config import ( "crypto/ecdsa" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "gitlab.com/distributed_lab/figure" @@ -11,13 +12,17 @@ import ( ) type EthClientConfig struct { - EthClient *ethclient.Client - PrivateKey *ecdsa.PrivateKey + EthClient *ethclient.Client + PrivateKey *ecdsa.PrivateKey + AuthStorageContract common.Address + ChatContract common.Address } type ethClientConfigRaw struct { - RpcURL string `fig:"rpc_url,required"` //nolint - PrivateKey string `fig:"private_key,required"` + RpcURL string `fig:"rpc_url,required"` //nolint + PrivateKey string `fig:"private_key,required"` + AuthStorageContract string `fig:"auth_storage_contract,required"` + ChatContract string `fig:"chat_contract,required"` } func (c *config) EthClient() *EthClientConfig { @@ -42,8 +47,10 @@ func (c *config) EthClient() *EthClientConfig { } return &EthClientConfig{ - EthClient: ethClient, - PrivateKey: privateKey, + EthClient: ethClient, + PrivateKey: privateKey, + AuthStorageContract: common.HexToAddress(configRaw.AuthStorageContract), + ChatContract: common.HexToAddress(configRaw.ChatContract), } }).(*EthClientConfig) } diff --git a/internal/config/main.go b/internal/config/main.go index 8a74f91..c2b5afa 100644 --- a/internal/config/main.go +++ b/internal/config/main.go @@ -16,6 +16,7 @@ type Config interface { EthClient() *EthClientConfig API() *APIConfig + Circom() *CircomConfig } type config struct { @@ -27,6 +28,7 @@ type config struct { ethClient comfig.Once api comfig.Once + circom comfig.Once } func New(getter kv.Getter) Config { diff --git a/internal/service/api/handlers/register_in_community.go b/internal/service/api/handlers/register_in_community.go new file mode 100644 index 0000000..09ec569 --- /dev/null +++ b/internal/service/api/handlers/register_in_community.go @@ -0,0 +1,40 @@ +package handlers + +import ( + "net/http" + + "gitlab.com/distributed_lab/ape" + "gitlab.com/distributed_lab/ape/problems" + + "github.com/black-pepper-team/community-indexer/internal/service/api/requests" + "github.com/black-pepper-team/community-indexer/internal/service/api/responses" +) + +func RegisterInCommunity(w http.ResponseWriter, r *http.Request) { + if MockAPI(r) { + ape.Render(w, responses.MockedCreateCommunity()) + return + } + + req, err := requests.NewRegisterInCommunity(r) + if err != nil { + Log(r).WithField("reason", err).Debug("Bad request") + ape.RenderErr(w, problems.BadRequest(err)...) + return + } + + registerRequest, err := Core(r).RegisterInCommunity( + req.BJJPublicKey, + req.NFTOwner, + req.ContractId, + req.NFTID, + ) + if err != nil { + Log(r).WithError(err). + Error("Failed register in community") + ape.RenderErr(w, problems.InternalError()) + return + } + + ape.Render(w, responses.NewRegisterInCommunity(registerRequest)) +} diff --git a/internal/service/api/requests/register_in_community.go b/internal/service/api/requests/register_in_community.go new file mode 100644 index 0000000..fd79ccd --- /dev/null +++ b/internal/service/api/requests/register_in_community.go @@ -0,0 +1,80 @@ +package requests + +import ( + "encoding/json" + "math/big" + "net/http" + + "github.com/ethereum/go-ethereum/common" + validation "github.com/go-ozzo/ozzo-validation/v4" + "github.com/iden3/go-iden3-crypto/babyjub" + "gitlab.com/distributed_lab/logan/v3/errors" +) + +type registerInCommunityRequest struct { + NFTID big.Int `json:"nft_id"` + NFTOwner string `json:"nft_owner"` + ContractId string `json:"contract_id"` + BJJPublicKey string `json:"bjj_public_key"` +} + +type RegisterInCommunityRequest struct { + NFTID big.Int + NFTOwner common.Address + ContractId common.Address + BJJPublicKey babyjub.PublicKey +} + +func NewRegisterInCommunity(r *http.Request) (*RegisterInCommunityRequest, error) { + var requestBody registerInCommunityRequest + + if err := json.NewDecoder(r.Body).Decode(&requestBody); err != nil { + return nil, errors.Wrap(err, "failed to decode json request body") + } + + if err := requestBody.validate(); err != nil { + return nil, err + } + + return requestBody.parse(), nil +} + +// nolint +func (r *registerInCommunityRequest) validate() error { + return validation.Errors{ + "body/nft_owner": validation.Validate( + r.NFTOwner, validation.Required, validation.By(MustBeValidAddress), + ), + "body/contract_id": validation.Validate( + r.ContractId, validation.Required, validation.By(MustBeValidAddress), + ), + "body/bjj_public_key": validation.Validate( + r.BJJPublicKey, validation.Required, validation.By(MustBeValidBJJPublicKey), + ), + }.Filter() +} + +func (r *registerInCommunityRequest) parse() *RegisterInCommunityRequest { + var bjjPublicKey babyjub.PublicKey + (&bjjPublicKey).UnmarshalText([]byte(r.BJJPublicKey)) + + return &RegisterInCommunityRequest{ + NFTID: r.NFTID, + NFTOwner: common.HexToAddress(r.NFTOwner), + ContractId: common.HexToAddress(r.ContractId), + BJJPublicKey: bjjPublicKey, + } +} + +func MustBeValidBJJPublicKey(value interface{}) error { + valueStr, ok := value.(string) + if !ok { + return errors.New("invalid BJJ public key") + } + + if err := new(babyjub.PublicKey).UnmarshalText([]byte(valueStr)); err != nil { + return errors.Wrap(err, "invalid BJJ public key") + } + + return nil +} diff --git a/internal/service/api/responses/register_in_community.go b/internal/service/api/responses/register_in_community.go new file mode 100644 index 0000000..f979b9c --- /dev/null +++ b/internal/service/api/responses/register_in_community.go @@ -0,0 +1,19 @@ +package responses + +import ( + "github.com/google/uuid" + + "github.com/black-pepper-team/community-indexer/internal/service/core" +) + +type RegisterRequest struct { + Id uuid.UUID `json:"id"` + Status string `json:"status"` +} + +func NewRegisterInCommunity(registerRequest *core.RegisterRequest) *RegisterRequest { + return &RegisterRequest{ + Id: registerRequest.Id, + Status: string(registerRequest.Status), + } +} diff --git a/internal/service/api/router.go b/internal/service/api/router.go index 22cde59..0078ce7 100644 --- a/internal/service/api/router.go +++ b/internal/service/api/router.go @@ -25,6 +25,7 @@ func (s *service) router() chi.Router { r.Post("/", handlers.CreateCommunity) r.Get("/list", handlers.CommunityList) r.Post("/import", handlers.ImportCommunity) + r.Post("/register", handlers.RegisterInCommunity) }) }) diff --git a/internal/service/core/handlers.go b/internal/service/core/handlers.go new file mode 100644 index 0000000..3200a11 --- /dev/null +++ b/internal/service/core/handlers.go @@ -0,0 +1,298 @@ +package core + +import ( + "encoding/json" + "errors" + "fmt" + "math/big" + "strconv" + "time" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/google/uuid" + "github.com/iden3/go-iden3-crypto/babyjub" + "github.com/iden3/go-rapidsnark/prover" + "github.com/iden3/go-rapidsnark/witness/v2" + "github.com/iden3/go-rapidsnark/witness/wazero" + + "github.com/black-pepper-team/community-indexer/contracts" + "github.com/black-pepper-team/community-indexer/internal/data" +) + +var ( + ErrContractNotFound = fmt.Errorf("contract not found") + ErrCreateWitnessCalculator = errors.New("failed to create witness calculator") +) + +func (c *Core) GetCommunitiesList() ([]data.Community, error) { + communities, err := c.db.New().CommunitiesQ().Select() + if err != nil { + c.log.WithError(err).Error("Failed to get communities list") + return nil, err + } + + return communities, nil +} + +func (c *Core) GetCommunityById(communityId uuid.UUID) (*data.Community, error) { + community, err := c.db.New().CommunitiesQ().WhereID(communityId).Get() + if err != nil { + c.log.WithError(err).Error("Failed to get community by ID") + return nil, err + } + + if community == nil { + return nil, nil + } + + return community, nil +} + +func (c *Core) CreateCommunity( + collectionName string, + collectionSymbol string, +) (*data.Community, error) { + var err error + var tx *types.Transaction + var address common.Address + err = c.retryChainCall(c.ctx, func(signer *bind.TransactOpts) error { + signer, err := c.newSigner(c.ctx) + if err != nil { + return fmt.Errorf("failed to get new signer: %w", err) + } + + address, tx, _, err = contracts.DeployERC721Mock(signer, c.ethClient, collectionName, collectionSymbol) + if err != nil { + return fmt.Errorf("failed to deploy new community: %w", err) + } + + return nil + }) + if err != nil { + return nil, fmt.Errorf("failed to call retryChainCall: %w", err) + } + + communityId, err := uuid.NewRandom() + if err != nil { + return nil, fmt.Errorf("failed to generate new UUID: %w", err) + } + + newCommunity := data.Community{ + ID: communityId, + Status: data.Deploying, + Name: collectionName, + Symbol: collectionSymbol, + ContractAddress: address, + OwnerAddress: c.address, + } + + if err = c.db.New().CommunitiesQ().Insert(&newCommunity); err != nil { + return nil, fmt.Errorf("failed to insert new community: %w", err) + } + + go func() { + nextStatus := data.Ready + + if _, err := c.waitMined(c.ctx, tx); err != nil { + c.log. + WithField("tx-hash", tx.Hash().Hex()). + WithField("reason", err). + Errorf("failed to wait tx mined") + + nextStatus = data.FailedToDeploy + } + + newCommunity.Status = nextStatus + if newErr := c.db.New().CommunitiesQ().Update(&newCommunity); newErr != nil { + c.log. + WithField("reason", newErr.Error()). + Errorf("failed to update the community status to failed community") + } + + return + }() + + return &newCommunity, nil +} + +func (c *Core) ImportCommunity(contractAddress common.Address) (*data.Community, error) { + existedCommunity, err := c.db.CommunitiesQ().WhereContractAddress(contractAddress).Get() + if err != nil { + return nil, fmt.Errorf("failed to get community by contract address: %w", err) + } + + if existedCommunity != nil { + return existedCommunity, nil + } + + collectionContract, err := contracts.NewERC721Mock(contractAddress, c.ethClient) + if err != nil { + return nil, fmt.Errorf("failed to get ERC721 contract: %w", err) + } + + collectionName, err := collectionContract.Name(nil) + if err != nil { + // Assume that the contract doesn't exists + return nil, ErrContractNotFound + } + + collectionSymbol, err := collectionContract.Symbol(nil) + if err != nil { + // Assume that the contract doesn't exists + return nil, ErrContractNotFound + } + + contractOwner, err := collectionContract.Owner(nil) + if err != nil { + // Assume that the contract doesn't exists + return nil, ErrContractNotFound + } + + communityId, err := uuid.NewRandom() + if err != nil { + return nil, fmt.Errorf("failed to generate new UUID: %w", err) + } + + newCommunity := &data.Community{ + ID: communityId, + Status: data.Ready, + Name: collectionName, + Symbol: collectionSymbol, + ContractAddress: contractAddress, + OwnerAddress: contractOwner, + } + + if err = c.db.New().CommunitiesQ().Insert(newCommunity); err != nil { + return nil, fmt.Errorf("failed to insert new community: %w", err) + } + + return newCommunity, nil +} + +func (c *Core) RegisterInCommunity( + bjjPublicKey babyjub.PublicKey, + nftOwner common.Address, + contractId common.Address, + nftId big.Int, +) (*RegisterRequest, error) { + wtnsCalculator, err := witness.NewCalculator( + c.circuits[VerifiableCommitmentCircuitName][WASM], + witness.WithWasmEngine(wazero.NewCircom2WZWitnessCalculator), + ) + if err != nil { + return nil, ErrCreateWitnessCalculator + } + + timestamp := time.Now().Add(96 * time.Hour) + deadline := timestamp.Add(300 * time.Second).Unix() + transitionInputs := VarifiableCommitmentInputs{ + ContractId: contractId.String(), + NftId: nftId.String(), + NftOwner: nftOwner.String(), + Deadline: strconv.FormatInt(deadline, 10), + Timestamp: strconv.FormatInt(timestamp.Unix(), 10), + BabyJubJubPKAx: bjjPublicKey.X.String(), + BabyJubJubPKAy: bjjPublicKey.Y.String(), + } + + transitionInputsRaw, err := json.Marshal(transitionInputs) + if err != nil { + return nil, fmt.Errorf("failed to marshal transition inputs: %w", err) + } + + parsedInputs, err := witness.ParseInputs(transitionInputsRaw) + if err != nil { + return nil, fmt.Errorf("failed to parse witness inputs: %w", err) + } + + wtnsBytes, err := wtnsCalculator.CalculateWTNSBin(parsedInputs, true) + if err != nil { + return nil, fmt.Errorf("failed to calculate witnesses: %w", err) + } + + rapidProof, err := prover.Groth16Prover(c.circuits[VerifiableCommitmentCircuitName][ZKEY], wtnsBytes) + if err != nil { + return nil, fmt.Errorf("failed to generate prov with groth16: %w", err) + } + + contractZKP, err := parseZKPArgs(&ZKProof{ + A: rapidProof.Proof.A, + B: rapidProof.Proof.B, + C: rapidProof.Proof.C, + Protocol: rapidProof.Proof.Protocol, + }) + if err != nil { + return nil, fmt.Errorf("failed to parse ZKProof to contract readable: %w", err) + } + + credentialIdBigInt, ok := new(big.Int).SetString(rapidProof.PubSignals[0], 10) + if !ok { + return nil, errors.New("failed to parse credential ID") + } + + var tx *types.Transaction + err = c.retryChainCall(c.ctx, func(signer *bind.TransactOpts) error { + signer, err := c.newSigner(c.ctx) + if err != nil { + return fmt.Errorf("failed to get new signer: %w", err) + } + + tx, err = c.authStorageContract.Register( + signer, + contractId, + &nftId, + nftOwner, + [32]byte(credentialIdBigInt.Bytes()), + big.NewInt(deadline), + *contractZKP, + ) + if err != nil { + return fmt.Errorf("failed to call Register: %w", err) + } + + return nil + }) + if err != nil { + return nil, fmt.Errorf("failed to call retryChainCall: %w", err) + } + + requestId := uuid.New() + registerRequest := RegisterRequest{ + Id: requestId, + Status: Processing, + } + + c.registerRequests[requestId] = registerRequest + + go func() { + nextStatus := Registered + + if _, err := c.waitMined(c.ctx, tx); err != nil { + c.log. + WithField("tx-hash", tx.Hash().Hex()). + WithField("reason", err). + Errorf("failed to wait tx mined") + + nextStatus = FailedRegister + } + + registerRequest.Status = nextStatus + c.registerRequests[requestId] = registerRequest + + return + }() + + return ®isterRequest, nil +} + +type VarifiableCommitmentInputs struct { + ContractId string `json:"contractId"` + NftId string `json:"nftId"` + NftOwner string `json:"nftOwner"` + Deadline string `json:"deadline"` + BabyJubJubPKAx string `json:"babyJubJubPK_Ax"` + BabyJubJubPKAy string `json:"babyJubJubPK_Ay"` + Timestamp string `json:"timestamp"` +} diff --git a/internal/service/core/main.go b/internal/service/core/main.go index e2bdab0..699a4f6 100644 --- a/internal/service/core/main.go +++ b/internal/service/core/main.go @@ -6,9 +6,7 @@ import ( "fmt" "math/big" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/google/uuid" @@ -20,8 +18,9 @@ import ( "github.com/black-pepper-team/community-indexer/internal/data/postgres" ) -var ( - ErrContractNotFound = fmt.Errorf("contract not found") +const ( + VerifiableCommitmentCircuitName = "VerifiableCommitment" + PostMessageCircuitName = "PostMessage" ) type Core struct { @@ -34,6 +33,12 @@ type Core struct { privateKey *ecdsa.PrivateKey chainID *big.Int address common.Address + + authStorageContract *contracts.AuthenticationStorage + chatContract *contracts.Chat + registerRequests map[uuid.UUID]RegisterRequest + + circuits Circuits } func New(ctx context.Context, cfg config.Config) (*Core, error) { @@ -42,158 +47,60 @@ func New(ctx context.Context, cfg config.Config) (*Core, error) { return nil, fmt.Errorf("failed to get chainID: %w", err) } - return &Core{ - log: cfg.Log(), - ctx: ctx, - db: postgres.NewMasterQ(cfg.DB()), - ethClient: cfg.EthClient().EthClient, - privateKey: cfg.EthClient().PrivateKey, - address: crypto.PubkeyToAddress(cfg.EthClient().PrivateKey.PublicKey), - chainID: chainID, - }, nil -} - -func (c *Core) GetCommunitiesList() ([]data.Community, error) { - communities, err := c.db.New().CommunitiesQ().Select() + circuits, err := readCircuits(cfg.Circom().PathToCircuits) if err != nil { - c.log.WithError(err).Error("Failed to get communities list") - return nil, err + return nil, fmt.Errorf("failed to read state transition circuits: %w", err) } - return communities, nil -} + authStorageContract, err := contracts.NewAuthenticationStorage( + cfg.EthClient().AuthStorageContract, + cfg.EthClient().EthClient, + ) -func (c *Core) GetCommunityById(communityId uuid.UUID) (*data.Community, error) { - community, err := c.db.New().CommunitiesQ().WhereID(communityId).Get() - if err != nil { - c.log.WithError(err).Error("Failed to get community by ID") - return nil, err - } - - if community == nil { - return nil, nil - } + chatContract, err := contracts.NewChat( + cfg.EthClient().ChatContract, + cfg.EthClient().EthClient, + ) - return community, nil + return &Core{ + log: cfg.Log(), + ctx: ctx, + db: postgres.NewMasterQ(cfg.DB()), + ethClient: cfg.EthClient().EthClient, + privateKey: cfg.EthClient().PrivateKey, + address: crypto.PubkeyToAddress(cfg.EthClient().PrivateKey.PublicKey), + chainID: chainID, + circuits: circuits, + chatContract: chatContract, + authStorageContract: authStorageContract, + }, nil } -func (c *Core) CreateCommunity( - collectionName string, - collectionSymbol string, -) (*data.Community, error) { +func readCircuits(pathToCircuits string) (Circuits, error) { var err error - var tx *types.Transaction - var address common.Address - err = c.retryChainCall(c.ctx, func(signer *bind.TransactOpts) error { - signer, err := c.newSigner(c.ctx) - if err != nil { - return fmt.Errorf("failed to get new signer: %w", err) - } - - address, tx, _, err = contracts.DeployERC721Mock(signer, c.ethClient, collectionName, collectionSymbol) - if err != nil { - return fmt.Errorf("failed to deploy new community: %w", err) - } - - return nil - }) - if err != nil { - return nil, fmt.Errorf("failed to call retryChainCall: %w", err) - } + circuits := make(Circuits) - communityId, err := uuid.NewRandom() + circuits[VerifiableCommitmentCircuitName] = make(map[circuitKey][]byte) + circuits[VerifiableCommitmentCircuitName][ZKEY], err = ReadFileByPath(pathToCircuits, fmt.Sprintf("%s.zkey", VerifiableCommitmentCircuitName)) if err != nil { - return nil, fmt.Errorf("failed to generate new UUID: %w", err) - } - - newCommunity := data.Community{ - ID: communityId, - Status: data.Deploying, - Name: collectionName, - Symbol: collectionSymbol, - ContractAddress: address, - OwnerAddress: c.address, - } - - if err = c.db.New().CommunitiesQ().Insert(&newCommunity); err != nil { - return nil, fmt.Errorf("failed to insert new community: %w", err) + return nil, fmt.Errorf("failed to read state transition circuit final: %w", err) } - go func() { - nextStatus := data.Ready - - if _, err := c.waitMined(c.ctx, tx); err != nil { - c.log. - WithField("tx-hash", tx.Hash().Hex()). - WithField("reason", err). - Errorf("failed to wait tx mined") - - nextStatus = data.FailedToDeploy - } - - newCommunity.Status = nextStatus - if newErr := c.db.New().CommunitiesQ().Update(&newCommunity); newErr != nil { - c.log. - WithField("reason", newErr.Error()). - Errorf("failed to update the community status to failed community") - } - - return - }() - - return &newCommunity, nil -} - -func (c *Core) ImportCommunity(contractAddress common.Address) (*data.Community, error) { - existedCommunity, err := c.db.CommunitiesQ().WhereContractAddress(contractAddress).Get() - if err != nil { - return nil, fmt.Errorf("failed to get community by contract address: %w", err) - } - - if existedCommunity != nil { - return existedCommunity, nil - } - - collectionContract, err := contracts.NewERC721Mock(contractAddress, c.ethClient) + circuits[PostMessageCircuitName] = make(map[circuitKey][]byte) + circuits[PostMessageCircuitName][ZKEY], err = ReadFileByPath(pathToCircuits, fmt.Sprintf("%s.zkey", PostMessageCircuitName)) if err != nil { - return nil, fmt.Errorf("failed to get ERC721 contract: %w", err) + return nil, fmt.Errorf("failed to read state transition circuit wasm: %w", err) } - collectionName, err := collectionContract.Name(nil) + circuits[VerifiableCommitmentCircuitName][WASM], err = ReadFileByPath(pathToCircuits, fmt.Sprintf("%s.wasm", VerifiableCommitmentCircuitName)) if err != nil { - // Assume that the contract doesn't exists - return nil, ErrContractNotFound + return nil, fmt.Errorf("failed to read state transition circuit final: %w", err) } - collectionSymbol, err := collectionContract.Symbol(nil) + circuits[PostMessageCircuitName][WASM], err = ReadFileByPath(pathToCircuits, fmt.Sprintf("%s.wasm", PostMessageCircuitName)) if err != nil { - // Assume that the contract doesn't exists - return nil, ErrContractNotFound - } - - contractOwner, err := collectionContract.Owner(nil) - if err != nil { - // Assume that the contract doesn't exists - return nil, ErrContractNotFound - } - - communityId, err := uuid.NewRandom() - if err != nil { - return nil, fmt.Errorf("failed to generate new UUID: %w", err) - } - - newCommunity := &data.Community{ - ID: communityId, - Status: data.Ready, - Name: collectionName, - Symbol: collectionSymbol, - ContractAddress: contractAddress, - OwnerAddress: contractOwner, - } - - if err = c.db.New().CommunitiesQ().Insert(newCommunity); err != nil { - return nil, fmt.Errorf("failed to insert new community: %w", err) + return nil, fmt.Errorf("failed to read state transition circuit wasm: %w", err) } - return newCommunity, nil + return circuits, nil } diff --git a/internal/service/core/types.go b/internal/service/core/types.go new file mode 100644 index 0000000..18cbd6f --- /dev/null +++ b/internal/service/core/types.go @@ -0,0 +1,109 @@ +package core + +import ( + "bytes" + "fmt" + "math/big" + "strings" + + "github.com/google/uuid" + + "github.com/black-pepper-team/community-indexer/contracts" +) + +type RegisterStatus string + +const ( + Registered RegisterStatus = "registered" + Processing RegisterStatus = "processing" + FailedRegister RegisterStatus = "failed-register" +) + +type RegisterRequest struct { + Id uuid.UUID `json:"id"` + Status RegisterStatus `json:"status"` +} + +// ZKProof is structure that represents SnarkJS library result of proof generation +type ZKProof struct { + A []string `json:"pi_a"` + B [][]string `json:"pi_b"` + C []string `json:"pi_c"` + Protocol string `json:"protocol"` +} + +// FullProof is ZKP proof with public signals +type FullProof struct { + Proof *ZKProof `json:"proof"` + PubSignals []string `json:"pub_signals"` +} + +func parseZKPArgs(zkp *ZKProof) (*contracts.VerifierHelperProofPoints, error) { + a, b, c, err := zkp.ProofToBigInts() + if err != nil { + return nil, fmt.Errorf("failed to parse ZKProof to big ints: %w", err) + } + + // Here we swap array's elements to be + // compatible with verifier contract + return &contracts.VerifierHelperProofPoints{ + A: [2]*big.Int{a[0], a[1]}, + B: [2][2]*big.Int{ + {b[0][1], b[0][0]}, + {b[1][1], b[1][0]}, + }, + C: [2]*big.Int{c[0], c[1]}, + }, nil +} + +func (p *ZKProof) ProofToBigInts() (a []*big.Int, b [][]*big.Int, c []*big.Int, err error) { + a, err = arrayStringToBigInt(p.A) + if err != nil { + return nil, nil, nil, err + } + + b = make([][]*big.Int, len(p.B)) + for i, v := range p.B { + b[i], err = arrayStringToBigInt(v) + if err != nil { + return nil, nil, nil, err + } + } + + c, err = arrayStringToBigInt(p.C) + if err != nil { + return nil, nil, nil, err + } + + return a, b, c, nil +} + +func arrayStringToBigInt(str []string) ([]*big.Int, error) { + var result []*big.Int + + for i := 0; i < len(str); i++ { + si, err := stringToBigInt(str[i]) + if err != nil { + return nil, err + } + + result = append(result, si) + } + + return result, nil +} + +func stringToBigInt(str string) (*big.Int, error) { + base := 10 + if bytes.HasPrefix([]byte(str), []byte("0x")) { + base = 16 + str = strings.TrimPrefix(str, "0x") + } + + n, ok := new(big.Int).SetString(str, base) + if !ok { + return nil, fmt.Errorf("can not parse string to *big.Int: %s", str) + } + + return n, nil +} diff --git a/internal/service/core/utils.go b/internal/service/core/utils.go new file mode 100644 index 0000000..b7afa33 --- /dev/null +++ b/internal/service/core/utils.go @@ -0,0 +1,32 @@ +package core + +import ( + "fmt" + "io" + "os" + "path/filepath" +) + +type circuitKey int + +const ( + WASM circuitKey = iota + ZKEY +) + +type Circuits map[string]map[circuitKey][]byte + +func ReadFileByPath(basePath string, fileName string) ([]byte, error) { + path := filepath.Join(basePath, fileName) + f, err := os.Open(filepath.Clean(path)) + if err != nil { + return nil, fmt.Errorf("failed to open file '%s' by path '%s': %w", fileName, path, err) + } + + data, err := io.ReadAll(f) + if err != nil { + return nil, fmt.Errorf("failed to read file '%s' by path '%s': %w", fileName, path, err) + } + + return data, nil +}