-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransactionNotifier.interface.ts
64 lines (59 loc) · 1.69 KB
/
TransactionNotifier.interface.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { BigNumber } from "ethers";
import {
TransactionReceipt,
TransactionResponse,
} from "@ethersproject/providers";
import { Address } from "../../types";
import { getPermit2Message } from "../../utils/signatures/permit2";
export interface ITransactionNotifier {
/** Transcation started */
onStart?: (
id: string,
user: Address,
operation: string,
symbol: string,
amount: BigNumber,
decimals: number
) => Promise<void>;
/** Waiting for wallet confirmation */
onConfirmWaiting?: (
id: string,
user: Address,
operation: string,
symbol: string,
amount: BigNumber,
decimals: number
) => Promise<void>;
/** Tx validated in wallet */
onConfirmed?: (id: string, tx?: TransactionResponse) => Promise<void>;
/** Waiting for approval signature */
onApprovalSignatureWaiting?: (
id: string,
user: Address,
symbol: string
) => Promise<void>;
/** Approval signed */
onApprovalSigned?: (
id: string,
payload: ApprovalSignedPayload
) => Promise<void>;
/** Tx is waiting to be integrated to the Blockchain */
onPending?: (id: string, tx?: TransactionResponse) => Promise<void>;
/** Tx successful */
onSuccess?: (id: string, tx?: TransactionReceipt) => Promise<void>;
/** Tx failed */
onError?: (id: string, error: Error) => Promise<void>;
/** Close notifier failed or success */
close?: (id: string, success: boolean) => Promise<void>;
/** Generic notification */
notify?: (
id: string,
code: string,
params?: Record<string, any>
) => Promise<void>;
}
export interface ApprovalSignedPayload {
signature: string;
hash: string;
data: Pick<ReturnType<typeof getPermit2Message>, "data">["data"];
}