diff --git a/docs/code/classes/types_application_client.ApplicationClient.md b/docs/code/classes/types_application_client.ApplicationClient.md index 774380fb..88fc3f31 100644 --- a/docs/code/classes/types_application_client.ApplicationClient.md +++ b/docs/code/classes/types_application_client.ApplicationClient.md @@ -60,7 +60,7 @@ Create a new ApplicationClient instance #### Defined in -[src/types/application-client.ts:151](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L151) +[src/types/application-client.ts:158](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L158) ## Properties @@ -201,7 +201,7 @@ ___ #### Defined in -[src/types/application-client.ts:408](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L408) +[src/types/application-client.ts:412](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L412) ___ @@ -221,7 +221,7 @@ ___ #### Defined in -[src/types/application-client.ts:388](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L388) +[src/types/application-client.ts:392](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L392) ___ @@ -241,7 +241,7 @@ ___ #### Defined in -[src/types/application-client.ts:400](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L400) +[src/types/application-client.ts:404](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L404) ___ @@ -261,7 +261,7 @@ ___ #### Defined in -[src/types/application-client.ts:396](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L396) +[src/types/application-client.ts:400](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L400) ___ @@ -281,7 +281,7 @@ ___ #### Defined in -[src/types/application-client.ts:293](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L293) +[src/types/application-client.ts:297](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L297) ___ @@ -301,13 +301,13 @@ ___ #### Defined in -[src/types/application-client.ts:404](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L404) +[src/types/application-client.ts:408](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L408) ___ ### deploy -▸ **deploy**(`deploy`): `Promise`<`Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"update"`` \| ``"create"`` } \| `Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `deleteResult`: [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) ; `operationPerformed`: ``"replace"`` } \| `Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"nothing"`` }\> +▸ **deploy**(`deploy?`): `Promise`<`Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"update"`` \| ``"create"`` } \| `Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `deleteResult`: [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) ; `operationPerformed`: ``"replace"`` } \| `Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"nothing"`` }\> Idempotently deploy (create, update/delete if changed) an app against the given name via the given creator account, including deploy-time template placeholder substitutions. @@ -325,7 +325,7 @@ https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-de | Name | Type | Description | | :------ | :------ | :------ | -| `deploy` | [`AppClientDeployParams`](../interfaces/types_application_client.AppClientDeployParams.md) | Deployment details | +| `deploy?` | [`AppClientDeployParams`](../interfaces/types_application_client.AppClientDeployParams.md) | Deployment details | #### Returns @@ -335,7 +335,7 @@ The metadata and transaction result(s) of the deployment, or just the metadata i #### Defined in -[src/types/application-client.ts:195](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L195) +[src/types/application-client.ts:200](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L200) ___ @@ -440,7 +440,7 @@ ___ #### Defined in -[src/types/application-client.ts:392](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L392) +[src/types/application-client.ts:396](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L396) ___ @@ -460,4 +460,4 @@ ___ #### Defined in -[src/types/application-client.ts:346](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L346) +[src/types/application-client.ts:350](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/application-client.ts#L350) diff --git a/package-lock.json b/package-lock.json index 1b38cf8c..d1096854 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "license": "MIT", "dependencies": { - "algosdk": "^2.1.0", + "algosdk": "^2.2.0", "buffer": "^6.0.3" }, "devDependencies": { @@ -2497,9 +2497,9 @@ } }, "node_modules/algosdk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/algosdk/-/algosdk-2.1.0.tgz", - "integrity": "sha512-KogpdRK3u7Efvw0FVduyFQEOwI+uGvMJmXUvzdmQJjK0hWhEYUl13X/X1QqNKwyEZjw2qutf9pf23UbNnBEAwA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/algosdk/-/algosdk-2.2.0.tgz", + "integrity": "sha512-FG3u/60DzjMK9Cffy9itst7WcfsTgZKfsD1r8pT33PfsA7r8NoXiUSL7cf0fNWFus6S3E14BpE2CY64VJ8KV1A==", "dependencies": { "algo-msgpack-with-bigint": "^2.1.1", "buffer": "^6.0.3", @@ -14224,9 +14224,9 @@ "integrity": "sha512-F1tGh056XczEaEAqu7s+hlZUDWwOBT70Eq0lfMpBP2YguSQVyxRbprLq5rELXKQOyOaixTWYhMeMQMzP0U5FoQ==" }, "algosdk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/algosdk/-/algosdk-2.1.0.tgz", - "integrity": "sha512-KogpdRK3u7Efvw0FVduyFQEOwI+uGvMJmXUvzdmQJjK0hWhEYUl13X/X1QqNKwyEZjw2qutf9pf23UbNnBEAwA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/algosdk/-/algosdk-2.2.0.tgz", + "integrity": "sha512-FG3u/60DzjMK9Cffy9itst7WcfsTgZKfsD1r8pT33PfsA7r8NoXiUSL7cf0fNWFus6S3E14BpE2CY64VJ8KV1A==", "requires": { "algo-msgpack-with-bigint": "^2.1.1", "buffer": "^6.0.3", diff --git a/package.json b/package.json index 0fdc3067..88986f7d 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "generate:code-docs": "typedoc" }, "dependencies": { - "algosdk": "^2.1.0", + "algosdk": "^2.2.0", "buffer": "^6.0.3" }, "devDependencies": { diff --git a/src/__snapshots__/deploy-app.spec.ts.snap b/src/__snapshots__/deploy-app.spec.ts.snap index b580bf58..36748dd6 100644 --- a/src/__snapshots__/deploy-app.spec.ts.snap +++ b/src/__snapshots__/deploy-app.spec.ts.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`deploy-app Deploy failure for replacement of permanent, updated app 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2203 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2456 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. INFO: Detected a TEAL update in app APP_1 for creator ACCOUNT_1 WARN: App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail @@ -10,26 +10,26 @@ WARN: Deleting existing test app with id APP_1 from ACCOUNT_1 account." `; exports[`deploy-app Deploy failure for replacement of schema broken app fails if onSchemaBreak = Fail 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2203 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2456 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. WARN: Detected a breaking app schema change in app APP_1: | [{"from":{"global":{"num-byte-slice":0,"num-uint":1},"local":{"num-byte-slice":0,"num-uint":0}},"to":{"global":{"num-byte-slice":1,"num-uint":1},"local":{"num-byte-slice":0,"num-uint":0}}}]" `; exports[`deploy-app Deploy failure for updated app fails if onupdate = Fail 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2203 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2456 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. INFO: Detected a TEAL update in app APP_1 for creator ACCOUNT_1" `; exports[`deploy-app Deploy new app 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2203 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2456 bytes of teal code and 39 bytes of teal code INFO: App test not found in apps created by ACCOUNT_1; deploying app with version 1.0. INFO: Sent transaction ID TXID_1 appl from ACCOUNT_1 DEBUG: Created app APP_1 from creator ACCOUNT_1" `; exports[`deploy-app Deploy replacement of deletable schema broken app 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2203 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2456 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. WARN: Detected a breaking app schema change in app APP_1: | [{"from":{"global":{"num-byte-slice":0,"num-uint":1},"local":{"num-byte-slice":0,"num-uint":0}},"to":{"global":{"num-byte-slice":1,"num-uint":1},"local":{"num-byte-slice":0,"num-uint":0}}}] INFO: App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app @@ -39,7 +39,7 @@ WARN: Sent transactions TXID_2 to create app with id APP_2 and TXID_3 to delete `; exports[`deploy-app Deploy replacement to deletable, updated app 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2203 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2456 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. INFO: Detected a TEAL update in app APP_1 for creator ACCOUNT_1 WARN: App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app... @@ -49,7 +49,7 @@ WARN: Sent transactions TXID_2 to create app with id APP_2 and TXID_3 to delete `; exports[`deploy-app Deploy replacement to schema broken, permanent app fails 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2203 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2456 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. WARN: Detected a breaking app schema change in app APP_1: | [{"from":{"global":{"num-byte-slice":0,"num-uint":1},"local":{"num-byte-slice":0,"num-uint":0}},"to":{"global":{"num-byte-slice":1,"num-uint":1},"local":{"num-byte-slice":0,"num-uint":0}}}] INFO: App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail @@ -58,7 +58,7 @@ WARN: Deleting existing test app with id APP_1 from ACCOUNT_1 account." `; exports[`deploy-app Deploy update to immutable updated app fails 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2203 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2456 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. INFO: Detected a TEAL update in app APP_1 for creator ACCOUNT_1 WARN: App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail @@ -67,7 +67,7 @@ DEBUG: Updating app APP_1" `; exports[`deploy-app Deploy update to updatable updated app 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2203 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2456 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. INFO: Detected a TEAL update in app APP_1 for creator ACCOUNT_1 INFO: App is updatable and onUpdate=UpdateApp, updating app... @@ -77,7 +77,7 @@ INFO: Sent transaction ID TXID_2 appl from ACCOUNT_1" `; exports[`deploy-app Do nothing if deploying app with no changes 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2203 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 2456 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. DEBUG: No detected changes in app, nothing to do." `; diff --git a/src/types/application-client.spec.ts b/src/types/application-client.spec.ts index ead53271..0bd17948 100644 --- a/src/types/application-client.spec.ts +++ b/src/types/application-client.spec.ts @@ -164,4 +164,41 @@ describe('application-client', () => { const methodArg = new ABIStringType().encode('test') expect(call.transaction.appArgs).toEqual([methodSelector, methodArg]) }) + + test('Display nice error messages when there is a logic error', async () => { + const { algod, indexer, testAccount } = localnet.context + const client = algokit.getApplicationClient( + { + app: appSpec, + sender: testAccount, + creatorAddress: testAccount.addr, + indexer: indexer, + }, + algod, + ) + await client.deploy({ + deployTimeParameters: { VALUE: 1 }, + }) + + try { + await client.call({ + method: 'error', + methodArgs: [], + }) + } catch (e: any) { + expect(e.toString()).toMatchInlineSnapshot(`"Error: assert failed pc=279. at:165"`) + expect(e.stack).toMatchInlineSnapshot(` + " + // error + error_2: + proto 0 0 + intc_0 // 0 + assert <--- Error + retsub + + // create + create_3:" + `) + } + }) }) diff --git a/src/types/application-client.ts b/src/types/application-client.ts index 4e20ab8a..e26778c7 100644 --- a/src/types/application-client.ts +++ b/src/types/application-client.ts @@ -197,8 +197,8 @@ export class ApplicationClient { * @param deploy Deployment details * @returns The metadata and transaction result(s) of the deployment, or just the metadata if it didn't need to issue transactions */ - async deploy(deploy: AppClientDeployParams) { - const { sender, version, allowUpdate, allowDelete, sendParams, createArgs, updateArgs, deleteArgs, ...deployArgs } = deploy + async deploy(deploy?: AppClientDeployParams) { + const { sender, version, allowUpdate, allowDelete, sendParams, createArgs, updateArgs, deleteArgs, ...deployArgs } = deploy ?? {} if (this._appId !== 0) { throw new Error(`Attempt to deploy app which already has an app id of ${this._appId}`) @@ -422,7 +422,7 @@ export class ApplicationClient { } try { - return callApp( + return await callApp( { appId: appMetadata.appId, callType: callType, diff --git a/tests/example-contracts/bare-call/application.json b/tests/example-contracts/bare-call/application.json index eea199d3..40b1590a 100644 --- a/tests/example-contracts/bare-call/application.json +++ b/tests/example-contracts/bare-call/application.json @@ -11,10 +11,16 @@ "call_config": { "no_op": "CALL" } + }, + "error()void": { + "read_only": true, + "call_config": { + "no_op": "CALL" + } } }, "source": { - "approval": "I3ByYWdtYSB2ZXJzaW9uIDgKaW50Y2Jsb2NrIDAgMQpieXRlY2Jsb2NrIDB4MTUxZjdjNzUgMHgKdHhuIE51bUFwcEFyZ3MKaW50Y18wIC8vIDAKPT0KYm56IG1haW5fbDYKdHhuYSBBcHBsaWNhdGlvbkF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Aphc3NlcnQKcmV0c3ViCgovLyBjcmVhdGUKY3JlYXRlXzM6CnByb3RvIDAgMAp0eG4gU2VuZGVyCmdsb2JhbCBDcmVhdG9yQWRkcmVzcwo9PQovLyB1bmF1dGhvcml6ZWQKYXNzZXJ0CnB1c2hieXRlcyAweDc2NjE2Yzc1NjUgLy8gInZhbHVlIgpwdXNoaW50IFRNUExfVkFMVUUgLy8gVE1QTF9WQUxVRQphcHBfZ2xvYmFsX3B1dApyZXRzdWIKCi8vIHVwZGF0ZQp1cGRhdGVfNDoKcHJvdG8gMCAwCnR4biBTZW5kZXIKZ2xvYmFsIENyZWF0b3JBZGRyZXNzCj09Ci8vIHVuYXV0aG9yaXplZAphc3NlcnQKcHVzaGludCBUTVBMX1VQREFUQUJMRSAvLyBUTVBMX1VQREFUQUJMRQovLyBDaGVjayBhcHAgaXMgdXBkYXRhYmxlCmFzc2VydApyZXRzdWIKCi8vIGRlbGV0ZQpkZWxldGVfNToKcHJvdG8gMCAwCnR4biBTZW5kZXIKZ2xvYmFsIENyZWF0b3JBZGRyZXNzCj09Ci8vIHVuYXV0aG9yaXplZAphc3NlcnQKcHVzaGludCBUTVBMX0RFTEVUQUJMRSAvLyBUTVBMX0RFTEVUQUJMRQovLyBDaGVjayBhcHAgaXMgZGVsZXRhYmxlCmFzc2VydApyZXRzdWI=", "clear": "I3ByYWdtYSB2ZXJzaW9uIDgKcHVzaGludCAwIC8vIDAKcmV0dXJu" }, "state": { @@ -73,6 +79,13 @@ "returns": { "type": "string" } + }, + { + "name": "error", + "args": [], + "returns": { + "type": "void" + } } ], "networks": {} diff --git a/tests/example-contracts/bare-call/approval.teal b/tests/example-contracts/bare-call/approval.teal index d0bcd7bc..0fb558ee 100644 --- a/tests/example-contracts/bare-call/approval.teal +++ b/tests/example-contracts/bare-call/approval.teal @@ -4,17 +4,33 @@ bytecblock 0x151f7c75 0x txn NumAppArgs intc_0 // 0 == -bnz main_l6 +bnz main_l8 txna ApplicationArgs 0 pushbytes 0xf81e962d // "call(string)string" == -bnz main_l5 +bnz main_l7 txna ApplicationArgs 0 pushbytes 0x3d9fe353 // "call_txn(pay,string)string" == -bnz main_l4 +bnz main_l6 +txna ApplicationArgs 0 +pushbytes 0x44d0da0d // "error()void" +== +bnz main_l5 err -main_l4: +main_l5: +txn OnCompletion +intc_0 // NoOp +== +txn ApplicationID +intc_0 // 0 +!= +&& +assert +callsub error_2 +intc_1 // 1 +return +main_l6: txn OnCompletion intc_0 // NoOp == @@ -44,7 +60,7 @@ concat log intc_1 // 1 return -main_l5: +main_l7: txn OnCompletion intc_0 // NoOp == @@ -62,42 +78,42 @@ concat log intc_1 // 1 return -main_l6: +main_l8: txn OnCompletion intc_0 // NoOp == -bnz main_l12 +bnz main_l14 txn OnCompletion pushint 4 // UpdateApplication == -bnz main_l11 +bnz main_l13 txn OnCompletion pushint 5 // DeleteApplication == -bnz main_l10 +bnz main_l12 err -main_l10: +main_l12: txn ApplicationID intc_0 // 0 != assert -callsub delete_4 +callsub delete_5 intc_1 // 1 return -main_l11: +main_l13: txn ApplicationID intc_0 // 0 != assert -callsub update_3 +callsub update_4 intc_1 // 1 return -main_l12: +main_l14: txn ApplicationID intc_0 // 0 == assert -callsub create_2 +callsub create_3 intc_1 // 1 return @@ -143,8 +159,15 @@ concat frame_bury 0 retsub +// error +error_2: +proto 0 0 +intc_0 // 0 +assert +retsub + // create -create_2: +create_3: proto 0 0 txn Sender global CreatorAddress @@ -157,7 +180,7 @@ app_global_put retsub // update -update_3: +update_4: proto 0 0 txn Sender global CreatorAddress @@ -170,7 +193,7 @@ assert retsub // delete -delete_4: +delete_5: proto 0 0 txn Sender global CreatorAddress diff --git a/tests/example-contracts/bare-call/bare_call.py b/tests/example-contracts/bare-call/bare_call.py index 72d2361d..7d8f9c63 100644 --- a/tests/example-contracts/bare-call/bare_call.py +++ b/tests/example-contracts/bare-call/bare_call.py @@ -22,6 +22,11 @@ def call_txn(txn: pt.abi.PaymentTransaction, value: pt.abi.String, *, output: pt return output.set(pt.Concat(pt.Bytes("Sent "), pt.Itob(txn.get().amount()), pt.Bytes(". "), value.get())) +@app.external(read_only=True) +def error() -> pt.Expr: + return pt.Assert(pt.Int(0)) + + @app.create(authorize=beaker.Authorize.only_creator(), bare=True) def create() -> pt.Expr: return app.state.value.set(pt.Tmpl.Int("TMPL_VALUE")) diff --git a/tests/example-contracts/bare-call/contract.json b/tests/example-contracts/bare-call/contract.json index 9c830fdb..ef737781 100644 --- a/tests/example-contracts/bare-call/contract.json +++ b/tests/example-contracts/bare-call/contract.json @@ -28,6 +28,13 @@ "returns": { "type": "string" } + }, + { + "name": "error", + "args": [], + "returns": { + "type": "void" + } } ], "networks": {} diff --git a/tests/example-contracts/hello-world/application.json b/tests/example-contracts/hello-world/application.json deleted file mode 100644 index 112a67e3..00000000 --- a/tests/example-contracts/hello-world/application.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "hints": { - "update()void": { - "call_config": { - "update_application": "CALL" - } - }, - "delete()void": { - "call_config": { - "delete_application": "CALL" - } - }, - "hello(string)string": { - "read_only": true, - "call_config": { - "no_op": "CALL" - } - } - }, - "source": { - "approval": "I3ByYWdtYSB2ZXJzaW9uIDgKaW50Y2Jsb2NrIDAgMQp0eG4gTnVtQXBwQXJncwppbnRjXzAgLy8gMAo9PQpibnogbWFpbl9sOAp0eG5hIEFwcGxpY2F0aW9uQXJncyAwCnB1c2hieXRlcyAweGEwZTgxODcyIC8vICJ1cGRhdGUoKXZvaWQiCj09CmJueiBtYWluX2w3CnR4bmEgQXBwbGljYXRpb25BcmdzIDAKcHVzaGJ5dGVzIDB4MjQzNzhkM2MgLy8gImRlbGV0ZSgpdm9pZCIKPT0KYm56IG1haW5fbDYKdHhuYSBBcHBsaWNhdGlvbkFyZ3MgMApwdXNoYnl0ZXMgMHgwMmJlY2UxMSAvLyAiaGVsbG8oc3RyaW5nKXN0cmluZyIKPT0KYm56IG1haW5fbDUKZXJyCm1haW5fbDU6CnR4biBPbkNvbXBsZXRpb24Ka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ZWF0b3JBZGRyZXNzCj09Ci8vIHVuYXV0aG9yaXplZAphc3NlcnQKcHVzaGludCBUTVBMX0RFTEVUQUJMRSAvLyBUTVBMX0RFTEVUQUJMRQovLyBDaGVjayBhcHAgaXMgZGVsZXRhYmxlCmFzc2VydApyZXRzdWIKCi8vIGhlbGxvCmhlbGxvXzI6CnByb3RvIDEgMQpwdXNoYnl0ZXMgMHggLy8gIiIKcHVzaGJ5dGVzIDB4NDg2NTZjNmM2ZjJjMjAgLy8gIkhlbGxvLCAiCmZyYW1lX2RpZyAtMQpleHRyYWN0IDIgMApjb25jYXQKZnJhbWVfYnVyeSAwCmZyYW1lX2RpZyAwCmxlbgppdG9iCmV4dHJhY3QgNiAwCmZyYW1lX2RpZyAwCmNvbmNhdApmcmFtZV9idXJ5IDAKcmV0c3Vi", - "clear": "I3ByYWdtYSB2ZXJzaW9uIDgKcHVzaGludCAwIC8vIDAKcmV0dXJu" - }, - "state": { - "global": { - "num_byte_slices": 0, - "num_uints": 0 - }, - "local": { - "num_byte_slices": 0, - "num_uints": 0 - } - }, - "schema": { - "global": { - "declared": {}, - "reserved": {} - }, - "local": { - "declared": {}, - "reserved": {} - } - }, - "contract": { - "name": "SampleApp", - "methods": [ - { - "name": "update", - "args": [], - "returns": { - "type": "void" - } - }, - { - "name": "delete", - "args": [], - "returns": { - "type": "void" - } - }, - { - "name": "hello", - "args": [ - { - "type": "string", - "name": "name" - } - ], - "returns": { - "type": "string" - } - } - ], - "networks": {} - }, - "bare_call_config": { - "no_op": "CREATE" - } -} \ No newline at end of file diff --git a/tests/example-contracts/hello-world/approval.teal b/tests/example-contracts/hello-world/approval.teal deleted file mode 100644 index 205e1725..00000000 --- a/tests/example-contracts/hello-world/approval.teal +++ /dev/null @@ -1,118 +0,0 @@ -#pragma version 8 -intcblock 0 1 -txn NumAppArgs -intc_0 // 0 -== -bnz main_l8 -txna ApplicationArgs 0 -pushbytes 0xa0e81872 // "update()void" -== -bnz main_l7 -txna ApplicationArgs 0 -pushbytes 0x24378d3c // "delete()void" -== -bnz main_l6 -txna ApplicationArgs 0 -pushbytes 0x02bece11 // "hello(string)string" -== -bnz main_l5 -err -main_l5: -txn OnCompletion -intc_0 // NoOp -== -txn ApplicationID -intc_0 // 0 -!= -&& -assert -txna ApplicationArgs 1 -callsub hello_2 -store 0 -pushbytes 0x151f7c75 // 0x151f7c75 -load 0 -concat -log -intc_1 // 1 -return -main_l6: -txn OnCompletion -pushint 5 // DeleteApplication -== -txn ApplicationID -intc_0 // 0 -!= -&& -assert -callsub delete_1 -intc_1 // 1 -return -main_l7: -txn OnCompletion -pushint 4 // UpdateApplication -== -txn ApplicationID -intc_0 // 0 -!= -&& -assert -callsub update_0 -intc_1 // 1 -return -main_l8: -txn OnCompletion -intc_0 // NoOp -== -bnz main_l10 -err -main_l10: -txn ApplicationID -intc_0 // 0 -== -assert -intc_1 // 1 -return - -// update -update_0: -proto 0 0 -txn Sender -global CreatorAddress -== -// unauthorized -assert -pushint TMPL_UPDATABLE // TMPL_UPDATABLE -// Check app is updatable -assert -retsub - -// delete -delete_1: -proto 0 0 -txn Sender -global CreatorAddress -== -// unauthorized -assert -pushint TMPL_DELETABLE // TMPL_DELETABLE -// Check app is deletable -assert -retsub - -// hello -hello_2: -proto 1 1 -pushbytes 0x // "" -pushbytes 0x48656c6c6f2c20 // "Hello, " -frame_dig -1 -extract 2 0 -concat -frame_bury 0 -frame_dig 0 -len -itob -extract 6 0 -frame_dig 0 -concat -frame_bury 0 -retsub \ No newline at end of file diff --git a/tests/example-contracts/hello-world/clear.teal b/tests/example-contracts/hello-world/clear.teal deleted file mode 100644 index e741f0e5..00000000 --- a/tests/example-contracts/hello-world/clear.teal +++ /dev/null @@ -1,3 +0,0 @@ -#pragma version 8 -pushint 0 // 0 -return \ No newline at end of file diff --git a/tests/example-contracts/hello-world/contract.json b/tests/example-contracts/hello-world/contract.json deleted file mode 100644 index d9fdf5b9..00000000 --- a/tests/example-contracts/hello-world/contract.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "SampleApp", - "methods": [ - { - "name": "update", - "args": [], - "returns": { - "type": "void" - } - }, - { - "name": "delete", - "args": [], - "returns": { - "type": "void" - } - }, - { - "name": "hello", - "args": [ - { - "type": "string", - "name": "name" - } - ], - "returns": { - "type": "string" - } - } - ], - "networks": {} -} \ No newline at end of file