@tatumio/bsc 2.0.1-alpha.327 → 2.0.1-alpha.328

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@tatumio/bsc",
3
- "version": "2.0.1-alpha.327",
3
+ "version": "2.0.1-alpha.328",
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.327",
9
- "@tatumio/shared-testing-common": "2.0.1-alpha.327",
10
- "@tatumio/api-client": "2.0.1-alpha.327",
8
+ "@tatumio/shared-testing-evm-based": "2.0.1-alpha.328",
9
+ "@tatumio/shared-testing-common": "2.0.1-alpha.328",
10
+ "@tatumio/api-client": "2.0.1-alpha.328",
11
11
  "axios": "^0.26.0",
12
12
  "form-data": "^4.0.0",
13
- "@tatumio/shared-blockchain-evm-based": "2.0.1-alpha.327",
14
- "@tatumio/shared-abstract-sdk": "2.0.1-alpha.327",
13
+ "@tatumio/shared-blockchain-evm-based": "2.0.1-alpha.328",
14
+ "@tatumio/shared-abstract-sdk": "2.0.1-alpha.328",
15
15
  "bignumber.js": "^9.0.2",
16
- "@tatumio/shared-core": "2.0.1-alpha.327",
17
- "@tatumio/shared-blockchain-abstract": "2.0.1-alpha.327",
16
+ "@tatumio/shared-core": "2.0.1-alpha.328",
17
+ "@tatumio/shared-blockchain-abstract": "2.0.1-alpha.328",
18
18
  "ethereumjs-wallet": "^1.0.2",
19
19
  "bip39": "^3.0.2",
20
20
  "web3": "^1.7.4",
