forked from chainorders/concordium-rwa
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rwaSponsor.ts
150 lines (150 loc) · 6.27 KB
/
rwaSponsor.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
import {
ContractEvent,
ContractName,
EntrypointName,
ModuleReference,
} from "@concordium/web-sdk";
import { InitMethod, ReceiveMethod } from "./GenericContract";
export const CONTRACT_NAME = "rwa_sponsor";
export const initErrorSchemaBase64 =
"FQUAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICEgAAAFNlcmlhbGl6YXRpb25FcnJvcgIRAAAAQ2FsbENvbnRyYWN0RXJyb3ICDgAAAENJUzNDaGVja0Vycm9yAg==";
export type BytesToSignError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { SerializationError: Record<string, never> }
| { CallContractError: Record<string, never> }
| { CIS3CheckError: Record<string, never> };
export const bytesToSignErrorSchemaBase64 =
"FQUAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICEgAAAFNlcmlhbGl6YXRpb25FcnJvcgIRAAAAQ2FsbENvbnRyYWN0RXJyb3ICDgAAAENJUzNDaGVja0Vycm9yAg==";
export type BytesToSignRequest = {
contract_address: { index: number; subindex: number };
nonce: bigint;
timestamp: string;
entry_point: string;
payload: Array<number>;
};
export const bytesToSignRequestSchemaBase64 =
"FAAFAAAAEAAAAGNvbnRyYWN0X2FkZHJlc3MMBQAAAG5vbmNlBQkAAAB0aW1lc3RhbXANCwAAAGVudHJ5X3BvaW50FgEHAAAAcGF5bG9hZBABAg==";
export type BytesToSignResponse = Array<number>;
export const bytesToSignResponseSchemaBase64 = "EyAAAAAC";
export type NonceError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { SerializationError: Record<string, never> }
| { CallContractError: Record<string, never> }
| { CIS3CheckError: Record<string, never> };
export const nonceErrorSchemaBase64 =
"FQUAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICEgAAAFNlcmlhbGl6YXRpb25FcnJvcgIRAAAAQ2FsbENvbnRyYWN0RXJyb3ICDgAAAENJUzNDaGVja0Vycm9yAg==";
export type NonceRequest = { account: string };
export const nonceRequestSchemaBase64 = "FAABAAAABwAAAGFjY291bnQL";
export type NonceResponse = bigint;
export const nonceResponseSchemaBase64 = "BQ==";
export type PermitError =
| { Parse: Record<string, never> }
| { Log: Record<string, never> }
| { WrongContract: Record<string, never> }
| { Expired: Record<string, never> }
| { NonceMismatch: Record<string, never> }
| { WrongSignature: Record<string, never> }
| { Serialization: Record<string, never> }
| { AccountMissing: Record<string, never> }
| { CallContractAmountTooLarge: Record<string, never> }
| { CallContractMissingAccount: Record<string, never> }
| { CallContractMissingContract: Record<string, never> }
| { CallContractMissingEntrypoint: Record<string, never> }
| { CallContractMessageFailed: Record<string, never> }
| { CallContractTrap: Record<string, never> }
| { CallContractLogicReject: [number] };
export const permitErrorSchemaBase64 =
"FQ8AAAAFAAAAUGFyc2UCAwAAAExvZwINAAAAV3JvbmdDb250cmFjdAIHAAAARXhwaXJlZAINAAAATm9uY2VNaXNtYXRjaAIOAAAAV3JvbmdTaWduYXR1cmUCDQAAAFNlcmlhbGl6YXRpb24CDgAAAEFjY291bnRNaXNzaW5nAhoAAABDYWxsQ29udHJhY3RBbW91bnRUb29MYXJnZQIaAAAAQ2FsbENvbnRyYWN0TWlzc2luZ0FjY291bnQCGwAAAENhbGxDb250cmFjdE1pc3NpbmdDb250cmFjdAIdAAAAQ2FsbENvbnRyYWN0TWlzc2luZ0VudHJ5cG9pbnQCGQAAAENhbGxDb250cmFjdE1lc3NhZ2VGYWlsZWQCEAAAAENhbGxDb250cmFjdFRyYXACFwAAAENhbGxDb250cmFjdExvZ2ljUmVqZWN0AQEAAAAI";
export type PermitRequest = {
signature: [number, [number, { Ed25519: [string] }][]][];
signer: string;
message: {
contract_address: { index: number; subindex: number };
nonce: bigint;
timestamp: string;
entry_point: string;
payload: Array<number>;
};
};
export const permitRequestSchemaBase64 =
"FAADAAAACQAAAHNpZ25hdHVyZRIAAhIAAhUBAAAABwAAAEVkMjU1MTkBAQAAAB5AAAAABgAAAHNpZ25lcgsHAAAAbWVzc2FnZRQABQAAABAAAABjb250cmFjdF9hZGRyZXNzDAUAAABub25jZQUJAAAAdGltZXN0YW1wDQsAAABlbnRyeV9wb2ludBYBBwAAAHBheWxvYWQQAQI=";
export type SupportsPermitError =
| { ParseError: Record<string, never> }
| { LogError: Record<string, never> }
| { SerializationError: Record<string, never> }
| { CallContractError: Record<string, never> }
| { CIS3CheckError: Record<string, never> };
export const supportsPermitErrorSchemaBase64 =
"FQUAAAAKAAAAUGFyc2VFcnJvcgIIAAAATG9nRXJyb3ICEgAAAFNlcmlhbGl6YXRpb25FcnJvcgIRAAAAQ2FsbENvbnRyYWN0RXJyb3ICDgAAAENJUzNDaGVja0Vycm9yAg==";
export type SupportsPermitRequest = { queries: Array<string> };
export const supportsPermitRequestSchemaBase64 = "FAABAAAABwAAAHF1ZXJpZXMQARYB";
export type SupportsPermitResponse = Array<boolean>;
export const supportsPermitResponseSchemaBase64 = "EAEB";
export type event = { Nonce: [{ account: string; nonce: bigint }] };
export const eventSchemaBase64 =
"FQEAAAAFAAAATm9uY2UBAQAAABQAAgAAAAcAAABhY2NvdW50CwUAAABub25jZQU=";
export const ENTRYPOINTS: Record<string, EntrypointName.Type> = {
bytesToSign: EntrypointName.fromString("bytesToSign"),
nonce: EntrypointName.fromString("nonce"),
permit: EntrypointName.fromString("permit"),
supportsPermit: EntrypointName.fromString("supportsPermit"),
};
export const ENTRYPOINT_DISPLAY_NAMES: Record<string, string> = {
bytesToSign: "Bytes To Sign",
nonce: "Nonce",
permit: "Permit",
supportsPermit: "Supports Permit",
};
export const rwaSponsor = {
init: new InitMethod<void>(
ModuleReference.fromHexString(
"918ae7df77db838f4c085ade260adc162ebc5576c9d83bbfb6c9ffe89db2a916",
),
ContractName.fromString("rwa_sponsor"),
),
bytesToSign: new ReceiveMethod<
BytesToSignRequest,
BytesToSignResponse,
BytesToSignError
>(
ContractName.fromString("rwa_sponsor"),
EntrypointName.fromString("bytesToSign"),
bytesToSignRequestSchemaBase64,
bytesToSignResponseSchemaBase64,
bytesToSignErrorSchemaBase64,
),
nonce: new ReceiveMethod<NonceRequest, NonceResponse, NonceError>(
ContractName.fromString("rwa_sponsor"),
EntrypointName.fromString("nonce"),
nonceRequestSchemaBase64,
nonceResponseSchemaBase64,
nonceErrorSchemaBase64,
),
permit: new ReceiveMethod<PermitRequest, never, PermitError>(
ContractName.fromString("rwa_sponsor"),
EntrypointName.fromString("permit"),
permitRequestSchemaBase64,
undefined,
permitErrorSchemaBase64,
),
supportsPermit: new ReceiveMethod<
SupportsPermitRequest,
SupportsPermitResponse,
SupportsPermitError
>(
ContractName.fromString("rwa_sponsor"),
EntrypointName.fromString("supportsPermit"),
supportsPermitRequestSchemaBase64,
supportsPermitResponseSchemaBase64,
supportsPermitErrorSchemaBase64,
),
deserializeEvent: (event: ContractEvent.Type): event => {
return ContractEvent.parseWithSchemaTypeBase64(
event,
eventSchemaBase64,
) as event;
},
};
export default rwaSponsor;