@tatumio/bsc 2.0.1-alpha.327 → 2.0.1-alpha.329
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tatumio/bsc",
|
|
3
|
-
"version": "2.0.1-alpha.
|
|
3
|
+
"version": "2.0.1-alpha.329",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@tatumio/shared-testing-evm-based": "2.0.1-alpha.
|
|
9
|
-
"@tatumio/shared-testing-common": "2.0.1-alpha.
|
|
10
|
-
"@tatumio/api-client": "2.0.1-alpha.
|
|
8
|
+
"@tatumio/shared-testing-evm-based": "2.0.1-alpha.329",
|
|
9
|
+
"@tatumio/shared-testing-common": "2.0.1-alpha.329",
|
|
10
|
+
"@tatumio/api-client": "2.0.1-alpha.329",
|
|
11
11
|
"axios": "^0.26.0",
|
|
12
12
|
"form-data": "^4.0.0",
|
|
13
|
-
"@tatumio/shared-blockchain-evm-based": "2.0.1-alpha.
|
|
14
|
-
"@tatumio/shared-abstract-sdk": "2.0.1-alpha.
|
|
13
|
+
"@tatumio/shared-blockchain-evm-based": "2.0.1-alpha.329",
|
|
14
|
+
"@tatumio/shared-abstract-sdk": "2.0.1-alpha.329",
|
|
15
15
|
"bignumber.js": "^9.0.2",
|
|
16
|
-
"@tatumio/shared-core": "2.0.1-alpha.
|
|
17
|
-
"@tatumio/shared-blockchain-abstract": "2.0.1-alpha.
|
|
16
|
+
"@tatumio/shared-core": "2.0.1-alpha.329",
|
|
17
|
+
"@tatumio/shared-blockchain-abstract": "2.0.1-alpha.329",
|
|
18
18
|
"ethereumjs-wallet": "^1.0.2",
|
|
19
19
|
"bip39": "^3.0.2",
|
|
20
20
|
"web3": "^1.7.4",
|
package/src/lib/bsc.sdk.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Web3Request, Web3Response } from '@tatumio/shared-core';
|
|
2
|
-
import { BlockchainFeesService, BnbSmartChainService, FungibleTokensErc20OrCompatibleService } from '@tatumio/api-client';
|
|
2
|
+
import { BlockchainFeesService, BlockchainUtilsService, BnbSmartChainService, FungibleTokensErc20OrCompatibleService } from '@tatumio/api-client';
|
|
3
3
|
import { SDKArguments } from '@tatumio/shared-abstract-sdk';
|
|
4
4
|
export declare const TatumBscSDK: (args: SDKArguments) => {
|
|
5
5
|
kms: {
|
|
@@ -118,7 +118,7 @@ export declare const TatumBscSDK: (args: SDKArguments) => {
|
|
|
118
118
|
getBalanceBatch: typeof import("@tatumio/api-client").MultiTokensErc1155OrCompatibleService.multiTokenGetBalanceBatch;
|
|
119
119
|
getMetadata: typeof import("@tatumio/api-client").MultiTokensErc1155OrCompatibleService.multiTokenGetMetadata;
|
|
120
120
|
};
|
|
121
|
-
|
|
121
|
+
custodial: {
|
|
122
122
|
prepare: {
|
|
123
123
|
transferFromCustodialWallet: (body: import("../../../../../dist/packages/shared/blockchain/abstract/src").ChainTransferCustodialWallet, provider?: string, testnet?: boolean) => Promise<any>;
|
|
124
124
|
batchTransferFromCustodialWallet: (body: import("../../../../../dist/packages/shared/blockchain/abstract/src").ChainBatchTransferCustodialWallet, provider?: string, testnet?: boolean) => Promise<any>;
|
|
@@ -210,12 +210,39 @@ export declare const TatumBscSDK: (args: SDKArguments) => {
|
|
|
210
210
|
get: typeof BnbSmartChainService.bscGetTransaction;
|
|
211
211
|
estimateGas: typeof BlockchainFeesService.bscEstimateGas;
|
|
212
212
|
smartContractInvocation: typeof BnbSmartChainService.bscBlockchainSmartContractInvocation;
|
|
213
|
+
smartContractGetAddress: typeof BlockchainUtilsService.scGetContractAddress;
|
|
213
214
|
blockchainTransfer: typeof BnbSmartChainService.bscBlockchainTransfer;
|
|
214
215
|
generateAddress: typeof BnbSmartChainService.bscGenerateAddress;
|
|
215
216
|
generateAddressPrivateKey: typeof BnbSmartChainService.bscGenerateAddressPrivateKey;
|
|
216
217
|
generateWallet: typeof BnbSmartChainService.bscGenerateWallet;
|
|
217
218
|
web3Driver: typeof BnbSmartChainService.bscWeb3Driver;
|
|
218
219
|
};
|
|
220
|
+
virtualAccount: {
|
|
221
|
+
send: (body: Omit<import("@tatumio/api-client").TransferBsc, "fromPrivateKey"> & Partial<import("@tatumio/api-client").SignatureId & {
|
|
222
|
+
index: number;
|
|
223
|
+
}> & Partial<{
|
|
224
|
+
mnemonic: string;
|
|
225
|
+
}> & Partial<Pick<import("@tatumio/api-client").TransferBsc, "fromPrivateKey">>) => Promise<(void | {
|
|
226
|
+
id?: string;
|
|
227
|
+
txId?: string;
|
|
228
|
+
completed?: boolean;
|
|
229
|
+
}) | import("@tatumio/api-client").OffchainTransactionSignatureResult>;
|
|
230
|
+
depositAddress: {
|
|
231
|
+
checkExists: (address: string, index?: number) => Promise<any>;
|
|
232
|
+
create: any;
|
|
233
|
+
createMultiple: any;
|
|
234
|
+
assign: any;
|
|
235
|
+
remove: any;
|
|
236
|
+
getByAccount: any;
|
|
237
|
+
};
|
|
238
|
+
withdrawal: {
|
|
239
|
+
getAll: (status?: "InProgress" | "Done" | "Cancelled", pageSize?: number, offset?: number) => Promise<any[]>;
|
|
240
|
+
broadcast: any;
|
|
241
|
+
create: any;
|
|
242
|
+
complete: any;
|
|
243
|
+
};
|
|
244
|
+
storeTokenAddress: any;
|
|
245
|
+
};
|
|
219
246
|
web3Client: (provider?: string, fromPrivateKey?: string) => import("web3").default;
|
|
220
247
|
record: {
|
|
221
248
|
getLog(id: string): import("@tatumio/api-client").CancelablePromise<{
|
|
@@ -273,4 +300,63 @@ export declare const TatumBscSDK: (args: SDKArguments) => {
|
|
|
273
300
|
delete: typeof import("@tatumio/api-client").CustodialManagedWalletsService.custodialDeleteWallet;
|
|
274
301
|
get: typeof import("@tatumio/api-client").CustodialManagedWalletsService.custodialGetWallet;
|
|
275
302
|
};
|
|
303
|
+
ledger: {
|
|
304
|
+
customer: {
|
|
305
|
+
get: typeof import("@tatumio/api-client").CustomerService.getCustomerByExternalOrInternalId;
|
|
306
|
+
getAll: typeof import("@tatumio/api-client").CustomerService.findAllCustomers;
|
|
307
|
+
update: typeof import("@tatumio/api-client").CustomerService.updateCustomer;
|
|
308
|
+
activate: typeof import("@tatumio/api-client").CustomerService.activateCustomer;
|
|
309
|
+
deactivate: typeof import("@tatumio/api-client").CustomerService.deactivateCustomer;
|
|
310
|
+
enable: typeof import("@tatumio/api-client").CustomerService.enableCustomer;
|
|
311
|
+
disable: typeof import("@tatumio/api-client").CustomerService.disableCustomer;
|
|
312
|
+
};
|
|
313
|
+
orderBook: {
|
|
314
|
+
getHistorical: typeof import("@tatumio/api-client").OrderBookService.getHistoricalTradesBody;
|
|
315
|
+
getActiveBuyTrades: typeof import("@tatumio/api-client").OrderBookService.getBuyTradesBody;
|
|
316
|
+
getActiveSellTrades: typeof import("@tatumio/api-client").OrderBookService.getSellTradesBody;
|
|
317
|
+
newTrade: typeof import("@tatumio/api-client").OrderBookService.storeTrade;
|
|
318
|
+
get: typeof import("@tatumio/api-client").OrderBookService.getTradeById;
|
|
319
|
+
cancel: typeof import("@tatumio/api-client").OrderBookService.deleteTrade;
|
|
320
|
+
cancelByAccount: typeof import("@tatumio/api-client").OrderBookService.deleteAccountTrades;
|
|
321
|
+
};
|
|
322
|
+
transaction: {
|
|
323
|
+
send: typeof import("@tatumio/api-client").TransactionService.sendTransaction;
|
|
324
|
+
sendMultiple: typeof import("@tatumio/api-client").TransactionService.sendTransactionBatch;
|
|
325
|
+
getAll: typeof import("@tatumio/api-client").TransactionService.getTransactions;
|
|
326
|
+
getAllByAccount: typeof import("@tatumio/api-client").TransactionService.getTransactionsByAccountId;
|
|
327
|
+
getAllByCustomer: typeof import("@tatumio/api-client").TransactionService.getTransactionsByCustomerId;
|
|
328
|
+
getAllByReference: typeof import("@tatumio/api-client").TransactionService.getTransactionsByReference;
|
|
329
|
+
countByAccount: (filter: import("@tatumio/api-client").TransactionFilter) => import("@tatumio/api-client").CancelablePromise<number | import("@tatumio/api-client").Transaction[]>;
|
|
330
|
+
countByCustomer: (filter: import("@tatumio/api-client").TransactionFilterCustomer) => import("@tatumio/api-client").CancelablePromise<number | import("@tatumio/api-client").Transaction[]>;
|
|
331
|
+
};
|
|
332
|
+
virtualCurrency: {
|
|
333
|
+
create: typeof import("@tatumio/api-client").VirtualCurrencyService.createCurrency;
|
|
334
|
+
mint: typeof import("@tatumio/api-client").VirtualCurrencyService.mintCurrency;
|
|
335
|
+
revoke: typeof import("@tatumio/api-client").VirtualCurrencyService.revokeCurrency;
|
|
336
|
+
getByName: typeof import("@tatumio/api-client").VirtualCurrencyService.getCurrency;
|
|
337
|
+
update: typeof import("@tatumio/api-client").VirtualCurrencyService.updateCurrency;
|
|
338
|
+
};
|
|
339
|
+
blockAmount: {
|
|
340
|
+
block: typeof import("@tatumio/api-client").AccountService.blockAmount;
|
|
341
|
+
unblock: typeof import("@tatumio/api-client").AccountService.deleteBlockAmount;
|
|
342
|
+
unblockWithTransaction: typeof import("@tatumio/api-client").AccountService.unblockAmountWithTransaction;
|
|
343
|
+
};
|
|
344
|
+
account: {
|
|
345
|
+
get: typeof import("@tatumio/api-client").AccountService.getAccountByAccountId;
|
|
346
|
+
getAll: typeof import("@tatumio/api-client").AccountService.getAccounts;
|
|
347
|
+
getByCustomerId: typeof import("@tatumio/api-client").AccountService.getAccountsByCustomerId;
|
|
348
|
+
getBalance: typeof import("@tatumio/api-client").AccountService.getAccountBalance;
|
|
349
|
+
create: typeof import("@tatumio/api-client").AccountService.createAccount;
|
|
350
|
+
createMultiple: typeof import("@tatumio/api-client").AccountService.createAccountBatch;
|
|
351
|
+
update: typeof import("@tatumio/api-client").AccountService.updateAccountByAccountId;
|
|
352
|
+
getBlockedAmountsByAccountId: typeof import("@tatumio/api-client").AccountService.getBlockAmountById;
|
|
353
|
+
activate: typeof import("@tatumio/api-client").AccountService.activateAccount;
|
|
354
|
+
deactivate: typeof import("@tatumio/api-client").AccountService.deactivateAccount;
|
|
355
|
+
freeze: typeof import("@tatumio/api-client").AccountService.freezeAccount;
|
|
356
|
+
unfreeze: typeof import("@tatumio/api-client").AccountService.unfreezeAccount;
|
|
357
|
+
generate: (account: import("@tatumio/api-client").CreateAccount & {
|
|
358
|
+
xpub?: string;
|
|
359
|
+
}, generateNewWalletFn: any, generateNewWallet?: boolean, testnet?: boolean, webhookUrl?: string) => Promise<any>;
|
|
360
|
+
};
|
|
361
|
+
};
|
|
276
362
|
};
|
package/src/lib/bsc.sdk.js
CHANGED
|
@@ -9,10 +9,12 @@ const bsc_web3_1 = require("./services/bsc.web3");
|
|
|
9
9
|
const bsc_kms_1 = require("./services/bsc.kms");
|
|
10
10
|
const bsc_tx_1 = require("./services/bsc.tx");
|
|
11
11
|
const bsc_auction_1 = require("./services/bsc.auction");
|
|
12
|
+
const bsc_virtualAccount_1 = require("./services/bsc.virtualAccount");
|
|
12
13
|
const blockchain = shared_core_1.Blockchain.BSC;
|
|
13
14
|
const TatumBscSDK = (args) => {
|
|
14
15
|
const web3 = (0, bsc_web3_1.bscWeb3)({ blockchain });
|
|
15
16
|
const api = api_client_1.BnbSmartChainService;
|
|
17
|
+
const virtualAccount = (0, bsc_virtualAccount_1.virtualAccountService)({ blockchain, web3 });
|
|
16
18
|
const txService = (0, bsc_tx_1.bscTxService)({ blockchain, web3 });
|
|
17
19
|
const _a = (0, shared_blockchain_evm_based_1.evmBasedSdk)(Object.assign(Object.assign({}, args), { blockchain, web3 })), { nft } = _a, evmSdk = tslib_1.__rest(_a, ["nft"]);
|
|
18
20
|
const { deployNFTSmartContract, mintNFT, transferNFT, mintMultipleNFTs, burnNFT, addNFTMinter, updateNFTRoyalty, getNFTTransaction, getNFTAccountBalance, getNFTProvenanceData, getNFTMetadataURI, getNFTRoyalty, } = nft;
|
|
@@ -27,7 +29,7 @@ const TatumBscSDK = (args) => {
|
|
|
27
29
|
getNFTAccountBalance,
|
|
28
30
|
getNFTProvenanceData,
|
|
29
31
|
getNFTMetadataURI,
|
|
30
|
-
getNFTRoyalty }), smartContract: txService.smartContract, multiToken: txService.multiToken,
|
|
32
|
+
getNFTRoyalty }), smartContract: txService.smartContract, multiToken: txService.multiToken, custodial: txService.custodial, gasPump: txService.gasPump, marketplace: Object.assign({ auction: (0, bsc_auction_1.bscAuctionService)({ blockchain, web3 }) }, (0, shared_blockchain_evm_based_1.evmBasedMarketplace)({
|
|
31
33
|
blockchain,
|
|
32
34
|
web3,
|
|
33
35
|
broadcastFunction: api_client_1.BnbSmartChainService.bscBroadcast,
|
|
@@ -42,12 +44,13 @@ const TatumBscSDK = (args) => {
|
|
|
42
44
|
get: api_client_1.BnbSmartChainService.bscGetTransaction,
|
|
43
45
|
estimateGas: api_client_1.BlockchainFeesService.bscEstimateGas,
|
|
44
46
|
smartContractInvocation: api_client_1.BnbSmartChainService.bscBlockchainSmartContractInvocation,
|
|
47
|
+
smartContractGetAddress: api_client_1.BlockchainUtilsService.scGetContractAddress,
|
|
45
48
|
blockchainTransfer: api_client_1.BnbSmartChainService.bscBlockchainTransfer,
|
|
46
49
|
generateAddress: api_client_1.BnbSmartChainService.bscGenerateAddress,
|
|
47
50
|
generateAddressPrivateKey: api_client_1.BnbSmartChainService.bscGenerateAddressPrivateKey,
|
|
48
51
|
generateWallet: api_client_1.BnbSmartChainService.bscGenerateWallet,
|
|
49
52
|
web3Driver: api_client_1.BnbSmartChainService.bscWeb3Driver,
|
|
50
|
-
} });
|
|
53
|
+
}, virtualAccount });
|
|
51
54
|
};
|
|
52
55
|
exports.TatumBscSDK = TatumBscSDK;
|
|
53
56
|
//# sourceMappingURL=bsc.sdk.js.map
|
package/src/lib/bsc.sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bsc.sdk.js","sourceRoot":"","sources":["../../../../../../packages/blockchain/bsc/src/lib/bsc.sdk.ts"],"names":[],"mappings":";;;;AAAA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AE,iCAAoB,CAAC,iBAAiB;YACtD,UAAU,EAAE,iCAAoB,CAAC,aAAa;SAC/C,EACD,cAAc,IACf;AACH,CAAC,CAAA;AA/EY,QAAA,WAAW,eA+EvB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TransferBsc } from '@tatumio/api-client';
|
|
2
|
+
import { FromPrivateKeyOrSignatureIdOrMnemonic } from '@tatumio/shared-blockchain-abstract';
|
|
3
|
+
import { EvmBasedWeb3 } from '@tatumio/shared-blockchain-evm-based';
|
|
4
|
+
import { Blockchain } from '@tatumio/shared-core';
|
|
5
|
+
declare type TransferVirtualAccountBsc = FromPrivateKeyOrSignatureIdOrMnemonic<TransferBsc>;
|
|
6
|
+
declare type VirtualAccountResponse = {
|
|
7
|
+
id?: string;
|
|
8
|
+
txId?: string;
|
|
9
|
+
completed?: boolean;
|
|
10
|
+
} | void;
|
|
11
|
+
export declare const virtualAccountService: (args: {
|
|
12
|
+
blockchain: Blockchain;
|
|
13
|
+
web3: EvmBasedWeb3;
|
|
14
|
+
}) => {
|
|
15
|
+
/**
|
|
16
|
+
* Send Bsc transaction from Tatum Ledger account to the blockchain. This method broadcasts signed transaction to the blockchain.
|
|
17
|
+
* This operation is irreversible.
|
|
18
|
+
* @param body content of the transaction to broadcast
|
|
19
|
+
* @returns transaction id of the transaction in the blockchain or id of the withdrawal, if it was not cancelled automatically
|
|
20
|
+
*/
|
|
21
|
+
send: (body: TransferVirtualAccountBsc) => Promise<VirtualAccountResponse | import("@tatumio/api-client").OffchainTransactionSignatureResult>;
|
|
22
|
+
depositAddress: {
|
|
23
|
+
checkExists: (address: string, index?: number) => Promise<any>;
|
|
24
|
+
create: any;
|
|
25
|
+
createMultiple: any;
|
|
26
|
+
assign: any;
|
|
27
|
+
remove: any;
|
|
28
|
+
getByAccount: any;
|
|
29
|
+
};
|
|
30
|
+
withdrawal: {
|
|
31
|
+
getAll: (status?: "InProgress" | "Done" | "Cancelled", pageSize?: number, offset?: number) => Promise<any[]>;
|
|
32
|
+
broadcast: any;
|
|
33
|
+
create: any;
|
|
34
|
+
complete: any;
|
|
35
|
+
};
|
|
36
|
+
storeTokenAddress: any;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.virtualAccountService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const api_client_1 = require("@tatumio/api-client");
|
|
6
|
+
const shared_blockchain_abstract_1 = require("@tatumio/shared-blockchain-abstract");
|
|
7
|
+
const shared_blockchain_evm_based_1 = require("@tatumio/shared-blockchain-evm-based");
|
|
8
|
+
const shared_core_1 = require("@tatumio/shared-core");
|
|
9
|
+
const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
|
|
10
|
+
const bsc_tx_1 = require("./bsc.tx");
|
|
11
|
+
const sendBscVirtualAccountTransaction = (body, web3) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
const txService = (0, bsc_tx_1.bscTxService)({ blockchain: shared_core_1.Blockchain.BSC, web3 });
|
|
13
|
+
const { mnemonic, index, fromPrivateKey, gasLimit, gasPrice, nonce } = body, withdrawal = tslib_1.__rest(body, ["mnemonic", "index", "fromPrivateKey", "gasLimit", "gasPrice", "nonce"]);
|
|
14
|
+
const { amount, address } = withdrawal;
|
|
15
|
+
let fromPrivKey;
|
|
16
|
+
let txData;
|
|
17
|
+
if (body.mnemonic && body.index !== undefined) {
|
|
18
|
+
fromPrivKey = (yield shared_blockchain_evm_based_1.evmBasedUtils.generatePrivateKeyFromMnemonic(shared_core_1.Blockchain.BSC, body.mnemonic, body.index));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
fromPrivKey = body.fromPrivateKey;
|
|
22
|
+
}
|
|
23
|
+
const account = yield api_client_1.AccountService.getAccountByAccountId(body.senderAccountId);
|
|
24
|
+
const fee = {
|
|
25
|
+
gasLimit: gasLimit || '21000',
|
|
26
|
+
gasPrice: gasPrice || '20',
|
|
27
|
+
};
|
|
28
|
+
if (account.currency === 'BSC') {
|
|
29
|
+
txData = txService.native.send.transferSignedTransaction({
|
|
30
|
+
amount,
|
|
31
|
+
fromPrivateKey: fromPrivKey,
|
|
32
|
+
fee,
|
|
33
|
+
nonce: body.nonce,
|
|
34
|
+
to: address,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
fee.gasLimit = '100000';
|
|
39
|
+
let contractAddress;
|
|
40
|
+
let decimals;
|
|
41
|
+
if (api_client_1.BEP20_CURRENCIES.includes(account.currency)) {
|
|
42
|
+
contractAddress = shared_core_1.CONTRACT_ADDRESSES[account.currency];
|
|
43
|
+
decimals = shared_core_1.CONTRACT_DECIMALS[account.currency];
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const vc = yield api_client_1.VirtualCurrencyService.getCurrency(account.currency);
|
|
47
|
+
contractAddress = vc.erc20Address;
|
|
48
|
+
decimals = vc.precision || 18;
|
|
49
|
+
}
|
|
50
|
+
txData = yield txService.erc20.send.transferSignedTransaction({
|
|
51
|
+
amount,
|
|
52
|
+
fee,
|
|
53
|
+
fromPrivateKey: fromPrivKey,
|
|
54
|
+
to: address,
|
|
55
|
+
digits: decimals,
|
|
56
|
+
nonce: body.nonce,
|
|
57
|
+
contractAddress,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const withdrawalFee = web3
|
|
61
|
+
.getClient()
|
|
62
|
+
.utils.fromWei(new bignumber_js_1.default(fee.gasLimit).multipliedBy(shared_blockchain_evm_based_1.evmBasedUtils.transformToWei(fee.gasPrice, 'gwei')).toString(), 'ether');
|
|
63
|
+
const withdrawalBody = Object.assign(Object.assign({}, withdrawal), { fee: withdrawalFee });
|
|
64
|
+
const { id } = yield api_client_1.WithdrawalService.storeWithdrawal(withdrawalBody);
|
|
65
|
+
try {
|
|
66
|
+
return Object.assign(Object.assign({}, (yield api_client_1.WithdrawalService.broadcastBlockchainTransaction({
|
|
67
|
+
txData,
|
|
68
|
+
withdrawalId: id,
|
|
69
|
+
currency: api_client_1.Currency.BSC,
|
|
70
|
+
}))), { id });
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
try {
|
|
74
|
+
return yield api_client_1.WithdrawalService.cancelInProgressWithdrawal(id);
|
|
75
|
+
}
|
|
76
|
+
catch (e1) {
|
|
77
|
+
return { id };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const virtualAccountService = (args) => {
|
|
82
|
+
return Object.assign(Object.assign({}, (0, shared_blockchain_abstract_1.abstractBlockchainOffchain)(args)), {
|
|
83
|
+
/**
|
|
84
|
+
* Send Bsc transaction from Tatum Ledger account to the blockchain. This method broadcasts signed transaction to the blockchain.
|
|
85
|
+
* This operation is irreversible.
|
|
86
|
+
* @param body content of the transaction to broadcast
|
|
87
|
+
* @returns transaction id of the transaction in the blockchain or id of the withdrawal, if it was not cancelled automatically
|
|
88
|
+
*/
|
|
89
|
+
send: (body) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
if (body.signatureId) {
|
|
91
|
+
return api_client_1.ApiServices.offChain.blockchain.bscOrBepTransfer(body);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
return yield sendBscVirtualAccountTransaction(body, args.web3);
|
|
95
|
+
}
|
|
96
|
+
}) });
|
|
97
|
+
};
|
|
98
|
+
exports.virtualAccountService = virtualAccountService;
|
|
99
|
+
//# sourceMappingURL=bsc.virtualAccount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bsc.virtualAccount.js","sourceRoot":"","sources":["../../../../../../../packages/blockchain/bsc/src/lib/services/bsc.virtualAccount.ts"],"names":[],"mappings":";;;;AAAA,oDAS4B;AAC5B,oFAG4C;AAC5C,sFAAkF;AAClF,sDAAwF;AACxF,wEAAoC;AACpC,qCAAuC;AAK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