@algorandfoundation/algokit-client-generator 6.0.2-beta.1 → 7.0.0-alpha.1
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/deploy-types.d.ts +1 -11
- package/client/generate.d.ts +1 -1
- package/client/generator-context.d.ts +3 -5
- package/client/helpers/contains-non-void-method.d.ts +2 -2
- package/client/helpers/get-equivalent-type.d.ts +3 -5
- package/client/imports.d.ts +1 -2
- package/package.json +2 -3
- package/schema/load.d.ts +1 -1
- package/src/cli.js.map +1 -0
- package/src/cli.mjs.map +1 -0
- package/src/client/app-client-context.js +211 -0
- package/src/client/app-client-context.js.map +1 -0
- package/src/client/app-client-context.mjs +208 -0
- package/src/client/app-client-context.mjs.map +1 -0
- package/{client → src/client}/app-client.js +29 -51
- package/src/client/app-client.js.map +1 -0
- package/{client → src/client}/app-client.mjs +29 -51
- package/src/client/app-client.mjs.map +1 -0
- package/{client → src/client}/app-factory.js +23 -27
- package/src/client/app-factory.js.map +1 -0
- package/{client → src/client}/app-factory.mjs +23 -27
- package/src/client/app-factory.mjs.map +1 -0
- package/{client → src/client}/app-types.js +31 -60
- package/src/client/app-types.js.map +1 -0
- package/{client → src/client}/app-types.mjs +32 -61
- package/src/client/app-types.mjs.map +1 -0
- package/{client → src/client}/call-composer-types.js +31 -34
- package/src/client/call-composer-types.js.map +1 -0
- package/{client → src/client}/call-composer-types.mjs +31 -34
- package/src/client/call-composer-types.mjs.map +1 -0
- package/{client → src/client}/call-composer.js +24 -31
- package/src/client/call-composer.js.map +1 -0
- package/{client → src/client}/call-composer.mjs +24 -31
- package/src/client/call-composer.mjs.map +1 -0
- package/{client → src/client}/deploy-types.js +28 -53
- package/src/client/deploy-types.js.map +1 -0
- package/{client → src/client}/deploy-types.mjs +29 -52
- package/src/client/deploy-types.mjs.map +1 -0
- package/{client → src/client}/generate.js +2 -2
- package/src/client/generate.js.map +1 -0
- package/{client → src/client}/generate.mjs +2 -2
- package/src/client/generate.mjs.map +1 -0
- package/src/client/generator-context.js +24 -0
- package/src/client/generator-context.js.map +1 -0
- package/src/client/generator-context.mjs +21 -0
- package/src/client/generator-context.mjs.map +1 -0
- package/{client → src/client}/helpers/contains-non-void-method.js +3 -2
- package/src/client/helpers/contains-non-void-method.js.map +1 -0
- package/{client → src/client}/helpers/contains-non-void-method.mjs +3 -2
- package/src/client/helpers/contains-non-void-method.mjs.map +1 -0
- package/src/client/helpers/get-equivalent-type.js +80 -0
- package/src/client/helpers/get-equivalent-type.js.map +1 -0
- package/src/client/helpers/get-equivalent-type.mjs +77 -0
- package/src/client/helpers/get-equivalent-type.mjs.map +1 -0
- package/src/client/imports.js +18 -0
- package/src/client/imports.js.map +1 -0
- package/src/client/imports.mjs +16 -0
- package/src/client/imports.mjs.map +1 -0
- package/src/client/params-factory.js +125 -0
- package/src/client/params-factory.js.map +1 -0
- package/src/client/params-factory.mjs +123 -0
- package/src/client/params-factory.mjs.map +1 -0
- package/src/client/utility-types.js.map +1 -0
- package/src/client/utility-types.mjs.map +1 -0
- package/src/output/writer.js.map +1 -0
- package/src/output/writer.mjs.map +1 -0
- package/src/schema/load.js.map +1 -0
- package/src/schema/load.mjs.map +1 -0
- package/src/util/boom.js.map +1 -0
- package/src/util/boom.mjs.map +1 -0
- package/src/util/color-console.js.map +1 -0
- package/src/util/color-console.mjs.map +1 -0
- package/src/util/sanitization.js.map +1 -0
- package/src/util/sanitization.mjs.map +1 -0
- package/cli.js.map +0 -1
- package/cli.mjs.map +0 -1
- package/client/app-client.js.map +0 -1
- package/client/app-client.mjs.map +0 -1
- package/client/app-factory.js.map +0 -1
- package/client/app-factory.mjs.map +0 -1
- package/client/app-types.js.map +0 -1
- package/client/app-types.mjs.map +0 -1
- package/client/call-composer-types.js.map +0 -1
- package/client/call-composer-types.mjs.map +0 -1
- package/client/call-composer.js.map +0 -1
- package/client/call-composer.mjs.map +0 -1
- package/client/deploy-types.js.map +0 -1
- package/client/deploy-types.mjs.map +0 -1
- package/client/generate.js.map +0 -1
- package/client/generate.mjs.map +0 -1
- package/client/generator-context.js +0 -30
- package/client/generator-context.js.map +0 -1
- package/client/generator-context.mjs +0 -27
- package/client/generator-context.mjs.map +0 -1
- package/client/helpers/contains-non-void-method.js.map +0 -1
- package/client/helpers/contains-non-void-method.mjs.map +0 -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
- package/client/helpers/get-equivalent-type.js +0 -81
- package/client/helpers/get-equivalent-type.js.map +0 -1
- package/client/helpers/get-equivalent-type.mjs +0 -79
- package/client/helpers/get-equivalent-type.mjs.map +0 -1
- package/client/imports.js +0 -27
- package/client/imports.js.map +0 -1
- package/client/imports.mjs +0 -25
- package/client/imports.mjs.map +0 -1
- package/client/params-factory.js +0 -128
- package/client/params-factory.js.map +0 -1
- package/client/params-factory.mjs +0 -126
- package/client/params-factory.mjs.map +0 -1
- package/client/utility-types.js.map +0 -1
- package/client/utility-types.mjs.map +0 -1
- package/output/writer.js.map +0 -1
- package/output/writer.mjs.map +0 -1
- package/schema/load.js.map +0 -1
- package/schema/load.mjs.map +0 -1
- package/util/boom.js.map +0 -1
- package/util/boom.mjs.map +0 -1
- package/util/color-console.js.map +0 -1
- package/util/color-console.mjs.map +0 -1
- package/util/sanitization.js.map +0 -1
- package/util/sanitization.mjs.map +0 -1
- /package/{cli.js → src/cli.js} +0 -0
- /package/{cli.mjs → src/cli.mjs} +0 -0
- /package/{client → src/client}/utility-types.js +0 -0
- /package/{client → src/client}/utility-types.mjs +0 -0
- /package/{index.js → src/index.js} +0 -0
- /package/{index.js.map → src/index.js.map} +0 -0
- /package/{index.mjs → src/index.mjs} +0 -0
- /package/{index.mjs.map → src/index.mjs.map} +0 -0
- /package/{output → src/output}/writer.js +0 -0
- /package/{output → src/output}/writer.mjs +0 -0
- /package/{schema → src/schema}/application.schema.json.js +0 -0
- /package/{schema → src/schema}/application.schema.json.js.map +0 -0
- /package/{schema → src/schema}/application.schema.json.mjs +0 -0
- /package/{schema → src/schema}/application.schema.json.mjs.map +0 -0
- /package/{schema → src/schema}/arc56.schema.json.js +0 -0
- /package/{schema → src/schema}/arc56.schema.json.js.map +0 -0
- /package/{schema → src/schema}/arc56.schema.json.mjs +0 -0
- /package/{schema → src/schema}/arc56.schema.json.mjs.map +0 -0
- /package/{schema → src/schema}/contract.schema.json.js +0 -0
- /package/{schema → src/schema}/contract.schema.json.js.map +0 -0
- /package/{schema → src/schema}/contract.schema.json.mjs +0 -0
- /package/{schema → src/schema}/contract.schema.json.mjs.map +0 -0
- /package/{schema → src/schema}/load.js +0 -0
- /package/{schema → src/schema}/load.mjs +0 -0
- /package/{util → src/util}/boom.js +0 -0
- /package/{util → src/util}/boom.mjs +0 -0
- /package/{util → src/util}/color-console.js +0 -0
- /package/{util → src/util}/color-console.mjs +0 -0
- /package/{util → src/util}/sanitization.js +0 -0
- /package/{util → src/util}/sanitization.mjs +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-types.mjs","sources":["../../src/client/deploy-types.ts"],"sourcesContent":["import { DecIndent, DocumentParts, IncIndent, jsDoc, NewLine } from '../output/writer'\nimport { BARE_CALL, MethodIdentifier } from './helpers/get-call-config-summary'\nimport { GeneratorContext } from './generator-context'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport function getCreateOnCompleteOptions(method: MethodIdentifier, app: Arc56Contract) {\n const validCreateOnCompletes =\n method === BARE_CALL ? app.bareActions.create : app.methods.find((m) => new ABIMethod(m).getSignature() === method)?.actions?.create\n const hasNoOp = validCreateOnCompletes?.includes('NoOp')\n const onCompleteType = validCreateOnCompletes\n ? `{onComplete${hasNoOp ? '?' : ''}: ${validCreateOnCompletes.map((oc) => `OnApplicationComplete.${oc}OC`).join(' | ')}}`\n : {}\n return {\n type: onCompleteType,\n isOptional: hasNoOp,\n }\n}\n\nexport function getCallOnCompleteOptions(method: MethodIdentifier, app: Arc56Contract) {\n const validCallOnCompletes =\n method === BARE_CALL ? app.bareActions.call : app.methods.find((m) => new ABIMethod(m).getSignature() === method)?.actions?.call\n const hasNoOp = validCallOnCompletes?.includes('NoOp')\n const onCompleteType = validCallOnCompletes\n ? `{onComplete${hasNoOp ? '?' : ''}: ${validCallOnCompletes.map((oc) => `OnApplicationComplete.${oc}OC`).join(' | ')}}`\n : {}\n return {\n type: onCompleteType,\n isOptional: hasNoOp,\n }\n}\n\nexport function* deployTypes({ app, callConfig, sanitizer, methodSignatureToUniqueName }: GeneratorContext): DocumentParts {\n const name = sanitizer.makeSafeTypeIdentifier(app.name)\n\n if (callConfig.createMethods.length > 0) {\n yield* jsDoc('Defines supported create method params for this smart contract')\n yield `export type ${name}CreateCallParams =`\n yield IncIndent\n for (const method of callConfig.createMethods) {\n const onComplete = getCreateOnCompleteOptions(method, app)\n if (method === BARE_CALL) {\n yield `| Expand<AppClientBareCallParams & {method?: never} & ${onComplete.type} & CreateSchema>`\n } else {\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method)\n const uniqueName = methodSignatureToUniqueName[method]\n if (uniqueName !== method) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'} & ${onComplete.type} & CreateSchema>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'} & ${onComplete.type} & CreateSchema>`\n }\n }\n yield DecIndent\n }\n if (callConfig.updateMethods.length > 0) {\n yield* jsDoc('Defines supported update method params for this smart contract')\n yield `export type ${name}UpdateCallParams =`\n yield IncIndent\n for (const method of callConfig.updateMethods) {\n if (method === BARE_CALL) {\n yield `| Expand<AppClientBareCallParams> & {method?: never}`\n } else {\n const uniqueName = methodSignatureToUniqueName[method]\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method)\n if (uniqueName !== method) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'}>`\n }\n }\n yield DecIndent\n }\n\n if (callConfig.deleteMethods.length > 0) {\n yield* jsDoc('Defines supported delete method params for this smart contract')\n yield `export type ${name}DeleteCallParams =`\n yield IncIndent\n for (const method of callConfig.deleteMethods) {\n if (method === BARE_CALL) {\n yield `| Expand<AppClientBareCallParams> & {method?: never}`\n } else {\n const uniqueName = methodSignatureToUniqueName[method]\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method)\n if (uniqueName !== method) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'}>`\n }\n }\n yield DecIndent\n }\n\n yield* jsDoc('Defines arguments required for the deploy method.')\n yield `export type ${name}DeployParams = Expand<Omit<AppFactoryDeployParams, 'createParams' | 'updateParams' | 'deleteParams'> & {`\n yield IncIndent\n if (callConfig.createMethods.length) {\n yield* jsDoc(\n 'Create transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `createParams?: ${name}CreateCallParams`\n }\n if (callConfig.updateMethods.length) {\n yield* jsDoc(\n 'Update transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `updateParams?: ${name}UpdateCallParams`\n }\n if (callConfig.deleteMethods.length) {\n yield* jsDoc(\n 'Delete transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `deleteParams?: ${name}DeleteCallParams`\n }\n yield DecIndent\n yield `}>`\n yield NewLine\n}\n"],"names":[],"mappings":";;;;AAMM,SAAU,0BAA0B,CAAC,MAAwB,EAAE,GAAkB,EAAA;AACrF,IAAA,MAAM,sBAAsB,GAC1B,MAAM,KAAK,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,KAAK,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM;IACtI,MAAM,OAAO,GAAG,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC;IACxD,MAAM,cAAc,GAAG;AACrB,UAAE,CAAA,WAAA,EAAc,OAAO,GAAG,GAAG,GAAG,EAAE,CAAA,EAAA,EAAK,sBAAsB,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAA,sBAAA,EAAyB,EAAE,CAAA,EAAA,CAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA,CAAA;UACpH,EAAE;IACN,OAAO;AACL,QAAA,IAAI,EAAE,cAAc;AACpB,QAAA,UAAU,EAAE,OAAO;KACpB;AACH;AAEM,SAAU,wBAAwB,CAAC,MAAwB,EAAE,GAAkB,EAAA;AACnF,IAAA,MAAM,oBAAoB,GACxB,MAAM,KAAK,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,KAAK,MAAM,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,QAAA,OAAO,KAAK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;IAChD;AACA,IAAA,IAAI,UAAU,CAAC,aAAa,CAAC,MAAM,EAAE;AACnC,QAAA,OAAO,KAAK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;IAChD;AACA,IAAA,IAAI,UAAU,CAAC,aAAa,CAAC,MAAM,EAAE;AACnC,QAAA,OAAO,KAAK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;IAChD;AACA,IAAA,MAAM,SAAS;AACf,IAAA,MAAM,IAAI;AACV,IAAA,MAAM,OAAO;AACf;;;;"}
|
package/client/generate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sources":["../../src/client/generate.ts"],"sourcesContent":["import { DocumentParts, inline, NewLine } from '../output/writer'\nimport { paramsFactory } from './params-factory'\nimport { appClient } from './app-client'\nimport { deployTypes } from './deploy-types'\nimport { utilityTypes } from './utility-types'\nimport { imports } from './imports'\nimport { createGeneratorContext, GeneratorOptions } from './generator-context'\nimport { appTypes } from './app-types'\nimport { callComposerType } from './call-composer-types'\nimport { Arc56Contract, ProgramSourceInfo, StructField } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { appFactory } from './app-factory'\nimport { Sanitizer } from '../util/sanitization'\n\nfunction convertStructs(s: StructField[], sanitizer: Sanitizer): StructField[] {\n return s.map(\n ({ name, type }) =>\n ({\n name: sanitizer.makeSafePropertyIdentifier(name),\n type: typeof type === 'string' ? type : convertStructs(type, sanitizer),\n }) satisfies StructField,\n )\n}\n\nfunction shrinkAppSpec(app: Arc56Contract, options: GeneratorOptions): Arc56Contract {\n const strippedAppSpec = structuredClone(app)\n\n // Only keep the source info if it is needed for error mapping\n const shrinkSourceInfo = (sourceInfo: ProgramSourceInfo['sourceInfo']) => {\n return sourceInfo\n .filter((entry) => entry.errorMessage)\n .map((entry) => ({\n pc: entry.pc,\n errorMessage: entry.errorMessage,\n // Keep minimal context for error mapping if available\n ...(entry.teal !== undefined && { teal: entry.teal }),\n }))\n }\n\n // Keep only source info entries that can be used for approval and clear program error mapping\n if (strippedAppSpec.sourceInfo?.approval?.sourceInfo && strippedAppSpec.sourceInfo.approval.sourceInfo.length > 0) {\n strippedAppSpec.sourceInfo.approval.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.approval.sourceInfo)\n }\n\n if (strippedAppSpec.sourceInfo?.clear?.sourceInfo && strippedAppSpec.sourceInfo.clear.sourceInfo.length > 0) {\n strippedAppSpec.sourceInfo.clear.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.clear.sourceInfo)\n }\n\n if (strippedAppSpec.compilerInfo) {\n delete strippedAppSpec.compilerInfo\n }\n\n // These are used for deploying but not for calling deployed apps\n if (options.mode === 'minimal') {\n if (strippedAppSpec.source) {\n delete strippedAppSpec.source\n }\n if (strippedAppSpec.byteCode) {\n delete strippedAppSpec.byteCode\n }\n if (strippedAppSpec.templateVariables) {\n delete strippedAppSpec.templateVariables\n }\n if (strippedAppSpec.scratchVariables) {\n delete strippedAppSpec.scratchVariables\n }\n }\n return strippedAppSpec\n}\n\nexport function* generate(app: Arc56Contract, options?: Partial<GeneratorOptions>): DocumentParts {\n const resolvedOptions: GeneratorOptions = {\n // Set defaults\n preserveNames: false,\n mode: 'full',\n ...options,\n }\n const reduceAppSpec = shrinkAppSpec(app, resolvedOptions)\n\n const ctx = createGeneratorContext(reduceAppSpec, resolvedOptions)\n yield `/* eslint-disable */`\n yield `/**`\n yield ` * This file was automatically generated by @algorandfoundation/algokit-client-generator.`\n yield ` * DO NOT MODIFY IT BY HAND.`\n yield ` * requires: @algorandfoundation/algokit-utils: ^7`\n yield ` */`\n\n yield* imports(ctx)\n // Change the structs definition to sanitize property names according to the defined rules\n // for instance, this may (unless you passed in --preserve-names) convert properties like my_prop to myProp\n reduceAppSpec.structs = Object.fromEntries(\n Object.keys(reduceAppSpec.structs).map((key) => [key, convertStructs(reduceAppSpec.structs[key], ctx.sanitizer)]),\n )\n yield* inline('export const APP_SPEC: Arc56Contract = ', JSON.stringify(reduceAppSpec), ' as unknown as Arc56Contract')\n yield NewLine\n\n yield* utilityTypes()\n yield NewLine\n yield* appTypes(ctx)\n\n if (ctx.mode === 'full') {\n yield* deployTypes(ctx)\n }\n yield NewLine\n\n // Write a call factory\n yield* paramsFactory(ctx)\n yield NewLine\n // Write a factory in full mode\n if (ctx.mode === 'full') {\n yield* appFactory(ctx)\n }\n // Write a client\n yield* appClient(ctx)\n\n yield* callComposerType(ctx)\n}\n"],"names":["createGeneratorContext","imports","inline","NewLine","utilityTypes","appTypes","deployTypes","paramsFactory","appFactory","appClient","callComposerType"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,cAAc,CAAC,CAAgB,EAAE,SAAoB,EAAA;AAC5D,IAAA,OAAO,CAAC,CAAC,GAAG,CACV,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MACZ;AACC,QAAA,IAAI,EAAE,SAAS,CAAC,0BAA0B,CAAC,IAAI,CAAC;AAChD,QAAA,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC;AACxE,KAAA,CAAuB,CAC3B;AACH;AAEA,SAAS,aAAa,CAAC,GAAkB,EAAE,OAAyB,EAAA;AAClE,IAAA,MAAM,eAAe,GAAG,eAAe,CAAC,GAAG,CAAC;;AAG5C,IAAA,MAAM,gBAAgB,GAAG,CAAC,UAA2C,KAAI;AACvE,QAAA,OAAO;aACJ,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,YAAY;AACpC,aAAA,GAAG,CAAC,CAAC,KAAK,MAAM;YACf,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,YAAY,EAAE,KAAK,CAAC,YAA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;AAEA,IAAA,OAAOC,mBAAS,CAAC,GAAG,CAAC;AAErB,IAAA,OAAOC,kCAAgB,CAAC,GAAG,CAAC;AAC9B;;;;"}
|
package/client/generate.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.mjs","sources":["../../src/client/generate.ts"],"sourcesContent":["import { DocumentParts, inline, NewLine } from '../output/writer'\nimport { paramsFactory } from './params-factory'\nimport { appClient } from './app-client'\nimport { deployTypes } from './deploy-types'\nimport { utilityTypes } from './utility-types'\nimport { imports } from './imports'\nimport { createGeneratorContext, GeneratorOptions } from './generator-context'\nimport { appTypes } from './app-types'\nimport { callComposerType } from './call-composer-types'\nimport { Arc56Contract, ProgramSourceInfo, StructField } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { appFactory } from './app-factory'\nimport { Sanitizer } from '../util/sanitization'\n\nfunction convertStructs(s: StructField[], sanitizer: Sanitizer): StructField[] {\n return s.map(\n ({ name, type }) =>\n ({\n name: sanitizer.makeSafePropertyIdentifier(name),\n type: typeof type === 'string' ? type : convertStructs(type, sanitizer),\n }) satisfies StructField,\n )\n}\n\nfunction shrinkAppSpec(app: Arc56Contract, options: GeneratorOptions): Arc56Contract {\n const strippedAppSpec = structuredClone(app)\n\n // Only keep the source info if it is needed for error mapping\n const shrinkSourceInfo = (sourceInfo: ProgramSourceInfo['sourceInfo']) => {\n return sourceInfo\n .filter((entry) => entry.errorMessage)\n .map((entry) => ({\n pc: entry.pc,\n errorMessage: entry.errorMessage,\n // Keep minimal context for error mapping if available\n ...(entry.teal !== undefined && { teal: entry.teal }),\n }))\n }\n\n // Keep only source info entries that can be used for approval and clear program error mapping\n if (strippedAppSpec.sourceInfo?.approval?.sourceInfo && strippedAppSpec.sourceInfo.approval.sourceInfo.length > 0) {\n strippedAppSpec.sourceInfo.approval.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.approval.sourceInfo)\n }\n\n if (strippedAppSpec.sourceInfo?.clear?.sourceInfo && strippedAppSpec.sourceInfo.clear.sourceInfo.length > 0) {\n strippedAppSpec.sourceInfo.clear.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.clear.sourceInfo)\n }\n\n if (strippedAppSpec.compilerInfo) {\n delete strippedAppSpec.compilerInfo\n }\n\n // These are used for deploying but not for calling deployed apps\n if (options.mode === 'minimal') {\n if (strippedAppSpec.source) {\n delete strippedAppSpec.source\n }\n if (strippedAppSpec.byteCode) {\n delete strippedAppSpec.byteCode\n }\n if (strippedAppSpec.templateVariables) {\n delete strippedAppSpec.templateVariables\n }\n if (strippedAppSpec.scratchVariables) {\n delete strippedAppSpec.scratchVariables\n }\n }\n return strippedAppSpec\n}\n\nexport function* generate(app: Arc56Contract, options?: Partial<GeneratorOptions>): DocumentParts {\n const resolvedOptions: GeneratorOptions = {\n // Set defaults\n preserveNames: false,\n mode: 'full',\n ...options,\n }\n const reduceAppSpec = shrinkAppSpec(app, resolvedOptions)\n\n const ctx = createGeneratorContext(reduceAppSpec, resolvedOptions)\n yield `/* eslint-disable */`\n yield `/**`\n yield ` * This file was automatically generated by @algorandfoundation/algokit-client-generator.`\n yield ` * DO NOT MODIFY IT BY HAND.`\n yield ` * requires: @algorandfoundation/algokit-utils: ^7`\n yield ` */`\n\n yield* imports(ctx)\n // Change the structs definition to sanitize property names according to the defined rules\n // for instance, this may (unless you passed in --preserve-names) convert properties like my_prop to myProp\n reduceAppSpec.structs = Object.fromEntries(\n Object.keys(reduceAppSpec.structs).map((key) => [key, convertStructs(reduceAppSpec.structs[key], ctx.sanitizer)]),\n )\n yield* inline('export const APP_SPEC: Arc56Contract = ', JSON.stringify(reduceAppSpec), ' as unknown as Arc56Contract')\n yield NewLine\n\n yield* utilityTypes()\n yield NewLine\n yield* appTypes(ctx)\n\n if (ctx.mode === 'full') {\n yield* deployTypes(ctx)\n }\n yield NewLine\n\n // Write a call factory\n yield* paramsFactory(ctx)\n yield NewLine\n // Write a factory in full mode\n if (ctx.mode === 'full') {\n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,GAAG,MAAM,CAAC,WAAW,CACxC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAClH;AACD,IAAA,OAAO,MAAM,CAAC,yCAAyC,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,8BAA8B,CAAC;AACvH,IAAA,MAAM,OAAO;AAEb,IAAA,OAAO,YAAY,EAAE;AACrB,IAAA,MAAM,OAAO;AACb,IAAA,OAAO,QAAQ,CAAC,GAAG,CAAC;AAEpB,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAO,WAAW,CAAC,GAAG,CAAC;IACzB;AACA,IAAA,MAAM,OAAO;;AAGb,IAAA,OAAO,aAAa,CAAC,GAAG,CAAC;AACzB,IAAA,MAAM,OAAO;;AAEb,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAO,UAAU,CAAC,GAAG,CAAC;IACxB;;AAEA,IAAA,OAAO,SAAS,CAAC,GAAG,CAAC;AAErB,IAAA,OAAO,gBAAgB,CAAC,GAAG,CAAC;AAC9B;;;;"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var getCallConfigSummary = require('./helpers/get-call-config-summary.js');
|
|
4
|
-
var sanitization = require('../util/sanitization.js');
|
|
5
|
-
var algosdk = require('algosdk');
|
|
6
|
-
|
|
7
|
-
const GenerateMode = {
|
|
8
|
-
FULL: 'full',
|
|
9
|
-
MINIMAL: 'minimal',
|
|
10
|
-
};
|
|
11
|
-
const generateModes = Object.values(GenerateMode);
|
|
12
|
-
const createGeneratorContext = (app, options) => {
|
|
13
|
-
const sanitizer = sanitization.getSanitizer(options);
|
|
14
|
-
return {
|
|
15
|
-
sanitizer,
|
|
16
|
-
app,
|
|
17
|
-
name: sanitizer.makeSafeTypeIdentifier(app.name),
|
|
18
|
-
callConfig: getCallConfigSummary.getCallConfigSummary(app),
|
|
19
|
-
methodSignatureToUniqueName: app.methods.reduce((acc, cur) => {
|
|
20
|
-
const signature = new algosdk.ABIMethod(cur).getSignature();
|
|
21
|
-
acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name;
|
|
22
|
-
return acc;
|
|
23
|
-
}, {}),
|
|
24
|
-
mode: options.mode,
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
exports.createGeneratorContext = createGeneratorContext;
|
|
29
|
-
exports.generateModes = generateModes;
|
|
30
|
-
//# sourceMappingURL=generator-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generator-context.js","sources":["../../src/client/generator-context.ts"],"sourcesContent":["import { CallConfigSummary, getCallConfigSummary } from './helpers/get-call-config-summary'\nimport { getSanitizer, Sanitizer } from '../util/sanitization'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nconst GenerateMode = {\n FULL: 'full',\n MINIMAL: 'minimal',\n} as const\nexport type GenerateMode = (typeof GenerateMode)[keyof typeof GenerateMode]\nexport const generateModes = Object.values(GenerateMode)\n\nexport type GeneratorContext = {\n app: Arc56Contract\n name: string\n callConfig: CallConfigSummary\n methodSignatureToUniqueName: Record<string, string>\n sanitizer: Sanitizer\n mode: GenerateMode\n}\n\nexport type GeneratorOptions = {\n preserveNames: boolean\n mode: GenerateMode\n}\n\nexport const createGeneratorContext = (app: Arc56Contract, options: GeneratorOptions): GeneratorContext => {\n const sanitizer = getSanitizer(options)\n return {\n sanitizer,\n app,\n name: sanitizer.makeSafeTypeIdentifier(app.name),\n callConfig: getCallConfigSummary(app),\n methodSignatureToUniqueName: app.methods.reduce(\n (acc, cur) => {\n const signature = new ABIMethod(cur).getSignature()\n acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name\n return acc\n },\n {} as Record<string, string>,\n ),\n mode: options.mode,\n }\n}\n"],"names":["getSanitizer","getCallConfigSummary","ABIMethod"],"mappings":";;;;;;AAKA,MAAM,YAAY,GAAG;AACnB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,OAAO,EAAE,SAAS;CACV;AAEH,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY;MAgB1C,sBAAsB,GAAG,CAAC,GAAkB,EAAE,OAAyB,KAAsB;AACxG,IAAA,MAAM,SAAS,GAAGA,yBAAY,CAAC,OAAO,CAAC;IACvC,OAAO;QACL,SAAS;QACT,GAAG;QACH,IAAI,EAAE,SAAS,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC;AAChD,QAAA,UAAU,EAAEC,yCAAoB,CAAC,GAAG,CAAC;AACrC,QAAA,2BAA2B,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,GAAG,KAAI;YACX,MAAM,SAAS,GAAG,IAAIC,iBAAS,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE;AACnD,YAAA,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,SAAS,GAAG,GAAG,CAAC,IAAI;AACjG,YAAA,OAAO,GAAG;QACZ,CAAC,EACD,EAA4B,CAC7B;QACD,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB;AACH;;;;;"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { getCallConfigSummary } from './helpers/get-call-config-summary.mjs';
|
|
2
|
-
import { getSanitizer } from '../util/sanitization.mjs';
|
|
3
|
-
import { ABIMethod } from 'algosdk';
|
|
4
|
-
|
|
5
|
-
const GenerateMode = {
|
|
6
|
-
FULL: 'full',
|
|
7
|
-
MINIMAL: 'minimal',
|
|
8
|
-
};
|
|
9
|
-
const generateModes = Object.values(GenerateMode);
|
|
10
|
-
const createGeneratorContext = (app, options) => {
|
|
11
|
-
const sanitizer = getSanitizer(options);
|
|
12
|
-
return {
|
|
13
|
-
sanitizer,
|
|
14
|
-
app,
|
|
15
|
-
name: sanitizer.makeSafeTypeIdentifier(app.name),
|
|
16
|
-
callConfig: getCallConfigSummary(app),
|
|
17
|
-
methodSignatureToUniqueName: app.methods.reduce((acc, cur) => {
|
|
18
|
-
const signature = new ABIMethod(cur).getSignature();
|
|
19
|
-
acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name;
|
|
20
|
-
return acc;
|
|
21
|
-
}, {}),
|
|
22
|
-
mode: options.mode,
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export { createGeneratorContext, generateModes };
|
|
27
|
-
//# sourceMappingURL=generator-context.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generator-context.mjs","sources":["../../src/client/generator-context.ts"],"sourcesContent":["import { CallConfigSummary, getCallConfigSummary } from './helpers/get-call-config-summary'\nimport { getSanitizer, Sanitizer } from '../util/sanitization'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nconst GenerateMode = {\n FULL: 'full',\n MINIMAL: 'minimal',\n} as const\nexport type GenerateMode = (typeof GenerateMode)[keyof typeof GenerateMode]\nexport const generateModes = Object.values(GenerateMode)\n\nexport type GeneratorContext = {\n app: Arc56Contract\n name: string\n callConfig: CallConfigSummary\n methodSignatureToUniqueName: Record<string, string>\n sanitizer: Sanitizer\n mode: GenerateMode\n}\n\nexport type GeneratorOptions = {\n preserveNames: boolean\n mode: GenerateMode\n}\n\nexport const createGeneratorContext = (app: Arc56Contract, options: GeneratorOptions): GeneratorContext => {\n const sanitizer = getSanitizer(options)\n return {\n sanitizer,\n app,\n name: sanitizer.makeSafeTypeIdentifier(app.name),\n callConfig: getCallConfigSummary(app),\n methodSignatureToUniqueName: app.methods.reduce(\n (acc, cur) => {\n const signature = new ABIMethod(cur).getSignature()\n acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name\n return acc\n },\n {} as Record<string, string>,\n ),\n mode: options.mode,\n }\n}\n"],"names":[],"mappings":";;;;AAKA,MAAM,YAAY,GAAG;AACnB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,OAAO,EAAE,SAAS;CACV;AAEH,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY;MAgB1C,sBAAsB,GAAG,CAAC,GAAkB,EAAE,OAAyB,KAAsB;AACxG,IAAA,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;IACvC,OAAO;QACL,SAAS;QACT,GAAG;QACH,IAAI,EAAE,SAAS,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC;AAChD,QAAA,UAAU,EAAE,oBAAoB,CAAC,GAAG,CAAC;AACrC,QAAA,2BAA2B,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,GAAG,KAAI;YACX,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE;AACnD,YAAA,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,SAAS,GAAG,GAAG,CAAC,IAAI;AACjG,YAAA,OAAO,GAAG;QACZ,CAAC,EACD,EAA4B,CAC7B;QACD,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB;AACH;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contains-non-void-method.js","sources":["../../../src/client/helpers/contains-non-void-method.ts"],"sourcesContent":["import { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\n\nexport const containsNonVoidMethod = (methods: Method[]) => {\n return methods.some((method) => {\n const returnType = method.returns.struct ?? method.returns.type ?? 'void'\n return returnType !== 'void'\n })\n}\n"],"names":[],"mappings":";;AAEO,MAAM,qBAAqB,GAAG,CAAC,OAAiB,KAAI;AACzD,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;AAC7B,QAAA,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM;QACzE,OAAO,UAAU,KAAK,MAAM;AAC9B,IAAA,CAAC,CAAC;AACJ;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contains-non-void-method.mjs","sources":["../../../src/client/helpers/contains-non-void-method.ts"],"sourcesContent":["import { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\n\nexport const containsNonVoidMethod = (methods: Method[]) => {\n return methods.some((method) => {\n const returnType = method.returns.struct ?? method.returns.type ?? 'void'\n return returnType !== 'void'\n })\n}\n"],"names":[],"mappings":"AAEO,MAAM,qBAAqB,GAAG,CAAC,OAAiB,KAAI;AACzD,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;AAC7B,QAAA,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM;QACzE,OAAO,UAAU,KAAK,MAAM;AAC9B,IAAA,CAAC,CAAC;AACJ;;;;"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56';
|
|
2
|
-
export declare const BARE_CALL: unique symbol;
|
|
3
|
-
export type MethodIdentifier = string | typeof BARE_CALL;
|
|
4
|
-
export type MethodList = Array<MethodIdentifier>;
|
|
5
|
-
export type OnComplete = 'NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication';
|
|
6
|
-
export type Actions = {
|
|
7
|
-
create: ('NoOp' | 'OptIn' | 'DeleteApplication')[];
|
|
8
|
-
call: OnComplete[];
|
|
9
|
-
};
|
|
10
|
-
export type CallConfigSummary = {
|
|
11
|
-
createMethods: MethodList;
|
|
12
|
-
callMethods: MethodList;
|
|
13
|
-
deleteMethods: MethodList;
|
|
14
|
-
updateMethods: MethodList;
|
|
15
|
-
optInMethods: MethodList;
|
|
16
|
-
closeOutMethods: MethodList;
|
|
17
|
-
};
|
|
18
|
-
export declare const getCallConfigSummary: (app: Arc56Contract) => CallConfigSummary;
|
|
19
|
-
export declare const getCreateOnComplete: (app: Arc56Contract, method: MethodIdentifier) => string;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var algosdk = require('algosdk');
|
|
4
|
-
|
|
5
|
-
const BARE_CALL = Symbol('bare');
|
|
6
|
-
const getCallConfigSummary = (app) => {
|
|
7
|
-
const result = {
|
|
8
|
-
createMethods: [],
|
|
9
|
-
callMethods: [],
|
|
10
|
-
deleteMethods: [],
|
|
11
|
-
updateMethods: [],
|
|
12
|
-
optInMethods: [],
|
|
13
|
-
closeOutMethods: [],
|
|
14
|
-
};
|
|
15
|
-
if (app.bareActions) {
|
|
16
|
-
addToConfig(result, BARE_CALL, app.bareActions);
|
|
17
|
-
}
|
|
18
|
-
if (app.methods) {
|
|
19
|
-
for (const m of app.methods) {
|
|
20
|
-
if (m.actions) {
|
|
21
|
-
addToConfig(result, new algosdk.ABIMethod(m).getSignature(), m.actions);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
const addToConfig = (result, method, config) => {
|
|
28
|
-
if (hasCall(config, 'NoOp')) {
|
|
29
|
-
result.callMethods.push(method);
|
|
30
|
-
}
|
|
31
|
-
if (hasCreate(config, 'NoOp') ||
|
|
32
|
-
hasCreate(config, 'OptIn') ||
|
|
33
|
-
hasCreate(config, 'CloseOut') ||
|
|
34
|
-
hasCreate(config, 'UpdateApplication') ||
|
|
35
|
-
hasCreate(config, 'DeleteApplication')) {
|
|
36
|
-
result.createMethods.push(method);
|
|
37
|
-
}
|
|
38
|
-
if (hasCall(config, 'DeleteApplication')) {
|
|
39
|
-
result.deleteMethods.push(method);
|
|
40
|
-
}
|
|
41
|
-
if (hasCall(config, 'UpdateApplication')) {
|
|
42
|
-
result.updateMethods.push(method);
|
|
43
|
-
}
|
|
44
|
-
if (hasCall(config, 'OptIn')) {
|
|
45
|
-
result.optInMethods.push(method);
|
|
46
|
-
}
|
|
47
|
-
if (hasCall(config, 'CloseOut')) {
|
|
48
|
-
result.closeOutMethods.push(method);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
const hasCall = (config, action) => {
|
|
52
|
-
return config?.call.includes(action);
|
|
53
|
-
};
|
|
54
|
-
const hasCreate = (config, action) => {
|
|
55
|
-
return (config?.create).includes(action);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
exports.BARE_CALL = BARE_CALL;
|
|
59
|
-
exports.getCallConfigSummary = getCallConfigSummary;
|
|
60
|
-
//# sourceMappingURL=get-call-config-summary.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-call-config-summary.js","sources":["../../../src/client/helpers/get-call-config-summary.ts"],"sourcesContent":["import { pascalCase } from 'change-case'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport const BARE_CALL = Symbol('bare')\n\nexport type MethodIdentifier = string | typeof BARE_CALL\n\nexport type MethodList = Array<MethodIdentifier>\n\nexport type OnComplete = 'NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication'\n\nexport type Actions = {\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n call: OnComplete[]\n}\n\nexport type CallConfigSummary = {\n createMethods: MethodList\n callMethods: MethodList\n deleteMethods: MethodList\n updateMethods: MethodList\n optInMethods: MethodList\n closeOutMethods: MethodList\n}\nexport const getCallConfigSummary = (app: Arc56Contract) => {\n const result: CallConfigSummary = {\n createMethods: [],\n callMethods: [],\n deleteMethods: [],\n updateMethods: [],\n optInMethods: [],\n closeOutMethods: [],\n }\n if (app.bareActions) {\n addToConfig(result, BARE_CALL, app.bareActions)\n }\n if (app.methods) {\n for (const m of app.methods) {\n if (m.actions) {\n addToConfig(result, new ABIMethod(m).getSignature(), m.actions)\n }\n }\n }\n return result\n}\n\nexport const getCreateOnComplete = (app: Arc56Contract, method: MethodIdentifier) => {\n const actions = method === BARE_CALL ? app.bareActions : app.methods?.find((m) => m.name === method)?.actions\n if (!actions) {\n return ''\n }\n const hasNoOp = actions.create.includes('NoOp')\n return `{ onCompleteAction${hasNoOp ? '?' : ''}: ${getCreateOnCompleteTypes(actions)} }`\n}\n\nconst getCreateOnCompleteTypes = (config: Actions) => {\n return config.create.map((oc) => `'${oc}' | OnApplicationComplete.${pascalCase(oc)}OC`).join(' | ')\n}\n\nconst addToConfig = (result: CallConfigSummary, method: MethodIdentifier, config: Actions) => {\n if (hasCall(config, 'NoOp')) {\n result.callMethods.push(method)\n }\n if (\n hasCreate(config, 'NoOp') ||\n hasCreate(config, 'OptIn') ||\n hasCreate(config, 'CloseOut') ||\n hasCreate(config, 'UpdateApplication') ||\n hasCreate(config, 'DeleteApplication')\n ) {\n result.createMethods.push(method)\n }\n if (hasCall(config, 'DeleteApplication')) {\n result.deleteMethods.push(method)\n }\n if (hasCall(config, 'UpdateApplication')) {\n result.updateMethods.push(method)\n }\n if (hasCall(config, 'OptIn')) {\n result.optInMethods.push(method)\n }\n if (hasCall(config, 'CloseOut')) {\n result.closeOutMethods.push(method)\n }\n}\n\nconst hasCall = (config: Actions | undefined, action: OnComplete) => {\n return config?.call.includes(action)\n}\nconst hasCreate = (config: Actions | undefined, action: OnComplete) => {\n return (config?.create as OnComplete[]).includes(action)\n}\n"],"names":["ABIMethod"],"mappings":";;;;MAIa,SAAS,GAAG,MAAM,CAAC,MAAM;AAqB/B,MAAM,oBAAoB,GAAG,CAAC,GAAkB,KAAI;AACzD,IAAA,MAAM,MAAM,GAAsB;AAChC,QAAA,aAAa,EAAE,EAAE;AACjB,QAAA,WAAW,EAAE,EAAE;AACf,QAAA,aAAa,EAAE,EAAE;AACjB,QAAA,aAAa,EAAE,EAAE;AACjB,QAAA,YAAY,EAAE,EAAE;AAChB,QAAA,eAAe,EAAE,EAAE;KACpB;AACD,IAAA,IAAI,GAAG,CAAC,WAAW,EAAE;QACnB,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,WAAW,CAAC;IACjD;AACA,IAAA,IAAI,GAAG,CAAC,OAAO,EAAE;AACf,QAAA,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE;AAC3B,YAAA,IAAI,CAAC,CAAC,OAAO,EAAE;AACb,gBAAA,WAAW,CAAC,MAAM,EAAE,IAAIA,iBAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC;YACjE;QACF;IACF;AACA,IAAA,OAAO,MAAM;AACf;AAeA,MAAM,WAAW,GAAG,CAAC,MAAyB,EAAE,MAAwB,EAAE,MAAe,KAAI;AAC3F,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;AAC3B,QAAA,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;IACjC;AACA,IAAA,IACE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;AACzB,QAAA,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;AAC1B,QAAA,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;AAC7B,QAAA,SAAS,CAAC,MAAM,EAAE,mBAAmB,CAAC;AACtC,QAAA,SAAS,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACtC;AACA,QAAA,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;IACnC;AACA,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;IACnC;AACA,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;IACnC;AACA,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;AAC5B,QAAA,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IAClC;AACA,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE;AAC/B,QAAA,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;IACrC;AACF,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,MAA2B,EAAE,MAAkB,KAAI;IAClE,OAAO,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AACtC,CAAC;AACD,MAAM,SAAS,GAAG,CAAC,MAA2B,EAAE,MAAkB,KAAI;IACpE,OAAO,CAAC,MAAM,EAAE,MAAuB,EAAC,QAAQ,CAAC,MAAM,CAAC;AAC1D,CAAC;;;;;"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { ABIMethod } from 'algosdk';
|
|
2
|
-
|
|
3
|
-
const BARE_CALL = Symbol('bare');
|
|
4
|
-
const getCallConfigSummary = (app) => {
|
|
5
|
-
const result = {
|
|
6
|
-
createMethods: [],
|
|
7
|
-
callMethods: [],
|
|
8
|
-
deleteMethods: [],
|
|
9
|
-
updateMethods: [],
|
|
10
|
-
optInMethods: [],
|
|
11
|
-
closeOutMethods: [],
|
|
12
|
-
};
|
|
13
|
-
if (app.bareActions) {
|
|
14
|
-
addToConfig(result, BARE_CALL, app.bareActions);
|
|
15
|
-
}
|
|
16
|
-
if (app.methods) {
|
|
17
|
-
for (const m of app.methods) {
|
|
18
|
-
if (m.actions) {
|
|
19
|
-
addToConfig(result, new ABIMethod(m).getSignature(), m.actions);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
const addToConfig = (result, method, config) => {
|
|
26
|
-
if (hasCall(config, 'NoOp')) {
|
|
27
|
-
result.callMethods.push(method);
|
|
28
|
-
}
|
|
29
|
-
if (hasCreate(config, 'NoOp') ||
|
|
30
|
-
hasCreate(config, 'OptIn') ||
|
|
31
|
-
hasCreate(config, 'CloseOut') ||
|
|
32
|
-
hasCreate(config, 'UpdateApplication') ||
|
|
33
|
-
hasCreate(config, 'DeleteApplication')) {
|
|
34
|
-
result.createMethods.push(method);
|
|
35
|
-
}
|
|
36
|
-
if (hasCall(config, 'DeleteApplication')) {
|
|
37
|
-
result.deleteMethods.push(method);
|
|
38
|
-
}
|
|
39
|
-
if (hasCall(config, 'UpdateApplication')) {
|
|
40
|
-
result.updateMethods.push(method);
|
|
41
|
-
}
|
|
42
|
-
if (hasCall(config, 'OptIn')) {
|
|
43
|
-
result.optInMethods.push(method);
|
|
44
|
-
}
|
|
45
|
-
if (hasCall(config, 'CloseOut')) {
|
|
46
|
-
result.closeOutMethods.push(method);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const hasCall = (config, action) => {
|
|
50
|
-
return config?.call.includes(action);
|
|
51
|
-
};
|
|
52
|
-
const hasCreate = (config, action) => {
|
|
53
|
-
return (config?.create).includes(action);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export { BARE_CALL, getCallConfigSummary };
|
|
57
|
-
//# sourceMappingURL=get-call-config-summary.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-call-config-summary.mjs","sources":["../../../src/client/helpers/get-call-config-summary.ts"],"sourcesContent":["import { pascalCase } from 'change-case'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport const BARE_CALL = Symbol('bare')\n\nexport type MethodIdentifier = string | typeof BARE_CALL\n\nexport type MethodList = Array<MethodIdentifier>\n\nexport type OnComplete = 'NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication'\n\nexport type Actions = {\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n call: OnComplete[]\n}\n\nexport type CallConfigSummary = {\n createMethods: MethodList\n callMethods: MethodList\n deleteMethods: MethodList\n updateMethods: MethodList\n optInMethods: MethodList\n closeOutMethods: MethodList\n}\nexport const getCallConfigSummary = (app: Arc56Contract) => {\n const result: CallConfigSummary = {\n createMethods: [],\n callMethods: [],\n deleteMethods: [],\n updateMethods: [],\n optInMethods: [],\n closeOutMethods: [],\n }\n if (app.bareActions) {\n addToConfig(result, BARE_CALL, app.bareActions)\n }\n if (app.methods) {\n for (const m of app.methods) {\n if (m.actions) {\n addToConfig(result, new ABIMethod(m).getSignature(), m.actions)\n }\n }\n }\n return result\n}\n\nexport const getCreateOnComplete = (app: Arc56Contract, method: MethodIdentifier) => {\n const actions = method === BARE_CALL ? app.bareActions : app.methods?.find((m) => m.name === method)?.actions\n if (!actions) {\n return ''\n }\n const hasNoOp = actions.create.includes('NoOp')\n return `{ onCompleteAction${hasNoOp ? '?' : ''}: ${getCreateOnCompleteTypes(actions)} }`\n}\n\nconst getCreateOnCompleteTypes = (config: Actions) => {\n return config.create.map((oc) => `'${oc}' | OnApplicationComplete.${pascalCase(oc)}OC`).join(' | ')\n}\n\nconst addToConfig = (result: CallConfigSummary, method: MethodIdentifier, config: Actions) => {\n if (hasCall(config, 'NoOp')) {\n result.callMethods.push(method)\n }\n if (\n hasCreate(config, 'NoOp') ||\n hasCreate(config, 'OptIn') ||\n hasCreate(config, 'CloseOut') ||\n hasCreate(config, 'UpdateApplication') ||\n hasCreate(config, 'DeleteApplication')\n ) {\n result.createMethods.push(method)\n }\n if (hasCall(config, 'DeleteApplication')) {\n result.deleteMethods.push(method)\n }\n if (hasCall(config, 'UpdateApplication')) {\n result.updateMethods.push(method)\n }\n if (hasCall(config, 'OptIn')) {\n result.optInMethods.push(method)\n }\n if (hasCall(config, 'CloseOut')) {\n result.closeOutMethods.push(method)\n }\n}\n\nconst hasCall = (config: Actions | undefined, action: OnComplete) => {\n return config?.call.includes(action)\n}\nconst hasCreate = (config: Actions | undefined, action: OnComplete) => {\n return (config?.create as OnComplete[]).includes(action)\n}\n"],"names":[],"mappings":";;MAIa,SAAS,GAAG,MAAM,CAAC,MAAM;AAqB/B,MAAM,oBAAoB,GAAG,CAAC,GAAkB,KAAI;AACzD,IAAA,MAAM,MAAM,GAAsB;AAChC,QAAA,aAAa,EAAE,EAAE;AACjB,QAAA,WAAW,EAAE,EAAE;AACf,QAAA,aAAa,EAAE,EAAE;AACjB,QAAA,aAAa,EAAE,EAAE;AACjB,QAAA,YAAY,EAAE,EAAE;AAChB,QAAA,eAAe,EAAE,EAAE;KACpB;AACD,IAAA,IAAI,GAAG,CAAC,WAAW,EAAE;QACnB,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,WAAW,CAAC;IACjD;AACA,IAAA,IAAI,GAAG,CAAC,OAAO,EAAE;AACf,QAAA,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE;AAC3B,YAAA,IAAI,CAAC,CAAC,OAAO,EAAE;AACb,gBAAA,WAAW,CAAC,MAAM,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC;YACjE;QACF;IACF;AACA,IAAA,OAAO,MAAM;AACf;AAeA,MAAM,WAAW,GAAG,CAAC,MAAyB,EAAE,MAAwB,EAAE,MAAe,KAAI;AAC3F,IAAA,IAAI,OAAO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 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var algosdk = require('algosdk');
|
|
4
|
-
|
|
5
|
-
const bigIntOrNumberType = 'bigint | number';
|
|
6
|
-
const bytesOrStringType = 'Uint8Array | string';
|
|
7
|
-
function getEquivalentType(abiTypeStr, ioType, ctx) {
|
|
8
|
-
const { app, sanitizer } = ctx;
|
|
9
|
-
if (abiTypeStr == 'void') {
|
|
10
|
-
return 'void';
|
|
11
|
-
}
|
|
12
|
-
if (abiTypeStr == 'AVMBytes') {
|
|
13
|
-
return ioType === 'input' ? bytesOrStringType : 'Uint8Array';
|
|
14
|
-
}
|
|
15
|
-
if (abiTypeStr == 'AVMString') {
|
|
16
|
-
return 'string';
|
|
17
|
-
}
|
|
18
|
-
if (abiTypeStr == 'AVMUint64') {
|
|
19
|
-
return 'bigint';
|
|
20
|
-
}
|
|
21
|
-
if (algosdk.abiTypeIsTransaction(abiTypeStr)) {
|
|
22
|
-
return 'AppMethodCallTransactionArgument';
|
|
23
|
-
}
|
|
24
|
-
if (abiTypeStr == algosdk.ABIReferenceType.account) {
|
|
25
|
-
return bytesOrStringType;
|
|
26
|
-
}
|
|
27
|
-
if (abiTypeStr == algosdk.ABIReferenceType.application || abiTypeStr == algosdk.ABIReferenceType.asset) {
|
|
28
|
-
return 'bigint';
|
|
29
|
-
}
|
|
30
|
-
if (Object.keys(app.structs).includes(abiTypeStr)) {
|
|
31
|
-
return sanitizer.makeSafeTypeIdentifier(abiTypeStr);
|
|
32
|
-
}
|
|
33
|
-
const abiType = algosdk.ABIType.from(abiTypeStr);
|
|
34
|
-
return abiTypeToTs(abiType, ioType);
|
|
35
|
-
function abiTypeToTs(abiType, ioType) {
|
|
36
|
-
if (abiType instanceof algosdk.ABIUintType) {
|
|
37
|
-
if (abiType.bitSize < 53)
|
|
38
|
-
return ioType === 'input' ? bigIntOrNumberType : 'number';
|
|
39
|
-
return ioType === 'input' ? bigIntOrNumberType : 'bigint';
|
|
40
|
-
}
|
|
41
|
-
if (abiType instanceof algosdk.ABIArrayDynamicType) {
|
|
42
|
-
if (abiType.childType instanceof algosdk.ABIByteType)
|
|
43
|
-
return 'Uint8Array';
|
|
44
|
-
const childTsType = abiTypeToTs(abiType.childType, ioType);
|
|
45
|
-
if (childTsType === bigIntOrNumberType) {
|
|
46
|
-
return 'bigint[] | number[]';
|
|
47
|
-
}
|
|
48
|
-
else if (childTsType === bytesOrStringType) {
|
|
49
|
-
return 'Uint8Array[] | string[]';
|
|
50
|
-
}
|
|
51
|
-
return `${childTsType}[]`;
|
|
52
|
-
}
|
|
53
|
-
if (abiType instanceof algosdk.ABIArrayStaticType) {
|
|
54
|
-
if (abiType.childType instanceof algosdk.ABIByteType)
|
|
55
|
-
return 'Uint8Array';
|
|
56
|
-
return `[${new Array(abiType.staticLength).fill(abiTypeToTs(abiType.childType, ioType)).join(', ')}]`;
|
|
57
|
-
}
|
|
58
|
-
if (abiType instanceof algosdk.ABIAddressType) {
|
|
59
|
-
return 'string';
|
|
60
|
-
}
|
|
61
|
-
if (abiType instanceof algosdk.ABIBoolType) {
|
|
62
|
-
return 'boolean';
|
|
63
|
-
}
|
|
64
|
-
if (abiType instanceof algosdk.ABIUfixedType) {
|
|
65
|
-
return 'number';
|
|
66
|
-
}
|
|
67
|
-
if (abiType instanceof algosdk.ABITupleType) {
|
|
68
|
-
return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType)).join(', ')}]`;
|
|
69
|
-
}
|
|
70
|
-
if (abiType instanceof algosdk.ABIByteType) {
|
|
71
|
-
return 'number';
|
|
72
|
-
}
|
|
73
|
-
if (abiType instanceof algosdk.ABIStringType) {
|
|
74
|
-
return 'string';
|
|
75
|
-
}
|
|
76
|
-
return 'unknown';
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
exports.getEquivalentType = getEquivalentType;
|
|
81
|
-
//# sourceMappingURL=get-equivalent-type.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-equivalent-type.js","sources":["../../../src/client/helpers/get-equivalent-type.ts"],"sourcesContent":["import { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport {\n ABIAddressType,\n ABIArrayDynamicType,\n ABIArrayStaticType,\n ABIBoolType,\n ABIByteType,\n ABIReferenceType,\n ABIStringType,\n ABITupleType,\n ABIType,\n ABIUfixedType,\n ABIUintType,\n abiTypeIsTransaction,\n} from 'algosdk'\nimport { Sanitizer } from '../../util/sanitization'\n\nconst bigIntOrNumberType = 'bigint | number'\nconst bytesOrStringType = 'Uint8Array | string'\n\nexport function getEquivalentType(\n abiTypeStr: string,\n ioType: 'input' | 'output',\n ctx: { app: Arc56Contract; sanitizer: Sanitizer },\n): string {\n const { app, sanitizer } = ctx\n if (abiTypeStr == 'void') {\n return 'void'\n }\n if (abiTypeStr == 'AVMBytes') {\n return ioType === 'input' ? bytesOrStringType : 'Uint8Array'\n }\n if (abiTypeStr == 'AVMString') {\n return 'string'\n }\n if (abiTypeStr == 'AVMUint64') {\n return 'bigint'\n }\n if (abiTypeIsTransaction(abiTypeStr)) {\n return 'AppMethodCallTransactionArgument'\n }\n if (abiTypeStr == ABIReferenceType.account) {\n return bytesOrStringType\n }\n if (abiTypeStr == ABIReferenceType.application || abiTypeStr == ABIReferenceType.asset) {\n return 'bigint'\n }\n if (Object.keys(app.structs).includes(abiTypeStr)) {\n return sanitizer.makeSafeTypeIdentifier(abiTypeStr)\n }\n\n const abiType = ABIType.from(abiTypeStr)\n\n return abiTypeToTs(abiType, ioType)\n\n function abiTypeToTs(abiType: ABIType, ioType: 'input' | 'output'): string {\n if (abiType instanceof ABIUintType) {\n if (abiType.bitSize < 53) return ioType === 'input' ? bigIntOrNumberType : 'number'\n return ioType === 'input' ? bigIntOrNumberType : 'bigint'\n }\n if (abiType instanceof ABIArrayDynamicType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n\n const childTsType = abiTypeToTs(abiType.childType, ioType)\n if (childTsType === bigIntOrNumberType) {\n return 'bigint[] | number[]'\n } else if (childTsType === bytesOrStringType) {\n return 'Uint8Array[] | string[]'\n }\n\n return `${childTsType}[]`\n }\n if (abiType instanceof ABIArrayStaticType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n return `[${new Array(abiType.staticLength).fill(abiTypeToTs(abiType.childType, ioType)).join(', ')}]`\n }\n if (abiType instanceof ABIAddressType) {\n return 'string'\n }\n if (abiType instanceof ABIBoolType) {\n return 'boolean'\n }\n if (abiType instanceof ABIUfixedType) {\n return 'number'\n }\n if (abiType instanceof ABITupleType) {\n return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType)).join(', ')}]`\n }\n if (abiType instanceof ABIByteType) {\n return 'number'\n }\n if (abiType instanceof ABIStringType) {\n return 'string'\n }\n return 'unknown'\n }\n}\n"],"names":["abiTypeIsTransaction","ABIReferenceType","ABIType","ABIUintType","ABIArrayDynamicType","ABIByteType","ABIArrayStaticType","ABIAddressType","ABIBoolType","ABIUfixedType","ABITupleType","ABIStringType"],"mappings":";;;;AAiBA,MAAM,kBAAkB,GAAG,iBAAiB;AAC5C,MAAM,iBAAiB,GAAG,qBAAqB;SAE/B,iBAAiB,CAC/B,UAAkB,EAClB,MAA0B,EAC1B,GAAiD,EAAA;AAEjD,IAAA,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,GAAG;AAC9B,IAAA,IAAI,UAAU,IAAI,MAAM,EAAE;AACxB,QAAA,OAAO,MAAM;IACf;AACA,IAAA,IAAI,UAAU,IAAI,UAAU,EAAE;QAC5B,OAAO,MAAM,KAAK,OAAO,GAAG,iBAAiB,GAAG,YAAY;IAC9D;AACA,IAAA,IAAI,UAAU,IAAI,WAAW,EAAE;AAC7B,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAI,UAAU,IAAI,WAAW,EAAE;AAC7B,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAIA,4BAAoB,CAAC,UAAU,CAAC,EAA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,IAAI,OAAO,YAAYC,0BAAkB,EAAE;AACzC,YAAA,IAAI,OAAO,CAAC,SAAS,YAAYD,mBAAW;AAAE,gBAAA,OAAO,YAAY;YACjE,OAAO,CAAA,CAAA,EAAI,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG;QACvG;AACA,QAAA,IAAI,OAAO,YAAYE,sBAAc,EAAE;AACrC,YAAA,OAAO,QAAQ;QACjB;AACA,QAAA,IAAI,OAAO,YAAYC,mBAAW,EAAE;AAClC,YAAA,OAAO,SAAS;QAClB;AACA,QAAA,IAAI,OAAO,YAAYC,qBAAa,EAAE;AACpC,YAAA,OAAO,QAAQ;QACjB;AACA,QAAA,IAAI,OAAO,YAAYC,oBAAY,EAAE;YACnC,OAAO,CAAA,CAAA,EAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG;QAChF;AACA,QAAA,IAAI,OAAO,YAAYL,mBAAW,EAAE;AAClC,YAAA,OAAO,QAAQ;QACjB;AACA,QAAA,IAAI,OAAO,YAAYM,qBAAa,EAAE;AACpC,YAAA,OAAO,QAAQ;QACjB;AACA,QAAA,OAAO,SAAS;IAClB;AACF;;;;"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { abiTypeIsTransaction, ABIReferenceType, ABIType, ABIUintType, ABIArrayDynamicType, ABIByteType, ABIArrayStaticType, ABIAddressType, ABIBoolType, ABIUfixedType, ABITupleType, ABIStringType } from 'algosdk';
|
|
2
|
-
|
|
3
|
-
const bigIntOrNumberType = 'bigint | number';
|
|
4
|
-
const bytesOrStringType = 'Uint8Array | string';
|
|
5
|
-
function getEquivalentType(abiTypeStr, ioType, ctx) {
|
|
6
|
-
const { app, sanitizer } = ctx;
|
|
7
|
-
if (abiTypeStr == 'void') {
|
|
8
|
-
return 'void';
|
|
9
|
-
}
|
|
10
|
-
if (abiTypeStr == 'AVMBytes') {
|
|
11
|
-
return ioType === 'input' ? bytesOrStringType : 'Uint8Array';
|
|
12
|
-
}
|
|
13
|
-
if (abiTypeStr == 'AVMString') {
|
|
14
|
-
return 'string';
|
|
15
|
-
}
|
|
16
|
-
if (abiTypeStr == 'AVMUint64') {
|
|
17
|
-
return 'bigint';
|
|
18
|
-
}
|
|
19
|
-
if (abiTypeIsTransaction(abiTypeStr)) {
|
|
20
|
-
return 'AppMethodCallTransactionArgument';
|
|
21
|
-
}
|
|
22
|
-
if (abiTypeStr == ABIReferenceType.account) {
|
|
23
|
-
return bytesOrStringType;
|
|
24
|
-
}
|
|
25
|
-
if (abiTypeStr == ABIReferenceType.application || abiTypeStr == ABIReferenceType.asset) {
|
|
26
|
-
return 'bigint';
|
|
27
|
-
}
|
|
28
|
-
if (Object.keys(app.structs).includes(abiTypeStr)) {
|
|
29
|
-
return sanitizer.makeSafeTypeIdentifier(abiTypeStr);
|
|
30
|
-
}
|
|
31
|
-
const abiType = ABIType.from(abiTypeStr);
|
|
32
|
-
return abiTypeToTs(abiType, ioType);
|
|
33
|
-
function abiTypeToTs(abiType, ioType) {
|
|
34
|
-
if (abiType instanceof ABIUintType) {
|
|
35
|
-
if (abiType.bitSize < 53)
|
|
36
|
-
return ioType === 'input' ? bigIntOrNumberType : 'number';
|
|
37
|
-
return ioType === 'input' ? bigIntOrNumberType : 'bigint';
|
|
38
|
-
}
|
|
39
|
-
if (abiType instanceof ABIArrayDynamicType) {
|
|
40
|
-
if (abiType.childType instanceof ABIByteType)
|
|
41
|
-
return 'Uint8Array';
|
|
42
|
-
const childTsType = abiTypeToTs(abiType.childType, ioType);
|
|
43
|
-
if (childTsType === bigIntOrNumberType) {
|
|
44
|
-
return 'bigint[] | number[]';
|
|
45
|
-
}
|
|
46
|
-
else if (childTsType === bytesOrStringType) {
|
|
47
|
-
return 'Uint8Array[] | string[]';
|
|
48
|
-
}
|
|
49
|
-
return `${childTsType}[]`;
|
|
50
|
-
}
|
|
51
|
-
if (abiType instanceof ABIArrayStaticType) {
|
|
52
|
-
if (abiType.childType instanceof ABIByteType)
|
|
53
|
-
return 'Uint8Array';
|
|
54
|
-
return `[${new Array(abiType.staticLength).fill(abiTypeToTs(abiType.childType, ioType)).join(', ')}]`;
|
|
55
|
-
}
|
|
56
|
-
if (abiType instanceof ABIAddressType) {
|
|
57
|
-
return 'string';
|
|
58
|
-
}
|
|
59
|
-
if (abiType instanceof ABIBoolType) {
|
|
60
|
-
return 'boolean';
|
|
61
|
-
}
|
|
62
|
-
if (abiType instanceof ABIUfixedType) {
|
|
63
|
-
return 'number';
|
|
64
|
-
}
|
|
65
|
-
if (abiType instanceof ABITupleType) {
|
|
66
|
-
return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType)).join(', ')}]`;
|
|
67
|
-
}
|
|
68
|
-
if (abiType instanceof ABIByteType) {
|
|
69
|
-
return 'number';
|
|
70
|
-
}
|
|
71
|
-
if (abiType instanceof ABIStringType) {
|
|
72
|
-
return 'string';
|
|
73
|
-
}
|
|
74
|
-
return 'unknown';
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export { getEquivalentType };
|
|
79
|
-
//# sourceMappingURL=get-equivalent-type.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-equivalent-type.mjs","sources":["../../../src/client/helpers/get-equivalent-type.ts"],"sourcesContent":["import { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport {\n ABIAddressType,\n ABIArrayDynamicType,\n ABIArrayStaticType,\n ABIBoolType,\n ABIByteType,\n ABIReferenceType,\n ABIStringType,\n ABITupleType,\n ABIType,\n ABIUfixedType,\n ABIUintType,\n abiTypeIsTransaction,\n} from 'algosdk'\nimport { Sanitizer } from '../../util/sanitization'\n\nconst bigIntOrNumberType = 'bigint | number'\nconst bytesOrStringType = 'Uint8Array | string'\n\nexport function getEquivalentType(\n abiTypeStr: string,\n ioType: 'input' | 'output',\n ctx: { app: Arc56Contract; sanitizer: Sanitizer },\n): string {\n const { app, sanitizer } = ctx\n if (abiTypeStr == 'void') {\n return 'void'\n }\n if (abiTypeStr == 'AVMBytes') {\n return ioType === 'input' ? bytesOrStringType : 'Uint8Array'\n }\n if (abiTypeStr == 'AVMString') {\n return 'string'\n }\n if (abiTypeStr == 'AVMUint64') {\n return 'bigint'\n }\n if (abiTypeIsTransaction(abiTypeStr)) {\n return 'AppMethodCallTransactionArgument'\n }\n if (abiTypeStr == ABIReferenceType.account) {\n return bytesOrStringType\n }\n if (abiTypeStr == ABIReferenceType.application || abiTypeStr == ABIReferenceType.asset) {\n return 'bigint'\n }\n if (Object.keys(app.structs).includes(abiTypeStr)) {\n return sanitizer.makeSafeTypeIdentifier(abiTypeStr)\n }\n\n const abiType = ABIType.from(abiTypeStr)\n\n return abiTypeToTs(abiType, ioType)\n\n function abiTypeToTs(abiType: ABIType, ioType: 'input' | 'output'): string {\n if (abiType instanceof ABIUintType) {\n if (abiType.bitSize < 53) return ioType === 'input' ? bigIntOrNumberType : 'number'\n return ioType === 'input' ? bigIntOrNumberType : 'bigint'\n }\n if (abiType instanceof ABIArrayDynamicType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n\n const childTsType = abiTypeToTs(abiType.childType, ioType)\n if (childTsType === bigIntOrNumberType) {\n return 'bigint[] | number[]'\n } else if (childTsType === bytesOrStringType) {\n return 'Uint8Array[] | string[]'\n }\n\n return `${childTsType}[]`\n }\n if (abiType instanceof ABIArrayStaticType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n return `[${new Array(abiType.staticLength).fill(abiTypeToTs(abiType.childType, ioType)).join(', ')}]`\n }\n if (abiType instanceof ABIAddressType) {\n return 'string'\n }\n if (abiType instanceof ABIBoolType) {\n return 'boolean'\n }\n if (abiType instanceof ABIUfixedType) {\n return 'number'\n }\n if (abiType instanceof ABITupleType) {\n return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType)).join(', ')}]`\n }\n if (abiType instanceof ABIByteType) {\n return 'number'\n }\n if (abiType instanceof ABIStringType) {\n return 'string'\n }\n return 'unknown'\n }\n}\n"],"names":[],"mappings":";;AAiBA,MAAM,kBAAkB,GAAG,iBAAiB;AAC5C,MAAM,iBAAiB,GAAG,qBAAqB;SAE/B,iBAAiB,CAC/B,UAAkB,EAClB,MAA0B,EAC1B,GAAiD,EAAA;AAEjD,IAAA,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,GAAG;AAC9B,IAAA,IAAI,UAAU,IAAI,MAAM,EAAE;AACxB,QAAA,OAAO,MAAM;IACf;AACA,IAAA,IAAI,UAAU,IAAI,UAAU,EAAE;QAC5B,OAAO,MAAM,KAAK,OAAO,GAAG,iBAAiB,GAAG,YAAY;IAC9D;AACA,IAAA,IAAI,UAAU,IAAI,WAAW,EAAE;AAC7B,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAI,UAAU,IAAI,WAAW,EAAE;AAC7B,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAI,oBAAoB,CAAC,UAAU,CAAC,EAAE;AACpC,QAAA,OAAO,kCAAkC;IAC3C;AACA,IAAA,IAAI,UAAU,IAAI,gBAAgB,CAAC,OAAO,EAAE;AAC1C,QAAA,OAAO,iBAAiB;IAC1B;AACA,IAAA,IAAI,UAAU,IAAI,gBAAgB,CAAC,WAAW,IAAI,UAAU,IAAI,gBAAgB,CAAC,KAAK,EAAE;AACtF,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;AACjD,QAAA,OAAO,SAAS,CAAC,sBAAsB,CAAC,UAAU,CAAC;IACr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YAAA,OAAO,SAAS;QAClB;AACA,QAAA,IAAI,OAAO,YAAY,aAAa,EAAE;AACpC,YAAA,OAAO,QAAQ;QACjB;AACA,QAAA,IAAI,OAAO,YAAY,YAAY,EAAE;YACnC,OAAO,CAAA,CAAA,EAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG;QAChF;AACA,QAAA,IAAI,OAAO,YAAY,WAAW,EAAE;AAClC,YAAA,OAAO,QAAQ;QACjB;AACA,QAAA,IAAI,OAAO,YAAY,aAAa,EAAE;AACpC,YAAA,OAAO,QAAQ;QACjB;AACA,QAAA,OAAO,SAAS;IAClB;AACF;;;;"}
|
package/client/imports.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function* imports(ctx) {
|
|
4
|
-
yield `
|
|
5
|
-
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
|
|
6
|
-
import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'
|
|
7
|
-
import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'
|
|
8
|
-
import {
|
|
9
|
-
AppClient as _AppClient,
|
|
10
|
-
AppClientMethodCallParams,
|
|
11
|
-
AppClientParams,
|
|
12
|
-
AppClientBareCallParams,
|
|
13
|
-
CallOnComplete,
|
|
14
|
-
AppClientCompilationParams,
|
|
15
|
-
ResolveAppClientByCreatorAndName,
|
|
16
|
-
ResolveAppClientByNetwork,
|
|
17
|
-
CloneAppClientParams,
|
|
18
|
-
} from '@algorandfoundation/algokit-utils/types/app-client'
|
|
19
|
-
${ctx.mode === 'full' ? `import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'` : ''}
|
|
20
|
-
import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'
|
|
21
|
-
import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'
|
|
22
|
-
import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'
|
|
23
|
-
`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
exports.imports = imports;
|
|
27
|
-
//# sourceMappingURL=imports.js.map
|
package/client/imports.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"imports.js","sources":["../../src/client/imports.ts"],"sourcesContent":["import { DocumentParts } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\n\nexport function* imports(ctx: GeneratorContext): DocumentParts {\n yield `\n import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'\n import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'\n import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'\n import {\n AppClient as _AppClient,\n AppClientMethodCallParams,\n AppClientParams,\n AppClientBareCallParams,\n CallOnComplete,\n AppClientCompilationParams,\n ResolveAppClientByCreatorAndName,\n ResolveAppClientByNetwork,\n CloneAppClientParams,\n } from '@algorandfoundation/algokit-utils/types/app-client'\n ${ctx.mode === 'full' ? `import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'` : ''}\n import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'\n import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'\n import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'\n `\n}\n"],"names":[],"mappings":";;AAGM,UAAW,OAAO,CAAC,GAAqB,EAAA;IAC5C,MAAM;;;;;;;;;;;;;;;MAeF,GAAG,CAAC,IAAI,KAAK,MAAM,GAAG,CAAA,oOAAA,CAAsO,GAAG,EAAE;;;;GAIpQ;AACH;;;;"}
|
package/client/imports.mjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
function* imports(ctx) {
|
|
2
|
-
yield `
|
|
3
|
-
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
|
|
4
|
-
import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'
|
|
5
|
-
import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'
|
|
6
|
-
import {
|
|
7
|
-
AppClient as _AppClient,
|
|
8
|
-
AppClientMethodCallParams,
|
|
9
|
-
AppClientParams,
|
|
10
|
-
AppClientBareCallParams,
|
|
11
|
-
CallOnComplete,
|
|
12
|
-
AppClientCompilationParams,
|
|
13
|
-
ResolveAppClientByCreatorAndName,
|
|
14
|
-
ResolveAppClientByNetwork,
|
|
15
|
-
CloneAppClientParams,
|
|
16
|
-
} from '@algorandfoundation/algokit-utils/types/app-client'
|
|
17
|
-
${ctx.mode === 'full' ? `import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'` : ''}
|
|
18
|
-
import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'
|
|
19
|
-
import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'
|
|
20
|
-
import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'
|
|
21
|
-
`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { imports };
|
|
25
|
-
//# sourceMappingURL=imports.mjs.map
|
package/client/imports.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"imports.mjs","sources":["../../src/client/imports.ts"],"sourcesContent":["import { DocumentParts } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\n\nexport function* imports(ctx: GeneratorContext): DocumentParts {\n yield `\n import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'\n import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'\n import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'\n import {\n AppClient as _AppClient,\n AppClientMethodCallParams,\n AppClientParams,\n AppClientBareCallParams,\n CallOnComplete,\n AppClientCompilationParams,\n ResolveAppClientByCreatorAndName,\n ResolveAppClientByNetwork,\n CloneAppClientParams,\n } from '@algorandfoundation/algokit-utils/types/app-client'\n ${ctx.mode === 'full' ? `import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'` : ''}\n import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'\n import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'\n import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'\n `\n}\n"],"names":[],"mappings":"AAGM,UAAW,OAAO,CAAC,GAAqB,EAAA;IAC5C,MAAM;;;;;;;;;;;;;;;MAeF,GAAG,CAAC,IAAI,KAAK,MAAM,GAAG,CAAA,oOAAA,CAAsO,GAAG,EAAE;;;;GAIpQ;AACH;;;;"}
|