Skip to content

Commit

Permalink
Merge pull request #122 from sotatek-dev/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Sotatek-TanHoang authored Oct 1, 2024
2 parents 8f04d70 + 165e3d7 commit 7b8dd54
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 5 deletions.
83 changes: 83 additions & 0 deletions design/bridge-eth-mina.puml
Original file line number Diff line number Diff line change
@@ -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

83 changes: 83 additions & 0 deletions design/bridge-mina-eth.puml
Original file line number Diff line number Diff line change
@@ -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

6 changes: 3 additions & 3 deletions src/modules/crawler/sender.minabridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ 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,
});
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();

Expand All @@ -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...');
Expand Down
2 changes: 0 additions & 2 deletions src/modules/users/dto/common-config-request.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7b8dd54

Please sign in to comment.