增加查询钱包交易记录的方法

This commit is contained in:
zhl 2023-02-03 14:30:46 +08:00
parent ebbb376f47
commit f3b8d4d532
2 changed files with 46 additions and 0 deletions

View File

@ -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);

View File

@ -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);
}
}