src/main/java/convex/java/Convex.java
/**
	 * Asynchronously execute a transaction using the current Account. Requires
	 * a valid key pair to be set up.
	 * 
	 * @param code Code to execute
	 * @return Future for the transaction result.
	 */
Asynchronously execute a transaction using the current Account. Requires
a valid key pair to be set up.

@param code Code to execute
@return Future for the transaction result.
Asynchronously execute a transaction using the current Account . Requires a valid key pair to be set up . @param code Code to execute @return Future for the transaction result .
public synchronized CompletableFuture<Map<String,Object>> transactAsync(String code) {
		String json=buildJsonQuery(code);
		CompletableFuture<Map<String,Object>> prep=doPostAsync(url+"/api/v1/transaction/prepare",json);
		return prep.thenCompose(r->{
			synchronized( this) {
				Map<String,Object> result=r;
				if (r==null) {
					throw new Error("Null response from transaction prepare!: "+r);
				}
				if (r.get("errorCode")!=null) {
					throw new Error("Error while preparing transaction: "+r);
				}
				Long seq=(Long)(r.get("sequence"));
				if (seq!=null) updateSequence(seq);
				Hash hash=Hash.fromHex((String) result.get("hash"));
				if (hash==null) throw new Error("Transaction Hash not provided by server, got result: "+r);
				try {
					CompletableFuture<Map<String,Object>> tr = submitAsync(hash);
					return tr;
				} catch (Throwable e) {
					throw Utils.sneakyThrow(e);
				}
			}
		});
	}
public synchronized CompletableFuture < Map < String , Object > > transactAsync ( String code ) { String json = buildJsonQuery ( code ) ; CompletableFuture < Map < String , Object > > prep = doPostAsync ( url + "/api/v1/transaction/prepare" , json ) ; return prep . thenCompose ( r -> { synchronized ( this ) { Map < String , Object > result = r ; if ( r == null ) { throw new Error ( "Null response from transaction prepare!: " + r ) ; } if ( r . get ( "errorCode" ) != null ) { throw new Error ( "Error while preparing transaction: " + r ) ; } Long seq = ( Long ) ( r . get ( "sequence" ) ) ; if ( seq != null ) updateSequence ( seq ) ; Hash hash = Hash . fromHex ( ( String ) result . get ( "hash" ) ) ; if ( hash == null ) throw new Error ( "Transaction Hash not provided by server, got result: " + r ) ; try { CompletableFuture < Map < String , Object > > tr = submitAsync ( hash ) ; return tr ; } catch ( Throwable e ) { throw Utils . sneakyThrow ( e ) ; } } } ) ; }
Asynchronously execute a transaction using the current Account.
Asynchronously execute a transaction using the current Account .
// first to prepare step // then do submit step // check the sequence number from the server // if our own sequence number is lower, we want to update it!