From 773397713bc003c4c7c79dcea5a1c35cdb77293b Mon Sep 17 00:00:00 2001 From: Peter Date: Tue, 18 Apr 2023 17:59:35 +0200 Subject: [PATCH] refactor: update according to code review --- src/parachain/amm.ts | 8 ++++---- src/parachain/escrow.ts | 10 +++++----- src/parachain/issue.ts | 8 ++++---- src/parachain/loans.ts | 20 ++++++++++---------- src/parachain/nomination.ts | 10 +++++----- src/parachain/oracle.ts | 4 ++-- src/parachain/redeem.ts | 12 ++++++------ src/parachain/replace.ts | 8 ++++---- src/parachain/rewards.ts | 2 +- src/parachain/system.ts | 2 +- src/parachain/tokens.ts | 4 ++-- src/parachain/transaction.ts | 20 +++++++++++--------- src/parachain/vaults.ts | 10 +++++----- src/types/extrinsic.ts | 7 ++++++- 14 files changed, 66 insertions(+), 59 deletions(-) diff --git a/src/parachain/amm.ts b/src/parachain/amm.ts index 53bf5f271..012023096 100644 --- a/src/parachain/amm.ts +++ b/src/parachain/amm.ts @@ -111,7 +111,7 @@ export interface AMMAPI { * @param {MonetaryAmount} minimumAmountOut Minimum output amount to be received. * @param {AddressOrPair} recipient Recipient address. * @param {number | string} deadline Deadline block for the swap transaction. - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ swap( trade: Trade, @@ -129,7 +129,7 @@ export interface AMMAPI { * @param {number} maxSlippage Maximum allowed slippage. * @param {number} deadline Deadline block number. * @param {AddressOrPair} recipient Recipient of the liquidity pool token. - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ addLiquidity( amounts: PooledCurrencies, @@ -147,7 +147,7 @@ export interface AMMAPI { * @param {number} maxSlippage Maximum allowed slippage. * @param {number} deadline Deadline block number. * @param {AddressOrPair} recipient Recipient of the pooled currencies. - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @note Removes `amount` of liquidity in LP token, breaks it down and transfers to account. */ removeLiquidity( @@ -163,7 +163,7 @@ export interface AMMAPI { * * @param claimableRewards Map of LpToken -> Array of reward monetary amounts -> supposed to be * output of `getClaimableFarmingRewards` - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ claimFarmingRewards(claimableRewards: Map>>): ExtrinsicData; } diff --git a/src/parachain/escrow.ts b/src/parachain/escrow.ts index e4ebf446e..ee68d6c9b 100644 --- a/src/parachain/escrow.ts +++ b/src/parachain/escrow.ts @@ -30,7 +30,7 @@ export interface EscrowAPI { /** * @param amount Governance token amount to lock (e.g. KINT or INTR) * @param unlockHeight Block number to lock until - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @remarks The amount can't be less than the max period (`getMaxPeriod` getter) to prevent rounding errors */ createLock(amount: MonetaryAmount, unlockHeight: number): ExtrinsicData; @@ -47,7 +47,7 @@ export interface EscrowAPI { */ getTotalStakedBalance(): Promise>; /** - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @remarks Withdraws all locked governance currency */ withdraw(): ExtrinsicData; @@ -60,19 +60,19 @@ export interface EscrowAPI { */ getMaxPeriod(): Promise; /** - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @remarks Withdraws stake-to-vote rewards */ withdrawRewards(): ExtrinsicData; /** * @param amount Governance token amount to lock (e.g. KINT or INTR) - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ increaseAmount(amount: MonetaryAmount): ExtrinsicData; /** * @param unlockHeight The unlock height to increase by. - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ increaseUnlockHeight(unlockHeight: number): ExtrinsicData; /** diff --git a/src/parachain/issue.ts b/src/parachain/issue.ts index 8c579c1df..752af126d 100644 --- a/src/parachain/issue.ts +++ b/src/parachain/issue.ts @@ -79,7 +79,7 @@ export interface IssueAPI { * @param amountsPerVault A mapping of vaults to issue from, and wrapped token amounts to issue using each vault * @param atomic Whether the issue request should be handled atomically or not. Only makes a difference if more than * one vault is needed to fulfil it. - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ requestAdvanced( amountsPerVault: Map>, @@ -104,7 +104,7 @@ export interface IssueAPI { * * @param issueId The ID returned by the issue request transaction * @param btcTxId Bitcoin transaction ID - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ execute(requestId: string, btcTxId: string): Promise; @@ -121,7 +121,7 @@ export interface IssueAPI { * the issuance request can be cancelled. As a result, the griefing collateral * of the requester will be slashed and sent to the vault that had prepared to issue. * @param issueId The ID returned by the issue request transaction - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ cancel(issueId: string): ExtrinsicData; /** @@ -129,7 +129,7 @@ export interface IssueAPI { * @param blocks The time difference in number of blocks between an issue request is created * and required completion time by a user. The issue period has an upper limit * to prevent griefing of vault collateral. - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ setIssuePeriod(blocks: number): ExtrinsicData; /** diff --git a/src/parachain/loans.ts b/src/parachain/loans.ts index 399761cf8..edec3e2df 100644 --- a/src/parachain/loans.ts +++ b/src/parachain/loans.ts @@ -102,7 +102,7 @@ export interface LoansAPI { * * @param {CurrencyExt} underlyingCurrency Currency to lend. * @param {MonetaryAmount} amount Amount of currency to lend. - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @throws If there is not active market for `underlyingCurrency`. * @throws If `amount` is exceeding available balance of account. */ @@ -113,7 +113,7 @@ export interface LoansAPI { * * @param {CurrencyExt} underlyingCurrency Currency to witdhraw. * @param {MonetaryAmount} amount Amount of currency to withdraw. - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @throws If there is not active market for `underlyingCurrency`. * @throws If `amount` is exceeding lent amount of account. * @throws If `underlyingCurrency` is used as collateral and withdrawal of @@ -127,7 +127,7 @@ export interface LoansAPI { * Same as `withdraw`, but exits full position. * * @param underlyingCurrency Currency to fully withdraw. - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ withdrawAll(underlyingCurrency: CurrencyExt): Promise; @@ -135,7 +135,7 @@ export interface LoansAPI { * Enable lend position of account as collateral for borrowing. * * @param underlyingCurrency Currency to enable as collateral. - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @throws If there is no existing lend position for `currency`. */ enableAsCollateral(underlyingCurrency: CurrencyExt): Promise; @@ -144,7 +144,7 @@ export interface LoansAPI { * Enable lend position of account as collateral for borrowing. * * @param underlyingCurrency Currency to enable as collateral. - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @throws If there is no existing lend position for `currency`. * @throws If disabling lend position of `currency` would bring * account under collateral threshold. @@ -153,7 +153,7 @@ export interface LoansAPI { /** * Claim subsidy rewards for all markets available for account. - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ claimAllSubsidyRewards(): ExtrinsicData; @@ -162,7 +162,7 @@ export interface LoansAPI { * * @param underlyingCurrency Currency to borrow. * @param amount Amount of currency to borrow. - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @throws If there is no active market for `underlyingCurrency`. * @throws If there is not enough collateral provided by account for * `amount` of `underlyingCurrency`. @@ -176,7 +176,7 @@ export interface LoansAPI { * * @param underlyingCurrency Currency to repay. * @param amount Amount of currency to repay. - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @throws If there is no active market for `underlyingCurrency`. * @throws If `amount` is higher than available balance of account. * @throws If `amount` is higher than outstanding loan. @@ -187,7 +187,7 @@ export interface LoansAPI { * Same as `repay`, but repays full loan. * * @param underlyingCurrency Currency to repay. - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ repayAll(underlyingCurrency: CurrencyExt): Promise; @@ -198,7 +198,7 @@ export interface LoansAPI { * @param liquidationCurrency Currency of position that will be liquidated. * @param repayAmount Amount to be repaid. * @param collateralCurrency Collateral currency which will be claimed by liquidator. - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ liquidateBorrowPosition( borrower: AccountId, diff --git a/src/parachain/nomination.ts b/src/parachain/nomination.ts index ef66e1732..dd345598c 100644 --- a/src/parachain/nomination.ts +++ b/src/parachain/nomination.ts @@ -42,13 +42,13 @@ export interface NominationAPI { /** * @param vaultAccountId Vault to nominate collateral to * @param amount Amount to deposit, as a `Monetary.js` object or `ForeignAsset` - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ depositCollateral(vaultAccountId: AccountId, amount: MonetaryAmount): ExtrinsicData; /** * @param vaultAccountId Vault that collateral was nominated to * @param amount Amount to withdraw, as a `Monetary.js` object or `ForeignAsset` - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ withdrawCollateral( vaultAccountId: AccountId, @@ -56,18 +56,18 @@ export interface NominationAPI { ): Promise; /** * @param collateralCurrency Currency to accept as nomination - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @remarks Function callable by vaults to opt in to the nomination feature */ optIn(collateralCurrency: CollateralCurrencyExt): ExtrinsicData; /** * @param collateralCurrency Currency to stop accepting as nomination - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @remarks Function callable by vaults to opt out of the nomination feature */ optOut(collateralCurrency: CollateralCurrencyExt): ExtrinsicData; /** - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @remarks Testnet utility function */ setNominationEnabled(enabled: boolean): ExtrinsicData; diff --git a/src/parachain/oracle.ts b/src/parachain/oracle.ts index 56f820510..c0b2efefb 100644 --- a/src/parachain/oracle.ts +++ b/src/parachain/oracle.ts @@ -53,13 +53,13 @@ export interface OracleAPI { /** * Create a transaction to set the exchange rate between Bitcoin and a collateral currency * @param exchangeRate The rate to set - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ setExchangeRate(exchangeRate: ExchangeRate): ExtrinsicData; /** * Create a transaction to set the current fee estimate for BTC transactions * @param fees Estimated Satoshis per bytes to get a transaction included - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ setBitcoinFees(fees: Big): ExtrinsicData; /** diff --git a/src/parachain/redeem.ts b/src/parachain/redeem.ts index 18c4f9a4f..7fff4a37e 100644 --- a/src/parachain/redeem.ts +++ b/src/parachain/redeem.ts @@ -60,7 +60,7 @@ export interface RedeemAPI { * @param atomic (optional) Whether the request should be handled atomically or not. Only makes a difference * if more than one vault is needed to fulfil it. Defaults to false. * @param availableVaults (optional) A list of all vaults usable for redeem. If not provided, will fetch from the parachain. - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ request( amount: MonetaryAmount, @@ -76,7 +76,7 @@ export interface RedeemAPI { * @param btcAddressEnc Bitcoin address where the redeemed BTC should be sent * @param atomic Whether the issue request should be handled atomically or not. Only makes a difference if more than * one vault is needed to fulfil it. - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @throws Rejects the promise if none of the requests succeeded (or if at least one failed, when atomic=true). */ requestAdvanced( @@ -103,7 +103,7 @@ export interface RedeemAPI { * * @param redeemId The ID generated by the redeem request transaction * @param btcTxId Bitcoin transaction ID - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ execute(requestId: string, btcTxId: string): Promise; @@ -129,7 +129,7 @@ export interface RedeemAPI { * @param reimburse (Optional) In case of redeem failure: * - (Default) `false` = retry redeeming, with a different Vault * - `true` = accept reimbursement in wrapped token - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ cancel(redeemId: string, reimburse?: boolean): ExtrinsicData; /** @@ -138,7 +138,7 @@ export interface RedeemAPI { * is created and required completion time by a vault. * The redeem period has an upper limit to ensure the user gets their BTC in time * and to potentially punish a vault for inactivity or stealing BTC. - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ setRedeemPeriod(blocks: number): ExtrinsicData; /** @@ -191,7 +191,7 @@ export interface RedeemAPI { * Burn wrapped tokens for a premium * @param amount The amount of wrapped tokens to burn * @param collateralCurrency Liquidated collateral currency to use when burning wrapped tokens - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ burn(amount: MonetaryAmount, collateralCurrency: CollateralCurrencyExt): ExtrinsicData; /** diff --git a/src/parachain/replace.ts b/src/parachain/replace.ts index 3327e76a3..12c913240 100644 --- a/src/parachain/replace.ts +++ b/src/parachain/replace.ts @@ -62,7 +62,7 @@ export interface ReplaceAPI { /** * @param amount Amount issued, denoted in Bitcoin, to have replaced by another vault * @param collateralCurrency Collateral currency to have replaced - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ request(amount: MonetaryAmount, collateralCurrency: CollateralCurrencyExt): ExtrinsicData; @@ -84,7 +84,7 @@ export interface ReplaceAPI { * @param amount The amount of wrapped tokens to withdraw from the amount * requested to have replaced. * @param collateralCurrency Collateral currency of the request - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ withdraw(amount: MonetaryAmount, collateralCurrency: CollateralCurrencyExt): ExtrinsicData; @@ -110,7 +110,7 @@ export interface ReplaceAPI { * @param amount Amount of issued tokens to be replaced * @param collateral The collateral for replacement * @param btcAddress The address that old-vault should transfer the btc to - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ accept( oldVault: AccountId, @@ -137,7 +137,7 @@ export interface ReplaceAPI { * * @param requestId The ID generated by the replace request transaction * @param btcTxId Bitcoin transaction ID - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ execute(requestId: string, btcTxId: string): Promise; /** diff --git a/src/parachain/rewards.ts b/src/parachain/rewards.ts index ccc1b741e..27325e877 100644 --- a/src/parachain/rewards.ts +++ b/src/parachain/rewards.ts @@ -32,7 +32,7 @@ export interface RewardsAPI { /** * @param vaultId VaultId object * @param nonce Staking pool nonce - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @remarks Withdraw all rewards from the current account in the `vaultId` staking pool. */ withdrawRewards(vaultId: InterbtcPrimitivesVaultId, nonce?: number): Promise; diff --git a/src/parachain/system.ts b/src/parachain/system.ts index 8bbe81a5e..568cbebd9 100644 --- a/src/parachain/system.ts +++ b/src/parachain/system.ts @@ -37,7 +37,7 @@ export interface SystemAPI { /** * @remarks Upgrades runtime using `sudoUncheckedWeight` * @param code Hex-encoded wasm blob - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ setCode(code: string): ExtrinsicData; diff --git a/src/parachain/tokens.ts b/src/parachain/tokens.ts index cf43baea9..3d17dec33 100644 --- a/src/parachain/tokens.ts +++ b/src/parachain/tokens.ts @@ -37,7 +37,7 @@ export interface TokensAPI { /** * @param destination The address of a user * @param amount The amount to transfer, as `Monetary.js` object or `ForeignAsset` - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ transfer(destination: string, amount: MonetaryAmount): ExtrinsicData; /** @@ -56,7 +56,7 @@ export interface TokensAPI { * @param accountId Account whose balance to set * @param freeBalance Free balance to set, as a Monetary.js object * @param lockedBalance Locked balance to set, as a Monetary.js object - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. * @remarks This extrinsic is only valid if submitted by a sudo account */ setBalance( diff --git a/src/parachain/transaction.ts b/src/parachain/transaction.ts index a21ea8817..2852265d3 100644 --- a/src/parachain/transaction.ts +++ b/src/parachain/transaction.ts @@ -9,6 +9,7 @@ import type { AnyTuple } from "@polkadot/types/types"; import { ACCOUNT_NOT_SET_ERROR_MESSAGE, IGNORED_ERROR_MESSAGES } from "../utils/constants"; import { MonetaryAmount, Currency } from "@interlay/monetary-js"; import { tokenSymbolToCurrency, newMonetaryAmount } from "../utils"; +import { DryRunResult } from "../types"; export interface TransactionAPI { api: ApiPromise; @@ -35,21 +36,22 @@ export interface TransactionAPI { ): SubmittableExtrinsic<"promise", ISubmittableResult>; /** - * Getter for fee estimation of the extrinsic. + * Getter for fee estimate of the extrinsic. * * @param {SubmittableExtrinsic<"promise">} extrinsic Extrinsic to get fee estimation about. * @returns {MonetaryAmount} amount of native currency that will be paid as transaction fee. * @note This fee estimation does not include tip. */ - getFeeEstimation(extrinsic: SubmittableExtrinsic<"promise">): Promise>; + getFeeEstimate(extrinsic: SubmittableExtrinsic<"promise">): Promise>; /** * Tests extrinsic execution against runtime. * * @param {SubmittableExtrinsic<"promise">} extrinsic Extrinsic to dry run. - * @return {boolean} True if extrinsic was successfully executed, false otherwise. + * @return {Promise} Object consisting of `success` boolean that is true if extrinsic + * was successfully executed, false otherwise. If execution fails, caught error is exposed. */ - dryRun(extrinsic: SubmittableExtrinsic<"promise">): Promise; + dryRun(extrinsic: SubmittableExtrinsic<"promise">): Promise; } export class DefaultTransactionAPI implements TransactionAPI { @@ -78,7 +80,7 @@ export class DefaultTransactionAPI implements TransactionAPI { return DefaultTransactionAPI.sendLogged(this.api, this.account, transaction, successEventType, extrinsicStatus); } - async getFeeEstimation(extrinsic: SubmittableExtrinsic<"promise">): Promise> { + async getFeeEstimate(extrinsic: SubmittableExtrinsic<"promise">): Promise> { const nativeCurrency = tokenSymbolToCurrency(this.api.consts.currency.getNativeCurrencyId.asToken); const account = this.account; @@ -90,15 +92,15 @@ export class DefaultTransactionAPI implements TransactionAPI { return newMonetaryAmount(paymentInfo.partialFee.toString(), nativeCurrency); } - async dryRun(extrinsic: SubmittableExtrinsic<"promise">): Promise { + async dryRun(extrinsic: SubmittableExtrinsic<"promise">): Promise { if (this.account === undefined) { return Promise.reject(new Error(ACCOUNT_NOT_SET_ERROR_MESSAGE)); } try { await extrinsic.dryRun(this.account); - return true; - } catch { - return false; + return { success: true }; + } catch (error) { + return { success: false, error }; } } diff --git a/src/parachain/vaults.ts b/src/parachain/vaults.ts index 1adbd7a68..ed91e1ded 100644 --- a/src/parachain/vaults.ts +++ b/src/parachain/vaults.ts @@ -224,7 +224,7 @@ export interface VaultsAPI { /** * @param amount The amount of collateral to withdraw - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ withdrawCollateral(amount: MonetaryAmount): Promise; @@ -240,7 +240,7 @@ export interface VaultsAPI { /** * @param amount The amount of extra collateral to lock - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ depositCollateral(amount: MonetaryAmount): ExtrinsicData; /** @@ -297,7 +297,7 @@ export interface VaultsAPI { * * @param vaultId The vault ID of the vault to be reported. * @param btcTxId Bitcoin transaction ID - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ reportVaultTheft(vaultId: InterbtcPrimitivesVaultId, btcTxId: string): Promise; @@ -357,7 +357,7 @@ export interface VaultsAPI { * Enables or disables issue requests for given vault * @param vaultId The vault ID whose issuing will be toggled * @param acceptNewIssues Boolean denoting whether issuing should be enabled or not - * @returns {Promise} A submittable extrinsic and event. + * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ toggleIssueRequests(vaultId: InterbtcPrimitivesVaultId, acceptNewIssues: boolean): Promise; @@ -392,7 +392,7 @@ export interface VaultsAPI { * Rejects with an Error if unable to register. * * @param collateralAmount The collateral amount to register the vault with - in the new collateral currency - * @returns {ExtrinsicData} A submittable extrinsic and event. + * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ registerNewCollateralVault(collateralAmount: MonetaryAmount): ExtrinsicData; /** diff --git a/src/types/extrinsic.ts b/src/types/extrinsic.ts index 9d841ea8a..a87ce9570 100644 --- a/src/types/extrinsic.ts +++ b/src/types/extrinsic.ts @@ -5,4 +5,9 @@ interface ExtrinsicData { event?: AugmentedEvent; } -export type { ExtrinsicData }; +interface DryRunResult { + success: boolean; + error?: unknown; +} + +export type { ExtrinsicData, DryRunResult };