File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
packages/library/src/protocol Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ import {
2+ MessageProcessorArgs ,
3+ OutgoingMessageProcessor ,
4+ outgoingMessageProcessor ,
5+ } from "@proto-kit/protocol" ;
6+ import { AccountUpdate , TokenId } from "o1js" ;
7+
8+ import { Withdrawal } from "../runtime/Withdrawals" ;
9+
10+ @outgoingMessageProcessor ( )
11+ export class WithdrawalMessageProcessor extends OutgoingMessageProcessor < Withdrawal > {
12+ type = Withdrawal ;
13+
14+ messageType = "withdrawal" ;
15+
16+ dummy ( ) : Withdrawal {
17+ return Withdrawal . dummy ( ) ;
18+ }
19+
20+ process (
21+ message : Withdrawal ,
22+ { bridgeContract } : MessageProcessorArgs
23+ ) : AccountUpdate [ ] {
24+ const subTokenId = TokenId . derive (
25+ bridgeContract . publicKey ,
26+ bridgeContract . tokenId
27+ ) ;
28+ const mintAccountUpdate = AccountUpdate . default (
29+ message . address ,
30+ subTokenId
31+ ) ;
32+ mintAccountUpdate . balance . addInPlace ( message . amount ) ;
33+ mintAccountUpdate . label = "Withdrawal processor: mint token" ;
34+ return [ mintAccountUpdate ] ;
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments