-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
109 lines (89 loc) · 2.94 KB
/
types.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { chains } from './chains'
export type ChainId = (typeof chains)[number]['chainId']
export type ChainShortName = (typeof chains)[number]['shortName']
export type PrefixedAddress =
| `${ChainShortName}:0x${string}`
| `eoa:0x${string}`
export enum AccountType {
EOA = 'EOA',
SAFE = 'SAFE',
ROLES = 'ROLES',
DELAY = 'DELAY',
}
export interface Eoa {
type: AccountType.EOA
address: `0x${string}`
prefixedAddress: PrefixedAddress
}
export interface Safe {
type: AccountType.SAFE
address: `0x${string}`
prefixedAddress: PrefixedAddress
chain: ChainId
threshold: number
}
export interface Roles {
type: AccountType.ROLES
address: `0x${string}`
prefixedAddress: PrefixedAddress
chain: ChainId
multisend: `0x${string}`[]
version: 1 | 2
}
export interface Delay {
type: AccountType.DELAY
address: `0x${string}`
prefixedAddress: PrefixedAddress
chain: ChainId
}
type Contract = Safe | Roles | Delay
export type Account = Eoa | Contract
export enum ConnectionType {
/** The source node is an owner of the destination safe */
OWNS = 'OWNS',
/** The source node is enabled as a module of the destination node */
IS_ENABLED = 'IS_ENABLED',
/** The source node is a role member of the destination Roles node */
IS_MEMBER = 'IS_MEMBER',
}
interface OwnsConnection {
type: ConnectionType.OWNS
from: PrefixedAddress
}
interface IsEnabledConnection {
type: ConnectionType.IS_ENABLED
from: PrefixedAddress
}
interface IsMemberConnection {
type: ConnectionType.IS_MEMBER
roles: string[]
defaultRole?: string
from: PrefixedAddress
}
export type Connection =
| OwnsConnection
| IsEnabledConnection
| IsMemberConnection
/** An execution route starts with the signing EOA or initiating smart contract account. */
export interface StartingPoint {
/** The account that is used as the signer or initiator of the transaction */
account: Account
}
/** An execution route flows along an arbitrary number of contract waypoints ending at the controlled avatar */
export interface Waypoint {
/** A description of the contract account or module at this waypoint */
account: Contract
/** A description of how the previous waypoint is connected to this contract */
connection: Connection
}
/** An execution route describes the flow a transaction can take from `from` (the initiating account) to `to` (the account being controlled) */
export interface Route {
/** An id that uniquely identifies this route, calculated deterministically based on its waypoints */
id: string
/** Address prefixed with "eoa:" or a chain short name identifying the account initiating the transaction */
initiator: PrefixedAddress
/** Chain-prefixed address of the account being controlled */
avatar: PrefixedAddress
/** An execution route flows along an arbitrary number of contract waypoints, starting at the signing EOA or initiating smart account and ending at the controlled avatar */
waypoints: [StartingPoint, ...Waypoint[]]
}