Java Code Examples for org.web3j.utils.Base64String#wrapList()

The following examples show how to use org.web3j.utils.Base64String#wrapList() . These examples are extracted from open source projects. 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
private CallPrivateSmartContractFunction(
    final String contractAddress,
    final String encodedFunction,
    final String transactionSigningKey,
    final long chainId,
    final String privateFrom,
    final List<String> privateFor,
    final String privacyGroupId) {

  this.contractAddress = contractAddress;
  this.encodedFunction = encodedFunction;
  this.senderCredentials = Credentials.create(transactionSigningKey);
  this.chainId = chainId;
  this.privateFrom = Base64String.wrap(privateFrom);
  this.privateFor = privateFor != null ? Base64String.wrapList(privateFor) : null;
  this.privacyGroupId = privacyGroupId != null ? Base64String.wrap(privacyGroupId) : null;
}
 
Example 2
Source Project: besu   File: PrivacyGroupAcceptanceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void nodeCanCreatePrivacyGroup() {
  final String privacyGroupId =
      alice.execute(
          privacyTransactions.createPrivacyGroup(
              "myGroupName", "my group description", alice, bob));

  assertThat(privacyGroupId).isNotNull();

  final PrivacyGroup expected =
      new PrivacyGroup(
          privacyGroupId,
          PrivacyGroup.Type.PANTHEON,
          "myGroupName",
          "my group description",
          Base64String.wrapList(alice.getEnclaveKey(), bob.getEnclaveKey()));

  alice.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));

  bob.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));
}
 
Example 3
Source Project: besu   File: PrivacyGroupAcceptanceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void nodeCanCreatePrivacyGroupWithoutName() {
  final String privacyGroupId =
      alice.execute(
          privacyTransactions.createPrivacyGroup(null, "my group description", alice, bob));

  assertThat(privacyGroupId).isNotNull();

  final PrivacyGroup expected =
      new PrivacyGroup(
          privacyGroupId,
          PrivacyGroup.Type.PANTHEON,
          "",
          "my group description",
          Base64String.wrapList(alice.getEnclaveKey(), bob.getEnclaveKey()));

  alice.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));

  bob.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));
}
 
Example 4
Source Project: besu   File: PrivacyGroupAcceptanceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void nodeCanCreatePrivacyGroupWithoutDescription() {
  final String privacyGroupId =
      alice.execute(privacyTransactions.createPrivacyGroup("myGroupName", null, alice, bob));

  assertThat(privacyGroupId).isNotNull();

  final PrivacyGroup expected =
      new PrivacyGroup(
          privacyGroupId,
          PrivacyGroup.Type.PANTHEON,
          "myGroupName",
          "",
          Base64String.wrapList(alice.getEnclaveKey(), bob.getEnclaveKey()));

  alice.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));

  bob.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));
}
 
Example 5
Source Project: besu   File: PrivacyGroupAcceptanceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void nodeCanCreatePrivacyGroupWithoutOptionalParams() {
  final String privacyGroupId =
      alice.execute(privacyTransactions.createPrivacyGroup(null, null, alice, bob));

  assertThat(privacyGroupId).isNotNull();

  final PrivacyGroup expected =
      new PrivacyGroup(
          privacyGroupId,
          PrivacyGroup.Type.PANTHEON,
          "",
          "",
          Base64String.wrapList(alice.getEnclaveKey(), bob.getEnclaveKey()));

  alice.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));

  bob.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));
}
 
Example 6
Source Project: besu   File: PrivGetCodeAcceptanceTest.java    License: Apache License 2.0 6 votes vote down vote up
private String createPrivacyGroup() {
  final String privacyGroupId =
      alice.execute(
          privacyTransactions.createPrivacyGroup("myGroupName", "my group description", alice));

  assertThat(privacyGroupId).isNotNull();

  final PrivacyGroup expected =
      new PrivacyGroup(
          privacyGroupId,
          PrivacyGroup.Type.PANTHEON,
          "myGroupName",
          "my group description",
          Base64String.wrapList(alice.getEnclaveKey()));

  alice.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));

  return privacyGroupId;
}
 
Example 7
public LoadPrivateSmartContractTransaction(
    final String contractAddress,
    final Class<T> clazz,
    final String transactionSigningKey,
    final long chainId,
    final String privateFrom,
    final List<String> privateFor) {

  this.contractAddress = contractAddress;
  this.clazz = clazz;
  this.senderCredentials = Credentials.create(transactionSigningKey);
  this.chainId = chainId;
  this.privateFrom = Base64String.wrap(privateFrom);
  this.privateFor = Base64String.wrapList(privateFor);
}
 
Example 8
public DeployPrivateSmartContractTransaction(
    final Class<T> clazz,
    final String transactionSigningKey,
    final long chainId,
    final String privateFrom,
    final List<String> privateFor) {
  this.clazz = clazz;
  this.senderCredentials = Credentials.create(transactionSigningKey);
  this.chainId = chainId;
  this.privateFrom = Base64String.wrap(privateFrom);
  this.privateFor = Base64String.wrapList(privateFor);
}
 
