Skip to content

Commit

Permalink
Update log
Browse files Browse the repository at this point in the history
  • Loading branch information
danial303065 committed Aug 12, 2024
1 parent 47aab5a commit 776d9fe
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
43 changes: 43 additions & 0 deletions packages/relay/scripts/notification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { BOACoin } from "../src/common/Amount";

import "@nomiclabs/hardhat-ethers";
import * as hre from "hardhat";
import { INotificationEventHandler, NotificationSender } from "../src/delegator/NotificationSender";

import { Config } from "../src/common/Config";

async function main() {
const provider = hre.ethers.provider;
const account = "0x9E8549cc1B5b9036AC410Ed11966BB3c6B94A77d";
const balance = await provider.getBalance(account);
console.log(`${account} : ${new BOACoin(balance).toBOAString()}`);

const notificationEventHandler: INotificationEventHandler = {
receive: async (to: string, title: string, body: string, data: any) => {
console.log(to, title);
},
};
// Create with the arguments and read from file
const config = new Config();
config.readFromFile("config/config.yaml");
const notification: NotificationSender = new NotificationSender(config, notificationEventHandler);

await notification.send(
"ExponentPushToken[gr9g1_GA_54W9mUfYMYPtG]",
"마일리지 사용 취소 알림",
"구매처 : 마이클2, 구매 금액 : 100 PHP, 포인트 사용 : 100 POINT",
{ type: "cancel" }
);
//
// await notification.send(
// "ExponentPushToken[s__I-xJSSmcJCfLRPSobU_]",
// "마일리지 사용 취소 알림",
// "구매처 : 마이클2, 구매 금액 : 100 PHP, 포인트 사용 : 100 POINT",
// { type: "cancel" }
// );
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
2 changes: 2 additions & 0 deletions packages/relay/src/routers/PaymentRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1131,8 +1131,10 @@ export class PaymentRouter {
);
contents.push(`${pointLabel} : ${new Amount(item.paidPoint, 18).toDisplayString(true, 0)} POINT`);

logger.info(`to : ${to}`);
logger.info(`contents.join(", ") : ${contents.join(", ")}`);
await this._sender.send(to, title, contents.join(", "), data);
logger.info(`end send`);
}

this.metrics.add("success", 1);
Expand Down

0 comments on commit 776d9fe

Please sign in to comment.