增加查询钱包交易记录的方法
This commit is contained in:
parent
f6ed757a1c
commit
e055eaba7f
@ -28,6 +28,7 @@ import {
|
|||||||
restoreWalletByMnemonic,
|
restoreWalletByMnemonic,
|
||||||
} from "./manage/WalletManage";
|
} from "./manage/WalletManage";
|
||||||
import { NativeSvr } from "./services/NativeSvr";
|
import { NativeSvr } from "./services/NativeSvr";
|
||||||
|
import { TranHistorySvr } from "./services/TranHistorySvr";
|
||||||
import { ChainCommon } from "./standards/ChainCommon";
|
import { ChainCommon } from "./standards/ChainCommon";
|
||||||
import { ERC1155Standard } from "./standards/ERC1155Standard";
|
import { ERC1155Standard } from "./standards/ERC1155Standard";
|
||||||
import { ERC20Standard } from "./standards/ERC20Standard";
|
import { ERC20Standard } from "./standards/ERC20Standard";
|
||||||
@ -78,6 +79,7 @@ export default class JCWallet {
|
|||||||
public chainCommon: ChainCommon;
|
public chainCommon: ChainCommon;
|
||||||
public jcStandard: JCStandard;
|
public jcStandard: JCStandard;
|
||||||
public nativeSvr: NativeSvr;
|
public nativeSvr: NativeSvr;
|
||||||
|
public historySvr: TranHistorySvr;
|
||||||
public wConnect: ZWalletConnect;
|
public wConnect: ZWalletConnect;
|
||||||
public mainHandlers = createWalletEvents();
|
public mainHandlers = createWalletEvents();
|
||||||
public data: IAccount[] = [];
|
public data: IAccount[] = [];
|
||||||
@ -91,6 +93,7 @@ export default class JCWallet {
|
|||||||
|
|
||||||
constructor({ type, chain }: { type: number; chain: number }) {
|
constructor({ type, chain }: { type: number; chain: number }) {
|
||||||
this.nativeSvr = new NativeSvr();
|
this.nativeSvr = new NativeSvr();
|
||||||
|
this.historySvr = new TranHistorySvr();
|
||||||
this.walletType = type;
|
this.walletType = type;
|
||||||
chain = chain || 80001;
|
chain = chain || 80001;
|
||||||
let data = AllChains.find((o) => o.id === chain);
|
let data = AllChains.find((o) => o.id === chain);
|
||||||
|
43
src/services/TranHistorySvr.ts
Normal file
43
src/services/TranHistorySvr.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user