From e055eaba7f4f352be297e6605422b7174f23f9a5 Mon Sep 17 00:00:00 2001 From: zhl Date: Fri, 3 Feb 2023 14:30:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9F=A5=E8=AF=A2=E9=92=B1?= =?UTF-8?q?=E5=8C=85=E4=BA=A4=E6=98=93=E8=AE=B0=E5=BD=95=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 3 +++ src/services/TranHistorySvr.ts | 43 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/services/TranHistorySvr.ts diff --git a/src/index.ts b/src/index.ts index 931dcae..2512a84 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,6 +28,7 @@ import { restoreWalletByMnemonic, } from "./manage/WalletManage"; import { NativeSvr } from "./services/NativeSvr"; +import { TranHistorySvr } from "./services/TranHistorySvr"; import { ChainCommon } from "./standards/ChainCommon"; import { ERC1155Standard } from "./standards/ERC1155Standard"; import { ERC20Standard } from "./standards/ERC20Standard"; @@ -78,6 +79,7 @@ export default class JCWallet { public chainCommon: ChainCommon; public jcStandard: JCStandard; public nativeSvr: NativeSvr; + public historySvr: TranHistorySvr; public wConnect: ZWalletConnect; public mainHandlers = createWalletEvents(); public data: IAccount[] = []; @@ -91,6 +93,7 @@ export default class JCWallet { constructor({ type, chain }: { type: number; chain: number }) { this.nativeSvr = new NativeSvr(); + this.historySvr = new TranHistorySvr(); this.walletType = type; chain = chain || 80001; let data = AllChains.find((o) => o.id === chain); diff --git a/src/services/TranHistorySvr.ts b/src/services/TranHistorySvr.ts new file mode 100644 index 0000000..695db1d --- /dev/null +++ b/src/services/TranHistorySvr.ts @@ -0,0 +1,43 @@ +import { records } from "../api/RecordApi"; +import { singleton } from "../decorator/singleton.decorator"; + +@singleton +export class TranHistorySvr { + /** + * eth history + */ + public async ethRecords(start: number, limit: number) { + start = start | 0; + limit = limit | 0; + const data = { start, limit, chain: jc.wallet.currentChain.id }; + return records(data); + } + + /** + * token history + */ + public async tokenRecords({ + address, + tokenId, + start, + limit, + }: { + address: string; + tokenId?: string; + start: number; + limit: number; + }) { + start = start | 0; + limit = limit | 0; + const data: any = { + start, + limit, + chain: jc.wallet.currentChain.id, + "details.address": address, + }; + if (tokenId) { + data["details.id"] = tokenId + ""; + } + return records(data); + } +}