diff --git a/build.gradle b/build.gradle index 08af85bf..a5ca15c2 100644 --- a/build.gradle +++ b/build.gradle @@ -74,7 +74,8 @@ dependencies { implementation 'software.amazon.awssdk:s3' // Smart Contract - implementation 'org.web3j:core:4.9.4' + implementation 'org.web3j:core:4.12.0' + implementation 'org.web3j:contracts:4.12.0' } tasks.named('test') { diff --git a/src/main/java/com/donet/donet/donation/adapter/in/scheduler/RefundScheduler.java b/src/main/java/com/donet/donet/donation/adapter/in/scheduler/RefundScheduler.java new file mode 100644 index 00000000..630200f7 --- /dev/null +++ b/src/main/java/com/donet/donet/donation/adapter/in/scheduler/RefundScheduler.java @@ -0,0 +1,17 @@ +package com.donet.donet.donation.adapter.in.scheduler; + +import com.donet.donet.donation.application.port.in.RefundDonationUsecase; +import lombok.RequiredArgsConstructor; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class RefundScheduler { + private final RefundDonationUsecase refundDonationUsecase; + + @Scheduled(cron = "0 0 0 * * *", zone = "Asia/Seoul") + public void runRefundJob() { + refundDonationUsecase.refundDonation(); + } +} diff --git a/src/main/java/com/donet/donet/donation/adapter/out/persistence/donation/DonationPersistenceAdapter.java b/src/main/java/com/donet/donet/donation/adapter/out/persistence/donation/DonationPersistenceAdapter.java index 395018fb..fcc73827 100644 --- a/src/main/java/com/donet/donet/donation/adapter/out/persistence/donation/DonationPersistenceAdapter.java +++ b/src/main/java/com/donet/donet/donation/adapter/out/persistence/donation/DonationPersistenceAdapter.java @@ -14,6 +14,7 @@ import com.donet.donet.global.exception.CustomException; import com.donet.donet.global.exception.DonationException; import com.donet.donet.global.exception.UserException; +import com.donet.donet.global.persistence.BaseStatus; import com.donet.donet.review.adapter.out.persistence.DonationReviewRepository; import com.donet.donet.user.adapter.out.persistence.UserJpaEntity; import com.donet.donet.user.adapter.out.persistence.UserRepository; @@ -26,6 +27,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Component; +import java.time.LocalDate; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -125,6 +127,14 @@ public List findRegisteredDonations(User user, int size) { return registeredDonations; } + @Override + public List findRefundableDonation() { + return donationRepository.findRefundableDonations(LocalDate.now(), BaseStatus.ACTIVE) + .stream() + .map(donationMapper::mapToDomainEntity) + .toList(); + } + @Override public Donation increaseDonationView(Long donationId) { DonationJpaEntity donationJpaEntity = donationRepository.findDonationById(donationId) diff --git a/src/main/java/com/donet/donet/donation/adapter/out/persistence/donation/DonationRepository.java b/src/main/java/com/donet/donet/donation/adapter/out/persistence/donation/DonationRepository.java index f025ce86..06d84c92 100644 --- a/src/main/java/com/donet/donet/donation/adapter/out/persistence/donation/DonationRepository.java +++ b/src/main/java/com/donet/donet/donation/adapter/out/persistence/donation/DonationRepository.java @@ -1,5 +1,6 @@ package com.donet.donet.donation.adapter.out.persistence.donation; +import com.donet.donet.global.persistence.BaseStatus; import com.donet.donet.user.adapter.out.persistence.UserJpaEntity; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -8,6 +9,7 @@ import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.time.LocalDate; import java.util.List; import java.util.Optional; @@ -90,4 +92,12 @@ SELECT COUNT(*) Page findJoinedDonations(@Param("userId") Long userId, Pageable pageable); List findAllByUserJpaEntityOrderByIdDesc(UserJpaEntity userJpaEntity, Pageable pageable); + + @Query(""" + SELECT d FROM DonationJpaEntity d + WHERE d.endDate < :today + AND d.currentAmount < d.targetAmount + AND d.status = :status + """) + List findRefundableDonations(LocalDate today, BaseStatus status); } diff --git a/src/main/java/com/donet/donet/donation/application/RefundDonationService.java b/src/main/java/com/donet/donet/donation/application/RefundDonationService.java new file mode 100644 index 00000000..b551994d --- /dev/null +++ b/src/main/java/com/donet/donet/donation/application/RefundDonationService.java @@ -0,0 +1,42 @@ +package com.donet.donet.donation.application; + +import com.donet.donet.donation.application.port.in.RefundDonationUsecase; +import com.donet.donet.donation.application.port.out.FindDonationPort; +import com.donet.donet.donation.application.port.out.SmartContractPort; +import com.donet.donet.donation.domain.Donation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Slf4j +@Service +@RequiredArgsConstructor +public class RefundDonationService implements RefundDonationUsecase { + + private final FindDonationPort findDonationPort; + private final SmartContractPort smartContractPort; + + @Override + public void refundDonation() { + List refundTargetDonationIds = findDonationPort.findRefundableDonation() + .stream() + .map(Donation::getId) + .toList(); + + if (refundTargetDonationIds.isEmpty()) { + log.info("환불 대상 기부가 없습니다."); + return; + } + + log.info("환불 처리 시작: {} 건", refundTargetDonationIds.size()); + boolean success = smartContractPort.refundDonations(refundTargetDonationIds); + + if (success) { + log.info("환불 처리 완료: {} 건", refundTargetDonationIds.size()); + }else{ + log.error("환불 처리 실패: donation IDs = {}", refundTargetDonationIds); + } + } +} diff --git a/src/main/java/com/donet/donet/donation/application/port/in/RefundDonationUsecase.java b/src/main/java/com/donet/donet/donation/application/port/in/RefundDonationUsecase.java new file mode 100644 index 00000000..c7318308 --- /dev/null +++ b/src/main/java/com/donet/donet/donation/application/port/in/RefundDonationUsecase.java @@ -0,0 +1,5 @@ +package com.donet.donet.donation.application.port.in; + +public interface RefundDonationUsecase { + void refundDonation(); +} diff --git a/src/main/java/com/donet/donet/donation/application/port/out/FindDonationPort.java b/src/main/java/com/donet/donet/donation/application/port/out/FindDonationPort.java index 92268817..c52e8fab 100644 --- a/src/main/java/com/donet/donet/donation/application/port/out/FindDonationPort.java +++ b/src/main/java/com/donet/donet/donation/application/port/out/FindDonationPort.java @@ -18,4 +18,6 @@ public interface FindDonationPort { List findJoinedDonations(User user, int size); List findRegisteredDonations(User user, int size); + + List findRefundableDonation(); } diff --git a/src/main/java/com/donet/donet/donation/application/port/out/SmartContractPort.java b/src/main/java/com/donet/donet/donation/application/port/out/SmartContractPort.java new file mode 100644 index 00000000..e80d8d40 --- /dev/null +++ b/src/main/java/com/donet/donet/donation/application/port/out/SmartContractPort.java @@ -0,0 +1,7 @@ +package com.donet.donet.donation.application.port.out; + +import java.util.List; + +public interface SmartContractPort { + boolean refundDonations(List donationIds); +} diff --git a/src/main/java/com/donet/donet/global/smartContract/Campaign.java b/src/main/java/com/donet/donet/global/smartContract/Campaign.java new file mode 100644 index 00000000..bea166b3 --- /dev/null +++ b/src/main/java/com/donet/donet/global/smartContract/Campaign.java @@ -0,0 +1,671 @@ +package com.donet.donet.global.smartContract; + +import io.reactivex.Flowable; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.web3j.abi.EventEncoder; +import org.web3j.abi.TypeReference; +import org.web3j.abi.datatypes.Address; +import org.web3j.abi.datatypes.Bool; +//import org.web3j.abi.datatypes.CustomError; +import org.web3j.abi.datatypes.Event; +import org.web3j.abi.datatypes.Function; +import org.web3j.abi.datatypes.Type; +import org.web3j.abi.datatypes.generated.Uint256; +import org.web3j.abi.datatypes.generated.Uint64; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.DefaultBlockParameter; +import org.web3j.protocol.core.RemoteCall; +import org.web3j.protocol.core.RemoteFunctionCall; +import org.web3j.protocol.core.methods.request.EthFilter; +import org.web3j.protocol.core.methods.response.BaseEventResponse; +import org.web3j.protocol.core.methods.response.Log; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import org.web3j.tx.Contract; +import org.web3j.tx.TransactionManager; +import org.web3j.tx.gas.ContractGasProvider; + +/** + *

Auto generated code. + *

Do not modify! + *

Please use the web3j command line tools, + * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the + * codegen module to update. + * + *

Generated with web3j version 1.7.0. + */ +@SuppressWarnings("rawtypes") +public class Campaign extends Contract { + public static final String BINARY = "608060405234801561001057600080fd5b5061001961001e565b6100d0565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161561006e5760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100cd5780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b611370806100df6000396000f3fe60806040526004361061012a5760003560e01c80637f83a4a6116100ab578063e9fee16f1161006f578063e9fee16f146102e7578063eb13554f14610307578063eeca08f014610327578063f0ea4bfc1461033d578063f14faf6f14610353578063ff203bc01461037357600080fd5b80637f83a4a614610285578063b69ef8a81461029a578063b907b846146102af578063c806a067146102c5578063d3eb6f61146102cd57600080fd5b8063451c3d80116100f2578063451c3d80146101f8578063590e1ae3146102185780635c76ca2d1461022f57806363bd1d4a146102505780636845516b1461026557600080fd5b806329dcb0cf1461012f5780632f13b60c1461015857806338af3eed1461017d57806340193883146101b557806342e94c90146101cb575b600080fd5b34801561013b57600080fd5b5061014560025481565b6040519081526020015b60405180910390f35b34801561016457600080fd5b5061016d610388565b604051901515815260200161014f565b34801561018957600080fd5b5060005461019d906001600160a01b031681565b6040516001600160a01b03909116815260200161014f565b3480156101c157600080fd5b5061014560015481565b3480156101d757600080fd5b506101456101e63660046111c3565b60076020526000908152604090205481565b34801561020457600080fd5b5060045461019d906001600160a01b031681565b34801561022457600080fd5b5061022d6103a3565b005b34801561023b57600080fd5b5060045461016d90600160a01b900460ff1681565b34801561025c57600080fd5b5061022d6103f8565b34801561027157600080fd5b5061022d6102803660046111e5565b610679565b34801561029157600080fd5b5061016d61080d565b3480156102a657600080fd5b5061014561085e565b3480156102bb57600080fd5b50610145600a5481565b61022d6108e8565b3480156102d957600080fd5b50600154600354101561016d565b3480156102f357600080fd5b5061022d610302366004611244565b610a74565b34801561031357600080fd5b5060065461019d906001600160a01b031681565b34801561033357600080fd5b5061014560055481565b34801561034957600080fd5b5061014560035481565b34801561035f57600080fd5b5061022d61036e366004611244565b610ba5565b34801561037f57600080fd5b5061016d610d49565b600060025460000361039a5750600090565b50600254421190565b6103ab610d70565b6103b3610da8565b60006103be33610e26565b9050806103de57604051631971fbf360e21b815260040160405180910390fd5b506103f6600160008051602061131b83398151915255565b565b610400610d70565b600454600160a01b900460ff161561042b57604051631897796360e21b815260040160405180910390fd5b6001546003541015610450576040516378c754c960e01b815260040160405180910390fd5b6004805460ff60a01b1916600160a01b1790556005546003546000916127109161047a9190611273565b610484919061128a565b905060008160035461049691906112ac565b6004549091506001600160a01b03166105b857600080546040516001600160a01b039091169083908381818185875af1925050503d80600081146104f6576040519150601f19603f3d011682016040523d82523d6000602084013e6104fb565b606091505b505090508061051d576040516312171d8360e31b815260040160405180910390fd5b60008311801561053757506006546001600160a01b031615155b156105b2576006546040516000916001600160a01b03169085908381818185875af1925050503d8060008114610589576040519150601f19603f3d011682016040523d82523d6000602084013e61058e565b606091505b50509050806105b0576040516312171d8360e31b815260040160405180910390fd5b505b50610612565b6004546000546001600160a01b03918216916105d79183911684610eec565b6000831180156105f157506006546001600160a01b031615155b1561061057600654610610906001600160a01b03838116911685610eec565b505b6000546040805183815260208101859052428183015290516001600160a01b03909216917f807c2c73192f2d30961a7d01ec8dc57115a4cd9f9bd0434331beacb916c6a8cc9181900360600190a250506103f6600160008051602061131b83398151915255565b6000610683610f50565b805490915060ff600160401b820416159067ffffffffffffffff166000811580156106ab5750825b905060008267ffffffffffffffff1660011480156106c85750303b155b9050811580156106d6575080155b156106f45760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561071e57845460ff60401b1916600160401b1785555b6001600160a01b038b1661074557604051631559b7d760e21b815260040160405180910390fd5b8960000361076657604051639b60eb4d60e01b815260040160405180910390fd5b61076e610f7b565b600080546001600160a01b03808e166001600160a01b03199283161790925560018c905560028b9055600480548b841690831617905560058990556006805492891692909116919091179055831561080057845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b600454600090600160a01b900460ff16156108285750600090565b6002546000036108385750600090565b60025442116108475750600090565b600154600354106108585750600090565b50600190565b6004546000906001600160a01b031661087657504790565b600480546040516370a0823160e01b815230928101929092526001600160a01b0316906370a0823190602401602060405180830381865afa1580156108bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e391906112bf565b905090565b6108f0610d70565b6004546001600160a01b03161561091a5760405163c1ab6dc160e01b815260040160405180910390fd5b3460000361093b57604051631f2a200560e01b815260040160405180910390fd5b6002541580159061094d575060025442115b1561096b5760405163387b2e5560e11b815260040160405180910390fd5b600454600160a01b900460ff161561099657604051631897796360e21b815260040160405180910390fd5b61099f33610f8b565b33600090815260076020526040812080543492906109be9084906112d8565b9250508190555034600360008282546109d791906112d8565b90915550506040805134815242602082015233917f4928895ba6723e8e27b15f32e4c3054a1b6c7f8c03f133558d6fa42b3928d14c910160405180910390a260015460035410610a5d57600354604080519182524260208301527f85b3ed4e45559c5f41fb220aa4ac86a440dfc741f219089de694242940aaa09c910160405180910390a15b6103f6600160008051602061131b83398151915255565b610a7c610d70565b610a84610da8565b80600003610aa557604051637862e95960e01b815260040160405180910390fd5b600854600a548111610aca5760405163571ee64360e01b815260040160405180910390fd5b60005b81600a54108015610add57508281105b15610b475760006008600a5481548110610af957610af96112eb565b6000918252602082200154600a80546001600160a01b0390921693509091610b2083611301565b9190505550610b2e81610e26565b15610b415781610b3d81611301565b9250505b50610acd565b600a546040805183815260208101929092524282820152517f5178c4962565e20ed5b9c5b08dbf83398b41c5b8d3e11ce05a57f9c3882d8b559181900360600190a15050610ba2600160008051602061131b83398151915255565b50565b610bad610d70565b6004546001600160a01b0316610bd65760405163c1ab6dc160e01b815260040160405180910390fd5b80600003610bf757604051631f2a200560e01b815260040160405180910390fd5b60025415801590610c09575060025442115b15610c275760405163387b2e5560e11b815260040160405180910390fd5b600454600160a01b900460ff1615610c5257604051631897796360e21b815260040160405180910390fd5b6004546001600160a01b0316610c6a81333085611011565b610c7333610f8b565b3360009081526007602052604081208054849290610c929084906112d8565b925050819055508160036000828254610cab91906112d8565b90915550506040805183815242602082015233917f4928895ba6723e8e27b15f32e4c3054a1b6c7f8c03f133558d6fa42b3928d14c910160405180910390a260015460035410610d3157600354604080519182524260208301527f85b3ed4e45559c5f41fb220aa4ac86a440dfc741f219089de694242940aaa09c910160405180910390a15b50610ba2600160008051602061131b83398151915255565b600454600090600160a01b900460ff1615610d645750600090565b50600154600354101590565b60008051602061131b833981519152805460011901610da257604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b600454600160a01b900460ff1615610dd357604051631897796360e21b815260040160405180910390fd5b6002541580610de457506002544211155b15610e025760405163387b2e5560e11b815260040160405180910390fd5b600154600354106103f65760405163465c128f60e11b815260040160405180910390fd5b6001600160a01b038116600090815260076020526040812054808203610e4f5750600092915050565b6001600160a01b038316600090815260076020526040812081905560038054839290610e7c9084906112ac565b90915550610e8c90508382611050565b604080518281524260208201526001600160a01b038516917f2dc8e290002f06fc0085bbca9dfb8b415cf4d1178950c72ff9ee8f4d8878ee66910160405180910390a250600192915050565b600160008051602061131b83398151915255565b6040516001600160a01b03838116602483015260448201839052610f4b91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050506110eb565b505050565b6000807ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005b92915050565b610f83611160565b6103f6611185565b6001600160a01b03811660009081526009602052604090205460ff16610ba2576001600160a01b03166000818152600960205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6040516001600160a01b03848116602483015283811660448301526064820183905261104a9186918216906323b872dd90608401610f19565b50505050565b6004546001600160a01b03166110d4576000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146110ad576040519150601f19603f3d011682016040523d82523d6000602084013e6110b2565b606091505b5050905080610f4b576040516312171d8360e31b815260040160405180910390fd5b6004546001600160a01b0316610f4b818484610eec565b600080602060008451602086016000885af18061110e576040513d6000823e3d81fd5b50506000513d91508115611126578060011415611133565b6001600160a01b0384163b155b1561104a57604051635274afe760e01b81526001600160a01b038516600482015260240160405180910390fd5b61116861118d565b6103f657604051631afcd79f60e31b815260040160405180910390fd5b610ed8611160565b6000611197610f50565b54600160401b900460ff16919050565b80356001600160a01b03811681146111be57600080fd5b919050565b6000602082840312156111d557600080fd5b6111de826111a7565b9392505050565b60008060008060008060c087890312156111fe57600080fd5b611207876111a7565b95506020870135945060408701359350611223606088016111a7565b92506080870135915061123860a088016111a7565b90509295509295509295565b60006020828403121561125657600080fd5b5035919050565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610f7557610f7561125d565b6000826112a757634e487b7160e01b600052601260045260246000fd5b500490565b81810381811115610f7557610f7561125d565b6000602082840312156112d157600080fd5b5051919050565b80820180821115610f7557610f7561125d565b634e487b7160e01b600052603260045260246000fd5b6000600182016113135761131361125d565b506001019056fe9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a2646970667358221220f19cbd997b24e347044c68e31c3da79e578f18e593bf9141901f306db159efe464736f6c63430008160033"; + + private static String librariesLinkedBinary; + + public static final String FUNC_ACCEPTEDTOKEN = "acceptedToken"; + + public static final String FUNC_BALANCE = "balance"; + + public static final String FUNC_BENEFICIARY = "beneficiary"; + + public static final String FUNC_CANPAYOUT = "canPayout"; + + public static final String FUNC_CANREFUND = "canRefund"; + + public static final String FUNC_CONTRIBUTIONS = "contributions"; + + public static final String FUNC_DEADLINE = "deadline"; + + public static final String FUNC_DONATE = "donate"; + + public static final String FUNC_DONATENATIVE = "donateNative"; + + public static final String FUNC_GOAL = "goal"; + + public static final String FUNC_INITIALIZE = "initialize"; + + public static final String FUNC_ISEXPIRED = "isExpired"; + + public static final String FUNC_ISGOALREACHED = "isGoalReached"; + + public static final String FUNC_PAIDOUT = "paidOut"; + + public static final String FUNC_PAYOUT = "payout"; + + public static final String FUNC_PLATFORMFEERATE = "platformFeeRate"; + + public static final String FUNC_PLATFORMFEERECIPIENT = "platformFeeRecipient"; + + public static final String FUNC_RAISED = "raised"; + + public static final String FUNC_REFUND = "refund"; + + public static final String FUNC_REFUNDALL = "refundAll"; + + public static final String FUNC_REFUNDCURSOR = "refundCursor"; + +// public static final CustomError ALLREFUNDSPROCESSED_ERROR = new CustomError("AllRefundsProcessed", +// Arrays.>asList()); +// ; +// +// public static final CustomError ALREADYPAIDOUT_ERROR = new CustomError("AlreadyPaidOut", +// Arrays.>asList()); +// ; +// +// public static final CustomError DEADLINEPASSED_ERROR = new CustomError("DeadlinePassed", +// Arrays.>asList()); +// ; +// +// public static final CustomError GOALALREADYREACHED_ERROR = new CustomError("GoalAlreadyReached", +// Arrays.>asList()); +// ; +// +// public static final CustomError GOALNOTREACHED_ERROR = new CustomError("GoalNotReached", +// Arrays.>asList()); +// ; +// +// public static final CustomError INVALIDBATCHSIZE_ERROR = new CustomError("InvalidBatchSize", +// Arrays.>asList()); +// ; +// +// public static final CustomError INVALIDBENEFICIARY_ERROR = new CustomError("InvalidBeneficiary", +// Arrays.>asList()); +// ; +// +// public static final CustomError INVALIDGOAL_ERROR = new CustomError("InvalidGoal", +// Arrays.>asList()); +// ; +// +// public static final CustomError INVALIDINITIALIZATION_ERROR = new CustomError("InvalidInitialization", +// Arrays.>asList()); +// ; +// +// public static final CustomError INVALIDTOKEN_ERROR = new CustomError("InvalidToken", +// Arrays.>asList()); +// ; +// +// public static final CustomError NOCONTRIBUTION_ERROR = new CustomError("NoContribution", +// Arrays.>asList()); +// ; +// +// public static final CustomError NOTINITIALIZING_ERROR = new CustomError("NotInitializing", +// Arrays.>asList()); +// ; +// +// public static final CustomError REENTRANCYGUARDREENTRANTCALL_ERROR = new CustomError("ReentrancyGuardReentrantCall", +// Arrays.>asList()); +// ; +// +// public static final CustomError SAFEERC20FAILEDOPERATION_ERROR = new CustomError("SafeERC20FailedOperation", +// Arrays.>asList(new TypeReference

() {})); +// ; +// +// public static final CustomError TRANSFERFAILED_ERROR = new CustomError("TransferFailed", +// Arrays.>asList()); +// ; +// +// public static final CustomError ZEROAMOUNT_ERROR = new CustomError("ZeroAmount", +// Arrays.>asList()); + ; + + public static final Event DONATED_EVENT = new Event("Donated", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event GOALREACHED_EVENT = new Event("GoalReached", + Arrays.>asList(new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event INITIALIZED_EVENT = new Event("Initialized", + Arrays.>asList(new TypeReference() {})); + ; + + public static final Event PAIDOUT_EVENT = new Event("PaidOut", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event REFUNDBATCHPROCESSED_EVENT = new Event("RefundBatchProcessed", + Arrays.>asList(new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event REFUNDED_EVENT = new Event("Refunded", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference() {}, new TypeReference() {})); + ; + + @Deprecated + protected Campaign(String contractAddress, Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + protected Campaign(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, credentials, contractGasProvider); + } + + @Deprecated + protected Campaign(String contractAddress, Web3j web3j, TransactionManager transactionManager, + BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + protected Campaign(String contractAddress, Web3j web3j, TransactionManager transactionManager, + ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static List getDonatedEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(DONATED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + DonatedEventResponse typedResponse = new DonatedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.donor = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.timestamp = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static DonatedEventResponse getDonatedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(DONATED_EVENT, log); + DonatedEventResponse typedResponse = new DonatedEventResponse(); + typedResponse.log = log; + typedResponse.donor = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.timestamp = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable donatedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getDonatedEventFromLog(log)); + } + + public Flowable donatedEventFlowable(DefaultBlockParameter startBlock, + DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(DONATED_EVENT)); + return donatedEventFlowable(filter); + } + + public static List getGoalReachedEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(GOALREACHED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + GoalReachedEventResponse typedResponse = new GoalReachedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.total = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.timestamp = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static GoalReachedEventResponse getGoalReachedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(GOALREACHED_EVENT, log); + GoalReachedEventResponse typedResponse = new GoalReachedEventResponse(); + typedResponse.log = log; + typedResponse.total = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.timestamp = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable goalReachedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getGoalReachedEventFromLog(log)); + } + + public Flowable goalReachedEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(GOALREACHED_EVENT)); + return goalReachedEventFlowable(filter); + } + + public static List getInitializedEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(INITIALIZED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + InitializedEventResponse typedResponse = new InitializedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.version = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static InitializedEventResponse getInitializedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(INITIALIZED_EVENT, log); + InitializedEventResponse typedResponse = new InitializedEventResponse(); + typedResponse.log = log; + typedResponse.version = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable initializedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getInitializedEventFromLog(log)); + } + + public Flowable initializedEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(INITIALIZED_EVENT)); + return initializedEventFlowable(filter); + } + + public static List getPaidOutEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(PAIDOUT_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + PaidOutEventResponse typedResponse = new PaidOutEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.beneficiary = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.platformFee = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.timestamp = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static PaidOutEventResponse getPaidOutEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(PAIDOUT_EVENT, log); + PaidOutEventResponse typedResponse = new PaidOutEventResponse(); + typedResponse.log = log; + typedResponse.beneficiary = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.platformFee = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.timestamp = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable paidOutEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getPaidOutEventFromLog(log)); + } + + public Flowable paidOutEventFlowable(DefaultBlockParameter startBlock, + DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(PAIDOUT_EVENT)); + return paidOutEventFlowable(filter); + } + + public static List getRefundBatchProcessedEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(REFUNDBATCHPROCESSED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + RefundBatchProcessedEventResponse typedResponse = new RefundBatchProcessedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.processedCount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.nextCursor = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.timestamp = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static RefundBatchProcessedEventResponse getRefundBatchProcessedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(REFUNDBATCHPROCESSED_EVENT, log); + RefundBatchProcessedEventResponse typedResponse = new RefundBatchProcessedEventResponse(); + typedResponse.log = log; + typedResponse.processedCount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.nextCursor = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.timestamp = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable refundBatchProcessedEventFlowable( + EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getRefundBatchProcessedEventFromLog(log)); + } + + public Flowable refundBatchProcessedEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(REFUNDBATCHPROCESSED_EVENT)); + return refundBatchProcessedEventFlowable(filter); + } + + public static List getRefundedEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(REFUNDED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + RefundedEventResponse typedResponse = new RefundedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.donor = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.timestamp = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static RefundedEventResponse getRefundedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(REFUNDED_EVENT, log); + RefundedEventResponse typedResponse = new RefundedEventResponse(); + typedResponse.log = log; + typedResponse.donor = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.timestamp = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable refundedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getRefundedEventFromLog(log)); + } + + public Flowable refundedEventFlowable(DefaultBlockParameter startBlock, + DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(REFUNDED_EVENT)); + return refundedEventFlowable(filter); + } + + public RemoteFunctionCall acceptedToken() { + final Function function = new Function(FUNC_ACCEPTEDTOKEN, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall balance() { + final Function function = new Function(FUNC_BALANCE, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall beneficiary() { + final Function function = new Function(FUNC_BENEFICIARY, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall canPayout() { + final Function function = new Function(FUNC_CANPAYOUT, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall canRefund() { + final Function function = new Function(FUNC_CANREFUND, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall contributions(String param0) { + final Function function = new Function(FUNC_CONTRIBUTIONS, + Arrays.asList(new Address(160, param0)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall deadline() { + final Function function = new Function(FUNC_DEADLINE, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall donate(BigInteger amount) { + final Function function = new Function( + FUNC_DONATE, + Arrays.asList(new Uint256(amount)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall donateNative(BigInteger weiValue) { + final Function function = new Function( + FUNC_DONATENATIVE, + Arrays.asList(), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall goal() { + final Function function = new Function(FUNC_GOAL, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall initialize(String _beneficiary, BigInteger _goal, + BigInteger _deadline, String _acceptedToken, BigInteger _platformFeeRate, + String _platformFeeRecipient) { + final Function function = new Function( + FUNC_INITIALIZE, + Arrays.asList(new Address(160, _beneficiary), + new Uint256(_goal), + new Uint256(_deadline), + new Address(160, _acceptedToken), + new Uint256(_platformFeeRate), + new Address(160, _platformFeeRecipient)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall isExpired() { + final Function function = new Function(FUNC_ISEXPIRED, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall isGoalReached() { + final Function function = new Function(FUNC_ISGOALREACHED, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall paidOut() { + final Function function = new Function(FUNC_PAIDOUT, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall payout() { + final Function function = new Function( + FUNC_PAYOUT, + Arrays.asList(), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall platformFeeRate() { + final Function function = new Function(FUNC_PLATFORMFEERATE, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall platformFeeRecipient() { + final Function function = new Function(FUNC_PLATFORMFEERECIPIENT, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall raised() { + final Function function = new Function(FUNC_RAISED, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall refund() { + final Function function = new Function( + FUNC_REFUND, + Arrays.asList(), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall refundAll(BigInteger batchSize) { + final Function function = new Function( + FUNC_REFUNDALL, + Arrays.asList(new Uint256(batchSize)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall refundCursor() { + final Function function = new Function(FUNC_REFUNDCURSOR, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + @Deprecated + public static Campaign load(String contractAddress, Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { + return new Campaign(contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + @Deprecated + public static Campaign load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + return new Campaign(contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + public static Campaign load(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { + return new Campaign(contractAddress, web3j, credentials, contractGasProvider); + } + + public static Campaign load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + return new Campaign(contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static RemoteCall deploy(Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { + return deployRemoteCall(Campaign.class, web3j, credentials, contractGasProvider, getDeploymentBinary(), ""); + } + + public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, + ContractGasProvider contractGasProvider) { + return deployRemoteCall(Campaign.class, web3j, transactionManager, contractGasProvider, getDeploymentBinary(), ""); + } + + @Deprecated + public static RemoteCall deploy(Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { + return deployRemoteCall(Campaign.class, web3j, credentials, gasPrice, gasLimit, getDeploymentBinary(), ""); + } + + @Deprecated + public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, + BigInteger gasPrice, BigInteger gasLimit) { + return deployRemoteCall(Campaign.class, web3j, transactionManager, gasPrice, gasLimit, getDeploymentBinary(), ""); + } + + public static void linkLibraries(List references) { + librariesLinkedBinary = linkBinaryWithReferences(BINARY, references); + } + + private static String getDeploymentBinary() { + if (librariesLinkedBinary != null) { + return librariesLinkedBinary; + } else { + return BINARY; + } + } + + public static class DonatedEventResponse extends BaseEventResponse { + public String donor; + + public BigInteger amount; + + public BigInteger timestamp; + } + + public static class GoalReachedEventResponse extends BaseEventResponse { + public BigInteger total; + + public BigInteger timestamp; + } + + public static class InitializedEventResponse extends BaseEventResponse { + public BigInteger version; + } + + public static class PaidOutEventResponse extends BaseEventResponse { + public String beneficiary; + + public BigInteger amount; + + public BigInteger platformFee; + + public BigInteger timestamp; + } + + public static class RefundBatchProcessedEventResponse extends BaseEventResponse { + public BigInteger processedCount; + + public BigInteger nextCursor; + + public BigInteger timestamp; + } + + public static class RefundedEventResponse extends BaseEventResponse { + public String donor; + + public BigInteger amount; + + public BigInteger timestamp; + } +} diff --git a/src/main/java/com/donet/donet/global/smartContract/CampaignFactory.java b/src/main/java/com/donet/donet/global/smartContract/CampaignFactory.java new file mode 100644 index 00000000..26bcf501 --- /dev/null +++ b/src/main/java/com/donet/donet/global/smartContract/CampaignFactory.java @@ -0,0 +1,875 @@ +package com.donet.donet.global.smartContract; + +import io.reactivex.Flowable; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.Callable; +import org.web3j.abi.EventEncoder; +import org.web3j.abi.TypeReference; +import org.web3j.abi.datatypes.Address; +import org.web3j.abi.datatypes.Bool; +//import org.web3j.abi.datatypes.CustomError; +import org.web3j.abi.datatypes.DynamicArray; +import org.web3j.abi.datatypes.Event; +import org.web3j.abi.datatypes.Function; +import org.web3j.abi.datatypes.Type; +import org.web3j.abi.datatypes.Utf8String; +import org.web3j.abi.datatypes.generated.Bytes32; +import org.web3j.abi.datatypes.generated.Uint256; +import org.web3j.abi.datatypes.generated.Uint64; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.DefaultBlockParameter; +import org.web3j.protocol.core.RemoteCall; +import org.web3j.protocol.core.RemoteFunctionCall; +import org.web3j.protocol.core.methods.request.EthFilter; +import org.web3j.protocol.core.methods.response.BaseEventResponse; +import org.web3j.protocol.core.methods.response.Log; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import org.web3j.tuples.generated.Tuple9; +import org.web3j.tx.Contract; +import org.web3j.tx.TransactionManager; +import org.web3j.tx.gas.ContractGasProvider; + +/** + *

