org.web3j.tx.Contract Java Examples

The following examples show how to use org.web3j.tx.Contract. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultOnChainPrivacyGroupManagementContract.java    From besu with Apache License 2.0 6 votes vote down vote up
public Flowable<ParticipantAddedEventResponse> participantAddedEventFlowable(EthFilter filter) {
  return web3j
      .ethLogFlowable(filter)
      .map(
          new Function<Log, ParticipantAddedEventResponse>() {
            @Override
            public ParticipantAddedEventResponse apply(Log log) {
              Contract.EventValuesWithLog eventValues =
                  extractEventParametersWithLog(PARTICIPANTADDED_EVENT, log);
              ParticipantAddedEventResponse typedResponse = new ParticipantAddedEventResponse();
              typedResponse.log = log;
              typedResponse.adminAdded =
                  (Boolean) eventValues.getNonIndexedValues().get(0).getValue();
              typedResponse.account =
                  (byte[]) eventValues.getNonIndexedValues().get(1).getValue();
              typedResponse.message =
                  (String) eventValues.getNonIndexedValues().get(2).getValue();
              return typedResponse;
            }
          });
}
 
Example #2
Source File: DepositContract.java    From teku with Apache License 2.0 6 votes vote down vote up
public List<DepositEventEventResponse> getDepositEventEvents(
    TransactionReceipt transactionReceipt) {
  List<Contract.EventValuesWithLog> valueList =
      extractEventParametersWithLog(DEPOSITEVENT_EVENT, transactionReceipt);
  ArrayList<DepositEventEventResponse> responses =
      new ArrayList<DepositEventEventResponse>(valueList.size());
  for (Contract.EventValuesWithLog eventValues : valueList) {
    DepositEventEventResponse typedResponse = new DepositEventEventResponse();
    typedResponse.log = eventValues.getLog();
    typedResponse.pubkey = (byte[]) eventValues.getNonIndexedValues().get(0).getValue();
    typedResponse.withdrawal_credentials =
        (byte[]) eventValues.getNonIndexedValues().get(1).getValue();
    typedResponse.amount = (byte[]) eventValues.getNonIndexedValues().get(2).getValue();
    typedResponse.signature = (byte[]) eventValues.getNonIndexedValues().get(3).getValue();
    typedResponse.index = (byte[]) eventValues.getNonIndexedValues().get(4).getValue();
    responses.add(typedResponse);
  }
  return responses;
}
 
Example #3
Source File: OnChainPrivacyAcceptanceTest.java    From besu with Apache License 2.0 6 votes vote down vote up
private <T extends Contract> T deployPrivateContract(
    final Class<T> clazz, final String privacyGroupId, final PrivacyNode sender) {
  final T contract =
      sender.execute(
          privateContractTransactions.createSmartContractWithPrivacyGroupId(
              clazz,
              sender.getTransactionSigningKey(),
              POW_CHAIN_ID,
              sender.getEnclaveKey(),
              privacyGroupId));

  privateContractVerifier
      .validPrivateContractDeployed(contract.getContractAddress(), sender.getAddress().toString())
      .verify(contract);

  return contract;
}
 
Example #4
Source File: SolidityFunctionWrapper.java    From client-sdk-java with Apache License 2.0 6 votes vote down vote up
Iterable<FieldSpec> buildFuncNameConstants(List<AbiDefinition> functionDefinitions) {
    List<FieldSpec> fields = new ArrayList<>();
    Set<String> fieldNames = new HashSet<>();
    fieldNames.add(Contract.FUNC_DEPLOY);

    for (AbiDefinition functionDefinition : functionDefinitions) {
        if (functionDefinition.getType().equals("function")) {
            String funcName = functionDefinition.getName();

            if (!fieldNames.contains(funcName)) {
                FieldSpec field = FieldSpec.builder(String.class,
                        funcNameToConst(funcName),
                        Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
                        .initializer("$S", funcName)
                        .build();
                fields.add(field);
                fieldNames.add(funcName);
            }
        }
    }
    return fields;
}
 
Example #5
Source File: EventEmitter.java    From eventeum with Apache License 2.0 6 votes vote down vote up
public Flowable<DummyEventAdditionalTypesEventResponse> dummyEventAdditionalTypesEventFlowable(EthFilter filter) {
    return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, DummyEventAdditionalTypesEventResponse>() {
        @Override
        public DummyEventAdditionalTypesEventResponse apply(Log log) {
            Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(DUMMYEVENTADDITIONALTYPES_EVENT, log);
            DummyEventAdditionalTypesEventResponse typedResponse = new DummyEventAdditionalTypesEventResponse();
            typedResponse.log = log;
            typedResponse.uint16Value = (BigInteger) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.int64Value = (BigInteger) eventValues.getIndexedValues().get(1).getValue();
            typedResponse.addressArray = (List<String>) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.byteValue = (byte[]) eventValues.getNonIndexedValues().get(1).getValue();
            typedResponse.boolValue = (Boolean) eventValues.getNonIndexedValues().get(2).getValue();
            return typedResponse;
        }
    });
}
 