@@ -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
- gasPucustodial: {
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>;
@@ -216,6 +216,32 @@ export declare const TatumBscSDK: (args: SDKArguments) => {
216
216
  generateWallet: typeof BnbSmartChainService.bscGenerateWallet;
217
217
  web3Driver: typeof BnbSmartChainService.bscWeb3Driver;
218
218
  };
219
+ virtualAccount: {
220
+ send: (body: Omit<import("@tatumio/api-client").TransferBsc, "fromPrivateKey"> & Partial<import("@tatumio/api-client").SignatureId & {
221
+ index: number;
222
+ }> & Partial<{
223
+ mnemonic: string;
224
+ }> & Partial<Pick<import("@tatumio/api-client").TransferBsc, "fromPrivateKey">>) => Promise<(void | {
225
+ id?: string;
226
+ txId?: string;
227
+ completed?: boolean;
228
+ }) | import("@tatumio/api-client").OffchainTransactionSignatureResult>;
229
+ depositAddress: {
230
+ checkExists: (address: string, index?: number) => Promise<any>;
231
+ create: any;
232
+ createMultiple: any;
233
+ assign: any;
234
+ remove: any;
235
+ getByAccount: any;
236
+ };
237
+ withdrawal: {
238
+ getAll: (status?: "InProgress" | "Done" | "Cancelled", pageSize?: number, offset?: number) => Promise<any[]>;
239
+ broadcast: any;
240
+ create: any;
241
+ complete: any;
242
+ };
243
+ storeTokenAddress: any;
244
+ };
219
245
  web3Client: (provider?: string, fromPrivateKey?: string) => import("web3").default;
220
246
  record: {
221
247
  getLog(id: string): import("@tatumio/api-client").CancelablePromise<{
@@ -273,4 +299,63 @@ export declare const TatumBscSDK: (args: SDKArguments) => {
273
299
  delete: typeof import("@tatumio/api-client").CustodialManagedWalletsService.custodialDeleteWallet;
274
300
  get: typeof import("@tatumio/api-client").CustodialManagedWalletsService.custodialGetWallet;
275
301
  };
302
+ ledger: {
303
+ customer: {
304
+ get: typeof import("@tatumio/api-client").CustomerService.getCustomerByExternalOrInternalId;
305
+ getAll: typeof import("@tatumio/api-client").CustomerService.findAllCustomers;
306
+ update: typeof import("@tatumio/api-client").CustomerService.updateCustomer;
307
+ activate: typeof import("@tatumio/api-client").CustomerService.activateCustomer;
308
+ deactivate: typeof import("@tatumio/api-client").CustomerService.deactivateCustomer;
309
+ enable: typeof import("@tatumio/api-client").CustomerService.enableCustomer;
310
+ disable: typeof import("@tatumio/api-client").CustomerService.disableCustomer;
311
+ };
312
+ orderBook: {
313
+ getHistorical: typeof import("@tatumio/api-client").OrderBookService.getHistoricalTradesBody;
314
+ getActiveBuyTrades: typeof import("@tatumio/api-client").OrderBookService.getBuyTradesBody;
315
+ getActiveSellTrades: typeof import("@tatumio/api-client").OrderBookService.getSellTradesBody;
316
+ newTrade: typeof import("@tatumio/api-client").OrderBookService.storeTrade;
317
+ get: typeof import("@tatumio/api-client").OrderBookService.getTradeById;
318
+ cancel: typeof import("@tatumio/api-client").OrderBookService.deleteTrade;
319
+ cancelByAccount: typeof import("@tatumio/api-client").OrderBookService.deleteAccountTrades;
320
+ };
321
+ transaction: {
322
+ send: typeof import("@tatumio/api-client").TransactionService.sendTransaction;
323
+ sendMultiple: typeof import("@tatumio/api-client").TransactionService.sendTransactionBatch;
324
+ getAll: typeof import("@tatumio/api-client").TransactionService.getTransactions;
325
+ getAllByAccount: typeof import("@tatumio/api-client").TransactionService.getTransactionsByAccountId;
326
+ getAllByCustomer: typeof import("@tatumio/api-client").TransactionService.getTransactionsByCustomerId;
327
+ getAllByReference: typeof import("@tatumio/api-client").TransactionService.getTransactionsByReference;
328
+ countByAccount: (filter: import("@tatumio/api-client").TransactionFilter) => import("@tatumio/api-client").CancelablePromise<number | import("@tatumio/api-client").Transaction[]>;
329
+ countByCustomer: (filter: import("@tatumio/api-client").TransactionFilterCustomer) => import("@tatumio/api-client").CancelablePromise<number | import("@tatumio/api-client").Transaction[]>;
330
+ };
331
+ virtualCurrency: {
332
+ create: typeof import("@tatumio/api-client").VirtualCurrencyService.createCurrency;
333
+ mint: typeof import("@tatumio/api-client").VirtualCurrencyService.mintCurrency;
334
+ revoke: typeof import("@tatumio/api-client").VirtualCurrencyService.revokeCurrency;
335
+ getByName: typeof import("@tatumio/api-client").VirtualCurrencyService.getCurrency;
336
+ update: typeof import("@tatumio/api-client").VirtualCurrencyService.updateCurrency;
337
+ };
338
+ blockAmount: {
339
+ block: typeof import("@tatumio/api-client").AccountService.blockAmount;
340
+ unblock: typeof import("@tatumio/api-client").AccountService.deleteBlockAmount;
341
+ unblockWithTransaction: typeof import("@tatumio/api-client").AccountService.unblockAmountWithTransaction;
342
+ };
343
+ account: {
344
+ get: typeof import("@tatumio/api-client").AccountService.getAccountByAccountId;
345
+ getAll: typeof import("@tatumio/api-client").AccountService.getAccounts;
346
+ getByCustomerId: typeof import("@tatumio/api-client").AccountService.getAccountsByCustomerId;
347
+ getBalance: typeof import("@tatumio/api-client").AccountService.getAccountBalance;
348
+ create: typeof import("@tatumio/api-client").AccountService.createAccount;
349
+ createMultiple: typeof import("@tatumio/api-client").AccountService.createAccountBatch;
350
+ update: typeof import("@tatumio/api-client").AccountService.updateAccountByAccountId;
351
+ getBlockedAmountsByAccountId: typeof import("@tatumio/api-client").AccountService.getBlockAmountById;
352
+ activate: typeof import("@tatumio/api-client").AccountService.activateAccount;
353
+ deactivate: typeof import("@tatumio/api-client").AccountService.deactivateAccount;
354
+ freeze: typeof import("@tatumio/api-client").AccountService.freezeAccount;
355
+ unfreeze: typeof import("@tatumio/api-client").AccountService.unfreezeAccount;
356
+ generate: (account: import("@tatumio/api-client").CreateAccount & {
357
+ xpub?: string;
358
+ }, generateNewWalletFn: any, generateNewWallet?: boolean, testnet?: boolean, webhookUrl?: string) => Promise<any>;
359
+ };
360
+ };
276
361
  };
@@ -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, gasPucustodial: txService.custodial, gasPump: txService.gasPump, marketplace: Object.assign({ auction: (0, bsc_auction_1.bscAuctionService)({ blockchain, web3 }) }, (0, shared_blockchain_evm_based_1.evmBasedMarketplace)({
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,
@@ -47,7 +49,7 @@ const TatumBscSDK = (args) => {
47
49
  generateAddressPrivateKey: api_client_1.BnbSmartChainService.bscGenerateAddressPrivateKey,
48
50
  generateWallet: api_client_1.BnbSmartChainService.bscGenerateWallet,
49
51
  web3Driver: api_client_1.BnbSmartChainService.bscWeb3Driver,
50
- } });
52
+ }, virtualAccount });
51
53
  };
