@@ -20,7 +20,7 @@ import {
2020import BigNumber from 'bignumber.js'
2121
2222const HORIZON_URL = 'https://horizon.stellar.org'
23- const NETWORK_PASSPHRASE = 'NETWORK_PASSPHRASE'
23+ const NETWORK_PASSPHRASE = 'NETWORK_PASSPHRASE' // eg. 'Public Global Stellar Network ; September 2015'
2424
2525const SECRET_KEY = 'YOUR_STELLAR_SECRET_KEY'
2626const API_KEY = 'c6381a79-2817-4602-83bf-6a641a409e32'
@@ -36,7 +36,7 @@ const SOROBAN_OP_TYPES = [
3636]
3737
3838const SOURCE_CHAIN = 'STELLAR'
39- const SOURCE_TOKEN_ADDR = null
39+ const SOURCE_TOKEN_ADDR = 'SOURCE_TOKEN_ADDR' // eg. 'USDC-GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'
4040const DESTINATION_CHAIN = 'DESTINATION_CHAIN' // eg. BSC
4141const DESTINATION_TOKEN_ADDR = 'DESTINATION_TOKEN_ADDR' // eg. 0x55d398326f99059ff775485246999027b3197955
4242const DESTINATION_ADDRESS = 'DESTINATION_ADDRESS' // eg. 0x8b5b3F18db50713709da94f88f9f5EEc339D1E4E
@@ -78,24 +78,23 @@ async function checkStellarChangeTrustLinePrerequisite(
7878 const server = new StellarSdk . Horizon . Server ( HORIZON_URL )
7979 const account = await server . loadAccount ( prerequisite . wallet )
8080
81- const balanceLines = account . balances . filter (
81+ const accountLines = account . balances . filter (
8282 ( balance ) =>
8383 balance . asset_type !== 'native' &&
8484 balance . asset_type !== 'liquidity_pool_shares'
8585 )
8686
87- const targetBalanceLine = balanceLines . find (
88- ( balanceLine ) =>
89- balanceLine . asset_code === prerequisite . code &&
90- balanceLine . asset_issuer === prerequisite . issuer
87+ const targetAccountLine = accountLines . find (
88+ ( accountLine ) =>
89+ accountLine . asset_code === prerequisite . code &&
90+ accountLine . asset_issuer === prerequisite . issuer
9191 )
9292
93- if ( targetBalanceLine ) {
94- const lineLimit = new BigNumber ( targetBalanceLine . limit )
95- const lineBalance = new BigNumber ( targetBalanceLine . balance )
96- const prerequisiteValue = new BigNumber ( prerequisite . value )
93+ if ( targetAccountLine ) {
94+ const lineLimit = new BigNumber ( targetAccountLine . limit )
95+ const targetLimit = new BigNumber ( TRUST_LINE_INFINITE_VALUE )
9796
98- if ( lineLimit . gte ( lineBalance . plus ( prerequisiteValue ) ) ) {
97+ if ( lineLimit . gte ( targetLimit ) ) {
9998 console . log ( 'Trust line already opened' )
10099 return
101100 }
0 commit comments