Example #6
Source File: CrossContractReader.java    From besu with Apache License 2.0 6 votes vote down vote up
public Flowable<NewEventEmitterEventResponse> newEventEmitterEventFlowable(
    final EthFilter filter) {
  return web3j
      .ethLogFlowable(filter)
      .map(
          new io.reactivex.functions.Function<Log, NewEventEmitterEventResponse>() {
            @Override
            public NewEventEmitterEventResponse apply(final Log log) {
              Contract.EventValuesWithLog eventValues =
                  extractEventParametersWithLog(NEWEVENTEMITTER_EVENT, log);
              NewEventEmitterEventResponse typedResponse = new NewEventEmitterEventResponse();
              typedResponse.log = log;
              typedResponse.contractAddress =
                  (String) eventValues.getNonIndexedValues().get(0).getValue();
              return typedResponse;
            }
          });
}
 
Example #7
Source File: Template.java    From tutorials with MIT License 6 votes vote down vote up
private void deployContract() throws Exception{

        Web3j web3j = Web3j.build(new HttpService("https://rinkeby.infura.io/<your_token>"));

        Credentials credentials =
            WalletUtils.loadCredentials(
               "<password>",
               "/path/to/<walletfile>");

        Greeting contract = Greeting.deploy(
            web3j, credentials,
            ManagedTransaction.GAS_PRICE, Contract.GAS_LIMIT,
            "Hello blockchain world!").send();

        String contractAddress = contract.getContractAddress();
        l.debug("Smart contract deployed to address "+ contractAddress);

        l.debug("Value stored in remote smart contract: "+ contract.greet().send());

        TransactionReceipt transactionReceipt = contract.setGreeting("Well hello again").send();

        l.debug("New value stored in remote smart contract: "+ contract.greet().send());
    }
 
Example #8
Source File: EventEmitter.java    From besu with Apache License 2.0 6 votes vote down vote up
public Flowable<StoredEventResponse> storedEventFlowable(final EthFilter filter) {
  return web3j
      .ethLogFlowable(filter)
      .map(
          new io.reactivex.functions.Function<Log, StoredEventResponse>() {
            @Override
            public StoredEventResponse apply(final Log log) {
              Contract.EventValuesWithLog eventValues =
                  extractEventParametersWithLog(STORED_EVENT, log);
              StoredEventResponse typedResponse = new StoredEventResponse();
              typedResponse.log = log;
              typedResponse._to = (String) eventValues.getNonIndexedValues().get(0).getValue();
              typedResponse._amount =
                  (BigInteger) eventValues.getNonIndexedValues().get(1).getValue();
              return typedResponse;
            }
          });
}
 
Example #9
Source File: ExpectValidPrivateContractDeployedReceipt.java    From besu with Apache License 2.0 6 votes vote down vote up
@Override
public void verify(final Contract contract) {

  assertThat(contract).isNotNull();
  final Optional<TransactionReceipt> receipt = contract.getTransactionReceipt();

  // We're expecting a receipt
  assertThat(receipt).isNotNull();
  assertThat(receipt.isPresent()).isTrue();
  final TransactionReceipt transactionReceipt = receipt.get();

  assertThat(transactionReceipt.isStatusOK()).isTrue();

  // Contract transaction has no 'to' address or contract address
  assertThat(transactionReceipt.getTo()).isNull();

  // Address generation is deterministic, based on the sender address and the transaction nonce
  assertThat(transactionReceipt.getContractAddress()).isEqualTo(contractAddress);

  // Address for the account that signed (and paid) for the contract deployment transaction
  assertThat(transactionReceipt.getFrom()).isEqualTo(senderAddress);
}
 