52
54
  exports.TatumBscSDK = TatumBscSDK;
53
55
  //# sourceMappingURL=bsc.sdk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bsc.sdk.js","sourceRoot":"","sources":["../../../../../../packages/blockchain/bsc/src/lib/bsc.sdk.ts"],"names":[],"mappings":";;;;AAAA,sFAAuF;AACvF,sDAA4E;AAC5E,oDAI4B;AAE5B,kDAA6C;AAC7C,gDAAkD;AAClD,8CAAgD;AAChD,wDAA0D;AAE1D,MAAM,UAAU,GAAG,wBAAU,CAAC,GAAG,CAAA;AAE1B,MAAM,WAAW,GAAG,CAAC,IAAkB,EAAE,EAAE;IAChD,MAAM,IAAI,GAAG,IAAA,kBAAO,EAAC,EAAE,UAAU,EAAE,CAAC,CAAA;IACpC,MAAM,GAAG,GAAG,iCAAoB,CAAA;IAChC,MAAM,SAAS,GAAG,IAAA,qBAAY,EAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;IACpD,MAAM,KAAqB,IAAA,yCAAW,kCAAM,IAAI,KAAE,UAAU,EAAE,IAAI,IAAG,EAA/D,EAAE,GAAG,OAA0D,EAArD,MAAM,sBAAhB,OAAkB,CAA6C,CAAA;IAErE,MAAM,EACJ,sBAAsB,EACtB,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,GACd,GAAG,GAAG,CAAA;IAEP,uCACK,MAAM,KACT,GAAG,EAAE,IAAA,uBAAa,EAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EACxC,WAAW,EAAE,SAAS,CAAC,MAAM,EAC7B,KAAK,kCACA,SAAS,CAAC,KAAK,KAClB,4BAA4B,EAAE,mDAAsC,CAAC,4BAA4B,EACjG,sBAAsB,EAA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A4B;YAC5E,cAAc,EAAE,iCAAoB,CAAC,iBAAiB;YACtD,UAAU,EAAE,iCAAoB,CAAC,aAAa;SAC/C,EACD,cAAc,IACf;AACH,CAAC,CAAA;AA9EY,QAAA,WAAW,eA8EvB"}
@@ -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;AAKvC,MAAM,gCAAgC,GAAG,CACvC,IAA+B,EAC/B,IAAkB,EACe,EAAE;IACnC,MAAM,SAAS,GAAG,IAAA,qBAAY,EAAC,EAAE,UAAU,EAAE,wBAAU,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAA;IACpE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,KAAoB,IAAI,EAAnB,UAAU,kBAAK,IAAI,EAApF,wEAA6E,CAAO,CAAA;IAC1F,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAA;IACtC,IAAI,WAAmB,CAAA;IACvB,IAAI,MAAW,CAAA;IAEf,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;QAC7C,WAAW,GAAG,CAAC,MAAM,2CAAa,CAAC,8BAA8B,CAC/D,wBAAU,CAAC,GAAG,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,KAAK,CACX,CAAW,CAAA;KACb;SAAM;QACL,WAAW,GAAG,IAAI,CAAC,cAAwB,CAAA;KAC5C;IAED,MAAM,OAAO,GAAG,MAAM,2BAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IAChF,MAAM,GAAG,GAAG;QACV,QAAQ,EAAE,QAAQ,IAAI,OAAO;QAC7B,QAAQ,EAAE,QAAQ,IAAI,IAAI;KAC3B,CAAA;IAED,IAAI,OAAO,CAAC,QAAQ,KAAK,KAAK,EAAE;QAC9B,MAAM,GAAG,SAAS,CAAC,MAAM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