From 7d5d3679bde482fdffc9843731d995620d4e3fad Mon Sep 17 00:00:00 2001 From: BenMemi Date: Sat, 8 Oct 2022 22:08:45 -0500 Subject: [PATCH] done --- .gitignore | 2 + .vscode/settings.json | 3 + DataTypes.sol | 380 ++++++++++++++++++++++++++++++ Dockerfile | 10 + Makefile | 45 ++++ abi.json | 1 + abi.sh | 4 + database/database.go | 67 ++++++ events.sol | 522 ++++++++++++++++++++++++++++++++++++++++++ go.mod | 41 ++++ go.sum | 261 +++++++++++++++++++++ main.go | 219 ++++++++++++++++++ main_test.go | 27 +++ 13 files changed, 1582 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 DataTypes.sol create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 abi.json create mode 100644 abi.sh create mode 100644 database/database.go create mode 100644 events.sol create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go create mode 100644 main_test.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..30bd623 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env + diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..13ee2b0 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "nuxt.isNuxtApp": false +} \ No newline at end of file diff --git a/DataTypes.sol b/DataTypes.sol new file mode 100644 index 0000000..2500142 --- /dev/null +++ b/DataTypes.sol @@ -0,0 +1,380 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.8.17; + +/** + * @title DataTypes + * @author Lens Protocol + * + * @notice A standard library of data types used throughout the Lens Protocol. + */ +library DataTypes { + /** + * @notice An enum containing the different states the protocol can be in, limiting certain actions. + * + * @param Unpaused The fully unpaused state. + * @param PublishingPaused The state where only publication creation functions are paused. + * @param Paused The fully paused state. + */ + enum ProtocolState { + Unpaused, + PublishingPaused, + Paused + } + + /** + * @notice An enum specifically used in a helper function to easily retrieve the publication type for integrations. + * + * @param Post A standard post, having a URI, a collect module but no pointer to another publication. + * @param Comment A comment, having a URI, a collect module and a pointer to another publication. + * @param Mirror A mirror, having a pointer to another publication, but no URI or collect module. + * @param Nonexistent An indicator showing the queried publication does not exist. + */ + enum PubType { + Post, + Comment, + Mirror, + Nonexistent + } + + /** + * @notice A struct containing the necessary information to reconstruct an EIP-712 typed data signature. + * + * @param v The signature's recovery parameter. + * @param r The signature's r parameter. + * @param s The signature's s parameter + * @param deadline The signature's deadline + */ + struct EIP712Signature { + uint8 v; + bytes32 r; + bytes32 s; + uint256 deadline; + } + + /** + * @notice A struct containing profile data. + * + * @param pubCount The number of publications made to this profile. + * @param followModule The address of the current follow module in use by this profile, can be empty. + * @param followNFT The address of the followNFT associated with this profile, can be empty.. + * @param handle The profile's associated handle. + * @param imageURI The URI to be used for the profile's image. + * @param followNFTURI The URI to be used for the follow NFT. + */ + struct ProfileStruct { + uint256 pubCount; + address followModule; + address followNFT; + string handle; + string imageURI; + string followNFTURI; + } + + /** + * @notice A struct containing data associated with each new publication. + * + * @param profileIdPointed The profile token ID this publication points to, for mirrors and comments. + * @param pubIdPointed The publication ID this publication points to, for mirrors and comments. + * @param contentURI The URI associated with this publication. + * @param referenceModule The address of the current reference module in use by this profile, can be empty. + * @param collectModule The address of the collect module associated with this publication, this exists for all publication. + * @param collectNFT The address of the collectNFT associated with this publication, if any. + */ + struct PublicationStruct { + uint256 profileIdPointed; + uint256 pubIdPointed; + string contentURI; + address referenceModule; + address collectModule; + address collectNFT; + } + + /** + * @notice A struct containing the parameters required for the `createProfile()` function. + * + * @param to The address receiving the profile. + * @param handle The handle to set for the profile, must be unique and non-empty. + * @param imageURI The URI to set for the profile image. + * @param followModule The follow module to use, can be the zero address. + * @param followModuleInitData The follow module initialization data, if any. + * @param followNFTURI The URI to use for the follow NFT. + */ + struct CreateProfileData { + address to; + string handle; + string imageURI; + address followModule; + bytes followModuleInitData; + string followNFTURI; + } + + /** + * @notice A struct containing the parameters required for the `setDefaultProfileWithSig()` function. Parameters are + * the same as the regular `setDefaultProfile()` function, with an added EIP712Signature. + * + * @param wallet The address of the wallet setting the default profile. + * @param profileId The token ID of the profile which will be set as default, or zero. + * @param sig The EIP712Signature struct containing the profile owner's signature. + */ + struct SetDefaultProfileWithSigData { + address wallet; + uint256 profileId; + EIP712Signature sig; + } + + /** + * @notice A struct containing the parameters required for the `setFollowModuleWithSig()` function. Parameters are + * the same as the regular `setFollowModule()` function, with an added EIP712Signature. + * + * @param profileId The token ID of the profile to change the followModule for. + * @param followModule The followModule to set for the given profile, must be whitelisted. + * @param followModuleInitData The data to be passed to the followModule for initialization. + * @param sig The EIP712Signature struct containing the profile owner's signature. + */ + struct SetFollowModuleWithSigData { + uint256 profileId; + address followModule; + bytes followModuleInitData; + EIP712Signature sig; + } + + /** + * @notice A struct containing the parameters required for the `setDispatcherWithSig()` function. Parameters are the same + * as the regular `setDispatcher()` function, with an added EIP712Signature. + * + * @param profileId The token ID of the profile to set the dispatcher for. + * @param dispatcher The dispatcher address to set for the profile. + * @param sig The EIP712Signature struct containing the profile owner's signature. + */ + struct SetDispatcherWithSigData { + uint256 profileId; + address dispatcher; + EIP712Signature sig; + } + + /** + * @notice A struct containing the parameters required for the `setProfileImageURIWithSig()` function. Parameters are the same + * as the regular `setProfileImageURI()` function, with an added EIP712Signature. + * + * @param profileId The token ID of the profile to set the URI for. + * @param imageURI The URI to set for the given profile image. + * @param sig The EIP712Signature struct containing the profile owner's signature. + */ + struct SetProfileImageURIWithSigData { + uint256 profileId; + string imageURI; + EIP712Signature sig; + } + + /** + * @notice A struct containing the parameters required for the `setFollowNFTURIWithSig()` function. Parameters are the same + * as the regular `setFollowNFTURI()` function, with an added EIP712Signature. + * + * @param profileId The token ID of the profile for which to set the followNFT URI. + * @param followNFTURI The follow NFT URI to set. + * @param sig The EIP712Signature struct containing the followNFT's associated profile owner's signature. + */ + struct SetFollowNFTURIWithSigData { + uint256 profileId; + string followNFTURI; + EIP712Signature sig; + } + + /** + * @notice A struct containing the parameters required for the `post()` function. + * + * @param profileId The token ID of the profile to publish to. + * @param contentURI The URI to set for this new publication. + * @param collectModule The collect module to set for this new publication. + * @param collectModuleInitData The data to pass to the collect module's initialization. + * @param referenceModule The reference module to set for the given publication, must be whitelisted. + * @param referenceModuleInitData The data to be passed to the reference module for initialization. + */ + struct PostData { + uint256 profileId; + string contentURI; + address collectModule; + bytes collectModuleInitData; + address referenceModule; + bytes referenceModuleInitData; + } + + /** + * @notice A struct containing the parameters required for the `postWithSig()` function. Parameters are the same as + * the regular `post()` function, with an added EIP712Signature. + * + * @param profileId The token ID of the profile to publish to. + * @param contentURI The URI to set for this new publication. + * @param collectModule The collectModule to set for this new publication. + * @param collectModuleInitData The data to pass to the collectModule's initialization. + * @param referenceModule The reference module to set for the given publication, must be whitelisted. + * @param referenceModuleInitData The data to be passed to the reference module for initialization. + * @param sig The EIP712Signature struct containing the profile owner's signature. + */ + struct PostWithSigData { + uint256 profileId; + string contentURI; + address collectModule; + bytes collectModuleInitData; + address referenceModule; + bytes referenceModuleInitData; + EIP712Signature sig; + } + + /** + * @notice A struct containing the parameters required for the `comment()` function. + * + * @param profileId The token ID of the profile to publish to. + * @param contentURI The URI to set for this new publication. + * @param profileIdPointed The profile token ID to point the comment to. + * @param pubIdPointed The publication ID to point the comment to. + * @param referenceModuleData The data passed to the reference module. + * @param collectModule The collect module to set for this new publication. + * @param collectModuleInitData The data to pass to the collect module's initialization. + * @param referenceModule The reference module to set for the given publication, must be whitelisted. + * @param referenceModuleInitData The data to be passed to the reference module for initialization. + */ + struct CommentData { + uint256 profileId; + string contentURI; + uint256 profileIdPointed; + uint256 pubIdPointed; + bytes referenceModuleData; + address collectModule; + bytes collectModuleInitData; + address referenceModule; + bytes referenceModuleInitData; + } + + /** + * @notice A struct containing the parameters required for the `commentWithSig()` function. Parameters are the same as + * the regular `comment()` function, with an added EIP712Signature. + * + * @param profileId The token ID of the profile to publish to. + * @param contentURI The URI to set for this new publication. + * @param profileIdPointed The profile token ID to point the comment to. + * @param pubIdPointed The publication ID to point the comment to. + * @param referenceModuleData The data passed to the reference module. + * @param collectModule The collectModule to set for this new publication. + * @param collectModuleInitData The data to pass to the collectModule's initialization. + * @param referenceModule The reference module to set for the given publication, must be whitelisted. + * @param referenceModuleInitData The data to be passed to the reference module for initialization. + * @param sig The EIP712Signature struct containing the profile owner's signature. + */ + struct CommentWithSigData { + uint256 profileId; + string contentURI; + uint256 profileIdPointed; + uint256 pubIdPointed; + bytes referenceModuleData; + address collectModule; + bytes collectModuleInitData; + address referenceModule; + bytes referenceModuleInitData; + EIP712Signature sig; + } + + /** + * @notice A struct containing the parameters required for the `mirror()` function. + * + * @param profileId The token ID of the profile to publish to. + * @param profileIdPointed The profile token ID to point the mirror to. + * @param pubIdPointed The publication ID to point the mirror to. + * @param referenceModuleData The data passed to the reference module. + * @param referenceModule The reference module to set for the given publication, must be whitelisted. + * @param referenceModuleInitData The data to be passed to the reference module for initialization. + */ + struct MirrorData { + uint256 profileId; + uint256 profileIdPointed; + uint256 pubIdPointed; + bytes referenceModuleData; + address referenceModule; + bytes referenceModuleInitData; + } + + /** + * @notice A struct containing the parameters required for the `mirrorWithSig()` function. Parameters are the same as + * the regular `mirror()` function, with an added EIP712Signature. + * + * @param profileId The token ID of the profile to publish to. + * @param profileIdPointed The profile token ID to point the mirror to. + * @param pubIdPointed The publication ID to point the mirror to. + * @param referenceModuleData The data passed to the reference module. + * @param referenceModule The reference module to set for the given publication, must be whitelisted. + * @param referenceModuleInitData The data to be passed to the reference module for initialization. + * @param sig The EIP712Signature struct containing the profile owner's signature. + */ + struct MirrorWithSigData { + uint256 profileId; + uint256 profileIdPointed; + uint256 pubIdPointed; + bytes referenceModuleData; + address referenceModule; + bytes referenceModuleInitData; + EIP712Signature sig; + } + + /** + * @notice A struct containing the parameters required for the `followWithSig()` function. Parameters are the same + * as the regular `follow()` function, with the follower's (signer) address and an EIP712Signature added. + * + * @param follower The follower which is the message signer. + * @param profileIds The array of token IDs of the profiles to follow. + * @param datas The array of arbitrary data to pass to the followModules if needed. + * @param sig The EIP712Signature struct containing the follower's signature. + */ + struct FollowWithSigData { + address follower; + uint256[] profileIds; + bytes[] datas; + EIP712Signature sig; + } + + /** + * @notice A struct containing the parameters required for the `collectWithSig()` function. Parameters are the same as + * the regular `collect()` function, with the collector's (signer) address and an EIP712Signature added. + * + * @param collector The collector which is the message signer. + * @param profileId The token ID of the profile that published the publication to collect. + * @param pubId The publication to collect's publication ID. + * @param data The arbitrary data to pass to the collectModule if needed. + * @param sig The EIP712Signature struct containing the collector's signature. + */ + struct CollectWithSigData { + address collector; + uint256 profileId; + uint256 pubId; + bytes data; + EIP712Signature sig; + } + + /** + * @notice A struct containing the parameters required for the `setProfileMetadataWithSig()` function. + * + * @param profileId The profile ID for which to set the metadata. + * @param metadata The metadata string to set for the profile and user. + * @param sig The EIP712Signature struct containing the user's signature. + */ + struct SetProfileMetadataWithSigData { + uint256 profileId; + string metadata; + EIP712Signature sig; + } + + /** + * @notice A struct containing the parameters required for the `toggleFollowWithSig()` function. + * + * @param follower The follower which is the message signer. + * @param profileIds The token ID array of the profiles. + * @param enables The array of booleans to enable/disable follows. + * @param sig The EIP712Signature struct containing the follower's signature. + */ + struct ToggleFollowWithSigData { + address follower; + uint256[] profileIds; + bool[] enables; + EIP712Signature sig; + } +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e3ef6d7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ + +FROM golang:latest + +WORKDIR /app + +ADD . . + +RUN go install +RUN go build +ENTRYPOINT ["./main"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..75f00ed --- /dev/null +++ b/Makefile @@ -0,0 +1,45 @@ + +docker_test: + docker system prune + docker build -t main . + docker run --name main main + +docker create: + docker build -t main . + +docker test exec: + # docker kill $(docker ps -q) + # docker system prune + docker build -t tracker . + docker run --name tracker tracker + docker exec -it tracker bash + +test: + docker build -t tracker . + docker run --name tracker tracker + +clean: + docker system prune + +Build_and_Push: + # Your Project ID here as argument in line! + echo "Set PROJECT_ID=YOUR_PROJECT_ID if you have not !!!" + docker buildx build --platform linux/amd64 -t gcr.io/$(PROJECT_ID)/tracker . + docker push gcr.io/$(PROJECT_ID)/tracker + + +setting up gcloud etc: + gcloud auth login + gcloud auth configure-docker + +production: + # Your Project ID here as argument in line! + echo "Set PROJECT_ID=YOUR_PROJECT_ID if you have not !!!" + # Build for production for arm64 to make it work on GKE + docker buildx build --platform linux/amd64 -t gcr.io/$(PROJECT_ID)/tracker . + docker push gcr.io/$(PROJECT_ID)/tracker + cd terraform; terraform apply; + + + + diff --git a/abi.json b/abi.json new file mode 100644 index 0000000..f8a3281 --- /dev/null +++ b/abi.json @@ -0,0 +1 @@ +[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"BaseInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collectModule","type":"address"},{"indexed":true,"internalType":"bool","name":"whitelisted","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"CollectModuleWhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":true,"internalType":"address","name":"collectNFT","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"CollectNFTDeployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"CollectNFTInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"collectNFTId","type":"uint256"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"CollectNFTTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collector","type":"address"},{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rootProfileId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rootPubId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"collectModuleData","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Collected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":false,"internalType":"string","name":"contentURI","type":"string"},{"indexed":false,"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"referenceModuleData","type":"bytes"},{"indexed":false,"internalType":"address","name":"collectModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"collectModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"address","name":"referenceModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"referenceModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"CommentCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"DefaultProfileSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"address","name":"dispatcher","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"DispatcherSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"oldEmergencyAdmin","type":"address"},{"indexed":true,"internalType":"address","name":"newEmergencyAdmin","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"EmergencyAdminSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"moduleGlobals","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FeeModuleBaseConstructed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"address","name":"followModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"followModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowModuleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"followModule","type":"address"},{"indexed":true,"internalType":"bool","name":"whitelisted","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowModuleWhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"indexed":true,"internalType":"uint256","name":"newPower","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowNFTDelegatedPowerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"address","name":"followNFT","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowNFTDeployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowNFTInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"followNFTId","type":"uint256"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowNFTTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"string","name":"followNFTURI","type":"string"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowNFTURISet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"follower","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"profileIds","type":"uint256[]"},{"indexed":false,"internalType":"bytes[]","name":"followModuleDatas","type":"bytes[]"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Followed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"addresses","type":"address[]"},{"indexed":false,"internalType":"bool[]","name":"approved","type":"bool[]"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowsApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"profileIds","type":"uint256[]"},{"indexed":false,"internalType":"bool[]","name":"enabled","type":"bool[]"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowsToggled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"prevGovernance","type":"address"},{"indexed":true,"internalType":"address","name":"newGovernance","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"GovernanceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"referenceModuleData","type":"bytes"},{"indexed":false,"internalType":"address","name":"referenceModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"referenceModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"MirrorCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hub","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ModuleBaseConstructed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"currency","type":"address"},{"indexed":true,"internalType":"bool","name":"prevWhitelisted","type":"bool"},{"indexed":true,"internalType":"bool","name":"whitelisted","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ModuleGlobalsCurrencyWhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"prevGovernance","type":"address"},{"indexed":true,"internalType":"address","name":"newGovernance","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ModuleGlobalsGovernanceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"prevTreasuryFee","type":"uint16"},{"indexed":true,"internalType":"uint16","name":"newTreasuryFee","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ModuleGlobalsTreasuryFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"prevTreasury","type":"address"},{"indexed":true,"internalType":"address","name":"newTreasury","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ModuleGlobalsTreasurySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":false,"internalType":"string","name":"contentURI","type":"string"},{"indexed":false,"internalType":"address","name":"collectModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"collectModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"address","name":"referenceModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"referenceModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"PostCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"string","name":"handle","type":"string"},{"indexed":false,"internalType":"string","name":"imageURI","type":"string"},{"indexed":false,"internalType":"address","name":"followModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"followModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"string","name":"followNFTURI","type":"string"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ProfileCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"profileCreator","type":"address"},{"indexed":true,"internalType":"bool","name":"whitelisted","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ProfileCreatorWhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"string","name":"imageURI","type":"string"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ProfileImageURISet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"referenceModule","type":"address"},{"indexed":true,"internalType":"bool","name":"whitelisted","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ReferenceModuleWhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"enum DataTypes.ProtocolState","name":"prevState","type":"uint8"},{"indexed":true,"internalType":"enum DataTypes.ProtocolState","name":"newState","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"StateSet","type":"event"}] \ No newline at end of file diff --git a/abi.sh b/abi.sh new file mode 100644 index 0000000..6831f01 --- /dev/null +++ b/abi.sh @@ -0,0 +1,4 @@ +solc --abi events.sol +solc --bin events.sol +abigen --bin=Store_sol_Store.bin --abi=Store_sol_Store.abi --pkg=store --out=Store.go + diff --git a/database/database.go b/database/database.go new file mode 100644 index 0000000..6c36c48 --- /dev/null +++ b/database/database.go @@ -0,0 +1,67 @@ +package database + +import ( + "time" + + "github.com/google/uuid" + "github.com/shopspring/decimal" +) + +type User struct { + ID string `gorm:"primaryKey"` + Address string +} + +type CommentMessage struct { + MessageID uuid.UUID `gorm:"primaryKey"` + Sent bool + ProfileId decimal.Decimal + PubId decimal.Decimal + ContentURI string + ProfileIdPointed decimal.Decimal + PubIdPointed decimal.Decimal + CollectModule string + CollectModuleReturnData string + ReferenceModule string + ReferenceModuleReturnData string + Timestamp decimal.Decimal +} + +type FollowMessage struct { + MessageID uuid.UUID `gorm:"primaryKey"` + ProfileId decimal.Decimal + FollowNFT string + Timestamp decimal.Decimal + Sent bool +} + +type Clone struct { + Day time.Time `gorm:"primaryKey"` + Count int + Uniques int + Repository string `gorm:"primaryKey"` +} + +type View struct { + Day time.Time `gorm:"primaryKey"` + Count int + Uniques int + Repository string `gorm:"primaryKey"` +} + +type Path struct { + Path string `gorm:"primaryKey"` + Title string + Count int + Uniques int + Day time.Time `gorm:"primaryKey"` + Repository string `gorm:"primaryKey"` +} + +type Referral struct { + Referrer string `gorm:"primaryKey"` + Count int + Uniques int + Day time.Time `gorm:"primaryKey"` + Repository string `gorm:"primaryKey"` +} diff --git a/events.sol b/events.sol new file mode 100644 index 0000000..3dbc1fa --- /dev/null +++ b/events.sol @@ -0,0 +1,522 @@ +// SPDX-License-Identifier: MIT + + + +pragma solidity 0.8.17; + +import {DataTypes} from './DataTypes.sol'; + +library Events { + /** + * @dev Emitted when the NFT contract's name and symbol are set at initialization. + * + * @param name The NFT name set. + * @param symbol The NFT symbol set. + * @param timestamp The current block timestamp. + */ + event BaseInitialized(string name, string symbol, uint256 timestamp); + + /** + * @dev Emitted when the hub state is set. + * + * @param caller The caller who set the state. + * @param prevState The previous protocol state, an enum of either `Paused`, `PublishingPaused` or `Unpaused`. + * @param newState The newly set state, an enum of either `Paused`, `PublishingPaused` or `Unpaused`. + * @param timestamp The current block timestamp. + */ + event StateSet( + address indexed caller, + DataTypes.ProtocolState indexed prevState, + DataTypes.ProtocolState indexed newState, + uint256 timestamp + ); + + /** + * @dev Emitted when the governance address is changed. We emit the caller even though it should be the previous + * governance address, as we cannot guarantee this will always be the case due to upgradeability. + * + * @param caller The caller who set the governance address. + * @param prevGovernance The previous governance address. + * @param newGovernance The new governance address set. + * @param timestamp The current block timestamp. + */ + event GovernanceSet( + address indexed caller, + address indexed prevGovernance, + address indexed newGovernance, + uint256 timestamp + ); + + /** + * @dev Emitted when the emergency admin is changed. We emit the caller even though it should be the previous + * governance address, as we cannot guarantee this will always be the case due to upgradeability. + * + * @param caller The caller who set the emergency admin address. + * @param oldEmergencyAdmin The previous emergency admin address. + * @param newEmergencyAdmin The new emergency admin address set. + * @param timestamp The current block timestamp. + */ + event EmergencyAdminSet( + address indexed caller, + address indexed oldEmergencyAdmin, + address indexed newEmergencyAdmin, + uint256 timestamp + ); + + /** + * @dev Emitted when a profile creator is added to or removed from the whitelist. + * + * @param profileCreator The address of the profile creator. + * @param whitelisted Whether or not the profile creator is being added to the whitelist. + * @param timestamp The current block timestamp. + */ + event ProfileCreatorWhitelisted( + address indexed profileCreator, + bool indexed whitelisted, + uint256 timestamp + ); + + /** + * @dev Emitted when a follow module is added to or removed from the whitelist. + * + * @param followModule The address of the follow module. + * @param whitelisted Whether or not the follow module is being added to the whitelist. + * @param timestamp The current block timestamp. + */ + event FollowModuleWhitelisted( + address indexed followModule, + bool indexed whitelisted, + uint256 timestamp + ); + + /** + * @dev Emitted when a reference module is added to or removed from the whitelist. + * + * @param referenceModule The address of the reference module. + * @param whitelisted Whether or not the reference module is being added to the whitelist. + * @param timestamp The current block timestamp. + */ + event ReferenceModuleWhitelisted( + address indexed referenceModule, + bool indexed whitelisted, + uint256 timestamp + ); + + /** + * @dev Emitted when a collect module is added to or removed from the whitelist. + * + * @param collectModule The address of the collect module. + * @param whitelisted Whether or not the collect module is being added to the whitelist. + * @param timestamp The current block timestamp. + */ + event CollectModuleWhitelisted( + address indexed collectModule, + bool indexed whitelisted, + uint256 timestamp + ); + + /** + * @dev Emitted when a profile is created. + * + * @param profileId The newly created profile's token ID. + * @param creator The profile creator, who created the token with the given profile ID. + * @param to The address receiving the profile with the given profile ID. + * @param handle The handle set for the profile. + * @param imageURI The image uri set for the profile. + * @param followModule The profile's newly set follow module. This CAN be the zero address. + * @param followModuleReturnData The data returned from the follow module's initialization. This is abi encoded + * and totally depends on the follow module chosen. + * @param followNFTURI The URI set for the profile's follow NFT. + * @param timestamp The current block timestamp. + */ + event ProfileCreated( + uint256 indexed profileId, + address indexed creator, + address indexed to, + string handle, + string imageURI, + address followModule, + bytes followModuleReturnData, + string followNFTURI, + uint256 timestamp + ); + + /** + * @dev Emitted when a a default profile is set for a wallet as its main identity + * + * @param wallet The wallet which set or unset its default profile. + * @param profileId The token ID of the profile being set as default, or zero. + * @param timestamp The current block timestamp. + */ + event DefaultProfileSet(address indexed wallet, uint256 indexed profileId, uint256 timestamp); + + /** + * @dev Emitted when a dispatcher is set for a specific profile. + * + * @param profileId The token ID of the profile for which the dispatcher is set. + * @param dispatcher The dispatcher set for the given profile. + * @param timestamp The current block timestamp. + */ + event DispatcherSet(uint256 indexed profileId, address indexed dispatcher, uint256 timestamp); + + /** + * @dev Emitted when a profile's URI is set. + * + * @param profileId The token ID of the profile for which the URI is set. + * @param imageURI The URI set for the given profile. + * @param timestamp The current block timestamp. + */ + event ProfileImageURISet(uint256 indexed profileId, string imageURI, uint256 timestamp); + + /** + * @dev Emitted when a follow NFT's URI is set. + * + * @param profileId The token ID of the profile for which the followNFT URI is set. + * @param followNFTURI The follow NFT URI set. + * @param timestamp The current block timestamp. + */ + event FollowNFTURISet(uint256 indexed profileId, string followNFTURI, uint256 timestamp); + + /** + * @dev Emitted when a profile's follow module is set. + * + * @param profileId The profile's token ID. + * @param followModule The profile's newly set follow module. This CAN be the zero address. + * @param followModuleReturnData The data returned from the follow module's initialization. This is abi encoded + * and totally depends on the follow module chosen. + * @param timestamp The current block timestamp. + */ + event FollowModuleSet( + uint256 indexed profileId, + address followModule, + bytes followModuleReturnData, + uint256 timestamp + ); + + /** + * @dev Emitted when a "post" is published. + * + * @param profileId The profile's token ID. + * @param pubId The new publication's ID. + * @param contentURI The URI mapped to this new publication. + * @param collectModule The collect module mapped to this new publication. This CANNOT be the zero address. + * @param collectModuleReturnData The data returned from the collect module's initialization for this given + * publication. This is abi encoded and totally depends on the collect module chosen. + * @param referenceModule The reference module set for this publication. + * @param referenceModuleReturnData The data returned from the reference module at initialization. This is abi + * encoded and totally depends on the reference module chosen. + * @param timestamp The current block timestamp. + */ + event PostCreated( + uint256 indexed profileId, + uint256 indexed pubId, + string contentURI, + address collectModule, + bytes collectModuleReturnData, + address referenceModule, + bytes referenceModuleReturnData, + uint256 timestamp + ); + + /** + * @dev Emitted when a "comment" is published. + * + * @param profileId The profile's token ID. + * @param pubId The new publication's ID. + * @param contentURI The URI mapped to this new publication. + * @param profileIdPointed The profile token ID that this comment points to. + * @param pubIdPointed The publication ID that this comment points to. + * @param referenceModuleData The data passed to the reference module. + * @param collectModule The collect module mapped to this new publication. This CANNOT be the zero address. + * @param collectModuleReturnData The data returned from the collect module's initialization for this given + * publication. This is abi encoded and totally depends on the collect module chosen. + * @param referenceModule The reference module set for this publication. + * @param referenceModuleReturnData The data returned from the reference module at initialization. This is abi + * encoded and totally depends on the reference module chosen. + * @param timestamp The current block timestamp. + */ + event CommentCreated( + uint256 indexed profileId, + uint256 indexed pubId, + string contentURI, + uint256 profileIdPointed, + uint256 pubIdPointed, + bytes referenceModuleData, + address collectModule, + bytes collectModuleReturnData, + address referenceModule, + bytes referenceModuleReturnData, + uint256 timestamp + ); + + /** + * @dev Emitted when a "mirror" is published. + * + * @param profileId The profile's token ID. + * @param pubId The new publication's ID. + * @param profileIdPointed The profile token ID that this mirror points to. + * @param pubIdPointed The publication ID that this mirror points to. + * @param referenceModuleData The data passed to the reference module. + * @param referenceModule The reference module set for this publication. + * @param referenceModuleReturnData The data returned from the reference module at initialization. This is abi + * encoded and totally depends on the reference module chosen. + * @param timestamp The current block timestamp. + */ + event MirrorCreated( + uint256 indexed profileId, + uint256 indexed pubId, + uint256 profileIdPointed, + uint256 pubIdPointed, + bytes referenceModuleData, + address referenceModule, + bytes referenceModuleReturnData, + uint256 timestamp + ); + + /** + * @dev Emitted when a followNFT clone is deployed using a lazy deployment pattern. + * + * @param profileId The token ID of the profile to which this followNFT is associated. + * @param followNFT The address of the newly deployed followNFT clone. + * @param timestamp The current block timestamp. + */ + event FollowNFTDeployed( + uint256 indexed profileId, + address indexed followNFT, + uint256 timestamp + ); + + /** + * @dev Emitted when a collectNFT clone is deployed using a lazy deployment pattern. + * + * @param profileId The publisher's profile token ID. + * @param pubId The publication associated with the newly deployed collectNFT clone's ID. + * @param collectNFT The address of the newly deployed collectNFT clone. + * @param timestamp The current block timestamp. + */ + event CollectNFTDeployed( + uint256 indexed profileId, + uint256 indexed pubId, + address indexed collectNFT, + uint256 timestamp + ); + + /** + * @dev Emitted upon a successful collect action. + * + * @param collector The address collecting the publication. + * @param profileId The token ID of the profile that the collect was initiated towards, useful to differentiate mirrors. + * @param pubId The publication ID that the collect was initiated towards, useful to differentiate mirrors. + * @param rootProfileId The profile token ID of the profile whose publication is being collected. + * @param rootPubId The publication ID of the publication being collected. + * @param collectModuleData The data passed to the collect module. + * @param timestamp The current block timestamp. + */ + event Collected( + address indexed collector, + uint256 indexed profileId, + uint256 indexed pubId, + uint256 rootProfileId, + uint256 rootPubId, + bytes collectModuleData, + uint256 timestamp + ); + + /** + * @dev Emitted upon a successful follow action. + * + * @param follower The address following the given profiles. + * @param profileIds The token ID array of the profiles being followed. + * @param followModuleDatas The array of data parameters passed to each follow module. + * @param timestamp The current block timestamp. + */ + event Followed( + address indexed follower, + uint256[] profileIds, + bytes[] followModuleDatas, + uint256 timestamp + ); + + /** + * @dev Emitted via callback when a followNFT is transferred. + * + * @param profileId The token ID of the profile associated with the followNFT being transferred. + * @param followNFTId The followNFT being transferred's token ID. + * @param from The address the followNFT is being transferred from. + * @param to The address the followNFT is being transferred to. + * @param timestamp The current block timestamp. + */ + event FollowNFTTransferred( + uint256 indexed profileId, + uint256 indexed followNFTId, + address from, + address to, + uint256 timestamp + ); + + /** + * @dev Emitted via callback when a collectNFT is transferred. + * + * @param profileId The token ID of the profile associated with the collectNFT being transferred. + * @param pubId The publication ID associated with the collectNFT being transferred. + * @param collectNFTId The collectNFT being transferred's token ID. + * @param from The address the collectNFT is being transferred from. + * @param to The address the collectNFT is being transferred to. + * @param timestamp The current block timestamp. + */ + event CollectNFTTransferred( + uint256 indexed profileId, + uint256 indexed pubId, + uint256 indexed collectNFTId, + address from, + address to, + uint256 timestamp + ); + + // Collect/Follow NFT-Specific + + /** + * @dev Emitted when a newly deployed follow NFT is initialized. + * + * @param profileId The token ID of the profile connected to this follow NFT. + * @param timestamp The current block timestamp. + */ + event FollowNFTInitialized(uint256 indexed profileId, uint256 timestamp); + + /** + * @dev Emitted when delegation power in a FollowNFT is changed. + * + * @param delegate The delegate whose power has been changed. + * @param newPower The new governance power mapped to the delegate. + * @param timestamp The current block timestamp. + */ + event FollowNFTDelegatedPowerChanged( + address indexed delegate, + uint256 indexed newPower, + uint256 timestamp + ); + + /** + * @dev Emitted when a newly deployed collect NFT is initialized. + * + * @param profileId The token ID of the profile connected to the publication mapped to this collect NFT. + * @param pubId The publication ID connected to the publication mapped to this collect NFT. + * @param timestamp The current block timestamp. + */ + event CollectNFTInitialized( + uint256 indexed profileId, + uint256 indexed pubId, + uint256 timestamp + ); + + // Module-Specific + + /** + * @notice Emitted when the ModuleGlobals governance address is set. + * + * @param prevGovernance The previous governance address. + * @param newGovernance The new governance address set. + * @param timestamp The current block timestamp. + */ + event ModuleGlobalsGovernanceSet( + address indexed prevGovernance, + address indexed newGovernance, + uint256 timestamp + ); + + /** + * @notice Emitted when the ModuleGlobals treasury address is set. + * + * @param prevTreasury The previous treasury address. + * @param newTreasury The new treasury address set. + * @param timestamp The current block timestamp. + */ + event ModuleGlobalsTreasurySet( + address indexed prevTreasury, + address indexed newTreasury, + uint256 timestamp + ); + + /** + * @notice Emitted when the ModuleGlobals treasury fee is set. + * + * @param prevTreasuryFee The previous treasury fee in BPS. + * @param newTreasuryFee The new treasury fee in BPS. + * @param timestamp The current block timestamp. + */ + event ModuleGlobalsTreasuryFeeSet( + uint16 indexed prevTreasuryFee, + uint16 indexed newTreasuryFee, + uint256 timestamp + ); + + /** + * @notice Emitted when a currency is added to or removed from the ModuleGlobals whitelist. + * + * @param currency The currency address. + * @param prevWhitelisted Whether or not the currency was previously whitelisted. + * @param whitelisted Whether or not the currency is whitelisted. + * @param timestamp The current block timestamp. + */ + event ModuleGlobalsCurrencyWhitelisted( + address indexed currency, + bool indexed prevWhitelisted, + bool indexed whitelisted, + uint256 timestamp + ); + + /** + * @notice Emitted when a module inheriting from the `FeeModuleBase` is constructed. + * + * @param moduleGlobals The ModuleGlobals contract address used. + * @param timestamp The current block timestamp. + */ + event FeeModuleBaseConstructed(address indexed moduleGlobals, uint256 timestamp); + + /** + * @notice Emitted when a module inheriting from the `ModuleBase` is constructed. + * + * @param hub The LensHub contract address used. + * @param timestamp The current block timestamp. + */ + event ModuleBaseConstructed(address indexed hub, uint256 timestamp); + + /** + * @notice Emitted when one or multiple addresses are approved (or disapproved) for following in + * the `ApprovalFollowModule`. + * + * @param owner The profile owner who executed the approval. + * @param profileId The profile ID that the follow approvals are granted/revoked for. + * @param addresses The addresses that have had the follow approvals grnated/revoked. + * @param approved Whether each corresponding address is now approved or disapproved. + * @param timestamp The current block timestamp. + */ + event FollowsApproved( + address indexed owner, + uint256 indexed profileId, + address[] addresses, + bool[] approved, + uint256 timestamp + ); + + /** + * @dev Emitted when the user wants to enable or disable follows in the `LensPeriphery`. + * + * @param owner The profile owner who executed the toggle. + * @param profileIds The array of token IDs of the profiles each followNFT is associated with. + * @param enabled The array of whether each FollowNFT's follow is enabled/disabled. + * @param timestamp The current block timestamp. + */ + event FollowsToggled( + address indexed owner, + uint256[] profileIds, + bool[] enabled, + uint256 timestamp + ); + + event bigint ( + uint256 number + ); + + +} \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1691fcd --- /dev/null +++ b/go.mod @@ -0,0 +1,41 @@ +module main + +go 1.19 + +require ( + github.com/ethereum/go-ethereum v1.10.25 + github.com/google/uuid v1.3.0 + github.com/profclems/go-dotenv v0.1.2 + github.com/shopspring/decimal v1.3.1 + gorm.io/driver/postgres v1.4.4 + gorm.io/gorm v1.24.0 +) + +require ( + github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect + github.com/deckarep/golang-set v1.8.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/go-ole/go-ole v1.2.1 // indirect + github.com/go-stack/stack v1.8.0 // indirect + github.com/google/renameio v0.1.0 // indirect + github.com/gorilla/websocket v1.4.2 // indirect + github.com/jackc/chunkreader/v2 v2.0.1 // indirect + github.com/jackc/pgconn v1.13.0 // indirect + github.com/jackc/pgio v1.0.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgproto3/v2 v2.3.1 // indirect + github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect + github.com/jackc/pgtype v1.12.0 // indirect + github.com/jackc/pgx/v4 v4.17.2 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.4 // indirect + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + github.com/spf13/cast v1.3.1 // indirect + github.com/tklauser/go-sysconf v0.3.5 // indirect + github.com/tklauser/numcpus v0.2.2 // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + golang.org/x/text v0.3.7 // indirect + gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..80338b9 --- /dev/null +++ b/go.sum @@ -0,0 +1,261 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= +github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= +github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= +github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= +github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= +github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= +github.com/ethereum/go-ethereum v1.10.25 h1:5dFrKJDnYf8L6/5o42abCE6a9yJm9cs4EJVRyYMr55s= +github.com/ethereum/go-ethereum v1.10.25/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= +github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= +github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= +github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= +github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM= +github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= +github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= +github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= +github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= +github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= +github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= +github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= +github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= +github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys= +github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= +github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= +github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= +github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= +github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= +github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc= +github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= +github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y= +github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= +github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= +github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= +github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= +github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= +github.com/jackc/pgtype v1.12.0 h1:Dlq8Qvcch7kiehm8wPGIW0W3KsCCHJnRacKW0UM8n5w= +github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= +github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= +github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= +github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= +github.com/jackc/pgx/v4 v4.17.2 h1:0Ut0rpeKwvIVbMQ1KbMBU4h6wxehBI535LK6Flheh8E= +github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw= +github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas= +github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= +github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/profclems/go-dotenv v0.1.2 h1:LRYhelv0dueEwvkkM9QAhz8Dg9NZPL1qBX7v+oat+dM= +github.com/profclems/go-dotenv v0.1.2/go.mod h1:Zw9Xc835DdcQS6J/yLQ0U6r9SLS3SXwyGWwN0WS4xPw= +github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA= +github.com/rjeczalik/notify v0.9.1 h1:CLCKso/QK1snAlnhNR/CNvNiFU2saUtjV0bx3EwNeCE= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= +github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= +github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= +github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= +github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp3vU4= +github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= +github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA= +github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= +github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef h1:wHSqTBrZW24CsNJDfeh9Ex6Pm0Rcpc7qrgKBiL44vF4= +github.com/urfave/cli/v2 v2.10.2 h1:x3p8awjp/2arX+Nl/G2040AZpOCHS/eMJJ1/a+mye4Y= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba h1:O8mE0/t419eoIwhTFpKVkHiTs/Igowgfkj25AcZrtiE= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= +gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= +gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/postgres v1.4.4 h1:zt1fxJ+C+ajparn0SteEnkoPg0BQ6wOWXEQ99bteAmw= +gorm.io/driver/postgres v1.4.4/go.mod h1:whNfh5WhhHs96honoLjBAMwJGYEuA3m1hvgUbNXhPCw= +gorm.io/gorm v1.23.7/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= +gorm.io/gorm v1.24.0 h1:j/CoiSm6xpRpmzbFJsQHYj+I8bGYWLXVHeYEyyKlF74= +gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/main.go b/main.go new file mode 100644 index 0000000..9372fdc --- /dev/null +++ b/main.go @@ -0,0 +1,219 @@ +package main + +import ( + "context" + "fmt" + "log" + "math/big" + "strings" + + //eth "github.com/ethereum/go-ethereum" + + "main/database" + + "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + types "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/google/uuid" + dotenv "github.com/profclems/go-dotenv" //Import dotenv library to deal with env variables before CICD is needed + "github.com/shopspring/decimal" + + //Import GORM (go ORM) to interact with the database + "gorm.io/driver/postgres" + "gorm.io/gorm" + "gorm.io/gorm/clause" +) + +const ( + ABI = `[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"BaseInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collectModule","type":"address"},{"indexed":true,"internalType":"bool","name":"whitelisted","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"CollectModuleWhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":true,"internalType":"address","name":"collectNFT","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"CollectNFTDeployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"CollectNFTInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"collectNFTId","type":"uint256"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"CollectNFTTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collector","type":"address"},{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rootProfileId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rootPubId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"collectModuleData","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Collected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":false,"internalType":"string","name":"contentURI","type":"string"},{"indexed":false,"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"referenceModuleData","type":"bytes"},{"indexed":false,"internalType":"address","name":"collectModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"collectModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"address","name":"referenceModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"referenceModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"CommentCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"DefaultProfileSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"address","name":"dispatcher","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"DispatcherSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"oldEmergencyAdmin","type":"address"},{"indexed":true,"internalType":"address","name":"newEmergencyAdmin","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"EmergencyAdminSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"moduleGlobals","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FeeModuleBaseConstructed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"address","name":"followModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"followModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowModuleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"followModule","type":"address"},{"indexed":true,"internalType":"bool","name":"whitelisted","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowModuleWhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"indexed":true,"internalType":"uint256","name":"newPower","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowNFTDelegatedPowerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"address","name":"followNFT","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowNFTDeployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowNFTInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"followNFTId","type":"uint256"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowNFTTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"string","name":"followNFTURI","type":"string"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowNFTURISet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"follower","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"profileIds","type":"uint256[]"},{"indexed":false,"internalType":"bytes[]","name":"followModuleDatas","type":"bytes[]"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Followed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"addresses","type":"address[]"},{"indexed":false,"internalType":"bool[]","name":"approved","type":"bool[]"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowsApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"profileIds","type":"uint256[]"},{"indexed":false,"internalType":"bool[]","name":"enabled","type":"bool[]"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FollowsToggled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"prevGovernance","type":"address"},{"indexed":true,"internalType":"address","name":"newGovernance","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"GovernanceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"referenceModuleData","type":"bytes"},{"indexed":false,"internalType":"address","name":"referenceModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"referenceModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"MirrorCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hub","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ModuleBaseConstructed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"currency","type":"address"},{"indexed":true,"internalType":"bool","name":"prevWhitelisted","type":"bool"},{"indexed":true,"internalType":"bool","name":"whitelisted","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ModuleGlobalsCurrencyWhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"prevGovernance","type":"address"},{"indexed":true,"internalType":"address","name":"newGovernance","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ModuleGlobalsGovernanceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"prevTreasuryFee","type":"uint16"},{"indexed":true,"internalType":"uint16","name":"newTreasuryFee","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ModuleGlobalsTreasuryFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"prevTreasury","type":"address"},{"indexed":true,"internalType":"address","name":"newTreasury","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ModuleGlobalsTreasurySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"pubId","type":"uint256"},{"indexed":false,"internalType":"string","name":"contentURI","type":"string"},{"indexed":false,"internalType":"address","name":"collectModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"collectModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"address","name":"referenceModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"referenceModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"PostCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"string","name":"handle","type":"string"},{"indexed":false,"internalType":"string","name":"imageURI","type":"string"},{"indexed":false,"internalType":"address","name":"followModule","type":"address"},{"indexed":false,"internalType":"bytes","name":"followModuleReturnData","type":"bytes"},{"indexed":false,"internalType":"string","name":"followNFTURI","type":"string"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ProfileCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"profileCreator","type":"address"},{"indexed":true,"internalType":"bool","name":"whitelisted","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ProfileCreatorWhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"profileId","type":"uint256"},{"indexed":false,"internalType":"string","name":"imageURI","type":"string"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ProfileImageURISet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"referenceModule","type":"address"},{"indexed":true,"internalType":"bool","name":"whitelisted","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"ReferenceModuleWhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"enum DataTypes.ProtocolState","name":"prevState","type":"uint8"},{"indexed":true,"internalType":"enum DataTypes.ProtocolState","name":"newState","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"StateSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"number","type":"uint256"}],"name":"bigint","type":"event"}]` +) + +type CommentCreated struct { + profileId decimal.Decimal + pubId decimal.Decimal + contentURI string + profileIdPointed decimal.Decimal + pubIdPointed decimal.Decimal + collectModule string + collectModuleReturnData string + referenceModule string + referenceModuleReturnData string + timestamp decimal.Decimal +} + +type FollowNFTDeployed struct { + profileId decimal.Decimal + followNFT string + timestamp decimal.Decimal +} + +func main() { + + dsn := "" + err := dotenv.LoadConfig() + if err != nil { + //panic if we cannot load the .env + fmt.Println("error loading .env file") + } + + dsn = dotenv.GetString("DATABASE_URL") + rpc := dotenv.GetString("RPC_URL") + + db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{}) + //panic if we cannot connect to the database + if err != nil { + panic("failed to connect database") + } else { + //or else we are good to go + fmt.Println("Connected to database") + fmt.Println(db) + } + db.AutoMigrate(&database.User{}) + db.AutoMigrate(&database.FollowMessage{}) + db.AutoMigrate(&database.CommentMessage{}) + + client, err := ethclient.Dial(rpc) + if err != nil { + log.Fatal("Failed to connect to the websocket of the Node (RPC) ", err) + } else { + fmt.Println("successfully connected to the RPC endpoint!") + } + + contractABI, err := abi.JSON(strings.NewReader(ABI)) + if err != nil { + log.Fatal("could not convert JSON ABI string to ABI object") + } + + contractAddress := common.HexToAddress("0x60Ae865ee4C725cd04353b5AAb364553f56ceF82") + query := ethereum.FilterQuery{ + Addresses: []common.Address{contractAddress}, + Topics: [][]common.Hash{{common.HexToHash("0x44403e38baed5e40df7f64ff8708b076c75a0dfda8380e75df5c36f11a476743")}}, + } + + query2 := ethereum.FilterQuery{ + Addresses: []common.Address{contractAddress}, + Topics: [][]common.Hash{{common.HexToHash("0x7b4d1aa33773161799847429e4fbf29f56dbf1a3fe815f5070231cbfba402c37")}}, + } + + logs1 := make(chan types.Log) + logs2 := make(chan types.Log) + + sub, err := client.SubscribeFilterLogs(context.Background(), query, logs1) + if err != nil { + log.Fatal(err) + } else { + fmt.Println("successfully subscribed to the contract events!") + } + + sub2, err := client.SubscribeFilterLogs(context.Background(), query2, logs2) + if err != nil { + log.Fatal(err) + } else { + fmt.Println("successfully subscribed to the contract events!") + } + + for { + select { + case err := <-sub.Err(): + log.Fatal(err) + case vLog := <-logs1: + fmt.Println("The Topic 0 of this event is;: ", vLog.Topics[0].Hex()) + Topics := vLog.Topics + ProfileIDData, err := hexutil.Decode(Topics[1].Hex()) + if err != nil { + log.Fatal(err) + } + + ProfileIdInterface, err := contractABI.Unpack("bigint", ProfileIDData) + + if err != nil { + log.Fatal(err) + } + + ProfileIDBI := ProfileIdInterface[0].(*big.Int) + profileID := decimal.NewFromBigInt(ProfileIDBI, 0) + followNFT := common.HexToAddress((Topics[2].Hex())).Hex() + + Timestamp, err := contractABI.Unpack("bigint", vLog.Data) + if err != nil { + log.Fatal(err) + } + TimestampBI := Timestamp[0].(*big.Int) + TimestampDecimal := decimal.NewFromBigInt(TimestampBI, 0) + + myvar := database.FollowMessage{ + MessageID: uuid.New(), + Sent: false, + ProfileId: profileID, + FollowNFT: followNFT, + Timestamp: TimestampDecimal, + } + + db.Clauses(clause.OnConflict{ + UpdateAll: true, + }).Create(&myvar) + + fmt.Println(common.HexToAddress((Topics[2].Hex())).Hex()) + case err := <-sub2.Err(): + log.Fatal(err) + case vLog2 := <-logs2: + fmt.Println("The Topic 0 of this event is;: ", vLog2.Topics[0].Hex()) + //Topics2 := vLog.Topics + inrerfaces, err := contractABI.Unpack("CommentCreated", vLog2.Data) + + fmt.Println("I am up to here") + if err != nil { + log.Fatal(err) + } + + profileIdData, err := hexutil.Decode(vLog2.Topics[1].Hex()) + if err != nil { + log.Fatal(err) + } + profileIdInterface, err := contractABI.Unpack("bigint", profileIdData) + if err != nil { + log.Fatal(err) + } + profileId := profileIdInterface[0].(*big.Int) + prodileIdDecimal := decimal.NewFromBigInt(profileId, 0) + + pubIdData, err := hexutil.Decode(vLog2.Topics[2].Hex()) + if err != nil { + log.Fatal(err) + } + pubIdInterface, err := contractABI.Unpack("bigint", pubIdData) + if err != nil { + log.Fatal(err) + } + pubId := pubIdInterface[0].(*big.Int) + pubIdDecimal := decimal.NewFromBigInt(pubId, 0) + + contentURI := inrerfaces[0].(string) + profileIdPointed := inrerfaces[1].(*big.Int) + pubIdPointed := inrerfaces[2].(*big.Int) + + myvar := database.CommentMessage{ + MessageID: uuid.New(), + Sent: false, + ProfileId: prodileIdDecimal, + PubId: pubIdDecimal, + ContentURI: contentURI, + ProfileIdPointed: decimal.NewFromBigInt(profileIdPointed, 0), + PubIdPointed: decimal.NewFromBigInt(pubIdPointed, 0), + } + + db.Clauses(clause.OnConflict{ + UpdateAll: true, + }).Create(&myvar) + + } + } +} + +// Main +// wss://polygon-mainnet.g.alchemy.com/v2/3ZR9MXbyYN4nBj4IWZJX9XNqxVpYUK2M +// Test +// wss://polygon-mumbai.g.alchemy.com/v2/-xLct1D6mffFUeh-NhHKvIQ1Qe6sNBqe diff --git a/main_test.go b/main_test.go new file mode 100644 index 0000000..dad51f5 --- /dev/null +++ b/main_test.go @@ -0,0 +1,27 @@ +package main + +import "testing" + +func TestHexToInt(t *testing.T) { + type args struct { + hex string + } + tests := []struct { + name string + args args + want int + }{ + { + name: "Quick Real data Test", + args: args{"0x0000000000000000000000000000000000000000000000000000000000011bb4"}, + want: 72628, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := HexToInt(tt.args.hex); got != tt.want { + t.Errorf("HexToInt() = %v, want %v", got, tt.want) + } + }) + } +}