-
Notifications
You must be signed in to change notification settings - Fork 4
/
rwaCompliance.ts
360 lines (360 loc) · 15.2 KB
/
rwaCompliance.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
import {
ContractEvent,
ContractName,
EntrypointName,
ModuleReference,
} from "@concordium/web-sdk";
import { InitMethod, ReceiveMethod } from "./GenericContract";
export const CONTRACT_NAME = "rwa_compliance";
export type initRequest = {
modules: Array<{ index: number; subindex: number }>;
};
export const initRequestSchemaBase64 = "FAABAAAABwAAAG1vZHVsZXMQAgw=";
export const initErrorSchemaBase64 =
"FQcAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICDQAAAEludmFsaWRNb2R1bGUCEQAAAENhbGxDb250cmFjdEVycm9yAgwAAABVbmF1dGhvcml6ZWQCEgAAAEFnZW50QWxyZWFkeUV4aXN0cwINAAAAQWdlbnROb3RGb3VuZAI=";
export type AddAgentError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { InvalidModule: Record<string, never> }
| { CallContractError: Record<string, never> }
| { Unauthorized: Record<string, never> }
| { AgentAlreadyExists: Record<string, never> }
| { AgentNotFound: Record<string, never> };
export const addAgentErrorSchemaBase64 =
"FQcAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICDQAAAEludmFsaWRNb2R1bGUCEQAAAENhbGxDb250cmFjdEVycm9yAgwAAABVbmF1dGhvcml6ZWQCEgAAAEFnZW50QWxyZWFkeUV4aXN0cwINAAAAQWdlbnROb3RGb3VuZAI=";
export type AddAgentRequest =
| { Account: [string] }
| { Contract: [{ index: number; subindex: number }] };
export const addAgentRequestSchemaBase64 =
"FQIAAAAHAAAAQWNjb3VudAEBAAAACwgAAABDb250cmFjdAEBAAAADA==";
export type AddModuleError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { InvalidModule: Record<string, never> }
| { CallContractError: Record<string, never> }
| { Unauthorized: Record<string, never> }
| { AgentAlreadyExists: Record<string, never> }
| { AgentNotFound: Record<string, never> };
export const addModuleErrorSchemaBase64 =
"FQcAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICDQAAAEludmFsaWRNb2R1bGUCEQAAAENhbGxDb250cmFjdEVycm9yAgwAAABVbmF1dGhvcml6ZWQCEgAAAEFnZW50QWxyZWFkeUV4aXN0cwINAAAAQWdlbnROb3RGb3VuZAI=";
export type AddModuleRequest = { index: number; subindex: number };
export const addModuleRequestSchemaBase64 = "DA==";
export type AgentsError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { InvalidModule: Record<string, never> }
| { CallContractError: Record<string, never> }
| { Unauthorized: Record<string, never> }
| { AgentAlreadyExists: Record<string, never> }
| { AgentNotFound: Record<string, never> };
export const agentsErrorSchemaBase64 =
"FQcAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICDQAAAEludmFsaWRNb2R1bGUCEQAAAENhbGxDb250cmFjdEVycm9yAgwAAABVbmF1dGhvcml6ZWQCEgAAAEFnZW50QWxyZWFkeUV4aXN0cwINAAAAQWdlbnROb3RGb3VuZAI=";
export type AgentsResponse = Array<
{ Account: [string] } | { Contract: [{ index: number; subindex: number }] }
>;
export const agentsResponseSchemaBase64 =
"EAIVAgAAAAcAAABBY2NvdW50AQEAAAALCAAAAENvbnRyYWN0AQEAAAAM";
export type BurnedError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { InvalidModule: Record<string, never> }
| { CallContractError: Record<string, never> }
| { Unauthorized: Record<string, never> }
| { AgentAlreadyExists: Record<string, never> }
| { AgentNotFound: Record<string, never> };
export const burnedErrorSchemaBase64 =
"FQcAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICDQAAAEludmFsaWRNb2R1bGUCEQAAAENhbGxDb250cmFjdEVycm9yAgwAAABVbmF1dGhvcml6ZWQCEgAAAEFnZW50QWxyZWFkeUV4aXN0cwINAAAAQWdlbnROb3RGb3VuZAI=";
export type BurnedRequest = {
token_id: { token_id: string; contract: { index: number; subindex: number } };
owner:
| { Account: [string] }
| { Contract: [{ index: number; subindex: number }] };
amount: string;
};
export const burnedRequestSchemaBase64 =
"FAADAAAACAAAAHRva2VuX2lkFAACAAAACAAAAHRva2VuX2lkHQAIAAAAY29udHJhY3QMBQAAAG93bmVyFQIAAAAHAAAAQWNjb3VudAEBAAAACwgAAABDb250cmFjdAEBAAAADAYAAABhbW91bnQbJQAAAA==";
export type CanTransferError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { InvalidModule: Record<string, never> }
| { CallContractError: Record<string, never> }
| { Unauthorized: Record<string, never> }
| { AgentAlreadyExists: Record<string, never> }
| { AgentNotFound: Record<string, never> };
export const canTransferErrorSchemaBase64 =
"FQcAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICDQAAAEludmFsaWRNb2R1bGUCEQAAAENhbGxDb250cmFjdEVycm9yAgwAAABVbmF1dGhvcml6ZWQCEgAAAEFnZW50QWxyZWFkeUV4aXN0cwINAAAAQWdlbnROb3RGb3VuZAI=";
export type CanTransferRequest = {
token_id: { token_id: string; contract: { index: number; subindex: number } };
to:
| { Account: [string] }
| { Contract: [{ index: number; subindex: number }] };
amount: string;
};
export const canTransferRequestSchemaBase64 =
"FAADAAAACAAAAHRva2VuX2lkFAACAAAACAAAAHRva2VuX2lkHQAIAAAAY29udHJhY3QMAgAAAHRvFQIAAAAHAAAAQWNjb3VudAEBAAAACwgAAABDb250cmFjdAEBAAAADAYAAABhbW91bnQbJQAAAA==";
export type CanTransferResponse = boolean;
export const canTransferResponseSchemaBase64 = "AQ==";
export type IsAgentError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { InvalidModule: Record<string, never> }
| { CallContractError: Record<string, never> }
| { Unauthorized: Record<string, never> }
| { AgentAlreadyExists: Record<string, never> }
| { AgentNotFound: Record<string, never> };
export const isAgentErrorSchemaBase64 =
"FQcAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICDQAAAEludmFsaWRNb2R1bGUCEQAAAENhbGxDb250cmFjdEVycm9yAgwAAABVbmF1dGhvcml6ZWQCEgAAAEFnZW50QWxyZWFkeUV4aXN0cwINAAAAQWdlbnROb3RGb3VuZAI=";
export type IsAgentRequest =
| { Account: [string] }
| { Contract: [{ index: number; subindex: number }] };
export const isAgentRequestSchemaBase64 =
"FQIAAAAHAAAAQWNjb3VudAEBAAAACwgAAABDb250cmFjdAEBAAAADA==";
export type IsAgentResponse = boolean;
export const isAgentResponseSchemaBase64 = "AQ==";
export type MintedError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { InvalidModule: Record<string, never> }
| { CallContractError: Record<string, never> }
| { Unauthorized: Record<string, never> }
| { AgentAlreadyExists: Record<string, never> }
| { AgentNotFound: Record<string, never> };
export const mintedErrorSchemaBase64 =
"FQcAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICDQAAAEludmFsaWRNb2R1bGUCEQAAAENhbGxDb250cmFjdEVycm9yAgwAAABVbmF1dGhvcml6ZWQCEgAAAEFnZW50QWxyZWFkeUV4aXN0cwINAAAAQWdlbnROb3RGb3VuZAI=";
export type MintedRequest = {
token_id: { token_id: string; contract: { index: number; subindex: number } };
owner:
| { Account: [string] }
| { Contract: [{ index: number; subindex: number }] };
amount: string;
};
export const mintedRequestSchemaBase64 =
"FAADAAAACAAAAHRva2VuX2lkFAACAAAACAAAAHRva2VuX2lkHQAIAAAAY29udHJhY3QMBQAAAG93bmVyFQIAAAAHAAAAQWNjb3VudAEBAAAACwgAAABDb250cmFjdAEBAAAADAYAAABhbW91bnQbJQAAAA==";
export type ModulesResponse = Array<{ index: number; subindex: number }>;
export const modulesResponseSchemaBase64 = "EAIM";
export type RemoveAgentError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { InvalidModule: Record<string, never> }
| { CallContractError: Record<string, never> }
| { Unauthorized: Record<string, never> }
| { AgentAlreadyExists: Record<string, never> }
| { AgentNotFound: Record<string, never> };
export const removeAgentErrorSchemaBase64 =
"FQcAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICDQAAAEludmFsaWRNb2R1bGUCEQAAAENhbGxDb250cmFjdEVycm9yAgwAAABVbmF1dGhvcml6ZWQCEgAAAEFnZW50QWxyZWFkeUV4aXN0cwINAAAAQWdlbnROb3RGb3VuZAI=";
export type RemoveAgentRequest =
| { Account: [string] }
| { Contract: [{ index: number; subindex: number }] };
export const removeAgentRequestSchemaBase64 =
"FQIAAAAHAAAAQWNjb3VudAEBAAAACwgAAABDb250cmFjdAEBAAAADA==";
export type RemoveModuleError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { InvalidModule: Record<string, never> }
| { CallContractError: Record<string, never> }
| { Unauthorized: Record<string, never> }
| { AgentAlreadyExists: Record<string, never> }
| { AgentNotFound: Record<string, never> };
export const removeModuleErrorSchemaBase64 =
"FQcAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICDQAAAEludmFsaWRNb2R1bGUCEQAAAENhbGxDb250cmFjdEVycm9yAgwAAABVbmF1dGhvcml6ZWQCEgAAAEFnZW50QWxyZWFkeUV4aXN0cwINAAAAQWdlbnROb3RGb3VuZAI=";
export type RemoveModuleRequest = { index: number; subindex: number };
export const removeModuleRequestSchemaBase64 = "DA==";
export type SupportsError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { InvalidModule: Record<string, never> }
| { CallContractError: Record<string, never> }
| { Unauthorized: Record<string, never> }
| { AgentAlreadyExists: Record<string, never> }
| { AgentNotFound: Record<string, never> };
export const supportsErrorSchemaBase64 =
"FQcAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICDQAAAEludmFsaWRNb2R1bGUCEQAAAENhbGxDb250cmFjdEVycm9yAgwAAABVbmF1dGhvcml6ZWQCEgAAAEFnZW50QWxyZWFkeUV4aXN0cwINAAAAQWdlbnROb3RGb3VuZAI=";
export type SupportsRequest = Array<string>;
export const supportsRequestSchemaBase64 = "EAEWAA==";
export type SupportsResponse = Array<
| { NoSupport: Record<string, never> }
| { Support: Record<string, never> }
| { SupportBy: [Array<{ index: number; subindex: number }>] }
>;
export const supportsResponseSchemaBase64 =
"EAEVAwAAAAkAAABOb1N1cHBvcnQCBwAAAFN1cHBvcnQCCQAAAFN1cHBvcnRCeQEBAAAAEAAM";
export type TransferredError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { InvalidModule: Record<string, never> }
| { CallContractError: Record<string, never> }
| { Unauthorized: Record<string, never> }
| { AgentAlreadyExists: Record<string, never> }
| { AgentNotFound: Record<string, never> };
export const transferredErrorSchemaBase64 =
"FQcAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICDQAAAEludmFsaWRNb2R1bGUCEQAAAENhbGxDb250cmFjdEVycm9yAgwAAABVbmF1dGhvcml6ZWQCEgAAAEFnZW50QWxyZWFkeUV4aXN0cwINAAAAQWdlbnROb3RGb3VuZAI=";
export type TransferredRequest = {
token_id: { token_id: string; contract: { index: number; subindex: number } };
from:
| { Account: [string] }
| { Contract: [{ index: number; subindex: number }] };
to:
| { Account: [string] }
| { Contract: [{ index: number; subindex: number }] };
amount: string;
};
export const transferredRequestSchemaBase64 =
"FAAEAAAACAAAAHRva2VuX2lkFAACAAAACAAAAHRva2VuX2lkHQAIAAAAY29udHJhY3QMBAAAAGZyb20VAgAAAAcAAABBY2NvdW50AQEAAAALCAAAAENvbnRyYWN0AQEAAAAMAgAAAHRvFQIAAAAHAAAAQWNjb3VudAEBAAAACwgAAABDb250cmFjdAEBAAAADAYAAABhbW91bnQbJQAAAA==";
export type event =
| {
AgentRemoved: [
{
agent:
| { Account: [string] }
| { Contract: [{ index: number; subindex: number }] };
},
];
}
| {
AgentAdded: [
{
agent:
| { Account: [string] }
| { Contract: [{ index: number; subindex: number }] };
},
];
}
| { ModuleAdded: [{ index: number; subindex: number }] }
| { ModuleRemoved: [{ index: number; subindex: number }] };
export const eventSchemaBase64 =
"FQQAAAAMAAAAQWdlbnRSZW1vdmVkAQEAAAAUAAEAAAAFAAAAYWdlbnQVAgAAAAcAAABBY2NvdW50AQEAAAALCAAAAENvbnRyYWN0AQEAAAAMCgAAAEFnZW50QWRkZWQBAQAAABQAAQAAAAUAAABhZ2VudBUCAAAABwAAAEFjY291bnQBAQAAAAsIAAAAQ29udHJhY3QBAQAAAAwLAAAATW9kdWxlQWRkZWQBAQAAAAwNAAAATW9kdWxlUmVtb3ZlZAEBAAAADA==";
export const ENTRYPOINTS: Record<string, EntrypointName.Type> = {
addAgent: EntrypointName.fromString("addAgent"),
addModule: EntrypointName.fromString("addModule"),
agents: EntrypointName.fromString("agents"),
burned: EntrypointName.fromString("burned"),
canTransfer: EntrypointName.fromString("canTransfer"),
isAgent: EntrypointName.fromString("isAgent"),
minted: EntrypointName.fromString("minted"),
modules: EntrypointName.fromString("modules"),
removeAgent: EntrypointName.fromString("removeAgent"),
removeModule: EntrypointName.fromString("removeModule"),
supports: EntrypointName.fromString("supports"),
transferred: EntrypointName.fromString("transferred"),
};
export const ENTRYPOINT_DISPLAY_NAMES: Record<string, string> = {
addAgent: "Add Agent",
addModule: "Add Module",
agents: "Agents",
burned: "Burned",
canTransfer: "Can Transfer",
isAgent: "Is Agent",
minted: "Minted",
modules: "Modules",
removeAgent: "Remove Agent",
removeModule: "Remove Module",
supports: "Supports",
transferred: "Transferred",
};
export const rwaCompliance = {
init: new InitMethod<initRequest>(
ModuleReference.fromHexString(
"3ed1d2653d674b56c2be13a9aac06bc9cb6ae3f08ea2ee2da508306631e918e0",
),
ContractName.fromString("rwa_compliance"),
initRequestSchemaBase64,
),
addAgent: new ReceiveMethod<AddAgentRequest, never, AddAgentError>(
ContractName.fromString("rwa_compliance"),
EntrypointName.fromString("addAgent"),
addAgentRequestSchemaBase64,
undefined,
addAgentErrorSchemaBase64,
),
addModule: new ReceiveMethod<AddModuleRequest, never, AddModuleError>(
ContractName.fromString("rwa_compliance"),
EntrypointName.fromString("addModule"),
addModuleRequestSchemaBase64,
undefined,
addModuleErrorSchemaBase64,
),
agents: new ReceiveMethod<never, AgentsResponse, AgentsError>(
ContractName.fromString("rwa_compliance"),
EntrypointName.fromString("agents"),
undefined,
agentsResponseSchemaBase64,
agentsErrorSchemaBase64,
),
burned: new ReceiveMethod<BurnedRequest, never, BurnedError>(
ContractName.fromString("rwa_compliance"),
EntrypointName.fromString("burned"),
burnedRequestSchemaBase64,
undefined,
burnedErrorSchemaBase64,
),
canTransfer: new ReceiveMethod<
CanTransferRequest,
CanTransferResponse,
CanTransferError
>(
ContractName.fromString("rwa_compliance"),
EntrypointName.fromString("canTransfer"),
canTransferRequestSchemaBase64,
canTransferResponseSchemaBase64,
canTransferErrorSchemaBase64,
),
isAgent: new ReceiveMethod<IsAgentRequest, IsAgentResponse, IsAgentError>(
ContractName.fromString("rwa_compliance"),
EntrypointName.fromString("isAgent"),
isAgentRequestSchemaBase64,
isAgentResponseSchemaBase64,
isAgentErrorSchemaBase64,
),
minted: new ReceiveMethod<MintedRequest, never, MintedError>(
ContractName.fromString("rwa_compliance"),
EntrypointName.fromString("minted"),
mintedRequestSchemaBase64,
undefined,
mintedErrorSchemaBase64,
),
modules: new ReceiveMethod<void, ModulesResponse>(
ContractName.fromString("rwa_compliance"),
EntrypointName.fromString("modules"),
undefined,
modulesResponseSchemaBase64,
),
removeAgent: new ReceiveMethod<RemoveAgentRequest, never, RemoveAgentError>(
ContractName.fromString("rwa_compliance"),
EntrypointName.fromString("removeAgent"),
removeAgentRequestSchemaBase64,
undefined,
removeAgentErrorSchemaBase64,
),
removeModule: new ReceiveMethod<
RemoveModuleRequest,
never,
RemoveModuleError
>(
ContractName.fromString("rwa_compliance"),
EntrypointName.fromString("removeModule"),
removeModuleRequestSchemaBase64,
undefined,
removeModuleErrorSchemaBase64,
),
supports: new ReceiveMethod<SupportsRequest, SupportsResponse, SupportsError>(
ContractName.fromString("rwa_compliance"),
EntrypointName.fromString("supports"),
supportsRequestSchemaBase64,
supportsResponseSchemaBase64,
supportsErrorSchemaBase64,
),
transferred: new ReceiveMethod<TransferredRequest, never, TransferredError>(
ContractName.fromString("rwa_compliance"),
EntrypointName.fromString("transferred"),
transferredRequestSchemaBase64,
undefined,
transferredErrorSchemaBase64,
),
deserializeEvent: (event: ContractEvent.Type): event => {
return ContractEvent.parseWithSchemaTypeBase64(
event,
eventSchemaBase64,
) as event;
},
};
export default rwaCompliance;