diff --git a/typescript/api-reference/README.md b/typescript/api-reference/README.md index 1f7650455..724fdbf21 100644 --- a/typescript/api-reference/README.md +++ b/typescript/api-reference/README.md @@ -19,6 +19,7 @@ - [BaseL2BitcoinDepositor](classes/BaseL2BitcoinDepositor.md) - [BaseL2TBTCToken](classes/BaseL2TBTCToken.md) - [BitcoinTxHash](classes/BitcoinTxHash.md) +- [CrossChainDepositor](classes/CrossChainDepositor.md) - [Deposit](classes/Deposit.md) - [DepositFunding](classes/DepositFunding.md) - [DepositRefund](classes/DepositRefund.md) @@ -78,6 +79,7 @@ - [BitcoinUtxo](README.md#bitcoinutxo) - [ChainMapping](README.md#chainmapping) - [CrossChainContracts](README.md#crosschaincontracts) +- [CrossChainDepositorMode](README.md#crosschaindepositormode) - [DepositRevealedEvent](README.md#depositrevealedevent) - [DkgResultApprovedEvent](README.md#dkgresultapprovedevent) - [DkgResultChallengedEvent](README.md#dkgresultchallengedevent) @@ -188,6 +190,23 @@ between TBTC L1 ledger chain and a specific supported L2/side-chain. ___ +### CrossChainDepositorMode + +Ƭ **CrossChainDepositorMode**: ``"L2Transaction"`` \| ``"L1Transaction"`` + +Mode of operation for the cross-chain depositor proxy: +- [L2Transaction]: The proxy will reveal the deposit using a transaction on + the L2 chain. The tBTC system is responsible for relaying the deposit to + the tBTC L1 chain. +- [L1Transaction]: The proxy will directly reveal the deposit using a + transaction on the tBTC L1 chain. + +#### Defined in + +[src/services/deposits/cross-chain.ts:19](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/cross-chain.ts#L19) + +___ + ### DepositRevealedEvent Ƭ **DepositRevealedEvent**: [`DepositReceipt`](interfaces/DepositReceipt.md) & `Pick`\<[`DepositRequest`](interfaces/DepositRequest.md), ``"amount"`` \| ``"vault"``\> & \{ `fundingOutputIndex`: `number` ; `fundingTxHash`: [`BitcoinTxHash`](classes/BitcoinTxHash.md) } & [`ChainEvent`](interfaces/ChainEvent.md) diff --git a/typescript/api-reference/classes/BaseL2BitcoinDepositor.md b/typescript/api-reference/classes/BaseL2BitcoinDepositor.md new file mode 100644 index 000000000..b02ea4910 --- /dev/null +++ b/typescript/api-reference/classes/BaseL2BitcoinDepositor.md @@ -0,0 +1,307 @@ +# Class: BaseL2BitcoinDepositor + +Implementation of the Base L2BitcoinDepositor handle. + +**`See`** + +for reference. + +## Hierarchy + +- `EthersContractHandle`\<`L2BitcoinDepositorTypechain`\> + + ↳ **`BaseL2BitcoinDepositor`** + +## Implements + +- [`L2BitcoinDepositor`](../interfaces/L2BitcoinDepositor.md) + +## Table of contents + +### Constructors + +- [constructor](BaseL2BitcoinDepositor.md#constructor) + +### Properties + +- [#depositOwner](BaseL2BitcoinDepositor.md##depositowner) +- [#extraDataEncoder](BaseL2BitcoinDepositor.md##extradataencoder) +- [\_deployedAtBlockNumber](BaseL2BitcoinDepositor.md#_deployedatblocknumber) +- [\_instance](BaseL2BitcoinDepositor.md#_instance) +- [\_totalRetryAttempts](BaseL2BitcoinDepositor.md#_totalretryattempts) + +### Methods + +- [extraDataEncoder](BaseL2BitcoinDepositor.md#extradataencoder) +- [getAddress](BaseL2BitcoinDepositor.md#getaddress) +- [getChainIdentifier](BaseL2BitcoinDepositor.md#getchainidentifier) +- [getDepositOwner](BaseL2BitcoinDepositor.md#getdepositowner) +- [getEvents](BaseL2BitcoinDepositor.md#getevents) +- [initializeDeposit](BaseL2BitcoinDepositor.md#initializedeposit) +- [setDepositOwner](BaseL2BitcoinDepositor.md#setdepositowner) + +## Constructors + +### constructor + +• **new BaseL2BitcoinDepositor**(`config`, `chainId`): [`BaseL2BitcoinDepositor`](BaseL2BitcoinDepositor.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | [`EthereumContractConfig`](../interfaces/EthereumContractConfig.md) | +| `chainId` | [`Base`](../enums/Chains.Base.md) | + +#### Returns + +[`BaseL2BitcoinDepositor`](BaseL2BitcoinDepositor.md) + +#### Overrides + +EthersContractHandle\<L2BitcoinDepositorTypechain\>.constructor + +#### Defined in + +[src/lib/base/l2-bitcoin-depositor.ts:37](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/base/l2-bitcoin-depositor.ts#L37) + +## Properties + +### #depositOwner + +• `Private` **#depositOwner**: `undefined` \| [`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +#### Defined in + +[src/lib/base/l2-bitcoin-depositor.ts:35](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/base/l2-bitcoin-depositor.ts#L35) + +___ + +### #extraDataEncoder + +• `Private` `Readonly` **#extraDataEncoder**: [`CrossChainExtraDataEncoder`](../interfaces/CrossChainExtraDataEncoder.md) + +#### Defined in + +[src/lib/base/l2-bitcoin-depositor.ts:34](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/base/l2-bitcoin-depositor.ts#L34) + +___ + +### \_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 + +[src/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**: `L2BitcoinDepositor` + +Ethers instance of the deployed contract. + +#### Inherited from + +EthersContractHandle.\_instance + +#### Defined in + +[src/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 + +[src/lib/ethereum/adapter.ts:84](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L84) + +## Methods + +### extraDataEncoder + +▸ **extraDataEncoder**(): [`CrossChainExtraDataEncoder`](../interfaces/CrossChainExtraDataEncoder.md) + +#### Returns + +[`CrossChainExtraDataEncoder`](../interfaces/CrossChainExtraDataEncoder.md) + +**`See`** + +#### Implementation of + +[L2BitcoinDepositor](../interfaces/L2BitcoinDepositor.md).[extraDataEncoder](../interfaces/L2BitcoinDepositor.md#extradataencoder) + +#### Defined in + +[src/lib/base/l2-bitcoin-depositor.ts:85](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/base/l2-bitcoin-depositor.ts#L85) + +___ + +### 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 + +[src/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 + +[L2BitcoinDepositor](../interfaces/L2BitcoinDepositor.md).[getChainIdentifier](../interfaces/L2BitcoinDepositor.md#getchainidentifier) + +#### Defined in + +[src/lib/base/l2-bitcoin-depositor.ts:61](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/base/l2-bitcoin-depositor.ts#L61) + +___ + +### getDepositOwner + +▸ **getDepositOwner**(): `undefined` \| [`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +#### Returns + +`undefined` \| [`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +**`See`** + +#### Implementation of + +[L2BitcoinDepositor](../interfaces/L2BitcoinDepositor.md).[getDepositOwner](../interfaces/L2BitcoinDepositor.md#getdepositowner) + +#### Defined in + +[src/lib/base/l2-bitcoin-depositor.ts:69](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/base/l2-bitcoin-depositor.ts#L69) + +___ + +### 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](BaseL2BitcoinDepositor.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 + +[src/lib/ethereum/adapter.ts:127](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L127) + +___ + +### initializeDeposit + +▸ **initializeDeposit**(`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 + +[L2BitcoinDepositor](../interfaces/L2BitcoinDepositor.md).[initializeDeposit](../interfaces/L2BitcoinDepositor.md#initializedeposit) + +#### Defined in + +[src/lib/base/l2-bitcoin-depositor.ts:93](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/base/l2-bitcoin-depositor.ts#L93) + +___ + +### setDepositOwner + +▸ **setDepositOwner**(`depositOwner`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `depositOwner` | `undefined` \| [`ChainIdentifier`](../interfaces/ChainIdentifier.md) | + +#### Returns + +`void` + +**`See`** + +#### Implementation of + +[L2BitcoinDepositor](../interfaces/L2BitcoinDepositor.md).[setDepositOwner](../interfaces/L2BitcoinDepositor.md#setdepositowner) + +#### Defined in + +[src/lib/base/l2-bitcoin-depositor.ts:77](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/base/l2-bitcoin-depositor.ts#L77) diff --git a/typescript/api-reference/classes/BaseL2TBTCToken.md b/typescript/api-reference/classes/BaseL2TBTCToken.md new file mode 100644 index 000000000..069905dc4 --- /dev/null +++ b/typescript/api-reference/classes/BaseL2TBTCToken.md @@ -0,0 +1,213 @@ +# Class: BaseL2TBTCToken + +Implementation of the Base L2TBTCToken handle. + +**`See`** + +for reference. + +## Hierarchy + +- `EthersContractHandle`\<`L2TBTCTypechain`\> + + ↳ **`BaseL2TBTCToken`** + +## Implements + +- [`L2TBTCToken`](../interfaces/L2TBTCToken.md) + +## Table of contents + +### Constructors + +- [constructor](BaseL2TBTCToken.md#constructor) + +### Properties + +- [\_deployedAtBlockNumber](BaseL2TBTCToken.md#_deployedatblocknumber) +- [\_instance](BaseL2TBTCToken.md#_instance) +- [\_totalRetryAttempts](BaseL2TBTCToken.md#_totalretryattempts) + +### Methods + +- [balanceOf](BaseL2TBTCToken.md#balanceof) +- [getAddress](BaseL2TBTCToken.md#getaddress) +- [getChainIdentifier](BaseL2TBTCToken.md#getchainidentifier) +- [getEvents](BaseL2TBTCToken.md#getevents) + +## Constructors + +### constructor + +• **new BaseL2TBTCToken**(`config`, `chainId`): [`BaseL2TBTCToken`](BaseL2TBTCToken.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | [`EthereumContractConfig`](../interfaces/EthereumContractConfig.md) | +| `chainId` | [`Base`](../enums/Chains.Base.md) | + +#### Returns + +[`BaseL2TBTCToken`](BaseL2TBTCToken.md) + +#### Overrides + +EthersContractHandle\<L2TBTCTypechain\>.constructor + +#### Defined in + +[src/lib/base/l2-tbtc-token.ts:21](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/base/l2-tbtc-token.ts#L21) + +## 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 + +[src/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**: `L2TBTC` + +Ethers instance of the deployed contract. + +#### Inherited from + +EthersContractHandle.\_instance + +#### Defined in + +[src/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 + +[src/lib/ethereum/adapter.ts:84](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L84) + +## Methods + +### balanceOf + +▸ **balanceOf**(`identifier`): `Promise`\<`BigNumber`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `identifier` | [`ChainIdentifier`](../interfaces/ChainIdentifier.md) | + +#### Returns + +`Promise`\<`BigNumber`\> + +**`See`** + +#### Implementation of + +[L2TBTCToken](../interfaces/L2TBTCToken.md).[balanceOf](../interfaces/L2TBTCToken.md#balanceof) + +#### Defined in + +[src/lib/base/l2-tbtc-token.ts:50](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/base/l2-tbtc-token.ts#L50) + +___ + +### 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 + +[src/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 + +[L2TBTCToken](../interfaces/L2TBTCToken.md).[getChainIdentifier](../interfaces/L2TBTCToken.md#getchainidentifier) + +#### Defined in + +[src/lib/base/l2-tbtc-token.ts:42](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/base/l2-tbtc-token.ts#L42) + +___ + +### 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](BaseL2BitcoinDepositor.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 + +[src/lib/ethereum/adapter.ts:127](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L127) diff --git a/typescript/api-reference/classes/CrossChainDepositor.md b/typescript/api-reference/classes/CrossChainDepositor.md new file mode 100644 index 000000000..ddc99c141 --- /dev/null +++ b/typescript/api-reference/classes/CrossChainDepositor.md @@ -0,0 +1,172 @@ +# Class: CrossChainDepositor + +Implementation of the cross chain depositor proxy. This component is used to +reveal cross-chain deposits whose target chain is not the same as the L1 +chain the tBTC system is deployed on. + +**`See`** + +for reference. + +## Implements + +- [`DepositorProxy`](../interfaces/DepositorProxy.md) + +## Table of contents + +### Constructors + +- [constructor](CrossChainDepositor.md#constructor) + +### Properties + +- [#crossChainContracts](CrossChainDepositor.md##crosschaincontracts) +- [#revealMode](CrossChainDepositor.md##revealmode) + +### Methods + +- [#extraDataEncoder](CrossChainDepositor.md##extradataencoder) +- [extraData](CrossChainDepositor.md#extradata) +- [getChainIdentifier](CrossChainDepositor.md#getchainidentifier) +- [revealDeposit](CrossChainDepositor.md#revealdeposit) + +## Constructors + +### constructor + +• **new CrossChainDepositor**(`crossChainContracts`, `revealMode?`): [`CrossChainDepositor`](CrossChainDepositor.md) + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `crossChainContracts` | [`CrossChainContracts`](../README.md#crosschaincontracts) | `undefined` | +| `revealMode` | [`CrossChainDepositorMode`](../README.md#crosschaindepositormode) | `"L2Transaction"` | + +#### Returns + +[`CrossChainDepositor`](CrossChainDepositor.md) + +#### Defined in + +[src/services/deposits/cross-chain.ts:31](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/cross-chain.ts#L31) + +## Properties + +### #crossChainContracts + +• `Private` `Readonly` **#crossChainContracts**: [`CrossChainContracts`](../README.md#crosschaincontracts) + +#### Defined in + +[src/services/deposits/cross-chain.ts:28](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/cross-chain.ts#L28) + +___ + +### #revealMode + +• `Private` `Readonly` **#revealMode**: [`CrossChainDepositorMode`](../README.md#crosschaindepositormode) + +#### Defined in + +[src/services/deposits/cross-chain.ts:29](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/cross-chain.ts#L29) + +## Methods + +### #extraDataEncoder + +▸ **#extraDataEncoder**(): [`CrossChainExtraDataEncoder`](../interfaces/CrossChainExtraDataEncoder.md) + +#### Returns + +[`CrossChainExtraDataEncoder`](../interfaces/CrossChainExtraDataEncoder.md) + +#### Defined in + +[src/services/deposits/cross-chain.ts:72](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/cross-chain.ts#L72) + +___ + +### extraData + +▸ **extraData**(): [`Hex`](Hex.md) + +#### Returns + +[`Hex`](Hex.md) + +Extra data for the cross-chain deposit script. Actually, this is + the L2 deposit owner identifier took from the L2BitcoinDepositor + contract. + +**`Throws`** + +Throws if the L2 deposit owner cannot be resolved. This + typically happens if the L2BitcoinDepositor operates with + a read-only signer whose address cannot be resolved. + +#### Defined in + +[src/services/deposits/cross-chain.ts:61](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/cross-chain.ts#L61) + +___ + +### getChainIdentifier + +▸ **getChainIdentifier**(): [`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +#### Returns + +[`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +The chain-specific identifier of the contract that will be + used as the actual L1 depositor embedded in the deposit script. + In this case, the depositor must be the L1BitcoinDepositor contract + corresponding to the given L2 chain the deposit is targeting. + This is because the L1BitcoinDepositor contract reveals the deposit to + the Bridge contract (on L1) and transfers minted TBTC token to the + target L2 chain once the deposit is processed. + +**`See`** + +#### Implementation of + +[DepositorProxy](../interfaces/DepositorProxy.md).[getChainIdentifier](../interfaces/DepositorProxy.md#getchainidentifier) + +#### Defined in + +[src/services/deposits/cross-chain.ts:49](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/cross-chain.ts#L49) + +___ + +### revealDeposit + +▸ **revealDeposit**(`depositTx`, `depositOutputIndex`, `deposit`, `vault?`): `Promise`\<[`Hex`](Hex.md)\> + +Reveals the given deposit depending on the reveal mode. + +#### 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`** + + - for reveal modes description. + - + +#### Implementation of + +[DepositorProxy](../interfaces/DepositorProxy.md).[revealDeposit](../interfaces/DepositorProxy.md#revealdeposit) + +#### Defined in + +[src/services/deposits/cross-chain.ts:87](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/cross-chain.ts#L87) diff --git a/typescript/api-reference/classes/EthereumCrossChainExtraDataEncoder.md b/typescript/api-reference/classes/EthereumCrossChainExtraDataEncoder.md new file mode 100644 index 000000000..370e78311 --- /dev/null +++ b/typescript/api-reference/classes/EthereumCrossChainExtraDataEncoder.md @@ -0,0 +1,84 @@ +# Class: EthereumCrossChainExtraDataEncoder + +Implementation of the Ethereum CrossChainExtraDataEncoder. + +**`See`** + +for reference. + +## Implements + +- [`CrossChainExtraDataEncoder`](../interfaces/CrossChainExtraDataEncoder.md) + +## Table of contents + +### Constructors + +- [constructor](EthereumCrossChainExtraDataEncoder.md#constructor) + +### Methods + +- [decodeDepositOwner](EthereumCrossChainExtraDataEncoder.md#decodedepositowner) +- [encodeDepositOwner](EthereumCrossChainExtraDataEncoder.md#encodedepositowner) + +## Constructors + +### constructor + +• **new EthereumCrossChainExtraDataEncoder**(): [`EthereumCrossChainExtraDataEncoder`](EthereumCrossChainExtraDataEncoder.md) + +#### Returns + +[`EthereumCrossChainExtraDataEncoder`](EthereumCrossChainExtraDataEncoder.md) + +## Methods + +### decodeDepositOwner + +▸ **decodeDepositOwner**(`extraData`): [`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `extraData` | [`Hex`](Hex.md) | + +#### Returns + +[`ChainIdentifier`](../interfaces/ChainIdentifier.md) + +**`See`** + +#### Implementation of + +[CrossChainExtraDataEncoder](../interfaces/CrossChainExtraDataEncoder.md).[decodeDepositOwner](../interfaces/CrossChainExtraDataEncoder.md#decodedepositowner) + +#### Defined in + +[src/lib/ethereum/l1-bitcoin-depositor.ts:154](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/l1-bitcoin-depositor.ts#L154) + +___ + +### encodeDepositOwner + +▸ **encodeDepositOwner**(`depositOwner`): [`Hex`](Hex.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `depositOwner` | [`ChainIdentifier`](../interfaces/ChainIdentifier.md) | + +#### Returns + +[`Hex`](Hex.md) + +**`See`** + +#### Implementation of + +[CrossChainExtraDataEncoder](../interfaces/CrossChainExtraDataEncoder.md).[encodeDepositOwner](../interfaces/CrossChainExtraDataEncoder.md#encodedepositowner) + +#### Defined in + +[src/lib/ethereum/l1-bitcoin-depositor.ts:140](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/l1-bitcoin-depositor.ts#L140) diff --git a/typescript/api-reference/classes/EthereumL1BitcoinDepositor.md b/typescript/api-reference/classes/EthereumL1BitcoinDepositor.md new file mode 100644 index 000000000..b6527dc56 --- /dev/null +++ b/typescript/api-reference/classes/EthereumL1BitcoinDepositor.md @@ -0,0 +1,250 @@ +# Class: EthereumL1BitcoinDepositor + +Implementation of the Ethereum L1BitcoinDepositor handle. It can be +constructed for each supported L2 chain. + +**`See`** + +for reference. + +## Hierarchy + +- `EthersContractHandle`\<`L1BitcoinDepositorTypechain`\> + + ↳ **`EthereumL1BitcoinDepositor`** + +## Implements + +- [`L1BitcoinDepositor`](../interfaces/L1BitcoinDepositor.md) + +## Table of contents + +### Constructors + +- [constructor](EthereumL1BitcoinDepositor.md#constructor) + +### Properties + +- [#extraDataEncoder](EthereumL1BitcoinDepositor.md##extradataencoder) +- [\_deployedAtBlockNumber](EthereumL1BitcoinDepositor.md#_deployedatblocknumber) +- [\_instance](EthereumL1BitcoinDepositor.md#_instance) +- [\_totalRetryAttempts](EthereumL1BitcoinDepositor.md#_totalretryattempts) + +### Methods + +- [extraDataEncoder](EthereumL1BitcoinDepositor.md#extradataencoder) +- [getAddress](EthereumL1BitcoinDepositor.md#getaddress) +- [getChainIdentifier](EthereumL1BitcoinDepositor.md#getchainidentifier) +- [getEvents](EthereumL1BitcoinDepositor.md#getevents) +- [initializeDeposit](EthereumL1BitcoinDepositor.md#initializedeposit) + +## Constructors + +### constructor + +• **new EthereumL1BitcoinDepositor**(`config`, `chainId`, `l2ChainName`): [`EthereumL1BitcoinDepositor`](EthereumL1BitcoinDepositor.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | [`EthereumContractConfig`](../interfaces/EthereumContractConfig.md) | +| `chainId` | [`Ethereum`](../enums/Chains.Ethereum.md) | +| `l2ChainName` | ``"Base"`` | + +#### Returns + +[`EthereumL1BitcoinDepositor`](EthereumL1BitcoinDepositor.md) + +#### Overrides + +EthersContractHandle\<L1BitcoinDepositorTypechain\>.constructor + +#### Defined in + +[src/lib/ethereum/l1-bitcoin-depositor.ts:55](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/l1-bitcoin-depositor.ts#L55) + +## Properties + +### #extraDataEncoder + +• `Private` `Readonly` **#extraDataEncoder**: [`CrossChainExtraDataEncoder`](../interfaces/CrossChainExtraDataEncoder.md) + +#### Defined in + +[src/lib/ethereum/l1-bitcoin-depositor.ts:53](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/l1-bitcoin-depositor.ts#L53) + +___ + +### \_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 + +[src/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**: `L1BitcoinDepositor` + +Ethers instance of the deployed contract. + +#### Inherited from + +EthersContractHandle.\_instance + +#### Defined in + +[src/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 + +[src/lib/ethereum/adapter.ts:84](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L84) + +## Methods + +### extraDataEncoder + +▸ **extraDataEncoder**(): [`CrossChainExtraDataEncoder`](../interfaces/CrossChainExtraDataEncoder.md) + +#### Returns + +[`CrossChainExtraDataEncoder`](../interfaces/CrossChainExtraDataEncoder.md) + +**`See`** + +#### Implementation of + +[L1BitcoinDepositor](../interfaces/L1BitcoinDepositor.md).[extraDataEncoder](../interfaces/L1BitcoinDepositor.md#extradataencoder) + +#### Defined in + +[src/lib/ethereum/l1-bitcoin-depositor.ts:90](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/l1-bitcoin-depositor.ts#L90) + +___ + +### 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 + +[src/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 + +[L1BitcoinDepositor](../interfaces/L1BitcoinDepositor.md).[getChainIdentifier](../interfaces/L1BitcoinDepositor.md#getchainidentifier) + +#### Defined in + +[src/lib/ethereum/l1-bitcoin-depositor.ts:82](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/l1-bitcoin-depositor.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](BaseL2BitcoinDepositor.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 + +[src/lib/ethereum/adapter.ts:127](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/adapter.ts#L127) + +___ + +### initializeDeposit + +▸ **initializeDeposit**(`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 + +[L1BitcoinDepositor](../interfaces/L1BitcoinDepositor.md).[initializeDeposit](../interfaces/L1BitcoinDepositor.md#initializedeposit) + +#### Defined in + +[src/lib/ethereum/l1-bitcoin-depositor.ts:98](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/l1-bitcoin-depositor.ts#L98) diff --git a/typescript/api-reference/enums/Chains.Base.md b/typescript/api-reference/enums/Chains.Base.md new file mode 100644 index 000000000..535d23c8f --- /dev/null +++ b/typescript/api-reference/enums/Chains.Base.md @@ -0,0 +1,30 @@ +# Enumeration: Base + +[Chains](../modules/Chains.md).Base + +## Table of contents + +### Enumeration Members + +- [Base](Chains.Base.md#base) +- [BaseSepolia](Chains.Base.md#basesepolia) + +## Enumeration Members + +### Base + +• **Base** = ``"8453"`` + +#### Defined in + +[src/lib/contracts/chain.ts:13](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain.ts#L13) + +___ + +### BaseSepolia + +• **BaseSepolia** = ``"84532"`` + +#### Defined in + +[src/lib/contracts/chain.ts:14](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain.ts#L14) diff --git a/typescript/api-reference/enums/Chains.Ethereum.md b/typescript/api-reference/enums/Chains.Ethereum.md new file mode 100644 index 000000000..88dc17e11 --- /dev/null +++ b/typescript/api-reference/enums/Chains.Ethereum.md @@ -0,0 +1,41 @@ +# Enumeration: Ethereum + +[Chains](../modules/Chains.md).Ethereum + +## Table of contents + +### Enumeration Members + +- [Local](Chains.Ethereum.md#local) +- [Mainnet](Chains.Ethereum.md#mainnet) +- [Sepolia](Chains.Ethereum.md#sepolia) + +## Enumeration Members + +### Local + +• **Local** = ``"1101"`` + +#### Defined in + +[src/lib/contracts/chain.ts:9](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain.ts#L9) + +___ + +### Mainnet + +• **Mainnet** = ``"1"`` + +#### Defined in + +[src/lib/contracts/chain.ts:7](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain.ts#L7) + +___ + +### Sepolia + +• **Sepolia** = ``"11155111"`` + +#### Defined in + +[src/lib/contracts/chain.ts:8](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/chain.ts#L8) diff --git a/typescript/api-reference/interfaces/CrossChainContractsLoader.md b/typescript/api-reference/interfaces/CrossChainContractsLoader.md new file mode 100644 index 000000000..4fea39457 --- /dev/null +++ b/typescript/api-reference/interfaces/CrossChainContractsLoader.md @@ -0,0 +1,58 @@ +# Interface: CrossChainContractsLoader + +Interface for loading TBTC cross-chain contracts for a specific L2 chain. +It should be implemented for each supported L1 chain tBTC ledger is deployed +on. + +## Table of contents + +### Properties + +- [loadChainMapping](CrossChainContractsLoader.md#loadchainmapping) +- [loadL1Contracts](CrossChainContractsLoader.md#loadl1contracts) + +## Properties + +### loadChainMapping + +• **loadChainMapping**: () => `undefined` \| [`ChainMapping`](../README.md#chainmapping) + +#### Type declaration + +▸ (): `undefined` \| [`ChainMapping`](../README.md#chainmapping) + +Loads the chain mapping based on underlying L1 chain. + +##### Returns + +`undefined` \| [`ChainMapping`](../README.md#chainmapping) + +#### Defined in + +[src/lib/contracts/cross-chain.ts:38](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L38) + +___ + +### loadL1Contracts + +• **loadL1Contracts**: (`l2ChainName`: ``"Base"``) => `Promise`\<[`L1CrossChainContracts`](../README.md#l1crosschaincontracts)\> + +#### Type declaration + +▸ (`l2ChainName`): `Promise`\<[`L1CrossChainContracts`](../README.md#l1crosschaincontracts)\> + +Loads L1-specific TBTC cross-chain contracts for the given L2 chain. + +##### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `l2ChainName` | ``"Base"`` | Name of the L2 chain for which to load L1 contracts. | + +##### Returns + +`Promise`\<[`L1CrossChainContracts`](../README.md#l1crosschaincontracts)\> + +#### Defined in + +[src/lib/contracts/cross-chain.ts:43](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L43) diff --git a/typescript/api-reference/interfaces/CrossChainExtraDataEncoder.md b/typescript/api-reference/interfaces/CrossChainExtraDataEncoder.md new file mode 100644 index 000000000..469a518e7 --- /dev/null +++ b/typescript/api-reference/interfaces/CrossChainExtraDataEncoder.md @@ -0,0 +1,63 @@ +# Interface: CrossChainExtraDataEncoder + +Interface for encoding and decoding the extra data included in the +cross-chain deposit script. + +## Implemented by + +- [`EthereumCrossChainExtraDataEncoder`](../classes/EthereumCrossChainExtraDataEncoder.md) + +## Table of contents + +### Methods + +- [decodeDepositOwner](CrossChainExtraDataEncoder.md#decodedepositowner) +- [encodeDepositOwner](CrossChainExtraDataEncoder.md#encodedepositowner) + +## Methods + +### decodeDepositOwner + +▸ **decodeDepositOwner**(`extraData`): [`ChainIdentifier`](ChainIdentifier.md) + +Decodes the extra data into the deposit owner identifier. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `extraData` | [`Hex`](../classes/Hex.md) | Extra data to decode. | + +#### Returns + +[`ChainIdentifier`](ChainIdentifier.md) + +Identifier of the deposit owner. + +#### Defined in + +[src/lib/contracts/cross-chain.ts:165](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L165) + +___ + +### encodeDepositOwner + +▸ **encodeDepositOwner**(`depositOwner`): [`Hex`](../classes/Hex.md) + +Encodes the given deposit owner identifier into the extra data. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `depositOwner` | [`ChainIdentifier`](ChainIdentifier.md) | Identifier of the deposit owner to encode. For cross-chain deposits, the deposit owner is typically an identifier on the L2 chain. | + +#### Returns + +[`Hex`](../classes/Hex.md) + +Encoded extra data. + +#### Defined in + +[src/lib/contracts/cross-chain.ts:158](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L158) diff --git a/typescript/api-reference/interfaces/DepositorProxy.md b/typescript/api-reference/interfaces/DepositorProxy.md index 9eba5ed1c..aa694798b 100644 --- a/typescript/api-reference/interfaces/DepositorProxy.md +++ b/typescript/api-reference/interfaces/DepositorProxy.md @@ -10,6 +10,7 @@ optional 32-byte extra data field of the deposit script). ## Implemented by +- [`CrossChainDepositor`](../classes/CrossChainDepositor.md) - [`EthereumDepositorProxy`](../classes/EthereumDepositorProxy.md) ## Table of contents diff --git a/typescript/api-reference/interfaces/L1BitcoinDepositor.md b/typescript/api-reference/interfaces/L1BitcoinDepositor.md new file mode 100644 index 000000000..3f0f01b86 --- /dev/null +++ b/typescript/api-reference/interfaces/L1BitcoinDepositor.md @@ -0,0 +1,76 @@ +# Interface: L1BitcoinDepositor + +Interface for communication with the L1BitcoinDepositor on-chain contract +specific to the given L2 chain, deployed on the L1 chain. + +## Implemented by + +- [`EthereumL1BitcoinDepositor`](../classes/EthereumL1BitcoinDepositor.md) + +## Table of contents + +### Methods + +- [extraDataEncoder](L1BitcoinDepositor.md#extradataencoder) +- [getChainIdentifier](L1BitcoinDepositor.md#getchainidentifier) +- [initializeDeposit](L1BitcoinDepositor.md#initializedeposit) + +## Methods + +### extraDataEncoder + +▸ **extraDataEncoder**(): [`CrossChainExtraDataEncoder`](CrossChainExtraDataEncoder.md) + +#### Returns + +[`CrossChainExtraDataEncoder`](CrossChainExtraDataEncoder.md) + +Extra data encoder for this contract. The encoder is used to +encode and decode the extra data included in the cross-chain deposit script. + +#### Defined in + +[src/lib/contracts/cross-chain.ts:126](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L126) + +___ + +### getChainIdentifier + +▸ **getChainIdentifier**(): [`ChainIdentifier`](ChainIdentifier.md) + +Gets the chain-specific identifier of this contract. + +#### Returns + +[`ChainIdentifier`](ChainIdentifier.md) + +#### Defined in + +[src/lib/contracts/cross-chain.ts:120](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L120) + +___ + +### initializeDeposit + +▸ **initializeDeposit**(`depositTx`, `depositOutputIndex`, `deposit`, `vault?`): `Promise`\<[`Hex`](../classes/Hex.md)\> + +Initializes the cross-chain deposit directly on the given L1 chain. + +#### 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 + +[src/lib/contracts/cross-chain.ts:138](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L138) diff --git a/typescript/api-reference/interfaces/L2BitcoinDepositor.md b/typescript/api-reference/interfaces/L2BitcoinDepositor.md new file mode 100644 index 000000000..412f090d3 --- /dev/null +++ b/typescript/api-reference/interfaces/L2BitcoinDepositor.md @@ -0,0 +1,120 @@ +# Interface: L2BitcoinDepositor + +Interface for communication with the L2BitcoinDepositor on-chain contract +deployed on the given L2 chain. + +## Implemented by + +- [`BaseL2BitcoinDepositor`](../classes/BaseL2BitcoinDepositor.md) + +## Table of contents + +### Methods + +- [extraDataEncoder](L2BitcoinDepositor.md#extradataencoder) +- [getChainIdentifier](L2BitcoinDepositor.md#getchainidentifier) +- [getDepositOwner](L2BitcoinDepositor.md#getdepositowner) +- [initializeDeposit](L2BitcoinDepositor.md#initializedeposit) +- [setDepositOwner](L2BitcoinDepositor.md#setdepositowner) + +## Methods + +### extraDataEncoder + +▸ **extraDataEncoder**(): [`CrossChainExtraDataEncoder`](CrossChainExtraDataEncoder.md) + +#### Returns + +[`CrossChainExtraDataEncoder`](CrossChainExtraDataEncoder.md) + +Extra data encoder for this contract. The encoder is used to +encode and decode the extra data included in the cross-chain deposit script. + +#### Defined in + +[src/lib/contracts/cross-chain.ts:92](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L92) + +___ + +### getChainIdentifier + +▸ **getChainIdentifier**(): [`ChainIdentifier`](ChainIdentifier.md) + +Gets the chain-specific identifier of this contract. + +#### Returns + +[`ChainIdentifier`](ChainIdentifier.md) + +#### Defined in + +[src/lib/contracts/cross-chain.ts:72](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L72) + +___ + +### getDepositOwner + +▸ **getDepositOwner**(): `undefined` \| [`ChainIdentifier`](ChainIdentifier.md) + +Gets the identifier that should be used as the owner of the deposits +issued by this contract. + +#### Returns + +`undefined` \| [`ChainIdentifier`](ChainIdentifier.md) + +The identifier of the deposit owner or undefined if not set. + +#### Defined in + +[src/lib/contracts/cross-chain.ts:79](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L79) + +___ + +### initializeDeposit + +▸ **initializeDeposit**(`depositTx`, `depositOutputIndex`, `deposit`, `vault?`): `Promise`\<[`Hex`](../classes/Hex.md)\> + +Initializes the cross-chain deposit indirectly through the given L2 chain. + +#### 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 + +[src/lib/contracts/cross-chain.ts:104](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L104) + +___ + +### setDepositOwner + +▸ **setDepositOwner**(`depositOwner`): `void` + +Sets the identifier that should be used as the owner of the deposits +issued by this contract. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `depositOwner` | [`ChainIdentifier`](ChainIdentifier.md) | Identifier of the deposit owner or undefined to clear. | + +#### Returns + +`void` + +#### Defined in + +[src/lib/contracts/cross-chain.ts:86](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L86) diff --git a/typescript/api-reference/interfaces/L2TBTCToken.md b/typescript/api-reference/interfaces/L2TBTCToken.md new file mode 100644 index 000000000..29db500d8 --- /dev/null +++ b/typescript/api-reference/interfaces/L2TBTCToken.md @@ -0,0 +1,55 @@ +# Interface: L2TBTCToken + +Interface for communication with the on-chain contract of the given +canonical L2 tBTC token. + +## Implemented by + +- [`BaseL2TBTCToken`](../classes/BaseL2TBTCToken.md) + +## Table of contents + +### Methods + +- [balanceOf](L2TBTCToken.md#balanceof) +- [getChainIdentifier](L2TBTCToken.md#getchainidentifier) + +## Methods + +### balanceOf + +▸ **balanceOf**(`identifier`): `Promise`\<`BigNumber`\> + +Returns the balance of the given identifier. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `identifier` | [`ChainIdentifier`](ChainIdentifier.md) | Identifier of the account to get the balance for. | + +#### Returns + +`Promise`\<`BigNumber`\> + +The balance of the given identifier in 1e18 precision. + +#### Defined in + +[src/lib/contracts/cross-chain.ts:61](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L61) + +___ + +### getChainIdentifier + +▸ **getChainIdentifier**(): [`ChainIdentifier`](ChainIdentifier.md) + +Gets the chain-specific identifier of this contract. + +#### Returns + +[`ChainIdentifier`](ChainIdentifier.md) + +#### Defined in + +[src/lib/contracts/cross-chain.ts:54](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/cross-chain.ts#L54) diff --git a/typescript/api-reference/modules/Chains.md b/typescript/api-reference/modules/Chains.md new file mode 100644 index 000000000..c9e37e04b --- /dev/null +++ b/typescript/api-reference/modules/Chains.md @@ -0,0 +1,10 @@ +# Namespace: Chains + +Chains supported by tBTC v2 contracts. + +## Table of contents + +### Enumerations + +- [Base](../enums/Chains.Base.md) +- [Ethereum](../enums/Chains.Ethereum.md)