Example #10
Source File: EventEmitter.java    From eventeum with Apache License 2.0 6 votes vote down vote up
public Flowable<DummyEventNotOrderedEventResponse> dummyEventNotOrderedEventFlowable(EthFilter filter) {
    return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, DummyEventNotOrderedEventResponse>() {
        @Override
        public DummyEventNotOrderedEventResponse apply(Log log) {
            Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(DUMMYEVENTNOTORDERED_EVENT, log);
            DummyEventNotOrderedEventResponse typedResponse = new DummyEventNotOrderedEventResponse();
            typedResponse.log = log;
            typedResponse.indexedBytes = (byte[]) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.indexedAddress = (String) eventValues.getIndexedValues().get(1).getValue();
            typedResponse.uintValue = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.stringValue = (String) eventValues.getNonIndexedValues().get(1).getValue();
            typedResponse.enumValue = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue();
            return typedResponse;
        }
    });
}
 
Example #11
Source File: Web3Service.java    From tutorials with MIT License 6 votes vote down vote up
public String fromScratchContractExample() {

        String contractAddress = "";

        try {
            //Create a wallet
            WalletUtils.generateNewWalletFile("PASSWORD", new File("/path/to/destination"), true);
            //Load the credentials from it
            Credentials credentials = WalletUtils.loadCredentials("PASSWORD", "/path/to/walletfile");

            //Deploy contract to address specified by wallet
            Example contract = Example.deploy(this.web3j,
                    credentials,
                    ManagedTransaction.GAS_PRICE,
                    Contract.GAS_LIMIT).send();

            //Het the address
            contractAddress = contract.getContractAddress();

        } catch (Exception ex) {
            System.out.println(PLEASE_SUPPLY_REAL_DATA);
            return PLEASE_SUPPLY_REAL_DATA;
        }
        return contractAddress;
    }
 
Example #12
Source File: SolidityFunctionWrapperGenerator.java    From web3j with Apache License 2.0 6 votes vote down vote up
public SolidityFunctionWrapperGenerator(
        File binFile,
        File abiFile,
        File destinationDir,
        String contractName,
        String basePackageName,
        boolean useJavaNativeTypes,
        boolean useJavaPrimitiveTypes,
        int addressLength) {

    this(
            binFile,
            abiFile,
            destinationDir,
            contractName,
            basePackageName,
            useJavaNativeTypes,
            useJavaPrimitiveTypes,
            false,
            Contract.class,
            addressLength);
}
 
Example #13
Source File: MetaCoin.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
public List<TransferEventResponse> getTransferEvents(TransactionReceipt transactionReceipt) {
    List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt);
    ArrayList<TransferEventResponse> responses = new ArrayList<TransferEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        TransferEventResponse typedResponse = new TransferEventResponse();
        typedResponse.log = eventValues.getLog();
        typedResponse._from = (String) eventValues.getIndexedValues().get(0).getValue();
        typedResponse._to = (String) eventValues.getIndexedValues().get(1).getValue();
        typedResponse._value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #14
Source File: MetaCoin.java    From web3j with Apache License 2.0 5 votes vote down vote up
public List<TransferEventResponse> getTransferEvents(TransactionReceipt transactionReceipt) {
    List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt);
    ArrayList<TransferEventResponse> responses = new ArrayList<TransferEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        TransferEventResponse typedResponse = new TransferEventResponse();
        typedResponse.log = eventValues.getLog();
        typedResponse._from = (String) eventValues.getIndexedValues().get(0).getValue();
        typedResponse._to = (String) eventValues.getIndexedValues().get(1).getValue();
        typedResponse._value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #15
Source File: ERC721.java    From web3j with Apache License 2.0 5 votes vote down vote up
public List<TransferEventResponse> getTransferEvents(TransactionReceipt transactionReceipt) {
    List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt);
    ArrayList<TransferEventResponse> responses = new ArrayList<TransferEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        TransferEventResponse typedResponse = new TransferEventResponse();
        typedResponse.log = eventValues.getLog();
        typedResponse._from = (String) eventValues.getIndexedValues().get(0).getValue();
        typedResponse._to = (String) eventValues.getIndexedValues().get(1).getValue();
        typedResponse._tokenId = (BigInteger) eventValues.getIndexedValues().get(2).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #16
Source File: SimpleAuction.java    From web3j with Apache License 2.0 5 votes vote down vote up
public Flowable<AuctionEndedEventResponse> auctionEndedEventFlowable(EthFilter filter) {
    return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, AuctionEndedEventResponse>() {
        @Override
        public AuctionEndedEventResponse apply(Log log) {
            Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(AUCTIONENDED_EVENT, log);
            AuctionEndedEventResponse typedResponse = new AuctionEndedEventResponse();
            typedResponse.log = log;
            typedResponse.winner = (String) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue();
            return typedResponse;
        }
    });
}
 
Example #17
Source File: SimpleAuction.java    From web3j with Apache License 2.0 5 votes vote down vote up
public List<AuctionEndedEventResponse> getAuctionEndedEvents(TransactionReceipt transactionReceipt) {
    List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(AUCTIONENDED_EVENT, transactionReceipt);
    ArrayList<AuctionEndedEventResponse> responses = new ArrayList<AuctionEndedEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        AuctionEndedEventResponse typedResponse = new AuctionEndedEventResponse();
        typedResponse.log = eventValues.getLog();
        typedResponse.winner = (String) eventValues.getNonIndexedValues().get(0).getValue();
        typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #18
Source File: MetaCoin.java    From web3j with Apache License 2.0 5 votes vote down vote up
public Flowable<TransferEventResponse> transferEventFlowable(EthFilter filter) {
    return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, TransferEventResponse>() {
        @Override
        public TransferEventResponse apply(Log log) {
            Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(TRANSFER_EVENT, log);
            TransferEventResponse typedResponse = new TransferEventResponse();
            typedResponse.log = log;
            typedResponse._from = (String) eventValues.getIndexedValues().get(0).getValue();
            typedResponse._to = (String) eventValues.getIndexedValues().get(1).getValue();
            typedResponse._value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            return typedResponse;
        }
    });
}
 
Example #19
Source File: PublicResolver.java    From web3j with Apache License 2.0 5 votes vote down vote up
public List<PubkeyChangedEventResponse> getPubkeyChangedEvents(TransactionReceipt transactionReceipt) {
    List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(PUBKEYCHANGED_EVENT, transactionReceipt);
    ArrayList<PubkeyChangedEventResponse> responses = new ArrayList<PubkeyChangedEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        PubkeyChangedEventResponse typedResponse = new PubkeyChangedEventResponse();
        typedResponse.log = eventValues.getLog();
        typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
        typedResponse.x = (byte[]) eventValues.getNonIndexedValues().get(0).getValue();
        typedResponse.y = (byte[]) eventValues.getNonIndexedValues().get(1).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #20
Source File: ERC721.java    From web3j with Apache License 2.0 5 votes vote down vote up
public Flowable<ApprovalForAllEventResponse> approvalForAllEventFlowable(EthFilter filter) {
    return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, ApprovalForAllEventResponse>() {
        @Override
        public ApprovalForAllEventResponse apply(Log log) {
            Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(APPROVALFORALL_EVENT, log);
            ApprovalForAllEventResponse typedResponse = new ApprovalForAllEventResponse();
            typedResponse.log = log;
            typedResponse._owner = (String) eventValues.getIndexedValues().get(0).getValue();
            typedResponse._operator = (String) eventValues.getIndexedValues().get(1).getValue();
            typedResponse._approved = (Boolean) eventValues.getNonIndexedValues().get(0).getValue();
            return typedResponse;
        }
    });
}
 
Example #21
Source File: EventEmitter.java    From eventeum with Apache License 2.0 5 votes vote down vote up
public Flowable<DummyEventBytes16EventResponse> dummyEventBytes16EventFlowable(EthFilter filter) {
    return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, DummyEventBytes16EventResponse>() {
        @Override
        public DummyEventBytes16EventResponse apply(Log log) {
            Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(DUMMYEVENTBYTES16_EVENT, log);
            DummyEventBytes16EventResponse typedResponse = new DummyEventBytes16EventResponse();
            typedResponse.log = log;
            typedResponse.indexedBytes16 = (byte[]) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.bytes16Value = (byte[]) eventValues.getNonIndexedValues().get(0).getValue();
            return typedResponse;
        }
    });
}
 
Example #22
Source File: SolidityFunctionWrapper.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
private TypeSpec.Builder createClassBuilder(String className, String binary) {

        String javadoc = CODEGEN_WARNING + getWeb3jVersion();

        return TypeSpec.classBuilder(className)
                .addModifiers(Modifier.PUBLIC)
                .addJavadoc(javadoc)
                .superclass(Contract.class)
                .addField(createBinaryDefinition(binary));
    }
 
Example #23
Source File: PublicResolver.java    From web3j with Apache License 2.0 5 votes vote down vote up
public List<NameChangedEventResponse> getNameChangedEvents(TransactionReceipt transactionReceipt) {
    List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NAMECHANGED_EVENT, transactionReceipt);
    ArrayList<NameChangedEventResponse> responses = new ArrayList<NameChangedEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        NameChangedEventResponse typedResponse = new NameChangedEventResponse();
        typedResponse.log = eventValues.getLog();
        typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
        typedResponse.name = (String) eventValues.getNonIndexedValues().get(0).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #24