Example 9
Source Project: web3j   File: ResponseTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testPrivGetPrivateTransactionLegacy() {

    buildResponse(
            "{\n"
                    + "    \"id\":1,\n"
                    + "    \"jsonrpc\":\"2.0\",\n"
                    + "    \"result\": {\n"
                    + "        \"hash\":\"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b\",\n"
                    + "        \"nonce\":\"0x00\",\n"
                    + "        \"from\":\"0x407d73d8a49eeb85d32cf465507dd71d507100c1\",\n"
                    + "        \"to\":\"0x85h43d8a49eeb85d32cf465507dd71d507100c1\",\n"
                    + "        \"value\":\"0x7f110\",\n"
                    + "        \"gas\": \"0x7f110\",\n"
                    + "        \"gasPrice\":\"0x09184e72a000\",\n"
                    + "        \"input\":\"0x603880600c6000396000f300603880600c6000396000f3603880600c6000396000f360\",\n"
                    + "        \"r\":\"0xf115cc4d7516dd430046504e1c888198e0323e8ded016d755f89c226ba3481dc\",\n"
                    + "        \"s\":\"0x4a2ae8ee49f1100b5c0202b37ed8bacf4caeddebde6b7f77e12e7a55893e9f62\",\n"
                    + "        \"v\":\"0x00\",\n"
                    + "        \"privateFrom\":\"A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=\",\n"
                    + "        \"privateFor\":[\"A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=\",\"Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs=\"],\n"
                    + "        \"restriction\":\"restricted\""
                    + "  }\n"
                    + "}");
    PrivateTransactionLegacy privateTransaction =
            new PrivateTransactionLegacy(
                    "0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b",
                    "0x00",
                    "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
                    "0x85h43d8a49eeb85d32cf465507dd71d507100c1",
                    "0x7f110",
                    "0x7f110",
                    "0x09184e72a000",
                    "0x603880600c6000396000f300603880600c6000396000f3603880600c6000396000f360",
                    "0xf115cc4d7516dd430046504e1c888198e0323e8ded016d755f89c226ba3481dc",
                    "0x4a2ae8ee49f1100b5c0202b37ed8bacf4caeddebde6b7f77e12e7a55893e9f62",
                    "0x00",
                    Base64String.wrap("A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="),
                    Base64String.wrapList(
                            "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=",
                            "Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs="),
                    "restricted");

    PrivGetPrivateTransaction privPrivateTransaction =
            deserialiseResponse(PrivGetPrivateTransaction.class);
    assertEquals(privPrivateTransaction.getPrivateTransaction().get(), (privateTransaction));
}
 
Example 10
Source Project: web3j   File: ResponseTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testPrivFindPrivacyGroup() {

    buildResponse(
            "{\n"
                    + "    \"jsonrpc\": \"2.0\",\n"
                    + "    \"id\": 1,\n"
                    + "    \"result\": [\n"
                    + "         {\n"
                    + "            \"privacyGroupId\":\"A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=\",\n"
                    + "            \"name\":\"PrivacyGroupName\",\n"
                    + "            \"description\":\"PrivacyGroupDescription\",\n"
                    + "            \"type\":\"LEGACY\",\n"
                    + "            \"members\": [\"A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=\"]\n"
                    + "         },\n"
                    + "         {\n"
                    + "            \"privacyGroupId\":\"A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=\",\n"
                    + "            \"name\":\"PrivacyGroupName\",\n"
                    + "            \"description\":\"PrivacyGroupDescription\",\n"
                    + "            \"type\":\"PANTHEON\",\n"
                    + "            \"members\": [\"A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=\"]\n"
                    + "         },\n"
                    + "         {\n"
                    + "            \"privacyGroupId\":\"A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=\",\n"
                    + "            \"type\":\"ONCHAIN\",\n"
                    + "            \"members\": [\"A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=\"]\n"
                    + "         }\n"
                    + "    ]\n"
                    + "}");

    PrivacyGroup privacyGroup1 =
            new PrivacyGroup(
                    "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=",
                    PrivacyGroup.Type.LEGACY,
                    "PrivacyGroupName",
                    "PrivacyGroupDescription",
                    Base64String.wrapList("A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="));
    PrivacyGroup privacyGroup2 =
            new PrivacyGroup(
                    "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=",
                    PrivacyGroup.Type.PANTHEON,
                    "PrivacyGroupName",
                    "PrivacyGroupDescription",
                    Base64String.wrapList("A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="));
    PrivacyGroup privacyGroup3 =
            new PrivacyGroup(
                    "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=",
                    PrivacyGroup.Type.ONCHAIN,
                    null,
                    null,
                    Base64String.wrapList("A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="));

    PrivFindPrivacyGroup privFindPrivacyGroup = deserialiseResponse(PrivFindPrivacyGroup.class);
    assertEquals(
            privFindPrivacyGroup.getGroups(),
            (Arrays.asList(privacyGroup1, privacyGroup2, privacyGroup3)));
}