@broxus/js-core
Advanced tools
Comparing version 0.14.1 to 0.14.2
@@ -18,2 +18,3 @@ "use strict"; | ||
const core_1 = require("../../core"); | ||
const models_1 = require("../../models"); | ||
const contracts_1 = require("../../models/dex-account/contracts"); | ||
@@ -24,3 +25,2 @@ const DexAccountUtils_1 = require("../../models/dex-account/DexAccountUtils"); | ||
const utils_1 = require("../../utils"); | ||
const models_1 = require("../../models"); | ||
class DexAccount extends core_1.TvmContractWrapper { | ||
@@ -75,7 +75,8 @@ _connection; | ||
await this.syncComputedStorageData(); | ||
const [balances, wallets] = await Promise.all([ | ||
const [balances, ownerAddress, wallets] = await Promise.all([ | ||
DexAccount.Utils.getBalances(this._connection, this.address, this.contractState), | ||
DexAccount.Utils.getOwner(this._connection, this.address, this.contractState), | ||
DexAccount.Utils.getWallets(this._connection, this.address, this.contractState), | ||
]); | ||
this.setData({ balances, wallets }); | ||
this.setData({ balances, ownerAddress, wallets }); | ||
} | ||
@@ -531,5 +532,22 @@ catch (e) { | ||
} | ||
/** | ||
* Returns user lp wallets balances as map where | ||
* key is lp wallet address and value is balance. | ||
* @returns {DexAccountData["balances"]} | ||
*/ | ||
get balances() { | ||
return this._data.balances; | ||
} | ||
/** | ||
* Returns account owner address | ||
* @returns {DexAccountData["ownerAddress"]} | ||
*/ | ||
get ownerAddress() { | ||
return this._data.ownerAddress; | ||
} | ||
/** | ||
* Returns user token wallets addresses as map where | ||
* key is lp token address and value is token wallet address. | ||
* @returns {DexAccountData["wallets"]} | ||
*/ | ||
get wallets() { | ||
@@ -603,2 +621,7 @@ return this._data.wallets; | ||
__metadata("design:paramtypes", []) | ||
], DexAccount.prototype, "ownerAddress", null); | ||
__decorate([ | ||
mobx_1.computed, | ||
__metadata("design:type", Object), | ||
__metadata("design:paramtypes", []) | ||
], DexAccount.prototype, "wallets", null); |
@@ -157,2 +157,8 @@ "use strict"; | ||
} | ||
static async getOwner(connection, dexAccountAddress, cachedState) { | ||
const result = await (0, contracts_1.dexAccountContract)(connection, dexAccountAddress) | ||
.methods.getOwner({ answerId: 0 }) | ||
.call({ cachedState, responsible: true }); | ||
return result.value0; | ||
} | ||
/** | ||
@@ -159,0 +165,0 @@ * Returns token balance by the given DEX Account and token address addresses |
import { type Address, type ProviderRpcClient, type SendInternalParams, type Subscriber, type Transaction } from 'everscale-inpage-provider'; | ||
import { TvmContractWrapper } from '../../core'; | ||
import { type DexPairDepositLiquiditySuccess, type DexPairDepositLiquiditySuccessV2, type DexPairOperationCancelled } from '../../models'; | ||
import { type Dex } from '../../models/dex'; | ||
@@ -7,3 +8,2 @@ import { type DexAccountAddPairAbiParams, type DexAccountAddPoolAbiParams, type DexAccountDepositLiquidityAbiParams, DexAccountUtils, type DexAccountWithdrawAbiParams } from '../../models/dex-account/DexAccountUtils'; | ||
import { type CallId, type Forceable, type SendMessageCallback, type Silentable, type Syncable, type TransactionCallbacks, type TransactionFailureReason, type TransactionSuccessResult, type Watchable } from '../../types'; | ||
import { type DexPairDepositLiquiditySuccess, type DexPairDepositLiquiditySuccessV2, type DexPairOperationCancelled } from '../../models'; | ||
type Callbacks<SendParams = any, SuccessParams = any, FailureParams = any> = SendMessageCallback<SendParams> & TransactionCallbacks<TransactionSuccessResult<SuccessParams>, TransactionFailureReason<FailureParams>>; | ||
@@ -81,2 +81,3 @@ export interface DexAccountAddPairSuccessResult { | ||
balances?: Map<string, string>; | ||
ownerAddress: Address; | ||
wallets?: Map<string, Address>; | ||
@@ -141,5 +142,20 @@ } | ||
withdrawToken(params: DexAccountWithdrawTokenParams, args?: Partial<SendInternalParams>): Promise<Transaction | undefined>; | ||
/** | ||
* Returns user lp wallets balances as map where | ||
* key is lp wallet address and value is balance. | ||
* @returns {DexAccountData["balances"]} | ||
*/ | ||
get balances(): DexAccountData['balances']; | ||
/** | ||
* Returns account owner address | ||
* @returns {DexAccountData["ownerAddress"]} | ||
*/ | ||
get ownerAddress(): DexAccountData['ownerAddress']; | ||
/** | ||
* Returns user token wallets addresses as map where | ||
* key is lp token address and value is token wallet address. | ||
* @returns {DexAccountData["wallets"]} | ||
*/ | ||
get wallets(): DexAccountData['wallets']; | ||
} | ||
export {}; |
@@ -15,2 +15,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
import { TvmContractWrapper } from '../../core'; | ||
import { dexPairCallbacksContract, } from '../../models'; | ||
import { dexAccountContract } from '../../models/dex-account/contracts'; | ||
@@ -21,3 +22,2 @@ import { DexAccountUtils, } from '../../models/dex-account/DexAccountUtils'; | ||
import { contractStateChangeDebugMessage, getRandomUint, isAddressesEquals, resolveTvmAddress, subscribeDebugMessage, syncErrorMessage, unsubscribeDebugMessage, unsubscribeErrorMessage, } from '../../utils'; | ||
import { dexPairCallbacksContract, } from '../../models'; | ||
export class DexAccount extends TvmContractWrapper { | ||
@@ -72,7 +72,8 @@ _connection; | ||
await this.syncComputedStorageData(); | ||
const [balances, wallets] = await Promise.all([ | ||
const [balances, ownerAddress, wallets] = await Promise.all([ | ||
DexAccount.Utils.getBalances(this._connection, this.address, this.contractState), | ||
DexAccount.Utils.getOwner(this._connection, this.address, this.contractState), | ||
DexAccount.Utils.getWallets(this._connection, this.address, this.contractState), | ||
]); | ||
this.setData({ balances, wallets }); | ||
this.setData({ balances, ownerAddress, wallets }); | ||
} | ||
@@ -528,5 +529,22 @@ catch (e) { | ||
} | ||
/** | ||
* Returns user lp wallets balances as map where | ||
* key is lp wallet address and value is balance. | ||
* @returns {DexAccountData["balances"]} | ||
*/ | ||
get balances() { | ||
return this._data.balances; | ||
} | ||
/** | ||
* Returns account owner address | ||
* @returns {DexAccountData["ownerAddress"]} | ||
*/ | ||
get ownerAddress() { | ||
return this._data.ownerAddress; | ||
} | ||
/** | ||
* Returns user token wallets addresses as map where | ||
* key is lp token address and value is token wallet address. | ||
* @returns {DexAccountData["wallets"]} | ||
*/ | ||
get wallets() { | ||
@@ -599,2 +617,7 @@ return this._data.wallets; | ||
__metadata("design:paramtypes", []) | ||
], DexAccount.prototype, "ownerAddress", null); | ||
__decorate([ | ||
computed, | ||
__metadata("design:type", Object), | ||
__metadata("design:paramtypes", []) | ||
], DexAccount.prototype, "wallets", null); |
@@ -101,2 +101,3 @@ import { type Address, type DelayedMessageExecution, type FullContractState, type ProviderRpcClient, type SendInternalParams } from 'everscale-inpage-provider'; | ||
static withdrawLiquidity(provider: ProviderRpcClient, dexAccountAddress: Address | string, params: DexAccountWithdrawLiquidityAbiParams, args?: Partial<SendInternalParams>): Promise<DelayedMessageExecution>; | ||
static getOwner(connection: ProviderRpcClient, dexAccountAddress: Address | string, cachedState?: FullContractState): Promise<Address>; | ||
/** | ||
@@ -103,0 +104,0 @@ * Returns token balance by the given DEX Account and token address addresses |
@@ -154,2 +154,8 @@ import { debug, groupCollapsed, groupEnd, sliceAddress } from '@broxus/js-utils'; | ||
} | ||
static async getOwner(connection, dexAccountAddress, cachedState) { | ||
const result = await dexAccountContract(connection, dexAccountAddress) | ||
.methods.getOwner({ answerId: 0 }) | ||
.call({ cachedState, responsible: true }); | ||
return result.value0; | ||
} | ||
/** | ||
@@ -156,0 +162,0 @@ * Returns token balance by the given DEX Account and token address addresses |
{ | ||
"name": "@broxus/js-core", | ||
"version": "0.14.1", | ||
"version": "0.14.2", | ||
"description": "MobX-based JavaScript Core library", | ||
@@ -63,3 +63,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "0e99a940e76c14852245242778836f497e3b0d2a" | ||
"gitHead": "89206e14ae1f699723352106ab7d74a7cc44f86e" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1255888
27030