changed testnet send ton functionality to mainnet
This commit is contained in:
parent
bfbe6b29b5
commit
6f6500dc7b
@ -1180,7 +1180,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get TON balance
|
// Get TON balance
|
||||||
const balance = await tonBlockchainAPI.getTestnetBalance(
|
const balance = await tonBlockchainAPI.getMainnetBalance(
|
||||||
tonAddress
|
tonAddress
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -13,11 +13,11 @@
|
|||||||
let tonweb;
|
let tonweb;
|
||||||
if (typeof TonWeb !== "undefined") {
|
if (typeof TonWeb !== "undefined") {
|
||||||
tonweb = new TonWeb(
|
tonweb = new TonWeb(
|
||||||
new TonWeb.HttpProvider("https://testnet.toncenter.com/api/v2/jsonRPC"),
|
new TonWeb.HttpProvider("https://toncenter.com/api/v2/jsonRPC"),
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"X-API-Key":
|
"X-API-Key":
|
||||||
"f100216d884fe3d57c9fbbdd8bcea727f387e7d86e4105bd4b15e63979c2fc74",
|
API_KEY,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -262,14 +262,17 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get testnet balance for an address
|
* Get balance for an address
|
||||||
* @param {string} address - The TON address to check on testnet
|
* @param {string} address - The TON address to check
|
||||||
* @returns {Promise} Promise object that resolves with balance in TON
|
* @returns {Promise} Promise object that resolves with balance in TON
|
||||||
*/
|
*/
|
||||||
tonBlockchainAPI.getTestnetBalance = function (address) {
|
tonBlockchainAPI.getMainnetBalance = function (address) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
fetch(
|
fetch(
|
||||||
`https://testnet.toncenter.com/api/v2/getAddressBalance?address=${address}`
|
`https://toncenter.com/api/v2/getAddressBalance?address=${address}`,
|
||||||
|
{
|
||||||
|
headers: { "X-API-Key": API_KEY },
|
||||||
|
}
|
||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (!response.ok)
|
if (!response.ok)
|
||||||
@ -322,7 +325,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send TON transaction on testnet
|
* Send TON transaction
|
||||||
* @param {string} privHex - Private key in hexadecimal format
|
* @param {string} privHex - Private key in hexadecimal format
|
||||||
* @param {string} toAddress - Recipient's TON address
|
* @param {string} toAddress - Recipient's TON address
|
||||||
* @param {string|number} amount - Amount to send in TON
|
* @param {string|number} amount - Amount to send in TON
|
||||||
@ -388,7 +391,10 @@
|
|||||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||||
|
|
||||||
const txRes = await fetch(
|
const txRes = await fetch(
|
||||||
`https://testnet.toncenter.com/api/v2/getTransactions?address=${senderAddr}&limit=5`
|
`https://toncenter.com/api/v2/getTransactions?address=${senderAddr}&limit=5`,
|
||||||
|
{
|
||||||
|
headers: { "X-API-Key": API_KEY },
|
||||||
|
}
|
||||||
);
|
);
|
||||||
const txData = await txRes.json();
|
const txData = await txRes.json();
|
||||||
const txs = txData.result || [];
|
const txs = txData.result || [];
|
||||||
@ -404,7 +410,7 @@
|
|||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
urlHash,
|
urlHash,
|
||||||
explorerUrl: `https://testnet.tonviewer.com/transaction/${urlHash}`,
|
explorerUrl: `https://tonviewer.com/transaction/${urlHash}`,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user