Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Update examples for JS-SDK due to breaking changes in v0.12.0 #431

Closed
sachushaji opened this issue Feb 4, 2019 · 2 comments
Closed

Update examples for JS-SDK due to breaking changes in v0.12.0 #431

sachushaji opened this issue Feb 4, 2019 · 2 comments
Assignees

Comments

@sachushaji
Copy link

Problem Description

Due to the breaking change in v0.12.0 , Because of the addition of TransactionBuilder.setTimeout method that sets timebounds.max_time on a transaction, None of the examples is working in the docs for Javascript

Example Problem

Executing one of the following examples throws the error

var StellarSdk = require('stellar-sdk');
StellarSdk.Network.useTestNetwork();
var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');

// Keys for issuing account
var issuingKeys = StellarSdk.Keypair
  .fromSecret('SCZANGBA5YHTNYVVV4C3U252E2B6P6F5T3U6MM63WBSBZATAQI3EBTQ4');

server.loadAccount(issuingKeys.publicKey())
  .then(function(issuer) {
    var transaction = new StellarSdk.TransactionBuilder(issuer)
      .addOperation(StellarSdk.Operation.setOptions({
        homeDomain: 'yourdomain.com',
      }))
      .build();
    transaction.sign(issuingKeys);
    return server.submitTransaction(transaction);
  })
  .catch(function(error) {
    console.error('Error!', error);
  });

error

Error! Error: TimeBounds has to be set or you must call setTimeout(TimeoutInfinite).

Solution

Updating the code with setTimeout solves the problem

var StellarSdk = require('stellar-sdk');
StellarSdk.Network.useTestNetwork();
var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');

// Keys for issuing account
var issuingKeys = StellarSdk.Keypair
  .fromSecret('SCZANGBA5YHTNYVVV4C3U252E2B6P6F5T3U6MM63WBSBZATAQI3EBTQ4');

server.loadAccount(issuingKeys.publicKey())
  .then(function(issuer) {
    var transaction = new StellarSdk.TransactionBuilder(issuer)
      .addOperation(StellarSdk.Operation.setOptions({
        homeDomain: 'yourdomain.com',
      })).setTimeout(1000)
      .build();
    transaction.sign(issuingKeys);
    return server.submitTransaction(transaction);
  })
  .catch(function(error) {
    console.error('Error!', error);
  });

Update the whole document by adding setTimeout where StellarSdk.TransactionBuilder() is used

@pdogbc
Copy link

pdogbc commented Mar 9, 2019

This should be updated in all relevant examples on the website e.g. on https://www.stellar.org/developers/guides/get-started/transactions.html

@bartekn
Copy link
Contributor

bartekn commented Mar 12, 2019

The doc linked above should indeed be updated.

@bartekn bartekn reopened this Mar 12, 2019
chaseoli added a commit to chaseoli/js-stellar-base that referenced this issue Feb 10, 2020
Related to stellar-deprecated/docs#431 I think the `.setTimeout()` was missed in this example.
abuiles pushed a commit to stellar/js-stellar-base that referenced this issue Feb 10, 2020
Related to stellar-deprecated/docs#431 I think the `.setTimeout()` was missed in this example.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants