@@ -122,6 +122,10 @@ The following code demonstrates how to implement the application’s side of thi
122
122
123
123
124
124
``` python
125
+ import requests
126
+ from stellar_sdk import Network
127
+ from stellar_sdk.sep.stellar_web_authentication import read_challenge_transaction
128
+
125
129
def get_token () -> str :
126
130
query = f " { AUTH_URL } ?account= { AUTH_PUBLIC_KEY } &memo= { USER_ID } "
127
131
response = requests.get(query)
@@ -165,6 +169,8 @@ The following code can be used as a reference for implementing this logic yourse
165
169
166
170
167
171
``` python
172
+ import requests
173
+
168
174
def initiate_withdraw (token : str , amount : str ) -> Tuple[str , str ]:
169
175
post_body = {
170
176
" asset_code" : ASSET_CODE , # USDC
@@ -239,6 +245,8 @@ This code uses a simple polling mechanism with no bail-out condition. The applic
239
245
240
246
241
247
``` python
248
+ import requests
249
+
242
250
response_body = poll_transaction_until_status(
243
251
transaction_id,
244
252
token = token,
@@ -292,6 +300,10 @@ Below is highly simplified code for submitting a payment transaction. It does no
292
300
293
301
294
302
``` python
303
+ from stellar_sdk import (
304
+ Server, TransactionBuilder, Network, Asset, IdMemo
305
+ )
306
+
295
307
submit_payment(
296
308
destination = response_body[" transaction" ][" withdraw_anchor_account" ],
297
309
memo = response_body[" transaction" ][" withdraw_memo" ],
@@ -334,6 +346,9 @@ Note that this code does not handle [path payments] or [claimable balances], two
334
346
335
347
336
348
``` python
349
+ from stellar_sdk import Server
350
+ from .queries import get_transaction_by_memo
351
+
337
352
def stream_payments (account : str , cursor : str ):
338
353
s = Server()
339
354
payments = s.payments().for_account(account).join(" transactions" )
@@ -342,14 +357,14 @@ def stream_payments(account: str, cursor: str):
342
357
payment[" type" ] != " payment"
343
358
or payment[" from" ] == account
344
359
or payment[" asset_type" ] == " native"
345
- or payment[" asset_code" ] != " USDC "
346
- or payment[" asset_issuer" ] != USDC_ISSUER
360
+ or payment[" asset_code" ] != ASSET_CODE
361
+ or payment[" asset_issuer" ] != ASSET_ISSUER
347
362
):
348
363
continue
349
364
transaction = get_transaction_by_memo(
350
365
payment[" transaction" ][" memo" ],
351
366
payment[" transaction" ][" memo_type" ]
352
- )
367
+ ) # DB query
353
368
if not transaction:
354
369
continue
355
370
print (
@@ -374,6 +389,8 @@ Note that MoneyGram’s transaction details page is protected with a JWT token i
374
389
375
390
376
391
``` python
392
+ from .api import poll_transction_until_status
393
+
377
394
response_body = poll_transaction_until_status(
378
395
transaction_id,
379
396
" pending_user_transfer_complete"
0 commit comments