Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK: Support for depositor proxies #776

Merged
merged 8 commits into from
Jan 19, 2024
67 changes: 57 additions & 10 deletions typescript/api-reference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- [ElectrumClient](classes/ElectrumClient.md)
- [EthereumAddress](classes/EthereumAddress.md)
- [EthereumBridge](classes/EthereumBridge.md)
- [EthereumDepositorProxy](classes/EthereumDepositorProxy.md)
- [EthereumTBTCToken](classes/EthereumTBTCToken.md)
- [EthereumTBTCVault](classes/EthereumTBTCVault.md)
- [EthereumWalletRegistry](classes/EthereumWalletRegistry.md)
Expand Down Expand Up @@ -52,6 +53,7 @@
- [ChainIdentifier](interfaces/ChainIdentifier.md)
- [DepositReceipt](interfaces/DepositReceipt.md)
- [DepositRequest](interfaces/DepositRequest.md)
- [DepositorProxy](interfaces/DepositorProxy.md)
- [ElectrumCredentials](interfaces/ElectrumCredentials.md)
- [EthereumContractConfig](interfaces/EthereumContractConfig.md)
- [RedemptionRequest](interfaces/RedemptionRequest.md)
Expand Down Expand Up @@ -103,6 +105,7 @@
- [ethereumNetworkFromSigner](README.md#ethereumnetworkfromsigner)
- [extractBitcoinRawTxVectors](README.md#extractbitcoinrawtxvectors)
- [loadEthereumContracts](README.md#loadethereumcontracts)
- [packRevealDepositParameters](README.md#packrevealdepositparameters)
- [retryAll](README.md#retryall)
- [skipRetryWhenMatched](README.md#skipretrywhenmatched)
- [toBitcoinJsLibNetwork](README.md#tobitcoinjslibnetwork)
Expand Down Expand Up @@ -144,7 +147,7 @@ Represents an event emitted on deposit reveal to the on-chain bridge.

#### Defined in

[src/lib/contracts/bridge.ts:283](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L283)
[src/lib/contracts/bridge.ts:293](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L293)

___

Expand Down Expand Up @@ -233,7 +236,7 @@ Supported Ethereum networks.

#### Defined in

[src/lib/ethereum/index.ts:76](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L76)
[src/lib/ethereum/index.ts:77](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L77)

___

Expand All @@ -247,7 +250,7 @@ or a Provider that works only in the read-only mode.

#### Defined in

[src/lib/ethereum/index.ts:25](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L25)
[src/lib/ethereum/index.ts:26](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L26)

___

Expand Down Expand Up @@ -285,7 +288,7 @@ Represents an event emitted when new wallet is registered on the on-chain bridge

#### Defined in

[src/lib/contracts/bridge.ts:445](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L445)
[src/lib/contracts/bridge.ts:455](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L455)

___

Expand Down Expand Up @@ -356,7 +359,7 @@ Represents an event emitted on redemption request.

#### Defined in

[src/lib/contracts/bridge.ts:334](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L334)
[src/lib/contracts/bridge.ts:344](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L344)

___

Expand Down Expand Up @@ -407,7 +410,7 @@ Convenience type aggregating all TBTC contracts handles.

#### Defined in

[src/lib/contracts/index.ts:16](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/index.ts#L16)
[src/lib/contracts/index.ts:17](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/index.ts#L17)

## Variables

Expand Down Expand Up @@ -716,7 +719,7 @@ Throws an error if the address of the signer is not a proper

#### Defined in

[src/lib/ethereum/index.ts:63](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L63)
[src/lib/ethereum/index.ts:64](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L64)

___

Expand All @@ -740,7 +743,7 @@ Ethereum network.

#### Defined in

[src/lib/ethereum/index.ts:32](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L32)
[src/lib/ethereum/index.ts:33](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L33)

___

Expand Down Expand Up @@ -796,7 +799,51 @@ Throws an error if the signer's Ethereum network is other than

#### Defined in

[src/lib/ethereum/index.ts:87](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L87)
[src/lib/ethereum/index.ts:88](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/index.ts#L88)

___

### packRevealDepositParameters

▸ **packRevealDepositParameters**(`depositTx`, `depositOutputIndex`, `deposit`, `vault?`): `Object`

Packs deposit parameters to match the ABI of the revealDeposit and
revealDepositWithExtraData functions of the Ethereum Bridge contract.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `depositTx` | [`BitcoinRawTxVectors`](interfaces/BitcoinRawTxVectors.md) | Deposit transaction data |
| `depositOutputIndex` | `number` | Index of the deposit transaction output that funds the revealed deposit |
| `deposit` | [`DepositReceipt`](interfaces/DepositReceipt.md) | Data of the revealed deposit |
| `vault?` | [`ChainIdentifier`](interfaces/ChainIdentifier.md) | Optional parameter denoting the vault the given deposit should be routed to |

#### Returns

`Object`

Packed parameters.

| Name | Type |
| :------ | :------ |
| `extraData` | `undefined` \| `string` |
| `fundingTx` | \{ `inputVector`: `string` ; `locktime`: `string` ; `outputVector`: `string` ; `version`: `string` } |
| `fundingTx.inputVector` | `string` |
| `fundingTx.locktime` | `string` |
| `fundingTx.outputVector` | `string` |
| `fundingTx.version` | `string` |
| `reveal` | \{ `blindingFactor`: `string` ; `fundingOutputIndex`: `number` = depositOutputIndex; `refundLocktime`: `string` ; `refundPubKeyHash`: `string` ; `vault`: `string` ; `walletPubKeyHash`: `string` } |
| `reveal.blindingFactor` | `string` |
| `reveal.fundingOutputIndex` | `number` |
| `reveal.refundLocktime` | `string` |
| `reveal.refundPubKeyHash` | `string` |
| `reveal.vault` | `string` |
| `reveal.walletPubKeyHash` | `string` |

#### Defined in

[src/lib/ethereum/bridge.ts:691](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/ethereum/bridge.ts#L691)

___

Expand Down Expand Up @@ -984,4 +1031,4 @@ This function does not validate the depositor's identifier as its

#### Defined in

[src/lib/contracts/bridge.ts:228](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L228)
[src/lib/contracts/bridge.ts:233](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/lib/contracts/bridge.ts#L233)
37 changes: 26 additions & 11 deletions typescript/api-reference/classes/Deposit.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This component tries to abstract away that complexity.

- [bitcoinClient](Deposit.md#bitcoinclient)
- [bitcoinNetwork](Deposit.md#bitcoinnetwork)
- [depositorProxy](Deposit.md#depositorproxy)
- [script](Deposit.md#script)
- [tbtcContracts](Deposit.md#tbtccontracts)

Expand All @@ -29,7 +30,7 @@ This component tries to abstract away that complexity.

### constructor

• **new Deposit**(`receipt`, `tbtcContracts`, `bitcoinClient`, `bitcoinNetwork`): [`Deposit`](Deposit.md)
• **new Deposit**(`receipt`, `tbtcContracts`, `bitcoinClient`, `bitcoinNetwork`, `depositorProxy?`): [`Deposit`](Deposit.md)

#### Parameters

Expand All @@ -39,14 +40,15 @@ This component tries to abstract away that complexity.
| `tbtcContracts` | [`TBTCContracts`](../README.md#tbtccontracts) |
| `bitcoinClient` | [`BitcoinClient`](../interfaces/BitcoinClient.md) |
| `bitcoinNetwork` | [`BitcoinNetwork`](../enums/BitcoinNetwork-1.md) |
| `depositorProxy?` | [`DepositorProxy`](../interfaces/DepositorProxy.md) |

#### Returns

[`Deposit`](Deposit.md)

#### Defined in

[src/services/deposits/deposit.ts:42](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L42)
[src/services/deposits/deposit.ts:47](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L47)

## Properties

Expand All @@ -58,7 +60,7 @@ Bitcoin client handle.

#### Defined in

[src/services/deposits/deposit.ts:35](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L35)
[src/services/deposits/deposit.ts:36](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L36)

___

Expand All @@ -71,6 +73,18 @@ generated deposit address.

#### Defined in

[src/services/deposits/deposit.ts:45](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L45)

___

### depositorProxy

• `Private` `Optional` `Readonly` **depositorProxy**: [`DepositorProxy`](../interfaces/DepositorProxy.md)

Optional depositor proxy used to initiate minting.

#### Defined in

[src/services/deposits/deposit.ts:40](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L40)

___
Expand All @@ -83,7 +97,7 @@ Bitcoin script corresponding to this deposit.

#### Defined in

[src/services/deposits/deposit.ts:27](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L27)
[src/services/deposits/deposit.ts:28](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L28)

___

Expand All @@ -95,7 +109,7 @@ Handle to tBTC contracts.

#### Defined in

[src/services/deposits/deposit.ts:31](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L31)
[src/services/deposits/deposit.ts:32](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L32)

## Methods

Expand All @@ -116,7 +130,7 @@ Specific UTXOs targeting this deposit. Empty array in case

#### Defined in

[src/services/deposits/deposit.ts:85](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L85)
[src/services/deposits/deposit.ts:99](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L99)

___

Expand All @@ -132,7 +146,7 @@ Bitcoin address corresponding to this deposit.

#### Defined in

[src/services/deposits/deposit.ts:74](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L74)
[src/services/deposits/deposit.ts:88](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L88)

___

Expand All @@ -148,7 +162,7 @@ Receipt corresponding to this deposit.

#### Defined in

[src/services/deposits/deposit.ts:67](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L67)
[src/services/deposits/deposit.ts:81](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L81)

___

Expand Down Expand Up @@ -192,13 +206,13 @@ Throws an error if the funding outpoint was already used to

#### Defined in

[src/services/deposits/deposit.ts:114](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L114)
[src/services/deposits/deposit.ts:128](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L128)

___

### fromReceipt

▸ **fromReceipt**(`receipt`, `tbtcContracts`, `bitcoinClient`): `Promise`\<[`Deposit`](Deposit.md)\>
▸ **fromReceipt**(`receipt`, `tbtcContracts`, `bitcoinClient`, `depositorProxy?`): `Promise`\<[`Deposit`](Deposit.md)\>

#### Parameters

Expand All @@ -207,11 +221,12 @@ ___
| `receipt` | [`DepositReceipt`](../interfaces/DepositReceipt.md) |
| `tbtcContracts` | [`TBTCContracts`](../README.md#tbtccontracts) |
| `bitcoinClient` | [`BitcoinClient`](../interfaces/BitcoinClient.md) |
| `depositorProxy?` | [`DepositorProxy`](../interfaces/DepositorProxy.md) |

#### Returns

`Promise`\<[`Deposit`](Deposit.md)\>

#### Defined in

[src/services/deposits/deposit.ts:54](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L54)
[src/services/deposits/deposit.ts:61](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L61)
14 changes: 7 additions & 7 deletions typescript/api-reference/classes/DepositScript.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ by the target wallet during the deposit sweep process.

#### Defined in

[src/services/deposits/deposit.ts:166](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L166)
[src/services/deposits/deposit.ts:189](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L189)

## Properties

Expand All @@ -56,7 +56,7 @@ and allowing to build a unique deposit script (and address) on Bitcoin chain.

#### Defined in

[src/services/deposits/deposit.ts:159](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L159)
[src/services/deposits/deposit.ts:182](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L182)

___

Expand All @@ -69,7 +69,7 @@ should be a witness P2WSH one. If false, legacy P2SH will be used instead.

#### Defined in

[src/services/deposits/deposit.ts:164](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L164)
[src/services/deposits/deposit.ts:187](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L187)

## Methods

Expand All @@ -93,7 +93,7 @@ Bitcoin address corresponding to this deposit script.

#### Defined in

[src/services/deposits/deposit.ts:228](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L228)
[src/services/deposits/deposit.ts:258](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L258)

___

Expand All @@ -109,7 +109,7 @@ Hashed deposit script as Buffer.

#### Defined in

[src/services/deposits/deposit.ts:183](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L183)
[src/services/deposits/deposit.ts:206](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L206)

___

Expand All @@ -125,7 +125,7 @@ Plain-text deposit script as a hex string.

#### Defined in

[src/services/deposits/deposit.ts:195](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L195)
[src/services/deposits/deposit.ts:218](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L218)

___

Expand All @@ -146,4 +146,4 @@ ___

#### Defined in

[src/services/deposits/deposit.ts:173](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L173)
[src/services/deposits/deposit.ts:196](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/deposits/deposit.ts#L196)
Loading