Auto generated code. + *

Do not modify! + *

Please use the web3j command line tools, + * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the + * codegen module to update. + * + *

Generated with web3j version 1.7.0. + */ +@SuppressWarnings("rawtypes") +public class CampaignFactory extends Contract { + public static final String BINARY = "60a06040523060805234801561001457600080fd5b5061001d610022565b6100d4565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100725760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100d15780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b60805161339d620000fe600039600081816114e7015281816115110152611666015261339d6000f3fe608060405260043610620001be5760003560e01c80638da5cb5b11620000ff578063da35a26f1162000095578063eb13554f116200006c578063eb13554f1462000615578063eeca08f01462000637578063f2fde38b146200064f578063f5fe7f71146200067457600080fd5b8063da35a26f1462000571578063e1231ec51462000596578063e744092e14620005d057600080fd5b806398bf6de811620000d657806398bf6de814620004605780639ca65ab8146200049a578063ad3cb1cc1462000519578063ae3b7f06146200054c57600080fd5b80638da5cb5b14620003d757806393aa61ed1462000416578063975626e9146200043b57600080fd5b806352d1902d11620001755780636caa9218116200014c5780636caa92181462000349578063715018a6146200036057806377321c58146200037857806384fcd2bc146200039d57600080fd5b806352d1902d14620002c657806354fd4d5014620002ed57806362a6e065146200032757600080fd5b80630905156614620001c35780630a920cb91462000200578063141961bc1462000225578063363f6ff814620002635780633dd25f9914620002885780634f1ef28614620002af575b600080fd5b348015620001d057600080fd5b50620001e8620001e236600462001a44565b62000699565b604051620001f7919062001a67565b60405180910390f35b3480156200020d57600080fd5b50620001e86200021f36600462001acc565b620007c5565b3480156200023257600080fd5b506200024a6200024436600462001aec565b6200083d565b6040516001600160a01b039091168152602001620001f7565b3480156200027057600080fd5b506200024a6200028236600462001b06565b62000868565b3480156200029557600080fd5b50620002ad620002a736600462001bb0565b62000a6a565b005b620002ad620002c036600462001c39565b62000bf0565b348015620002d357600080fd5b50620002de62000c15565b604051908152602001620001f7565b348015620002fa57600080fd5b506040805180820190915260058152640312e302e360dc1b60208201525b604051620001f7919062001d2f565b3480156200033457600080fd5b506000546200024a906001600160a01b031681565b3480156200035657600080fd5b50600454620002de565b3480156200036d57600080fd5b50620002ad62000c35565b3480156200038557600080fd5b50620002ad6200039736600462001acc565b62000c4d565b348015620003aa57600080fd5b50620002de620003bc36600462001acc565b6001600160a01b031660009081526006602052604090205490565b348015620003e457600080fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b03166200024a565b3480156200042357600080fd5b50620002ad6200043536600462001d73565b62000ce1565b3480156200044857600080fd5b506200024a6200045a36600462001db1565b62000d4a565b3480156200046d57600080fd5b506200024a6200047f36600462001aec565b6005602052600090815260409020546001600160a01b031681565b348015620004a757600080fd5b50620004bf620004b936600462001acc565b62000d83565b604080516001600160a01b039a8b16815260208101999099528801969096526060870194909452959091166080850152151560a084015292151560c083015291151560e082015290151561010082015261012001620001f7565b3480156200052657600080fd5b5062000318604051806040016040528060058152602001640352e302e360dc1b81525081565b3480156200055957600080fd5b50620002ad6200056b36600462001aec565b62001142565b3480156200057e57600080fd5b50620002ad6200059036600462001de0565b620011af565b348015620005a357600080fd5b506200024a620005b536600462001aec565b6000908152600560205260409020546001600160a01b031690565b348015620005dd57600080fd5b5062000604620005ef36600462001acc565b60036020526000908152604090205460ff1681565b6040519015158152602001620001f7565b3480156200062257600080fd5b506002546200024a906001600160a01b031681565b3480156200064457600080fd5b50620002de60015481565b3480156200065c57600080fd5b50620002ad6200066e36600462001acc565b6200139e565b3480156200068157600080fd5b50620002ad6200069336600462001acc565b620013e2565b6004546060908310620006bc5750604080516000815260208101909152620007bf565b6000620006ca838562001e1e565b600454909150811115620006dd57506004545b6000620006eb858362001e34565b905060008167ffffffffffffffff8111156200070b576200070b62001c23565b60405190808252806020026020018201604052801562000735578160200160208202803683370190505b50905060005b82811015620007b957600462000752828962001e1e565b8154811062000765576200076562001e4a565b9060005260206000200160009054906101000a90046001600160a01b031682828151811062000798576200079862001e4a565b6001600160a01b03909216602092830291909101909101526001016200073b565b50925050505b92915050565b6001600160a01b0381166000908152600660209081526040918290208054835181840281018401909452808452606093928301828280156200083157602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831162000812575b50505050509050919050565b600481815481106200084e57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000620008746200146f565b6001600160a01b03821660009081526003602052604090205460ff16620008ae5760405163514e24c360e11b815260040160405180910390fd5b6000868152600560205260409020546001600160a01b031615620008e557604051637e31d8a360e01b815260040160405180910390fd5b600054620008fc906001600160a01b0316620014cd565b600154600254604051636845516b60e01b81526001600160a01b03898116600483015260248201899052604482018890528681166064830152608482019390935290821660a4820152919250821690636845516b9060c401600060405180830381600087803b1580156200096f57600080fd5b505af115801562000984573d6000803e3d6000fd5b50506004805460018082019092557f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0180546001600160a01b038681166001600160a01b0319928316811790935560008c815260056020908152604080832080548616871790558d841680845260068352818420805498890181558452928290209096018054909416851790935584518b81529283018a905290881693820193909352426060820152919350915088907f9f585125d57c208dc1a2dd6af25b0bed44ee6be72157997cfc421320b551defb9060800160405180910390a495945050505050565b62000a746200146f565b82811462000abb5760405162461bcd60e51b815260206004820152600f60248201526e098cadccee8d040dad2e6dac2e8c6d608b1b60448201526064015b60405180910390fd5b60005b8381101562000be95782828281811062000adc5762000adc62001e4a565b905060200201602081019062000af3919062001e60565b6003600087878581811062000b0c5762000b0c62001e4a565b905060200201602081019062000b23919062001acc565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905584848281811062000b605762000b6062001e4a565b905060200201602081019062000b77919062001acc565b6001600160a01b03167f826a6c33b9617800a065940671c098354c7803a6c578f4894be72bead330235d84848481811062000bb65762000bb662001e4a565b905060200201602081019062000bcd919062001e60565b604051901515815260200160405180910390a260010162000abe565b5050505050565b62000bfa620014dc565b62000c058262001585565b62000c1182826200158f565b5050565b600062000c216200165b565b506000805160206200334883398151915290565b62000c3f6200146f565b62000c4b6000620016a5565b565b62000c576200146f565b6001600160a01b03811662000c7f5760405163340aafcd60e11b815260040160405180910390fd5b600080546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527fecb67f84d4ac8c3c40a86a0fe2cc78920f164c7acd55770db1e6b8b8fd29131391015b60405180910390a15050565b62000ceb6200146f565b6001600160a01b038216600081815260036020908152604091829020805460ff191685151590811790915591519182527f826a6c33b9617800a065940671c098354c7803a6c578f4894be72bead330235d910160405180910390a25050565b6006602052816000526040600020818154811062000d6757600080fd5b6000918252602090912001546001600160a01b03169150829050565b6000806000806000806000806000808a9050806001600160a01b03166338af3eed6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000dd4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000dfa919062001e80565b816001600160a01b031663401938836040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000e39573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000e5f919062001ea0565b826001600160a01b03166329dcb0cf6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000e9e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000ec4919062001ea0565b836001600160a01b031663f0ea4bfc6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000f03573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000f29919062001ea0565b846001600160a01b031663451c3d806040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000f68573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000f8e919062001e80565b856001600160a01b0316635c76ca2d6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000fcd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000ff3919062001eba565b866001600160a01b031663d3eb6f616040518163ffffffff1660e01b8152600401602060405180830381865afa15801562001032573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001058919062001eba565b876001600160a01b0316637f83a4a66040518163ffffffff1660e01b8152600401602060405180830381865afa15801562001097573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620010bd919062001eba565b886001600160a01b031663ff203bc06040518163ffffffff1660e01b8152600401602060405180830381865afa158015620010fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001122919062001eba565b995099509950995099509950995099509950509193959799909294969850565b6200114c6200146f565b6103e88111156200117057604051630adad23360e31b815260040160405180910390fd5b600180549082905560408051828152602081018490527fa82b850e6100ae23c7e82adbdcf4da8a3740c1540a6241792521a80179a892dc910162000cd5565b6000620011bb62001716565b805490915060ff600160401b820416159067ffffffffffffffff16600081158015620011e45750825b905060008267ffffffffffffffff166001148015620012025750303b155b90508115801562001211575080155b15620012305760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156200125b57845460ff60401b1916600160401b1785555b6103e88711156200127f57604051630adad23360e31b815260040160405180910390fd5b6001600160a01b038616620012a757604051634e46966960e11b815260040160405180910390fd5b620012b23362001740565b620012bc62001755565b604051620012ca9062001a36565b604051809103906000f080158015620012e7573d6000803e3d6000fd5b50600080546001600160a01b03199081166001600160a01b0393841617825560018a815560028054909216938a16939093179055805260036020527f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff805460ff1916909117905583156200139557845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b620013a86200146f565b6001600160a01b038116620013d457604051631e4fbdf760e01b81526000600482015260240162000ab2565b620013df81620016a5565b50565b620013ec6200146f565b6001600160a01b0381166200141457604051634e46966960e11b815260040160405180910390fd5b600280546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527faf04973bb8004e313cfd09017b963bee1e6f6ffb9be88c07a0c5ce5fafe93403910162000cd5565b33620014a27f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b03161462000c4b5760405163118cdaa760e01b815233600482015260240162000ab2565b6000620007bf8260006200175f565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614806200156657507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166200155a60008051602062003348833981519152546001600160a01b031690565b6001600160a01b031614155b1562000c4b5760405163703e46dd60e11b815260040160405180910390fd5b620013df6200146f565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015620015ec575060408051601f3d908101601f19168201909252620015e99181019062001ea0565b60015b6200161657604051634c9c8ce360e01b81526001600160a01b038316600482015260240162000ab2565b6000805160206200334883398151915281146200164a57604051632a87526960e21b81526004810182905260240162000ab2565b620016568383620017f8565b505050565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161462000c4b5760405163703e46dd60e11b815260040160405180910390fd5b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b6000807ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00620007bf565b6200174a62001855565b620013df816200187d565b62000c4b62001855565b6000814710156200178d5760405163cf47918160e01b81524760048201526024810183905260440162000ab2565b763d602d80600a3d3981f3363d3d373d3d3d363d730000008360601b60e81c176000526e5af43d82803e903d91602b57fd5bf38360781b176020526037600983f090506001600160a01b038116620007bf5760405163b06ebf3d60e01b815260040160405180910390fd5b620018038262001887565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a28051156200184b57620016568282620018ef565b62000c116200196b565b6200185f6200198b565b62000c4b57604051631afcd79f60e31b815260040160405180910390fd5b620013a862001855565b806001600160a01b03163b600003620018bf57604051634c9c8ce360e01b81526001600160a01b038216600482015260240162000ab2565b6000805160206200334883398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b0316846040516200190e919062001eda565b600060405180830381855af49150503d80600081146200194b576040519150601f19603f3d011682016040523d82523d6000602084013e62001950565b606091505b509150915062001962858383620019a7565b95945050505050565b341562000c4b5760405163b398979f60e01b815260040160405180910390fd5b60006200199762001716565b54600160401b900460ff16919050565b606082620019c057620019ba8262001a0d565b62001a06565b8151158015620019d857506001600160a01b0384163b155b1562001a0357604051639996b31560e01b81526001600160a01b038516600482015260240162000ab2565b50805b9392505050565b80511562001a1d57805160208201fd5b60405163d6bda27560e01b815260040160405180910390fd5b61144f8062001ef983390190565b6000806040838503121562001a5857600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b8181101562001aaa5783516001600160a01b03168352928401929184019160010162001a83565b50909695505050505050565b6001600160a01b0381168114620013df57600080fd5b60006020828403121562001adf57600080fd5b813562001a068162001ab6565b60006020828403121562001aff57600080fd5b5035919050565b600080600080600060a0868803121562001b1f57600080fd5b85359450602086013562001b338162001ab6565b93506040860135925060608601359150608086013562001b538162001ab6565b809150509295509295909350565b60008083601f84011262001b7457600080fd5b50813567ffffffffffffffff81111562001b8d57600080fd5b6020830191508360208260051b850101111562001ba957600080fd5b9250929050565b6000806000806040858703121562001bc757600080fd5b843567ffffffffffffffff8082111562001be057600080fd5b62001bee8883890162001b61565b9096509450602087013591508082111562001c0857600080fd5b5062001c178782880162001b61565b95989497509550505050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121562001c4d57600080fd5b823562001c5a8162001ab6565b9150602083013567ffffffffffffffff8082111562001c7857600080fd5b818501915085601f83011262001c8d57600080fd5b81358181111562001ca25762001ca262001c23565b604051601f8201601f19908116603f0116810190838211818310171562001ccd5762001ccd62001c23565b8160405282815288602084870101111562001ce757600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60005b8381101562001d2657818101518382015260200162001d0c565b50506000910152565b602081526000825180602084015262001d5081604085016020870162001d09565b601f01601f19169190910160400192915050565b8015158114620013df57600080fd5b6000806040838503121562001d8757600080fd5b823562001d948162001ab6565b9150602083013562001da68162001d64565b809150509250929050565b6000806040838503121562001dc557600080fd5b823562001dd28162001ab6565b946020939093013593505050565b6000806040838503121562001df457600080fd5b82359150602083013562001da68162001ab6565b634e487b7160e01b600052601160045260246000fd5b80820180821115620007bf57620007bf62001e08565b81810381811115620007bf57620007bf62001e08565b634e487b7160e01b600052603260045260246000fd5b60006020828403121562001e7357600080fd5b813562001a068162001d64565b60006020828403121562001e9357600080fd5b815162001a068162001ab6565b60006020828403121562001eb357600080fd5b5051919050565b60006020828403121562001ecd57600080fd5b815162001a068162001d64565b6000825162001eee81846020870162001d09565b919091019291505056fe608060405234801561001057600080fd5b5061001961001e565b6100d0565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161561006e5760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100cd5780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b611370806100df6000396000f3fe60806040526004361061012a5760003560e01c80637f83a4a6116100ab578063e9fee16f1161006f578063e9fee16f146102e7578063eb13554f14610307578063eeca08f014610327578063f0ea4bfc1461033d578063f14faf6f14610353578063ff203bc01461037357600080fd5b80637f83a4a614610285578063b69ef8a81461029a578063b907b846146102af578063c806a067146102c5578063d3eb6f61146102cd57600080fd5b8063451c3d80116100f2578063451c3d80146101f8578063590e1ae3146102185780635c76ca2d1461022f57806363bd1d4a146102505780636845516b1461026557600080fd5b806329dcb0cf1461012f5780632f13b60c1461015857806338af3eed1461017d57806340193883146101b557806342e94c90146101cb575b600080fd5b34801561013b57600080fd5b5061014560025481565b6040519081526020015b60405180910390f35b34801561016457600080fd5b5061016d610388565b604051901515815260200161014f565b34801561018957600080fd5b5060005461019d906001600160a01b031681565b6040516001600160a01b03909116815260200161014f565b3480156101c157600080fd5b5061014560015481565b3480156101d757600080fd5b506101456101e63660046111c3565b60076020526000908152604090205481565b34801561020457600080fd5b5060045461019d906001600160a01b031681565b34801561022457600080fd5b5061022d6103a3565b005b34801561023b57600080fd5b5060045461016d90600160a01b900460ff1681565b34801561025c57600080fd5b5061022d6103f8565b34801561027157600080fd5b5061022d6102803660046111e5565b610679565b34801561029157600080fd5b5061016d61080d565b3480156102a657600080fd5b5061014561085e565b3480156102bb57600080fd5b50610145600a5481565b61022d6108e8565b3480156102d957600080fd5b50600154600354101561016d565b3480156102f357600080fd5b5061022d610302366004611244565b610a74565b34801561031357600080fd5b5060065461019d906001600160a01b031681565b34801561033357600080fd5b5061014560055481565b34801561034957600080fd5b5061014560035481565b34801561035f57600080fd5b5061022d61036e366004611244565b610ba5565b34801561037f57600080fd5b5061016d610d49565b600060025460000361039a5750600090565b50600254421190565b6103ab610d70565b6103b3610da8565b60006103be33610e26565b9050806103de57604051631971fbf360e21b815260040160405180910390fd5b506103f6600160008051602061131b83398151915255565b565b610400610d70565b600454600160a01b900460ff161561042b57604051631897796360e21b815260040160405180910390fd5b6001546003541015610450576040516378c754c960e01b815260040160405180910390fd5b6004805460ff60a01b1916600160a01b1790556005546003546000916127109161047a9190611273565b610484919061128a565b905060008160035461049691906112ac565b6004549091506001600160a01b03166105b857600080546040516001600160a01b039091169083908381818185875af1925050503d80600081146104f6576040519150601f19603f3d011682016040523d82523d6000602084013e6104fb565b606091505b505090508061051d576040516312171d8360e31b815260040160405180910390fd5b60008311801561053757506006546001600160a01b031615155b156105b2576006546040516000916001600160a01b03169085908381818185875af1925050503d8060008114610589576040519150601f19603f3d011682016040523d82523d6000602084013e61058e565b606091505b50509050806105b0576040516312171d8360e31b815260040160405180910390fd5b505b50610612565b6004546000546001600160a01b03918216916105d79183911684610eec565b6000831180156105f157506006546001600160a01b031615155b1561061057600654610610906001600160a01b03838116911685610eec565b505b6000546040805183815260208101859052428183015290516001600160a01b03909216917f807c2c73192f2d30961a7d01ec8dc57115a4cd9f9bd0434331beacb916c6a8cc9181900360600190a250506103f6600160008051602061131b83398151915255565b6000610683610f50565b805490915060ff600160401b820416159067ffffffffffffffff166000811580156106ab5750825b905060008267ffffffffffffffff1660011480156106c85750303b155b9050811580156106d6575080155b156106f45760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561071e57845460ff60401b1916600160401b1785555b6001600160a01b038b1661074557604051631559b7d760e21b815260040160405180910390fd5b8960000361076657604051639b60eb4d60e01b815260040160405180910390fd5b61076e610f7b565b600080546001600160a01b03808e166001600160a01b03199283161790925560018c905560028b9055600480548b841690831617905560058990556006805492891692909116919091179055831561080057845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b600454600090600160a01b900460ff16156108285750600090565b6002546000036108385750600090565b60025442116108475750600090565b600154600354106108585750600090565b50600190565b6004546000906001600160a01b031661087657504790565b600480546040516370a0823160e01b815230928101929092526001600160a01b0316906370a0823190602401602060405180830381865afa1580156108bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e391906112bf565b905090565b6108f0610d70565b6004546001600160a01b03161561091a5760405163c1ab6dc160e01b815260040160405180910390fd5b3460000361093b57604051631f2a200560e01b815260040160405180910390fd5b6002541580159061094d575060025442115b1561096b5760405163387b2e5560e11b815260040160405180910390fd5b600454600160a01b900460ff161561099657604051631897796360e21b815260040160405180910390fd5b61099f33610f8b565b33600090815260076020526040812080543492906109be9084906112d8565b9250508190555034600360008282546109d791906112d8565b90915550506040805134815242602082015233917f4928895ba6723e8e27b15f32e4c3054a1b6c7f8c03f133558d6fa42b3928d14c910160405180910390a260015460035410610a5d57600354604080519182524260208301527f85b3ed4e45559c5f41fb220aa4ac86a440dfc741f219089de694242940aaa09c910160405180910390a15b6103f6600160008051602061131b83398151915255565b610a7c610d70565b610a84610da8565b80600003610aa557604051637862e95960e01b815260040160405180910390fd5b600854600a548111610aca5760405163571ee64360e01b815260040160405180910390fd5b60005b81600a54108015610add57508281105b15610b475760006008600a5481548110610af957610af96112eb565b6000918252602082200154600a80546001600160a01b0390921693509091610b2083611301565b9190505550610b2e81610e26565b15610b415781610b3d81611301565b9250505b50610acd565b600a546040805183815260208101929092524282820152517f5178c4962565e20ed5b9c5b08dbf83398b41c5b8d3e11ce05a57f9c3882d8b559181900360600190a15050610ba2600160008051602061131b83398151915255565b50565b610bad610d70565b6004546001600160a01b0316610bd65760405163c1ab6dc160e01b815260040160405180910390fd5b80600003610bf757604051631f2a200560e01b815260040160405180910390fd5b60025415801590610c09575060025442115b15610c275760405163387b2e5560e11b815260040160405180910390fd5b600454600160a01b900460ff1615610c5257604051631897796360e21b815260040160405180910390fd5b6004546001600160a01b0316610c6a81333085611011565b610c7333610f8b565b3360009081526007602052604081208054849290610c929084906112d8565b925050819055508160036000828254610cab91906112d8565b90915550506040805183815242602082015233917f4928895ba6723e8e27b15f32e4c3054a1b6c7f8c03f133558d6fa42b3928d14c910160405180910390a260015460035410610d3157600354604080519182524260208301527f85b3ed4e45559c5f41fb220aa4ac86a440dfc741f219089de694242940aaa09c910160405180910390a15b50610ba2600160008051602061131b83398151915255565b600454600090600160a01b900460ff1615610d645750600090565b50600154600354101590565b60008051602061131b833981519152805460011901610da257604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b600454600160a01b900460ff1615610dd357604051631897796360e21b815260040160405180910390fd5b6002541580610de457506002544211155b15610e025760405163387b2e5560e11b815260040160405180910390fd5b600154600354106103f65760405163465c128f60e11b815260040160405180910390fd5b6001600160a01b038116600090815260076020526040812054808203610e4f5750600092915050565b6001600160a01b038316600090815260076020526040812081905560038054839290610e7c9084906112ac565b90915550610e8c90508382611050565b604080518281524260208201526001600160a01b038516917f2dc8e290002f06fc0085bbca9dfb8b415cf4d1178950c72ff9ee8f4d8878ee66910160405180910390a250600192915050565b600160008051602061131b83398151915255565b6040516001600160a01b03838116602483015260448201839052610f4b91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050506110eb565b505050565b6000807ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005b92915050565b610f83611160565b6103f6611185565b6001600160a01b03811660009081526009602052604090205460ff16610ba2576001600160a01b03166000818152600960205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6040516001600160a01b03848116602483015283811660448301526064820183905261104a9186918216906323b872dd90608401610f19565b50505050565b6004546001600160a01b03166110d4576000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146110ad576040519150601f19603f3d011682016040523d82523d6000602084013e6110b2565b606091505b5050905080610f4b576040516312171d8360e31b815260040160405180910390fd5b6004546001600160a01b0316610f4b818484610eec565b600080602060008451602086016000885af18061110e576040513d6000823e3d81fd5b50506000513d91508115611126578060011415611133565b6001600160a01b0384163b155b1561104a57604051635274afe760e01b81526001600160a01b038516600482015260240160405180910390fd5b61116861118d565b6103f657604051631afcd79f60e31b815260040160405180910390fd5b610ed8611160565b6000611197610f50565b54600160401b900460ff16919050565b80356001600160a01b03811681146111be57600080fd5b919050565b6000602082840312156111d557600080fd5b6111de826111a7565b9392505050565b60008060008060008060c087890312156111fe57600080fd5b611207876111a7565b95506020870135945060408701359350611223606088016111a7565b92506080870135915061123860a088016111a7565b90509295509295509295565b60006020828403121561125657600080fd5b5035919050565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610f7557610f7561125d565b6000826112a757634e487b7160e01b600052601260045260246000fd5b500490565b81810381811115610f7557610f7561125d565b6000602082840312156112d157600080fd5b5051919050565b80820180821115610f7557610f7561125d565b634e487b7160e01b600052603260045260246000fd5b6000600182016113135761131361125d565b506001019056fe9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a2646970667358221220f19cbd997b24e347044c68e31c3da79e578f18e593bf9141901f306db159efe464736f6c63430008160033360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca264697066735822122079a2abf16ccc857c813004fe1d68ecfb7d15ff3783271162854565f62958a69464736f6c63430008160033"; + + private static String librariesLinkedBinary; + + public static final String FUNC_UPGRADE_INTERFACE_VERSION = "UPGRADE_INTERFACE_VERSION"; + + public static final String FUNC_ALLOWEDTOKENS = "allowedTokens"; + + public static final String FUNC_CAMPAIGNBYID = "campaignById"; + + public static final String FUNC_CAMPAIGNIMPLEMENTATION = "campaignImplementation"; + + public static final String FUNC_CAMPAIGNS = "campaigns"; + + public static final String FUNC_CAMPAIGNSBYBENEFICIARY = "campaignsByBeneficiary"; + + public static final String FUNC_CREATECAMPAIGN = "createCampaign"; + + public static final String FUNC_GETCAMPAIGNADDRESS = "getCampaignAddress"; + + public static final String FUNC_GETCAMPAIGNCOUNT = "getCampaignCount"; + + public static final String FUNC_GETCAMPAIGNCOUNTBYBENEFICIARY = "getCampaignCountByBeneficiary"; + + public static final String FUNC_GETCAMPAIGNDETAILS = "getCampaignDetails"; + + public static final String FUNC_GETCAMPAIGNS = "getCampaigns"; + + public static final String FUNC_GETCAMPAIGNSBYBENEFICIARY = "getCampaignsByBeneficiary"; + + public static final String FUNC_INITIALIZE = "initialize"; + + public static final String FUNC_OWNER = "owner"; + + public static final String FUNC_PLATFORMFEERATE = "platformFeeRate"; + + public static final String FUNC_PLATFORMFEERECIPIENT = "platformFeeRecipient"; + + public static final String FUNC_PROXIABLEUUID = "proxiableUUID"; + + public static final String FUNC_RENOUNCEOWNERSHIP = "renounceOwnership"; + + public static final String FUNC_SETTOKENALLOWANCE = "setTokenAllowance"; + + public static final String FUNC_SETTOKENALLOWANCEBATCH = "setTokenAllowanceBatch"; + + public static final String FUNC_TRANSFEROWNERSHIP = "transferOwnership"; + + public static final String FUNC_UPDATECAMPAIGNIMPLEMENTATION = "updateCampaignImplementation"; + + public static final String FUNC_UPDATEPLATFORMFEERATE = "updatePlatformFeeRate"; + + public static final String FUNC_UPDATEPLATFORMFEERECIPIENT = "updatePlatformFeeRecipient"; + + public static final String FUNC_UPGRADETOANDCALL = "upgradeToAndCall"; + + public static final String FUNC_VERSION = "version"; + +// public static final CustomError ADDRESSEMPTYCODE_ERROR = new CustomError("AddressEmptyCode", +// Arrays.>asList(new TypeReference

() {})); +// ; +// +// public static final CustomError CAMPAIGNALREADYEXISTS_ERROR = new CustomError("CampaignAlreadyExists", +// Arrays.>asList()); +// ; +// +// public static final CustomError ERC1967INVALIDIMPLEMENTATION_ERROR = new CustomError("ERC1967InvalidImplementation", +// Arrays.>asList(new TypeReference
() {})); +// ; +// +// public static final CustomError ERC1967NONPAYABLE_ERROR = new CustomError("ERC1967NonPayable", +// Arrays.>asList()); +// ; +// +// public static final CustomError FAILEDCALL_ERROR = new CustomError("FailedCall", +// Arrays.>asList()); +// ; +// +// public static final CustomError FAILEDDEPLOYMENT_ERROR = new CustomError("FailedDeployment", +// Arrays.>asList()); +// ; +// +// public static final CustomError INSUFFICIENTBALANCE_ERROR = new CustomError("InsufficientBalance", +// Arrays.>asList(new TypeReference() {}, new TypeReference() {})); +// ; +// +// public static final CustomError INVALIDFEERATE_ERROR = new CustomError("InvalidFeeRate", +// Arrays.>asList()); +// ; +// +// public static final CustomError INVALIDIMPLEMENTATION_ERROR = new CustomError("InvalidImplementation", +// Arrays.>asList()); +// ; +// +// public static final CustomError INVALIDINITIALIZATION_ERROR = new CustomError("InvalidInitialization", +// Arrays.>asList()); +// ; +// +// public static final CustomError INVALIDRECIPIENT_ERROR = new CustomError("InvalidRecipient", +// Arrays.>asList()); +// ; +// +// public static final CustomError NOTINITIALIZING_ERROR = new CustomError("NotInitializing", +// Arrays.>asList()); +// ; +// +// public static final CustomError OWNABLEINVALIDOWNER_ERROR = new CustomError("OwnableInvalidOwner", +// Arrays.>asList(new TypeReference
() {})); +// ; +// +// public static final CustomError OWNABLEUNAUTHORIZEDACCOUNT_ERROR = new CustomError("OwnableUnauthorizedAccount", +// Arrays.>asList(new TypeReference
() {})); +// ; +// +// public static final CustomError TOKENNOTALLOWED_ERROR = new CustomError("TokenNotAllowed", +// Arrays.>asList()); +// ; +// +// public static final CustomError UUPSUNAUTHORIZEDCALLCONTEXT_ERROR = new CustomError("UUPSUnauthorizedCallContext", +// Arrays.>asList()); +// ; +// +// public static final CustomError UUPSUNSUPPORTEDPROXIABLEUUID_ERROR = new CustomError("UUPSUnsupportedProxiableUUID", +// Arrays.>asList(new TypeReference() {})); + ; + + public static final Event CAMPAIGNCREATED_EVENT = new Event("CampaignCreated", + Arrays.>asList(new TypeReference(true) {}, new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {}, new TypeReference() {}, new TypeReference
() {}, new TypeReference() {})); + ; + + public static final Event CAMPAIGNIMPLEMENTATIONUPDATED_EVENT = new Event("CampaignImplementationUpdated", + Arrays.>asList(new TypeReference
() {}, new TypeReference
() {})); + ; + + public static final Event INITIALIZED_EVENT = new Event("Initialized", + Arrays.>asList(new TypeReference() {})); + ; + + public static final Event OWNERSHIPTRANSFERRED_EVENT = new Event("OwnershipTransferred", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {})); + ; + + public static final Event PLATFORMFEERATEUPDATED_EVENT = new Event("PlatformFeeRateUpdated", + Arrays.>asList(new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event PLATFORMFEERECIPIENTUPDATED_EVENT = new Event("PlatformFeeRecipientUpdated", + Arrays.>asList(new TypeReference
() {}, new TypeReference
() {})); + ; + + public static final Event TOKENALLOWANCEUPDATED_EVENT = new Event("TokenAllowanceUpdated", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference() {})); + ; + + public static final Event UPGRADED_EVENT = new Event("Upgraded", + Arrays.>asList(new TypeReference
(true) {})); + ; + + @Deprecated + protected CampaignFactory(String contractAddress, Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + protected CampaignFactory(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, credentials, contractGasProvider); + } + + @Deprecated + protected CampaignFactory(String contractAddress, Web3j web3j, + TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + protected CampaignFactory(String contractAddress, Web3j web3j, + TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static List getCampaignCreatedEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(CAMPAIGNCREATED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + CampaignCreatedEventResponse typedResponse = new CampaignCreatedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.campaignId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.campaignAddress = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.beneficiary = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.goal = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.deadline = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.acceptedToken = (String) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.timestamp = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static CampaignCreatedEventResponse getCampaignCreatedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(CAMPAIGNCREATED_EVENT, log); + CampaignCreatedEventResponse typedResponse = new CampaignCreatedEventResponse(); + typedResponse.log = log; + typedResponse.campaignId = (BigInteger) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.campaignAddress = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.beneficiary = (String) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.goal = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.deadline = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.acceptedToken = (String) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.timestamp = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); + return typedResponse; + } + + public Flowable campaignCreatedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getCampaignCreatedEventFromLog(log)); + } + + public Flowable campaignCreatedEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(CAMPAIGNCREATED_EVENT)); + return campaignCreatedEventFlowable(filter); + } + + public static List getCampaignImplementationUpdatedEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(CAMPAIGNIMPLEMENTATIONUPDATED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + CampaignImplementationUpdatedEventResponse typedResponse = new CampaignImplementationUpdatedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.oldImplementation = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.newImplementation = (String) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static CampaignImplementationUpdatedEventResponse getCampaignImplementationUpdatedEventFromLog( + Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(CAMPAIGNIMPLEMENTATIONUPDATED_EVENT, log); + CampaignImplementationUpdatedEventResponse typedResponse = new CampaignImplementationUpdatedEventResponse(); + typedResponse.log = log; + typedResponse.oldImplementation = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.newImplementation = (String) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable campaignImplementationUpdatedEventFlowable( + EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getCampaignImplementationUpdatedEventFromLog(log)); + } + + public Flowable campaignImplementationUpdatedEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(CAMPAIGNIMPLEMENTATIONUPDATED_EVENT)); + return campaignImplementationUpdatedEventFlowable(filter); + } + + public static List getInitializedEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(INITIALIZED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + InitializedEventResponse typedResponse = new InitializedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.version = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static InitializedEventResponse getInitializedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(INITIALIZED_EVENT, log); + InitializedEventResponse typedResponse = new InitializedEventResponse(); + typedResponse.log = log; + typedResponse.version = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable initializedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getInitializedEventFromLog(log)); + } + + public Flowable initializedEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(INITIALIZED_EVENT)); + return initializedEventFlowable(filter); + } + + public static List getOwnershipTransferredEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(OWNERSHIPTRANSFERRED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + OwnershipTransferredEventResponse typedResponse = new OwnershipTransferredEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.previousOwner = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newOwner = (String) eventValues.getIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static OwnershipTransferredEventResponse getOwnershipTransferredEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(OWNERSHIPTRANSFERRED_EVENT, log); + OwnershipTransferredEventResponse typedResponse = new OwnershipTransferredEventResponse(); + typedResponse.log = log; + typedResponse.previousOwner = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.newOwner = (String) eventValues.getIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable ownershipTransferredEventFlowable( + EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getOwnershipTransferredEventFromLog(log)); + } + + public Flowable ownershipTransferredEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(OWNERSHIPTRANSFERRED_EVENT)); + return ownershipTransferredEventFlowable(filter); + } + + public static List getPlatformFeeRateUpdatedEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(PLATFORMFEERATEUPDATED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + PlatformFeeRateUpdatedEventResponse typedResponse = new PlatformFeeRateUpdatedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.oldRate = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.newRate = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static PlatformFeeRateUpdatedEventResponse getPlatformFeeRateUpdatedEventFromLog( + Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(PLATFORMFEERATEUPDATED_EVENT, log); + PlatformFeeRateUpdatedEventResponse typedResponse = new PlatformFeeRateUpdatedEventResponse(); + typedResponse.log = log; + typedResponse.oldRate = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.newRate = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable platformFeeRateUpdatedEventFlowable( + EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getPlatformFeeRateUpdatedEventFromLog(log)); + } + + public Flowable platformFeeRateUpdatedEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(PLATFORMFEERATEUPDATED_EVENT)); + return platformFeeRateUpdatedEventFlowable(filter); + } + + public static List getPlatformFeeRecipientUpdatedEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(PLATFORMFEERECIPIENTUPDATED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + PlatformFeeRecipientUpdatedEventResponse typedResponse = new PlatformFeeRecipientUpdatedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.oldRecipient = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.newRecipient = (String) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static PlatformFeeRecipientUpdatedEventResponse getPlatformFeeRecipientUpdatedEventFromLog( + Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(PLATFORMFEERECIPIENTUPDATED_EVENT, log); + PlatformFeeRecipientUpdatedEventResponse typedResponse = new PlatformFeeRecipientUpdatedEventResponse(); + typedResponse.log = log; + typedResponse.oldRecipient = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.newRecipient = (String) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable platformFeeRecipientUpdatedEventFlowable( + EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getPlatformFeeRecipientUpdatedEventFromLog(log)); + } + + public Flowable platformFeeRecipientUpdatedEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(PLATFORMFEERECIPIENTUPDATED_EVENT)); + return platformFeeRecipientUpdatedEventFlowable(filter); + } + + public static List getTokenAllowanceUpdatedEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(TOKENALLOWANCEUPDATED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + TokenAllowanceUpdatedEventResponse typedResponse = new TokenAllowanceUpdatedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.token = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.allowed = (Boolean) eventValues.getNonIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static TokenAllowanceUpdatedEventResponse getTokenAllowanceUpdatedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(TOKENALLOWANCEUPDATED_EVENT, log); + TokenAllowanceUpdatedEventResponse typedResponse = new TokenAllowanceUpdatedEventResponse(); + typedResponse.log = log; + typedResponse.token = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.allowed = (Boolean) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable tokenAllowanceUpdatedEventFlowable( + EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getTokenAllowanceUpdatedEventFromLog(log)); + } + + public Flowable tokenAllowanceUpdatedEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(TOKENALLOWANCEUPDATED_EVENT)); + return tokenAllowanceUpdatedEventFlowable(filter); + } + + public static List getUpgradedEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(UPGRADED_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (EventValuesWithLog eventValues : valueList) { + UpgradedEventResponse typedResponse = new UpgradedEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.implementation = (String) eventValues.getIndexedValues().get(0).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static UpgradedEventResponse getUpgradedEventFromLog(Log log) { + EventValuesWithLog eventValues = staticExtractEventParametersWithLog(UPGRADED_EVENT, log); + UpgradedEventResponse typedResponse = new UpgradedEventResponse(); + typedResponse.log = log; + typedResponse.implementation = (String) eventValues.getIndexedValues().get(0).getValue(); + return typedResponse; + } + + public Flowable upgradedEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getUpgradedEventFromLog(log)); + } + + public Flowable upgradedEventFlowable(DefaultBlockParameter startBlock, + DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(UPGRADED_EVENT)); + return upgradedEventFlowable(filter); + } + + public RemoteFunctionCall UPGRADE_INTERFACE_VERSION() { + final Function function = new Function(FUNC_UPGRADE_INTERFACE_VERSION, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall allowedTokens(String param0) { + final Function function = new Function(FUNC_ALLOWEDTOKENS, + Arrays.asList(new Address(160, param0)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, Boolean.class); + } + + public RemoteFunctionCall campaignById(BigInteger param0) { + final Function function = new Function(FUNC_CAMPAIGNBYID, + Arrays.asList(new Uint256(param0)), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall campaignImplementation() { + final Function function = new Function(FUNC_CAMPAIGNIMPLEMENTATION, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall campaigns(BigInteger param0) { + final Function function = new Function(FUNC_CAMPAIGNS, + Arrays.asList(new Uint256(param0)), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall campaignsByBeneficiary(String param0, BigInteger param1) { + final Function function = new Function(FUNC_CAMPAIGNSBYBENEFICIARY, + Arrays.asList(new Address(160, param0), + new Uint256(param1)), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall createCampaign(BigInteger campaignId, + String beneficiary, BigInteger goal, BigInteger deadline, String acceptedToken) { + final Function function = new Function( + FUNC_CREATECAMPAIGN, + Arrays.asList(new Uint256(campaignId), + new Address(160, beneficiary), + new Uint256(goal), + new Uint256(deadline), + new Address(160, acceptedToken)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall getCampaignAddress(BigInteger campaignId) { + final Function function = new Function(FUNC_GETCAMPAIGNADDRESS, + Arrays.asList(new Uint256(campaignId)), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall getCampaignCount() { + final Function function = new Function(FUNC_GETCAMPAIGNCOUNT, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall getCampaignCountByBeneficiary(String beneficiary) { + final Function function = new Function(FUNC_GETCAMPAIGNCOUNTBYBENEFICIARY, + Arrays.asList(new Address(160, beneficiary)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall> getCampaignDetails( + String campaignAddress) { + final Function function = new Function(FUNC_GETCAMPAIGNDETAILS, + Arrays.asList(new Address(160, campaignAddress)), + Arrays.>asList(new TypeReference
() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference
() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + return new RemoteFunctionCall>(function, + new Callable>() { + @Override + public Tuple9 call( + ) throws Exception { + List results = executeCallMultipleValueReturn(function); + return new Tuple9( + (String) results.get(0).getValue(), + (BigInteger) results.get(1).getValue(), + (BigInteger) results.get(2).getValue(), + (BigInteger) results.get(3).getValue(), + (String) results.get(4).getValue(), + (Boolean) results.get(5).getValue(), + (Boolean) results.get(6).getValue(), + (Boolean) results.get(7).getValue(), + (Boolean) results.get(8).getValue()); + } + }); + } + + public RemoteFunctionCall getCampaigns(BigInteger offset, BigInteger limit) { + final Function function = new Function(FUNC_GETCAMPAIGNS, + Arrays.asList(new Uint256(offset), + new Uint256(limit)), + Arrays.>asList(new TypeReference>() {})); + return new RemoteFunctionCall(function, + new Callable() { + @Override + @SuppressWarnings("unchecked") + public List call() throws Exception { + List result = (List) executeCallSingleValueReturn(function, List.class); + return convertToNative(result); + } + }); + } + + public RemoteFunctionCall getCampaignsByBeneficiary(String beneficiary) { + final Function function = new Function(FUNC_GETCAMPAIGNSBYBENEFICIARY, + Arrays.asList(new Address(160, beneficiary)), + Arrays.>asList(new TypeReference>() {})); + return new RemoteFunctionCall(function, + new Callable() { + @Override + @SuppressWarnings("unchecked") + public List call() throws Exception { + List result = (List) executeCallSingleValueReturn(function, List.class); + return convertToNative(result); + } + }); + } + + public RemoteFunctionCall initialize(BigInteger _platformFeeRate, + String _platformFeeRecipient) { + final Function function = new Function( + FUNC_INITIALIZE, + Arrays.asList(new Uint256(_platformFeeRate), + new Address(160, _platformFeeRecipient)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall owner() { + final Function function = new Function(FUNC_OWNER, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall platformFeeRate() { + final Function function = new Function(FUNC_PLATFORMFEERATE, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall platformFeeRecipient() { + final Function function = new Function(FUNC_PLATFORMFEERECIPIENT, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall proxiableUUID() { + final Function function = new Function(FUNC_PROXIABLEUUID, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, byte[].class); + } + + public RemoteFunctionCall renounceOwnership() { + final Function function = new Function( + FUNC_RENOUNCEOWNERSHIP, + Arrays.asList(), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall setTokenAllowance(String token, Boolean allowed) { + final Function function = new Function( + FUNC_SETTOKENALLOWANCE, + Arrays.asList(new Address(160, token), + new Bool(allowed)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall setTokenAllowanceBatch(List tokens, + List allowed) { + final Function function = new Function( + FUNC_SETTOKENALLOWANCEBATCH, + Arrays.asList(new DynamicArray
( + Address.class, + org.web3j.abi.Utils.typeMap(tokens, Address.class)), + new DynamicArray( + Bool.class, + org.web3j.abi.Utils.typeMap(allowed, Bool.class))), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall transferOwnership(String newOwner) { + final Function function = new Function( + FUNC_TRANSFEROWNERSHIP, + Arrays.asList(new Address(160, newOwner)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall updateCampaignImplementation( + String newImplementation) { + final Function function = new Function( + FUNC_UPDATECAMPAIGNIMPLEMENTATION, + Arrays.asList(new Address(160, newImplementation)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall updatePlatformFeeRate(BigInteger newRate) { + final Function function = new Function( + FUNC_UPDATEPLATFORMFEERATE, + Arrays.asList(new Uint256(newRate)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall updatePlatformFeeRecipient(String newRecipient) { + final Function function = new Function( + FUNC_UPDATEPLATFORMFEERECIPIENT, + Arrays.asList(new Address(160, newRecipient)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall upgradeToAndCall(String newImplementation, + byte[] data, BigInteger weiValue) { + final Function function = new Function( + FUNC_UPGRADETOANDCALL, + Arrays.asList(new Address(160, newImplementation), + new org.web3j.abi.datatypes.DynamicBytes(data)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function, weiValue); + } + + public RemoteFunctionCall version() { + final Function function = new Function(FUNC_VERSION, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + @Deprecated + public static CampaignFactory load(String contractAddress, Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { + return new CampaignFactory(contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + @Deprecated + public static CampaignFactory load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + return new CampaignFactory(contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + public static CampaignFactory load(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { + return new CampaignFactory(contractAddress, web3j, credentials, contractGasProvider); + } + + public static CampaignFactory load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + return new CampaignFactory(contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static RemoteCall deploy(Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { + return deployRemoteCall(CampaignFactory.class, web3j, credentials, contractGasProvider, getDeploymentBinary(), ""); + } + + public static RemoteCall deploy(Web3j web3j, + TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + return deployRemoteCall(CampaignFactory.class, web3j, transactionManager, contractGasProvider, getDeploymentBinary(), ""); + } + + @Deprecated + public static RemoteCall deploy(Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { + return deployRemoteCall(CampaignFactory.class, web3j, credentials, gasPrice, gasLimit, getDeploymentBinary(), ""); + } + + @Deprecated + public static RemoteCall deploy(Web3j web3j, + TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + return deployRemoteCall(CampaignFactory.class, web3j, transactionManager, gasPrice, gasLimit, getDeploymentBinary(), ""); + } + + public static void linkLibraries(List references) { + librariesLinkedBinary = linkBinaryWithReferences(BINARY, references); + } + + private static String getDeploymentBinary() { + if (librariesLinkedBinary != null) { + return librariesLinkedBinary; + } else { + return BINARY; + } + } + + public static class CampaignCreatedEventResponse extends BaseEventResponse { + public BigInteger campaignId; + + public String campaignAddress; + + public String beneficiary; + + public BigInteger goal; + + public BigInteger deadline; + + public String acceptedToken; + + public BigInteger timestamp; + } + + public static class CampaignImplementationUpdatedEventResponse extends BaseEventResponse { + public String oldImplementation; + + public String newImplementation; + } + + public static class InitializedEventResponse extends BaseEventResponse { + public BigInteger version; + } + + public static class OwnershipTransferredEventResponse extends BaseEventResponse { + public String previousOwner; + + public String newOwner; + } + + public static class PlatformFeeRateUpdatedEventResponse extends BaseEventResponse { + public BigInteger oldRate; + + public BigInteger newRate; + } + + public static class PlatformFeeRecipientUpdatedEventResponse extends BaseEventResponse { + public String oldRecipient; + + public String newRecipient; + } + + public static class TokenAllowanceUpdatedEventResponse extends BaseEventResponse { + public String token; + + public Boolean allowed; + } + + public static class UpgradedEventResponse extends BaseEventResponse { + public String implementation; + } +} diff --git a/src/main/java/com/donet/donet/global/smartContract/SmartContractAdapter.java b/src/main/java/com/donet/donet/global/smartContract/SmartContractAdapter.java new file mode 100644 index 00000000..ffd8af80 --- /dev/null +++ b/src/main/java/com/donet/donet/global/smartContract/SmartContractAdapter.java @@ -0,0 +1,64 @@ +package com.donet.donet.global.smartContract; + +import com.donet.donet.donation.application.port.out.SmartContractPort; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import org.web3j.protocol.Web3j; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import org.web3j.tx.gas.ContractGasProvider; + +import java.math.BigInteger; +import java.util.List; + +@Component +@RequiredArgsConstructor +public class SmartContractAdapter implements SmartContractPort { + + private final CampaignFactory campaignFactory; + private final Web3j web3j; + private final Credentials credentials; + private final ContractGasProvider gasProvider; + + @Override + public boolean refundDonations(List donationIds) { + + try { + for (Long donationId : donationIds) { + + // 1. Factory에서 donationId로 캠페인 주소 조회 + String campaignAddress = campaignFactory + .getCampaignAddress(BigInteger.valueOf(donationId)) + .send(); + + if (campaignAddress == null || campaignAddress.isBlank() || "0x0000000000000000000000000000000000000000".equalsIgnoreCase(campaignAddress)) { + throw new IllegalStateException("Campaign address not found for donationId=" + donationId); + } + + // 2. 해당 주소로 Campaign 컨트랙트 인스턴스 로딩 + Campaign campaign = Campaign.load( + campaignAddress, + web3j, + credentials, + gasProvider + ); + + // 3. Donation ID 기반 환불 트랜잭션 실행 + TransactionReceipt tx = campaign.refund().send(); + + // 4. 실패 여부 확인 + if (!tx.isStatusOK()) { + throw new RuntimeException("Refund transaction failed: " + tx.getTransactionHash()); + } + + System.out.println("Refund success for donationId=" + donationId + + " / tx=" + tx.getTransactionHash()); + } + return true; + + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } +} diff --git a/src/main/java/com/donet/donet/global/smartContract/Web3jConfig.java b/src/main/java/com/donet/donet/global/smartContract/Web3jConfig.java new file mode 100644 index 00000000..cdd9107b --- /dev/null +++ b/src/main/java/com/donet/donet/global/smartContract/Web3jConfig.java @@ -0,0 +1,60 @@ +package com.donet.donet.global.smartContract; + +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.http.HttpService; +import org.web3j.tx.gas.ContractGasProvider; +import org.web3j.tx.gas.StaticGasProvider; + +import java.math.BigInteger; + +@Profile("!test") +@Configuration +@RequiredArgsConstructor +public class Web3jConfig { + + @Value("${web3.rpcUrl}") + private String rpcUrl; + + @Value("${web3.privateKey}") + private String privateKey; + + @Value("${web3.gasPrice}") + private BigInteger gasPrice; + + @Value("${web3.gasLimit}") + private BigInteger gasLimit; + + // 이미 배포되어 있는 CampaignFactory의 on-chain 주소 + @Value("${contracts.campaignFactoryAddress}") + private String campaignFactoryAddress; + + @Bean + public Web3j web3j() { + return Web3j.build(new HttpService(rpcUrl)); + } + + @Bean + public Credentials credentials() { + return Credentials.create(privateKey); + } + + @Bean + public ContractGasProvider contractGasProvider() { + return new StaticGasProvider(gasPrice, gasLimit); + } + + @Bean + public CampaignFactory campaignFactory( + Web3j web3j, + Credentials credentials, + ContractGasProvider gasProvider + ) { + return CampaignFactory.load(campaignFactoryAddress, web3j, credentials, gasProvider); + } +} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d58b4a75..4329b842 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -94,3 +94,12 @@ management: show-details: "always" # 상세 정보 포함 server: port: 8080 + +web3: + rpcUrl: ${RPC_URL} + privateKey: ${CONTRACT_PRIVATE_KEY} + gasPrice: ${GAS_PRICE} + gasLimit: ${GAS_LIMIT} + +contracts: + campaignFactoryAddress: ${CONTRACT_ADDRESS} diff --git a/src/test/java/com/donet/donet/global/config/Web3jTestConfig.java b/src/test/java/com/donet/donet/global/config/Web3jTestConfig.java new file mode 100644 index 00000000..b8e079ed --- /dev/null +++ b/src/test/java/com/donet/donet/global/config/Web3jTestConfig.java @@ -0,0 +1,39 @@ +package com.donet.donet.global.config; + +import com.donet.donet.global.smartContract.CampaignFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.Web3j; +import org.web3j.tx.gas.ContractGasProvider; + +import static org.mockito.Mockito.mock; + +@Profile("test") +@Configuration +public class Web3jTestConfig { + @Bean + public Web3j web3j() { + return mock(Web3j.class); + } + + @Bean + public Credentials credentials() { + return mock(Credentials.class); + } + + @Bean + public ContractGasProvider contractGasProvider() { + return mock(ContractGasProvider.class); + } + + @Bean + public CampaignFactory campaignFactory( + Web3j web3j, + Credentials credentials, + ContractGasProvider gasProvider + ) { + return mock(CampaignFactory.class); + } +} \ No newline at end of file