-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
162 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
import {TonClient} from '@ton/ton'; | ||
import axios from 'axios'; | ||
import {Api, HttpClient} from 'tonapi-sdk-js'; | ||
|
||
import {toNano} from './utils/big-int.utils'; | ||
|
||
export const TON = 'ton'; | ||
export const USDT = 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'; | ||
export const WORKCHAIN = 0; | ||
|
||
export const DEBOUNCE_DUE_TIME = 300; | ||
|
||
export const GAS_AMOUNT = toNano('0.255', 9); | ||
export const JETTON_TRANSFER_GAS_AMOUNT = toNano('0.065', 9); | ||
|
||
export const API = axios.create({ | ||
baseURL: 'http://93.188.34.207/api' | ||
}); | ||
|
||
export const TON_CLIENT = new TonClient({ | ||
endpoint: `http://65.109.108.204:8088/jsonRPC` | ||
}); | ||
|
||
export const DEBOUNCE_DUE_TIME = 300; | ||
export const TON_API_CLIENT = new Api( | ||
new HttpClient({ | ||
baseUrl: 'https://tonapi.io' | ||
}) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface TransactionInfo { | ||
senderRawAddress: string; | ||
bocHash: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import {TransactionInfo} from '../../interfaces/transaction-info.interface.ts'; | ||
import {CalculatedSwapRoute} from '../../swap-routes/shared/calculated-swap-route.type.ts'; | ||
import {LoadableEntityState} from '../types'; | ||
import {createEntity} from '../utils/create-entity'; | ||
|
||
export interface SwapRoutesState { | ||
batch: LoadableEntityState<CalculatedSwapRoute[]>; | ||
pendingSwapTransaction: LoadableEntityState<TransactionInfo | undefined>; | ||
} | ||
|
||
export const swapRouteInitialState: SwapRoutesState = { | ||
batch: createEntity([]) | ||
batch: createEntity([]), | ||
pendingSwapTransaction: createEntity(undefined) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {TON_API_CLIENT} from '../globals'; | ||
|
||
const CHECK_INTERVAL = 1500; | ||
const TRANSACTION_CONFIRMATION_TIMEOUT = 5 * 1000; | ||
|
||
export const waitTransactionConfirmation = async ( | ||
senderRawAddress: string, | ||
bocHash: string | ||
) => | ||
new Promise<string>((resolve, reject) => { | ||
const timeoutId = setTimeout(() => { | ||
clearInterval(intervalId); | ||
clearTimeout(timeoutId); | ||
|
||
reject( | ||
`transaction confirmation timeout (sender: ${senderRawAddress}, hash: ${bocHash})` | ||
); | ||
}, TRANSACTION_CONFIRMATION_TIMEOUT); | ||
|
||
const intervalId = setInterval(async () => { | ||
const accountEvent = await TON_API_CLIENT.accounts | ||
.getAccountEvent(senderRawAddress, bocHash) | ||
.catch(() => ({ | ||
event_id: 'empty_event_id', | ||
in_progress: true | ||
})); | ||
|
||
if (!accountEvent.in_progress) { | ||
clearInterval(intervalId); | ||
clearTimeout(timeoutId); | ||
|
||
resolve(accountEvent.event_id); | ||
} | ||
}, CHECK_INTERVAL); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters