Skip to content

Commit 9d9c7bd

Browse files
committed
Copied WithdrawalMessageProcessor to library package
1 parent ab776ea commit 9d9c7bd

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
}

0 commit comments

Comments
 (0)