Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
SwiftAdviser committed Oct 12, 2023
2 parents d7e4939 + 2678665 commit fd45108
Show file tree
Hide file tree
Showing 17 changed files with 3,376 additions and 12 deletions.
31 changes: 31 additions & 0 deletions docs/develop/dapps/telegram-apps/tips-and-tricks.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


# Tips and Tricks


:::danger
Page is under development.
:::


On this page, you'll find a list of frequently asked questions related to issues in TMA.

### How to solve the cache overflow issue in TMA?

:::tip
Only reinstalling the Telegram application could be helpful.
:::


### Are there any recommendations on caching headers for HTML files?

:::tip
It's preferable to switch off cache in the HTML. To ensure your cache switched off, specify headers in your request according the following:

```curl
Cache-Control: no-store, must-revalidate
Pragma: no-cache
Expires: 0
```
:::

2 changes: 1 addition & 1 deletion docs/develop/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Take your first steps in DApps development with a comprehensive DApps building g
* [APIs](/develop/dapps/apis)
* [SDKs](/develop/dapps/apis/sdk)

## TON Education Hub
## TON Education

- [Education](https://github.com/ton-community/awesome-ton#-education) - Unveil the comprehensive list of various educational materials, meticulously crafted by the remarkable TON Community.

Expand Down
40 changes: 29 additions & 11 deletions docs/develop/smart-contracts/testing/writing-test-examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,17 @@ blockchain.verbosity = {
## Direct Unit Tests
Fireworks demonstrate different operating with sending messages in the TON Blockchain.
![](/img/docs/test-examples/fireworks_trace_tonviewer.png?=RAW)
![](/img/docs/writing-test-examples/test-examples-schemes.svg)
Once you deploy this with message `set_first` with enough TON amount, it will be automatically executed with primary and usable combinations of send modes.
Fireworks redeployed itself, as result it will be created 3 entities of Fireworks entities, while each of entity has own ID(keep it in storage) and, as a result, different Smart Contract Address.
For clearness define different by ID Fireworks entities with the following names:
For clearness define different by ID Fireworks instances (different `state_init`) with the following names:
* 1 - Fireworks setter - The entity that spread different launch op codes. Could be extended up to four different opcodes.
* 2 - Fireworks launcher 1 - The Fireworks instance, which launch first fireworks, means messages will be sent to the launcher.
* 3 - Fireworks launcher 2 - The Fireworks instance, which launch second fireworks, means messages will be sent launcher.
Each 'firework' - is a transaction which executed with unique message body and message sending mode.
* 2 - Fireworks launcher-1 - The Fireworks instance, which launch first fireworks, means messages will be sent to the launcher.
* 3 - Fireworks launcher-2 - The Fireworks instance, which launch second fireworks, means messages will be sent launcher.
<details>
Expand All @@ -77,6 +76,8 @@ index - is an ID of a transaction in the `launchResult` array.
</details>
Each 'firework' - is outbound message with a unique message body appears in transactions with ID:3 and ID:4.
Bellow the list of test for each transaction expected successfully executed. Transaction[ID:0] External request to the treasury (the Launcher) that resulted with a outbound message `op::set_first` with 2.5 to fireworks. In case you will deploy Fireworks to the blockchain launcher is your wallet.
Expand All @@ -85,11 +86,14 @@ Bellow the list of test for each transaction expected successfully executed. Tra
[This test](https://github.com/ton-community/fireworks-func/blob/main/tests/Fireworks.spec.ts#L75) checks if the fireworks are successfully set by sending a transaction with a value of 2.5 TON.
This is the simplest case, the main purpose here to assert result of transaction success property to true.
To filter certain transaction from the `launhcResult.transactions` array, we can use the most convince fields.
With
`from` (contract sender address), `to` (contract destination address), `op` (Op code value) - we will retrieve only one transaction for this combination.
The transaction[ID:1] in Fireworks Setter contract invoked with `op::set_first` and executed with two outbound messages to the Fireworks Launcher-1 and Fireworks Launcher-2
![](/img/docs/writing-test-examples/test-examples-schemes_id1.svg)
The transaction[ID:1] in Fireworks Setter contract invoked with `op::set_first` and executed with two outbound messages to the Fireworks launcher-1 and Fireworks launcher-2
```typescript

Expand All @@ -115,6 +119,8 @@ The transaction[ID:1] in Fireworks Setter contract invoked with `op::set_first`

[This test](https://github.com/ton-community/fireworks-func/blob/main/tests/Fireworks.spec.ts#L92) checks if the transaction[ID:2] executed successfully.

![](/img/docs/writing-test-examples/test-examples-schemes_id2.svg)

The transaction in the Fireworks launcher 1 invoked with `op::launch_first`, and executed with four outbound messages to the Launcher.

```typescript
Expand Down Expand Up @@ -154,6 +160,8 @@ The full list of Account Status related fields:

[This test](https://github.com/ton-community/fireworks-func/blob/main/tests/Fireworks.spec.ts#L113) checks if the transaction[ID:3] executed successfully.

![](/img/docs/writing-test-examples/test-examples-schemes_id3.svg)

The transaction[ID:3] carries out in the Fireworks launcher 1, invokes with `op::launch_first`, and executes with four outbound messages to the Launcher.


Expand Down Expand Up @@ -189,6 +197,8 @@ The transaction[ID:3] carries out in the Fireworks launcher 1, invokes with `op:

[This test](https://github.com/ton-community/fireworks-func/blob/main/tests/Fireworks.spec.ts#L133) checks if the transaction[ID:4] executed successfully.

![](/img/docs/writing-test-examples/test-examples-schemes_id4.svg)

Transaction[ID:4] carries out in the Launcher(Deploy Wallet) with incoming message from the Fireworks launcher 1. This message sent with `send mode = 0` in the Transaction[ID:2].

```typescript
Expand Down Expand Up @@ -216,6 +226,8 @@ Transaction[ID:4] carries out in the Launcher(Deploy Wallet) with incoming messa

[This test](https://github.com/ton-community/fireworks-func/blob/main/tests/Fireworks.spec.ts#L152) checks if the transaction[ID:5] executed successfully.

![](/img/docs/writing-test-examples/test-examples-schemes_id5.svg)

Transaction[ID:5] carries out in the Launcher with incoming message from the Fireworks launcher 1. This message sent with `send mode = 1`

```typescript
Expand Down Expand Up @@ -244,6 +256,8 @@ Transaction[ID:5] carries out in the Launcher with incoming message from the Fi

[This test](https://github.com/ton-community/fireworks-func/blob/main/tests/Fireworks.spec.ts#L170) checks if the transaction[ID:6] executed successfully.

![](/img/docs/writing-test-examples/test-examples-schemes_id6.svg)

The transaction[ID:6] carries out in the Launcher with incoming message from the Fireworks launcher 1. This message sent with `send mode = 2`


Expand Down Expand Up @@ -271,6 +285,8 @@ The transaction[ID:6] carries out in the Launcher with incoming message from the

[This test](https://github.com/ton-community/fireworks-func/blob/main/tests/Fireworks.spec.ts#L188) checks if the transaction[ID:7] executed successfully.

![](/img/docs/writing-test-examples/test-examples-schemes_id7.svg)

The transaction[ID:7] carries out in the Launcher with incoming message from the Fireworks launcher 1. This message sent with `send mode = 128 + 32`

```typescript
Expand All @@ -292,10 +308,12 @@ The transaction[ID:7] carries out in the Launcher with incoming message from the
})
```

#### ### Transaction ID:8 Success Test
### Transaction ID:8 Success Test

[This test](https://github.com/ton-community/fireworks-func/blob/main/tests/Fireworks.spec.ts#L188) checks if the transaction[ID:8] executed successfully.

![](/img/docs/writing-test-examples/test-examples-schemes_id8.svg)

The transaction[ID:8] carries out in the Launcher with incoming message from the Fireworks launcher 2. This message sent with `send mode = 64`

```typescript
Expand All @@ -320,7 +338,7 @@ The transaction[ID:8] carries out in the Launcher with incoming message from the

```

### Printing and Reading Transaction Fees
## Printing and Reading Transaction Fees

During the test, reading the details about fees can be useful for optimizing the contract. The printTransactionFees function prints the entire transaction chain in a convenient manner."
```typescript
Expand Down Expand Up @@ -357,7 +375,7 @@ For instance, in case of `launchResult` the following table will be printed:



![](/img/docs/test-examples/fireworks_trace_tonviewer.png?=RAW)
![](/img/docs/writing-test-examples/fireworks_trace_tonviewer.png?=RAW)

index - is an ID of a transaction in the `launchResult` array.
* `0` - External request to the treasury (the Launcher) that resulted in a message `op::set_first` to Fireworks
Expand All @@ -371,7 +389,7 @@ index - is an ID of a transaction in the `launchResult` array.
* `8` - Transaction on Launcher with incoming message from the Launched Fireworks - 2, message sent with `send mode = 64`


### Transaction Fees Tests
## Transaction Fees Tests

This test verifies whether the transaction fees for launching the fireworks are as expected. It is possible to define custom assertions for different parts of commission fees.

Expand Down
2 changes: 2 additions & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ const sidebars = {
'develop/dapps/telegram-apps/publishing',
'develop/dapps/telegram-apps/monetization',
'develop/dapps/telegram-apps/grants',
'develop/dapps/telegram-apps/tips-and-tricks',


],
},
Expand Down
Loading

0 comments on commit fd45108

Please sign in to comment.