@algorandfoundation/algokit-client-generator 6.0.2-beta.1 → 7.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/app-client-context.d.ts +122 -0
- package/client/app-client-context.js +212 -0
- package/client/app-client-context.js.map +1 -0
- package/client/app-client-context.mjs +209 -0
- package/client/app-client-context.mjs.map +1 -0
- package/client/app-client.js +29 -51
- package/client/app-client.js.map +1 -1
- package/client/app-client.mjs +29 -51
- package/client/app-client.mjs.map +1 -1
- package/client/app-factory.js +23 -27
- package/client/app-factory.js.map +1 -1
- package/client/app-factory.mjs +23 -27
- package/client/app-factory.mjs.map +1 -1
- package/client/app-types.js +31 -60
- package/client/app-types.js.map +1 -1
- package/client/app-types.mjs +32 -61
- package/client/app-types.mjs.map +1 -1
- package/client/call-composer-types.js +31 -34
- package/client/call-composer-types.js.map +1 -1
- package/client/call-composer-types.mjs +31 -34
- package/client/call-composer-types.mjs.map +1 -1
- package/client/call-composer.js +24 -31
- package/client/call-composer.js.map +1 -1
- package/client/call-composer.mjs +24 -31
- package/client/call-composer.mjs.map +1 -1
- package/client/deploy-types.d.ts +1 -11
- package/client/deploy-types.js +28 -53
- package/client/deploy-types.js.map +1 -1
- package/client/deploy-types.mjs +29 -52
- package/client/deploy-types.mjs.map +1 -1
- package/client/generate.d.ts +1 -1
- package/client/generate.js +2 -2
- package/client/generate.js.map +1 -1
- package/client/generate.mjs +2 -2
- package/client/generate.mjs.map +1 -1
- package/client/generator-context.d.ts +3 -5
- package/client/generator-context.js +4 -10
- package/client/generator-context.js.map +1 -1
- package/client/generator-context.mjs +4 -10
- package/client/generator-context.mjs.map +1 -1
- package/client/helpers/contains-non-void-method.d.ts +2 -2
- package/client/helpers/contains-non-void-method.js +3 -2
- package/client/helpers/contains-non-void-method.js.map +1 -1
- package/client/helpers/contains-non-void-method.mjs +3 -2
- package/client/helpers/contains-non-void-method.mjs.map +1 -1
- package/client/helpers/get-equivalent-type.d.ts +3 -5
- package/client/helpers/get-equivalent-type.js +53 -54
- package/client/helpers/get-equivalent-type.js.map +1 -1
- package/client/helpers/get-equivalent-type.mjs +53 -55
- package/client/helpers/get-equivalent-type.mjs.map +1 -1
- package/client/imports.d.ts +1 -2
- package/client/imports.js +10 -19
- package/client/imports.js.map +1 -1
- package/client/imports.mjs +10 -19
- package/client/imports.mjs.map +1 -1
- package/client/params-factory.js +47 -50
- package/client/params-factory.js.map +1 -1
- package/client/params-factory.mjs +47 -50
- package/client/params-factory.mjs.map +1 -1
- package/package.json +2 -3
- package/schema/load.d.ts +1 -1
- package/schema/load.js.map +1 -1
- package/schema/load.mjs.map +1 -1
- package/client/helpers/get-call-config-summary.d.ts +0 -19
- package/client/helpers/get-call-config-summary.js +0 -60
- package/client/helpers/get-call-config-summary.js.map +0 -1
- package/client/helpers/get-call-config-summary.mjs +0 -57
- package/client/helpers/get-call-config-summary.mjs.map +0 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Arc56Contract, ABIType, ABIReferenceType, ABITransactionType, AVMType } from '@algorandfoundation/algokit-utils/abi';
|
|
2
|
+
import { Sanitizer } from '../util/sanitization';
|
|
3
|
+
export type AppClientContext = {
|
|
4
|
+
name: SanitizableString;
|
|
5
|
+
methods: AppClientMethodContext[];
|
|
6
|
+
abiMethods: AbiMethodClientContext[];
|
|
7
|
+
state: {
|
|
8
|
+
keys: {
|
|
9
|
+
global: {
|
|
10
|
+
[name: string]: StorageKeyContext;
|
|
11
|
+
};
|
|
12
|
+
local: {
|
|
13
|
+
[name: string]: StorageKeyContext;
|
|
14
|
+
};
|
|
15
|
+
box: {
|
|
16
|
+
[name: string]: StorageKeyContext;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/** Mapping of human-readable names to StorageMap objects */
|
|
20
|
+
maps: {
|
|
21
|
+
global: {
|
|
22
|
+
[name: string]: StorageMapContext;
|
|
23
|
+
};
|
|
24
|
+
local: {
|
|
25
|
+
[name: string]: StorageMapContext;
|
|
26
|
+
};
|
|
27
|
+
box: {
|
|
28
|
+
[name: string]: StorageMapContext;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
structs: Record<string, StructContext>;
|
|
33
|
+
createMethods: AppClientMethodContext[];
|
|
34
|
+
updateMethods: AppClientMethodContext[];
|
|
35
|
+
deleteMethods: AppClientMethodContext[];
|
|
36
|
+
optInMethods: AppClientMethodContext[];
|
|
37
|
+
closeOutMethods: AppClientMethodContext[];
|
|
38
|
+
clearStateMethods: AppClientMethodContext[];
|
|
39
|
+
noOpMethods: AppClientMethodContext[];
|
|
40
|
+
bareMethod: BareMethodClientContext;
|
|
41
|
+
templateVariables: Record<string, TemplateVariableContext>;
|
|
42
|
+
};
|
|
43
|
+
export type AppClientMethodContext = AbiMethodClientContext | BareMethodClientContext;
|
|
44
|
+
export declare function isAbiMethod(method: AppClientMethodContext): method is AbiMethodClientContext;
|
|
45
|
+
export type StructContext = {
|
|
46
|
+
type: TypeContext;
|
|
47
|
+
tsObjDef: string;
|
|
48
|
+
tsTupDef: string;
|
|
49
|
+
};
|
|
50
|
+
export type StorageKeyContext = {
|
|
51
|
+
desc?: string;
|
|
52
|
+
keyType: TypeContext;
|
|
53
|
+
valueType: TypeContext;
|
|
54
|
+
key: string;
|
|
55
|
+
};
|
|
56
|
+
/** Describes a mapping of key-value pairs in storage */
|
|
57
|
+
export type StorageMapContext = {
|
|
58
|
+
desc?: string;
|
|
59
|
+
keyType: TypeContext;
|
|
60
|
+
valueType: TypeContext;
|
|
61
|
+
prefix?: string;
|
|
62
|
+
};
|
|
63
|
+
export type TypeContext = {
|
|
64
|
+
type: ABIType | AVMType;
|
|
65
|
+
isAvmBytes?: boolean;
|
|
66
|
+
tsInType: string;
|
|
67
|
+
tsOutType: string;
|
|
68
|
+
};
|
|
69
|
+
export type TemplateVariableContext = {
|
|
70
|
+
type: TypeContext;
|
|
71
|
+
value: string | undefined;
|
|
72
|
+
};
|
|
73
|
+
export type AbiMethodClientContext = {
|
|
74
|
+
isBare: false;
|
|
75
|
+
desc: string | undefined;
|
|
76
|
+
name: SanitizableString;
|
|
77
|
+
baseNameIsUnique: boolean;
|
|
78
|
+
uniqueName: SanitizableString;
|
|
79
|
+
signature: string;
|
|
80
|
+
args: MethodArgClientContext[];
|
|
81
|
+
returns: MethodReturnClientContext;
|
|
82
|
+
createActions: MethodOcas;
|
|
83
|
+
callActions: MethodOcas;
|
|
84
|
+
readonly: boolean;
|
|
85
|
+
};
|
|
86
|
+
export type BareMethodClientContext = {
|
|
87
|
+
isBare: true;
|
|
88
|
+
createActions: MethodOcas;
|
|
89
|
+
callActions: MethodOcas;
|
|
90
|
+
};
|
|
91
|
+
export type MethodOcas = {
|
|
92
|
+
raw: string[];
|
|
93
|
+
any: boolean;
|
|
94
|
+
noOp: boolean;
|
|
95
|
+
optIn: boolean;
|
|
96
|
+
closeOut: boolean;
|
|
97
|
+
clearState: boolean;
|
|
98
|
+
updateApplication: boolean;
|
|
99
|
+
deleteApplication: boolean;
|
|
100
|
+
inputType: {
|
|
101
|
+
isOptional: boolean;
|
|
102
|
+
typeLiteral: string | undefined;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
export type MethodArgClientContext = {
|
|
106
|
+
name: SanitizableString | undefined;
|
|
107
|
+
desc: string | undefined;
|
|
108
|
+
type: ABIType | ABIReferenceType | ABITransactionType;
|
|
109
|
+
tsInType: string;
|
|
110
|
+
defaultValue: unknown;
|
|
111
|
+
};
|
|
112
|
+
export type MethodReturnClientContext = {
|
|
113
|
+
tsOutType: string;
|
|
114
|
+
type: ABIType | undefined;
|
|
115
|
+
desc: string | undefined;
|
|
116
|
+
};
|
|
117
|
+
export type SanitizableString = {
|
|
118
|
+
original: string;
|
|
119
|
+
} & {
|
|
120
|
+
[key in keyof Sanitizer]: ReturnType<Sanitizer[key]>;
|
|
121
|
+
};
|
|
122
|
+
export declare function createAppClientContext(appSpec: Arc56Contract, sanitizer: Sanitizer): AppClientContext;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var abi = require('@algorandfoundation/algokit-utils/abi');
|
|
4
|
+
var getEquivalentType = require('./helpers/get-equivalent-type.js');
|
|
5
|
+
|
|
6
|
+
function isAbiMethod(method) {
|
|
7
|
+
return !method.isBare;
|
|
8
|
+
}
|
|
9
|
+
function createAppClientContext(appSpec, sanitizer) {
|
|
10
|
+
const methods = [];
|
|
11
|
+
for (const m of appSpec.methods) {
|
|
12
|
+
const abiMethod = abi.arc56MethodToABIMethod(m, appSpec);
|
|
13
|
+
const baseNameIsUnique = appSpec.methods.filter((o) => o.name === m.name).length === 1;
|
|
14
|
+
methods.push({
|
|
15
|
+
isBare: false,
|
|
16
|
+
name: createSanitizableString(m.name, sanitizer),
|
|
17
|
+
desc: m.desc,
|
|
18
|
+
baseNameIsUnique,
|
|
19
|
+
uniqueName: createSanitizableString(baseNameIsUnique ? m.name : abiMethod.getSignature(), sanitizer),
|
|
20
|
+
args: abiMethod.args.map((a) => {
|
|
21
|
+
return {
|
|
22
|
+
name: a.name ? createSanitizableString(a.name, sanitizer) : undefined,
|
|
23
|
+
desc: a.description,
|
|
24
|
+
type: a.type,
|
|
25
|
+
tsInType: getEquivalentType.getEquivalentType(a.type, 'input', sanitizer),
|
|
26
|
+
defaultValue: Boolean(a.defaultValue),
|
|
27
|
+
};
|
|
28
|
+
}),
|
|
29
|
+
callActions: buildOcas(m.actions.call),
|
|
30
|
+
createActions: buildOcas(m.actions.create),
|
|
31
|
+
readonly: Boolean(m.readonly),
|
|
32
|
+
signature: abiMethod.getSignature(),
|
|
33
|
+
returns: {
|
|
34
|
+
tsOutType: getEquivalentType.getEquivalentType(abiMethod.returns.type, 'output', sanitizer),
|
|
35
|
+
type: abiMethod.returns.type === 'void' ? undefined : abiMethod.returns.type,
|
|
36
|
+
desc: abiMethod.returns.description,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const bareMethod = {
|
|
41
|
+
isBare: true,
|
|
42
|
+
createActions: buildOcas(appSpec.bareActions.create),
|
|
43
|
+
callActions: buildOcas(appSpec.bareActions.call),
|
|
44
|
+
};
|
|
45
|
+
if (bareMethod.createActions.any || bareMethod.callActions.any) {
|
|
46
|
+
methods.push(bareMethod);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
name: createSanitizableString(appSpec.name, sanitizer),
|
|
50
|
+
methods,
|
|
51
|
+
bareMethod,
|
|
52
|
+
createMethods: methods.filter((m) => m.createActions.any),
|
|
53
|
+
updateMethods: methods.filter((m) => m.callActions.updateApplication),
|
|
54
|
+
deleteMethods: methods.filter((m) => m.callActions.deleteApplication),
|
|
55
|
+
noOpMethods: methods.filter((m) => m.callActions.noOp),
|
|
56
|
+
optInMethods: methods.filter((m) => m.callActions.optIn),
|
|
57
|
+
closeOutMethods: methods.filter((m) => m.callActions.closeOut),
|
|
58
|
+
clearStateMethods: methods.filter((m) => m.callActions.clearState),
|
|
59
|
+
abiMethods: methods.filter(isAbiMethod),
|
|
60
|
+
state: {
|
|
61
|
+
maps: {
|
|
62
|
+
global: buildStorageMap(appSpec.state.maps.global, appSpec, sanitizer),
|
|
63
|
+
local: buildStorageMap(appSpec.state.maps.local, appSpec, sanitizer),
|
|
64
|
+
box: buildStorageMap(appSpec.state.maps.box, appSpec, sanitizer),
|
|
65
|
+
},
|
|
66
|
+
keys: {
|
|
67
|
+
global: buildStorageKey(appSpec.state.keys.global, appSpec, sanitizer),
|
|
68
|
+
local: buildStorageKey(appSpec.state.keys.local, appSpec, sanitizer),
|
|
69
|
+
box: buildStorageKey(appSpec.state.keys.box, appSpec, sanitizer),
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
structs: mapRecord(appSpec.structs, (def, name) => buildStructCtx(name, appSpec, sanitizer)),
|
|
73
|
+
templateVariables: mapRecord(appSpec.templateVariables ?? {}, (v) => ({
|
|
74
|
+
value: v.value,
|
|
75
|
+
type: buildTypeContext(v.type, appSpec, sanitizer),
|
|
76
|
+
})),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function buildStructCtx(name, appSpec, sanitizer) {
|
|
80
|
+
const typeCtx = buildTypeContext(name, appSpec, sanitizer);
|
|
81
|
+
const abiType = typeCtx.type;
|
|
82
|
+
if (!(abiType instanceof abi.ABIStructType)) {
|
|
83
|
+
throw new Error(`Expected abiType to be ABIStructType`);
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
type: typeCtx,
|
|
87
|
+
tsObjDef: buildStructObjDef(abiType.structFields, appSpec, sanitizer, 1),
|
|
88
|
+
tsTupDef: `[${Array.from(buildStructTupleDef(abiType.structFields, appSpec, sanitizer)).join(', ')}]`,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function buildStructObjDef(fields, appSpec, sanitizer, indent) {
|
|
92
|
+
const indentStr = ' '.repeat(indent);
|
|
93
|
+
const closingIndent = ' '.repeat(indent - 1);
|
|
94
|
+
const lines = [];
|
|
95
|
+
for (const field of fields) {
|
|
96
|
+
const typeDef = Array.isArray(field.type)
|
|
97
|
+
? buildStructObjDef(field.type, appSpec, sanitizer, indent + 1)
|
|
98
|
+
: getEquivalentType.abiTypeToTs(field.type, 'output', sanitizer);
|
|
99
|
+
lines.push(`${indentStr}${sanitizer.makeSafePropertyIdentifier(field.name)}: ${typeDef}`);
|
|
100
|
+
}
|
|
101
|
+
return `{\n${lines.join(',\n')}\n${closingIndent}}`;
|
|
102
|
+
}
|
|
103
|
+
function* buildStructTupleDef(fields, appSpec, sanitizer) {
|
|
104
|
+
for (const field of fields) {
|
|
105
|
+
let typeDef;
|
|
106
|
+
if (Array.isArray(field.type)) {
|
|
107
|
+
typeDef = `[${Array.from(buildStructTupleDef(field.type, appSpec, sanitizer)).join(', ')}]`;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
typeDef = getEquivalentType.abiTypeToTs(field.type, 'output', sanitizer);
|
|
111
|
+
}
|
|
112
|
+
yield `${typeDef}`;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function buildStorageMap(maps, appSpec, sanitizer) {
|
|
116
|
+
return mapRecord(maps, (v) => ({
|
|
117
|
+
desc: v.desc,
|
|
118
|
+
valueType: buildTypeContext(v.valueType, appSpec, sanitizer),
|
|
119
|
+
keyType: buildTypeContext(v.keyType, appSpec, sanitizer),
|
|
120
|
+
prefix: v.prefix,
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
function buildStorageKey(keys, appSpec, sanitizer) {
|
|
124
|
+
return mapRecord(keys, (v) => ({
|
|
125
|
+
desc: v.desc,
|
|
126
|
+
valueType: buildTypeContext(v.valueType, appSpec, sanitizer),
|
|
127
|
+
keyType: buildTypeContext(v.valueType, appSpec, sanitizer),
|
|
128
|
+
key: v.key,
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
function mapRecord(input, mapper) {
|
|
132
|
+
return Object.fromEntries(Object.entries(input).map(([k, v]) => [k, mapper(v, k)]));
|
|
133
|
+
}
|
|
134
|
+
function createSanitizableString(name, sanitizer) {
|
|
135
|
+
return new Proxy({}, {
|
|
136
|
+
get(target, property) {
|
|
137
|
+
if (property === 'toString')
|
|
138
|
+
return () => name;
|
|
139
|
+
if (property === 'original')
|
|
140
|
+
return name;
|
|
141
|
+
if (property in sanitizer) {
|
|
142
|
+
return sanitizer[property](name);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function buildOcas(actions) {
|
|
148
|
+
const isOptional = actions.includes('NoOp') || actions.length === 1;
|
|
149
|
+
const typeLiteral = actions.length
|
|
150
|
+
? `{ onComplete${isOptional ? '?' : ''}: ${actions.map((oc) => `OnApplicationComplete.${oc}`).join(' | ')} }`
|
|
151
|
+
: undefined;
|
|
152
|
+
return {
|
|
153
|
+
raw: actions,
|
|
154
|
+
any: Boolean(actions.length),
|
|
155
|
+
noOp: actions.includes('NoOp'),
|
|
156
|
+
optIn: actions.includes('OptIn'),
|
|
157
|
+
closeOut: actions.includes('CloseOut'),
|
|
158
|
+
clearState: actions.includes('ClearState'),
|
|
159
|
+
updateApplication: actions.includes('UpdateApplication'),
|
|
160
|
+
deleteApplication: actions.includes('DeleteApplication'),
|
|
161
|
+
inputType: {
|
|
162
|
+
isOptional,
|
|
163
|
+
typeLiteral,
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function buildTypeContext(typeName, appSpec, sanitizer) {
|
|
168
|
+
switch (typeName) {
|
|
169
|
+
case 'AVMBytes':
|
|
170
|
+
return {
|
|
171
|
+
isAvmBytes: true,
|
|
172
|
+
type: typeName,
|
|
173
|
+
tsInType: 'Uint8Array | string',
|
|
174
|
+
tsOutType: 'Uint8Array',
|
|
175
|
+
};
|
|
176
|
+
case 'AVMString':
|
|
177
|
+
return {
|
|
178
|
+
type: typeName,
|
|
179
|
+
tsInType: 'string',
|
|
180
|
+
tsOutType: 'string',
|
|
181
|
+
};
|
|
182
|
+
case 'AVMUint64':
|
|
183
|
+
return {
|
|
184
|
+
type: typeName,
|
|
185
|
+
tsInType: 'bigint',
|
|
186
|
+
tsOutType: 'bigint',
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
if (typeName in appSpec.structs) {
|
|
190
|
+
return {
|
|
191
|
+
type: abi.ABIStructType.fromStruct(typeName, appSpec.structs),
|
|
192
|
+
tsInType: sanitizer.makeSafeTypeIdentifier(typeName),
|
|
193
|
+
tsOutType: sanitizer.makeSafeTypeIdentifier(typeName),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
// Otherwise parse as ABI type
|
|
197
|
+
try {
|
|
198
|
+
const abiType = abi.ABIType.from(typeName);
|
|
199
|
+
return {
|
|
200
|
+
type: abiType,
|
|
201
|
+
tsInType: getEquivalentType.abiTypeToTs(abiType, 'input', sanitizer),
|
|
202
|
+
tsOutType: getEquivalentType.abiTypeToTs(abiType, 'output', sanitizer),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
throw new Error(`Failed to parse storage type '${typeName}': ${error}`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
exports.createAppClientContext = createAppClientContext;
|
|
211
|
+
exports.isAbiMethod = isAbiMethod;
|
|
212
|
+
//# sourceMappingURL=app-client-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-client-context.js","sources":["../../src/client/app-client-context.ts"],"sourcesContent":["import {\n arc56MethodToABIMethod,\n Arc56Contract,\n ABIType,\n ABIReferenceType,\n ABITransactionType,\n AVMType,\n ABIStructField,\n ABIStructType,\n StorageKey,\n StorageMap,\n} from '@algorandfoundation/algokit-utils/abi'\nimport { Sanitizer } from '../util/sanitization'\nimport { abiTypeToTs, getEquivalentType } from './helpers/get-equivalent-type'\n\nexport type AppClientContext = {\n name: SanitizableString\n\n methods: AppClientMethodContext[]\n abiMethods: AbiMethodClientContext[]\n\n state: {\n keys: {\n global: {\n [name: string]: StorageKeyContext\n }\n local: {\n [name: string]: StorageKeyContext\n }\n box: {\n [name: string]: StorageKeyContext\n }\n }\n /** Mapping of human-readable names to StorageMap objects */\n maps: {\n global: {\n [name: string]: StorageMapContext\n }\n local: {\n [name: string]: StorageMapContext\n }\n box: {\n [name: string]: StorageMapContext\n }\n }\n }\n\n structs: Record<string, StructContext>\n\n createMethods: AppClientMethodContext[]\n updateMethods: AppClientMethodContext[]\n deleteMethods: AppClientMethodContext[]\n optInMethods: AppClientMethodContext[]\n closeOutMethods: AppClientMethodContext[]\n clearStateMethods: AppClientMethodContext[]\n noOpMethods: AppClientMethodContext[]\n\n bareMethod: BareMethodClientContext\n\n templateVariables: Record<string, TemplateVariableContext>\n}\n\nexport type AppClientMethodContext = AbiMethodClientContext | BareMethodClientContext\n\nexport function isAbiMethod(method: AppClientMethodContext): method is AbiMethodClientContext {\n return !method.isBare\n}\n\nexport type StructContext = {\n type: TypeContext\n tsObjDef: string\n tsTupDef: string\n}\n\nexport type StorageKeyContext = {\n desc?: string\n keyType: TypeContext\n valueType: TypeContext\n key: string\n}\n/** Describes a mapping of key-value pairs in storage */\nexport type StorageMapContext = {\n desc?: string\n keyType: TypeContext\n valueType: TypeContext\n prefix?: string\n}\n\nexport type TypeContext = {\n type: ABIType | AVMType\n isAvmBytes?: boolean\n tsInType: string\n tsOutType: string\n}\n\nexport type TemplateVariableContext = {\n type: TypeContext\n value: string | undefined\n}\n\nexport type AbiMethodClientContext = {\n isBare: false\n desc: string | undefined\n name: SanitizableString\n baseNameIsUnique: boolean\n uniqueName: SanitizableString\n signature: string\n args: MethodArgClientContext[]\n returns: MethodReturnClientContext\n createActions: MethodOcas\n callActions: MethodOcas\n readonly: boolean\n}\nexport type BareMethodClientContext = {\n isBare: true\n //desc: string | undefined\n createActions: MethodOcas\n callActions: MethodOcas\n //readonly: boolean\n}\n\nexport type MethodOcas = {\n raw: string[]\n any: boolean\n noOp: boolean\n optIn: boolean\n closeOut: boolean\n clearState: boolean\n updateApplication: boolean\n deleteApplication: boolean\n\n inputType: {\n isOptional: boolean\n typeLiteral: string | undefined\n }\n}\n\nexport type MethodArgClientContext = {\n name: SanitizableString | undefined\n desc: string | undefined\n type: ABIType | ABIReferenceType | ABITransactionType\n tsInType: string\n defaultValue: unknown\n}\n\nexport type MethodReturnClientContext = {\n tsOutType: string\n type: ABIType | undefined\n desc: string | undefined\n}\n\nexport type SanitizableString = {\n original: string\n} & {\n [key in keyof Sanitizer]: ReturnType<Sanitizer[key]>\n}\n\nexport function createAppClientContext(appSpec: Arc56Contract, sanitizer: Sanitizer): AppClientContext {\n const methods: AppClientMethodContext[] = []\n\n for (const m of appSpec.methods) {\n const abiMethod = arc56MethodToABIMethod(m, appSpec)\n const baseNameIsUnique = appSpec.methods.filter((o) => o.name === m.name).length === 1\n methods.push({\n isBare: false,\n name: createSanitizableString(m.name, sanitizer),\n desc: m.desc,\n baseNameIsUnique,\n uniqueName: createSanitizableString(baseNameIsUnique ? m.name : abiMethod.getSignature(), sanitizer),\n args: abiMethod.args.map((a): MethodArgClientContext => {\n return {\n name: a.name ? createSanitizableString(a.name, sanitizer) : undefined,\n desc: a.description,\n type: a.type,\n tsInType: getEquivalentType(a.type, 'input', sanitizer),\n defaultValue: Boolean(a.defaultValue),\n }\n }),\n callActions: buildOcas(m.actions.call),\n createActions: buildOcas(m.actions.create),\n readonly: Boolean(m.readonly),\n signature: abiMethod.getSignature(),\n returns: {\n tsOutType: getEquivalentType(abiMethod.returns.type, 'output', sanitizer),\n type: abiMethod.returns.type === 'void' ? undefined : abiMethod.returns.type,\n desc: abiMethod.returns.description,\n },\n })\n }\n\n const bareMethod: BareMethodClientContext = {\n isBare: true,\n createActions: buildOcas(appSpec.bareActions.create),\n callActions: buildOcas(appSpec.bareActions.call),\n }\n if (bareMethod.createActions.any || bareMethod.callActions.any) {\n methods.push(bareMethod)\n }\n\n return {\n name: createSanitizableString(appSpec.name, sanitizer),\n methods,\n bareMethod,\n createMethods: methods.filter((m) => m.createActions.any),\n updateMethods: methods.filter((m) => m.callActions.updateApplication),\n deleteMethods: methods.filter((m) => m.callActions.deleteApplication),\n noOpMethods: methods.filter((m) => m.callActions.noOp),\n optInMethods: methods.filter((m) => m.callActions.optIn),\n closeOutMethods: methods.filter((m) => m.callActions.closeOut),\n clearStateMethods: methods.filter((m) => m.callActions.clearState),\n abiMethods: methods.filter(isAbiMethod),\n\n state: {\n maps: {\n global: buildStorageMap(appSpec.state.maps.global, appSpec, sanitizer),\n local: buildStorageMap(appSpec.state.maps.local, appSpec, sanitizer),\n box: buildStorageMap(appSpec.state.maps.box, appSpec, sanitizer),\n },\n keys: {\n global: buildStorageKey(appSpec.state.keys.global, appSpec, sanitizer),\n local: buildStorageKey(appSpec.state.keys.local, appSpec, sanitizer),\n box: buildStorageKey(appSpec.state.keys.box, appSpec, sanitizer),\n },\n },\n\n structs: mapRecord(appSpec.structs, (def, name) => buildStructCtx(name, appSpec, sanitizer)),\n\n templateVariables: mapRecord(appSpec.templateVariables ?? {}, (v) => ({\n value: v.value,\n type: buildTypeContext(v.type, appSpec, sanitizer),\n })),\n }\n}\n\nfunction buildStructCtx(name: string, appSpec: Arc56Contract, sanitizer: Sanitizer): StructContext {\n const typeCtx = buildTypeContext(name, appSpec, sanitizer)\n\n const abiType = typeCtx.type\n if (!(abiType instanceof ABIStructType)) {\n throw new Error(`Expected abiType to be ABIStructType`)\n }\n\n return {\n type: typeCtx,\n tsObjDef: buildStructObjDef(abiType.structFields, appSpec, sanitizer, 1),\n tsTupDef: `[${Array.from(buildStructTupleDef(abiType.structFields, appSpec, sanitizer)).join(', ')}]`,\n }\n}\n\nfunction buildStructObjDef(fields: ABIStructField[], appSpec: Arc56Contract, sanitizer: Sanitizer, indent: number): string {\n const indentStr = ' '.repeat(indent)\n const closingIndent = ' '.repeat(indent - 1)\n const lines: string[] = []\n\n for (const field of fields) {\n const typeDef = Array.isArray(field.type)\n ? buildStructObjDef(field.type, appSpec, sanitizer, indent + 1)\n : abiTypeToTs(field.type, 'output', sanitizer)\n lines.push(`${indentStr}${sanitizer.makeSafePropertyIdentifier(field.name)}: ${typeDef}`)\n }\n\n return `{\\n${lines.join(',\\n')}\\n${closingIndent}}`\n}\nfunction* buildStructTupleDef(fields: ABIStructField[], appSpec: Arc56Contract, sanitizer: Sanitizer) {\n for (const field of fields) {\n let typeDef: string\n if (Array.isArray(field.type)) {\n typeDef = `[${Array.from(buildStructTupleDef(field.type, appSpec, sanitizer)).join(', ')}]`\n } else {\n typeDef = abiTypeToTs(field.type, 'output', sanitizer)\n }\n yield `${typeDef}`\n }\n}\n\nfunction buildStorageMap(\n maps: Record<string, StorageMap>,\n appSpec: Arc56Contract,\n sanitizer: Sanitizer,\n): Record<string, StorageMapContext> {\n return mapRecord(maps, (v) => ({\n desc: v.desc,\n valueType: buildTypeContext(v.valueType, appSpec, sanitizer),\n keyType: buildTypeContext(v.keyType, appSpec, sanitizer),\n prefix: v.prefix,\n }))\n}\nfunction buildStorageKey(\n keys: Record<string, StorageKey>,\n appSpec: Arc56Contract,\n sanitizer: Sanitizer,\n): Record<string, StorageKeyContext> {\n return mapRecord(keys, (v) => ({\n desc: v.desc,\n valueType: buildTypeContext(v.valueType, appSpec, sanitizer),\n keyType: buildTypeContext(v.valueType, appSpec, sanitizer),\n key: v.key,\n }))\n}\n\nfunction mapRecord<TIn, TOut>(input: Record<string, TIn>, mapper: (value: TIn, key: string) => TOut): Record<string, TOut> {\n return Object.fromEntries(Object.entries(input).map(([k, v]) => [k, mapper(v, k)]))\n}\n\nfunction createSanitizableString(name: string, sanitizer: Sanitizer): SanitizableString {\n return new Proxy<SanitizableString>({} as SanitizableString, {\n get(target, property) {\n if (property === 'toString') return () => name\n if (property === 'original') return name\n if (property in sanitizer) {\n return sanitizer[property as keyof Sanitizer](name)\n }\n },\n })\n}\n\nfunction buildOcas(actions: string[]): MethodOcas {\n const isOptional = actions.includes('NoOp') || actions.length === 1\n const typeLiteral = actions.length\n ? `{ onComplete${isOptional ? '?' : ''}: ${actions.map((oc) => `OnApplicationComplete.${oc}`).join(' | ')} }`\n : undefined\n\n return {\n raw: actions,\n any: Boolean(actions.length),\n noOp: actions.includes('NoOp'),\n optIn: actions.includes('OptIn'),\n closeOut: actions.includes('CloseOut'),\n clearState: actions.includes('ClearState'),\n updateApplication: actions.includes('UpdateApplication'),\n deleteApplication: actions.includes('DeleteApplication'),\n\n inputType: {\n isOptional,\n typeLiteral,\n },\n }\n}\n\nfunction buildTypeContext(typeName: string, appSpec: Arc56Contract, sanitizer: Sanitizer): TypeContext {\n switch (typeName) {\n case 'AVMBytes':\n return {\n isAvmBytes: true,\n type: typeName,\n tsInType: 'Uint8Array | string',\n tsOutType: 'Uint8Array',\n }\n case 'AVMString':\n return {\n type: typeName,\n tsInType: 'string',\n tsOutType: 'string',\n }\n case 'AVMUint64':\n return {\n type: typeName,\n tsInType: 'bigint',\n tsOutType: 'bigint',\n }\n }\n if (typeName in appSpec.structs) {\n return {\n type: ABIStructType.fromStruct(typeName, appSpec.structs),\n tsInType: sanitizer.makeSafeTypeIdentifier(typeName),\n tsOutType: sanitizer.makeSafeTypeIdentifier(typeName),\n }\n }\n // Otherwise parse as ABI type\n try {\n const abiType = ABIType.from(typeName)\n return {\n type: abiType,\n tsInType: abiTypeToTs(abiType, 'input', sanitizer),\n tsOutType: abiTypeToTs(abiType, 'output', sanitizer),\n }\n } catch (error) {\n throw new Error(`Failed to parse storage type '${typeName}': ${error}`)\n }\n}\n"],"names":["arc56MethodToABIMethod","getEquivalentType","ABIStructType","abiTypeToTs","ABIType"],"mappings":";;;;;AAgEM,SAAU,WAAW,CAAC,MAA8B,EAAA;AACxD,IAAA,OAAO,CAAC,MAAM,CAAC,MAAM;AACvB;AA2FM,SAAU,sBAAsB,CAAC,OAAsB,EAAE,SAAoB,EAAA;IACjF,MAAM,OAAO,GAA6B,EAAE;AAE5C,IAAA,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE;QAC/B,MAAM,SAAS,GAAGA,0BAAsB,CAAC,CAAC,EAAE,OAAO,CAAC;QACpD,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;QACtF,OAAO,CAAC,IAAI,CAAC;AACX,YAAA,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC;YAChD,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,gBAAgB;AAChB,YAAA,UAAU,EAAE,uBAAuB,CAAC,gBAAgB,GAAG,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC,YAAY,EAAE,EAAE,SAAS,CAAC;YACpG,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAA4B;gBACrD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CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC;YAClD,SAAS,EAAEA,6BAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC;SACrD;IACH;IAAE,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,CAAA,8BAAA,EAAiC,QAAQ,CAAA,GAAA,EAAM,KAAK,CAAA,CAAE,CAAC;IACzE;AACF;;;;;"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { arc56MethodToABIMethod, ABIStructType, ABIType } from '@algorandfoundation/algokit-utils/abi';
|
|
2
|
+
import { getEquivalentType, abiTypeToTs } from './helpers/get-equivalent-type.mjs';
|
|
3
|
+
|
|
4
|
+
function isAbiMethod(method) {
|
|
5
|
+
return !method.isBare;
|
|
6
|
+
}
|
|
7
|
+
function createAppClientContext(appSpec, sanitizer) {
|
|
8
|
+
const methods = [];
|
|
9
|
+
for (const m of appSpec.methods) {
|
|
10
|
+
const abiMethod = arc56MethodToABIMethod(m, appSpec);
|
|
11
|
+
const baseNameIsUnique = appSpec.methods.filter((o) => o.name === m.name).length === 1;
|
|
12
|
+
methods.push({
|
|
13
|
+
isBare: false,
|
|
14
|
+
name: createSanitizableString(m.name, sanitizer),
|
|
15
|
+
desc: m.desc,
|
|
16
|
+
baseNameIsUnique,
|
|
17
|
+
uniqueName: createSanitizableString(baseNameIsUnique ? m.name : abiMethod.getSignature(), sanitizer),
|
|
18
|
+
args: abiMethod.args.map((a) => {
|
|
19
|
+
return {
|
|
20
|
+
name: a.name ? createSanitizableString(a.name, sanitizer) : undefined,
|
|
21
|
+
desc: a.description,
|
|
22
|
+
type: a.type,
|
|
23
|
+
tsInType: getEquivalentType(a.type, 'input', sanitizer),
|
|
24
|
+
defaultValue: Boolean(a.defaultValue),
|
|
25
|
+
};
|
|
26
|
+
}),
|
|
27
|
+
callActions: buildOcas(m.actions.call),
|
|
28
|
+
createActions: buildOcas(m.actions.create),
|
|
29
|
+
readonly: Boolean(m.readonly),
|
|
30
|
+
signature: abiMethod.getSignature(),
|
|
31
|
+
returns: {
|
|
32
|
+
tsOutType: getEquivalentType(abiMethod.returns.type, 'output', sanitizer),
|
|
33
|
+
type: abiMethod.returns.type === 'void' ? undefined : abiMethod.returns.type,
|
|
34
|
+
desc: abiMethod.returns.description,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const bareMethod = {
|
|
39
|
+
isBare: true,
|
|
40
|
+
createActions: buildOcas(appSpec.bareActions.create),
|
|
41
|
+
callActions: buildOcas(appSpec.bareActions.call),
|
|
42
|
+
};
|
|
43
|
+
if (bareMethod.createActions.any || bareMethod.callActions.any) {
|
|
44
|
+
methods.push(bareMethod);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
name: createSanitizableString(appSpec.name, sanitizer),
|
|
48
|
+
methods,
|
|
49
|
+
bareMethod,
|
|
50
|
+
createMethods: methods.filter((m) => m.createActions.any),
|
|
51
|
+
updateMethods: methods.filter((m) => m.callActions.updateApplication),
|
|
52
|
+
deleteMethods: methods.filter((m) => m.callActions.deleteApplication),
|
|
53
|
+
noOpMethods: methods.filter((m) => m.callActions.noOp),
|
|
54
|
+
optInMethods: methods.filter((m) => m.callActions.optIn),
|
|
55
|
+
closeOutMethods: methods.filter((m) => m.callActions.closeOut),
|
|
56
|
+
clearStateMethods: methods.filter((m) => m.callActions.clearState),
|
|
57
|
+
abiMethods: methods.filter(isAbiMethod),
|
|
58
|
+
state: {
|
|
59
|
+
maps: {
|
|
60
|
+
global: buildStorageMap(appSpec.state.maps.global, appSpec, sanitizer),
|
|
61
|
+
local: buildStorageMap(appSpec.state.maps.local, appSpec, sanitizer),
|
|
62
|
+
box: buildStorageMap(appSpec.state.maps.box, appSpec, sanitizer),
|
|
63
|
+
},
|
|
64
|
+
keys: {
|
|
65
|
+
global: buildStorageKey(appSpec.state.keys.global, appSpec, sanitizer),
|
|
66
|
+
local: buildStorageKey(appSpec.state.keys.local, appSpec, sanitizer),
|
|
67
|
+
box: buildStorageKey(appSpec.state.keys.box, appSpec, sanitizer),
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
structs: mapRecord(appSpec.structs, (def, name) => buildStructCtx(name, appSpec, sanitizer)),
|
|
71
|
+
templateVariables: mapRecord(appSpec.templateVariables ?? {}, (v) => ({
|
|
72
|
+
value: v.value,
|
|
73
|
+
type: buildTypeContext(v.type, appSpec, sanitizer),
|
|
74
|
+
})),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function buildStructCtx(name, appSpec, sanitizer) {
|
|
78
|
+
const typeCtx = buildTypeContext(name, appSpec, sanitizer);
|
|
79
|
+
const abiType = typeCtx.type;
|
|
80
|
+
if (!(abiType instanceof ABIStructType)) {
|
|
81
|
+
throw new Error(`Expected abiType to be ABIStructType`);
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
type: typeCtx,
|
|
85
|
+
tsObjDef: buildStructObjDef(abiType.structFields, appSpec, sanitizer, 1),
|
|
86
|
+
tsTupDef: `[${Array.from(buildStructTupleDef(abiType.structFields, appSpec, sanitizer)).join(', ')}]`,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function buildStructObjDef(fields, appSpec, sanitizer, indent) {
|
|
90
|
+
const indentStr = ' '.repeat(indent);
|
|
91
|
+
const closingIndent = ' '.repeat(indent - 1);
|
|
92
|
+
const lines = [];
|
|
93
|
+
for (const field of fields) {
|
|
94
|
+
const typeDef = Array.isArray(field.type)
|
|
95
|
+
? buildStructObjDef(field.type, appSpec, sanitizer, indent + 1)
|
|
96
|
+
: abiTypeToTs(field.type, 'output', sanitizer);
|
|
97
|
+
lines.push(`${indentStr}${sanitizer.makeSafePropertyIdentifier(field.name)}: ${typeDef}`);
|
|
98
|
+
}
|
|
99
|
+
return `{\n${lines.join(',\n')}\n${closingIndent}}`;
|
|
100
|
+
}
|
|
101
|
+
function* buildStructTupleDef(fields, appSpec, sanitizer) {
|
|
102
|
+
for (const field of fields) {
|
|
103
|
+
let typeDef;
|
|
104
|
+
if (Array.isArray(field.type)) {
|
|
105
|
+
typeDef = `[${Array.from(buildStructTupleDef(field.type, appSpec, sanitizer)).join(', ')}]`;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
typeDef = abiTypeToTs(field.type, 'output', sanitizer);
|
|
109
|
+
}
|
|
110
|
+
yield `${typeDef}`;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function buildStorageMap(maps, appSpec, sanitizer) {
|
|
114
|
+
return mapRecord(maps, (v) => ({
|
|
115
|
+
desc: v.desc,
|
|
116
|
+
valueType: buildTypeContext(v.valueType, appSpec, sanitizer),
|
|
117
|
+
keyType: buildTypeContext(v.keyType, appSpec, sanitizer),
|
|
118
|
+
prefix: v.prefix,
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
function buildStorageKey(keys, appSpec, sanitizer) {
|
|
122
|
+
return mapRecord(keys, (v) => ({
|
|
123
|
+
desc: v.desc,
|
|
124
|
+
valueType: buildTypeContext(v.valueType, appSpec, sanitizer),
|
|
125
|
+
keyType: buildTypeContext(v.valueType, appSpec, sanitizer),
|
|
126
|
+
key: v.key,
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
function mapRecord(input, mapper) {
|
|
130
|
+
return Object.fromEntries(Object.entries(input).map(([k, v]) => [k, mapper(v, k)]));
|
|
131
|
+
}
|
|
132
|
+
function createSanitizableString(name, sanitizer) {
|
|
133
|
+
return new Proxy({}, {
|
|
134
|
+
get(target, property) {
|
|
135
|
+
if (property === 'toString')
|
|
136
|
+
return () => name;
|
|
137
|
+
if (property === 'original')
|
|
138
|
+
return name;
|
|
139
|
+
if (property in sanitizer) {
|
|
140
|
+
return sanitizer[property](name);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function buildOcas(actions) {
|
|
146
|
+
const isOptional = actions.includes('NoOp') || actions.length === 1;
|
|
147
|
+
const typeLiteral = actions.length
|
|
148
|
+
? `{ onComplete${isOptional ? '?' : ''}: ${actions.map((oc) => `OnApplicationComplete.${oc}`).join(' | ')} }`
|
|
149
|
+
: undefined;
|
|
150
|
+
return {
|
|
151
|
+
raw: actions,
|
|
152
|
+
any: Boolean(actions.length),
|
|
153
|
+
noOp: actions.includes('NoOp'),
|
|
154
|
+
optIn: actions.includes('OptIn'),
|
|
155
|
+
closeOut: actions.includes('CloseOut'),
|
|
156
|
+
clearState: actions.includes('ClearState'),
|
|
157
|
+
updateApplication: actions.includes('UpdateApplication'),
|
|
158
|
+
deleteApplication: actions.includes('DeleteApplication'),
|
|
159
|
+
inputType: {
|
|
160
|
+
isOptional,
|
|
161
|
+
typeLiteral,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function buildTypeContext(typeName, appSpec, sanitizer) {
|
|
166
|
+
switch (typeName) {
|
|
167
|
+
case 'AVMBytes':
|
|
168
|
+
return {
|
|
169
|
+
isAvmBytes: true,
|
|
170
|
+
type: typeName,
|
|
171
|
+
tsInType: 'Uint8Array | string',
|
|
172
|
+
tsOutType: 'Uint8Array',
|
|
173
|
+
};
|
|
174
|
+
case 'AVMString':
|
|
175
|
+
return {
|
|
176
|
+
type: typeName,
|
|
177
|
+
tsInType: 'string',
|
|
178
|
+
tsOutType: 'string',
|
|
179
|
+
};
|
|
180
|
+
case 'AVMUint64':
|
|
181
|
+
return {
|
|
182
|
+
type: typeName,
|
|
183
|
+
tsInType: 'bigint',
|
|
184
|
+
tsOutType: 'bigint',
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
if (typeName in appSpec.structs) {
|
|
188
|
+
return {
|
|
189
|
+
type: ABIStructType.fromStruct(typeName, appSpec.structs),
|
|
190
|
+
tsInType: sanitizer.makeSafeTypeIdentifier(typeName),
|
|
191
|
+
tsOutType: sanitizer.makeSafeTypeIdentifier(typeName),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
// Otherwise parse as ABI type
|
|
195
|
+
try {
|
|
196
|
+
const abiType = ABIType.from(typeName);
|
|
197
|
+
return {
|
|
198
|
+
type: abiType,
|
|
199
|
+
tsInType: abiTypeToTs(abiType, 'input', sanitizer),
|
|
200
|
+
tsOutType: abiTypeToTs(abiType, 'output', sanitizer),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
throw new Error(`Failed to parse storage type '${typeName}': ${error}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export { createAppClientContext, isAbiMethod };
|
|
209
|
+
//# sourceMappingURL=app-client-context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-client-context.mjs","sources":["../../src/client/app-client-context.ts"],"sourcesContent":["import {\n arc56MethodToABIMethod,\n Arc56Contract,\n ABIType,\n ABIReferenceType,\n ABITransactionType,\n AVMType,\n ABIStructField,\n ABIStructType,\n StorageKey,\n StorageMap,\n} from '@algorandfoundation/algokit-utils/abi'\nimport { Sanitizer } from '../util/sanitization'\nimport { abiTypeToTs, getEquivalentType } from './helpers/get-equivalent-type'\n\nexport type AppClientContext = {\n name: SanitizableString\n\n methods: AppClientMethodContext[]\n abiMethods: AbiMethodClientContext[]\n\n state: {\n keys: {\n global: {\n [name: string]: StorageKeyContext\n }\n local: {\n [name: string]: StorageKeyContext\n }\n box: {\n [name: string]: StorageKeyContext\n }\n }\n /** Mapping of human-readable names to StorageMap objects */\n maps: {\n global: {\n [name: string]: StorageMapContext\n }\n local: {\n [name: string]: StorageMapContext\n }\n box: {\n [name: string]: StorageMapContext\n }\n }\n }\n\n structs: Record<string, StructContext>\n\n createMethods: AppClientMethodContext[]\n updateMethods: AppClientMethodContext[]\n deleteMethods: AppClientMethodContext[]\n optInMethods: AppClientMethodContext[]\n closeOutMethods: AppClientMethodContext[]\n clearStateMethods: AppClientMethodContext[]\n noOpMethods: AppClientMethodContext[]\n\n bareMethod: BareMethodClientContext\n\n templateVariables: Record<string, TemplateVariableContext>\n}\n\nexport type AppClientMethodContext = AbiMethodClientContext | BareMethodClientContext\n\nexport function isAbiMethod(method: AppClientMethodContext): method is AbiMethodClientContext {\n return !method.isBare\n}\n\nexport type StructContext = {\n type: TypeContext\n tsObjDef: string\n tsTupDef: string\n}\n\nexport type StorageKeyContext = {\n desc?: string\n keyType: TypeContext\n valueType: TypeContext\n key: string\n}\n/** Describes a mapping of key-value pairs in storage */\nexport type StorageMapContext = {\n desc?: string\n keyType: TypeContext\n valueType: TypeContext\n prefix?: string\n}\n\nexport type TypeContext = {\n type: ABIType | AVMType\n isAvmBytes?: boolean\n tsInType: string\n tsOutType: string\n}\n\nexport type TemplateVariableContext = {\n type: TypeContext\n value: string | undefined\n}\n\nexport type AbiMethodClientContext = {\n isBare: false\n desc: string | undefined\n name: SanitizableString\n baseNameIsUnique: boolean\n uniqueName: SanitizableString\n signature: string\n args: MethodArgClientContext[]\n returns: MethodReturnClientContext\n createActions: MethodOcas\n callActions: MethodOcas\n readonly: boolean\n}\nexport type BareMethodClientContext = {\n isBare: true\n //desc: string | undefined\n createActions: MethodOcas\n callActions: MethodOcas\n //readonly: boolean\n}\n\nexport type MethodOcas = {\n raw: string[]\n any: boolean\n noOp: boolean\n optIn: boolean\n closeOut: boolean\n clearState: boolean\n updateApplication: boolean\n deleteApplication: boolean\n\n inputType: {\n isOptional: boolean\n typeLiteral: string | undefined\n }\n}\n\nexport type MethodArgClientContext = {\n name: SanitizableString | undefined\n desc: string | undefined\n type: ABIType | ABIReferenceType | ABITransactionType\n tsInType: string\n defaultValue: unknown\n}\n\nexport type MethodReturnClientContext = {\n tsOutType: string\n type: ABIType | undefined\n desc: string | undefined\n}\n\nexport type SanitizableString = {\n original: string\n} & {\n [key in keyof Sanitizer]: ReturnType<Sanitizer[key]>\n}\n\nexport function createAppClientContext(appSpec: Arc56Contract, sanitizer: Sanitizer): AppClientContext {\n const methods: AppClientMethodContext[] = []\n\n for (const m of appSpec.methods) {\n const abiMethod = arc56MethodToABIMethod(m, appSpec)\n const baseNameIsUnique = appSpec.methods.filter((o) => o.name === m.name).length === 1\n methods.push({\n isBare: false,\n name: createSanitizableString(m.name, sanitizer),\n desc: m.desc,\n baseNameIsUnique,\n uniqueName: createSanitizableString(baseNameIsUnique ? m.name : abiMethod.getSignature(), sanitizer),\n args: abiMethod.args.map((a): MethodArgClientContext => {\n return {\n name: a.name ? createSanitizableString(a.name, sanitizer) : undefined,\n desc: a.description,\n type: a.type,\n tsInType: getEquivalentType(a.type, 'input', sanitizer),\n defaultValue: Boolean(a.defaultValue),\n }\n }),\n callActions: buildOcas(m.actions.call),\n createActions: buildOcas(m.actions.create),\n readonly: Boolean(m.readonly),\n signature: abiMethod.getSignature(),\n returns: {\n tsOutType: getEquivalentType(abiMethod.returns.type, 'output', sanitizer),\n type: abiMethod.returns.type === 'void' ? undefined : abiMethod.returns.type,\n desc: abiMethod.returns.description,\n },\n })\n }\n\n const bareMethod: BareMethodClientContext = {\n isBare: true,\n createActions: buildOcas(appSpec.bareActions.create),\n callActions: buildOcas(appSpec.bareActions.call),\n }\n if (bareMethod.createActions.any || bareMethod.callActions.any) {\n methods.push(bareMethod)\n }\n\n return {\n name: createSanitizableString(appSpec.name, sanitizer),\n methods,\n bareMethod,\n createMethods: methods.filter((m) => m.createActions.any),\n updateMethods: methods.filter((m) => m.callActions.updateApplication),\n deleteMethods: methods.filter((m) => m.callActions.deleteApplication),\n noOpMethods: methods.filter((m) => m.callActions.noOp),\n optInMethods: methods.filter((m) => m.callActions.optIn),\n closeOutMethods: methods.filter((m) => m.callActions.closeOut),\n clearStateMethods: methods.filter((m) => m.callActions.clearState),\n abiMethods: methods.filter(isAbiMethod),\n\n state: {\n maps: {\n global: buildStorageMap(appSpec.state.maps.global, appSpec, sanitizer),\n local: buildStorageMap(appSpec.state.maps.local, appSpec, sanitizer),\n box: buildStorageMap(appSpec.state.maps.box, appSpec, sanitizer),\n },\n keys: {\n global: buildStorageKey(appSpec.state.keys.global, appSpec, sanitizer),\n local: buildStorageKey(appSpec.state.keys.local, appSpec, sanitizer),\n box: buildStorageKey(appSpec.state.keys.box, appSpec, sanitizer),\n },\n },\n\n structs: mapRecord(appSpec.structs, (def, name) => buildStructCtx(name, appSpec, sanitizer)),\n\n templateVariables: mapRecord(appSpec.templateVariables ?? {}, (v) => ({\n value: v.value,\n type: buildTypeContext(v.type, appSpec, sanitizer),\n })),\n }\n}\n\nfunction buildStructCtx(name: string, appSpec: Arc56Contract, sanitizer: Sanitizer): StructContext {\n const typeCtx = buildTypeContext(name, appSpec, sanitizer)\n\n const abiType = typeCtx.type\n if (!(abiType instanceof ABIStructType)) {\n throw new Error(`Expected abiType to be ABIStructType`)\n }\n\n return {\n type: typeCtx,\n tsObjDef: buildStructObjDef(abiType.structFields, appSpec, sanitizer, 1),\n tsTupDef: `[${Array.from(buildStructTupleDef(abiType.structFields, appSpec, sanitizer)).join(', ')}]`,\n }\n}\n\nfunction buildStructObjDef(fields: ABIStructField[], appSpec: Arc56Contract, sanitizer: Sanitizer, indent: number): string {\n const indentStr = ' '.repeat(indent)\n const closingIndent = ' '.repeat(indent - 1)\n const lines: string[] = []\n\n for (const field of fields) {\n const typeDef = Array.isArray(field.type)\n ? buildStructObjDef(field.type, appSpec, sanitizer, indent + 1)\n : abiTypeToTs(field.type, 'output', sanitizer)\n lines.push(`${indentStr}${sanitizer.makeSafePropertyIdentifier(field.name)}: ${typeDef}`)\n }\n\n return `{\\n${lines.join(',\\n')}\\n${closingIndent}}`\n}\nfunction* buildStructTupleDef(fields: ABIStructField[], appSpec: Arc56Contract, sanitizer: Sanitizer) {\n for (const field of fields) {\n let typeDef: string\n if (Array.isArray(field.type)) {\n typeDef = `[${Array.from(buildStructTupleDef(field.type, appSpec, sanitizer)).join(', ')}]`\n } else {\n typeDef = abiTypeToTs(field.type, 'output', sanitizer)\n }\n yield `${typeDef}`\n }\n}\n\nfunction buildStorageMap(\n maps: Record<string, StorageMap>,\n appSpec: Arc56Contract,\n sanitizer: Sanitizer,\n): Record<string, StorageMapContext> {\n return mapRecord(maps, (v) => ({\n desc: v.desc,\n valueType: buildTypeContext(v.valueType, appSpec, sanitizer),\n keyType: buildTypeContext(v.keyType, appSpec, sanitizer),\n prefix: v.prefix,\n }))\n}\nfunction buildStorageKey(\n keys: Record<string, StorageKey>,\n appSpec: Arc56Contract,\n sanitizer: Sanitizer,\n): Record<string, StorageKeyContext> {\n return mapRecord(keys, (v) => ({\n desc: v.desc,\n valueType: buildTypeContext(v.valueType, appSpec, sanitizer),\n keyType: buildTypeContext(v.valueType, appSpec, sanitizer),\n key: v.key,\n }))\n}\n\nfunction mapRecord<TIn, TOut>(input: Record<string, TIn>, mapper: (value: TIn, key: string) => TOut): Record<string, TOut> {\n return Object.fromEntries(Object.entries(input).map(([k, v]) => [k, mapper(v, k)]))\n}\n\nfunction createSanitizableString(name: string, sanitizer: Sanitizer): SanitizableString {\n return new Proxy<SanitizableString>({} as SanitizableString, {\n get(target, property) {\n if (property === 'toString') return () => name\n if (property === 'original') return name\n if (property in sanitizer) {\n return sanitizer[property as keyof Sanitizer](name)\n }\n },\n })\n}\n\nfunction buildOcas(actions: string[]): MethodOcas {\n const isOptional = actions.includes('NoOp') || actions.length === 1\n const typeLiteral = actions.length\n ? `{ onComplete${isOptional ? '?' : ''}: ${actions.map((oc) => `OnApplicationComplete.${oc}`).join(' | ')} }`\n : undefined\n\n return {\n raw: actions,\n any: Boolean(actions.length),\n noOp: actions.includes('NoOp'),\n optIn: actions.includes('OptIn'),\n closeOut: actions.includes('CloseOut'),\n clearState: actions.includes('ClearState'),\n updateApplication: actions.includes('UpdateApplication'),\n deleteApplication: actions.includes('DeleteApplication'),\n\n inputType: {\n isOptional,\n typeLiteral,\n },\n }\n}\n\nfunction buildTypeContext(typeName: string, appSpec: Arc56Contract, sanitizer: Sanitizer): TypeContext {\n switch (typeName) {\n case 'AVMBytes':\n return {\n isAvmBytes: true,\n type: typeName,\n tsInType: 'Uint8Array | string',\n tsOutType: 'Uint8Array',\n }\n case 'AVMString':\n return {\n type: typeName,\n tsInType: 'string',\n tsOutType: 'string',\n }\n case 'AVMUint64':\n return {\n type: typeName,\n tsInType: 'bigint',\n tsOutType: 'bigint',\n }\n }\n if (typeName in appSpec.structs) {\n return {\n type: ABIStructType.fromStruct(typeName, appSpec.structs),\n tsInType: sanitizer.makeSafeTypeIdentifier(typeName),\n tsOutType: sanitizer.makeSafeTypeIdentifier(typeName),\n }\n }\n // Otherwise parse as ABI type\n try {\n const abiType = ABIType.from(typeName)\n return {\n type: abiType,\n tsInType: abiTypeToTs(abiType, 'input', sanitizer),\n tsOutType: abiTypeToTs(abiType, 'output', sanitizer),\n }\n } catch (error) {\n throw new Error(`Failed to parse storage type '${typeName}': ${error}`)\n }\n}\n"],"names":[],"mappings":";;;AAgEM,SAAU,WAAW,CAAC,MAA8B,EAAA;AACxD,IAAA,OAAO,CAAC,MAAM,CAAC,MAAM;AACvB;AA2FM,SAAU,sBAAsB,CAAC,OAAsB,EAAE,SAAoB,EAAA;IACjF,MAAM,OAAO,GAA6B,EAAE;AAE5C,IAAA,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE;QAC/B,MAAM,SAAS,GAAG,sBAAsB,CAAC,CAAC,EAAE,OAAO,CAAC;QACpD,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;QACtF,OAAO,CAAC,IAAI,CAAC;AACX,YAAA,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC;YAChD,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,gBAAgB;AAChB,YAAA,UAAU,EAAE,uBAAuB,CAAC,gBAAgB,GAAG,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC,YAAY,E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