Skip to content

Commit

Permalink
TSDK-776 Fix redemption problem (#7)
Browse files Browse the repository at this point in the history
* TSDK-776 Fix redemption problem

* TSDK-776 Change port to 4000

* TSDK-776 Update brambl-cli version

* TSDK-776 Fix port

* TSDK-776 Fix port (bis)

* TSDK-776 Fix port (bis bis)

* TSDK-776 Remove extra logs
  • Loading branch information
mundacho committed Apr 9, 2024
1 parent 2ad0c11 commit 332a9cc
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sbt_checkPR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
image: ghcr.io/topl/topl-btc-bridge:latest
#
ports:
- 3000:3000
- 4000:4000
options: --name topl_bridge
volumes:
- ${{ github.workspace }}/data:/data
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@


# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased] - 2023-mm-dd (this date should be changed on release)

### Added

- Minting status is now displayed in the UI.

### Changed

- Default port is now 4000.
- `brambl-cli` version (for IT) is now 2.0.0-beta3.
4 changes: 2 additions & 2 deletions bridge-ui/src/Frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface MintingStatusResponse {
mintingStatus: string;
address: string;
bridgePKey: string;
redeemTemplate: string;
redeemScript: string;
}

async function checkMintingStatus(mintingStatusRequest: MintingStatusRequest): Promise<MintingStatusResponse | ErrorResponse> {
Expand Down Expand Up @@ -61,7 +61,7 @@ function Frame() {
updateStatus(sessionId);
}, 5000);
} else {
mintedBTC(setSession, session, currentStatus.address, currentStatus.bridgePKey, currentStatus.redeemTemplate);
mintedBTC(setSession, session, currentStatus.address, currentStatus.bridgePKey, currentStatus.redeemScript);
}
}
} else {
Expand Down
24 changes: 14 additions & 10 deletions bridge-ui/src/views/WaitingForMint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function WaitingForMint(session: SessionInformation) {
width: '75%'
};

const waitingView = (mintingStatus: PeginUIState, redeemAddress: string, redeemTemplate: string) => {
const waitingView = (mintingStatus: PeginUIState, redeemAddress: string, bridgePKey: string, redeemTemplate: string) => {
if (mintingStatus === PeginUIState.MintingTBTC) {
return (
<>
Expand Down Expand Up @@ -72,14 +72,18 @@ function WaitingForMint(session: SessionInformation) {
<div className="mb-3">
<div className="d-flex align-items-center">
<strong role="status">Tokens minted sucessfully</strong>
<div className="input-group mb-3">
<span className="input-group-text" id="basic-addon1">Redeem address</span>
<input value={redeemAddress} type="text" className="form-control" aria-label="Redeem address" aria-describedby="basic-addon1" />
</div>
<div className="input-group mb-3">
<span className="input-group-text" id="basic-addon1">Redeem template</span>
<input value={redeemTemplate} type="text" className="form-control" aria-label="Redeem template" aria-describedby="basic-addon1" />
</div>
</div>
<div className="input-group mb-3">
<span className="input-group-text" id="basic-addon1">Redeem address</span>
<input disabled value={redeemAddress} type="text" className="form-control" aria-label="Redeem address" aria-describedby="basic-addon1" />
</div>
<div className="input-group mb-3">
<span className="input-group-text" id="basic-addon1">Bridge Key</span>
<input disabled value={bridgePKey} type="text" className="form-control" aria-label="Redeem template" aria-describedby="basic-addon1" />
</div>
<div className="input-group mb-3">
<span className="input-group-text" id="basic-addon1">Redeem template</span>
<input disabled value={redeemTemplate} type="text" className="form-control" aria-label="Redeem template" aria-describedby="basic-addon1" />
</div>
</div>
</div>
Expand All @@ -94,7 +98,7 @@ function WaitingForMint(session: SessionInformation) {

return (
<>
{waitingView(session.currentState, session.redeemAddress, session.redeemTemplate)}
{waitingView(session.currentState, session.redeemAddress, session.toplBridgePKey, session.redeemTemplate)}
</>
);
}
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ lazy val commonDockerSettings = List(
)

lazy val dockerPublishSettingsBroker = List(
dockerExposedPorts ++= Seq(3000),
dockerExposedPorts ++= Seq(4000),
Docker / packageName := "topl-btc-bridge"
) ++ commonDockerSettings

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class BridgeIntegrationSpec extends CatsEffectSuite {
"launch",
"-r",
"https://s01.oss.sonatype.org/content/repositories/releases",
"co.topl:brambl-cli_2.13:2.0.0-beta1",
"co.topl:brambl-cli_2.13:2.0.0-beta3",
"--",
"genus-query",
"utxo-by-address",
Expand All @@ -141,7 +141,7 @@ class BridgeIntegrationSpec extends CatsEffectSuite {
"launch",
"-r",
"https://s01.oss.sonatype.org/content/repositories/releases",
"co.topl:brambl-cli_2.13:2.0.0-beta1",
"co.topl:brambl-cli_2.13:2.0.0-beta3",
"--",
"genus-query",
"utxo-by-address",
Expand Down Expand Up @@ -222,7 +222,7 @@ class BridgeIntegrationSpec extends CatsEffectSuite {
method = Method.POST,
Uri
.fromString(
"http://127.0.0.1:3000/api/" + BridgeContants.START_PEGIN_SESSION_PATH
"http://127.0.0.1:4000/api/" + BridgeContants.START_PEGIN_SESSION_PATH
)
.toOption
.get
Expand All @@ -246,7 +246,7 @@ class BridgeIntegrationSpec extends CatsEffectSuite {
Request[IO](
method = Method.POST,
Uri
.fromString("http://127.0.0.1:3000/api/sync-wallet")
.fromString("http://127.0.0.1:4000/api/sync-wallet")
.toOption
.get
).withContentType(
Expand Down Expand Up @@ -297,7 +297,7 @@ class BridgeIntegrationSpec extends CatsEffectSuite {
Request[IO](
method = Method.POST,
Uri
.fromString("http://127.0.0.1:3000/api/confirm-deposit-btc")
.fromString("http://127.0.0.1:4000/api/confirm-deposit-btc")
.toOption
.get
).withContentType(
Expand Down Expand Up @@ -334,7 +334,7 @@ class BridgeIntegrationSpec extends CatsEffectSuite {
Request[IO](
method = Method.POST,
Uri
.fromString("http://127.0.0.1:3000/api/confirm-redemption")
.fromString("http://127.0.0.1:4000/api/confirm-redemption")
.toOption
.get
).withContentType(
Expand Down
2 changes: 1 addition & 1 deletion microsite/docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ npm run start

The `cd` command changes the directory you're working with. In order to work with your newly created Docusaurus site, you'll need to navigate the terminal there.

The `npm run start` command builds your website locally and serves it through a development server, ready for you to view at http://localhost:3000/.
The `npm run start` command builds your website locally and serves it through a development server, ready for you to view at http://localhost:4000/.

Open `docs/intro.md` (this page) and edit some lines: the site **reloads automatically** and displays your changes.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ trait ApiServicesModule {
pegin.mintingBTCState.toString(),
pegin.redeemAddress,
pegin.toplBridgePKey,
s"threshold(1, or(sign(0), sha256(${pegin.sha256})))",
s"threshold(1, sign(0) or sha256(${pegin.sha256}))",
).asJson
)
_ <- IO.println("Minting status response: " + resp)
Expand Down
2 changes: 1 addition & 1 deletion topl-btc-bridge/src/main/scala/co/topl/bridge/Server.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object ServerConfig {
.getOrElse(false)

val port: Port = {
val portStr = Option(java.lang.System.getProperty("port")).getOrElse("3000")
val portStr = Option(java.lang.System.getProperty("port")).getOrElse("4000")
Port
.fromString(portStr)
.getOrElse(throw new Exception(s"Bad port option: `${portStr}`"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class ConfirmDepositController[F[_]: Async: Logger](
case e: BridgeError => Left(e)
case e: Throwable =>
e.printStackTrace()
Left(InvalidInput("Error in confirmDeposit"))
Left(InvalidInput(s"Error in confirmDeposit: ${e.getMessage}"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ object ToplWalletImpl {
lockTempl <- wsa
.getLockTemplate(mintTemplateName)
.liftT
bridgePartialVk = Encoding.encodeToBase58(
bk.vk.toByteArray
)
deriveChildKeyBridgeString = Encoding.encodeToBase58(
bridgeVk.toByteArray
)
Expand All @@ -195,7 +198,7 @@ object ToplWalletImpl {
.addEntityVks(
fromFellowship,
mintTemplateName,
deriveChildKeyBridgeString :: Nil
bridgePartialVk :: Nil
)
.optionT
currentAddress <- wsa
Expand All @@ -205,7 +208,7 @@ object ToplWalletImpl {
None
)
.liftT
} yield (currentAddress, deriveChildKeyBridgeString)).value
} yield (currentAddress, bridgePartialVk)).value
}

private def computeSerializedTemplate(
Expand Down

0 comments on commit 332a9cc

Please sign in to comment.