@@ -44,7 +44,7 @@ server = Server("https://horizon-testnet.stellar.org")
44
44
privateKey = " SAXBT6KO6NJ6SJXHBO6EBC7I5ZB7DZFYNPQOLXZJOKQ2LSGY5FU7ZJZB"
45
45
publicKey = " GBRPYHIL2CI3R5N4A7WMBETDZQ24DXFQGNCJWHXPFRGFWZHJZZBDTWR2"
46
46
47
- # Asset config
47
+ # Asset setup
48
48
astroDollar = Asset(" AstroDollar" , " GDRM3MK6KMHSYIT4E2AG2S2LWTDBJNYXE4H72C7YTTRWOWX5ZBECFWO7" )
49
49
astroPeso = Asset(" AstroPeso" , " GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5" )
50
50
@@ -72,7 +72,7 @@ const server = new Server("https://horizon-testnet.stellar.org");
72
72
const privateKey = " SAXBT6KO6NJ6SJXHBO6EBC7I5ZB7DZFYNPQOLXZJOKQ2LSGY5FU7ZJZB" ;
73
73
const publicKey = " GBRPYHIL2CI3R5N4A7WMBETDZQ24DXFQGNCJWHXPFRGFWZHJZZBDTWR2" ;
74
74
75
- // Asset config
75
+ // Asset setup
76
76
const astroDollar = new Asset (
77
77
" AstroDollar" ,
78
78
" GDRM3MK6KMHSYIT4E2AG2S2LWTDBJNYXE4H72C7YTTRWOWX5ZBECFWO7" ,
@@ -82,25 +82,39 @@ const astroPeso = new Asset(
82
82
" GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5" ,
83
83
);
84
84
85
- // pending newTxEnvelope(..)
85
+ function newTxBuilder (source , signer , ... ops ) {
86
+ let tx = new sdk.TransactionBuilder (source, {
87
+ fee: sdk .BASE_FEE ,
88
+ networkPassphrase: sdk .Networks .TESTNET ,
89
+ });
90
+ ops .forEach ((op ) => tx .addOperation (op));
91
+ tx = tx .setTimeout (360 ).build ();
92
+ tx .sign (signer);
93
+ return tx;
94
+ }
86
95
```
87
96
88
97
``` java
89
98
import org.stellar.sdk.* ;
90
99
import org.stellar.sdk.responses.AccountResponse ;
91
100
import org.stellar.sdk.responses.SubmitTransactionResponse ;
92
101
93
-
94
102
public class Liquidity {
95
103
static final Server server = new Server (" https://horizon-testnet.stellar.org" );
96
104
97
105
// Account setup
98
106
static String privateKey = " SAXBT6KO6NJ6SJXHBO6EBC7I5ZB7DZFYNPQOLXZJOKQ2LSGY5FU7ZJZB" ;
99
107
static String publicKey = " GBRPYHIL2CI3R5N4A7WMBETDZQ24DXFQGNCJWHXPFRGFWZHJZZBDTWR2" ;
100
108
101
- // Asset config
102
- Asset astroDollar = new AssetTypeCreditAlphaNum4 (" AstroDollar" , " GDRM3MK6KMHSYIT4E2AG2S2LWTDBJNYXE4H72C7YTTRWOWX5ZBECFWO7" );
103
- Asset astroPeso = new AssetTypeCreditAlphaNum4 (" AstroPeso" , " GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5" );
109
+ // Asset setup
110
+ Asset astroDollar = new AssetTypeCreditAlphaNum4 (
111
+ " AstroDollar" ,
112
+ " GDRM3MK6KMHSYIT4E2AG2S2LWTDBJNYXE4H72C7YTTRWOWX5ZBECFWO7"
113
+ );
114
+ Asset astroPeso = new AssetTypeCreditAlphaNum4 (
115
+ " AstroPeso" ,
116
+ " GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5"
117
+ );
104
118
105
119
public static Transaction .Builder newTxBuilder (KeyPair source ) {
106
120
AccountResponse sourceAccount = server. accounts(). account(source. getAccountId());
@@ -112,6 +126,15 @@ public class Liquidity {
112
126
```
113
127
114
128
``` go
129
+ import (
130
+ " fmt"
131
+ " strconv"
132
+ " github.com/stellar/go/keypair"
133
+ " github.com/stellar/go/txnbuild"
134
+ " github.com/stellar/go/clients/horizonclient"
135
+ " github.com/stellar/go/network"
136
+ )
137
+
115
138
func main () {
116
139
// Account setup
117
140
privateKey := " SAXBT6KO6NJ6SJXHBO6EBC7I5ZB7DZFYNPQOLXZJOKQ2LSGY5FU7ZJZB"
@@ -819,17 +842,6 @@ const [A, B] = orderAssets(
819
842
new sdk. Asset (" B" , kp0. publicKey()),
820
843
);
821
844
822
- function newTxBuilder(source, signer, .. . ops) {
823
- let tx = new sdk. TransactionBuilder (source, {
824
- fee: sdk. BASE_FEE ,
825
- networkPassphrase: sdk. Networks . TESTNET ,
826
- });
827
- ops. forEach((op) = > tx. addOperation(op));
828
- tx = tx. setTimeout(360 ). build();
829
- tx. sign(signer);
830
- return tx;
831
- }
832
-
833
845
// Establishes trustlines and funds `recipientKps` for all `assets`
834
846
function distributeAssets(issuerKp, recipientKps, .. . assets) {
835
847
return server. loadAccount(issuerKp. publicKey()). then((issuer) = > {
0 commit comments