This repository has been archived by the owner on Dec 27, 2022. It is now read-only.
/
shared.ts
68 lines (60 loc) · 1.88 KB
/
shared.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
65
66
67
68
import { NodeResponses } from "../schemas";
import { Address } from "../basic";
import { Values } from "../error";
import { tidy } from "../utils";
import {
HashlockTransferName,
HashlockTransferResolver,
HashlockTransferResolverEncoding,
HashlockTransferState,
HashlockTransferStateEncoding,
} from "./hashlockTransfer";
import {
WithdrawName,
WithdrawResolver,
WithdrawResolverEncoding,
WithdrawState,
WithdrawStateEncoding,
} from "./withdraw";
// Must be updated when adding a new transfer
export const TransferNames = {
[HashlockTransferName]: HashlockTransferName,
[WithdrawName]: WithdrawName,
} as const;
// Must be updated when adding a new transfer
export interface TransferResolverMap {
[HashlockTransferName]: HashlockTransferResolver;
[WithdrawName]: WithdrawResolver;
}
// Must be updated when adding a new transfer
export interface TransferStateMap {
[HashlockTransferName]: HashlockTransferState;
[WithdrawName]: WithdrawState;
}
// Must be updated when adding a new transfer
export const TransferEncodingsMap = {
[HashlockTransferName]: [HashlockTransferStateEncoding, HashlockTransferResolverEncoding],
[WithdrawName]: [WithdrawStateEncoding, WithdrawResolverEncoding],
} as const;
export type TransferName = keyof typeof TransferNames | string;
export type TransferState = Values<TransferStateMap> | any;
export type TransferResolver = Values<TransferResolverMap> | any;
export type TransferEncodings = Values<typeof TransferEncodingsMap> | [string, string];
export type RegisteredTransfer = {
stateEncoding: string;
resolverEncoding: string;
definition: Address;
name: string;
encodedCancel: string;
};
export const TransferQuoteEncoding = tidy(`tuple(
string routerIdentifier,
uint256 amount,
address assetId,
uint256 chainId,
string recipient,
uint256 recipientChainId,
address recipientAssetId,
uint256 fee,
uint256 expiry
)`);