Source File: ERC20.java    From web3j with Apache License 2.0 5 votes vote down vote up
public List<ApprovalEventResponse> getApprovalEvents(TransactionReceipt transactionReceipt) {
    List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(APPROVAL_EVENT, transactionReceipt);
    ArrayList<ApprovalEventResponse> responses = new ArrayList<ApprovalEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        ApprovalEventResponse typedResponse = new ApprovalEventResponse();
        typedResponse.log = eventValues.getLog();
        typedResponse._owner = (String) eventValues.getIndexedValues().get(0).getValue();
        typedResponse._spender = (String) eventValues.getIndexedValues().get(1).getValue();
        typedResponse._value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #25
Source File: Purchase.java    From web3j with Apache License 2.0 5 votes vote down vote up
public List<PurchaseConfirmedEventResponse> getPurchaseConfirmedEvents(TransactionReceipt transactionReceipt) {
    List<EventValuesWithLog> valueList = extractEventParametersWithLog(PURCHASECONFIRMED_EVENT, transactionReceipt);
    ArrayList<PurchaseConfirmedEventResponse> responses = new ArrayList<PurchaseConfirmedEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        PurchaseConfirmedEventResponse typedResponse = new PurchaseConfirmedEventResponse();
        typedResponse.log = eventValues.getLog();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #26
Source File: FunctionWrapperGenerator.java    From web3j with Apache License 2.0 5 votes vote down vote up
FunctionWrapperGenerator(
        Class<? extends Contract> contractClass,
        File destinationDirLocation,
        String basePackageName,
        boolean useJavaNativeTypes,
        boolean useJavaPrimitiveTypes) {

    this.destinationDirLocation = destinationDirLocation;
    this.basePackageName = basePackageName;
    this.useJavaNativeTypes = useJavaNativeTypes;
    this.useJavaPrimitiveTypes = useJavaPrimitiveTypes;
    this.contractClass = contractClass;
}
 
Example #27
Source File: ENS.java    From web3j with Apache License 2.0 5 votes vote down vote up
public List<NewResolverEventResponse> getNewResolverEvents(TransactionReceipt transactionReceipt) {
    List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWRESOLVER_EVENT, transactionReceipt);
    ArrayList<NewResolverEventResponse> responses = new ArrayList<NewResolverEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        NewResolverEventResponse typedResponse = new NewResolverEventResponse();
        typedResponse.log = eventValues.getLog();
        typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
        typedResponse.resolver = (String) eventValues.getNonIndexedValues().get(0).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #28
Source File: Purchase.java    From web3j with Apache License 2.0 5 votes vote down vote up
public Flowable<PurchaseConfirmedEventResponse> purchaseConfirmedEventFlowable(EthFilter filter) {
    return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, PurchaseConfirmedEventResponse>() {
        @Override
        public PurchaseConfirmedEventResponse apply(Log log) {
            Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(PURCHASECONFIRMED_EVENT, log);
            PurchaseConfirmedEventResponse typedResponse = new PurchaseConfirmedEventResponse();
            typedResponse.log = log;
            return typedResponse;
        }
    });
}
 
Example #29
Source File: PublicResolver.java    From web3j with Apache License 2.0 5 votes vote down vote up
public List<TextChangedEventResponse> getTextChangedEvents(TransactionReceipt transactionReceipt) {
    List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(TEXTCHANGED_EVENT, transactionReceipt);
    ArrayList<TextChangedEventResponse> responses = new ArrayList<TextChangedEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        TextChangedEventResponse typedResponse = new TextChangedEventResponse();
        typedResponse.log = eventValues.getLog();
        typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
        typedResponse.indexedKey = (byte[]) eventValues.getIndexedValues().get(1).getValue();
        typedResponse.key = (String) eventValues.getNonIndexedValues().get(0).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #30
Source File: EventEmitter.java    From eventeum with Apache License 2.0 5 votes vote down vote up
public List<DummyEventEventResponse> getDummyEventEvents(TransactionReceipt transactionReceipt) {
    List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(DUMMYEVENT_EVENT, transactionReceipt);
    ArrayList<DummyEventEventResponse> responses = new ArrayList<DummyEventEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        DummyEventEventResponse typedResponse = new DummyEventEventResponse();
        typedResponse.log = eventValues.getLog();
        typedResponse.indexedBytes = (byte[]) eventValues.getIndexedValues().get(0).getValue();
        typedResponse.indexedAddress = (String) eventValues.getIndexedValues().get(1).getValue();
        typedResponse.uintValue = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
        typedResponse.stringValue = (String) eventValues.getNonIndexedValues().get(1).getValue();
        typedResponse.enumValue = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue();
        responses.add(typedResponse);
    }
    return responses;
}