diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index d7053b4fb..ca00d4a3f 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -177,3 +177,36 @@ jobs: - name: Check formatting run: yarn format + + typescript-docs: + needs: typescript-detect-changes + if: | + github.event_name == 'push' + || needs.typescript-detect-changes.outputs.path-filter == 'true' + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./typescript + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: "18.x" + cache: "yarn" + cache-dependency-path: typescript/yarn.lock + + - name: Configure git to don't use unauthenticated protocol + run: git config --global url."https://".insteadOf git:// + + - name: Install dependencies + run: yarn install + + - name: Build + run: yarn build + + - name: Generate docs + run: yarn docs + + - name: Check docs up to date + run: git diff --exit-code || exit 1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f63f7acc3..b57092008 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,3 +41,9 @@ repos: files: "^cross-chain/arbitrum/" language: script description: "Checks cross-chain/arbitrum directory code according to the formatting configuration" + - id: typescript-docs + name: "Generate typescript API reference docs" + entry: /usr/bin/env bash -c "cd typescript && yarn docs" + files: "^typescript/" + language: script + description: "Generates typescript API reference docs according to the typedoc configuration" diff --git a/solidity/package.json b/solidity/package.json index 7cf2be864..1cf41a0a5 100644 --- a/solidity/package.json +++ b/solidity/package.json @@ -76,10 +76,5 @@ }, "engines": { "node": ">= 14.0.0" - }, - "repository": { - "type": "git", - "url": "https://github.com/keep-network/tbtc-v2.git", - "directory": "typescript" } } diff --git a/typescript/.eslintignore b/typescript/.eslintignore index fc0895897..e6f28fa5e 100644 --- a/typescript/.eslintignore +++ b/typescript/.eslintignore @@ -1,3 +1,4 @@ dist/ node_modules/ typechain/ +api-reference/ diff --git a/typescript/.prettierignore b/typescript/.prettierignore index aa7f39fe5..ae167429d 100644 --- a/typescript/.prettierignore +++ b/typescript/.prettierignore @@ -1,3 +1,4 @@ dist/ external/ typechain/ +api-reference/ diff --git a/typescript/README.md b/typescript/README.md index a8f2c5bc7..7f841306f 100644 --- a/typescript/README.md +++ b/typescript/README.md @@ -20,6 +20,7 @@ trustless tokenized Bitcoin to their users. - [Build](#build) - [Test](#test) - [Format](#format) + - [Auto-generated API reference](#auto-generated-api-reference) - [Documentation](#documentation) ## Quickstart @@ -134,6 +135,19 @@ To format code automatically, invoke: yarn format:fix ``` +### Auto-generated API reference + +There is an auto-generated API reference documentation that must be +re-generated in case of modifications in the source code. This can be +done automatically using a pre-commit hook or manually using: + +```bash +yarn docs +``` + +Generated API reference in form of Markdown files is saved +to the [`api-reference`](./api-reference) directory. + ## Documentation This README provides just a basic guidance. Comprehensive documentation for diff --git a/typescript/api-reference/README.md b/typescript/api-reference/README.md new file mode 100644 index 000000000..3184171aa --- /dev/null +++ b/typescript/api-reference/README.md @@ -0,0 +1,986 @@ +# @keep-network/tbtc-v2.ts + +## Table of contents + +### Namespaces + +- [BitcoinNetwork](modules/BitcoinNetwork.md) +- [GetChainEvents](modules/GetChainEvents.md) +- [WalletState](modules/WalletState.md) + +### Enumerations + +- [BitcoinNetwork](enums/BitcoinNetwork-1.md) +- [WalletState](enums/WalletState-1.md) + +### Classes + +- [BitcoinTxHash](classes/BitcoinTxHash.md) +- [Deposit](classes/Deposit.md) +- [DepositFunding](classes/DepositFunding.md) +- [DepositRefund](classes/DepositRefund.md) +- [DepositScript](classes/DepositScript.md) +- [DepositsService](classes/DepositsService.md) +- [ElectrumClient](classes/ElectrumClient.md) +- [EthereumAddress](classes/EthereumAddress.md) +- [EthereumBridge](classes/EthereumBridge.md) +- [EthereumTBTCToken](classes/EthereumTBTCToken.md) +- [EthereumTBTCVault](classes/EthereumTBTCVault.md) +- [EthereumWalletRegistry](classes/EthereumWalletRegistry.md) +- [Hex](classes/Hex.md) +- [MaintenanceService](classes/MaintenanceService.md) +- [OptimisticMinting](classes/OptimisticMinting.md) +- [RedemptionsService](classes/RedemptionsService.md) +- [Spv](classes/Spv.md) +- [TBTC](classes/TBTC.md) +- [WalletTx](classes/WalletTx.md) + +### Interfaces + +- [BitcoinClient](interfaces/BitcoinClient.md) +- [BitcoinHeader](interfaces/BitcoinHeader.md) +- [BitcoinRawTx](interfaces/BitcoinRawTx.md) +- [BitcoinRawTxVectors](interfaces/BitcoinRawTxVectors.md) +- [BitcoinSpvProof](interfaces/BitcoinSpvProof.md) +- [BitcoinTx](interfaces/BitcoinTx.md) +- [BitcoinTxMerkleBranch](interfaces/BitcoinTxMerkleBranch.md) +- [BitcoinTxOutpoint](interfaces/BitcoinTxOutpoint.md) +- [BitcoinTxOutput](interfaces/BitcoinTxOutput.md) +- [Bridge](interfaces/Bridge.md) +- [ChainEvent](interfaces/ChainEvent.md) +- [ChainIdentifier](interfaces/ChainIdentifier.md) +- [DepositReceipt](interfaces/DepositReceipt.md) +- [DepositRequest](interfaces/DepositRequest.md) +- [ElectrumCredentials](interfaces/ElectrumCredentials.md) +- [EthereumContractConfig](interfaces/EthereumContractConfig.md) +- [RedemptionRequest](interfaces/RedemptionRequest.md) +- [TBTCToken](interfaces/TBTCToken.md) +- [TBTCVault](interfaces/TBTCVault.md) +- [Wallet](interfaces/Wallet.md) +- [WalletRegistry](interfaces/WalletRegistry.md) + +### Type Aliases + +- [BitcoinTxInput](README.md#bitcointxinput) +- [BitcoinUtxo](README.md#bitcoinutxo) +- [DepositRevealedEvent](README.md#depositrevealedevent) +- [DkgResultApprovedEvent](README.md#dkgresultapprovedevent) +- [DkgResultChallengedEvent](README.md#dkgresultchallengedevent) +- [DkgResultSubmittedEvent](README.md#dkgresultsubmittedevent) +- [ElectrumClientOptions](README.md#electrumclientoptions) +- [ErrorMatcherFn](README.md#errormatcherfn) +- [EthereumNetwork](README.md#ethereumnetwork) +- [EthereumSigner](README.md#ethereumsigner) +- [ExecutionLoggerFn](README.md#executionloggerfn) +- [NewWalletRegisteredEvent](README.md#newwalletregisteredevent) +- [OptimisticMintingCancelledEvent](README.md#optimisticmintingcancelledevent) +- [OptimisticMintingFinalizedEvent](README.md#optimisticmintingfinalizedevent) +- [OptimisticMintingRequest](README.md#optimisticmintingrequest) +- [OptimisticMintingRequestedEvent](README.md#optimisticmintingrequestedevent) +- [RedemptionRequestedEvent](README.md#redemptionrequestedevent) +- [RetrierFn](README.md#retrierfn) +- [TBTCContracts](README.md#tbtccontracts) + +### Variables + +- [BitcoinAddressConverter](README.md#bitcoinaddressconverter) +- [BitcoinCompactSizeUint](README.md#bitcoincompactsizeuint) +- [BitcoinHashUtils](README.md#bitcoinhashutils) +- [BitcoinHeaderSerializer](README.md#bitcoinheaderserializer) +- [BitcoinLocktimeUtils](README.md#bitcoinlocktimeutils) +- [BitcoinPrivateKeyUtils](README.md#bitcoinprivatekeyutils) +- [BitcoinPublicKeyUtils](README.md#bitcoinpublickeyutils) +- [BitcoinScriptUtils](README.md#bitcoinscriptutils) +- [BitcoinTargetConverter](README.md#bitcointargetconverter) + +### Functions + +- [assembleBitcoinSpvProof](README.md#assemblebitcoinspvproof) +- [backoffRetrier](README.md#backoffretrier) +- [computeElectrumScriptHash](README.md#computeelectrumscripthash) +- [ethereumAddressFromSigner](README.md#ethereumaddressfromsigner) +- [ethereumNetworkFromSigner](README.md#ethereumnetworkfromsigner) +- [extractBitcoinRawTxVectors](README.md#extractbitcoinrawtxvectors) +- [loadEthereumContracts](README.md#loadethereumcontracts) +- [retryAll](README.md#retryall) +- [skipRetryWhenMatched](README.md#skipretrywhenmatched) +- [toBitcoinJsLibNetwork](README.md#tobitcoinjslibnetwork) +- [validateBitcoinHeadersChain](README.md#validatebitcoinheaderschain) +- [validateBitcoinSpvProof](README.md#validatebitcoinspvproof) +- [validateDepositReceipt](README.md#validatedepositreceipt) + +## Type Aliases + +### BitcoinTxInput + +Ƭ **BitcoinTxInput**: [`BitcoinTxOutpoint`](interfaces/BitcoinTxOutpoint.md) & \{ `scriptSig`: [`Hex`](classes/Hex.md) } + +Data about a Bitcoin transaction input. + +#### Defined in + +[lib/bitcoin/tx.ts:63](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L63) + +___ + +### BitcoinUtxo + +Ƭ **BitcoinUtxo**: [`BitcoinTxOutpoint`](interfaces/BitcoinTxOutpoint.md) & \{ `value`: `BigNumber` } + +Data about a Bitcoin unspent transaction output. + +#### Defined in + +[lib/bitcoin/tx.ts:93](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L93) + +___ + +### DepositRevealedEvent + +Ƭ **DepositRevealedEvent**: [`DepositReceipt`](interfaces/DepositReceipt.md) & `Pick`\<[`DepositRequest`](interfaces/DepositRequest.md), ``"amount"`` \| ``"vault"``\> & \{ `fundingOutputIndex`: `number` ; `fundingTxHash`: [`BitcoinTxHash`](classes/BitcoinTxHash.md) } & [`ChainEvent`](interfaces/ChainEvent.md) + +Represents an event emitted on deposit reveal to the on-chain bridge. + +#### Defined in + +[lib/contracts/bridge.ts:283](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L283) + +___ + +### DkgResultApprovedEvent + +Ƭ **DkgResultApprovedEvent**: \{ `approver`: [`ChainIdentifier`](interfaces/ChainIdentifier.md) ; `resultHash`: [`Hex`](classes/Hex.md) } & [`ChainEvent`](interfaces/ChainEvent.md) + +Represents an event emitted when a DKG result is approved on the on-chain +wallet registry. + +#### Defined in + +[lib/contracts/wallet-registry.ts:64](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/wallet-registry.ts#L64) + +___ + +### DkgResultChallengedEvent + +Ƭ **DkgResultChallengedEvent**: \{ `challenger`: [`ChainIdentifier`](interfaces/ChainIdentifier.md) ; `reason`: `string` ; `resultHash`: [`Hex`](classes/Hex.md) } & [`ChainEvent`](interfaces/ChainEvent.md) + +Represents an event emitted when a DKG result is challenged on the on-chain +wallet registry. + +#### Defined in + +[lib/contracts/wallet-registry.ts:79](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/wallet-registry.ts#L79) + +___ + +### DkgResultSubmittedEvent + +Ƭ **DkgResultSubmittedEvent**: \{ `result`: `DkgResult` ; `resultHash`: [`Hex`](classes/Hex.md) ; `seed`: [`Hex`](classes/Hex.md) } & [`ChainEvent`](interfaces/ChainEvent.md) + +Represents an event emitted when a DKG result is submitted to the on-chain +wallet registry. + +#### Defined in + +[lib/contracts/wallet-registry.ts:45](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/wallet-registry.ts#L45) + +___ + +### ElectrumClientOptions + +Ƭ **ElectrumClientOptions**: `object` + +Additional options used by the Electrum server. + +#### Defined in + +[lib/electrum/client.ts:48](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L48) + +___ + +### ErrorMatcherFn + +Ƭ **ErrorMatcherFn**: (`err`: `unknown`) => `boolean` + +#### Type declaration + +▸ (`err`): `boolean` + +##### Parameters + +| Name | Type | +| :------ | :------ | +| `err` | `unknown` | + +##### Returns + +`boolean` + +True if the error matches, false otherwise. + +#### Defined in + +[lib/utils/backoff.ts:42](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/backoff.ts#L42) + +___ + +### EthereumNetwork + +Ƭ **EthereumNetwork**: ``"local"`` \| ``"goerli"`` \| ``"mainnet"`` + +Supported Ethereum networks. + +#### Defined in + +[lib/ethereum/index.ts:74](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L74) + +___ + +### EthereumSigner + +Ƭ **EthereumSigner**: `Signer` \| `providers.Provider` + +Represents an Ethereum signer. This type is a wrapper for Ethers-specific +types and can be either a Signer that can make write transactions +or a Provider that works only in the read-only mode. + +#### Defined in + +[lib/ethereum/index.ts:25](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L25) + +___ + +### ExecutionLoggerFn + +Ƭ **ExecutionLoggerFn**: (`msg`: `string`) => `void` + +#### Type declaration + +▸ (`msg`): `void` + +A function that is called with execution status messages. + +##### Parameters + +| Name | Type | +| :------ | :------ | +| `msg` | `string` | + +##### Returns + +`void` + +#### Defined in + +[lib/utils/backoff.ts:56](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/backoff.ts#L56) + +___ + +### NewWalletRegisteredEvent + +Ƭ **NewWalletRegisteredEvent**: \{ `ecdsaWalletID`: [`Hex`](classes/Hex.md) ; `walletPublicKeyHash`: [`Hex`](classes/Hex.md) } & [`ChainEvent`](interfaces/ChainEvent.md) + +Represents an event emitted when new wallet is registered on the on-chain bridge. + +#### Defined in + +[lib/contracts/bridge.ts:445](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L445) + +___ + +### OptimisticMintingCancelledEvent + +Ƭ **OptimisticMintingCancelledEvent**: \{ `depositKey`: [`Hex`](classes/Hex.md) ; `guardian`: [`ChainIdentifier`](interfaces/ChainIdentifier.md) } & [`ChainEvent`](interfaces/ChainEvent.md) + +Represents an event that is emitted when an optimistic minting request +is cancelled on chain. + +#### Defined in + +[lib/contracts/tbtc-vault.ts:170](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L170) + +___ + +### OptimisticMintingFinalizedEvent + +Ƭ **OptimisticMintingFinalizedEvent**: \{ `depositKey`: [`Hex`](classes/Hex.md) ; `depositor`: [`ChainIdentifier`](interfaces/ChainIdentifier.md) ; `minter`: [`ChainIdentifier`](interfaces/ChainIdentifier.md) ; `optimisticMintingDebt`: `BigNumber` } & [`ChainEvent`](interfaces/ChainEvent.md) + +Represents an event that is emitted when an optimistic minting request +is finalized on chain. + +#### Defined in + +[lib/contracts/tbtc-vault.ts:186](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L186) + +___ + +### OptimisticMintingRequest + +Ƭ **OptimisticMintingRequest**: `Object` + +Represents optimistic minting request for the given deposit revealed to the +Bridge. + +#### Type declaration + +| Name | Type | Description | +| :------ | :------ | :------ | +| `finalizedAt` | `number` | UNIX timestamp at which the optimistic minting was finalized. 0 if not yet finalized. | +| `requestedAt` | `number` | UNIX timestamp at which the optimistic minting was requested. | + +#### Defined in + +[lib/contracts/tbtc-vault.ts:120](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L120) + +___ + +### OptimisticMintingRequestedEvent + +Ƭ **OptimisticMintingRequestedEvent**: \{ `amount`: `BigNumber` ; `depositKey`: [`Hex`](classes/Hex.md) ; `depositor`: [`ChainIdentifier`](interfaces/ChainIdentifier.md) ; `fundingOutputIndex`: `number` ; `fundingTxHash`: [`BitcoinTxHash`](classes/BitcoinTxHash.md) ; `minter`: [`ChainIdentifier`](interfaces/ChainIdentifier.md) } & [`ChainEvent`](interfaces/ChainEvent.md) + +Represents an event that is emitted when a new optimistic minting is requested +on chain. + +#### Defined in + +[lib/contracts/tbtc-vault.ts:136](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L136) + +___ + +### RedemptionRequestedEvent + +Ƭ **RedemptionRequestedEvent**: `Omit`\<[`RedemptionRequest`](interfaces/RedemptionRequest.md), ``"requestedAt"``\> & \{ `walletPublicKeyHash`: [`Hex`](classes/Hex.md) } & [`ChainEvent`](interfaces/ChainEvent.md) + +Represents an event emitted on redemption request. + +#### Defined in + +[lib/contracts/bridge.ts:334](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L334) + +___ + +### RetrierFn + +Ƭ **RetrierFn**\<`T`\>: (`fn`: () => `Promise`\<`T`\>) => `Promise`\<`T`\> + +#### Type parameters + +| Name | +| :------ | +| `T` | + +#### Type declaration + +▸ (`fn`): `Promise`\<`T`\> + +##### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `fn` | () => `Promise`\<`T`\> | The function to be retried. | + +##### Returns + +`Promise`\<`T`\> + +#### Defined in + +[lib/utils/backoff.ts:51](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/backoff.ts#L51) + +___ + +### TBTCContracts + +Ƭ **TBTCContracts**: `Object` + +Convenience type aggregating all TBTC contracts handles. + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `bridge` | [`Bridge`](interfaces/Bridge.md) | +| `tbtcToken` | [`TBTCToken`](interfaces/TBTCToken.md) | +| `tbtcVault` | [`TBTCVault`](interfaces/TBTCVault.md) | +| `walletRegistry` | [`WalletRegistry`](interfaces/WalletRegistry.md) | + +#### Defined in + +[lib/contracts/index.ts:16](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/index.ts#L16) + +## Variables + +### BitcoinAddressConverter + +• `Const` **BitcoinAddressConverter**: `Object` + +Utility functions allowing to perform Bitcoin address conversions. + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `addressToOutputScript` | (`address`: `string`, `bitcoinNetwork`: [`BitcoinNetwork`](enums/BitcoinNetwork-1.md)) => [`Hex`](classes/Hex.md) | +| `addressToPublicKeyHash` | (`address`: `string`, `bitcoinNetwork`: [`BitcoinNetwork`](enums/BitcoinNetwork-1.md)) => [`Hex`](classes/Hex.md) | +| `outputScriptToAddress` | (`script`: [`Hex`](classes/Hex.md), `bitcoinNetwork`: [`BitcoinNetwork`](enums/BitcoinNetwork-1.md)) => `string` | +| `publicKeyHashToAddress` | (`publicKeyHash`: [`Hex`](classes/Hex.md), `witness`: `boolean`, `bitcoinNetwork`: [`BitcoinNetwork`](enums/BitcoinNetwork-1.md)) => `string` | +| `publicKeyToAddress` | (`publicKey`: [`Hex`](classes/Hex.md), `bitcoinNetwork`: [`BitcoinNetwork`](enums/BitcoinNetwork-1.md), `witness`: `boolean`) => `string` | + +#### Defined in + +[lib/bitcoin/address.ts:112](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/address.ts#L112) + +___ + +### BitcoinCompactSizeUint + +• `Const` **BitcoinCompactSizeUint**: `Object` + +Utility functions allowing to deal with Bitcoin compact size uints. + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `read` | (`varLenData`: [`Hex`](classes/Hex.md)) => \{ `byteLength`: `number` ; `value`: `number` } | + +#### Defined in + +[lib/bitcoin/csuint.ts:50](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/csuint.ts#L50) + +___ + +### BitcoinHashUtils + +• `Const` **BitcoinHashUtils**: `Object` + +Utility functions allowing to deal with Bitcoin hashes. + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `computeHash160` | (`text`: [`Hex`](classes/Hex.md)) => [`Hex`](classes/Hex.md) | +| `computeHash256` | (`text`: [`Hex`](classes/Hex.md)) => [`Hex`](classes/Hex.md) | +| `computeSha256` | (`text`: [`Hex`](classes/Hex.md)) => [`Hex`](classes/Hex.md) | +| `hashLEToBigNumber` | (`hash`: [`Hex`](classes/Hex.md)) => `BigNumber` | + +#### Defined in + +[lib/bitcoin/hash.ts:52](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/hash.ts#L52) + +___ + +### BitcoinHeaderSerializer + +• `Const` **BitcoinHeaderSerializer**: `Object` + +Utility functions allowing to serialize and deserialize Bitcoin block headers. + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `deserializeHeader` | (`rawHeader`: [`Hex`](classes/Hex.md)) => [`BitcoinHeader`](interfaces/BitcoinHeader.md) | +| `deserializeHeadersChain` | (`rawHeadersChain`: [`Hex`](classes/Hex.md)) => [`BitcoinHeader`](interfaces/BitcoinHeader.md)[] | +| `serializeHeader` | (`header`: [`BitcoinHeader`](interfaces/BitcoinHeader.md)) => [`Hex`](classes/Hex.md) | + +#### Defined in + +[lib/bitcoin/header.ts:109](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/header.ts#L109) + +___ + +### BitcoinLocktimeUtils + +• `Const` **BitcoinLocktimeUtils**: `Object` + +Utility functions allowing to deal with Bitcoin locktime. + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `calculateLocktime` | (`locktimeStartedAt`: `number`, `locktimeDuration`: `number`) => [`Hex`](classes/Hex.md) | +| `locktimeToNumber` | (`locktimeLE`: `string` \| `Buffer`) => `number` | + +#### Defined in + +[lib/bitcoin/tx.ts:234](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L234) + +___ + +### BitcoinPrivateKeyUtils + +• `Const` **BitcoinPrivateKeyUtils**: `Object` + +Utility functions allowing to perform operations on Bitcoin ECDSA private keys. + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `createKeyPair` | (`privateKey`: `string`, `bitcoinNetwork`: [`BitcoinNetwork`](enums/BitcoinNetwork-1.md)) => `ECPairInterface` | + +#### Defined in + +[lib/bitcoin/ecdsa-key.ts:77](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/ecdsa-key.ts#L77) + +___ + +### BitcoinPublicKeyUtils + +• `Const` **BitcoinPublicKeyUtils**: `Object` + +Utility functions allowing to perform operations on Bitcoin ECDSA public keys. + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `compressPublicKey` | (`publicKey`: [`Hex`](classes/Hex.md)) => `string` | +| `isCompressedPublicKey` | (`publicKey`: [`Hex`](classes/Hex.md)) => `boolean` | + +#### Defined in + +[lib/bitcoin/ecdsa-key.ts:51](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/ecdsa-key.ts#L51) + +___ + +### BitcoinScriptUtils + +• `Const` **BitcoinScriptUtils**: `Object` + +Utility functions allowing to deal with Bitcoin scripts. + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `isP2PKHScript` | (`script`: [`Hex`](classes/Hex.md)) => `boolean` | +| `isP2SHScript` | (`script`: [`Hex`](classes/Hex.md)) => `boolean` | +| `isP2WPKHScript` | (`script`: [`Hex`](classes/Hex.md)) => `boolean` | +| `isP2WSHScript` | (`script`: [`Hex`](classes/Hex.md)) => `boolean` | + +#### Defined in + +[lib/bitcoin/script.ts:63](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/script.ts#L63) + +___ + +### BitcoinTargetConverter + +• `Const` **BitcoinTargetConverter**: `Object` + +Utility functions allowing to perform Bitcoin target conversions. + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `bitsToTarget` | (`bits`: `number`) => `BigNumber` | +| `targetToDifficulty` | (`target`: `BigNumber`) => `BigNumber` | + +#### Defined in + +[lib/bitcoin/header.ts:268](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/header.ts#L268) + +## Functions + +### assembleBitcoinSpvProof + +▸ **assembleBitcoinSpvProof**(`transactionHash`, `requiredConfirmations`, `bitcoinClient`): `Promise`\<[`BitcoinTx`](interfaces/BitcoinTx.md) & [`BitcoinSpvProof`](interfaces/BitcoinSpvProof.md)\> + +Assembles a proof that a given transaction was included in the blockchain and +has accumulated the required number of confirmations. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transactionHash` | [`BitcoinTxHash`](classes/BitcoinTxHash.md) | Hash of the transaction being proven. | +| `requiredConfirmations` | `number` | Required number of confirmations. | +| `bitcoinClient` | [`BitcoinClient`](interfaces/BitcoinClient.md) | Bitcoin client used to interact with the network. | + +#### Returns + +`Promise`\<[`BitcoinTx`](interfaces/BitcoinTx.md) & [`BitcoinSpvProof`](interfaces/BitcoinSpvProof.md)\> + +Bitcoin transaction along with the inclusion proof. + +#### Defined in + +[lib/bitcoin/spv.ts:64](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/spv.ts#L64) + +___ + +### backoffRetrier + +▸ **backoffRetrier**\<`T`\>(`retries`, `backoffStepMs?`, `logger?`, `errorMatcher?`): [`RetrierFn`](README.md#retrierfn)\<`T`\> + +Returns a retrier that can be passed a function to be retried `retries` +number of times, with exponential backoff. The result will return the +function's return value if no exceptions are thrown. It will only retry if +the function throws an exception matched by `matcher`; {@see retryAll} can +be used to retry no matter the exception, though this is not necessarily +recommended in production. + +Example usage: + + await url.get("https://example.com/") // may transiently fail + // Retries 3 times with exponential backoff, no matter what error is + // reported by `url.get`. + backoffRetrier(3)(async () => url.get("https://example.com")) + // Retries 3 times with exponential backoff, but only if the error + // message includes "server unavailable". + backoffRetrier(3, (_) => _.message.includes('server unavailable'))( + async () => url.get("https://example.com")) + ) + +#### Type parameters + +| Name | +| :------ | +| `T` | + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `retries` | `number` | `undefined` | The number of retries to perform before bubbling the failure out. | +| `backoffStepMs` | `number` | `1000` | Initial backoff step in milliseconds that will be increased exponentially for subsequent retry attempts. (default = 1000 ms) | +| `logger` | [`ExecutionLoggerFn`](README.md#executionloggerfn) | `console.debug` | A logger function to pass execution messages. | +| `errorMatcher?` | [`ErrorMatcherFn`](README.md#errormatcherfn) | `retryAll` | A matcher function that receives the error when an exception is thrown, and returns true if the error should lead to a retry. A false return will rethrow the error and terminate the retry loop. | + +#### Returns + +[`RetrierFn`](README.md#retrierfn)\<`T`\> + +A function that can retry any function. + +#### Defined in + +[lib/utils/backoff.ts:89](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/backoff.ts#L89) + +___ + +### computeElectrumScriptHash + +▸ **computeElectrumScriptHash**(`script`): `string` + +Converts a Bitcoin script to an Electrum script hash. See +[Electrum protocol][https://electrumx.readthedocs.io/en/stable/protocol-basics.html#script-hashes](https://electrumx.readthedocs.io/en/stable/protocol-basics.html#script-hashes) + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `script` | [`Hex`](classes/Hex.md) | Bitcoin script as hex string | + +#### Returns + +`string` + +Electrum script hash as a hex string. + +#### Defined in + +[lib/electrum/client.ts:591](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L591) + +___ + +### ethereumAddressFromSigner + +▸ **ethereumAddressFromSigner**(`signer`): `Promise`\<[`EthereumAddress`](classes/EthereumAddress.md) \| `undefined`\> + +Resolves the Ethereum address tied to the given signer. The address +cannot be resolved for signers that works in the read-only mode + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `signer` | [`EthereumSigner`](README.md#ethereumsigner) | The signer whose address should be resolved. | + +#### Returns + +`Promise`\<[`EthereumAddress`](classes/EthereumAddress.md) \| `undefined`\> + +Ethereum address or undefined for read-only signers. + +**`Throws`** + +Throws an error if the address of the signer is not a proper + Ethereum address. + +#### Defined in + +[lib/ethereum/index.ts:61](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L61) + +___ + +### ethereumNetworkFromSigner + +▸ **ethereumNetworkFromSigner**(`signer`): `Promise`\<[`EthereumNetwork`](README.md#ethereumnetwork)\> + +Resolves the Ethereum network the given signer is tied to. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `signer` | [`EthereumSigner`](README.md#ethereumsigner) | The signer whose network should be resolved. | + +#### Returns + +`Promise`\<[`EthereumNetwork`](README.md#ethereumnetwork)\> + +Ethereum network. + +#### Defined in + +[lib/ethereum/index.ts:32](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L32) + +___ + +### extractBitcoinRawTxVectors + +▸ **extractBitcoinRawTxVectors**(`rawTransaction`): [`BitcoinRawTxVectors`](interfaces/BitcoinRawTxVectors.md) + +Decomposes a transaction in the raw representation into version, vector of +inputs, vector of outputs and locktime. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `rawTransaction` | [`BitcoinRawTx`](interfaces/BitcoinRawTx.md) | Transaction in the raw format. | + +#### Returns + +[`BitcoinRawTxVectors`](interfaces/BitcoinRawTxVectors.md) + +Transaction data with fields represented as un-prefixed hex strings. + +#### Defined in + +[lib/bitcoin/tx.ts:133](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L133) + +___ + +### loadEthereumContracts + +▸ **loadEthereumContracts**(`signer`, `network`): `Promise`\<[`TBTCContracts`](README.md#tbtccontracts)\> + +Loads Ethereum implementation of tBTC contracts for the given Ethereum +network and attaches the given signer there. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `signer` | [`EthereumSigner`](README.md#ethereumsigner) | Signer that should be attached to tBTC contracts. | +| `network` | [`EthereumNetwork`](README.md#ethereumnetwork) | Ethereum network. | + +#### Returns + +`Promise`\<[`TBTCContracts`](README.md#tbtccontracts)\> + +Handle to tBTC contracts. + +**`Throws`** + +Throws an error if the signer's Ethereum network is other than + the one used to load tBTC contracts. + +#### Defined in + +[lib/ethereum/index.ts:85](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L85) + +___ + +### retryAll + +▸ **retryAll**(`error`): ``true`` + +A convenience matcher for withBackoffRetries that retries irrespective of +the error. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `error` | `any` | The error to match against. Not necessarily an Error instance, since the retriable function may throw a non-Error. | + +#### Returns + +``true`` + +Always returns true. + +#### Defined in + +[lib/utils/backoff.ts:9](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/backoff.ts#L9) + +___ + +### skipRetryWhenMatched + +▸ **skipRetryWhenMatched**(`matchers`): [`ErrorMatcherFn`](README.md#errormatcherfn) + +A matcher to specify list of error messages that should abort the retry loop +and throw immediately. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `matchers` | (`string` \| `RegExp`)[] | List of patterns for error matching. | + +#### Returns + +[`ErrorMatcherFn`](README.md#errormatcherfn) + +Matcher function that returns false if error matches one of the patterns. + True is returned if no matches are found and retry loop should continue + +#### Defined in + +[lib/utils/backoff.ts:20](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/backoff.ts#L20) + +___ + +### toBitcoinJsLibNetwork + +▸ **toBitcoinJsLibNetwork**(`bitcoinNetwork`): `networks.Network` + +Converts the provided [BitcoinNetwork](enums/BitcoinNetwork-1.md) enumeration to a format expected +by the `bitcoinjs-lib` library. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `bitcoinNetwork` | [`BitcoinNetwork`](enums/BitcoinNetwork-1.md) | Specified Bitcoin network. | + +#### Returns + +`networks.Network` + +Network representation compatible with the `bitcoinjs-lib` library. + +**`Throws`** + +An error if the network is not supported by `bitcoinjs-lib`. + +#### Defined in + +[lib/bitcoin/network.ts:55](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/network.ts#L55) + +___ + +### validateBitcoinHeadersChain + +▸ **validateBitcoinHeadersChain**(`headers`, `previousEpochDifficulty`, `currentEpochDifficulty`): `void` + +Validates a chain of consecutive block headers by checking each header's +difficulty, hash, and continuity with the previous header. This function can +be used to validate a series of Bitcoin block headers for their validity. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `headers` | [`BitcoinHeader`](interfaces/BitcoinHeader.md)[] | An array of block headers that form the chain to be validated. | +| `previousEpochDifficulty` | `BigNumber` | The difficulty of the previous Bitcoin epoch. | +| `currentEpochDifficulty` | `BigNumber` | The difficulty of the current Bitcoin epoch. | + +#### Returns + +`void` + +An empty return value. + +**`Dev`** + +The block headers must come from Bitcoin epochs with difficulties marked + by the previous and current difficulties. If a Bitcoin difficulty relay + is used to provide these values and the relay is up-to-date, only the + recent block headers will pass validation. Block headers older than the + current and previous Bitcoin epochs will fail. + +**`Throws`** + +If any of the block headers are invalid, or if the block + header chain is not continuous. + +#### Defined in + +[lib/bitcoin/header.ts:132](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/header.ts#L132) + +___ + +### validateBitcoinSpvProof + +▸ **validateBitcoinSpvProof**(`transactionHash`, `requiredConfirmations`, `previousDifficulty`, `currentDifficulty`, `bitcoinClient`): `Promise`\<`void`\> + +Proves that a transaction with the given hash is included in the Bitcoin +blockchain by validating the transaction's inclusion in the Merkle tree and +verifying that the block containing the transaction has enough confirmations. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transactionHash` | [`BitcoinTxHash`](classes/BitcoinTxHash.md) | The hash of the transaction to be validated. | +| `requiredConfirmations` | `number` | The number of confirmations required for the transaction to be considered valid. The transaction has 1 confirmation when it is in the block at the current blockchain tip. Every subsequent block added to the blockchain is one additional confirmation. | +| `previousDifficulty` | `BigNumber` | The difficulty of the previous Bitcoin epoch. | +| `currentDifficulty` | `BigNumber` | The difficulty of the current Bitcoin epoch. | +| `bitcoinClient` | [`BitcoinClient`](interfaces/BitcoinClient.md) | The client for interacting with the Bitcoin blockchain. | + +#### Returns + +`Promise`\<`void`\> + +An empty return value. + +**`Throws`** + +If the transaction is not included in the Bitcoin blockchain + or if the block containing the transaction does not have enough + confirmations. + +**`Dev`** + +The function should be used within a try-catch block. + +#### Defined in + +[lib/bitcoin/spv.ts:145](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/spv.ts#L145) + +___ + +### validateDepositReceipt + +▸ **validateDepositReceipt**(`receipt`): `void` + +Validates the given deposit receipt. Throws in case of a validation error. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `receipt` | [`DepositReceipt`](interfaces/DepositReceipt.md) | The validated deposit receipt. | + +#### Returns + +`void` + +**`Dev`** + +This function does not validate the depositor's identifier as its + validity is chain-specific. This parameter must be validated outside. + +#### Defined in + +[lib/contracts/bridge.ts:228](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L228) diff --git a/typescript/api-reference/classes/BitcoinTxHash.md b/typescript/api-reference/classes/BitcoinTxHash.md new file mode 100644 index 000000000..47deeb331 --- /dev/null +++ b/typescript/api-reference/classes/BitcoinTxHash.md @@ -0,0 +1,202 @@ +# Class: BitcoinTxHash + +Represents a Bitcoin transaction hash (or transaction ID) as an un-prefixed hex +string. This hash is supposed to have the same byte order as used by the +Bitcoin block explorers which is the opposite of the byte order used +by the Bitcoin protocol internally. That means the hash must be reversed in +the use cases that expect the Bitcoin internal byte order. + +## Hierarchy + +- [`Hex`](Hex.md) + + ↳ **`BitcoinTxHash`** + +## Table of contents + +### Constructors + +- [constructor](BitcoinTxHash.md#constructor) + +### Properties + +- [\_hex](BitcoinTxHash.md#_hex) + +### Methods + +- [equals](BitcoinTxHash.md#equals) +- [reverse](BitcoinTxHash.md#reverse) +- [toBuffer](BitcoinTxHash.md#tobuffer) +- [toPrefixedString](BitcoinTxHash.md#toprefixedstring) +- [toString](BitcoinTxHash.md#tostring) +- [from](BitcoinTxHash.md#from) + +## Constructors + +### constructor + +• **new BitcoinTxHash**(`value`): [`BitcoinTxHash`](BitcoinTxHash.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `value` | `string` \| `Buffer` | + +#### Returns + +[`BitcoinTxHash`](BitcoinTxHash.md) + +#### Inherited from + +[Hex](Hex.md).[constructor](Hex.md#constructor) + +#### Defined in + +[lib/utils/hex.ts:7](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L7) + +## Properties + +### \_hex + +• `Protected` `Readonly` **\_hex**: `Buffer` + +#### Inherited from + +[Hex](Hex.md).[_hex](Hex.md#_hex) + +#### Defined in + +[lib/utils/hex.ts:5](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L5) + +## Methods + +### equals + +▸ **equals**(`otherValue`): `boolean` + +Checks if other value equals the current value. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `otherValue` | [`Hex`](Hex.md) | Other value that will be compared to this value. | + +#### Returns + +`boolean` + +True if both values are equal, false otherwise. + +#### Inherited from + +[Hex](Hex.md).[equals](Hex.md#equals) + +#### Defined in + +[lib/utils/hex.ts:57](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L57) + +___ + +### reverse + +▸ **reverse**(): [`Hex`](Hex.md) + +#### Returns + +[`Hex`](Hex.md) + +Reversed hexadecimal value. + +#### Inherited from + +[Hex](Hex.md).[reverse](Hex.md#reverse) + +#### Defined in + +[lib/utils/hex.ts:64](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L64) + +___ + +### toBuffer + +▸ **toBuffer**(): `Buffer` + +#### Returns + +`Buffer` + +Hexadecimal value as a Buffer. + +#### Inherited from + +[Hex](Hex.md).[toBuffer](Hex.md#tobuffer) + +#### Defined in + +[lib/utils/hex.ts:32](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L32) + +___ + +### toPrefixedString + +▸ **toPrefixedString**(): `string` + +#### Returns + +`string` + +Hexadecimal string prefixed with '0x'. + +#### Inherited from + +[Hex](Hex.md).[toPrefixedString](Hex.md#toprefixedstring) + +#### Defined in + +[lib/utils/hex.ts:46](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L46) + +___ + +### toString + +▸ **toString**(): `string` + +#### Returns + +`string` + +Unprefixed hexadecimal string. + +#### Inherited from + +[Hex](Hex.md).[toString](Hex.md#tostring) + +#### Defined in + +[lib/utils/hex.ts:39](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L39) + +___ + +### from + +▸ **from**(`value`): [`Hex`](Hex.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `value` | `string` \| `Buffer` | + +#### Returns + +[`Hex`](Hex.md) + +#### Inherited from + +[Hex](Hex.md).[from](Hex.md#from) + +#### Defined in + +[lib/utils/hex.ts:25](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L25) diff --git a/typescript/api-reference/classes/Deposit.md b/typescript/api-reference/classes/Deposit.md new file mode 100644 index 000000000..522fa783b --- /dev/null +++ b/typescript/api-reference/classes/Deposit.md @@ -0,0 +1,215 @@ +# Class: Deposit + +Component representing an instance of the tBTC v2 deposit process. +Depositing is a complex process spanning both the Bitcoin and the target chain. +This component tries to abstract away that complexity. + +## Table of contents + +### Constructors + +- [constructor](Deposit.md#constructor) + +### Properties + +- [bitcoinClient](Deposit.md#bitcoinclient) +- [bitcoinNetwork](Deposit.md#bitcoinnetwork) +- [script](Deposit.md#script) +- [tbtcContracts](Deposit.md#tbtccontracts) + +### Methods + +- [detectFunding](Deposit.md#detectfunding) +- [getBitcoinAddress](Deposit.md#getbitcoinaddress) +- [getReceipt](Deposit.md#getreceipt) +- [initiateMinting](Deposit.md#initiateminting) +- [fromReceipt](Deposit.md#fromreceipt) + +## Constructors + +### constructor + +• **new Deposit**(`receipt`, `tbtcContracts`, `bitcoinClient`, `bitcoinNetwork`): [`Deposit`](Deposit.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `receipt` | [`DepositReceipt`](../interfaces/DepositReceipt.md) | +| `tbtcContracts` | [`TBTCContracts`](../README.md#tbtccontracts) | +| `bitcoinClient` | [`BitcoinClient`](../interfaces/BitcoinClient.md) | +| `bitcoinNetwork` | [`BitcoinNetwork`](../enums/BitcoinNetwork-1.md) | + +#### Returns + +[`Deposit`](Deposit.md) + +#### Defined in + +[services/deposits/deposit.ts:42](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L42) + +## Properties + +### bitcoinClient + +• `Private` `Readonly` **bitcoinClient**: [`BitcoinClient`](../interfaces/BitcoinClient.md) + +Bitcoin client handle. + +#### Defined in + +[services/deposits/deposit.ts:35](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L35) + +___ + +### bitcoinNetwork + +• `Readonly` **bitcoinNetwork**: [`BitcoinNetwork`](../enums/BitcoinNetwork-1.md) + +Bitcoin network the deposit is relevant for. Has an impact on the +generated deposit address. + +#### Defined in + +[services/deposits/deposit.ts:40](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L40) + +___ + +### script + +• `Private` `Readonly` **script**: [`DepositScript`](DepositScript.md) + +Bitcoin script corresponding to this deposit. + +#### Defined in + +[services/deposits/deposit.ts:27](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L27) + +___ + +### tbtcContracts + +• `Private` `Readonly` **tbtcContracts**: [`TBTCContracts`](../README.md#tbtccontracts) + +Handle to tBTC contracts. + +#### Defined in + +[services/deposits/deposit.ts:31](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L31) + +## Methods + +### detectFunding + +▸ **detectFunding**(): `Promise`\<[`BitcoinUtxo`](../README.md#bitcoinutxo)[]\> + +Detects Bitcoin funding transactions transferring BTC to this deposit. + +#### Returns + +`Promise`\<[`BitcoinUtxo`](../README.md#bitcoinutxo)[]\> + +Specific UTXOs targeting this deposit. Empty array in case + there are no UTXOs referring this deposit. + +#### Defined in + +[services/deposits/deposit.ts:84](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L84) + +___ + +### getBitcoinAddress + +▸ **getBitcoinAddress**(): `Promise`\<`string`\> + +#### Returns + +`Promise`\<`string`\> + +Bitcoin address corresponding to this deposit. + +#### Defined in + +[services/deposits/deposit.ts:74](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L74) + +___ + +### getReceipt + +▸ **getReceipt**(): [`DepositReceipt`](../interfaces/DepositReceipt.md) + +#### Returns + +[`DepositReceipt`](../interfaces/DepositReceipt.md) + +Receipt corresponding to this deposit. + +#### Defined in + +[services/deposits/deposit.ts:67](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L67) + +___ + +### initiateMinting + +▸ **initiateMinting**(`fundingOutpoint?`): `Promise`\<[`Hex`](Hex.md)\> + +Initiates minting of the TBTC token, based on the Bitcoin funding +transaction outpoint targeting this deposit. By default, it detects and +uses the outpoint of the recent Bitcoin funding transaction and throws if +such a transaction does not exist. This behavior can be changed by pointing +a funding transaction explicitly, using the fundingOutpoint parameter. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `fundingOutpoint?` | [`BitcoinTxOutpoint`](../interfaces/BitcoinTxOutpoint.md) | Optional parameter. Can be used to point the funding transaction's outpoint manually. | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +Target chain hash of the initiate minting transaction. + +**`Throws`** + +Throws an error if there are no funding transactions while using + the default funding detection mode. + +**`Throws`** + +Throws an error if the provided funding outpoint does not + actually refer to this deposit while using the manual funding + provision mode. + +**`Throws`** + +Throws an error if the funding outpoint was already used to + initiate minting (both modes). + +#### Defined in + +[services/deposits/deposit.ts:114](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L114) + +___ + +### fromReceipt + +▸ **fromReceipt**(`receipt`, `tbtcContracts`, `bitcoinClient`): `Promise`\<[`Deposit`](Deposit.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `receipt` | [`DepositReceipt`](../interfaces/DepositReceipt.md) | +| `tbtcContracts` | [`TBTCContracts`](../README.md#tbtccontracts) | +| `bitcoinClient` | [`BitcoinClient`](../interfaces/BitcoinClient.md) | + +#### Returns + +`Promise`\<[`Deposit`](Deposit.md)\> + +#### Defined in + +[services/deposits/deposit.ts:54](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L54) diff --git a/typescript/api-reference/classes/DepositFunding.md b/typescript/api-reference/classes/DepositFunding.md new file mode 100644 index 000000000..7bf298e41 --- /dev/null +++ b/typescript/api-reference/classes/DepositFunding.md @@ -0,0 +1,174 @@ +# Class: DepositFunding + +Component allowing to craft and submit the Bitcoin funding transaction using +the given tBTC v2 deposit script. + + THIS IS EXPERIMENTAL CODE THAT CAN BE CHANGED OR REMOVED + IN FUTURE RELEASES. IT SHOULD BE USED ONLY FOR INTERNAL + PURPOSES AND EXTERNAL APPLICATIONS SHOULD NOT DEPEND ON IT. + +## Table of contents + +### Constructors + +- [constructor](DepositFunding.md#constructor) + +### Properties + +- [script](DepositFunding.md#script) + +### Methods + +- [assembleTransaction](DepositFunding.md#assembletransaction) +- [submitTransaction](DepositFunding.md#submittransaction) +- [fromScript](DepositFunding.md#fromscript) + +## Constructors + +### constructor + +• **new DepositFunding**(`script`): [`DepositFunding`](DepositFunding.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `script` | [`DepositScript`](DepositScript.md) | + +#### Returns + +[`DepositFunding`](DepositFunding.md) + +#### Defined in + +[services/deposits/funding.ts:30](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/funding.ts#L30) + +## Properties + +### script + +• `Readonly` **script**: [`DepositScript`](DepositScript.md) + +#### Defined in + +[services/deposits/funding.ts:28](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/funding.ts#L28) + +## Methods + +### assembleTransaction + +▸ **assembleTransaction**(`bitcoinNetwork`, `amount`, `inputUtxos`, `fee`, `depositorPrivateKey`): `Promise`\<\{ `depositUtxo`: [`BitcoinUtxo`](../README.md#bitcoinutxo) ; `rawTransaction`: [`BitcoinRawTx`](../interfaces/BitcoinRawTx.md) ; `transactionHash`: [`BitcoinTxHash`](BitcoinTxHash.md) }\> + +Assembles and signs the Bitcoin P2(W)SH funding transaction using +the underlying deposit script. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `bitcoinNetwork` | [`BitcoinNetwork`](../enums/BitcoinNetwork-1.md) | The target Bitcoin network. | +| `amount` | `BigNumber` | Deposit amount in satoshis. | +| `inputUtxos` | [`BitcoinTxOutpoint`](../interfaces/BitcoinTxOutpoint.md) & \{ `value`: `BigNumber` } & [`BitcoinRawTx`](../interfaces/BitcoinRawTx.md)[] | UTXOs to be used for funding the deposit transaction. So far only P2WPKH UTXO inputs are supported. | +| `fee` | `BigNumber` | Transaction fee to be subtracted from the sum of the UTXOs' values. | +| `depositorPrivateKey` | `string` | Bitcoin private key of the depositor. Must be able to unlock input UTXOs. | + +#### Returns + +`Promise`\<\{ `depositUtxo`: [`BitcoinUtxo`](../README.md#bitcoinutxo) ; `rawTransaction`: [`BitcoinRawTx`](../interfaces/BitcoinRawTx.md) ; `transactionHash`: [`BitcoinTxHash`](BitcoinTxHash.md) }\> + +The outcome consisting of: + - the deposit transaction hash, + - the deposit UTXO produced by this transaction. + - the deposit transaction in the raw format + +**`Dev`** + +It is up to the caller to ensure that input UTXOs are valid and + can be unlocked using the depositor's private key. It is also + caller's responsibility to ensure the given deposit is funded exactly + once. + +**`Dev`** + +UTXOs are selected for transaction funding based on their types. UTXOs + with unsupported types are skipped. The selection process stops once + the sum of the chosen UTXOs meets the required funding amount. + +**`Throws`** + +When the sum of the selected UTXOs is insufficient to cover + the deposit amount and transaction fee. + +#### Defined in + +[services/deposits/funding.ts:62](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/funding.ts#L62) + +___ + +### submitTransaction + +▸ **submitTransaction**(`amount`, `inputUtxos`, `fee`, `depositorPrivateKey`, `bitcoinClient`): `Promise`\<\{ `depositUtxo`: [`BitcoinUtxo`](../README.md#bitcoinutxo) ; `transactionHash`: [`BitcoinTxHash`](BitcoinTxHash.md) }\> + +Assembles, signs and submits the Bitcoin P2(W)SH funding transaction +using the underlying deposit script. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `amount` | `BigNumber` | Deposit amount in satoshis. | +| `inputUtxos` | [`BitcoinUtxo`](../README.md#bitcoinutxo)[] | UTXOs to be used for funding the deposit transaction. So far only P2WPKH UTXO inputs are supported. | +| `fee` | `BigNumber` | The value that should be subtracted from the sum of the UTXOs values and used as the transaction fee. | +| `depositorPrivateKey` | `string` | Bitcoin private key of the depositor. | +| `bitcoinClient` | [`BitcoinClient`](../interfaces/BitcoinClient.md) | Bitcoin client used to interact with the network. | + +#### Returns + +`Promise`\<\{ `depositUtxo`: [`BitcoinUtxo`](../README.md#bitcoinutxo) ; `transactionHash`: [`BitcoinTxHash`](BitcoinTxHash.md) }\> + +The outcome consisting of: + - the deposit transaction hash, + - the deposit UTXO produced by this transaction. + +**`Dev`** + +It is up to the caller to ensure that depositor's private key controls + some UTXOs that can be used as input. It is also caller's responsibility + to ensure the given deposit is funded exactly once. + +**`Dev`** + +UTXOs are selected for transaction funding based on their types. UTXOs + with unsupported types are skipped. The selection process stops once + the sum of the chosen UTXOs meets the required funding amount. + Be aware that the function will attempt to broadcast the transaction, + although successful broadcast is not guaranteed. + +**`Throws`** + +When the sum of the selected UTXOs is insufficient to cover + the deposit amount and transaction fee. + +#### Defined in + +[services/deposits/funding.ts:181](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/funding.ts#L181) + +___ + +### fromScript + +▸ **fromScript**(`script`): [`DepositFunding`](DepositFunding.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `script` | [`DepositScript`](DepositScript.md) | + +#### Returns + +[`DepositFunding`](DepositFunding.md) + +#### Defined in + +[services/deposits/funding.ts:34](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/funding.ts#L34) diff --git a/typescript/api-reference/classes/DepositRefund.md b/typescript/api-reference/classes/DepositRefund.md new file mode 100644 index 000000000..1bc726de0 --- /dev/null +++ b/typescript/api-reference/classes/DepositRefund.md @@ -0,0 +1,226 @@ +# Class: DepositRefund + +Component allowing to craft and submit the Bitcoin refund transaction using +the given tBTC v2 deposit script. + + THIS IS EXPERIMENTAL CODE THAT CAN BE CHANGED OR REMOVED + IN FUTURE RELEASES. IT SHOULD BE USED ONLY FOR INTERNAL + PURPOSES AND EXTERNAL APPLICATIONS SHOULD NOT DEPEND ON IT. + +## Table of contents + +### Constructors + +- [constructor](DepositRefund.md#constructor) + +### Properties + +- [script](DepositRefund.md#script) + +### Methods + +- [assembleTransaction](DepositRefund.md#assembletransaction) +- [prepareDepositScript](DepositRefund.md#preparedepositscript) +- [signP2SHDepositInput](DepositRefund.md#signp2shdepositinput) +- [signP2WSHDepositInput](DepositRefund.md#signp2wshdepositinput) +- [submitTransaction](DepositRefund.md#submittransaction) +- [fromScript](DepositRefund.md#fromscript) + +## Constructors + +### constructor + +• **new DepositRefund**(`script`): [`DepositRefund`](DepositRefund.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `script` | [`DepositScript`](DepositScript.md) | + +#### Returns + +[`DepositRefund`](DepositRefund.md) + +#### Defined in + +[services/deposits/refund.ts:37](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/refund.ts#L37) + +## Properties + +### script + +• `Readonly` **script**: [`DepositScript`](DepositScript.md) + +#### Defined in + +[services/deposits/refund.ts:35](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/refund.ts#L35) + +## Methods + +### assembleTransaction + +▸ **assembleTransaction**(`bitcoinNetwork`, `fee`, `utxo`, `refunderAddress`, `refunderPrivateKey`): `Promise`\<\{ `rawTransaction`: [`BitcoinRawTx`](../interfaces/BitcoinRawTx.md) ; `transactionHash`: [`BitcoinTxHash`](BitcoinTxHash.md) }\> + +Assembles a Bitcoin P2(W)PKH deposit refund transaction. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `bitcoinNetwork` | [`BitcoinNetwork`](../enums/BitcoinNetwork-1.md) | The target Bitcoin network. | +| `fee` | `BigNumber` | the value that will be subtracted from the deposit UTXO being refunded and used as the transaction fee. | +| `utxo` | [`BitcoinTxOutpoint`](../interfaces/BitcoinTxOutpoint.md) & \{ `value`: `BigNumber` } & [`BitcoinRawTx`](../interfaces/BitcoinRawTx.md) | UTXO that was created during depositing that needs be refunded. | +| `refunderAddress` | `string` | Recipient Bitcoin wallet address of the refunded deposit. | +| `refunderPrivateKey` | `string` | Bitcoin wallet private key of the refunder. It must correspond to the `refundPublicKeyHash` of the deposit script. | + +#### Returns + +`Promise`\<\{ `rawTransaction`: [`BitcoinRawTx`](../interfaces/BitcoinRawTx.md) ; `transactionHash`: [`BitcoinTxHash`](BitcoinTxHash.md) }\> + +The outcome consisting of: + - the deposit refund transaction hash, + - the refund transaction in the raw format. + +#### Defined in + +[services/deposits/refund.ts:111](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/refund.ts#L111) + +___ + +### prepareDepositScript + +▸ **prepareDepositScript**(`refunderKeyPair`): `Promise`\<`Buffer`\> + +Assembles the deposit script based on the given deposit details. Performs +validations on values and key formats. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `refunderKeyPair` | `Signer` | Signer object containing the refunder's key pair. | + +#### Returns + +`Promise`\<`Buffer`\> + +A Promise resolving to the assembled deposit script as a Buffer. + +**`Throws`** + +Error if there are discrepancies in values or key formats. + +#### Defined in + +[services/deposits/refund.ts:191](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/refund.ts#L191) + +___ + +### signP2SHDepositInput + +▸ **signP2SHDepositInput**(`transaction`, `inputIndex`, `refunderKeyPair`): `Promise`\<`void`\> + +Signs a P2SH deposit transaction input and sets the `scriptSig`. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transaction` | `Transaction` | The transaction containing the input to be signed. | +| `inputIndex` | `number` | Index pointing to the input within the transaction. | +| `refunderKeyPair` | `Signer` | A Signer object with the refunder's public and private key pair. | + +#### Returns + +`Promise`\<`void`\> + +An empty promise upon successful signing. + +#### Defined in + +[services/deposits/refund.ts:219](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/refund.ts#L219) + +___ + +### signP2WSHDepositInput + +▸ **signP2WSHDepositInput**(`transaction`, `inputIndex`, `previousOutputValue`, `refunderKeyPair`): `Promise`\<`void`\> + +Signs a P2WSH deposit transaction input and sets the witness script. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transaction` | `Transaction` | The transaction containing the input to be signed. | +| `inputIndex` | `number` | Index pointing to the input within the transaction. | +| `previousOutputValue` | `number` | The value from the previous transaction output. | +| `refunderKeyPair` | `Signer` | A Signer object with the refunder's public and private key pair. | + +#### Returns + +`Promise`\<`void`\> + +An empty promise upon successful signing. + +#### Defined in + +[services/deposits/refund.ts:256](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/refund.ts#L256) + +___ + +### submitTransaction + +▸ **submitTransaction**(`bitcoinClient`, `fee`, `utxo`, `refunderAddress`, `refunderPrivateKey`): `Promise`\<\{ `transactionHash`: [`BitcoinTxHash`](BitcoinTxHash.md) }\> + +Submits a deposit refund by creating and broadcasting a Bitcoin P2(W)PKH +deposit refund transaction. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `bitcoinClient` | [`BitcoinClient`](../interfaces/BitcoinClient.md) | Bitcoin client used to interact with the network. | +| `fee` | `BigNumber` | the value that will be subtracted from the deposit UTXO being refunded and used as the transaction fee. | +| `utxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | UTXO that was created during depositing that needs be refunded. | +| `refunderAddress` | `string` | Recipient Bitcoin wallet address of the refunded deposit. | +| `refunderPrivateKey` | `string` | Bitcoin wallet private key of the refunder. It must correspond to the `refundPublicKeyHash` of the deposit script. | + +#### Returns + +`Promise`\<\{ `transactionHash`: [`BitcoinTxHash`](BitcoinTxHash.md) }\> + +The outcome is the deposit refund transaction hash. + +**`Dev`** + +This function should be called by the refunder after `refundLocktime` + passes plus 1 hour. The additional hour of waiting is the result of + adopting BIP113 which compares the transaction's locktime against the + median timestamp of the last 11 blocks. This median time lags + the current unix time by about 1 hour. + +#### Defined in + +[services/deposits/refund.ts:63](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/refund.ts#L63) + +___ + +### fromScript + +▸ **fromScript**(`script`): [`DepositRefund`](DepositRefund.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `script` | [`DepositScript`](DepositScript.md) | + +#### Returns + +[`DepositRefund`](DepositRefund.md) + +#### Defined in + +[services/deposits/refund.ts:41](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/refund.ts#L41) diff --git a/typescript/api-reference/classes/DepositScript.md b/typescript/api-reference/classes/DepositScript.md new file mode 100644 index 000000000..3e70aa76d --- /dev/null +++ b/typescript/api-reference/classes/DepositScript.md @@ -0,0 +1,149 @@ +# Class: DepositScript + +Represents a Bitcoin script corresponding to a tBTC v2 deposit. +On a high-level, the script is used to derive the Bitcoin address that is +used to fund the deposit with BTC. On a low-level, the script is used to +produce a properly locked funding transaction output that can be unlocked +by the target wallet during the deposit sweep process. + +## Table of contents + +### Constructors + +- [constructor](DepositScript.md#constructor) + +### Properties + +- [receipt](DepositScript.md#receipt) +- [witness](DepositScript.md#witness) + +### Methods + +- [deriveAddress](DepositScript.md#deriveaddress) +- [getHash](DepositScript.md#gethash) +- [getPlainText](DepositScript.md#getplaintext) +- [fromReceipt](DepositScript.md#fromreceipt) + +## Constructors + +### constructor + +• **new DepositScript**(`receipt`, `witness`): [`DepositScript`](DepositScript.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `receipt` | [`DepositReceipt`](../interfaces/DepositReceipt.md) | +| `witness` | `boolean` | + +#### Returns + +[`DepositScript`](DepositScript.md) + +#### Defined in + +[services/deposits/deposit.ts:166](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L166) + +## Properties + +### receipt + +• `Readonly` **receipt**: [`DepositReceipt`](../interfaces/DepositReceipt.md) + +Deposit receipt holding the most important information about the deposit +and allowing to build a unique deposit script (and address) on Bitcoin chain. + +#### Defined in + +[services/deposits/deposit.ts:159](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L159) + +___ + +### witness + +• `Readonly` **witness**: `boolean` + +Flag indicating whether the generated Bitcoin deposit script (and address) +should be a witness P2WSH one. If false, legacy P2SH will be used instead. + +#### Defined in + +[services/deposits/deposit.ts:164](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L164) + +## Methods + +### deriveAddress + +▸ **deriveAddress**(`bitcoinNetwork`): `Promise`\<`string`\> + +Derives a Bitcoin address for the given network for this deposit script. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `bitcoinNetwork` | [`BitcoinNetwork`](../enums/BitcoinNetwork-1.md) | Bitcoin network the address should be derived for. | + +#### Returns + +`Promise`\<`string`\> + +Bitcoin address corresponding to this deposit script. + +#### Defined in + +[services/deposits/deposit.ts:228](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L228) + +___ + +### getHash + +▸ **getHash**(): `Promise`\<`Buffer`\> + +#### Returns + +`Promise`\<`Buffer`\> + +Hashed deposit script as Buffer. + +#### Defined in + +[services/deposits/deposit.ts:183](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L183) + +___ + +### getPlainText + +▸ **getPlainText**(): `Promise`\<[`Hex`](Hex.md)\> + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +Plain-text deposit script as a hex string. + +#### Defined in + +[services/deposits/deposit.ts:195](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L195) + +___ + +### fromReceipt + +▸ **fromReceipt**(`receipt`, `witness?`): [`DepositScript`](DepositScript.md) + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `receipt` | [`DepositReceipt`](../interfaces/DepositReceipt.md) | `undefined` | +| `witness` | `boolean` | `true` | + +#### Returns + +[`DepositScript`](DepositScript.md) + +#### Defined in + +[services/deposits/deposit.ts:173](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L173) diff --git a/typescript/api-reference/classes/DepositsService.md b/typescript/api-reference/classes/DepositsService.md new file mode 100644 index 000000000..cd237c9ab --- /dev/null +++ b/typescript/api-reference/classes/DepositsService.md @@ -0,0 +1,173 @@ +# Class: DepositsService + +Service exposing features related to tBTC v2 deposits. + +## Table of contents + +### Constructors + +- [constructor](DepositsService.md#constructor) + +### Properties + +- [bitcoinClient](DepositsService.md#bitcoinclient) +- [defaultDepositor](DepositsService.md#defaultdepositor) +- [depositRefundLocktimeDuration](DepositsService.md#depositrefundlocktimeduration) +- [tbtcContracts](DepositsService.md#tbtccontracts) + +### Methods + +- [generateDepositReceipt](DepositsService.md#generatedepositreceipt) +- [initiateDeposit](DepositsService.md#initiatedeposit) +- [setDefaultDepositor](DepositsService.md#setdefaultdepositor) + +## Constructors + +### constructor + +• **new DepositsService**(`tbtcContracts`, `bitcoinClient`): [`DepositsService`](DepositsService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `tbtcContracts` | [`TBTCContracts`](../README.md#tbtccontracts) | +| `bitcoinClient` | [`BitcoinClient`](../interfaces/BitcoinClient.md) | + +#### Returns + +[`DepositsService`](DepositsService.md) + +#### Defined in + +[services/deposits/deposits-service.ts:40](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposits-service.ts#L40) + +## Properties + +### bitcoinClient + +• `Private` `Readonly` **bitcoinClient**: [`BitcoinClient`](../interfaces/BitcoinClient.md) + +Bitcoin client handle. + +#### Defined in + +[services/deposits/deposits-service.ts:33](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposits-service.ts#L33) + +___ + +### defaultDepositor + +• `Private` **defaultDepositor**: `undefined` \| [`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +Chain-specific identifier of the default depositor used for deposits +initiated by this service. + +#### Defined in + +[services/deposits/deposits-service.ts:38](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposits-service.ts#L38) + +___ + +### depositRefundLocktimeDuration + +• `Private` `Readonly` **depositRefundLocktimeDuration**: ``23328000`` + +Deposit refund locktime duration in seconds. +This is 9 month in seconds assuming 1 month = 30 days + +#### Defined in + +[services/deposits/deposits-service.ts:25](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposits-service.ts#L25) + +___ + +### tbtcContracts + +• `Private` `Readonly` **tbtcContracts**: [`TBTCContracts`](../README.md#tbtccontracts) + +Handle to tBTC contracts. + +#### Defined in + +[services/deposits/deposits-service.ts:29](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposits-service.ts#L29) + +## Methods + +### generateDepositReceipt + +▸ **generateDepositReceipt**(`bitcoinRecoveryAddress`): `Promise`\<[`DepositReceipt`](../interfaces/DepositReceipt.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `bitcoinRecoveryAddress` | `string` | + +#### Returns + +`Promise`\<[`DepositReceipt`](../interfaces/DepositReceipt.md)\> + +#### Defined in + +[services/deposits/deposits-service.ts:62](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposits-service.ts#L62) + +___ + +### initiateDeposit + +▸ **initiateDeposit**(`bitcoinRecoveryAddress`): `Promise`\<[`Deposit`](Deposit.md)\> + +Initiates the tBTC v2 deposit process. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `bitcoinRecoveryAddress` | `string` | P2PKH or P2WPKH Bitcoin address that can be used for emergency recovery of the deposited funds. | + +#### Returns + +`Promise`\<[`Deposit`](Deposit.md)\> + +Handle to the initiated deposit process. + +**`Throws`** + +Throws an error if one of the following occurs: + - The default depositor is not set + - There are no active wallet in the Bridge contract + - The Bitcoin recovery address is not a valid P2(W)PKH + +#### Defined in + +[services/deposits/deposits-service.ts:57](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposits-service.ts#L57) + +___ + +### setDefaultDepositor + +▸ **setDefaultDepositor**(`defaultDepositor`): `void` + +Sets the default depositor used for deposits initiated by this service. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `defaultDepositor` | [`ChainIdentifier`](../interfaces/ChainIdentifier.md) | Chain-specific identifier of the default depositor. | + +#### Returns + +`void` + +**`Dev`** + +Typically, there is no need to use this method when DepositsService + is orchestrated automatically. However, there are some use cases + where setting the default depositor explicitly may be useful. + Make sure you know what you are doing while using this method. + +#### Defined in + +[services/deposits/deposits-service.ts:125](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposits-service.ts#L125) diff --git a/typescript/api-reference/classes/ElectrumClient.md b/typescript/api-reference/classes/ElectrumClient.md new file mode 100644 index 000000000..f617ed98e --- /dev/null +++ b/typescript/api-reference/classes/ElectrumClient.md @@ -0,0 +1,496 @@ +# Class: ElectrumClient + +Electrum-based implementation of the Bitcoin client. + +## Implements + +- [`BitcoinClient`](../interfaces/BitcoinClient.md) + +## Table of contents + +### Constructors + +- [constructor](ElectrumClient.md#constructor) + +### Properties + +- [connectionTimeout](ElectrumClient.md#connectiontimeout) +- [credentials](ElectrumClient.md#credentials) +- [options](ElectrumClient.md#options) +- [retryBackoffStep](ElectrumClient.md#retrybackoffstep) +- [totalRetryAttempts](ElectrumClient.md#totalretryattempts) + +### Methods + +- [broadcast](ElectrumClient.md#broadcast) +- [findAllUnspentTransactionOutputs](ElectrumClient.md#findallunspenttransactionoutputs) +- [getHeadersChain](ElectrumClient.md#getheaderschain) +- [getNetwork](ElectrumClient.md#getnetwork) +- [getRawTransaction](ElectrumClient.md#getrawtransaction) +- [getTransaction](ElectrumClient.md#gettransaction) +- [getTransactionConfirmations](ElectrumClient.md#gettransactionconfirmations) +- [getTransactionHistory](ElectrumClient.md#gettransactionhistory) +- [getTransactionMerkle](ElectrumClient.md#gettransactionmerkle) +- [latestBlockHeight](ElectrumClient.md#latestblockheight) +- [withBackoffRetrier](ElectrumClient.md#withbackoffretrier) +- [withElectrum](ElectrumClient.md#withelectrum) +- [fromDefaultConfig](ElectrumClient.md#fromdefaultconfig) +- [fromUrl](ElectrumClient.md#fromurl) +- [parseElectrumCredentials](ElectrumClient.md#parseelectrumcredentials) + +## Constructors + +### constructor + +• **new ElectrumClient**(`credentials`, `options?`, `totalRetryAttempts?`, `retryBackoffStep?`, `connectionTimeout?`): [`ElectrumClient`](ElectrumClient.md) + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `credentials` | [`ElectrumCredentials`](../interfaces/ElectrumCredentials.md)[] | `undefined` | +| `options?` | `object` | `undefined` | +| `totalRetryAttempts` | `number` | `3` | +| `retryBackoffStep` | `number` | `10000` | +| `connectionTimeout` | `number` | `20000` | + +#### Returns + +[`ElectrumClient`](ElectrumClient.md) + +#### Defined in + +[lib/electrum/client.ts:72](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L72) + +## Properties + +### connectionTimeout + +• `Private` **connectionTimeout**: `number` + +#### Defined in + +[lib/electrum/client.ts:70](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L70) + +___ + +### credentials + +• `Private` **credentials**: [`ElectrumCredentials`](../interfaces/ElectrumCredentials.md)[] + +#### Defined in + +[lib/electrum/client.ts:66](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L66) + +___ + +### options + +• `Private` `Optional` **options**: `object` + +#### Defined in + +[lib/electrum/client.ts:67](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L67) + +___ + +### retryBackoffStep + +• `Private` **retryBackoffStep**: `number` + +#### Defined in + +[lib/electrum/client.ts:69](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L69) + +___ + +### totalRetryAttempts + +• `Private` **totalRetryAttempts**: `number` + +#### Defined in + +[lib/electrum/client.ts:68](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L68) + +## Methods + +### broadcast + +▸ **broadcast**(`transaction`): `Promise`\<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transaction` | [`BitcoinRawTx`](../interfaces/BitcoinRawTx.md) | + +#### Returns + +`Promise`\<`void`\> + +**`See`** + +#### Implementation of + +[BitcoinClient](../interfaces/BitcoinClient.md).[broadcast](../interfaces/BitcoinClient.md#broadcast) + +#### Defined in + +[lib/electrum/client.ts:574](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L574) + +___ + +### findAllUnspentTransactionOutputs + +▸ **findAllUnspentTransactionOutputs**(`address`): `Promise`\<[`BitcoinUtxo`](../README.md#bitcoinutxo)[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `address` | `string` | + +#### Returns + +`Promise`\<[`BitcoinUtxo`](../README.md#bitcoinutxo)[]\> + +**`See`** + +#### Implementation of + +[BitcoinClient](../interfaces/BitcoinClient.md).[findAllUnspentTransactionOutputs](../interfaces/BitcoinClient.md#findallunspenttransactionoutputs) + +#### Defined in + +[lib/electrum/client.ts:260](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L260) + +___ + +### getHeadersChain + +▸ **getHeadersChain**(`blockHeight`, `chainLength`): `Promise`\<[`Hex`](Hex.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `blockHeight` | `number` | +| `chainLength` | `number` | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +**`See`** + +#### Implementation of + +[BitcoinClient](../interfaces/BitcoinClient.md).[getHeadersChain](../interfaces/BitcoinClient.md#getheaderschain) + +#### Defined in + +[lib/electrum/client.ts:524](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L524) + +___ + +### getNetwork + +▸ **getNetwork**(): `Promise`\<[`BitcoinNetwork`](../enums/BitcoinNetwork-1.md)\> + +#### Returns + +`Promise`\<[`BitcoinNetwork`](../enums/BitcoinNetwork-1.md)\> + +**`See`** + +#### Implementation of + +[BitcoinClient](../interfaces/BitcoinClient.md).[getNetwork](../interfaces/BitcoinClient.md#getnetwork) + +#### Defined in + +[lib/electrum/client.ts:238](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L238) + +___ + +### getRawTransaction + +▸ **getRawTransaction**(`transactionHash`): `Promise`\<[`BitcoinRawTx`](../interfaces/BitcoinRawTx.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | + +#### Returns + +`Promise`\<[`BitcoinRawTx`](../interfaces/BitcoinRawTx.md)\> + +**`See`** + +#### Implementation of + +[BitcoinClient](../interfaces/BitcoinClient.md).[getRawTransaction](../interfaces/BitcoinClient.md#getrawtransaction) + +#### Defined in + +[lib/electrum/client.ts:395](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L395) + +___ + +### getTransaction + +▸ **getTransaction**(`transactionHash`): `Promise`\<[`BitcoinTx`](../interfaces/BitcoinTx.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | + +#### Returns + +`Promise`\<[`BitcoinTx`](../interfaces/BitcoinTx.md)\> + +**`See`** + +#### Implementation of + +[BitcoinClient](../interfaces/BitcoinClient.md).[getTransaction](../interfaces/BitcoinClient.md#gettransaction) + +#### Defined in + +[lib/electrum/client.ts:345](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L345) + +___ + +### getTransactionConfirmations + +▸ **getTransactionConfirmations**(`transactionHash`): `Promise`\<`number`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | + +#### Returns + +`Promise`\<`number`\> + +**`See`** + +#### Implementation of + +[BitcoinClient](../interfaces/BitcoinClient.md).[getTransactionConfirmations](../interfaces/BitcoinClient.md#gettransactionconfirmations) + +#### Defined in + +[lib/electrum/client.ts:416](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L416) + +___ + +### getTransactionHistory + +▸ **getTransactionHistory**(`address`, `limit?`): `Promise`\<[`BitcoinTx`](../interfaces/BitcoinTx.md)[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `address` | `string` | +| `limit?` | `number` | + +#### Returns + +`Promise`\<[`BitcoinTx`](../interfaces/BitcoinTx.md)[]\> + +**`See`** + +#### Implementation of + +[BitcoinClient](../interfaces/BitcoinClient.md).[getTransactionHistory](../interfaces/BitcoinClient.md#gettransactionhistory) + +#### Defined in + +[lib/electrum/client.ts:291](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L291) + +___ + +### getTransactionMerkle + +▸ **getTransactionMerkle**(`transactionHash`, `blockHeight`): `Promise`\<[`BitcoinTxMerkleBranch`](../interfaces/BitcoinTxMerkleBranch.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `transactionHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | +| `blockHeight` | `number` | + +#### Returns + +`Promise`\<[`BitcoinTxMerkleBranch`](../interfaces/BitcoinTxMerkleBranch.md)\> + +**`See`** + +#### Implementation of + +[BitcoinClient](../interfaces/BitcoinClient.md).[getTransactionMerkle](../interfaces/BitcoinClient.md#gettransactionmerkle) + +#### Defined in + +[lib/electrum/client.ts:543](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L543) + +___ + +### latestBlockHeight + +▸ **latestBlockHeight**(): `Promise`\<`number`\> + +#### Returns + +`Promise`\<`number`\> + +**`See`** + +#### Implementation of + +[BitcoinClient](../interfaces/BitcoinClient.md).[latestBlockHeight](../interfaces/BitcoinClient.md#latestblockheight) + +#### Defined in + +[lib/electrum/client.ts:508](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L508) + +___ + +### withBackoffRetrier + +▸ **withBackoffRetrier**\<`T`\>(): [`RetrierFn`](../README.md#retrierfn)\<`T`\> + +Initiates a backoff retrier. + +#### Type parameters + +| Name | +| :------ | +| `T` | + +#### Returns + +[`RetrierFn`](../README.md#retrierfn)\<`T`\> + +A function that can retry any function. + +#### Defined in + +[lib/electrum/client.ts:230](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L230) + +___ + +### withElectrum + +▸ **withElectrum**\<`T`\>(`action`): `Promise`\<`T`\> + +Initiates an Electrum connection and uses it to feed the given action. +Closes the connection regardless of the action outcome. + +#### Type parameters + +| Name | +| :------ | +| `T` | + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `action` | `ElectrumAction`\<`T`\> | Action that makes use of the Electrum connection. | + +#### Returns + +`Promise`\<`T`\> + +Promise holding the outcome. + +#### Defined in + +[lib/electrum/client.ts:168](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L168) + +___ + +### fromDefaultConfig + +▸ **fromDefaultConfig**(`network`): [`ElectrumClient`](ElectrumClient.md) + +Creates an Electrum client instance using a default config for the given +Bitcoin network. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `network` | [`BitcoinNetwork`](../enums/BitcoinNetwork-1.md) | Bitcoin network the instance should be created for. | + +#### Returns + +[`ElectrumClient`](ElectrumClient.md) + +Electrum client instance. + +#### Defined in + +[lib/electrum/client.ts:126](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L126) + +___ + +### fromUrl + +▸ **fromUrl**(`url`, `options?`, `totalRetryAttempts?`, `retryBackoffStep?`, `connectionTimeout?`): [`ElectrumClient`](ElectrumClient.md) + +Creates an Electrum client instance from a URL. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `url` | `string` \| `string`[] | `undefined` | Connection URL or list of URLs. | +| `options?` | `object` | `undefined` | Additional options used by the Electrum server. | +| `totalRetryAttempts` | `number` | `3` | Number of retries for requests sent to Electrum server. | +| `retryBackoffStep` | `number` | `1000` | Initial backoff step in milliseconds that will be increased exponentially for subsequent retry attempts. | +| `connectionTimeout` | `number` | `20000` | Timeout for a single try of connection establishment. | + +#### Returns + +[`ElectrumClient`](ElectrumClient.md) + +Electrum client instance. + +#### Defined in + +[lib/electrum/client.ts:97](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L97) + +___ + +### parseElectrumCredentials + +▸ **parseElectrumCredentials**(`url`): [`ElectrumCredentials`](../interfaces/ElectrumCredentials.md) + +Create Electrum credentials by parsing an URL. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `url` | `string` | URL to be parsed. | + +#### Returns + +[`ElectrumCredentials`](../interfaces/ElectrumCredentials.md) + +Electrum credentials object. + +#### Defined in + +[lib/electrum/client.ts:147](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L147) diff --git a/typescript/api-reference/classes/EthereumAddress.md b/typescript/api-reference/classes/EthereumAddress.md new file mode 100644 index 000000000..7998fc4a6 --- /dev/null +++ b/typescript/api-reference/classes/EthereumAddress.md @@ -0,0 +1,104 @@ +# Class: EthereumAddress + +Represents an Ethereum address. + +## Implements + +- [`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +## Table of contents + +### Constructors + +- [constructor](EthereumAddress.md#constructor) + +### Properties + +- [identifierHex](EthereumAddress.md#identifierhex) + +### Methods + +- [equals](EthereumAddress.md#equals) +- [from](EthereumAddress.md#from) + +## Constructors + +### constructor + +• **new EthereumAddress**(`address`): [`EthereumAddress`](EthereumAddress.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `address` | `string` | + +#### Returns + +[`EthereumAddress`](EthereumAddress.md) + +#### Defined in + +[lib/ethereum/address.ts:12](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/address.ts#L12) + +## Properties + +### identifierHex + +• `Readonly` **identifierHex**: `string` + +Identifier as an un-prefixed hex string. + +#### Implementation of + +[ChainIdentifier](../interfaces/ChainIdentifier.md).[identifierHex](../interfaces/ChainIdentifier.md#identifierhex) + +#### Defined in + +[lib/ethereum/address.ts:10](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/address.ts#L10) + +## Methods + +### equals + +▸ **equals**(`otherValue`): `boolean` + +Checks if two identifiers are equal. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `otherValue` | [`EthereumAddress`](EthereumAddress.md) | Another identifier | + +#### Returns + +`boolean` + +#### Implementation of + +[ChainIdentifier](../interfaces/ChainIdentifier.md).[equals](../interfaces/ChainIdentifier.md#equals) + +#### Defined in + +[lib/ethereum/address.ts:28](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/address.ts#L28) + +___ + +### from + +▸ **from**(`address`): [`EthereumAddress`](EthereumAddress.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `address` | `string` | + +#### Returns + +[`EthereumAddress`](EthereumAddress.md) + +#### Defined in + +[lib/ethereum/address.ts:24](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/address.ts#L24) diff --git a/typescript/api-reference/classes/EthereumBridge.md b/typescript/api-reference/classes/EthereumBridge.md new file mode 100644 index 000000000..dc55ab59e --- /dev/null +++ b/typescript/api-reference/classes/EthereumBridge.md @@ -0,0 +1,743 @@ +# Class: EthereumBridge + +Implementation of the Ethereum Bridge handle. + +**`See`** + +for reference. + +## Hierarchy + +- `EthersContractHandle`\<`BridgeTypechain`\> + + ↳ **`EthereumBridge`** + +## Implements + +- [`Bridge`](../interfaces/Bridge.md) + +## Table of contents + +### Constructors + +- [constructor](EthereumBridge.md#constructor) + +### Properties + +- [\_deployedAtBlockNumber](EthereumBridge.md#_deployedatblocknumber) +- [\_instance](EthereumBridge.md#_instance) +- [\_totalRetryAttempts](EthereumBridge.md#_totalretryattempts) + +### Methods + +- [activeWalletPublicKey](EthereumBridge.md#activewalletpublickey) +- [buildUtxoHash](EthereumBridge.md#buildutxohash) +- [deposits](EthereumBridge.md#deposits) +- [getAddress](EthereumBridge.md#getaddress) +- [getChainIdentifier](EthereumBridge.md#getchainidentifier) +- [getDepositRevealedEvents](EthereumBridge.md#getdepositrevealedevents) +- [getEvents](EthereumBridge.md#getevents) +- [getNewWalletRegisteredEvents](EthereumBridge.md#getnewwalletregisteredevents) +- [getRedemptionRequestedEvents](EthereumBridge.md#getredemptionrequestedevents) +- [getWalletCompressedPublicKey](EthereumBridge.md#getwalletcompressedpublickey) +- [parseDepositRequest](EthereumBridge.md#parsedepositrequest) +- [parseRedemptionRequest](EthereumBridge.md#parseredemptionrequest) +- [parseWalletDetails](EthereumBridge.md#parsewalletdetails) +- [pendingRedemptions](EthereumBridge.md#pendingredemptions) +- [requestRedemption](EthereumBridge.md#requestredemption) +- [revealDeposit](EthereumBridge.md#revealdeposit) +- [submitDepositSweepProof](EthereumBridge.md#submitdepositsweepproof) +- [submitRedemptionProof](EthereumBridge.md#submitredemptionproof) +- [timedOutRedemptions](EthereumBridge.md#timedoutredemptions) +- [txProofDifficultyFactor](EthereumBridge.md#txproofdifficultyfactor) +- [walletRegistry](EthereumBridge.md#walletregistry) +- [wallets](EthereumBridge.md#wallets) +- [buildDepositKey](EthereumBridge.md#builddepositkey) +- [buildRedemptionKey](EthereumBridge.md#buildredemptionkey) + +## Constructors + +### constructor + +• **new EthereumBridge**(`config`, `deploymentType?`): [`EthereumBridge`](EthereumBridge.md) + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `config` | [`EthereumContractConfig`](../interfaces/EthereumContractConfig.md) | `undefined` | +| `deploymentType` | ``"local"`` \| ``"goerli"`` \| ``"mainnet"`` | `"local"` | + +#### Returns + +[`EthereumBridge`](EthereumBridge.md) + +#### Overrides + +EthersContractHandle\<BridgeTypechain\>.constructor + +#### Defined in + +[lib/ethereum/bridge.ts:59](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L59) + +## Properties + +### \_deployedAtBlockNumber + +• `Protected` `Readonly` **\_deployedAtBlockNumber**: `number` + +Number of a block within which the contract was deployed. Value is read from +the contract deployment artifact. It can be overwritten by setting a +[EthersContractConfig.deployedAtBlockNumber](../interfaces/EthereumContractConfig.md#deployedatblocknumber) property. + +#### Inherited from + +EthersContractHandle.\_deployedAtBlockNumber + +#### Defined in + +[lib/ethereum/adapter.ts:80](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L80) + +___ + +### \_instance + +• `Protected` `Readonly` **\_instance**: `Bridge` + +Ethers instance of the deployed contract. + +#### Inherited from + +EthersContractHandle.\_instance + +#### Defined in + +[lib/ethereum/adapter.ts:74](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L74) + +___ + +### \_totalRetryAttempts + +• `Protected` `Readonly` **\_totalRetryAttempts**: `number` + +Number of retries for ethereum requests. + +#### Inherited from + +EthersContractHandle.\_totalRetryAttempts + +#### Defined in + +[lib/ethereum/adapter.ts:84](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L84) + +## Methods + +### activeWalletPublicKey + +▸ **activeWalletPublicKey**(): `Promise`\<`undefined` \| [`Hex`](Hex.md)\> + +#### Returns + +`Promise`\<`undefined` \| [`Hex`](Hex.md)\> + +**`See`** + +#### Implementation of + +[Bridge](../interfaces/Bridge.md).[activeWalletPublicKey](../interfaces/Bridge.md#activewalletpublickey) + +#### Defined in + +[lib/ethereum/bridge.ts:490](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L490) + +___ + +### buildUtxoHash + +▸ **buildUtxoHash**(`utxo`): [`Hex`](Hex.md) + +Builds the UTXO hash based on the UTXO components. UTXO hash is computed as +`keccak256(txHash | txOutputIndex | txOutputValue)`. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `utxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | + +#### Returns + +[`Hex`](Hex.md) + +**`See`** + +#### Implementation of + +[Bridge](../interfaces/Bridge.md).[buildUtxoHash](../interfaces/Bridge.md#buildutxohash) + +#### Defined in + +[lib/ethereum/bridge.ts:614](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L614) + +___ + +### deposits + +▸ **deposits**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`DepositRequest`](../interfaces/DepositRequest.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | +| `depositOutputIndex` | `number` | + +#### Returns + +`Promise`\<[`DepositRequest`](../interfaces/DepositRequest.md)\> + +**`See`** + +#### Implementation of + +[Bridge](../interfaces/Bridge.md).[deposits](../interfaces/Bridge.md#deposits) + +#### Defined in + +[lib/ethereum/bridge.ts:425](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L425) + +___ + +### getAddress + +▸ **getAddress**(): [`EthereumAddress`](EthereumAddress.md) + +Get address of the contract instance. + +#### Returns + +[`EthereumAddress`](EthereumAddress.md) + +Address of this contract instance. + +#### Inherited from + +EthersContractHandle.getAddress + +#### Defined in + +[lib/ethereum/adapter.ts:112](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L112) + +___ + +### getChainIdentifier + +▸ **getChainIdentifier**(): [`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +#### Returns + +[`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +**`See`** + +#### Implementation of + +[Bridge](../interfaces/Bridge.md).[getChainIdentifier](../interfaces/Bridge.md#getchainidentifier) + +#### Defined in + +[lib/ethereum/bridge.ts:86](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L86) + +___ + +### getDepositRevealedEvents + +▸ **getDepositRevealedEvents**(`options?`, `...filterArgs`): `Promise`\<[`DepositRevealedEvent`](../README.md#depositrevealedevent)[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `options?` | [`Options`](../interfaces/GetChainEvents.Options.md) | +| `...filterArgs` | `unknown`[] | + +#### Returns + +`Promise`\<[`DepositRevealedEvent`](../README.md#depositrevealedevent)[]\> + +**`See`** + +#### Implementation of + +Bridge.getDepositRevealedEvents + +#### Defined in + +[lib/ethereum/bridge.ts:94](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L94) + +___ + +### getEvents + +▸ **getEvents**(`eventName`, `options?`, `...filterArgs`): `Promise`\<`Event`[]\> + +Get events emitted by the Ethereum contract. +It starts searching from provided block number. If the GetEvents.Options#fromBlock +option is missing it looks for a contract's defined property +[_deployedAtBlockNumber](EthereumBridge.md#_deployedatblocknumber). If the property is missing starts searching +from block `0`. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `eventName` | `string` | Name of the event. | +| `options?` | [`Options`](../interfaces/GetChainEvents.Options.md) | Options for events fetching. | +| `...filterArgs` | `unknown`[] | Arguments for events filtering. | + +#### Returns + +`Promise`\<`Event`[]\> + +Array of found events. + +#### Inherited from + +EthersContractHandle.getEvents + +#### Defined in + +[lib/ethereum/adapter.ts:127](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L127) + +___ + +### getNewWalletRegisteredEvents + +▸ **getNewWalletRegisteredEvents**(`options?`, `...filterArgs`): `Promise`\<[`NewWalletRegisteredEvent`](../README.md#newwalletregisteredevent)[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `options?` | [`Options`](../interfaces/GetChainEvents.Options.md) | +| `...filterArgs` | `unknown`[] | + +#### Returns + +`Promise`\<[`NewWalletRegisteredEvent`](../README.md#newwalletregisteredevent)[]\> + +**`See`** + +#### Implementation of + +Bridge.getNewWalletRegisteredEvents + +#### Defined in + +[lib/ethereum/bridge.ts:526](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L526) + +___ + +### getRedemptionRequestedEvents + +▸ **getRedemptionRequestedEvents**(`options?`, `...filterArgs`): `Promise`\<[`RedemptionRequestedEvent`](../README.md#redemptionrequestedevent)[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `options?` | [`Options`](../interfaces/GetChainEvents.Options.md) | +| `...filterArgs` | `unknown`[] | + +#### Returns + +`Promise`\<[`RedemptionRequestedEvent`](../README.md#redemptionrequestedevent)[]\> + +**`See`** + +#### Implementation of + +Bridge.getRedemptionRequestedEvents + +#### Defined in + +[lib/ethereum/bridge.ts:631](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L631) + +___ + +### getWalletCompressedPublicKey + +▸ **getWalletCompressedPublicKey**(`ecdsaWalletID`): `Promise`\<[`Hex`](Hex.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `ecdsaWalletID` | [`Hex`](Hex.md) | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +#### Defined in + +[lib/ethereum/bridge.ts:511](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L511) + +___ + +### parseDepositRequest + +▸ **parseDepositRequest**(`deposit`): [`DepositRequest`](../interfaces/DepositRequest.md) + +Parses a deposit request using data fetched from the on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `deposit` | `DepositRequestStructOutput` | Data of the deposit request. | + +#### Returns + +[`DepositRequest`](../interfaces/DepositRequest.md) + +Parsed deposit request. + +#### Defined in + +[lib/ethereum/bridge.ts:470](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L470) + +___ + +### parseRedemptionRequest + +▸ **parseRedemptionRequest**(`request`, `redeemerOutputScript`): [`RedemptionRequest`](../interfaces/RedemptionRequest.md) + +Parses a redemption request using data fetched from the on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `request` | `RedemptionRequestStructOutput` | Data of the request. | +| `redeemerOutputScript` | [`Hex`](Hex.md) | The redeemer output script that identifies the pending redemption (along with the wallet public key hash). Must not be prepended with length. | + +#### Returns + +[`RedemptionRequest`](../interfaces/RedemptionRequest.md) + +Parsed redemption request. + +#### Defined in + +[lib/ethereum/bridge.ts:212](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L212) + +___ + +### parseWalletDetails + +▸ **parseWalletDetails**(`wallet`): `Promise`\<[`Wallet`](../interfaces/Wallet.md)\> + +Parses a wallet data using data fetched from the on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `wallet` | `WalletStructOutput` | Data of the wallet. | + +#### Returns + +`Promise`\<[`Wallet`](../interfaces/Wallet.md)\> + +Parsed wallet data. + +#### Defined in + +[lib/ethereum/bridge.ts:585](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L585) + +___ + +### pendingRedemptions + +▸ **pendingRedemptions**(`walletPublicKey`, `redeemerOutputScript`): `Promise`\<[`RedemptionRequest`](../interfaces/RedemptionRequest.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `walletPublicKey` | [`Hex`](Hex.md) | +| `redeemerOutputScript` | [`Hex`](Hex.md) | + +#### Returns + +`Promise`\<[`RedemptionRequest`](../interfaces/RedemptionRequest.md)\> + +**`See`** + +#### Implementation of + +[Bridge](../interfaces/Bridge.md).[pendingRedemptions](../interfaces/Bridge.md#pendingredemptions) + +#### Defined in + +[lib/ethereum/bridge.ts:131](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L131) + +___ + +### requestRedemption + +▸ **requestRedemption**(`walletPublicKey`, `mainUtxo`, `redeemerOutputScript`, `amount`): `Promise`\<[`Hex`](Hex.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `walletPublicKey` | [`Hex`](Hex.md) | +| `mainUtxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | +| `redeemerOutputScript` | [`Hex`](Hex.md) | +| `amount` | `BigNumber` | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +**`See`** + +#### Implementation of + +[Bridge](../interfaces/Bridge.md).[requestRedemption](../interfaces/Bridge.md#requestredemption) + +#### Defined in + +[lib/ethereum/bridge.ts:332](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L332) + +___ + +### revealDeposit + +▸ **revealDeposit**(`depositTx`, `depositOutputIndex`, `deposit`, `vault?`): `Promise`\<[`Hex`](Hex.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `depositTx` | [`BitcoinRawTxVectors`](../interfaces/BitcoinRawTxVectors.md) | +| `depositOutputIndex` | `number` | +| `deposit` | [`DepositReceipt`](../interfaces/DepositReceipt.md) | +| `vault?` | [`ChainIdentifier`](../interfaces/ChainIdentifier.md) | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +**`See`** + +#### Implementation of + +[Bridge](../interfaces/Bridge.md).[revealDeposit](../interfaces/Bridge.md#revealdeposit) + +#### Defined in + +[lib/ethereum/bridge.ts:230](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L230) + +___ + +### submitDepositSweepProof + +▸ **submitDepositSweepProof**(`sweepTx`, `sweepProof`, `mainUtxo`, `vault?`): `Promise`\<[`Hex`](Hex.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `sweepTx` | [`BitcoinRawTxVectors`](../interfaces/BitcoinRawTxVectors.md) | +| `sweepProof` | [`BitcoinSpvProof`](../interfaces/BitcoinSpvProof.md) | +| `mainUtxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | +| `vault?` | [`ChainIdentifier`](../interfaces/ChainIdentifier.md) | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +**`See`** + +#### Implementation of + +[Bridge](../interfaces/Bridge.md).[submitDepositSweepProof](../interfaces/Bridge.md#submitdepositsweepproof) + +#### Defined in + +[lib/ethereum/bridge.ts:268](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L268) + +___ + +### submitRedemptionProof + +▸ **submitRedemptionProof**(`redemptionTx`, `redemptionProof`, `mainUtxo`, `walletPublicKey`): `Promise`\<[`Hex`](Hex.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `redemptionTx` | [`BitcoinRawTxVectors`](../interfaces/BitcoinRawTxVectors.md) | +| `redemptionProof` | [`BitcoinSpvProof`](../interfaces/BitcoinSpvProof.md) | +| `mainUtxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | +| `walletPublicKey` | [`Hex`](Hex.md) | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +**`See`** + +#### Implementation of + +[Bridge](../interfaces/Bridge.md).[submitRedemptionProof](../interfaces/Bridge.md#submitredemptionproof) + +#### Defined in + +[lib/ethereum/bridge.ts:376](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L376) + +___ + +### timedOutRedemptions + +▸ **timedOutRedemptions**(`walletPublicKey`, `redeemerOutputScript`): `Promise`\<[`RedemptionRequest`](../interfaces/RedemptionRequest.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `walletPublicKey` | [`Hex`](Hex.md) | +| `redeemerOutputScript` | [`Hex`](Hex.md) | + +#### Returns + +`Promise`\<[`RedemptionRequest`](../interfaces/RedemptionRequest.md)\> + +**`See`** + +#### Implementation of + +[Bridge](../interfaces/Bridge.md).[timedOutRedemptions](../interfaces/Bridge.md#timedoutredemptions) + +#### Defined in + +[lib/ethereum/bridge.ts:154](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L154) + +___ + +### txProofDifficultyFactor + +▸ **txProofDifficultyFactor**(): `Promise`\<`number`\> + +#### Returns + +`Promise`\<`number`\> + +**`See`** + +#### Implementation of + +[Bridge](../interfaces/Bridge.md).[txProofDifficultyFactor](../interfaces/Bridge.md#txproofdifficultyfactor) + +#### Defined in + +[lib/ethereum/bridge.ts:318](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L318) + +___ + +### walletRegistry + +▸ **walletRegistry**(): `Promise`\<[`WalletRegistry`](../interfaces/WalletRegistry.md)\> + +#### Returns + +`Promise`\<[`WalletRegistry`](../interfaces/WalletRegistry.md)\> + +**`See`** + +#### Implementation of + +[Bridge](../interfaces/Bridge.md).[walletRegistry](../interfaces/Bridge.md#walletregistry) + +#### Defined in + +[lib/ethereum/bridge.ts:551](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L551) + +___ + +### wallets + +▸ **wallets**(`walletPublicKeyHash`): `Promise`\<[`Wallet`](../interfaces/Wallet.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `walletPublicKeyHash` | [`Hex`](Hex.md) | + +#### Returns + +`Promise`\<[`Wallet`](../interfaces/Wallet.md)\> + +**`See`** + +#### Implementation of + +[Bridge](../interfaces/Bridge.md).[wallets](../interfaces/Bridge.md#wallets) + +#### Defined in + +[lib/ethereum/bridge.ts:568](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L568) + +___ + +### buildDepositKey + +▸ **buildDepositKey**(`depositTxHash`, `depositOutputIndex`): `string` + +Builds the deposit key required to refer a revealed deposit. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | The revealed deposit transaction's hash. | +| `depositOutputIndex` | `number` | Index of the deposit transaction output that funds the revealed deposit. | + +#### Returns + +`string` + +Deposit key. + +#### Defined in + +[lib/ethereum/bridge.ts:451](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L451) + +___ + +### buildRedemptionKey + +▸ **buildRedemptionKey**(`walletPublicKeyHash`, `redeemerOutputScript`): `string` + +Builds a redemption key required to refer a redemption request. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `walletPublicKeyHash` | [`Hex`](Hex.md) | The wallet public key hash that identifies the pending redemption (along with the redeemer output script). | +| `redeemerOutputScript` | [`Hex`](Hex.md) | The redeemer output script that identifies the pending redemption (along with the wallet public key hash). Must not be prepended with length. | + +#### Returns + +`string` + +The redemption key. + +#### Defined in + +[lib/ethereum/bridge.ts:182](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L182) diff --git a/typescript/api-reference/classes/EthereumTBTCToken.md b/typescript/api-reference/classes/EthereumTBTCToken.md new file mode 100644 index 000000000..1c5657ef8 --- /dev/null +++ b/typescript/api-reference/classes/EthereumTBTCToken.md @@ -0,0 +1,299 @@ +# Class: EthereumTBTCToken + +Implementation of the Ethereum TBTC v2 token handle. + +**`See`** + +for reference. + +## Hierarchy + +- `EthersContractHandle`\<`TBTCTypechain`\> + + ↳ **`EthereumTBTCToken`** + +## Implements + +- [`TBTCToken`](../interfaces/TBTCToken.md) + +## Table of contents + +### Constructors + +- [constructor](EthereumTBTCToken.md#constructor) + +### Properties + +- [\_deployedAtBlockNumber](EthereumTBTCToken.md#_deployedatblocknumber) +- [\_instance](EthereumTBTCToken.md#_instance) +- [\_totalRetryAttempts](EthereumTBTCToken.md#_totalretryattempts) + +### Methods + +- [buildBridgeRequestRedemptionData](EthereumTBTCToken.md#buildbridgerequestredemptiondata) +- [buildRequestRedemptionData](EthereumTBTCToken.md#buildrequestredemptiondata) +- [getAddress](EthereumTBTCToken.md#getaddress) +- [getChainIdentifier](EthereumTBTCToken.md#getchainidentifier) +- [getEvents](EthereumTBTCToken.md#getevents) +- [requestRedemption](EthereumTBTCToken.md#requestredemption) +- [totalSupply](EthereumTBTCToken.md#totalsupply) + +## Constructors + +### constructor + +• **new EthereumTBTCToken**(`config`, `deploymentType?`): [`EthereumTBTCToken`](EthereumTBTCToken.md) + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `config` | [`EthereumContractConfig`](../interfaces/EthereumContractConfig.md) | `undefined` | +| `deploymentType` | ``"local"`` \| ``"goerli"`` \| ``"mainnet"`` | `"local"` | + +#### Returns + +[`EthereumTBTCToken`](EthereumTBTCToken.md) + +#### Overrides + +EthersContractHandle\<TBTCTypechain\>.constructor + +#### Defined in + +[lib/ethereum/tbtc-token.ts:26](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-token.ts#L26) + +## Properties + +### \_deployedAtBlockNumber + +• `Protected` `Readonly` **\_deployedAtBlockNumber**: `number` + +Number of a block within which the contract was deployed. Value is read from +the contract deployment artifact. It can be overwritten by setting a +[EthersContractConfig.deployedAtBlockNumber](../interfaces/EthereumContractConfig.md#deployedatblocknumber) property. + +#### Inherited from + +EthersContractHandle.\_deployedAtBlockNumber + +#### Defined in + +[lib/ethereum/adapter.ts:80](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L80) + +___ + +### \_instance + +• `Protected` `Readonly` **\_instance**: `TBTC` + +Ethers instance of the deployed contract. + +#### Inherited from + +EthersContractHandle.\_instance + +#### Defined in + +[lib/ethereum/adapter.ts:74](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L74) + +___ + +### \_totalRetryAttempts + +• `Protected` `Readonly` **\_totalRetryAttempts**: `number` + +Number of retries for ethereum requests. + +#### Inherited from + +EthersContractHandle.\_totalRetryAttempts + +#### Defined in + +[lib/ethereum/adapter.ts:84](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L84) + +## Methods + +### buildBridgeRequestRedemptionData + +▸ **buildBridgeRequestRedemptionData**(`walletPublicKey`, `mainUtxo`, `redeemerOutputScript`): `Object` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `walletPublicKey` | [`Hex`](Hex.md) | +| `mainUtxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | +| `redeemerOutputScript` | [`Hex`](Hex.md) | + +#### Returns + +`Object` + +| Name | Type | +| :------ | :------ | +| `mainUtxo` | \{ `txHash`: `string` ; `txOutputIndex`: `number` = mainUtxo.outputIndex; `txOutputValue`: `BigNumber` = mainUtxo.value } | +| `mainUtxo.txHash` | `string` | +| `mainUtxo.txOutputIndex` | `number` | +| `mainUtxo.txOutputValue` | `BigNumber` | +| `prefixedRawRedeemerOutputScript` | `string` | +| `walletPublicKeyHash` | `string` | + +#### Defined in + +[lib/ethereum/tbtc-token.ts:135](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-token.ts#L135) + +___ + +### buildRequestRedemptionData + +▸ **buildRequestRedemptionData**(`redeemer`, `walletPublicKey`, `mainUtxo`, `redeemerOutputScript`): [`Hex`](Hex.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `redeemer` | [`EthereumAddress`](EthereumAddress.md) | +| `walletPublicKey` | [`Hex`](Hex.md) | +| `mainUtxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | +| `redeemerOutputScript` | [`Hex`](Hex.md) | + +#### Returns + +[`Hex`](Hex.md) + +#### Defined in + +[lib/ethereum/tbtc-token.ts:104](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-token.ts#L104) + +___ + +### getAddress + +▸ **getAddress**(): [`EthereumAddress`](EthereumAddress.md) + +Get address of the contract instance. + +#### Returns + +[`EthereumAddress`](EthereumAddress.md) + +Address of this contract instance. + +#### Inherited from + +EthersContractHandle.getAddress + +#### Defined in + +[lib/ethereum/adapter.ts:112](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L112) + +___ + +### getChainIdentifier + +▸ **getChainIdentifier**(): [`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +#### Returns + +[`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +**`See`** + +#### Implementation of + +[TBTCToken](../interfaces/TBTCToken.md).[getChainIdentifier](../interfaces/TBTCToken.md#getchainidentifier) + +#### Defined in + +[lib/ethereum/tbtc-token.ts:53](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-token.ts#L53) + +___ + +### getEvents + +▸ **getEvents**(`eventName`, `options?`, `...filterArgs`): `Promise`\<`Event`[]\> + +Get events emitted by the Ethereum contract. +It starts searching from provided block number. If the GetEvents.Options#fromBlock +option is missing it looks for a contract's defined property +[_deployedAtBlockNumber](EthereumBridge.md#_deployedatblocknumber). If the property is missing starts searching +from block `0`. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `eventName` | `string` | Name of the event. | +| `options?` | [`Options`](../interfaces/GetChainEvents.Options.md) | Options for events fetching. | +| `...filterArgs` | `unknown`[] | Arguments for events filtering. | + +#### Returns + +`Promise`\<`Event`[]\> + +Array of found events. + +#### Inherited from + +EthersContractHandle.getEvents + +#### Defined in + +[lib/ethereum/adapter.ts:127](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L127) + +___ + +### requestRedemption + +▸ **requestRedemption**(`walletPublicKey`, `mainUtxo`, `redeemerOutputScript`, `amount`): `Promise`\<[`Hex`](Hex.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `walletPublicKey` | [`Hex`](Hex.md) | +| `mainUtxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | +| `redeemerOutputScript` | [`Hex`](Hex.md) | +| `amount` | `BigNumber` | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +**`See`** + +#### Implementation of + +[TBTCToken](../interfaces/TBTCToken.md).[requestRedemption](../interfaces/TBTCToken.md#requestredemption) + +#### Defined in + +[lib/ethereum/tbtc-token.ts:71](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-token.ts#L71) + +___ + +### totalSupply + +▸ **totalSupply**(`blockNumber?`): `Promise`\<`BigNumber`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `blockNumber?` | `number` | + +#### Returns + +`Promise`\<`BigNumber`\> + +**`See`** + +#### Implementation of + +[TBTCToken](../interfaces/TBTCToken.md).[totalSupply](../interfaces/TBTCToken.md#totalsupply) + +#### Defined in + +[lib/ethereum/tbtc-token.ts:61](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-token.ts#L61) diff --git a/typescript/api-reference/classes/EthereumTBTCVault.md b/typescript/api-reference/classes/EthereumTBTCVault.md new file mode 100644 index 000000000..4e3bd636f --- /dev/null +++ b/typescript/api-reference/classes/EthereumTBTCVault.md @@ -0,0 +1,503 @@ +# Class: EthereumTBTCVault + +Implementation of the Ethereum TBTCVault handle. + +**`See`** + +for reference. + +## Hierarchy + +- `EthersContractHandle`\<`TBTCVaultTypechain`\> + + ↳ **`EthereumTBTCVault`** + +## Implements + +- [`TBTCVault`](../interfaces/TBTCVault.md) + +## Table of contents + +### Constructors + +- [constructor](EthereumTBTCVault.md#constructor) + +### Properties + +- [\_deployedAtBlockNumber](EthereumTBTCVault.md#_deployedatblocknumber) +- [\_instance](EthereumTBTCVault.md#_instance) +- [\_totalRetryAttempts](EthereumTBTCVault.md#_totalretryattempts) + +### Methods + +- [cancelOptimisticMint](EthereumTBTCVault.md#canceloptimisticmint) +- [finalizeOptimisticMint](EthereumTBTCVault.md#finalizeoptimisticmint) +- [getAddress](EthereumTBTCVault.md#getaddress) +- [getChainIdentifier](EthereumTBTCVault.md#getchainidentifier) +- [getEvents](EthereumTBTCVault.md#getevents) +- [getMinters](EthereumTBTCVault.md#getminters) +- [getOptimisticMintingCancelledEvents](EthereumTBTCVault.md#getoptimisticmintingcancelledevents) +- [getOptimisticMintingFinalizedEvents](EthereumTBTCVault.md#getoptimisticmintingfinalizedevents) +- [getOptimisticMintingRequestedEvents](EthereumTBTCVault.md#getoptimisticmintingrequestedevents) +- [isGuardian](EthereumTBTCVault.md#isguardian) +- [isMinter](EthereumTBTCVault.md#isminter) +- [optimisticMintingDelay](EthereumTBTCVault.md#optimisticmintingdelay) +- [optimisticMintingRequests](EthereumTBTCVault.md#optimisticmintingrequests) +- [parseOptimisticMintingRequest](EthereumTBTCVault.md#parseoptimisticmintingrequest) +- [requestOptimisticMint](EthereumTBTCVault.md#requestoptimisticmint) + +## Constructors + +### constructor + +• **new EthereumTBTCVault**(`config`, `deploymentType?`): [`EthereumTBTCVault`](EthereumTBTCVault.md) + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `config` | [`EthereumContractConfig`](../interfaces/EthereumContractConfig.md) | `undefined` | +| `deploymentType` | ``"local"`` \| ``"goerli"`` \| ``"mainnet"`` | `"local"` | + +#### Returns + +[`EthereumTBTCVault`](EthereumTBTCVault.md) + +#### Overrides + +EthersContractHandle\<TBTCVaultTypechain\>.constructor + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:40](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L40) + +## Properties + +### \_deployedAtBlockNumber + +• `Protected` `Readonly` **\_deployedAtBlockNumber**: `number` + +Number of a block within which the contract was deployed. Value is read from +the contract deployment artifact. It can be overwritten by setting a +[EthersContractConfig.deployedAtBlockNumber](../interfaces/EthereumContractConfig.md#deployedatblocknumber) property. + +#### Inherited from + +EthersContractHandle.\_deployedAtBlockNumber + +#### Defined in + +[lib/ethereum/adapter.ts:80](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L80) + +___ + +### \_instance + +• `Protected` `Readonly` **\_instance**: `TBTCVault` + +Ethers instance of the deployed contract. + +#### Inherited from + +EthersContractHandle.\_instance + +#### Defined in + +[lib/ethereum/adapter.ts:74](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L74) + +___ + +### \_totalRetryAttempts + +• `Protected` `Readonly` **\_totalRetryAttempts**: `number` + +Number of retries for ethereum requests. + +#### Inherited from + +EthersContractHandle.\_totalRetryAttempts + +#### Defined in + +[lib/ethereum/adapter.ts:84](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L84) + +## Methods + +### cancelOptimisticMint + +▸ **cancelOptimisticMint**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`Hex`](Hex.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | +| `depositOutputIndex` | `number` | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +**`See`** + +#### Implementation of + +[TBTCVault](../interfaces/TBTCVault.md).[cancelOptimisticMint](../interfaces/TBTCVault.md#canceloptimisticmint) + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:149](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L149) + +___ + +### finalizeOptimisticMint + +▸ **finalizeOptimisticMint**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`Hex`](Hex.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | +| `depositOutputIndex` | `number` | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +**`See`** + +#### Implementation of + +[TBTCVault](../interfaces/TBTCVault.md).[finalizeOptimisticMint](../interfaces/TBTCVault.md#finalizeoptimisticmint) + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:172](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L172) + +___ + +### getAddress + +▸ **getAddress**(): [`EthereumAddress`](EthereumAddress.md) + +Get address of the contract instance. + +#### Returns + +[`EthereumAddress`](EthereumAddress.md) + +Address of this contract instance. + +#### Inherited from + +EthersContractHandle.getAddress + +#### Defined in + +[lib/ethereum/adapter.ts:112](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L112) + +___ + +### getChainIdentifier + +▸ **getChainIdentifier**(): [`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +#### Returns + +[`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +**`See`** + +#### Implementation of + +[TBTCVault](../interfaces/TBTCVault.md).[getChainIdentifier](../interfaces/TBTCVault.md#getchainidentifier) + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:67](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L67) + +___ + +### getEvents + +▸ **getEvents**(`eventName`, `options?`, `...filterArgs`): `Promise`\<`Event`[]\> + +Get events emitted by the Ethereum contract. +It starts searching from provided block number. If the GetEvents.Options#fromBlock +option is missing it looks for a contract's defined property +[_deployedAtBlockNumber](EthereumBridge.md#_deployedatblocknumber). If the property is missing starts searching +from block `0`. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `eventName` | `string` | Name of the event. | +| `options?` | [`Options`](../interfaces/GetChainEvents.Options.md) | Options for events fetching. | +| `...filterArgs` | `unknown`[] | Arguments for events filtering. | + +#### Returns + +`Promise`\<`Event`[]\> + +Array of found events. + +#### Inherited from + +EthersContractHandle.getEvents + +#### Defined in + +[lib/ethereum/adapter.ts:127](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L127) + +___ + +### getMinters + +▸ **getMinters**(): `Promise`\<[`EthereumAddress`](EthereumAddress.md)[]\> + +#### Returns + +`Promise`\<[`EthereumAddress`](EthereumAddress.md)[]\> + +**`See`** + +#### Implementation of + +[TBTCVault](../interfaces/TBTCVault.md).[getMinters](../interfaces/TBTCVault.md#getminters) + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:89](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L89) + +___ + +### getOptimisticMintingCancelledEvents + +▸ **getOptimisticMintingCancelledEvents**(`options?`, `...filterArgs`): `Promise`\<[`OptimisticMintingCancelledEvent`](../README.md#optimisticmintingcancelledevent)[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `options?` | [`Options`](../interfaces/GetChainEvents.Options.md) | +| `...filterArgs` | `any`[] | + +#### Returns + +`Promise`\<[`OptimisticMintingCancelledEvent`](../README.md#optimisticmintingcancelledevent)[]\> + +**`See`** + +#### Implementation of + +TBTCVault.getOptimisticMintingCancelledEvents + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:267](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L267) + +___ + +### getOptimisticMintingFinalizedEvents + +▸ **getOptimisticMintingFinalizedEvents**(`options?`, `...filterArgs`): `Promise`\<[`OptimisticMintingFinalizedEvent`](../README.md#optimisticmintingfinalizedevent)[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `options?` | [`Options`](../interfaces/GetChainEvents.Options.md) | +| `...filterArgs` | `any`[] | + +#### Returns + +`Promise`\<[`OptimisticMintingFinalizedEvent`](../README.md#optimisticmintingfinalizedevent)[]\> + +**`See`** + +#### Implementation of + +TBTCVault.getOptimisticMintingFinalizedEvents + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:294](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L294) + +___ + +### getOptimisticMintingRequestedEvents + +▸ **getOptimisticMintingRequestedEvents**(`options?`, `...filterArgs`): `Promise`\<[`OptimisticMintingRequestedEvent`](../README.md#optimisticmintingrequestedevent)[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `options?` | [`Options`](../interfaces/GetChainEvents.Options.md) | +| `...filterArgs` | `any`[] | + +#### Returns + +`Promise`\<[`OptimisticMintingRequestedEvent`](../README.md#optimisticmintingrequestedevent)[]\> + +**`See`** + +#### Implementation of + +TBTCVault.getOptimisticMintingRequestedEvents + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:234](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L234) + +___ + +### isGuardian + +▸ **isGuardian**(`address`): `Promise`\<`boolean`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `address` | [`EthereumAddress`](EthereumAddress.md) | + +#### Returns + +`Promise`\<`boolean`\> + +**`See`** + +#### Implementation of + +[TBTCVault](../interfaces/TBTCVault.md).[isGuardian](../interfaces/TBTCVault.md#isguardian) + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:113](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L113) + +___ + +### isMinter + +▸ **isMinter**(`address`): `Promise`\<`boolean`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `address` | [`EthereumAddress`](EthereumAddress.md) | + +#### Returns + +`Promise`\<`boolean`\> + +**`See`** + +#### Implementation of + +[TBTCVault](../interfaces/TBTCVault.md).[isMinter](../interfaces/TBTCVault.md#isminter) + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:103](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L103) + +___ + +### optimisticMintingDelay + +▸ **optimisticMintingDelay**(): `Promise`\<`number`\> + +#### Returns + +`Promise`\<`number`\> + +**`See`** + +#### Implementation of + +[TBTCVault](../interfaces/TBTCVault.md).[optimisticMintingDelay](../interfaces/TBTCVault.md#optimisticmintingdelay) + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:75](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L75) + +___ + +### optimisticMintingRequests + +▸ **optimisticMintingRequests**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`OptimisticMintingRequest`](../README.md#optimisticmintingrequest)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | +| `depositOutputIndex` | `number` | + +#### Returns + +`Promise`\<[`OptimisticMintingRequest`](../README.md#optimisticmintingrequest)\> + +**`See`** + +#### Implementation of + +[TBTCVault](../interfaces/TBTCVault.md).[optimisticMintingRequests](../interfaces/TBTCVault.md#optimisticmintingrequests) + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:198](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L198) + +___ + +### parseOptimisticMintingRequest + +▸ **parseOptimisticMintingRequest**(`request`): [`OptimisticMintingRequest`](../README.md#optimisticmintingrequest) + +Parses a optimistic minting request using data fetched from the on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `request` | `ContractOptimisticMintingRequest` | Data of the optimistic minting request. | + +#### Returns + +[`OptimisticMintingRequest`](../README.md#optimisticmintingrequest) + +Parsed optimistic minting request. + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:221](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L221) + +___ + +### requestOptimisticMint + +▸ **requestOptimisticMint**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`Hex`](Hex.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | +| `depositOutputIndex` | `number` | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +**`See`** + +#### Implementation of + +[TBTCVault](../interfaces/TBTCVault.md).[requestOptimisticMint](../interfaces/TBTCVault.md#requestoptimisticmint) + +#### Defined in + +[lib/ethereum/tbtc-vault.ts:123](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/tbtc-vault.ts#L123) diff --git a/typescript/api-reference/classes/EthereumWalletRegistry.md b/typescript/api-reference/classes/EthereumWalletRegistry.md new file mode 100644 index 000000000..7cab2bd60 --- /dev/null +++ b/typescript/api-reference/classes/EthereumWalletRegistry.md @@ -0,0 +1,297 @@ +# Class: EthereumWalletRegistry + +Implementation of the Ethereum WalletRegistry handle. + +**`See`** + +for reference. + +## Hierarchy + +- `EthersContractHandle`\<`WalletRegistryTypechain`\> + + ↳ **`EthereumWalletRegistry`** + +## Implements + +- [`WalletRegistry`](../interfaces/WalletRegistry.md) + +## Table of contents + +### Constructors + +- [constructor](EthereumWalletRegistry.md#constructor) + +### Properties + +- [\_deployedAtBlockNumber](EthereumWalletRegistry.md#_deployedatblocknumber) +- [\_instance](EthereumWalletRegistry.md#_instance) +- [\_totalRetryAttempts](EthereumWalletRegistry.md#_totalretryattempts) + +### Methods + +- [getAddress](EthereumWalletRegistry.md#getaddress) +- [getChainIdentifier](EthereumWalletRegistry.md#getchainidentifier) +- [getDkgResultApprovedEvents](EthereumWalletRegistry.md#getdkgresultapprovedevents) +- [getDkgResultChallengedEvents](EthereumWalletRegistry.md#getdkgresultchallengedevents) +- [getDkgResultSubmittedEvents](EthereumWalletRegistry.md#getdkgresultsubmittedevents) +- [getEvents](EthereumWalletRegistry.md#getevents) +- [getWalletPublicKey](EthereumWalletRegistry.md#getwalletpublickey) + +## Constructors + +### constructor + +• **new EthereumWalletRegistry**(`config`, `deploymentType?`): [`EthereumWalletRegistry`](EthereumWalletRegistry.md) + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `config` | [`EthereumContractConfig`](../interfaces/EthereumContractConfig.md) | `undefined` | +| `deploymentType` | ``"local"`` \| ``"goerli"`` \| ``"mainnet"`` | `"local"` | + +#### Returns + +[`EthereumWalletRegistry`](EthereumWalletRegistry.md) + +#### Overrides + +EthersContractHandle\<WalletRegistryTypechain\>.constructor + +#### Defined in + +[lib/ethereum/wallet-registry.ts:32](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/wallet-registry.ts#L32) + +## Properties + +### \_deployedAtBlockNumber + +• `Protected` `Readonly` **\_deployedAtBlockNumber**: `number` + +Number of a block within which the contract was deployed. Value is read from +the contract deployment artifact. It can be overwritten by setting a +[EthersContractConfig.deployedAtBlockNumber](../interfaces/EthereumContractConfig.md#deployedatblocknumber) property. + +#### Inherited from + +EthersContractHandle.\_deployedAtBlockNumber + +#### Defined in + +[lib/ethereum/adapter.ts:80](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L80) + +___ + +### \_instance + +• `Protected` `Readonly` **\_instance**: `WalletRegistry` + +Ethers instance of the deployed contract. + +#### Inherited from + +EthersContractHandle.\_instance + +#### Defined in + +[lib/ethereum/adapter.ts:74](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L74) + +___ + +### \_totalRetryAttempts + +• `Protected` `Readonly` **\_totalRetryAttempts**: `number` + +Number of retries for ethereum requests. + +#### Inherited from + +EthersContractHandle.\_totalRetryAttempts + +#### Defined in + +[lib/ethereum/adapter.ts:84](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L84) + +## Methods + +### getAddress + +▸ **getAddress**(): [`EthereumAddress`](EthereumAddress.md) + +Get address of the contract instance. + +#### Returns + +[`EthereumAddress`](EthereumAddress.md) + +Address of this contract instance. + +#### Inherited from + +EthersContractHandle.getAddress + +#### Defined in + +[lib/ethereum/adapter.ts:112](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L112) + +___ + +### getChainIdentifier + +▸ **getChainIdentifier**(): [`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +#### Returns + +[`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +**`See`** + +#### Implementation of + +[WalletRegistry](../interfaces/WalletRegistry.md).[getChainIdentifier](../interfaces/WalletRegistry.md#getchainidentifier) + +#### Defined in + +[lib/ethereum/wallet-registry.ts:59](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/wallet-registry.ts#L59) + +___ + +### getDkgResultApprovedEvents + +▸ **getDkgResultApprovedEvents**(`options?`, `...filterArgs`): `Promise`\<[`DkgResultApprovedEvent`](../README.md#dkgresultapprovedevent)[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `options?` | [`Options`](../interfaces/GetChainEvents.Options.md) | +| `...filterArgs` | `unknown`[] | + +#### Returns + +`Promise`\<[`DkgResultApprovedEvent`](../README.md#dkgresultapprovedevent)[]\> + +**`See`** + +#### Implementation of + +WalletRegistry.getDkgResultApprovedEvents + +#### Defined in + +[lib/ethereum/wallet-registry.ts:125](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/wallet-registry.ts#L125) + +___ + +### getDkgResultChallengedEvents + +▸ **getDkgResultChallengedEvents**(`options?`, `...filterArgs`): `Promise`\<[`DkgResultChallengedEvent`](../README.md#dkgresultchallengedevent)[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `options?` | [`Options`](../interfaces/GetChainEvents.Options.md) | +| `...filterArgs` | `unknown`[] | + +#### Returns + +`Promise`\<[`DkgResultChallengedEvent`](../README.md#dkgresultchallengedevent)[]\> + +**`See`** + +#### Implementation of + +WalletRegistry.getDkgResultChallengedEvents + +#### Defined in + +[lib/ethereum/wallet-registry.ts:150](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/wallet-registry.ts#L150) + +___ + +### getDkgResultSubmittedEvents + +▸ **getDkgResultSubmittedEvents**(`options?`, `...filterArgs`): `Promise`\<[`DkgResultSubmittedEvent`](../README.md#dkgresultsubmittedevent)[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `options?` | [`Options`](../interfaces/GetChainEvents.Options.md) | +| `...filterArgs` | `unknown`[] | + +#### Returns + +`Promise`\<[`DkgResultSubmittedEvent`](../README.md#dkgresultsubmittedevent)[]\> + +**`See`** + +#### Implementation of + +WalletRegistry.getDkgResultSubmittedEvents + +#### Defined in + +[lib/ethereum/wallet-registry.ts:82](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/wallet-registry.ts#L82) + +___ + +### getEvents + +▸ **getEvents**(`eventName`, `options?`, `...filterArgs`): `Promise`\<`Event`[]\> + +Get events emitted by the Ethereum contract. +It starts searching from provided block number. If the GetEvents.Options#fromBlock +option is missing it looks for a contract's defined property +[_deployedAtBlockNumber](EthereumBridge.md#_deployedatblocknumber). If the property is missing starts searching +from block `0`. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `eventName` | `string` | Name of the event. | +| `options?` | [`Options`](../interfaces/GetChainEvents.Options.md) | Options for events fetching. | +| `...filterArgs` | `unknown`[] | Arguments for events filtering. | + +#### Returns + +`Promise`\<`Event`[]\> + +Array of found events. + +#### Inherited from + +EthersContractHandle.getEvents + +#### Defined in + +[lib/ethereum/adapter.ts:127](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L127) + +___ + +### getWalletPublicKey + +▸ **getWalletPublicKey**(`walletID`): `Promise`\<[`Hex`](Hex.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `walletID` | [`Hex`](Hex.md) | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +**`See`** + +#### Implementation of + +[WalletRegistry](../interfaces/WalletRegistry.md).[getWalletPublicKey](../interfaces/WalletRegistry.md#getwalletpublickey) + +#### Defined in + +[lib/ethereum/wallet-registry.ts:67](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/wallet-registry.ts#L67) diff --git a/typescript/api-reference/classes/Hex.md b/typescript/api-reference/classes/Hex.md new file mode 100644 index 000000000..9975b5248 --- /dev/null +++ b/typescript/api-reference/classes/Hex.md @@ -0,0 +1,166 @@ +# Class: Hex + +Represents a hexadecimal value. + +## Hierarchy + +- **`Hex`** + + ↳ [`BitcoinTxHash`](BitcoinTxHash.md) + +## Table of contents + +### Constructors + +- [constructor](Hex.md#constructor) + +### Properties + +- [\_hex](Hex.md#_hex) + +### Methods + +- [equals](Hex.md#equals) +- [reverse](Hex.md#reverse) +- [toBuffer](Hex.md#tobuffer) +- [toPrefixedString](Hex.md#toprefixedstring) +- [toString](Hex.md#tostring) +- [from](Hex.md#from) + +## Constructors + +### constructor + +• **new Hex**(`value`): [`Hex`](Hex.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `value` | `string` \| `Buffer` | + +#### Returns + +[`Hex`](Hex.md) + +#### Defined in + +[lib/utils/hex.ts:7](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L7) + +## Properties + +### \_hex + +• `Protected` `Readonly` **\_hex**: `Buffer` + +#### Defined in + +[lib/utils/hex.ts:5](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L5) + +## Methods + +### equals + +▸ **equals**(`otherValue`): `boolean` + +Checks if other value equals the current value. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `otherValue` | [`Hex`](Hex.md) | Other value that will be compared to this value. | + +#### Returns + +`boolean` + +True if both values are equal, false otherwise. + +#### Defined in + +[lib/utils/hex.ts:57](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L57) + +___ + +### reverse + +▸ **reverse**(): [`Hex`](Hex.md) + +#### Returns + +[`Hex`](Hex.md) + +Reversed hexadecimal value. + +#### Defined in + +[lib/utils/hex.ts:64](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L64) + +___ + +### toBuffer + +▸ **toBuffer**(): `Buffer` + +#### Returns + +`Buffer` + +Hexadecimal value as a Buffer. + +#### Defined in + +[lib/utils/hex.ts:32](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L32) + +___ + +### toPrefixedString + +▸ **toPrefixedString**(): `string` + +#### Returns + +`string` + +Hexadecimal string prefixed with '0x'. + +#### Defined in + +[lib/utils/hex.ts:46](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L46) + +___ + +### toString + +▸ **toString**(): `string` + +#### Returns + +`string` + +Unprefixed hexadecimal string. + +#### Defined in + +[lib/utils/hex.ts:39](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L39) + +___ + +### from + +▸ **from**(`value`): [`Hex`](Hex.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `value` | `string` \| `Buffer` | + +#### Returns + +[`Hex`](Hex.md) + +#### Defined in + +[lib/utils/hex.ts:25](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/utils/hex.ts#L25) diff --git a/typescript/api-reference/classes/MaintenanceService.md b/typescript/api-reference/classes/MaintenanceService.md new file mode 100644 index 000000000..22efdffb5 --- /dev/null +++ b/typescript/api-reference/classes/MaintenanceService.md @@ -0,0 +1,60 @@ +# Class: MaintenanceService + +Service exposing features relevant to authorized maintainers and +operators of the tBTC v2 system. + +## Table of contents + +### Constructors + +- [constructor](MaintenanceService.md#constructor) + +### Properties + +- [optimisticMinting](MaintenanceService.md#optimisticminting) +- [spv](MaintenanceService.md#spv) + +## Constructors + +### constructor + +• **new MaintenanceService**(`tbtcContracts`, `bitcoinClient`): [`MaintenanceService`](MaintenanceService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `tbtcContracts` | [`TBTCContracts`](../README.md#tbtccontracts) | +| `bitcoinClient` | [`BitcoinClient`](../interfaces/BitcoinClient.md) | + +#### Returns + +[`MaintenanceService`](MaintenanceService.md) + +#### Defined in + +[services/maintenance/maintenance-service.ts:20](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/maintenance-service.ts#L20) + +## Properties + +### optimisticMinting + +• `Readonly` **optimisticMinting**: [`OptimisticMinting`](OptimisticMinting.md) + +Features for optimistic minting maintainers. + +#### Defined in + +[services/maintenance/maintenance-service.ts:14](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/maintenance-service.ts#L14) + +___ + +### spv + +• `Readonly` **spv**: [`Spv`](Spv.md) + +Features for SPV proof maintainers. + +#### Defined in + +[services/maintenance/maintenance-service.ts:18](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/maintenance-service.ts#L18) diff --git a/typescript/api-reference/classes/OptimisticMinting.md b/typescript/api-reference/classes/OptimisticMinting.md new file mode 100644 index 000000000..4c5fe6b04 --- /dev/null +++ b/typescript/api-reference/classes/OptimisticMinting.md @@ -0,0 +1,148 @@ +# Class: OptimisticMinting + +## Table of contents + +### Constructors + +- [constructor](OptimisticMinting.md#constructor) + +### Properties + +- [tbtcContracts](OptimisticMinting.md#tbtccontracts) + +### Methods + +- [cancelMint](OptimisticMinting.md#cancelmint) +- [finalizeMint](OptimisticMinting.md#finalizemint) +- [getMintingRequest](OptimisticMinting.md#getmintingrequest) +- [requestMint](OptimisticMinting.md#requestmint) + +## Constructors + +### constructor + +• **new OptimisticMinting**(`tbtcContracts`): [`OptimisticMinting`](OptimisticMinting.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `tbtcContracts` | [`TBTCContracts`](../README.md#tbtccontracts) | + +#### Returns + +[`OptimisticMinting`](OptimisticMinting.md) + +#### Defined in + +[services/maintenance/optimistic-minting.ts:9](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/optimistic-minting.ts#L9) + +## Properties + +### tbtcContracts + +• `Private` `Readonly` **tbtcContracts**: [`TBTCContracts`](../README.md#tbtccontracts) + +#### Defined in + +[services/maintenance/optimistic-minting.ts:7](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/optimistic-minting.ts#L7) + +## Methods + +### cancelMint + +▸ **cancelMint**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`Hex`](Hex.md)\> + +Cancels optimistic minting for a deposit on chain. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | The revealed deposit transaction's hash. | +| `depositOutputIndex` | `number` | Index of the deposit transaction output that funds the revealed deposit. | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +Transaction hash of the optimistic mint cancel transaction. + +#### Defined in + +[services/maintenance/optimistic-minting.ts:37](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/optimistic-minting.ts#L37) + +___ + +### finalizeMint + +▸ **finalizeMint**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`Hex`](Hex.md)\> + +Finalizes optimistic minting for a deposit on chain. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | The revealed deposit transaction's hash. | +| `depositOutputIndex` | `number` | Index of the deposit transaction output that funds the revealed deposit. | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +Transaction hash of the optimistic mint finalize transaction. + +#### Defined in + +[services/maintenance/optimistic-minting.ts:54](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/optimistic-minting.ts#L54) + +___ + +### getMintingRequest + +▸ **getMintingRequest**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`OptimisticMintingRequest`](../README.md#optimisticmintingrequest)\> + +Gets optimistic minting request for a deposit from chain. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | The revealed deposit transaction's hash. | +| `depositOutputIndex` | `number` | Index of the deposit transaction output that funds the revealed deposit. | + +#### Returns + +`Promise`\<[`OptimisticMintingRequest`](../README.md#optimisticmintingrequest)\> + +Optimistic minting request. + +#### Defined in + +[services/maintenance/optimistic-minting.ts:71](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/optimistic-minting.ts#L71) + +___ + +### requestMint + +▸ **requestMint**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`Hex`](Hex.md)\> + +Requests optimistic minting for a deposit on chain. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | The revealed deposit transaction's hash. | +| `depositOutputIndex` | `number` | Index of the deposit transaction output that funds the revealed deposit. | + +#### Returns + +`Promise`\<[`Hex`](Hex.md)\> + +Transaction hash of the optimistic mint request transaction. + +#### Defined in + +[services/maintenance/optimistic-minting.ts:20](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/optimistic-minting.ts#L20) diff --git a/typescript/api-reference/classes/RedemptionsService.md b/typescript/api-reference/classes/RedemptionsService.md new file mode 100644 index 000000000..f92529d8a --- /dev/null +++ b/typescript/api-reference/classes/RedemptionsService.md @@ -0,0 +1,184 @@ +# Class: RedemptionsService + +Service exposing features related to tBTC v2 redemptions. + +## Table of contents + +### Constructors + +- [constructor](RedemptionsService.md#constructor) + +### Properties + +- [bitcoinClient](RedemptionsService.md#bitcoinclient) +- [tbtcContracts](RedemptionsService.md#tbtccontracts) + +### Methods + +- [determineWalletMainUtxo](RedemptionsService.md#determinewalletmainutxo) +- [findWalletForRedemption](RedemptionsService.md#findwalletforredemption) +- [getRedemptionRequests](RedemptionsService.md#getredemptionrequests) +- [requestRedemption](RedemptionsService.md#requestredemption) + +## Constructors + +### constructor + +• **new RedemptionsService**(`tbtcContracts`, `bitcoinClient`): [`RedemptionsService`](RedemptionsService.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `tbtcContracts` | [`TBTCContracts`](../README.md#tbtccontracts) | +| `bitcoinClient` | [`BitcoinClient`](../interfaces/BitcoinClient.md) | + +#### Returns + +[`RedemptionsService`](RedemptionsService.md) + +#### Defined in + +[services/redemptions/redemptions-service.ts:30](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/redemptions/redemptions-service.ts#L30) + +## Properties + +### bitcoinClient + +• `Private` `Readonly` **bitcoinClient**: [`BitcoinClient`](../interfaces/BitcoinClient.md) + +Bitcoin client handle. + +#### Defined in + +[services/redemptions/redemptions-service.ts:28](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/redemptions/redemptions-service.ts#L28) + +___ + +### tbtcContracts + +• `Private` `Readonly` **tbtcContracts**: [`TBTCContracts`](../README.md#tbtccontracts) + +Handle to tBTC contracts. + +#### Defined in + +[services/redemptions/redemptions-service.ts:24](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/redemptions/redemptions-service.ts#L24) + +## Methods + +### determineWalletMainUtxo + +▸ **determineWalletMainUtxo**(`walletPublicKeyHash`, `bitcoinNetwork`): `Promise`\<`undefined` \| [`BitcoinUtxo`](../README.md#bitcoinutxo)\> + +Determines the plain-text wallet main UTXO currently registered in the +Bridge on-chain contract. The returned main UTXO can be undefined if the +wallet does not have a main UTXO registered in the Bridge at the moment. + +WARNING: THIS FUNCTION CANNOT DETERMINE THE MAIN UTXO IF IT COMES FROM A +BITCOIN TRANSACTION THAT IS NOT ONE OF THE LATEST FIVE TRANSACTIONS +TARGETING THE GIVEN WALLET PUBLIC KEY HASH. HOWEVER, SUCH A CASE IS +VERY UNLIKELY. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `walletPublicKeyHash` | [`Hex`](Hex.md) | Public key hash of the wallet. | +| `bitcoinNetwork` | [`BitcoinNetwork`](../enums/BitcoinNetwork-1.md) | Bitcoin network. | + +#### Returns + +`Promise`\<`undefined` \| [`BitcoinUtxo`](../README.md#bitcoinutxo)\> + +Promise holding the wallet main UTXO or undefined value. + +#### Defined in + +[services/redemptions/redemptions-service.ts:221](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/redemptions/redemptions-service.ts#L221) + +___ + +### findWalletForRedemption + +▸ **findWalletForRedemption**(`redeemerOutputScript`, `amount`): `Promise`\<\{ `mainUtxo`: [`BitcoinUtxo`](../README.md#bitcoinutxo) ; `walletPublicKey`: [`Hex`](Hex.md) }\> + +Finds the oldest live wallet that has enough BTC to handle a redemption +request. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `redeemerOutputScript` | [`Hex`](Hex.md) | The redeemer output script the redeemed funds are supposed to be locked on. Must not be prepended with length. | +| `amount` | `BigNumber` | The amount to be redeemed in satoshis. | + +#### Returns + +`Promise`\<\{ `mainUtxo`: [`BitcoinUtxo`](../README.md#bitcoinutxo) ; `walletPublicKey`: [`Hex`](Hex.md) }\> + +Promise with the wallet details needed to request a redemption. + +#### Defined in + +[services/redemptions/redemptions-service.ts:96](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/redemptions/redemptions-service.ts#L96) + +___ + +### getRedemptionRequests + +▸ **getRedemptionRequests**(`bitcoinRedeemerAddress`, `walletPublicKey`, `type?`): `Promise`\<[`RedemptionRequest`](../interfaces/RedemptionRequest.md)\> + +Gets data of a registered redemption request from the Bridge contract. + +#### Parameters + +| Name | Type | Default value | Description | +| :------ | :------ | :------ | :------ | +| `bitcoinRedeemerAddress` | `string` | `undefined` | Bitcoin redeemer address used to request the redemption. | +| `walletPublicKey` | [`Hex`](Hex.md) | `undefined` | Bitcoin public key of the wallet handling the redemption. Must be in the compressed form (33 bytes long with 02 or 03 prefix). | +| `type` | ``"pending"`` \| ``"timedOut"`` | `"pending"` | Type of redemption requests the function will look for. Can be either `pending` or `timedOut`. By default, `pending` is used. | + +#### Returns + +`Promise`\<[`RedemptionRequest`](../interfaces/RedemptionRequest.md)\> + +Matching redemption requests. + +**`Throws`** + +Throws an error if no redemption request exists for the given + input parameters. + +#### Defined in + +[services/redemptions/redemptions-service.ts:337](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/redemptions/redemptions-service.ts#L337) + +___ + +### requestRedemption + +▸ **requestRedemption**(`bitcoinRedeemerAddress`, `amount`): `Promise`\<\{ `targetChainTxHash`: [`Hex`](Hex.md) ; `walletPublicKey`: [`Hex`](Hex.md) }\> + +Requests a redemption of TBTC v2 token into BTC. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `bitcoinRedeemerAddress` | `string` | Bitcoin address redeemed BTC should be sent to. Only P2PKH, P2WPKH, P2SH, and P2WSH address types are supported. | +| `amount` | `BigNumber` | The amount to be redeemed with the precision of the tBTC on-chain token contract. | + +#### Returns + +`Promise`\<\{ `targetChainTxHash`: [`Hex`](Hex.md) ; `walletPublicKey`: [`Hex`](Hex.md) }\> + +Object containing: + - Target chain hash of the request redemption transaction + (for example, Ethereum transaction hash) + - Bitcoin public key of the wallet asked to handle the redemption. + Presented in the compressed form (33 bytes long with 02 or 03 prefix). + +#### Defined in + +[services/redemptions/redemptions-service.ts:48](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/redemptions/redemptions-service.ts#L48) diff --git a/typescript/api-reference/classes/Spv.md b/typescript/api-reference/classes/Spv.md new file mode 100644 index 000000000..2fdf8ae10 --- /dev/null +++ b/typescript/api-reference/classes/Spv.md @@ -0,0 +1,116 @@ +# Class: Spv + +## Table of contents + +### Constructors + +- [constructor](Spv.md#constructor) + +### Properties + +- [bitcoinClient](Spv.md#bitcoinclient) +- [tbtcContracts](Spv.md#tbtccontracts) + +### Methods + +- [submitDepositSweepProof](Spv.md#submitdepositsweepproof) +- [submitRedemptionProof](Spv.md#submitredemptionproof) + +## Constructors + +### constructor + +• **new Spv**(`tbtcContracts`, `bitcoinClient`): [`Spv`](Spv.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `tbtcContracts` | [`TBTCContracts`](../README.md#tbtccontracts) | +| `bitcoinClient` | [`BitcoinClient`](../interfaces/BitcoinClient.md) | + +#### Returns + +[`Spv`](Spv.md) + +#### Defined in + +[services/maintenance/spv.ts:21](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/spv.ts#L21) + +## Properties + +### bitcoinClient + +• `Private` `Readonly` **bitcoinClient**: [`BitcoinClient`](../interfaces/BitcoinClient.md) + +Bitcoin client handle. + +#### Defined in + +[services/maintenance/spv.ts:19](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/spv.ts#L19) + +___ + +### tbtcContracts + +• `Private` `Readonly` **tbtcContracts**: [`TBTCContracts`](../README.md#tbtccontracts) + +Handle to tBTC contracts. + +#### Defined in + +[services/maintenance/spv.ts:15](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/spv.ts#L15) + +## Methods + +### submitDepositSweepProof + +▸ **submitDepositSweepProof**(`transactionHash`, `mainUtxo`, `vault?`): `Promise`\<`void`\> + +Prepares the proof of a deposit sweep transaction and submits it to the +Bridge on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transactionHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | Hash of the transaction being proven. | +| `mainUtxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | Recent main UTXO of the wallet as currently known on-chain. | +| `vault?` | [`ChainIdentifier`](../interfaces/ChainIdentifier.md) | (Optional) The vault pointed by swept deposits. | + +#### Returns + +`Promise`\<`void`\> + +Empty promise. + +#### Defined in + +[services/maintenance/spv.ts:34](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/spv.ts#L34) + +___ + +### submitRedemptionProof + +▸ **submitRedemptionProof**(`transactionHash`, `mainUtxo`, `walletPublicKey`): `Promise`\<`void`\> + +Prepares the proof of a redemption transaction and submits it to the +Bridge on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transactionHash` | [`BitcoinTxHash`](BitcoinTxHash.md) | Hash of the transaction being proven. | +| `mainUtxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | Recent main UTXO of the wallet as currently known on-chain. | +| `walletPublicKey` | [`Hex`](Hex.md) | Bitcoin public key of the wallet. Must be in the compressed form (33 bytes long with 02 or 03 prefix). | + +#### Returns + +`Promise`\<`void`\> + +Empty promise. + +#### Defined in + +[services/maintenance/spv.ts:67](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/spv.ts#L67) diff --git a/typescript/api-reference/classes/TBTC.md b/typescript/api-reference/classes/TBTC.md new file mode 100644 index 000000000..3317f5fde --- /dev/null +++ b/typescript/api-reference/classes/TBTC.md @@ -0,0 +1,233 @@ +# Class: TBTC + +Entrypoint component of the tBTC v2 SDK. + +## Table of contents + +### Constructors + +- [constructor](TBTC.md#constructor) + +### Properties + +- [bitcoinClient](TBTC.md#bitcoinclient) +- [deposits](TBTC.md#deposits) +- [maintenance](TBTC.md#maintenance) +- [redemptions](TBTC.md#redemptions) +- [tbtcContracts](TBTC.md#tbtccontracts) + +### Methods + +- [initializeCustom](TBTC.md#initializecustom) +- [initializeEthereum](TBTC.md#initializeethereum) +- [initializeGoerli](TBTC.md#initializegoerli) +- [initializeMainnet](TBTC.md#initializemainnet) + +## Constructors + +### constructor + +• **new TBTC**(`tbtcContracts`, `bitcoinClient`): [`TBTC`](TBTC.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `tbtcContracts` | [`TBTCContracts`](../README.md#tbtccontracts) | +| `bitcoinClient` | [`BitcoinClient`](../interfaces/BitcoinClient.md) | + +#### Returns + +[`TBTC`](TBTC.md) + +#### Defined in + +[services/tbtc.ts:40](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/tbtc.ts#L40) + +## Properties + +### bitcoinClient + +• `Readonly` **bitcoinClient**: [`BitcoinClient`](../interfaces/BitcoinClient.md) + +Bitcoin client handle for low-level access. + +#### Defined in + +[services/tbtc.ts:38](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/tbtc.ts#L38) + +___ + +### deposits + +• `Readonly` **deposits**: [`DepositsService`](DepositsService.md) + +Service supporting the tBTC v2 deposit flow. + +#### Defined in + +[services/tbtc.ts:21](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/tbtc.ts#L21) + +___ + +### maintenance + +• `Readonly` **maintenance**: [`MaintenanceService`](MaintenanceService.md) + +Service supporting authorized operations of tBTC v2 system maintainers +and operators. + +#### Defined in + +[services/tbtc.ts:26](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/tbtc.ts#L26) + +___ + +### redemptions + +• `Readonly` **redemptions**: [`RedemptionsService`](RedemptionsService.md) + +Service supporting the tBTC v2 redemption flow. + +#### Defined in + +[services/tbtc.ts:30](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/tbtc.ts#L30) + +___ + +### tbtcContracts + +• `Readonly` **tbtcContracts**: [`TBTCContracts`](../README.md#tbtccontracts) + +Handle to tBTC contracts for low-level access. + +#### Defined in + +[services/tbtc.ts:34](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/tbtc.ts#L34) + +## Methods + +### initializeCustom + +▸ **initializeCustom**(`tbtcContracts`, `bitcoinClient`): `Promise`\<[`TBTC`](TBTC.md)\> + +Initializes the tBTC v2 SDK entrypoint with custom tBTC contracts and +Bitcoin client. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `tbtcContracts` | [`TBTCContracts`](../README.md#tbtccontracts) | Custom tBTC contracts handle. | +| `bitcoinClient` | [`BitcoinClient`](../interfaces/BitcoinClient.md) | Custom Bitcoin client implementation. | + +#### Returns + +`Promise`\<[`TBTC`](TBTC.md)\> + +Initialized tBTC v2 SDK entrypoint. + +**`Dev`** + +This function is especially useful for local development as it gives + flexibility to combine different implementations of tBTC v2 contracts + with different Bitcoin networks. + +#### Defined in + +[services/tbtc.ts:117](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/tbtc.ts#L117) + +___ + +### initializeEthereum + +▸ **initializeEthereum**(`signer`, `ethereumNetwork`, `bitcoinNetwork`): `Promise`\<[`TBTC`](TBTC.md)\> + +Initializes the tBTC v2 SDK entrypoint for the given Ethereum network and Bitcoin network. +The initialized instance uses default Electrum servers to interact +with Bitcoin network. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `signer` | [`EthereumSigner`](../README.md#ethereumsigner) | Ethereum signer. | +| `ethereumNetwork` | [`EthereumNetwork`](../README.md#ethereumnetwork) | Ethereum network. | +| `bitcoinNetwork` | [`BitcoinNetwork`](../enums/BitcoinNetwork-1.md) | Bitcoin network. | + +#### Returns + +`Promise`\<[`TBTC`](TBTC.md)\> + +Initialized tBTC v2 SDK entrypoint. + +**`Throws`** + +Throws an error if the underlying signer's Ethereum network is + other than the given Ethereum network. + +#### Defined in + +[services/tbtc.ts:88](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/tbtc.ts#L88) + +___ + +### initializeGoerli + +▸ **initializeGoerli**(`signer`): `Promise`\<[`TBTC`](TBTC.md)\> + +Initializes the tBTC v2 SDK entrypoint for Ethereum goerli and Bitcoin testnet. +The initialized instance uses default Electrum servers to interact +with Bitcoin testnet + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `signer` | [`EthereumSigner`](../README.md#ethereumsigner) | Ethereum signer. | + +#### Returns + +`Promise`\<[`TBTC`](TBTC.md)\> + +Initialized tBTC v2 SDK entrypoint. + +**`Throws`** + +Throws an error if the signer's Ethereum network is other than + Ethereum mainnet. + +#### Defined in + +[services/tbtc.ts:73](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/tbtc.ts#L73) + +___ + +### initializeMainnet + +▸ **initializeMainnet**(`signer`): `Promise`\<[`TBTC`](TBTC.md)\> + +Initializes the tBTC v2 SDK entrypoint for Ethereum and Bitcoin mainnets. +The initialized instance uses default Electrum servers to interact +with Bitcoin mainnet + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `signer` | [`EthereumSigner`](../README.md#ethereumsigner) | Ethereum signer. | + +#### Returns + +`Promise`\<[`TBTC`](TBTC.md)\> + +Initialized tBTC v2 SDK entrypoint. + +**`Throws`** + +Throws an error if the signer's Ethereum network is other than + Ethereum mainnet. + +#### Defined in + +[services/tbtc.ts:60](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/tbtc.ts#L60) diff --git a/typescript/api-reference/classes/WalletTx.md b/typescript/api-reference/classes/WalletTx.md new file mode 100644 index 000000000..f3371bf4f --- /dev/null +++ b/typescript/api-reference/classes/WalletTx.md @@ -0,0 +1,63 @@ +# Class: WalletTx + +Wallet transactions builder. This feature set is supposed to be used only +for internal purposes like system tests. In real world, tBTC v2 wallets +are formed by peer-to-peer network participants that sign transactions +using threshold signature schemes. + + THIS IS EXPERIMENTAL CODE THAT CAN BE CHANGED OR REMOVED + IN FUTURE RELEASES. IT SHOULD BE USED ONLY FOR INTERNAL + PURPOSES AND EXTERNAL APPLICATIONS SHOULD NOT DEPEND ON IT. + +## Table of contents + +### Constructors + +- [constructor](WalletTx.md#constructor) + +### Properties + +- [depositSweep](WalletTx.md#depositsweep) +- [redemption](WalletTx.md#redemption) + +## Constructors + +### constructor + +• **new WalletTx**(`tbtcContracts`, `bitcoinClient`, `witness?`): [`WalletTx`](WalletTx.md) + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `tbtcContracts` | [`TBTCContracts`](../README.md#tbtccontracts) | `undefined` | +| `bitcoinClient` | [`BitcoinClient`](../interfaces/BitcoinClient.md) | `undefined` | +| `witness` | `boolean` | `true` | + +#### Returns + +[`WalletTx`](WalletTx.md) + +#### Defined in + +[services/maintenance/wallet-tx.ts:48](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/wallet-tx.ts#L48) + +## Properties + +### depositSweep + +• `Readonly` **depositSweep**: `DepositSweep` + +#### Defined in + +[services/maintenance/wallet-tx.ts:45](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/wallet-tx.ts#L45) + +___ + +### redemption + +• `Readonly` **redemption**: `Redemption` + +#### Defined in + +[services/maintenance/wallet-tx.ts:46](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/maintenance/wallet-tx.ts#L46) diff --git a/typescript/api-reference/enums/BitcoinNetwork-1.md b/typescript/api-reference/enums/BitcoinNetwork-1.md new file mode 100644 index 000000000..0b7b11044 --- /dev/null +++ b/typescript/api-reference/enums/BitcoinNetwork-1.md @@ -0,0 +1,47 @@ +# Enumeration: BitcoinNetwork + +Bitcoin networks. + +## Table of contents + +### Enumeration Members + +- [Mainnet](BitcoinNetwork-1.md#mainnet) +- [Testnet](BitcoinNetwork-1.md#testnet) +- [Unknown](BitcoinNetwork-1.md#unknown) + +## Enumeration Members + +### Mainnet + +• **Mainnet** = ``"mainnet"`` + +Bitcoin Mainnet. + +#### Defined in + +[lib/bitcoin/network.ts:20](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/network.ts#L20) + +___ + +### Testnet + +• **Testnet** = ``"testnet"`` + +Bitcoin Testnet. + +#### Defined in + +[lib/bitcoin/network.ts:16](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/network.ts#L16) + +___ + +### Unknown + +• **Unknown** = ``"unknown"`` + +Unknown network. + +#### Defined in + +[lib/bitcoin/network.ts:12](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/network.ts#L12) diff --git a/typescript/api-reference/enums/WalletState-1.md b/typescript/api-reference/enums/WalletState-1.md new file mode 100644 index 000000000..f31266409 --- /dev/null +++ b/typescript/api-reference/enums/WalletState-1.md @@ -0,0 +1,93 @@ +# Enumeration: WalletState + +## Table of contents + +### Enumeration Members + +- [Closed](WalletState-1.md#closed) +- [Closing](WalletState-1.md#closing) +- [Live](WalletState-1.md#live) +- [MovingFunds](WalletState-1.md#movingfunds) +- [Terminated](WalletState-1.md#terminated) +- [Unknown](WalletState-1.md#unknown) + +## Enumeration Members + +### Closed + +• **Closed** = ``4`` + +The wallet finalized the closing period successfully and can no longer perform +any action in the Bridge. + +#### Defined in + +[lib/contracts/bridge.ts:371](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L371) + +___ + +### Closing + +• **Closing** = ``3`` + +The wallet moved or redeemed all their funds and is in the +losing period where it is still a subject of fraud challenges +and must defend against them. + +#### Defined in + +[lib/contracts/bridge.ts:366](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L366) + +___ + +### Live + +• **Live** = ``1`` + +The wallet can sweep deposits and accept redemption requests. + +#### Defined in + +[lib/contracts/bridge.ts:353](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L353) + +___ + +### MovingFunds + +• **MovingFunds** = ``2`` + +The wallet was deemed unhealthy and is expected to move their outstanding +funds to another wallet. The wallet can still fulfill their pending redemption +requests although new redemption requests and new deposit reveals are not +accepted. + +#### Defined in + +[lib/contracts/bridge.ts:360](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L360) + +___ + +### Terminated + +• **Terminated** = ``5`` + +The wallet committed a fraud that was reported, did not move funds to +another wallet before a timeout, or did not sweep funds moved to if from +another wallet before a timeout. The wallet is blocked and can not perform +any actions in the Bridge. + +#### Defined in + +[lib/contracts/bridge.ts:378](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L378) + +___ + +### Unknown + +• **Unknown** = ``0`` + +The wallet is unknown to the Bridge. + +#### Defined in + +[lib/contracts/bridge.ts:349](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L349) diff --git a/typescript/api-reference/interfaces/BitcoinClient.md b/typescript/api-reference/interfaces/BitcoinClient.md new file mode 100644 index 000000000..67e3358f1 --- /dev/null +++ b/typescript/api-reference/interfaces/BitcoinClient.md @@ -0,0 +1,253 @@ +# Interface: BitcoinClient + +Represents a Bitcoin client. + +## Implemented by + +- [`ElectrumClient`](../classes/ElectrumClient.md) + +## Table of contents + +### Methods + +- [broadcast](BitcoinClient.md#broadcast) +- [findAllUnspentTransactionOutputs](BitcoinClient.md#findallunspenttransactionoutputs) +- [getHeadersChain](BitcoinClient.md#getheaderschain) +- [getNetwork](BitcoinClient.md#getnetwork) +- [getRawTransaction](BitcoinClient.md#getrawtransaction) +- [getTransaction](BitcoinClient.md#gettransaction) +- [getTransactionConfirmations](BitcoinClient.md#gettransactionconfirmations) +- [getTransactionHistory](BitcoinClient.md#gettransactionhistory) +- [getTransactionMerkle](BitcoinClient.md#gettransactionmerkle) +- [latestBlockHeight](BitcoinClient.md#latestblockheight) + +## Methods + +### broadcast + +▸ **broadcast**(`transaction`): `Promise`\<`void`\> + +Broadcasts the given transaction over the network. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transaction` | [`BitcoinRawTx`](BitcoinRawTx.md) | Transaction to broadcast. | + +#### Returns + +`Promise`\<`void`\> + +#### Defined in + +[lib/bitcoin/client.ts:87](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/client.ts#L87) + +___ + +### findAllUnspentTransactionOutputs + +▸ **findAllUnspentTransactionOutputs**(`address`): `Promise`\<[`BitcoinUtxo`](../README.md#bitcoinutxo)[]\> + +Finds all unspent transaction outputs (UTXOs) for given Bitcoin address. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `address` | `string` | Bitcoin address UTXOs should be determined for. | + +#### Returns + +`Promise`\<[`BitcoinUtxo`](../README.md#bitcoinutxo)[]\> + +List of UTXOs. + +#### Defined in + +[lib/bitcoin/client.ts:21](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/client.ts#L21) + +___ + +### getHeadersChain + +▸ **getHeadersChain**(`blockHeight`, `chainLength`): `Promise`\<[`Hex`](../classes/Hex.md)\> + +Gets concatenated chunk of block headers built on a starting block. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `blockHeight` | `number` | Starting block height. | +| `chainLength` | `number` | Number of subsequent blocks built on the starting block. | + +#### Returns + +`Promise`\<[`Hex`](../classes/Hex.md)\> + +Concatenation of block headers in a hexadecimal format. + +#### Defined in + +[lib/bitcoin/client.ts:70](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/client.ts#L70) + +___ + +### getNetwork + +▸ **getNetwork**(): `Promise`\<[`BitcoinNetwork`](../enums/BitcoinNetwork-1.md)\> + +Gets the network supported by the server the client connected to. + +#### Returns + +`Promise`\<[`BitcoinNetwork`](../enums/BitcoinNetwork-1.md)\> + +Bitcoin network. + +#### Defined in + +[lib/bitcoin/client.ts:14](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/client.ts#L14) + +___ + +### getRawTransaction + +▸ **getRawTransaction**(`transactionHash`): `Promise`\<[`BitcoinRawTx`](BitcoinRawTx.md)\> + +Gets the raw transaction data for given transaction hash. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transactionHash` | [`BitcoinTxHash`](../classes/BitcoinTxHash.md) | Hash of the transaction. | + +#### Returns + +`Promise`\<[`BitcoinRawTx`](BitcoinRawTx.md)\> + +Raw transaction. + +#### Defined in + +[lib/bitcoin/client.ts:47](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/client.ts#L47) + +___ + +### getTransaction + +▸ **getTransaction**(`transactionHash`): `Promise`\<[`BitcoinTx`](BitcoinTx.md)\> + +Gets the full transaction object for given transaction hash. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transactionHash` | [`BitcoinTxHash`](../classes/BitcoinTxHash.md) | Hash of the transaction. | + +#### Returns + +`Promise`\<[`BitcoinTx`](BitcoinTx.md)\> + +Transaction object. + +#### Defined in + +[lib/bitcoin/client.ts:40](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/client.ts#L40) + +___ + +### getTransactionConfirmations + +▸ **getTransactionConfirmations**(`transactionHash`): `Promise`\<`number`\> + +Gets the number of confirmations that a given transaction has accumulated +so far. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transactionHash` | [`BitcoinTxHash`](../classes/BitcoinTxHash.md) | Hash of the transaction. | + +#### Returns + +`Promise`\<`number`\> + +The number of confirmations. + +#### Defined in + +[lib/bitcoin/client.ts:55](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/client.ts#L55) + +___ + +### getTransactionHistory + +▸ **getTransactionHistory**(`address`, `limit?`): `Promise`\<[`BitcoinTx`](BitcoinTx.md)[]\> + +Gets the history of confirmed transactions for given Bitcoin address. +Returned transactions are sorted from oldest to newest. The returned +result does not contain unconfirmed transactions living in the mempool +at the moment of request. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `address` | `string` | Bitcoin address transaction history should be determined for. | +| `limit?` | `number` | Optional parameter that can limit the resulting list to a specific number of last transaction. For example, limit = 5 will return only the last 5 transactions for the given address. | + +#### Returns + +`Promise`\<[`BitcoinTx`](BitcoinTx.md)[]\> + +#### Defined in + +[lib/bitcoin/client.ts:33](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/client.ts#L33) + +___ + +### getTransactionMerkle + +▸ **getTransactionMerkle**(`transactionHash`, `blockHeight`): `Promise`\<[`BitcoinTxMerkleBranch`](BitcoinTxMerkleBranch.md)\> + +Get Merkle branch for a given transaction. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transactionHash` | [`BitcoinTxHash`](../classes/BitcoinTxHash.md) | Hash of a transaction. | +| `blockHeight` | `number` | Height of the block where transaction was confirmed. | + +#### Returns + +`Promise`\<[`BitcoinTxMerkleBranch`](BitcoinTxMerkleBranch.md)\> + +Merkle branch. + +#### Defined in + +[lib/bitcoin/client.ts:78](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/client.ts#L78) + +___ + +### latestBlockHeight + +▸ **latestBlockHeight**(): `Promise`\<`number`\> + +Gets height of the latest mined block. + +#### Returns + +`Promise`\<`number`\> + +Height of the last mined block. + +#### Defined in + +[lib/bitcoin/client.ts:61](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/client.ts#L61) diff --git a/typescript/api-reference/interfaces/BitcoinHeader.md b/typescript/api-reference/interfaces/BitcoinHeader.md new file mode 100644 index 000000000..731675c74 --- /dev/null +++ b/typescript/api-reference/interfaces/BitcoinHeader.md @@ -0,0 +1,93 @@ +# Interface: BitcoinHeader + +BitcoinHeader represents the header of a Bitcoin block. For reference, see: +https://developer.bitcoin.org/reference/block_chain.html#block-headers. + +## Table of contents + +### Properties + +- [bits](BitcoinHeader.md#bits) +- [merkleRootHash](BitcoinHeader.md#merkleroothash) +- [nonce](BitcoinHeader.md#nonce) +- [previousBlockHeaderHash](BitcoinHeader.md#previousblockheaderhash) +- [time](BitcoinHeader.md#time) +- [version](BitcoinHeader.md#version) + +## Properties + +### bits + +• **bits**: `number` + +Bits that determine the target threshold this block's header hash must be +less than or equal to. The field is 4-byte long. + +#### Defined in + +[lib/bitcoin/header.ts:37](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/header.ts#L37) + +___ + +### merkleRootHash + +• **merkleRootHash**: [`Hex`](../classes/Hex.md) + +The hash derived from the hashes of all transactions included in this block. +The field is 32-byte long. + +#### Defined in + +[lib/bitcoin/header.ts:25](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/header.ts#L25) + +___ + +### nonce + +• **nonce**: `number` + +An arbitrary number miners change to modify the header hash in order to +produce a hash less than or equal to the target threshold. The field is +4-byte long. + +#### Defined in + +[lib/bitcoin/header.ts:44](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/header.ts#L44) + +___ + +### previousBlockHeaderHash + +• **previousBlockHeaderHash**: [`Hex`](../classes/Hex.md) + +The hash of the previous block's header. The field is 32-byte long. + +#### Defined in + +[lib/bitcoin/header.ts:19](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/header.ts#L19) + +___ + +### time + +• **time**: `number` + +The Unix epoch time when the miner started hashing the header. The field is +4-byte long. + +#### Defined in + +[lib/bitcoin/header.ts:31](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/header.ts#L31) + +___ + +### version + +• **version**: `number` + +The block version number that indicates which set of block validation rules +to follow. The field is 4-byte long. + +#### Defined in + +[lib/bitcoin/header.ts:14](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/header.ts#L14) diff --git a/typescript/api-reference/interfaces/BitcoinRawTx.md b/typescript/api-reference/interfaces/BitcoinRawTx.md new file mode 100644 index 000000000..f1b4f45b1 --- /dev/null +++ b/typescript/api-reference/interfaces/BitcoinRawTx.md @@ -0,0 +1,21 @@ +# Interface: BitcoinRawTx + +Represents a raw Bitcoin transaction. + +## Table of contents + +### Properties + +- [transactionHex](BitcoinRawTx.md#transactionhex) + +## Properties + +### transactionHex + +• **transactionHex**: `string` + +The full transaction payload as an un-prefixed hex string. + +#### Defined in + +[lib/bitcoin/tx.ts:22](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L22) diff --git a/typescript/api-reference/interfaces/BitcoinRawTxVectors.md b/typescript/api-reference/interfaces/BitcoinRawTxVectors.md new file mode 100644 index 000000000..a541515d1 --- /dev/null +++ b/typescript/api-reference/interfaces/BitcoinRawTxVectors.md @@ -0,0 +1,62 @@ +# Interface: BitcoinRawTxVectors + +Represents a raw Bitcoin transaction decomposed into specific vectors. + +## Table of contents + +### Properties + +- [inputs](BitcoinRawTxVectors.md#inputs) +- [locktime](BitcoinRawTxVectors.md#locktime) +- [outputs](BitcoinRawTxVectors.md#outputs) +- [version](BitcoinRawTxVectors.md#version) + +## Properties + +### inputs + +• **inputs**: [`Hex`](../classes/Hex.md) + +All transaction's inputs prepended by the number of transaction inputs, +as a hex string. + +#### Defined in + +[lib/bitcoin/tx.ts:113](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L113) + +___ + +### locktime + +• **locktime**: [`Hex`](../classes/Hex.md) + +Transaction locktime as a hex string. + +#### Defined in + +[lib/bitcoin/tx.ts:124](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L124) + +___ + +### outputs + +• **outputs**: [`Hex`](../classes/Hex.md) + +All transaction's outputs prepended by the number of transaction outputs, +as a hex string. + +#### Defined in + +[lib/bitcoin/tx.ts:119](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L119) + +___ + +### version + +• **version**: [`Hex`](../classes/Hex.md) + +Transaction version as a hex string. + +#### Defined in + +[lib/bitcoin/tx.ts:107](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L107) diff --git a/typescript/api-reference/interfaces/BitcoinSpvProof.md b/typescript/api-reference/interfaces/BitcoinSpvProof.md new file mode 100644 index 000000000..7c06b4549 --- /dev/null +++ b/typescript/api-reference/interfaces/BitcoinSpvProof.md @@ -0,0 +1,49 @@ +# Interface: BitcoinSpvProof + +Data required to perform a proof that a given transaction was included in +the Bitcoin blockchain. + +## Table of contents + +### Properties + +- [bitcoinHeaders](BitcoinSpvProof.md#bitcoinheaders) +- [merkleProof](BitcoinSpvProof.md#merkleproof) +- [txIndexInBlock](BitcoinSpvProof.md#txindexinblock) + +## Properties + +### bitcoinHeaders + +• **bitcoinHeaders**: [`Hex`](../classes/Hex.md) + +Concatenated block headers in hexadecimal format. Each block header is +80-byte-long. The block header with the lowest height is first. + +#### Defined in + +[lib/bitcoin/spv.ts:31](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/spv.ts#L31) + +___ + +### merkleProof + +• **merkleProof**: [`Hex`](../classes/Hex.md) + +The merkle proof of transaction inclusion in a block. + +#### Defined in + +[lib/bitcoin/spv.ts:20](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/spv.ts#L20) + +___ + +### txIndexInBlock + +• **txIndexInBlock**: `number` + +Transaction index in the block (0-indexed). + +#### Defined in + +[lib/bitcoin/spv.ts:25](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/spv.ts#L25) diff --git a/typescript/api-reference/interfaces/BitcoinTx.md b/typescript/api-reference/interfaces/BitcoinTx.md new file mode 100644 index 000000000..aad847f53 --- /dev/null +++ b/typescript/api-reference/interfaces/BitcoinTx.md @@ -0,0 +1,47 @@ +# Interface: BitcoinTx + +Data about a Bitcoin transaction. + +## Table of contents + +### Properties + +- [inputs](BitcoinTx.md#inputs) +- [outputs](BitcoinTx.md#outputs) +- [transactionHash](BitcoinTx.md#transactionhash) + +## Properties + +### inputs + +• **inputs**: [`BitcoinTxInput`](../README.md#bitcointxinput)[] + +The vector of transaction inputs. + +#### Defined in + +[lib/bitcoin/tx.ts:37](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L37) + +___ + +### outputs + +• **outputs**: [`BitcoinTxOutput`](BitcoinTxOutput.md)[] + +The vector of transaction outputs. + +#### Defined in + +[lib/bitcoin/tx.ts:42](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L42) + +___ + +### transactionHash + +• **transactionHash**: [`BitcoinTxHash`](../classes/BitcoinTxHash.md) + +The transaction hash (or transaction ID) as an un-prefixed hex string. + +#### Defined in + +[lib/bitcoin/tx.ts:32](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L32) diff --git a/typescript/api-reference/interfaces/BitcoinTxMerkleBranch.md b/typescript/api-reference/interfaces/BitcoinTxMerkleBranch.md new file mode 100644 index 000000000..df3aac29e --- /dev/null +++ b/typescript/api-reference/interfaces/BitcoinTxMerkleBranch.md @@ -0,0 +1,49 @@ +# Interface: BitcoinTxMerkleBranch + +Information about the merkle branch to a confirmed transaction. + +## Table of contents + +### Properties + +- [blockHeight](BitcoinTxMerkleBranch.md#blockheight) +- [merkle](BitcoinTxMerkleBranch.md#merkle) +- [position](BitcoinTxMerkleBranch.md#position) + +## Properties + +### blockHeight + +• **blockHeight**: `number` + +The height of the block the transaction was confirmed in. + +#### Defined in + +[lib/bitcoin/spv.ts:41](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/spv.ts#L41) + +___ + +### merkle + +• **merkle**: [`Hex`](../classes/Hex.md)[] + +A list of transaction hashes the current hash is paired with, recursively, +in order to trace up to obtain the merkle root of the including block, +the deepest pairing first. Each hash is an unprefixed hex string. + +#### Defined in + +[lib/bitcoin/spv.ts:48](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/spv.ts#L48) + +___ + +### position + +• **position**: `number` + +The 0-based index of the transaction's position in the block. + +#### Defined in + +[lib/bitcoin/spv.ts:53](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/spv.ts#L53) diff --git a/typescript/api-reference/interfaces/BitcoinTxOutpoint.md b/typescript/api-reference/interfaces/BitcoinTxOutpoint.md new file mode 100644 index 000000000..e6bff27c7 --- /dev/null +++ b/typescript/api-reference/interfaces/BitcoinTxOutpoint.md @@ -0,0 +1,34 @@ +# Interface: BitcoinTxOutpoint + +Data about a Bitcoin transaction outpoint. + +## Table of contents + +### Properties + +- [outputIndex](BitcoinTxOutpoint.md#outputindex) +- [transactionHash](BitcoinTxOutpoint.md#transactionhash) + +## Properties + +### outputIndex + +• **outputIndex**: `number` + +The zero-based index of the output from the specified transaction. + +#### Defined in + +[lib/bitcoin/tx.ts:57](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L57) + +___ + +### transactionHash + +• **transactionHash**: [`BitcoinTxHash`](../classes/BitcoinTxHash.md) + +The hash of the transaction the outpoint belongs to. + +#### Defined in + +[lib/bitcoin/tx.ts:52](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L52) diff --git a/typescript/api-reference/interfaces/BitcoinTxOutput.md b/typescript/api-reference/interfaces/BitcoinTxOutput.md new file mode 100644 index 000000000..d364b1206 --- /dev/null +++ b/typescript/api-reference/interfaces/BitcoinTxOutput.md @@ -0,0 +1,47 @@ +# Interface: BitcoinTxOutput + +Data about a Bitcoin transaction output. + +## Table of contents + +### Properties + +- [outputIndex](BitcoinTxOutput.md#outputindex) +- [scriptPubKey](BitcoinTxOutput.md#scriptpubkey) +- [value](BitcoinTxOutput.md#value) + +## Properties + +### outputIndex + +• **outputIndex**: `number` + +The 0-based index of the output. + +#### Defined in + +[lib/bitcoin/tx.ts:77](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L77) + +___ + +### scriptPubKey + +• **scriptPubKey**: [`Hex`](../classes/Hex.md) + +The receiving scriptPubKey. + +#### Defined in + +[lib/bitcoin/tx.ts:87](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L87) + +___ + +### value + +• **value**: `BigNumber` + +The value of the output in satoshis. + +#### Defined in + +[lib/bitcoin/tx.ts:82](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/tx.ts#L82) diff --git a/typescript/api-reference/interfaces/Bridge.md b/typescript/api-reference/interfaces/Bridge.md new file mode 100644 index 000000000..1282c848f --- /dev/null +++ b/typescript/api-reference/interfaces/Bridge.md @@ -0,0 +1,385 @@ +# Interface: Bridge + +Interface for communication with the Bridge on-chain contract. + +## Implemented by + +- [`EthereumBridge`](../classes/EthereumBridge.md) + +## Table of contents + +### Properties + +- [getDepositRevealedEvents](Bridge.md#getdepositrevealedevents) +- [getNewWalletRegisteredEvents](Bridge.md#getnewwalletregisteredevents) +- [getRedemptionRequestedEvents](Bridge.md#getredemptionrequestedevents) + +### Methods + +- [activeWalletPublicKey](Bridge.md#activewalletpublickey) +- [buildUtxoHash](Bridge.md#buildutxohash) +- [deposits](Bridge.md#deposits) +- [getChainIdentifier](Bridge.md#getchainidentifier) +- [pendingRedemptions](Bridge.md#pendingredemptions) +- [requestRedemption](Bridge.md#requestredemption) +- [revealDeposit](Bridge.md#revealdeposit) +- [submitDepositSweepProof](Bridge.md#submitdepositsweepproof) +- [submitRedemptionProof](Bridge.md#submitredemptionproof) +- [timedOutRedemptions](Bridge.md#timedoutredemptions) +- [txProofDifficultyFactor](Bridge.md#txproofdifficultyfactor) +- [walletRegistry](Bridge.md#walletregistry) +- [wallets](Bridge.md#wallets) + +## Properties + +### getDepositRevealedEvents + +• **getDepositRevealedEvents**: [`Function`](GetChainEvents.Function.md)\<[`DepositRevealedEvent`](../README.md#depositrevealedevent)\> + +Get emitted DepositRevealed events. + +**`See`** + +GetEventsFunction + +#### Defined in + +[lib/contracts/bridge.ts:26](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L26) + +___ + +### getNewWalletRegisteredEvents + +• **getNewWalletRegisteredEvents**: [`Function`](GetChainEvents.Function.md)\<[`NewWalletRegisteredEvent`](../README.md#newwalletregisteredevent)\> + +Get emitted NewWalletRegisteredEvent events. + +**`See`** + +GetEventsFunction + +#### Defined in + +[lib/contracts/bridge.ts:155](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L155) + +___ + +### getRedemptionRequestedEvents + +• **getRedemptionRequestedEvents**: [`Function`](GetChainEvents.Function.md)\<[`RedemptionRequestedEvent`](../README.md#redemptionrequestedevent)\> + +Get emitted RedemptionRequested events. + +**`See`** + +GetEventsFunction + +#### Defined in + +[lib/contracts/bridge.ts:181](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L181) + +## Methods + +### activeWalletPublicKey + +▸ **activeWalletPublicKey**(): `Promise`\<`undefined` \| [`Hex`](../classes/Hex.md)\> + +Gets the public key of the current active wallet. + +#### Returns + +`Promise`\<`undefined` \| [`Hex`](../classes/Hex.md)\> + +Compressed (33 bytes long with 02 or 03 prefix) active wallet's + public key. If there is no active wallet at the moment, undefined + is returned. + +#### Defined in + +[lib/contracts/bridge.ts:149](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L149) + +___ + +### buildUtxoHash + +▸ **buildUtxoHash**(`utxo`): [`Hex`](../classes/Hex.md) + +Builds the UTXO hash based on the UTXO components. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `utxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | UTXO components. | + +#### Returns + +[`Hex`](../classes/Hex.md) + +The hash of the UTXO. + +#### Defined in + +[lib/contracts/bridge.ts:175](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L175) + +___ + +### deposits + +▸ **deposits**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`DepositRequest`](DepositRequest.md)\> + +Gets a revealed deposit from the on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](../classes/BitcoinTxHash.md) | The revealed deposit transaction's hash. | +| `depositOutputIndex` | `number` | Index of the deposit transaction output that funds the revealed deposit. | + +#### Returns + +`Promise`\<[`DepositRequest`](DepositRequest.md)\> + +Revealed deposit data. + +#### Defined in + +[lib/contracts/bridge.ts:68](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L68) + +___ + +### getChainIdentifier + +▸ **getChainIdentifier**(): [`ChainIdentifier`](ChainIdentifier.md) + +Gets the chain-specific identifier of this contract. + +#### Returns + +[`ChainIdentifier`](ChainIdentifier.md) + +#### Defined in + +[lib/contracts/bridge.ts:20](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L20) + +___ + +### pendingRedemptions + +▸ **pendingRedemptions**(`walletPublicKey`, `redeemerOutputScript`): `Promise`\<[`RedemptionRequest`](RedemptionRequest.md)\> + +Gets a pending redemption from the on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `walletPublicKey` | [`Hex`](../classes/Hex.md) | Bitcoin public key of the wallet the request is targeted to. Must be in the compressed form (33 bytes long with 02 or 03 prefix). | +| `redeemerOutputScript` | [`Hex`](../classes/Hex.md) | The redeemer output script the redeemed funds are supposed to be locked on. Must not be prepended with length. | + +#### Returns + +`Promise`\<[`RedemptionRequest`](RedemptionRequest.md)\> + +Promise with the pending redemption. + +#### Defined in + +[lib/contracts/bridge.ts:124](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L124) + +___ + +### requestRedemption + +▸ **requestRedemption**(`walletPublicKey`, `mainUtxo`, `redeemerOutputScript`, `amount`): `Promise`\<[`Hex`](../classes/Hex.md)\> + +Requests a redemption from the on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `walletPublicKey` | [`Hex`](../classes/Hex.md) | The Bitcoin public key of the wallet. Must be in the compressed form (33 bytes long with 02 or 03 prefix). | +| `mainUtxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | The main UTXO of the wallet. Must match the main UTXO held by the on-chain contract. | +| `redeemerOutputScript` | [`Hex`](../classes/Hex.md) | The output script that the redeemed funds will be locked to. Must not be prepended with length. | +| `amount` | `BigNumber` | The amount to be redeemed in satoshis. | + +#### Returns + +`Promise`\<[`Hex`](../classes/Hex.md)\> + +Transaction hash of the request redemption transaction. + +#### Defined in + +[lib/contracts/bridge.ts:84](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L84) + +___ + +### revealDeposit + +▸ **revealDeposit**(`depositTx`, `depositOutputIndex`, `deposit`, `vault?`): `Promise`\<[`Hex`](../classes/Hex.md)\> + +Reveals a given deposit to the on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `depositTx` | [`BitcoinRawTxVectors`](BitcoinRawTxVectors.md) | Deposit transaction data | +| `depositOutputIndex` | `number` | Index of the deposit transaction output that funds the revealed deposit | +| `deposit` | [`DepositReceipt`](DepositReceipt.md) | Data of the revealed deposit | +| `vault?` | [`ChainIdentifier`](ChainIdentifier.md) | Optional parameter denoting the vault the given deposit should be routed to | + +#### Returns + +`Promise`\<[`Hex`](../classes/Hex.md)\> + +Transaction hash of the reveal deposit transaction. + +#### Defined in + +[lib/contracts/bridge.ts:54](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L54) + +___ + +### submitDepositSweepProof + +▸ **submitDepositSweepProof**(`sweepTx`, `sweepProof`, `mainUtxo`, `vault?`): `Promise`\<[`Hex`](../classes/Hex.md)\> + +Submits a deposit sweep transaction proof to the on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `sweepTx` | [`BitcoinRawTxVectors`](BitcoinRawTxVectors.md) | Sweep transaction data. | +| `sweepProof` | [`BitcoinSpvProof`](BitcoinSpvProof.md) | Sweep proof data. | +| `mainUtxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | Data of the wallet's main UTXO. | +| `vault?` | [`ChainIdentifier`](ChainIdentifier.md) | Optional identifier of the vault the swept deposits should be routed in. | + +#### Returns + +`Promise`\<[`Hex`](../classes/Hex.md)\> + +Transaction hash of the submit deposit sweep proof transaction. + +#### Defined in + +[lib/contracts/bridge.ts:37](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L37) + +___ + +### submitRedemptionProof + +▸ **submitRedemptionProof**(`redemptionTx`, `redemptionProof`, `mainUtxo`, `walletPublicKey`): `Promise`\<[`Hex`](../classes/Hex.md)\> + +Submits a redemption transaction proof to the on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `redemptionTx` | [`BitcoinRawTxVectors`](BitcoinRawTxVectors.md) | Redemption transaction data | +| `redemptionProof` | [`BitcoinSpvProof`](BitcoinSpvProof.md) | Redemption proof data | +| `mainUtxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | Data of the wallet's main UTXO | +| `walletPublicKey` | [`Hex`](../classes/Hex.md) | Bitcoin public key of the wallet. Must be in the compressed form (33 bytes long with 02 or 03 prefix). | + +#### Returns + +`Promise`\<[`Hex`](../classes/Hex.md)\> + +Transaction hash of the submit redemption proof transaction. + +#### Defined in + +[lib/contracts/bridge.ts:100](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L100) + +___ + +### timedOutRedemptions + +▸ **timedOutRedemptions**(`walletPublicKey`, `redeemerOutputScript`): `Promise`\<[`RedemptionRequest`](RedemptionRequest.md)\> + +Gets a timed-out redemption from the on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `walletPublicKey` | [`Hex`](../classes/Hex.md) | Bitcoin public key of the wallet the request is targeted to. Must be in the compressed form (33 bytes long with 02 or 03 prefix). | +| `redeemerOutputScript` | [`Hex`](../classes/Hex.md) | The redeemer output script the redeemed funds are supposed to be locked on. Must not be prepended with length. | + +#### Returns + +`Promise`\<[`RedemptionRequest`](RedemptionRequest.md)\> + +Promise with the pending redemption. + +#### Defined in + +[lib/contracts/bridge.ts:138](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L138) + +___ + +### txProofDifficultyFactor + +▸ **txProofDifficultyFactor**(): `Promise`\<`number`\> + +Gets transaction proof difficulty factor from the on-chain contract. + +#### Returns + +`Promise`\<`number`\> + +Proof difficulty factor. + +**`Dev`** + +This number signifies how many confirmations a transaction has to + accumulate before it can be proven on-chain. + +#### Defined in + +[lib/contracts/bridge.ts:113](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L113) + +___ + +### walletRegistry + +▸ **walletRegistry**(): `Promise`\<[`WalletRegistry`](WalletRegistry.md)\> + +Returns the attached WalletRegistry instance. + +#### Returns + +`Promise`\<[`WalletRegistry`](WalletRegistry.md)\> + +#### Defined in + +[lib/contracts/bridge.ts:160](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L160) + +___ + +### wallets + +▸ **wallets**(`walletPublicKeyHash`): `Promise`\<[`Wallet`](Wallet.md)\> + +Gets details about a registered wallet. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `walletPublicKeyHash` | [`Hex`](../classes/Hex.md) | The 20-byte wallet public key hash (computed using Bitcoin HASH160 over the compressed ECDSA public key). | + +#### Returns + +`Promise`\<[`Wallet`](Wallet.md)\> + +Promise with the wallet details. + +#### Defined in + +[lib/contracts/bridge.ts:168](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L168) diff --git a/typescript/api-reference/interfaces/ChainEvent.md b/typescript/api-reference/interfaces/ChainEvent.md new file mode 100644 index 000000000..afc8f0b7a --- /dev/null +++ b/typescript/api-reference/interfaces/ChainEvent.md @@ -0,0 +1,47 @@ +# Interface: ChainEvent + +Represents a generic chain event. + +## Table of contents + +### Properties + +- [blockHash](ChainEvent.md#blockhash) +- [blockNumber](ChainEvent.md#blocknumber) +- [transactionHash](ChainEvent.md#transactionhash) + +## Properties + +### blockHash + +• **blockHash**: [`Hex`](../classes/Hex.md) + +Block hash of the event emission. + +#### Defined in + +[lib/contracts/chain-event.ts:14](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain-event.ts#L14) + +___ + +### blockNumber + +• **blockNumber**: `number` + +Block number of the event emission. + +#### Defined in + +[lib/contracts/chain-event.ts:10](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain-event.ts#L10) + +___ + +### transactionHash + +• **transactionHash**: [`Hex`](../classes/Hex.md) + +Transaction hash within which the event was emitted. + +#### Defined in + +[lib/contracts/chain-event.ts:18](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain-event.ts#L18) diff --git a/typescript/api-reference/interfaces/ChainIdentifier.md b/typescript/api-reference/interfaces/ChainIdentifier.md new file mode 100644 index 000000000..a5a08597a --- /dev/null +++ b/typescript/api-reference/interfaces/ChainIdentifier.md @@ -0,0 +1,51 @@ +# Interface: ChainIdentifier + +Represents a generic chain identifier. + +## Implemented by + +- [`EthereumAddress`](../classes/EthereumAddress.md) + +## Table of contents + +### Properties + +- [identifierHex](ChainIdentifier.md#identifierhex) + +### Methods + +- [equals](ChainIdentifier.md#equals) + +## Properties + +### identifierHex + +• **identifierHex**: `string` + +Identifier as an un-prefixed hex string. + +#### Defined in + +[lib/contracts/chain-identifier.ts:8](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain-identifier.ts#L8) + +## Methods + +### equals + +▸ **equals**(`identifier`): `boolean` + +Checks if two identifiers are equal. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `identifier` | [`ChainIdentifier`](ChainIdentifier.md) | Another identifier | + +#### Returns + +`boolean` + +#### Defined in + +[lib/contracts/chain-identifier.ts:14](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain-identifier.ts#L14) diff --git a/typescript/api-reference/interfaces/DepositReceipt.md b/typescript/api-reference/interfaces/DepositReceipt.md new file mode 100644 index 000000000..85f12c732 --- /dev/null +++ b/typescript/api-reference/interfaces/DepositReceipt.md @@ -0,0 +1,80 @@ +# Interface: DepositReceipt + +Represents a deposit receipt. The receipt holds all information required +to build a unique deposit address on Bitcoin chain. + +## Table of contents + +### Properties + +- [blindingFactor](DepositReceipt.md#blindingfactor) +- [depositor](DepositReceipt.md#depositor) +- [refundLocktime](DepositReceipt.md#refundlocktime) +- [refundPublicKeyHash](DepositReceipt.md#refundpublickeyhash) +- [walletPublicKeyHash](DepositReceipt.md#walletpublickeyhash) + +## Properties + +### blindingFactor + +• **blindingFactor**: [`Hex`](../classes/Hex.md) + +An 8-byte blinding factor. Must be unique for the given depositor, wallet +public key and refund public key. + +#### Defined in + +[lib/contracts/bridge.ts:198](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L198) + +___ + +### depositor + +• **depositor**: [`ChainIdentifier`](ChainIdentifier.md) + +Depositor's chain identifier. + +#### Defined in + +[lib/contracts/bridge.ts:192](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L192) + +___ + +### refundLocktime + +• **refundLocktime**: [`Hex`](../classes/Hex.md) + +A 4-byte little-endian refund locktime. + +#### Defined in + +[lib/contracts/bridge.ts:218](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L218) + +___ + +### refundPublicKeyHash + +• **refundPublicKeyHash**: [`Hex`](../classes/Hex.md) + +Public key hash that is meant to be used during deposit refund after the +locktime passes. + +You can use `computeHash160` function to get the hash from a public key. + +#### Defined in + +[lib/contracts/bridge.ts:213](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L213) + +___ + +### walletPublicKeyHash + +• **walletPublicKeyHash**: [`Hex`](../classes/Hex.md) + +Public key hash of the wallet that is meant to receive the deposit. + +You can use `computeHash160` function to get the hash from a public key. + +#### Defined in + +[lib/contracts/bridge.ts:205](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L205) diff --git a/typescript/api-reference/interfaces/DepositRequest.md b/typescript/api-reference/interfaces/DepositRequest.md new file mode 100644 index 000000000..89b9d6ea2 --- /dev/null +++ b/typescript/api-reference/interfaces/DepositRequest.md @@ -0,0 +1,88 @@ +# Interface: DepositRequest + +Represents a deposit request revealed to the on-chain bridge. + +## Table of contents + +### Properties + +- [amount](DepositRequest.md#amount) +- [depositor](DepositRequest.md#depositor) +- [revealedAt](DepositRequest.md#revealedat) +- [sweptAt](DepositRequest.md#sweptat) +- [treasuryFee](DepositRequest.md#treasuryfee) +- [vault](DepositRequest.md#vault) + +## Properties + +### amount + +• **amount**: `BigNumber` + +Deposit amount in satoshis. + +#### Defined in + +[lib/contracts/bridge.ts:257](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L257) + +___ + +### depositor + +• **depositor**: [`ChainIdentifier`](ChainIdentifier.md) + +Depositor's chain identifier. + +#### Defined in + +[lib/contracts/bridge.ts:252](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L252) + +___ + +### revealedAt + +• **revealedAt**: `number` + +UNIX timestamp the deposit was revealed at. + +#### Defined in + +[lib/contracts/bridge.ts:267](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L267) + +___ + +### sweptAt + +• **sweptAt**: `number` + +UNIX timestamp the request was swept at. If not swept yet, this parameter +should have zero as value. + +#### Defined in + +[lib/contracts/bridge.ts:272](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L272) + +___ + +### treasuryFee + +• **treasuryFee**: `BigNumber` + +Value of the treasury fee calculated for this revealed deposit. +Denominated in satoshi. + +#### Defined in + +[lib/contracts/bridge.ts:277](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L277) + +___ + +### vault + +• `Optional` **vault**: [`ChainIdentifier`](ChainIdentifier.md) + +Optional identifier of the vault the deposit should be routed in. + +#### Defined in + +[lib/contracts/bridge.ts:262](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L262) diff --git a/typescript/api-reference/interfaces/ElectrumCredentials.md b/typescript/api-reference/interfaces/ElectrumCredentials.md new file mode 100644 index 000000000..d72c5c2d4 --- /dev/null +++ b/typescript/api-reference/interfaces/ElectrumCredentials.md @@ -0,0 +1,47 @@ +# Interface: ElectrumCredentials + +Represents a set of credentials required to establish an Electrum connection. + +## Table of contents + +### Properties + +- [host](ElectrumCredentials.md#host) +- [port](ElectrumCredentials.md#port) +- [protocol](ElectrumCredentials.md#protocol) + +## Properties + +### host + +• **host**: `string` + +Host pointing to the Electrum server. + +#### Defined in + +[lib/electrum/client.ts:34](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L34) + +___ + +### port + +• **port**: `number` + +Port the Electrum server listens on. + +#### Defined in + +[lib/electrum/client.ts:38](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L38) + +___ + +### protocol + +• **protocol**: ``"tcp"`` \| ``"tls"`` \| ``"ssl"`` \| ``"ws"`` \| ``"wss"`` + +Protocol used by the Electrum server. + +#### Defined in + +[lib/electrum/client.ts:42](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/electrum/client.ts#L42) diff --git a/typescript/api-reference/interfaces/EthereumContractConfig.md b/typescript/api-reference/interfaces/EthereumContractConfig.md new file mode 100644 index 000000000..49b8d1b50 --- /dev/null +++ b/typescript/api-reference/interfaces/EthereumContractConfig.md @@ -0,0 +1,52 @@ +# Interface: EthereumContractConfig + +Represents a config set required to connect an Ethereum contract. + +## Table of contents + +### Properties + +- [address](EthereumContractConfig.md#address) +- [deployedAtBlockNumber](EthereumContractConfig.md#deployedatblocknumber) +- [signerOrProvider](EthereumContractConfig.md#signerorprovider) + +## Properties + +### address + +• `Optional` **address**: `string` + +Address of the Ethereum contract as a 0x-prefixed hex string. +Optional parameter, if not provided the value will be resolved from the +contract artifact. + +#### Defined in + +[lib/ethereum/adapter.ts:53](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L53) + +___ + +### deployedAtBlockNumber + +• `Optional` **deployedAtBlockNumber**: `number` + +Number of a block in which the contract was deployed. +Optional parameter, if not provided the value will be resolved from the +contract artifact. + +#### Defined in + +[lib/ethereum/adapter.ts:64](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L64) + +___ + +### signerOrProvider + +• **signerOrProvider**: `Signer` \| `Provider` + +Signer - will return a Contract which will act on behalf of that signer. The signer will sign all contract transactions. +Provider - will return a downgraded Contract which only has read-only access (i.e. constant calls) + +#### Defined in + +[lib/ethereum/adapter.ts:58](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L58) diff --git a/typescript/api-reference/interfaces/GetChainEvents.Function.md b/typescript/api-reference/interfaces/GetChainEvents.Function.md new file mode 100644 index 000000000..10c90d30d --- /dev/null +++ b/typescript/api-reference/interfaces/GetChainEvents.Function.md @@ -0,0 +1,36 @@ +# Interface: Function\ + +[GetChainEvents](../modules/GetChainEvents.md).Function + +Represents a generic function to get events emitted on the chain. + +## Type parameters + +| Name | Type | +| :------ | :------ | +| `T` | extends [`ChainEvent`](ChainEvent.md) | + +## Callable + +### Function + +▸ **Function**(`options?`, `...filterArgs`): `Promise`\<`T`[]\> + +Get emitted events. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `options?` | [`Options`](GetChainEvents.Options.md) | Options for getting events. | +| `...filterArgs` | `any`[] | Arguments for events filtering. | + +#### Returns + +`Promise`\<`T`[]\> + +Array of found events. + +#### Defined in + +[lib/contracts/chain-event.ts:60](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain-event.ts#L60) diff --git a/typescript/api-reference/interfaces/GetChainEvents.Options.md b/typescript/api-reference/interfaces/GetChainEvents.Options.md new file mode 100644 index 000000000..eb17d6ac7 --- /dev/null +++ b/typescript/api-reference/interfaces/GetChainEvents.Options.md @@ -0,0 +1,77 @@ +# Interface: Options + +[GetChainEvents](../modules/GetChainEvents.md).Options + +Represents generic options used for getting events from the chain. + +## Table of contents + +### Properties + +- [batchedQueryBlockInterval](GetChainEvents.Options.md#batchedqueryblockinterval) +- [fromBlock](GetChainEvents.Options.md#fromblock) +- [logger](GetChainEvents.Options.md#logger) +- [retries](GetChainEvents.Options.md#retries) +- [toBlock](GetChainEvents.Options.md#toblock) + +## Properties + +### batchedQueryBlockInterval + +• `Optional` **batchedQueryBlockInterval**: `number` + +Number of blocks for interval length in partial events pulls. + +#### Defined in + +[lib/contracts/chain-event.ts:43](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain-event.ts#L43) + +___ + +### fromBlock + +• `Optional` **fromBlock**: `number` + +Block number from which events should be queried. +If not defined a block number of a contract deployment is used. + +#### Defined in + +[lib/contracts/chain-event.ts:30](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain-event.ts#L30) + +___ + +### logger + +• `Optional` **logger**: [`ExecutionLoggerFn`](../README.md#executionloggerfn) + +A logger function to pass execution messages. + +#### Defined in + +[lib/contracts/chain-event.ts:47](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain-event.ts#L47) + +___ + +### retries + +• `Optional` **retries**: `number` + +Number of retries in case of an error getting the events. + +#### Defined in + +[lib/contracts/chain-event.ts:39](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain-event.ts#L39) + +___ + +### toBlock + +• `Optional` **toBlock**: `number` + +Block number to which events should be queried. +If not defined the latest block number will be used. + +#### Defined in + +[lib/contracts/chain-event.ts:35](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain-event.ts#L35) diff --git a/typescript/api-reference/interfaces/RedemptionRequest.md b/typescript/api-reference/interfaces/RedemptionRequest.md new file mode 100644 index 000000000..5202c498e --- /dev/null +++ b/typescript/api-reference/interfaces/RedemptionRequest.md @@ -0,0 +1,93 @@ +# Interface: RedemptionRequest + +Represents a redemption request. + +## Table of contents + +### Properties + +- [redeemer](RedemptionRequest.md#redeemer) +- [redeemerOutputScript](RedemptionRequest.md#redeemeroutputscript) +- [requestedAmount](RedemptionRequest.md#requestedamount) +- [requestedAt](RedemptionRequest.md#requestedat) +- [treasuryFee](RedemptionRequest.md#treasuryfee) +- [txMaxFee](RedemptionRequest.md#txmaxfee) + +## Properties + +### redeemer + +• **redeemer**: [`ChainIdentifier`](ChainIdentifier.md) + +On-chain identifier of the redeemer. + +#### Defined in + +[lib/contracts/bridge.ts:296](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L296) + +___ + +### redeemerOutputScript + +• **redeemerOutputScript**: [`Hex`](../classes/Hex.md) + +The output script the redeemed Bitcoin funds are locked to. It is not +prepended with length. + +#### Defined in + +[lib/contracts/bridge.ts:302](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L302) + +___ + +### requestedAmount + +• **requestedAmount**: `BigNumber` + +The amount of Bitcoins in satoshis that is requested to be redeemed. +The actual value of the output in the Bitcoin transaction will be decreased +by the sum of the fee share and the treasury fee for this particular output. + +#### Defined in + +[lib/contracts/bridge.ts:309](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L309) + +___ + +### requestedAt + +• **requestedAt**: `number` + +UNIX timestamp the request was created at. + +#### Defined in + +[lib/contracts/bridge.ts:328](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L328) + +___ + +### treasuryFee + +• **treasuryFee**: `BigNumber` + +The amount of Bitcoins in satoshis that is subtracted from the amount of +the redemption request and used to pay the treasury fee. +The value should be exactly equal to the value of treasury fee in the Bridge +on-chain contract at the time the redemption request was made. + +#### Defined in + +[lib/contracts/bridge.ts:317](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L317) + +___ + +### txMaxFee + +• **txMaxFee**: `BigNumber` + +The maximum amount of Bitcoins in satoshis that can be subtracted from the +redemption's `requestedAmount` to pay the transaction network fee. + +#### Defined in + +[lib/contracts/bridge.ts:323](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L323) diff --git a/typescript/api-reference/interfaces/TBTCToken.md b/typescript/api-reference/interfaces/TBTCToken.md new file mode 100644 index 000000000..3c8e0a182 --- /dev/null +++ b/typescript/api-reference/interfaces/TBTCToken.md @@ -0,0 +1,85 @@ +# Interface: TBTCToken + +Interface for communication with the TBTC v2 token on-chain contract. + +## Implemented by + +- [`EthereumTBTCToken`](../classes/EthereumTBTCToken.md) + +## Table of contents + +### Methods + +- [getChainIdentifier](TBTCToken.md#getchainidentifier) +- [requestRedemption](TBTCToken.md#requestredemption) +- [totalSupply](TBTCToken.md#totalsupply) + +## Methods + +### getChainIdentifier + +▸ **getChainIdentifier**(): [`ChainIdentifier`](ChainIdentifier.md) + +Gets the chain-specific identifier of this contract. + +#### Returns + +[`ChainIdentifier`](ChainIdentifier.md) + +#### Defined in + +[lib/contracts/tbtc-token.ts:13](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-token.ts#L13) + +___ + +### requestRedemption + +▸ **requestRedemption**(`walletPublicKey`, `mainUtxo`, `redeemerOutputScript`, `amount`): `Promise`\<[`Hex`](../classes/Hex.md)\> + +Requests redemption in one transaction using the `approveAndCall` function +from the tBTC on-chain token contract. Then the tBTC token contract calls +the `receiveApproval` function from the `TBTCVault` contract which burns +tBTC tokens and requests redemption. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `walletPublicKey` | [`Hex`](../classes/Hex.md) | The Bitcoin public key of the wallet. Must be in the compressed form (33 bytes long with 02 or 03 prefix). | +| `mainUtxo` | [`BitcoinUtxo`](../README.md#bitcoinutxo) | The main UTXO of the wallet. Must match the main UTXO held by the on-chain Bridge contract. | +| `redeemerOutputScript` | [`Hex`](../classes/Hex.md) | The output script that the redeemed funds will be locked to. Must not be prepended with length. | +| `amount` | `BigNumber` | The amount to be redeemed with the precision of the tBTC on-chain token contract. | + +#### Returns + +`Promise`\<[`Hex`](../classes/Hex.md)\> + +Transaction hash of the approve and call transaction. + +#### Defined in + +[lib/contracts/tbtc-token.ts:40](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-token.ts#L40) + +___ + +### totalSupply + +▸ **totalSupply**(`blockNumber?`): `Promise`\<`BigNumber`\> + +Gets the total supply of the TBTC v2 token. The returned value is in +ERC 1e18 precision, it has to be converted before using as Bitcoin value +with 1e8 precision in satoshi. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `blockNumber?` | `number` | Optional parameter determining the block the total supply should be fetched for. If this parameter is not set, the total supply is taken for the latest block. | + +#### Returns + +`Promise`\<`BigNumber`\> + +#### Defined in + +[lib/contracts/tbtc-token.ts:23](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-token.ts#L23) diff --git a/typescript/api-reference/interfaces/TBTCVault.md b/typescript/api-reference/interfaces/TBTCVault.md new file mode 100644 index 000000000..c7bead2a0 --- /dev/null +++ b/typescript/api-reference/interfaces/TBTCVault.md @@ -0,0 +1,274 @@ +# Interface: TBTCVault + +Interface for communication with the TBTCVault on-chain contract. + +## Implemented by + +- [`EthereumTBTCVault`](../classes/EthereumTBTCVault.md) + +## Table of contents + +### Properties + +- [getOptimisticMintingCancelledEvents](TBTCVault.md#getoptimisticmintingcancelledevents) +- [getOptimisticMintingFinalizedEvents](TBTCVault.md#getoptimisticmintingfinalizedevents) +- [getOptimisticMintingRequestedEvents](TBTCVault.md#getoptimisticmintingrequestedevents) + +### Methods + +- [cancelOptimisticMint](TBTCVault.md#canceloptimisticmint) +- [finalizeOptimisticMint](TBTCVault.md#finalizeoptimisticmint) +- [getChainIdentifier](TBTCVault.md#getchainidentifier) +- [getMinters](TBTCVault.md#getminters) +- [isGuardian](TBTCVault.md#isguardian) +- [isMinter](TBTCVault.md#isminter) +- [optimisticMintingDelay](TBTCVault.md#optimisticmintingdelay) +- [optimisticMintingRequests](TBTCVault.md#optimisticmintingrequests) +- [requestOptimisticMint](TBTCVault.md#requestoptimisticmint) + +## Properties + +### getOptimisticMintingCancelledEvents + +• **getOptimisticMintingCancelledEvents**: [`Function`](GetChainEvents.Function.md)\<[`OptimisticMintingCancelledEvent`](../README.md#optimisticmintingcancelledevent)\> + +Get emitted OptimisticMintingCancelled events. + +**`See`** + +GetEventsFunction + +#### Defined in + +[lib/contracts/tbtc-vault.ts:107](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L107) + +___ + +### getOptimisticMintingFinalizedEvents + +• **getOptimisticMintingFinalizedEvents**: [`Function`](GetChainEvents.Function.md)\<[`OptimisticMintingFinalizedEvent`](../README.md#optimisticmintingfinalizedevent)\> + +Get emitted OptimisticMintingFinalized events. + +**`See`** + +GetEventsFunction + +#### Defined in + +[lib/contracts/tbtc-vault.ts:113](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L113) + +___ + +### getOptimisticMintingRequestedEvents + +• **getOptimisticMintingRequestedEvents**: [`Function`](GetChainEvents.Function.md)\<[`OptimisticMintingRequestedEvent`](../README.md#optimisticmintingrequestedevent)\> + +Get emitted OptimisticMintingRequested events. + +**`See`** + +GetEventsFunction + +#### Defined in + +[lib/contracts/tbtc-vault.ts:101](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L101) + +## Methods + +### cancelOptimisticMint + +▸ **cancelOptimisticMint**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`Hex`](../classes/Hex.md)\> + +Cancels optimistic minting for a deposit in an on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](../classes/BitcoinTxHash.md) | The revealed deposit transaction's hash. | +| `depositOutputIndex` | `number` | Index of the deposit transaction output that funds the revealed deposit. | + +#### Returns + +`Promise`\<[`Hex`](../classes/Hex.md)\> + +Transaction hash of the optimistic mint cancel transaction. + +#### Defined in + +[lib/contracts/tbtc-vault.ts:67](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L67) + +___ + +### finalizeOptimisticMint + +▸ **finalizeOptimisticMint**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`Hex`](../classes/Hex.md)\> + +Finalizes optimistic minting for a deposit in an on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](../classes/BitcoinTxHash.md) | The revealed deposit transaction's hash. | +| `depositOutputIndex` | `number` | Index of the deposit transaction output that funds the revealed deposit. | + +#### Returns + +`Promise`\<[`Hex`](../classes/Hex.md)\> + +Transaction hash of the optimistic mint finalize transaction. + +#### Defined in + +[lib/contracts/tbtc-vault.ts:80](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L80) + +___ + +### getChainIdentifier + +▸ **getChainIdentifier**(): [`ChainIdentifier`](ChainIdentifier.md) + +Gets the chain-specific identifier of this contract. + +#### Returns + +[`ChainIdentifier`](ChainIdentifier.md) + +#### Defined in + +[lib/contracts/tbtc-vault.ts:14](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L14) + +___ + +### getMinters + +▸ **getMinters**(): `Promise`\<[`ChainIdentifier`](ChainIdentifier.md)[]\> + +Gets currently registered minters. + +#### Returns + +`Promise`\<[`ChainIdentifier`](ChainIdentifier.md)[]\> + +Array containing identifiers of all currently registered minters. + +#### Defined in + +[lib/contracts/tbtc-vault.ts:30](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L30) + +___ + +### isGuardian + +▸ **isGuardian**(`identifier`): `Promise`\<`boolean`\> + +Checks if given identifier is registered as guardian. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `identifier` | [`ChainIdentifier`](ChainIdentifier.md) | Chain identifier to check. | + +#### Returns + +`Promise`\<`boolean`\> + +#### Defined in + +[lib/contracts/tbtc-vault.ts:44](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L44) + +___ + +### isMinter + +▸ **isMinter**(`identifier`): `Promise`\<`boolean`\> + +Checks if given identifier is registered as minter. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `identifier` | [`ChainIdentifier`](ChainIdentifier.md) | Chain identifier to check. | + +#### Returns + +`Promise`\<`boolean`\> + +#### Defined in + +[lib/contracts/tbtc-vault.ts:37](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L37) + +___ + +### optimisticMintingDelay + +▸ **optimisticMintingDelay**(): `Promise`\<`number`\> + +Gets optimistic minting delay. + +The time that needs to pass between the moment the optimistic minting is +requested and the moment optimistic minting is finalized with minting TBTC. + +#### Returns + +`Promise`\<`number`\> + +Optimistic Minting Delay in seconds. + +#### Defined in + +[lib/contracts/tbtc-vault.ts:23](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L23) + +___ + +### optimisticMintingRequests + +▸ **optimisticMintingRequests**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`OptimisticMintingRequest`](../README.md#optimisticmintingrequest)\> + +Gets optimistic minting request for a deposit. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](../classes/BitcoinTxHash.md) | The revealed deposit transaction's hash. | +| `depositOutputIndex` | `number` | Index of the deposit transaction output that funds the revealed deposit. | + +#### Returns + +`Promise`\<[`OptimisticMintingRequest`](../README.md#optimisticmintingrequest)\> + +Optimistic minting request. + +#### Defined in + +[lib/contracts/tbtc-vault.ts:92](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L92) + +___ + +### requestOptimisticMint + +▸ **requestOptimisticMint**(`depositTxHash`, `depositOutputIndex`): `Promise`\<[`Hex`](../classes/Hex.md)\> + +Requests optimistic minting for a deposit in an on-chain contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `depositTxHash` | [`BitcoinTxHash`](../classes/BitcoinTxHash.md) | The revealed deposit transaction's hash. | +| `depositOutputIndex` | `number` | Index of the deposit transaction output that funds the revealed deposit. | + +#### Returns + +`Promise`\<[`Hex`](../classes/Hex.md)\> + +Transaction hash of the optimistic mint request transaction. + +#### Defined in + +[lib/contracts/tbtc-vault.ts:54](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/tbtc-vault.ts#L54) diff --git a/typescript/api-reference/interfaces/Wallet.md b/typescript/api-reference/interfaces/Wallet.md new file mode 100644 index 000000000..38cb250d1 --- /dev/null +++ b/typescript/api-reference/interfaces/Wallet.md @@ -0,0 +1,139 @@ +# Interface: Wallet + +Represents a deposit. + +## Table of contents + +### Properties + +- [closingStartedAt](Wallet.md#closingstartedat) +- [createdAt](Wallet.md#createdat) +- [ecdsaWalletID](Wallet.md#ecdsawalletid) +- [mainUtxoHash](Wallet.md#mainutxohash) +- [movingFundsRequestedAt](Wallet.md#movingfundsrequestedat) +- [movingFundsTargetWalletsCommitmentHash](Wallet.md#movingfundstargetwalletscommitmenthash) +- [pendingMovedFundsSweepRequestsCount](Wallet.md#pendingmovedfundssweeprequestscount) +- [pendingRedemptionsValue](Wallet.md#pendingredemptionsvalue) +- [state](Wallet.md#state) +- [walletPublicKey](Wallet.md#walletpublickey) + +## Properties + +### closingStartedAt + +• **closingStartedAt**: `number` + +UNIX timestamp indicating the moment the wallet's closing period started. + +#### Defined in + +[lib/contracts/bridge.ts:427](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L427) + +___ + +### createdAt + +• **createdAt**: `number` + +UNIX timestamp the wallet was created at. + +#### Defined in + +[lib/contracts/bridge.ts:418](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L418) + +___ + +### ecdsaWalletID + +• **ecdsaWalletID**: [`Hex`](../classes/Hex.md) + +Identifier of a ECDSA Wallet registered in the ECDSA Wallet Registry. + +#### Defined in + +[lib/contracts/bridge.ts:402](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L402) + +___ + +### mainUtxoHash + +• **mainUtxoHash**: [`Hex`](../classes/Hex.md) + +Latest wallet's main UTXO hash. + +#### Defined in + +[lib/contracts/bridge.ts:410](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L410) + +___ + +### movingFundsRequestedAt + +• **movingFundsRequestedAt**: `number` + +UNIX timestamp indicating the moment the wallet was requested to move their +funds. + +#### Defined in + +[lib/contracts/bridge.ts:423](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L423) + +___ + +### movingFundsTargetWalletsCommitmentHash + +• **movingFundsTargetWalletsCommitmentHash**: [`Hex`](../classes/Hex.md) + +Moving funds target wallet commitment submitted by the wallet. + +#### Defined in + +[lib/contracts/bridge.ts:439](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L439) + +___ + +### pendingMovedFundsSweepRequestsCount + +• **pendingMovedFundsSweepRequestsCount**: `number` + +Total count of pending moved funds sweep requests targeting this wallet. + +#### Defined in + +[lib/contracts/bridge.ts:431](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L431) + +___ + +### pendingRedemptionsValue + +• **pendingRedemptionsValue**: `BigNumber` + +The total redeemable value of pending redemption requests targeting that wallet. + +#### Defined in + +[lib/contracts/bridge.ts:414](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L414) + +___ + +### state + +• **state**: [`WalletState`](../enums/WalletState-1.md) + +Current state of the wallet. + +#### Defined in + +[lib/contracts/bridge.ts:435](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L435) + +___ + +### walletPublicKey + +• **walletPublicKey**: [`Hex`](../classes/Hex.md) + +Compressed public key of the ECDSA Wallet. + +#### Defined in + +[lib/contracts/bridge.ts:406](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L406) diff --git a/typescript/api-reference/interfaces/WalletRegistry.md b/typescript/api-reference/interfaces/WalletRegistry.md new file mode 100644 index 000000000..2fb0500fc --- /dev/null +++ b/typescript/api-reference/interfaces/WalletRegistry.md @@ -0,0 +1,108 @@ +# Interface: WalletRegistry + +Interface for communication with the WalletRegistry on-chain contract. + +## Implemented by + +- [`EthereumWalletRegistry`](../classes/EthereumWalletRegistry.md) + +## Table of contents + +### Properties + +- [getDkgResultApprovedEvents](WalletRegistry.md#getdkgresultapprovedevents) +- [getDkgResultChallengedEvents](WalletRegistry.md#getdkgresultchallengedevents) +- [getDkgResultSubmittedEvents](WalletRegistry.md#getdkgresultsubmittedevents) + +### Methods + +- [getChainIdentifier](WalletRegistry.md#getchainidentifier) +- [getWalletPublicKey](WalletRegistry.md#getwalletpublickey) + +## Properties + +### getDkgResultApprovedEvents + +• **getDkgResultApprovedEvents**: [`Function`](GetChainEvents.Function.md)\<[`DkgResultApprovedEvent`](../README.md#dkgresultapprovedevent)\> + +Get emitted DkgResultApprovedEvent events. + +**`See`** + +GetEventsFunction + +#### Defined in + +[lib/contracts/wallet-registry.ts:32](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/wallet-registry.ts#L32) + +___ + +### getDkgResultChallengedEvents + +• **getDkgResultChallengedEvents**: [`Function`](GetChainEvents.Function.md)\<[`DkgResultChallengedEvent`](../README.md#dkgresultchallengedevent)\> + +Get emitted DkgResultChallengedEvent events. + +**`See`** + +GetEventsFunction + +#### Defined in + +[lib/contracts/wallet-registry.ts:38](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/wallet-registry.ts#L38) + +___ + +### getDkgResultSubmittedEvents + +• **getDkgResultSubmittedEvents**: [`Function`](GetChainEvents.Function.md)\<[`DkgResultSubmittedEvent`](../README.md#dkgresultsubmittedevent)\> + +Get emitted DkgResultSubmittedEvent events. + +**`See`** + +GetEventsFunction + +#### Defined in + +[lib/contracts/wallet-registry.ts:26](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/wallet-registry.ts#L26) + +## Methods + +### getChainIdentifier + +▸ **getChainIdentifier**(): [`ChainIdentifier`](ChainIdentifier.md) + +Gets the chain-specific identifier of this contract. + +#### Returns + +[`ChainIdentifier`](ChainIdentifier.md) + +#### Defined in + +[lib/contracts/wallet-registry.ts:13](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/wallet-registry.ts#L13) + +___ + +### getWalletPublicKey + +▸ **getWalletPublicKey**(`walletID`): `Promise`\<[`Hex`](../classes/Hex.md)\> + +Gets the public key for the given wallet. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `walletID` | [`Hex`](../classes/Hex.md) | ID of the wallet. | + +#### Returns + +`Promise`\<[`Hex`](../classes/Hex.md)\> + +Uncompressed public key without the 04 prefix. + +#### Defined in + +[lib/contracts/wallet-registry.ts:20](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/wallet-registry.ts#L20) diff --git a/typescript/api-reference/modules/BitcoinNetwork.md b/typescript/api-reference/modules/BitcoinNetwork.md new file mode 100644 index 000000000..369c84e00 --- /dev/null +++ b/typescript/api-reference/modules/BitcoinNetwork.md @@ -0,0 +1,33 @@ +# Namespace: BitcoinNetwork + +## Table of contents + +### Functions + +- [fromGenesisHash](BitcoinNetwork.md#fromgenesishash) + +## Functions + +### fromGenesisHash + +▸ **fromGenesisHash**(`hash`): [`BitcoinNetwork`](../enums/BitcoinNetwork-1.md) + +Gets Bitcoin Network type by comparing a provided hash to known +[genesis block hashes](https://en.bitcoin.it/wiki/Genesis_block). +Returns [BitcoinNetwork.Unknown](../enums/BitcoinNetwork-1.md#unknown) + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `hash` | [`Hex`](../classes/Hex.md) | Hash of a block. | + +#### Returns + +[`BitcoinNetwork`](../enums/BitcoinNetwork-1.md) + +Bitcoin Network. + +#### Defined in + +[lib/bitcoin/network.ts:33](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/bitcoin/network.ts#L33) diff --git a/typescript/api-reference/modules/GetChainEvents.md b/typescript/api-reference/modules/GetChainEvents.md new file mode 100644 index 000000000..6291419e5 --- /dev/null +++ b/typescript/api-reference/modules/GetChainEvents.md @@ -0,0 +1,8 @@ +# Namespace: GetChainEvents + +## Table of contents + +### Interfaces + +- [Function](../interfaces/GetChainEvents.Function.md) +- [Options](../interfaces/GetChainEvents.Options.md) diff --git a/typescript/api-reference/modules/WalletState.md b/typescript/api-reference/modules/WalletState.md new file mode 100644 index 000000000..9a940a1b9 --- /dev/null +++ b/typescript/api-reference/modules/WalletState.md @@ -0,0 +1,27 @@ +# Namespace: WalletState + +## Table of contents + +### Functions + +- [parse](WalletState.md#parse) + +## Functions + +### parse + +▸ **parse**(`val`): [`WalletState`](../enums/WalletState-1.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `val` | `number` | + +#### Returns + +[`WalletState`](../enums/WalletState-1.md) + +#### Defined in + +[lib/contracts/bridge.ts:384](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L384) diff --git a/typescript/package.json b/typescript/package.json index 9397f7d89..15ca45520 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -13,7 +13,8 @@ "test": "mocha --exit --recursive 'test/**/*.test.ts'", "typechain": "rm -rf ./typechain && for i in $npm_package_config_contracts; do typechain --target ethers-v5 --out-dir ./typechain $i; done && rm ./typechain/index.ts", "build": "npm run typechain && tsc --project tsconfig.build.json", - "dev": "tsc --project tsconfig.build.json --watch" + "dev": "tsc --project tsconfig.build.json --watch", + "docs": "typedoc --options typedoc.json" }, "files": [ "dist/", @@ -42,7 +43,7 @@ "@types/chai": "^4.2.21", "@types/chai-as-promised": "^7.1.4", "@types/mocha": "^8.2.3", - "@types/node": "^16.3.1", + "@types/node": "^16.4.0", "@typescript-eslint/eslint-plugin": "^4.28.3", "@typescript-eslint/parser": "^4.28.3", "chai": "^4.3.4", @@ -53,11 +54,18 @@ "ethereum-waffle": "4.0.0-alpha.25", "mocha": "^9.0.2", "prettier": "^2.3.2", - "ts-node": "^10.1.0", + "ts-node": "^10.8.0", "typechain": "^8.1.1", - "typescript": "^4.3.5" + "typedoc": "^0.25.3", + "typedoc-plugin-markdown": "^3.17.0", + "typescript": "^4.6.0" }, "engines": { "node": ">=16" + }, + "repository": { + "type": "git", + "url": "https://github.com/keep-network/tbtc-v2.git", + "directory": "typescript" } } diff --git a/typescript/typedoc.json b/typescript/typedoc.json new file mode 100644 index 000000000..99e9f6f49 --- /dev/null +++ b/typescript/typedoc.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://typedoc.org/schema.json", + "entryPoints": ["src/index.ts"], + "out": "./api-reference", + "plugin": ["typedoc-plugin-markdown"], + "githubPages": false, + "readme": "none", + "gitRevision": "main", + "hideBreadcrumbs": true, + "compilerOptions": { + "skipLibCheck": true + } +} diff --git a/typescript/yarn.lock b/typescript/yarn.lock index 1ee5acf25..584329aed 100644 --- a/typescript/yarn.lock +++ b/typescript/yarn.lock @@ -173,17 +173,12 @@ eth-lib "^0.2.8" ethereumjs-util "^5.2.0" -"@cspotcode/source-map-consumer@0.8.0": - version "0.8.0" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b" - integrity sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg== - -"@cspotcode/source-map-support@0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz#4789840aa859e46d2f3173727ab707c66bf344f5" - integrity sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA== +"@cspotcode/source-map-support@^0.8.0": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" + integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== dependencies: - "@cspotcode/source-map-consumer" "0.8.0" + "@jridgewell/trace-mapping" "0.3.9" "@ensdomains/ens@^0.4.4": version "0.4.5" @@ -1498,6 +1493,24 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== +"@jridgewell/resolve-uri@^3.0.3": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721" + integrity sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA== + +"@jridgewell/sourcemap-codec@^1.4.10": + version "1.4.15" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" + integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== + +"@jridgewell/trace-mapping@0.3.9": + version "0.3.9" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== + dependencies: + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@keep-network/bitcoin-spv-sol@3.4.0-solc-0.8": version "3.4.0-solc-0.8" resolved "https://registry.yarnpkg.com/@keep-network/bitcoin-spv-sol/-/bitcoin-spv-sol-3.4.0-solc-0.8.tgz#8b44c246ffab8ea993efe196f6bf385b1a3b84dc" @@ -2098,10 +2111,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.52.tgz#2fd2dc6bfa185601b15457398d4ba1ef27f81251" integrity sha512-cfkwWw72849SNYp3Zx0IcIs25vABmFh73xicxhCkTcvtZQeIez15PpwQN8fY3RD7gv1Wrxlc9MEtfMORZDEsGw== -"@types/node@^16.3.1": - version "16.11.14" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.14.tgz#4939fb42e5b0ffb3ea7e193c28244fe7414977a6" - integrity sha512-mK6BKLpL0bG6v2CxHbm0ed6RcZrAtTHBTd/ZpnlVPVa3HkumsqLE4BC4u6TQ8D7pnrRbOU0am6epuALs+Ncnzw== +"@types/node@^16.4.0": + version "16.18.60" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.60.tgz#0b0f4316906f1bd0e03b640363f67bd4e86958bd" + integrity sha512-ZUGPWx5vKfN+G2/yN7pcSNLkIkXEvlwNaJEd4e0ppX7W2S8XAkdc/37hM4OUNJB9sa0p12AOvGvxL4JCPiz9DA== "@types/pbkdf2@^3.0.0": version "3.1.0" @@ -2349,6 +2362,11 @@ ansi-regex@^5.0.1: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== +ansi-sequence-parser@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ansi-sequence-parser/-/ansi-sequence-parser-1.1.1.tgz#e0aa1cdcbc8f8bb0b5bca625aac41f5f056973cf" + integrity sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg== + ansi-styles@^3.2.0, ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -2720,6 +2738,13 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + braces@^3.0.1, braces@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" @@ -4841,6 +4866,18 @@ growl@1.10.5: resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== +handlebars@^4.7.7: + version "4.7.8" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.8.tgz#41c42c18b1be2365439188c77c6afae71c0cd9e9" + integrity sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ== + dependencies: + minimist "^1.2.5" + neo-async "^2.6.2" + source-map "^0.6.1" + wordwrap "^1.0.0" + optionalDependencies: + uglify-js "^3.1.4" + har-schema@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" @@ -5399,6 +5436,11 @@ json-text-sequence@^0.1: dependencies: delimit-stream "0.1.0" +jsonc-parser@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.2.0.tgz#31ff3f4c2b9793f89c67212627c51c6394f88e76" + integrity sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w== + jsonfile@^2.1.0: version "2.4.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" @@ -5687,6 +5729,11 @@ ltgt@~2.2.0: resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.2.1.tgz#f35ca91c493f7b73da0e07495304f17b31f87ee5" integrity sha1-81ypHEk/e3PaDgdJUwTxezH4fuU= +lunr@^2.3.9: + version "2.3.9" + resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1" + integrity sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow== + make-dir@^1.0.0: version "1.3.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" @@ -5699,6 +5746,11 @@ make-error@^1.1.1: resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== +marked@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/marked/-/marked-4.3.0.tgz#796362821b019f734054582038b116481b456cf3" + integrity sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A== + mcl-wasm@^0.7.1: version "0.7.9" resolved "https://registry.yarnpkg.com/mcl-wasm/-/mcl-wasm-0.7.9.tgz#c1588ce90042a8700c3b60e40efb339fc07ab87f" @@ -5829,6 +5881,13 @@ minimatch@3.0.4, minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" +minimatch@^9.0.3: + version "9.0.3" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.3.tgz#a6e00c3de44c3a542bfaae70abfc22420a6da825" + integrity sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg== + dependencies: + brace-expansion "^2.0.1" + minimist@^1.2.5, minimist@^1.2.6: version "1.2.6" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" @@ -6029,6 +6088,11 @@ negotiator@0.6.3: resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== +neo-async@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" + integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== + next-tick@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb" @@ -7000,6 +7064,16 @@ shebang-regex@^3.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== +shiki@^0.14.1: + version "0.14.5" + resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.14.5.tgz#375dd214e57eccb04f0daf35a32aa615861deb93" + integrity sha512-1gCAYOcmCFONmErGTrS1fjzJLA7MGZmKzrBNX7apqSwhyITJg2O102uFzXUeBxNnEkDA9vHIKLyeKq0V083vIw== + dependencies: + ansi-sequence-parser "^1.1.0" + jsonc-parser "^3.2.0" + vscode-oniguruma "^1.7.0" + vscode-textmate "^8.0.0" + side-channel@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" @@ -7075,7 +7149,7 @@ source-map-support@^0.5.17: buffer-from "^1.0.0" source-map "^0.6.0" -source-map@^0.6.0: +source-map@^0.6.0, source-map@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== @@ -7490,12 +7564,12 @@ ts-essentials@^7.0.1: resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-7.0.3.tgz#686fd155a02133eedcc5362dc8b5056cde3e5a38" integrity sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ== -ts-node@^10.1.0: - version "10.4.0" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.4.0.tgz#680f88945885f4e6cf450e7f0d6223dd404895f7" - integrity sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A== +ts-node@^10.8.0: + version "10.9.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" + integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw== dependencies: - "@cspotcode/source-map-support" "0.7.0" + "@cspotcode/source-map-support" "^0.8.0" "@tsconfig/node10" "^1.0.7" "@tsconfig/node12" "^1.0.7" "@tsconfig/node14" "^1.0.0" @@ -7506,6 +7580,7 @@ ts-node@^10.1.0: create-require "^1.1.0" diff "^4.0.1" make-error "^1.1.1" + v8-compile-cache-lib "^3.0.1" yn "3.1.1" ts-node@^8.4.1: @@ -7622,6 +7697,23 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" +typedoc-plugin-markdown@^3.17.0: + version "3.17.0" + resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.17.0.tgz#f4820efadcac80d0e04c2d3eb67a8cf616477923" + integrity sha512-+uh5fHNfNSGdUxae0FWOuJ8Xu9Sl08jkdshOg6dilAqN/ZXmYsUFFDKw70fYfiGxdCLvpUuyr9FYO+WAa2lHeA== + dependencies: + handlebars "^4.7.7" + +typedoc@^0.25.3: + version "0.25.3" + resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.25.3.tgz#53c6d668e1001b3d488e9a750fcdfb05433554c0" + integrity sha512-Ow8Bo7uY1Lwy7GTmphRIMEo6IOZ+yYUyrc8n5KXIZg1svpqhZSWgni2ZrDhe+wLosFS8yswowUzljTAV/3jmWw== + dependencies: + lunr "^2.3.9" + marked "^4.3.0" + minimatch "^9.0.3" + shiki "^0.14.1" + typeforce@^1.11.3, typeforce@^1.11.5, typeforce@^1.18.0: version "1.18.0" resolved "https://registry.yarnpkg.com/typeforce/-/typeforce-1.18.0.tgz#d7416a2c5845e085034d70fcc5b6cc4a90edbfdc" @@ -7632,10 +7724,10 @@ typescript@^3.6.4: resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8" integrity sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q== -typescript@^4.3.5: - version "4.5.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.4.tgz#a17d3a0263bf5c8723b9c52f43c5084edf13c2e8" - integrity sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg== +typescript@^4.6.0: + version "4.9.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" + integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== typical@^4.0.0: version "4.0.0" @@ -7647,6 +7739,11 @@ typical@^5.2.0: resolved "https://registry.yarnpkg.com/typical/-/typical-5.2.0.tgz#4daaac4f2b5315460804f0acf6cb69c52bb93066" integrity sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg== +uglify-js@^3.1.4: + version "3.17.4" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" + integrity sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g== + ultron@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c" @@ -7790,6 +7887,11 @@ uuid@^3.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== +v8-compile-cache-lib@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" + integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== + v8-compile-cache@^2.0.3: version "2.3.0" resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" @@ -7829,6 +7931,16 @@ verror@1.10.0: core-util-is "1.0.2" extsprintf "^1.2.0" +vscode-oniguruma@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz#439bfad8fe71abd7798338d1cd3dc53a8beea94b" + integrity sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA== + +vscode-textmate@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-8.0.0.tgz#2c7a3b1163ef0441097e0b5d6389cd5504b59e5d" + integrity sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg== + web3-bzz@1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/web3-bzz/-/web3-bzz-1.2.2.tgz#a3b9f613c49fd3e120e0997088a73557d5adb724" @@ -8670,6 +8782,11 @@ word-wrap@^1.2.3: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== +wordwrap@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" + integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q== + wordwrapjs@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-4.0.1.tgz#d9790bccfb110a0fc7836b5ebce0937b37a8b98f"