diff --git a/design/bridge-eth-mina.puml b/design/bridge-eth-mina.puml new file mode 100644 index 0000000..88f6ba1 --- /dev/null +++ b/design/bridge-eth-mina.puml @@ -0,0 +1,83 @@ +@startuml 1 +title Lock From Eth to Mina +actor User +boundary fe as "Frontend" +control be as "Backend" +boundary evm_crawler as "EVM crawler" +boundary mina_validator as "Mina signature validators" +boundary mina_sender as "Mina tx sender" +boundary mina_crawler as "Mina crawler" +participant Ethereum +participant Mina +database db as "Database" +autonumber + +group#LightGreen User lock token from Evm + + User -> fe : select network to bridge + + activate fe + fe -> be : get list of token pairs + activate be + be --> fe : list of token pairs + deactivate be + + User -> fe: select destination wallet, amount + fe --> User: display amount, tip, fee + User -> fe: perform bridge action + fe -> Ethereum: call lock tx using user's wallet + activate Ethereum + Ethereum --> fe: tx status success + deactivate Ethereum + + fe --> User: show popup success + deactivate fe + + +end +group#LightGreen Crawler evm fetch lock tx + evm_crawler->Ethereum: fetch lock events + activate Ethereum + Ethereum --> evm_crawler: return locked tx events + deactivate Ethereum + + evm_crawler -> db: save tx to be unlock in Mina + activate db + db --> evm_crawler: saved tx with status waiting to be unlocked + deactivate db +end +group#LightGreen System unlock token to Mina + + mina_validator -> db: get pending unlock tx and verify theirs signature + activate mina_validator + activate db + db --> mina_validator: update signature + deactivate db + deactivate mina_validator + + mina_sender -> db: get signatured verified tx + activate db + activate mina_sender + db -> mina_sender: return tx + deactivate db + + mina_sender -> Mina: prove, send tx + activate Mina + Mina --> mina_sender: return tx hash + deactivate Mina + deactivate mina_sender + + mina_crawler -> Mina: get unlock events + activate mina_crawler + activate Mina + Mina --> mina_crawler: events unlock + deactivate Mina + mina_crawler ->db: mark tx unlock as completed + activate db + db -> mina_crawler: update completed + deactivate mina_crawler + deactivate db +end + +@enduml + diff --git a/design/bridge-mina-eth.puml b/design/bridge-mina-eth.puml new file mode 100644 index 0000000..f30d367 --- /dev/null +++ b/design/bridge-mina-eth.puml @@ -0,0 +1,83 @@ +@startuml 2 +title Lock From Mina to Eth +actor User +boundary fe as "Frontend" +control be as "Backend" +boundary evm_crawler as "Mina crawler" +boundary mina_validator as "Mina signature validators" +boundary mina_sender as "Evm tx sender" +boundary mina_crawler as "Evm crawler" +participant Ethereum as "Mina" +participant Mina as "Evm" +database db as "Database" +autonumber + +group#LightGreen User lock token from Mina + + User -> fe : select network to bridge + + activate fe + fe -> be : get list of token pairs + activate be + be --> fe : list of token pairs + deactivate be + + User -> fe: select destination wallet, amount + fe --> User: display amount, tip, fee + User -> fe: perform bridge action + fe -> Ethereum: call lock tx using user's wallet + activate Ethereum + Ethereum --> fe: tx status success + deactivate Ethereum + + fe --> User: show popup success + deactivate fe + + +end +group#LightGreen Crawler Mina fetch lock tx + evm_crawler->Ethereum: fetch lock events + activate Ethereum + Ethereum --> evm_crawler: return locked tx events + deactivate Ethereum + + evm_crawler -> db: save tx to be unlock in Mina + activate db + db --> evm_crawler: saved tx with status waiting to be unlocked + deactivate db +end +group#LightGreen System unlock token to Evm + + mina_validator -> db: get pending unlock tx and verify theirs signature + activate mina_validator + activate db + db --> mina_validator: update signature + deactivate db + deactivate mina_validator + + mina_sender -> db: get signatured verified tx + activate db + activate mina_sender + db -> mina_sender: return tx + deactivate db + + mina_sender -> Mina: prove, send tx + activate Mina + Mina --> mina_sender: return tx hash + deactivate Mina + deactivate mina_sender + + mina_crawler -> Mina: get unlock events + activate mina_crawler + activate Mina + Mina --> mina_crawler: events unlock + deactivate Mina + mina_crawler ->db: mark tx unlock as completed + activate db + db -> mina_crawler: update completed + deactivate mina_crawler + deactivate db +end + +@enduml + diff --git a/src/modules/crawler/sender.minabridge.ts b/src/modules/crawler/sender.minabridge.ts index 813baec..8dabf1f 100644 --- a/src/modules/crawler/sender.minabridge.ts +++ b/src/modules/crawler/sender.minabridge.ts @@ -167,7 +167,7 @@ export class SenderMinaBridge { } } - private async callUnlockFunction(amount, txId, receiveAddress) { + private async callUnlockFunction(amount: string, txId: number, receiveAddress: string) { try { const generatedSignatures = await this.multiSignatureRepository.findBy({ txId, @@ -175,7 +175,7 @@ export class SenderMinaBridge { const signatureData = generatedSignatures .map(e => [Bool(true), PublicKey.fromBase58(e.validator), Signature.fromJSON(JSON.parse(e.signature))]) .flat(1); - this.logger.info(`Found ${generatedSignatures.length} signatures.`); + this.logger.info(`Found ${generatedSignatures.length} signatures for txId= ${txId}`); this.logger.info('compile the contract...'); await this.compileContract(); @@ -200,7 +200,7 @@ export class SenderMinaBridge { const typedAmount = UInt64.from(amount); - this.logger.info('Receivier token account status = ', hasAccount); + this.logger.info(`Addr ${receiveAddress} token account status = ${hasAccount}`); // compile the contract to create prover keys this.logger.info('build transaction and create proof...'); diff --git a/src/modules/users/dto/common-config-request.dto.ts b/src/modules/users/dto/common-config-request.dto.ts index e90db4c..edb6978 100644 --- a/src/modules/users/dto/common-config-request.dto.ts +++ b/src/modules/users/dto/common-config-request.dto.ts @@ -3,14 +3,12 @@ import { NumberField } from '../../../shared/decorators/field.decorator.js'; export class UpdateCommonConfigBodyDto { @NumberField({ example: 50, - maximum: 100, required: false, }) tip: number; @NumberField({ example: 500, - maximum: 100, required: false, }) dailyQuota: number;