· 6 years ago · Mar 31, 2020, 01:52 PM
1$ git diff QAXH_Eth_358.java QAXH_Eth_359.java
2diff --git a/QAXH_Eth_358.java b/QAXH_Eth_359.java
3index 4d5a60e..1fbf913 100644
4--- a/QAXH_Eth_358.java
5+++ b/QAXH_Eth_359.java
6@@ -115,8 +115,8 @@ import java.util.List;
7 import java.util.Formatter;
8
9 class QAXH_ETH_COMPONENT {
10- public static final int VERSION = 358;
11- public static final String VERSION_STR = "3.58";
12+ public static final int VERSION = 359;
13+ public static final String VERSION_STR = "3.59";
14 }
15
16 @DesignerComponent(
17@@ -168,107 +168,32 @@ public class QAXH_Eth extends AndroidNonvisibleComponent implements Component {
18 nonce = null;
19 }
20
21- // PRIVATE METHODS
22+
23+
24+
25+ // PUBLIC FUNCTIONS (appInventor blocks API)
26
27 /**
28- * Convert bytes to hexadecimal
29+ * Setup the private key and nonce private variables used in the extension.
30 *
31- * @param byte[] bytes, the array of bits to be translated
32- * @return a string containing the transalation in hexadecimal
33+ * @param privHexKey appInventor private key.
34 */
35- private static String bytesToHex(byte[] bytes) {
36- char[] hexArray = "0123456789ABCDEF".toCharArray();
37- char[] hexChars = new char[bytes.length * 2];
38- for ( int j = 0; j < bytes.length; j++ ) {
39- int v = bytes[j] & 0xFF;
40- hexChars[j * 2] = hexArray[v >>> 4];
41- hexChars[j * 2 + 1] = hexArray[v & 0x0F];
42- }
43- return new String(hexChars);
44- }
45-
46- private void setupNonce(String privateKey) {
47+ @SimpleFunction(description="Setup the private key and nonce references in QAXH_Auth extension.")
48+ public void createAccount(String privHexKey) {
49 try {
50- Credentials credentials = Credentials.create(privateKey);
51+ Credentials credentials = Credentials.create(privHexKey);
52 String publicAddress = credentials.getAddress();
53 EthGetTransactionCount transactionCount = web3.ethGetTransactionCou nt(publicAddress, DefaultBlockParameterName.LATEST).send();
54- nonce = transactionCount.getTransactionCount();
55+ this.nonce = transactionCount.getTransactionCount();
56 }
57 catch (Exception e) {
58 e.printStackTrace();
59 }
60+ this.privHexKey = privHexKey;
61 }
62
63- // PUBLIC METHODS (APPINVENTOR API)
64-
65- @SimpleFunction(description = "Return the Eth extension version.")
66- public String getVersion() {
67- return String.valueOf(QAXH_ETH_COMPONENT.VERSION_STR);
68- }
69-
70- /**
71- * Give the keccak hash of a string
72- *
73- * @param message, message to hash.
74- * @return hash value as hexadecimal encoded string.
75- */
76- @SimpleFunction(description = "Computes the Keccak-256 of the string parame ter.")
77- public String keccak(String message) {
78- return Hash.sha3String(message);
79- }
80-
81- @SimpleFunction(description = "Returns Infura client version.")
82- public String readClientVersion(){
83- try {
84- return web3.web3ClientVersion().send().getWeb3ClientVersion();
85- }
86- catch (IOException e) {
87- return "Could not get version: could not reach network";
88- }
89- }
90-
91- @SimpleFunction(description = "Returns the current block number.")
92- public String readBlockNumber() {
93- try {
94- return web3.ethBlockNumber().send().getBlockNumber().toString();
95- }
96- catch (IOException e) {
97- return "could not reach network";
98- }
99- }
100-
101- @SimpleFunction(description = "Returns the balance of an account.")
102- public String readBalance(String address) {
103- try {
104- return web3.ethGetBalance(address.toUpperCase(Locale.US), DefaultBl ockParameterName.LATEST)
105- .send()
106- .getBalance()
107- .toString();
108- }
109- catch (IOException e) {
110- return "Could not reach network";
111- }
112- }
113-
114-@SimpleFunction(description = "Returns the token balance of an address.")
115- public String readTokenBalance(String tokenContractAddress, String address) {
116- Function function = new Function(
117- "balanceOf",
118- Arrays.<Type>asList(new Address(address)),
119- Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {
120- }));
121-
122- List<Uint256> lst = callViewFunction(tokenContractAddress, function);
123- return lst.get(0).getValue().toString();
124- }
125-
126- /**
127- * Generate an ethereum private / public key pair.
128- *
129- * @return the keys and address of the account, in format : Ox <privateKey> /0x04 <publicKeys> /Ox <adress>
130- */
131- @SimpleFunction (description = "Generate an ethereum private / public key p air.")
132- public String createKeyTriplet() {
133+ @SimpleFunction (description = "Create an keyLabel / address pair")
134+ public String createAdress() {
135 ECPublicKey publicKey;
136 ECPrivateKey privateKey;
137 BigInteger priv = BigInteger.ZERO;
138@@ -291,11 +216,16 @@ public class QAXH_Eth extends AndroidNonvisibleComponent i mplements Component {
139 } catch(Exception e) {
140 e.printStackTrace();
141 }
142- return "0x" + priv.toString(16) + "/0x04" + pubX.toString(16) + pubY.t oString(16) + "/0x" + Keys.getAddress(pubX.toString(16) + pubY.toString(16));
143+ return "0x" + priv.toString(16) + "/0x" + Keys.getAddress(pubX.toString (16) + pubY.toString(16));
144 }
145
146- @SimpleFunction (description = "Create an keyLabel / address pair")
147- public String createAdress() {
148+ /**
149+ * Generate an ethereum private / public key pair.
150+ *
151+ * @return the keys and address of the account, in format : Ox <privateKey> /0x04 <publicKeys> /Ox <adress>
152+ */
153+ @SimpleFunction (description = "Generate an ethereum private / public key p air.")
154+ public String createKeyTriplet() {
155 ECPublicKey publicKey;
156 ECPrivateKey privateKey;
157 BigInteger priv = BigInteger.ZERO;
158@@ -318,86 +248,119 @@ public class QAXH_Eth extends AndroidNonvisibleComponent implements Component {
159 } catch(Exception e) {
160 e.printStackTrace();
161 }
162- return "0x" + priv.toString(16) + "/0x" + Keys.getAddress(pubX.toString (16) + pubY.toString(16));
163+ return "0x" + priv.toString(16) + "/0x04" + pubX.toString(16) + pubY.t oString(16) + "/0x" + Keys.getAddress(pubX.toString(16) + pubY.toString(16));
164 }
165-
166- /**
167- * Send Gwei = 10-9 ether.
168- *
169- * @param String privKeyHex, the private key of the sending account in hexa decimal
170- * @param String dest, the address of the receiver in hexadecimal
171- * @param String howMuchGwei, number of Gwei to send
172- * @param String data, the data to encript in the transaction, usually the identity hash here
173- * @return the transaction hash if successful, if not a String Error : with an explaination of why it failed.
174- */
175- @SimpleFunction (description = "Send Gwei = 10-9 ether.")
176- public String transferEtherTo(String address, String howManyWei, String dat a)
177- {
178- Credentials credentials = Credentials.create(this.privHexKey);
179- if (nonce == null)
180- setupNonce(this.privHexKey);
181- try {
182- BigInteger gasPrice = web3.ethGasPrice().send().getGasPrice();
183- BigInteger gasLimit = BigInteger.valueOf(500000);
184- BigInteger value = new BigInteger(howManyWei);
185- RawTransaction rawTransaction = RawTransaction.createTransaction(th is.nonce, gasPrice, gasLimit, address, value, data);
186- byte[] signedMessage = TransactionEncoder.signMessage(rawTransactio n, credentials);
187- String hexValue = Numeric.toHexString(signedMessage);
188- EthSendTransaction ethSendTransaction = web3.ethSendRawTransaction( hexValue).sendAsync().get();
189- nonce = nonce.add(BigInteger.valueOf(1));
190- return ethSendTransaction.getTransactionHash();
191- } catch (Exception e) {
192- e.printStackTrace();
193- return "Error when calling `sendEther`";
194- }
195+
196+ @SimpleFunction(description = "Return the Eth extension version.")
197+ public String getVersion() {
198+ return String.valueOf(QAXH_ETH_COMPONENT.VERSION_STR);
199 }
200
201 /**
202- * Get the status of a transaction.
203+ * Give the keccak hash of a string
204 *
205- * @param String transactionId, the hexadecimal id of the transaction to sc an
206- * @return a String, describing the status if successful, with a Error : + explanation if not.
207+ * @param message, message to hash.
208+ * @return hash value as hexadecimal encoded string.
209 */
210- @SimpleFunction(description = "Retrieves the status of a transaction.")
211- public String readTransactionStatus(String transaction_0x) {
212- EthTransaction ethTx;
213+ @SimpleFunction(description = "Computes the Keccak-256 of the string parame ter.")
214+ public String keccak(String message) {
215+ return Hash.sha3String(message);
216+ }
217+
218+ @SimpleFunction(description = "Returns the balance of an account.")
219+ public String readBalance(String address) {
220 try {
221- ethTx=web3.ethGetTransactionByHash(transaction_0x).send();
222+ return web3.ethGetBalance(address.toUpperCase(Locale.US), DefaultBl ockParameterName.LATEST)
223+ .send()
224+ .getBalance()
225+ .toString();
226 }
227 catch (IOException e) {
228- return "Error: getTransactionStatus could not reach network";
229+ return "Could not reach network";
230 }
231+ }
232+
233+ @SimpleFunction(description = "Returns the current block number.")
234+ public String readBlockNumber() {
235 try {
236- EthGetTransactionReceipt ethTxReceipt = web3.ethGetTransactionRecei pt(transaction_0x).sendAsync().get();
237- TransactionReceipt txReceipt = ethTxReceipt.getTransactionReceipt() ;
238- if (txReceipt == null)
239- return "Pending";
240- if (txReceipt.getStatus().equals("0x1"))
241- return String.format("Mined in block#" + txReceipt.getBlockNumb erRaw() + "Gas used: %d",txReceipt.getGasUsed());
242- return String.format("Transaction has failed with status: %s. Gas u sed: %d. (not-enough gas?)", txReceipt.getStatus(), txReceipt.getGasUsed());
243+ return web3.ethBlockNumber().send().getBlockNumber().toString();
244+ }
245+ catch (IOException e) {
246+ return "could not reach network";
247 }
248- catch (Exception e) { }
249- return "failed to poll status for transaction " + transaction_0x;
250 }
251
252- /*
253- * get the timestamp of a block
254+ /*
255+ * Get the timestamp of a block
256 *
257 */
258- @SimpleFunction(description = "Retrieves the timestamp of a block")
259- public String readBlockTimestamp(String blockNumber) {
260- EthBlock ethBlock;
261- try {
262- ethBlock = web3.ethGetBlockByNumber(new DefaultBlockParameterNumber(new B igInteger(blockNumber)),true).send();
263+ @SimpleFunction(description = "Retrieves the timestamp of a block")
264+ public String readBlockTimestamp(String blockNumber) {
265+ EthBlock ethBlock;
266+ try {
267+ ethBlock = web3.ethGetBlockByNumber(new DefaultBlockParameterNumber(n ew BigInteger(blockNumber)),true).send();
268+ }
269+ catch (IOException e) {
270+ return ("Problem connecting to network in getBlockTimestamp");
271+ }
272+ if (ethBlock.getBlock() == null) {
273+ return "not mined";
274+ }
275+ return ethBlock.getBlock().getTimestamp().toString();
276 }
277- catch (IOException e) {
278- return ("Problem connecting to network in getBlockTimestamp");
279+
280+ @SimpleFunction(description = "Returns Infura client version.")
281+ public String readClientVersion(){
282+ try {
283+ return web3.web3ClientVersion().send().getWeb3ClientVersion();
284+ }
285+ catch (IOException e) {
286+ return "Could not get version: could not reach network";
287+ }
288 }
289- if (ethBlock.getBlock() == null) {
290- return "not mined";
291+
292+ /**
293+ * List all the transactions received by a given address from block number fromBlock to block number fromBlock + numberOfBlocks.
294+ *
295+ * @param address, the address of the user to retrieve received transaction s for.
296+ * @param firstBlockNumber, the block umber to start from
297+ * @param howMuchBlocks, the number of blocks to read
298+ * @return the last block read / a list of received transaction, encoded in a String
299+ * ex : the last block read number / 0x... / 0x... / 0x...
300+ */
301+ @SimpleFunction(description = "List all the transactions received by a give n address from block n° fromBlock to block n° fromBlock + numberOfBlocks.")
302+ public String readReceivedBlock(String address, String firstBlockNumber, in t howMuchBlocks) {
303+ BigInteger block = new BigInteger(firstBlockNumber);
304+ BigInteger toBlock = block.add(BigInteger.valueOf(howMuchBlocks));
305+ String result = "";
306+ for (; !block.equals(toBlock); block = block.add(BigInteger.ONE)) {
307+ try {
308+ EthBlock ethBlock = web3.ethGetBlockByNumber(new DefaultBlockPa rameterNumber(block), true).send();
309+ List<TransactionResult> listTx = ethBlock.getBlock().getTransac tions();
310+ for (TransactionResult txR : listTx) {
311+ org.web3j.protocol.core.methods.response.Transaction tx = ( org.web3j.protocol.core.methods.response.Transaction) txR.get();
312+ if (tx.getTo() != null && toChecksumAddress(tx.getTo()).equ als(toChecksumAddress(address))) {
313+ result += tx.getHash() + "/";
314+ }
315+ }
316+ } catch (IOException e) {
317+ return "Problem connecting to network";
318+ }
319+ }
320+ return block.toString() + "/" + result;
321+ }
322+
323+ @SimpleFunction(description = "Returns the token balance of an address.")
324+ public String readTokenBalance(String tokenContractAddress, String address) {
325+ Function function = new Function(
326+ "balanceOf",
327+ Arrays.<Type>asList(new Address(address)),
328+ Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {
329+ }));
330+
331+ List<Uint256> lst = callViewFunction(tokenContractAddress, function);
332+ return lst.get(0).getValue().toString();
333 }
334- return ethBlock.getBlock().getTimestamp().toString();
335- }
336
337 /**
338 * Retrieve the details of a transaction.
339@@ -456,61 +419,40 @@ public class QAXH_Eth extends AndroidNonvisibleComponent i mplements Component {
340 ret.add(timestampStr);
341 ret.add(inputData);
342
343- // Laisser le contrat à la fin pour ne pas casser l'app de Cyril
344+ // Laisser le contrat à la fin pour ne pas casser l'app de Cyril
345 ret.add(transactionReceipt.getContractAddress());
346
347 return ret;
348 }
349
350- /************************************************************************** ****************************************
351- ************************************************** STEP 2 **************** ****************************************
352- ************************************************************************** ***************************************/
353-
354 /**
355- * List all the transactions received by a given address from block number fromBlock to block number fromBlock + numberOfBlocks.
356+ * Get the status of a transaction.
357 *
358- * @param address, the address of the user to retrieve received transaction s for.
359- * @param firstBlockNumber, the block umber to start from
360- * @param howMuchBlocks, the number of blocks to read
361- * @return the last block read / a list of received transaction, encoded in a String
362- * ex : the last block read number / 0x... / 0x... / 0x...
363+ * @param String transactionId, the hexadecimal id of the transaction to sc an
364+ * @return a String, describing the status if successful, with a Error : + explanation if not.
365 */
366- @SimpleFunction(description = "List all the transactions received by a give n address from block n° fromBlock to block n° fromBlock + numberOfBlocks.")
367- public String readReceivedBlock(String address, String firstBlockNumber, in t howMuchBlocks) {
368- BigInteger block = new BigInteger(firstBlockNumber);
369- BigInteger toBlock = block.add(BigInteger.valueOf(howMuchBlocks));
370- String result = "";
371- for (; !block.equals(toBlock); block = block.add(BigInteger.ONE)) {
372- try {
373- EthBlock ethBlock = web3.ethGetBlockByNumber(new DefaultBlockPa rameterNumber(block), true).send();
374- List<TransactionResult> listTx = ethBlock.getBlock().getTransac tions();
375- for (TransactionResult txR : listTx) {
376- org.web3j.protocol.core.methods.response.Transaction tx = ( org.web3j.protocol.core.methods.response.Transaction) txR.get();
377- if (tx.getTo() != null && toChecksumAddress(tx.getTo()).equ als(toChecksumAddress(address))) {
378- result += tx.getHash() + "/";
379- }
380- }
381- } catch (IOException e) {
382- return "Problem connecting to network";
383- }
384+ @SimpleFunction(description = "Retrieves the status of a transaction.")
385+ public String readTransactionStatus(String transaction_0x) {
386+ EthTransaction ethTx;
387+ try {
388+ ethTx=web3.ethGetTransactionByHash(transaction_0x).send();
389 }
390- return block.toString() + "/" + result;
391- }
392-
393- /**
394- *
395- * Return the given address with an EIP55 checksum.
396- *
397- */
398- @SimpleFunction(description = "Return the given address with an EIP55 check sum.")
399- public String toChecksumAddress(String address) {
400- return Keys.toChecksumAddress(address);
401+ catch (IOException e) {
402+ return "Error: getTransactionStatus could not reach network";
403+ }
404+ try {
405+ EthGetTransactionReceipt ethTxReceipt = web3.ethGetTransactionRecei pt(transaction_0x).sendAsync().get();
406+ TransactionReceipt txReceipt = ethTxReceipt.getTransactionReceipt() ;
407+ if (txReceipt == null)
408+ return "Pending";
409+ if (txReceipt.getStatus().equals("0x1"))
410+ return String.format("Mined in block#" + txReceipt.getBlockNumb erRaw() + "Gas used: %d",txReceipt.getGasUsed());
411+ return String.format("Transaction has failed with status: %s. Gas u sed: %d. (not-enough gas?)", txReceipt.getStatus(), txReceipt.getGasUsed());
412+ }
413+ catch (Exception e) { }
414+ return "failed to poll status for transaction " + transaction_0x;
415 }
416
417- /************************************************************************** ****************************************
418- ****************************************** Using Etherscan API *********** ****************************************
419- ************************************************************************** ***************************************/
420-
421 @SimpleFunction(description = "Get the lists of received and sent transacti on for an address, using the etherscan API")
422 public YailList readTxLists(String address, String startNumber, String endN umber ) {
423 Etherscan client = new Etherscan();
424@@ -527,11 +469,51 @@ public class QAXH_Eth extends AndroidNonvisibleComponent i mplements Component {
425 return list.makeList(res2);
426 }
427
428- //############################################//
429- //############### QAXH_AUTH ##################//
430- //############################################//
431
432- // PRIVATE FUNCTIONS
433+ /// Utility Functions
434+
435+ /**
436+ *
437+ * Return the given address with an EIP55 checksum.
438+ *
439+ */
440+ @SimpleFunction(description = "Return the given address with an EIP55 check sum.")
441+ public String toChecksumAddress(String address) {
442+ return Keys.toChecksumAddress(address);
443+ }
444+
445+ /**
446+ * Send Gwei = 10-9 ether.
447+ *
448+ * @param String privKeyHex, the private key of the sending account in hexa decimal
449+ * @param String dest, the address of the receiver in hexadecimal
450+ * @param String howMuchGwei, number of Gwei to send
451+ * @param String data, the data to encript in the transaction, usually the identity hash here
452+ * @return the transaction hash if successful, if not a String Error : with an explaination of why it failed.
453+ */
454+ @SimpleFunction (description = "Send Gwei = 10-9 ether.")
455+ public String transferEtherTo(String address, String howManyWei, String dat a)
456+ {
457+ Credentials credentials = Credentials.create(this.privHexKey);
458+ if (nonce == null)
459+ setupNonce(this.privHexKey);
460+ try {
461+ BigInteger gasPrice = web3.ethGasPrice().send().getGasPrice();
462+ BigInteger gasLimit = BigInteger.valueOf(500000);
463+ BigInteger value = new BigInteger(howManyWei);
464+ RawTransaction rawTransaction = RawTransaction.createTransaction(th is.nonce, gasPrice, gasLimit, address, value, data);
465+ byte[] signedMessage = TransactionEncoder.signMessage(rawTransactio n, credentials);
466+ String hexValue = Numeric.toHexString(signedMessage);
467+ EthSendTransaction ethSendTransaction = web3.ethSendRawTransaction( hexValue).sendAsync().get();
468+ nonce = nonce.add(BigInteger.valueOf(1));
469+ return ethSendTransaction.getTransactionHash();
470+ } catch (Exception e) {
471+ e.printStackTrace();
472+ return "Error when calling `sendEther`";
473+ }
474+ }
475+
476+ // Private functions
477
478 private List callViewFunction(String contractAddress, Function function) {
479 Credentials credentials = Credentials.create(this.privHexKey);
480@@ -565,7 +547,43 @@ public class QAXH_Eth extends AndroidNonvisibleComponent im plements Component {
481 }
482 }
483
484- @SuppressWarnings("unchecked")
485+ private void setupNonce(String privateKey) {
486+ try {
487+ Credentials credentials = Credentials.create(privateKey);
488+ String publicAddress = credentials.getAddress();
489+ EthGetTransactionCount transactionCount = web3.ethGetTransactionCou nt(publicAddress, DefaultBlockParameterName.LATEST).send();
490+ nonce = transactionCount.getTransactionCount();
491+ }
492+ catch (Exception e) {
493+ e.printStackTrace();
494+ }
495+ }
496+
497+ /**
498+ * Convert bytes to hexadecimal
499+ *
500+ * @param byte[] bytes, the array of bits to be translated
501+ * @return a string containing the transalation in hexadecimal
502+ */
503+ private static String bytesToHex(byte[] bytes) {
504+ char[] hexArray = "0123456789ABCDEF".toCharArray();
505+ char[] hexChars = new char[bytes.length * 2];
506+ for ( int j = 0; j < bytes.length; j++ ) {
507+ int v = bytes[j] & 0xFF;
508+ hexChars[j * 2] = hexArray[v >>> 4];
509+ hexChars[j * 2 + 1] = hexArray[v & 0x0F];
510+ }
511+ return new String(hexChars);
512+ }
513+
514+
515+ // Fin des fonctions Rinkeby_ETH
516+
517+ // Début des fonctions QAXH
518+
519+ //----------------------------------------USERSAFE------------------------- ---------------
520+
521+ @SuppressWarnings("unchecked")
522 private String getQaxhModule(String UserSafeKey) {
523 Function function = new Function(
524 "getModules",
525@@ -579,27 +597,6 @@ public class QAXH_Eth extends AndroidNonvisibleComponent im plements Component {
526 return lst.get(0).getValue().get(0).toString();
527 }
528
529- // PUBLIC FUNCTIONS (appInventor blocks API)
530-
531- /**
532- * Setup the private key and nonce private variables used in the extension.
533- *
534- * @param privHexKey appInventor private key.
535- */
536- @SimpleFunction(description="Setup the private key and nonce references in QAXH_Auth extension.")
537- public void createAccount(String privHexKey) {
538- try {
539- Credentials credentials = Credentials.create(privHexKey);
540- String publicAddress = credentials.getAddress();
541- EthGetTransactionCount transactionCount = web3.ethGetTransactionCou nt(publicAddress, DefaultBlockParameterName.LATEST).send();
542- this.nonce = transactionCount.getTransactionCount();
543- }
544- catch (Exception e) {
545- e.printStackTrace();
546- }
547- this.privHexKey = privHexKey;
548- }
549-
550 /**
551 * Returns the creator of a qaxh usersafe, or 0 if it is not in the SchemeS afe
552 *
553@@ -621,27 +618,6 @@ public class QAXH_Eth extends AndroidNonvisibleComponent im plements Component {
554 }
555
556 /**
557- * Returns the creator of a qaxh corporatesafe, or 0 if it is not in the Sc hemeSafe
558- *
559- * @param schemeSafeAddress Address of the SchemeSafe
560- * @param corporateSafeAddress Address of the corporate safe
561- * @return Address of the creator, 0 if it is not a qaxh safe
562- */
563- @SimpleFunction(description="Returns the creator of a corporate safe, or 0 if it is not in the SchemeSafe")
564- public String isQaxhCorporateSafe(String schemeSafeAddress, String corporat eSafeAddress)
565- {
566- Function f = new Function(
567- "corporateSafes",
568- Arrays.<Type>asList(new Address(corporateSafeAddress)),
569- Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {} )
570- );
571-
572- List<Address> lst = callViewFunction(schemeSafeAddress, f);
573- return lst.get(0).toString();
574- }
575-
576-
577- /**
578 * Return true if the key is active in the Qaxh Safe.
579 *
580 * @param UserSafeKey Address of the userSafe.
581@@ -1106,9 +1082,29 @@ public class QAXH_Eth extends AndroidNonvisibleComponent implements Component {
582 return result;
583 }
584
585+ //----------------------------------------CORPORATESAFE-------------------- --------------------
586+
587+ /**
588+ * Returns the creator of a qaxh corporatesafe, or 0 if it is not in the Sc hemeSafe
589+ *
590+ * @param schemeSafeAddress Address of the SchemeSafe
591+ * @param corporateSafeAddress Address of the corporate safe
592+ * @return Address of the creator, 0 if it is not a qaxh safe
593+ */
594+ @SimpleFunction(description="Returns the creator of a corporate safe, or 0 if it is not in the SchemeSafe")
595+ public String isQaxhCorporateSafe(String schemeSafeAddress, String corporat eSafeAddress)
596+ {
597+ Function f = new Function(
598+ "corporateSafes",
599+ Arrays.<Type>asList(new Address(corporateSafeAddress)),
600+ Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {} )
601+ );
602+
603+ List<Address> lst = callViewFunction(schemeSafeAddress, f);
604+ return lst.get(0).toString();
605+ }
606+
607
608- //----------------------------------------CORPORATE------------------------ ----------------
609-
610 @SimpleFunction(description="Getter of the Safe type.")
611 public int getSafeType(String safeAddress) {
612 String QaxhModule;
613@@ -1211,8 +1207,8 @@ public class QAXH_Eth extends AndroidNonvisibleComponent i mplements Component {
614 public String getCorporateIdentityBody(String corporateSafeAddress) {
615 String Qbody = "QGbody";
616 if (getSafeType(corporateSafeAddress) == 3) {
617- Qbody = "QCbody";
618- }
619+ Qbody = "QCbody";
620+ }
621 Function function = new Function(
622 Qbody,
623 Collections.<Type>emptyList(),
624@@ -1568,7 +1564,7 @@ public class QAXH_Eth extends AndroidNonvisibleComponent i mplements Component {
625 @SimpleFunction(description="Withdraw a transaction from another corporate safe")
626 public String withdrawCorporateTransaction(
627 String beneficiaryUserSafe, String beneficiaryCorporateSafe,
628- String originatorCorporateSafe, String txid)
629+ String originatorCorporateSafe, String txid)
630 {
631 Function f = new Function(
632 "withdrawTransactionFrom",
633@@ -1888,4 +1884,4 @@ public class QAXH_Eth extends AndroidNonvisibleComponent i mplements Component {
634 }
635 */
636
637-}
638+}