├── .gitbook.yaml ├── .gitbook └── assets │ ├── scr1.jpg │ └── ton-sdk-blue.png ├── .github └── workflows │ └── npmpublish.yml ├── .gitignore ├── .npmignore ├── .prettierrc ├── CHANGELOG.md ├── LICENSE ├── README.md ├── __tests__ ├── basic.ts ├── tsconfig.json └── utils │ ├── Hello.abi.json │ ├── Hello.sol │ ├── Hello.tvc │ └── index.ts ├── babel.config.js ├── docs ├── .nojekyll ├── assets │ ├── highlight.css │ ├── icons.css │ ├── icons.png │ ├── icons@2x.png │ ├── main.js │ ├── search.js │ ├── style.css │ ├── widgets.png │ └── widgets@2x.png ├── classes │ ├── Account.html │ └── AccountError.html ├── enums │ └── AccountType.html ├── index.html ├── interfaces │ └── AccountGiver.html └── modules.html ├── gitbook ├── SUMMARY.md └── guides │ ├── appkit_guides.md │ ├── configure_appkit.md │ ├── custom_giver.md │ ├── deploy.md │ ├── run_abi_get_method.md │ ├── run_onchain.md │ └── work_with_events.md ├── jest.config.js ├── package.json ├── src ├── account.ts └── index.ts ├── tsconfig.base.json └── tsconfig.json /.gitbook.yaml: -------------------------------------------------------------------------------- 1 | root: ./gitbook/ 2 | 3 | structure: 4 | readme: ../README.md 5 | summary: ./SUMMARY.md -------------------------------------------------------------------------------- /.gitbook/assets/scr1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/.gitbook/assets/scr1.jpg -------------------------------------------------------------------------------- /.gitbook/assets/ton-sdk-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/.gitbook/assets/ton-sdk-blue.png -------------------------------------------------------------------------------- /.github/workflows/npmpublish.yml: -------------------------------------------------------------------------------- 1 | name: npm publish 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | publish-npm: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - uses: actions/setup-node@v1 13 | with: 14 | node-version: 12 15 | registry-url: https://registry.npmjs.org/ 16 | 17 | - name: appkit-js 18 | run: npm publish --access public 19 | env: 20 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | **/*.swp 5 | **/*.swo 6 | .idea/ 7 | .vscode/ 8 | node_modules/ 9 | package-lock.json 10 | /__tests__/*.dylib 11 | /__tests__/*.node 12 | /coverage/ 13 | Jenkinsfile 14 | /reinstall.sh 15 | /uninstall.sh 16 | **/*.a 17 | **/*.so 18 | **/*.dylib 19 | **/*.node 20 | **/*.wasm 21 | **/dist/ 22 | **/*.map 23 | **/*.tsbuildinfo 24 | **/Cargo.lock 25 | **/publish/** 26 | **/target/** 27 | **/*.tgz 28 | **/BUCK 29 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | * 2 | !src/**/* 3 | !dist/**/* 4 | dist/**/*.test.* 5 | !package.json 6 | !README.md 7 | **/*.map 8 | src/ 9 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "all", 3 | "tabWidth": 4, 4 | "semi": false, 5 | "singleQuote": false, 6 | "printWidth": 80, 7 | "arrowParens": "avoid", 8 | "bracketSpacing": true, 9 | "endOfLine": "lf", 10 | "proseWrap": "preserve", 11 | "quoteProps": "as-needed", 12 | "requirePragma": false, 13 | "useTabs": false 14 | } 15 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | 6 | ## [0.3.8] – 2023-05-12 7 | 8 | - AccountGiver.sendTo now returns ResultOfProcessMessage 9 | 10 | ## [0.3.7] – 2023-05-11 11 | 12 | - Support giver v3 13 | 14 | ## [0.3.6] – 2023-03-02 15 | 16 | - Fixed giver 17 | 18 | ## [0.3.5] – 2022-12-23 19 | 20 | - Improved error handling in case of network errors 21 | 22 | ## [0.3.4] – 2022-11-17 23 | 24 | - Improved error handling in case of network errors 25 | 26 | ## [0.3.3] – 2022-11-14 27 | 28 | ### Fix 29 | 30 | - Fixed a bug that caused the error to disappear instead of being thrown. 31 | 32 | - Fixed a test that started to fail after improving message processing speed in Evernode-SE. 33 | 34 | 35 | ## [0.3.2] – 2022-10-18 36 | ### Fix 37 | - Minor fix, considering accounts with type "NonExist", which BOC is empty. 38 | 39 | ## [0.3.1] – 2022-03-22 40 | 41 | ### New 42 | - Rebranding to ever-appkit-js (@eversdk/appkit) 43 | 44 | ## [0.3.0] – 2021-12-03 45 | 46 | ### Improved 47 | - Add `useCachedState` flag. If set to true, appkit aggressively caches account state, that can be useful for running `deployLocal` and `runLocal` functions in tests (local emulation of contract deployment and execution). 48 | 49 | ## [0.2.0] – 2021-04-08 50 | 51 | ### New 52 | - `Account.deployLocal` emulates deploy on local TVM. 53 | - `AccountType` enumeration with available values for `acc_type` field of the parsed account. 54 | - `Account.calcDeployFees` and `Account.calcRunFees` calculates estimated fees for deploy and run message processing. 55 | 56 | ### Fixed 57 | - Before `Account.getAccount` failed if the account did not exist in the blockchain. Now it returns parsed account with only field `acc_type` equals to `AccountType.nonExist`. If account does not exist in the blockchain and `deployLocal` is executed, it will return a full account object. 58 | 59 | ### Documentation 60 | - API Reference documentation is now hosted at https://tonlabs.github.io/appkit-js/ 61 | 62 | ## [0.1.0] – 2021-03-19 63 | 64 | ### New 65 | - AppKit first release. 66 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Everscale JS Application Kit 2 | 3 | This library is a part of Everscale SDK for JavaScript. 4 | 5 | AppKit is built over the [@eversdk/core](https://github.com/tonlabs/ever-sdk-js) package and purposed to simplify writing applications on Everscale. 6 | 7 | Full API reference: [https://tonlabs.github.io/ever-appkit-js/](https://tonlabs.github.io/ever-appkit-js/) 8 | 9 | If this package helped you, please give it a star:) 10 | 11 | **Have a question? Get quick help in our channel:** 12 | 13 | [![Chat on Telegram](https://img.shields.io/badge/chat-on%20telegram-9cf.svg)](https://t.me/ton\_sdk) 14 | 15 | ## Table of Contents 16 | 17 | * [Useful links](./#useful-links) 18 | * [Before You Start](./#before-you-start) 19 | * [Installation](./#installation) 20 | * [Setup Client Library](./#setup-client-library) 21 | * [NodeJs:](./#nodejs) 22 | * [Web:](./#web) 23 | * [React Native:](./#react-native) 24 | * [Create Client Instance](./#create-client-instance) 25 | * [A Few Words about the Code](./#a-few-words-about-the-code) 26 | * [Use Account Object](./#use-account-object) 27 | * [Sample source code](./#sample-source-code) 28 | * [Subscribe for Changes](./#subscribe-for-changes) 29 | * [Executing Contract on TVM](./#executing-contract-on-tvm) 30 | * [Interacting with Core SDK](./#interacting-with-core-sdk) 31 | 32 | ## Useful links 33 | 34 | * [Full API reference](https://tonlabs.github.io/ever-appkit-js/) 35 | * [Appkit samples](https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples) 36 | * [SDK guides](https://docs.everos.dev/ever-sdk/quick\_start) - to get a deeper understanding dive into our sdk guides where you can find extensive explanations and descriptions of each step of DApp development on Everscale. 37 | 38 | ## Before You Start 39 | 40 | We strongly recommend installing [EverDev](https://docs.everos.dev/everdev/) utility before you start playing with AppKit. This utility will help you manage your tools for Everscale development. 41 | 42 | ## Installation 43 | 44 | ```shell 45 | # Install core package 46 | npm i --save @eversdk/core 47 | 48 | # Install lib-node bridge if you write node js application 49 | npm i --save @eversdk/lib-node 50 | 51 | # Or install lib-web bridge if you write web/browser application 52 | npm i --save @eversdk/lib-web 53 | 54 | # Or install lib-react-native if you write react-native mobile application 55 | npm i --save @eversdk/lib-react-native 56 | 57 | # And finally install appkit itself 58 | npm i --save @eversdk/appkit 59 | ``` 60 | 61 | ## Setup Client Library 62 | 63 | You must initialize the core library before the first use. The best place to do it is in the initialization code of your application. 64 | 65 | ### NodeJs: 66 | 67 | ```javascript 68 | const { TonClient } = require("@eversdk/core"); 69 | const { libNode } = require("@eversdk/lib-node"); 70 | 71 | // Application initialization 72 | 73 | TonClient.useBinaryLibrary(libNode) 74 | ``` 75 | 76 | ### Web: 77 | 78 | ```javascript 79 | import { TonClient } from "@eversdk/core"; 80 | import { libWeb } from "@eversdk/lib-web"; 81 | 82 | // Application initialization 83 | 84 | TonClient.useBinaryLibrary(libWeb); 85 | ``` 86 | 87 | By default, the library loads wasm module from relative URL `/tonclient.wasm`. 88 | 89 | You can specify alternative URL if you want to place (or rename) wasm module. 90 | 91 | ```javascript 92 | import { TonClient } from "@eversdk/core"; 93 | import { libWeb, libWebSetup } from "@eversdk/lib-web"; 94 | 95 | // Application initialization. 96 | 97 | // You have to setup libWeb if the `tonclient.wasm` 98 | // isn't located at root of your web site. 99 | // Otherwise you havn't to call `libWebSetup`. 100 | libWebSetup({ 101 | binaryURL: "/assets/tonclient_1_2_3.wasm", 102 | }); 103 | 104 | TonClient.useBinaryLibrary(libWeb); 105 | ``` 106 | 107 | ### React Native: 108 | 109 | ```javascript 110 | import { TonClient } from "@eversdk/core"; 111 | import { libReactNative } from "@eversdk/lib-react-native"; 112 | 113 | // Application initialization 114 | 115 | TonClient.useBinaryLibrary(libReactNative); 116 | ``` 117 | 118 | ## Create Client Instance 119 | 120 | AppKit is built over [core JS library](https://github.com/tonlabs/ever-sdk-js/tree/master/packages/core). So you have to create an instance of `TonClient` to use it later with AppKit objects. 121 | 122 | ```javascript 123 | const client = new TonClient({ 124 | network: { endpoints: ["http://localhost"] } 125 | }); 126 | ``` 127 | 128 | In this sample we create a client instance configured to use local blockchain [Evernode SE](https://github.com/tonlabs/evernode-se) instance. 129 | 130 | If you want to work with Developer Network or Everscale main network, please use the [list of endpoints, listed here](https://docs.everos.dev/ever-sdk/reference/ever-os-api/networks). **Attention** You must specify all the endpoints as an array in `endpoints` parameter, because each endpoint does not guarantee its availability, but we guarantee that at least one endpoint is operational at the moment. 131 | 132 | ## A Few Words about the Code 133 | 134 | Below we use a code snippets to illustrate `AppKit` usage.\ 135 | In this code we omit an initialization part because it is the same.\ 136 | We suppose that we are using lib-node bridge (NodeJs) to write examples. Also, we use the library to deal with local [Evernode SE](https://github.com/tonlabs/evernode-se) instance. 137 | 138 | So the full code of each example can look like this: 139 | 140 | ```javascript 141 | const { TonClient } = require("@eversdk/core"); 142 | const { libNode } = require("@eversdk/lib-node"); 143 | const { Account } = require("@eversdk/appkit"); 144 | 145 | TonClient.useBinaryLibrary(libNode); 146 | 147 | (async () => { 148 | const endpoint = process.env.TON_NETWORK_ADDRESS || "http://localhost"; 149 | const client = new TonClient({ network: { endpoints: [endpoint] } }); 150 | try { 151 | await main(client); 152 | } catch (err) { 153 | console.error(err); 154 | } finally { 155 | client.close(); 156 | } 157 | })(); 158 | 159 | async function main(client) { 160 | // Snippet code is here 161 | } 162 | ``` 163 | 164 | ## Use Account Object 165 | 166 | At the moment the key point of `AppKit` is an Account object (class). Application uses an Account instance to deal with specific blockchain account using specific owner ( signer in terms of TonClient library). 167 | 168 | Each Account instance must use an ABI compliant contract. So we have to define the `Contract` object with an ABI and optionally tvc fields. This object must be provided to the Account constructor. 169 | 170 | In the example below we use predefined giver already included in AppKit and predeployed in Evernode SE. 171 | 172 | ```javascript 173 | // Define Contract object. 174 | const AccContract = { 175 | abi: { /* ABI declarations */ }, 176 | tvc: "... base64 encoded string ...", 177 | }; 178 | 179 | // Generate new keys pair for new account. 180 | const keys = await client.crypto.generate_random_sign_keys(); 181 | 182 | // Create owner (signer) instance for new account. 183 | const signer = signerKeys(keys); 184 | 185 | // Construct Account instance. 186 | // 187 | // Note that this account is not deployed in the blockchain yet. 188 | // We just create an object to deal with this account. 189 | const acc = new Account(AccContract, { signer, client }); 190 | 191 | // We can determine the future addres of the account 192 | // and print it to the user before deploying. 193 | console.log(`New account future address: ${await acc.getAddress()}`); 194 | 195 | // Deploy account to the blockchain. 196 | // Here we use TONOS SE giver to create a positive balance 197 | // before deploying. 198 | await acc.deploy({ useGiver: true }); 199 | 200 | // Send external inbound message to our new account 201 | // and receives result from external outboud message. 202 | const response = await acc.run("someFunction", { someParam: 1 }); 203 | 204 | // Print decoded response message 205 | console.log("Account has responded to someFunction with", response.decoded.output); 206 | 207 | // Print current balance. 208 | // Note that balance returned as a string in decimal representation. 209 | // This is because of a value measure is a nano. 210 | // So its value may not be representable using JS Number. 211 | console.log("Account balance now is", await acc.getBalance()); 212 | ``` 213 | 214 | In the example above we demonstrated typical basic usage of the Account object. 215 | 216 | ### Sample source code 217 | 218 | Find the sample that demonstrates AppKit usage source code here: [https://github.com/tonlabs/sdk-samples/tree/master/demo/hello-wallet](https://github.com/tonlabs/sdk-samples/tree/master/demo/hello-wallet) 219 | 220 | ## Subscribe for Changes 221 | 222 | Sometimes it is required to listen for events related to an account in realtime. 223 | 224 | It is easy: just call one of the `subscribe` methods of an account instance. 225 | 226 | For example, if we need to track all changes in the account state on the blockchain we can use `subscribeAccount`: 227 | 228 | ```ts 229 | const hello = new Account(Hello, { signer }); 230 | await hello.deploy(); 231 | 232 | await hello.subscribeAccount("balance", (acc) => { 233 | // This callback triggers every time the account data 234 | // is changed on the blockchain 235 | console.log("Account has updated. Current balance is ", parseInt(acc.balance)); 236 | }); 237 | 238 | await hello.subscribeMessages("boc", async (msg) => { 239 | // This callback triggers every time the message related to this account 240 | // is appeared on the blockchain. 241 | // Releated messages include inbound and outbound messages. 242 | console.log("Message is appeared ", msg); 243 | }); 244 | 245 | // ...... do something with hello account ........... 246 | 247 | // In addition to other cleanup stuff the `free` method 248 | // unsubscribes all active subscriptions for this account instance. 249 | await hello.free(); 250 | ``` 251 | 252 | ## Executing Contract on TVM 253 | 254 | There are some situations where running the contract on the blockchain is not acceptable: 255 | 256 | * Writing a tests for developing contract. 257 | * Emulating execution for an existing account to detect failure reason or to calculate estimated fees. 258 | * Getting information from an existing account by running its get methods. 259 | 260 | In these cases we can play with an account on the TVM included in EVER SDK client library: 261 | 262 | ```ts 263 | const hello = new Account(Hello, { signer }); 264 | 265 | // We don't deploy contract on real network. 266 | // We just emulate it. After this call the hello instance 267 | // will have an account boc that can be used in consequent 268 | // calls. 269 | await hello.deployLocal(); 270 | 271 | // We execute contract locally. 272 | // But exactly the same way as it executes on the real blockchain. 273 | const result = await hello.runLocal("touch", {}); 274 | console.log('Touch output', result); 275 | ``` 276 | 277 | We can call get method on accounts in the blockchain: 278 | 279 | ```ts 280 | const acc = new Account(MyAccount, { address: someAddress }); 281 | 282 | // Contracts code and data will be downloaded from the blockchain 283 | // and used to execute on the local TVM. 284 | // Without any fees. 285 | const lastBid = (await acc.runLocal("getLastBid", {})).decoded.output.lastBid; 286 | console.log('Last bid is', lastBid); 287 | 288 | // As laways we need to cleanup resources associated with insdtance. 289 | await acc.free(); 290 | ``` 291 | 292 | There are some situations where running the contract on the blockchain is not acceptable: 293 | 294 | * Writing a tests for developing contract. 295 | * Emulating execution for an existing account to detect failure reason or to calculate estimated fees. 296 | * Getting information from an existing account by running its get methods. 297 | 298 | In these cases we can play with an account on the TVM included in EVER SDK client library: 299 | 300 | ```ts 301 | const hello = new Account(Hello, { signer }); 302 | 303 | // We don't deploy contract on real network. 304 | // We just emulate it. After this call the hello instance 305 | // will have an account boc that can be used in consequent 306 | // calls. 307 | await hello.deployLocal(); 308 | 309 | // We execute contract locally. 310 | // But exactly the same way as it executes on the real blockchain. 311 | const result = await hello.runLocal("touch", {}); 312 | console.log('Touch output', result); 313 | ``` 314 | 315 | We can call get method on accounts in the blockchain: 316 | 317 | ```ts 318 | const acc = new Account(MyAccount, { address: someAddress }); 319 | 320 | // Contracts code and data will be downloaded from the blockchain 321 | // and used to execute on the local TVM. 322 | // Without any fees. 323 | const lastBid = (await acc.runLocal("getLastBid", {})).decoded.output.lastBid; 324 | console.log('Last bid is', lastBid); 325 | 326 | // As laways we need to cleanup resources associated with insdtance. 327 | await acc.free(); 328 | ``` 329 | 330 | ## Interacting with Core SDK 331 | 332 | AppKit is a convenient library built over the EVER SDK core library. Of course the AppKit doesn't cover a lot of tasks the core SDK do. 333 | 334 | So you have to easily interact with low level SDK functions. It is really easy. 335 | 336 | Each `Account` instance has a reference to the EVER SDK client instance. So you can use this reference. 337 | 338 | ```ts 339 | async function test(wallet: Account) { 340 | const rnd = (await wallet.client.crypto.generate_random_bytes({ 341 | length: 100 342 | })).bytes; 343 | } 344 | ``` 345 | 346 | Each account instance has an `abi` field with ABI this account belongs to. 347 | 348 | ```ts 349 | async function test(wallet: Account) { 350 | const decoded = (await wallet.client.abi.decode_message_body({ 351 | abi: wallet.abi, 352 | body: someMessageBody, 353 | is_internal: false, 354 | })).value; 355 | } 356 | ``` 357 | -------------------------------------------------------------------------------- /__tests__/basic.ts: -------------------------------------------------------------------------------- 1 | import { 2 | signerKeys, 3 | TonClient, 4 | } from "@eversdk/core"; 5 | import { 6 | loadContract, 7 | init, 8 | done, 9 | } from "./utils"; 10 | import { 11 | Account, 12 | AccountType, 13 | } from "../src"; 14 | 15 | beforeAll(init); 16 | afterAll(done); 17 | const helloContract = () => loadContract("Hello"); 18 | 19 | test("Account Basic Usage", async () => { 20 | const client = TonClient.default; 21 | const startTimeInSeconds = Math.floor(Date.now() / 1000); 22 | 23 | const acc = new Account(helloContract(), { 24 | signer: signerKeys(await client.crypto.generate_random_sign_keys()), 25 | client, 26 | }); 27 | 28 | const address = await acc.getAddress(); 29 | expect(address.substr(0, 2)).toEqual("0:"); 30 | 31 | await acc.deploy({useGiver: true}); 32 | expect(Number.parseInt((await acc.getAccount()).balance)).toBeGreaterThan(500_000_000); 33 | 34 | let response = await acc.run("touch", {}); 35 | expect(response.transaction.id).toHaveLength(64); 36 | 37 | response = await acc.runLocal("sayHello", {}); 38 | const timestampInSeconds = Number(response.decoded?.output.value0); 39 | expect(timestampInSeconds).toBeGreaterThanOrEqual(startTimeInSeconds); 40 | }); 41 | 42 | test("Calc Fees", async () => { 43 | const client = TonClient.default; 44 | const account = new Account(helloContract(), { 45 | signer: signerKeys(await client.crypto.generate_random_sign_keys()), 46 | client, 47 | useCachedState: true, 48 | }); 49 | 50 | const deployFees = await account.calcDeployFees(); 51 | expect(deployFees.total_account_fees).toBeGreaterThan(13_300_000); 52 | 53 | await account.deployLocal(); 54 | 55 | const runFees = await account.calcRunFees("touch", {}); 56 | expect(runFees.total_account_fees).toBeGreaterThan(5_550_000); 57 | }); 58 | 59 | test("Uninit State", async () => { 60 | const client = TonClient.default; 61 | const account = new Account(helloContract(), { 62 | signer: signerKeys(await client.crypto.generate_random_sign_keys()), 63 | client, 64 | }); 65 | expect((await account.getAccount()).acc_type).toEqual(AccountType.nonExist); 66 | const giver = await Account.getGiverForClient(client); 67 | await giver.sendTo(await account.getAddress(), 200_000_000); 68 | 69 | account.refresh(); 70 | expect((await account.getAccount()).acc_type).toEqual(AccountType.uninit); 71 | }); 72 | 73 | test("Local run without `useCachedState`", async () => { 74 | const client = TonClient.default; 75 | const account = new Account(helloContract(), { 76 | signer: signerKeys(await client.crypto.generate_random_sign_keys()), 77 | client, 78 | }); 79 | await account.deployLocal(); 80 | await expect(account.calcRunFees("touch", {})).rejects.toHaveProperty( 81 | 'message', 82 | expect.stringMatching(/Account does not exists on the blockchain/) 83 | ) 84 | }); 85 | -------------------------------------------------------------------------------- /__tests__/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": "../", 5 | "outDir": "./dist", 6 | "types": ["node", "jest"] 7 | }, 8 | "include": [ 9 | "../**/*" 10 | ], 11 | "exclude": [ 12 | "**/dist" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /__tests__/utils/Hello.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | ], 9 | "outputs": [ 10 | ] 11 | }, 12 | { 13 | "name": "touch", 14 | "inputs": [ 15 | ], 16 | "outputs": [ 17 | ] 18 | }, 19 | { 20 | "name": "sayHello", 21 | "inputs": [ 22 | ], 23 | "outputs": [ 24 | {"name":"value0","type":"uint32"} 25 | ] 26 | }, 27 | { 28 | "name": "sendAllMoney", 29 | "inputs": [ 30 | {"name":"dest_addr","type":"address"} 31 | ], 32 | "outputs": [ 33 | ] 34 | } 35 | ], 36 | "data": [ 37 | ], 38 | "events": [ 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /__tests__/utils/Hello.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.5.0; 2 | pragma AbiHeader time; 3 | pragma AbiHeader expire; 4 | 5 | contract HelloTON { 6 | uint32 timestamp; 7 | 8 | // Modifier that allows public function to accept all external calls. 9 | modifier alwaysAccept { 10 | tvm.accept(); 11 | _; 12 | } 13 | modifier onlyOwner { 14 | require(msg.pubkey() == tvm.pubkey(), 100); 15 | tvm.accept(); 16 | _; 17 | } 18 | 19 | constructor() public { 20 | tvm.accept(); 21 | timestamp = uint32(now); 22 | } 23 | //Function setting set value to state variable timestamp 24 | function touch() public alwaysAccept { 25 | timestamp = uint32(now); 26 | } 27 | //Function returns value of state variable timestamp 28 | function sayHello() public view returns (uint32) { 29 | return timestamp; 30 | } 31 | //Due to the modifier onlyOwner function sendAllMoney can be called only by the owner of the contract. 32 | //Function sendAllMoney send all contract's money to dest_addr. 33 | function sendAllMoney(address dest_addr) public onlyOwner { 34 | selfdestruct(dest_addr); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /__tests__/utils/Hello.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/__tests__/utils/Hello.tvc -------------------------------------------------------------------------------- /__tests__/utils/index.ts: -------------------------------------------------------------------------------- 1 | import * as fs from "fs"; 2 | import * as path from "path"; 3 | import {TonClient} from "@eversdk/core"; 4 | import {libNode} from "@eversdk/lib-node"; 5 | import {ContractPackage} from "../../src"; 6 | 7 | export function init() { 8 | jest.setTimeout(100000); 9 | TonClient.useBinaryLibrary(libNode); 10 | TonClient.defaultConfig = {network: {endpoints: [process.env.TON_NETWORK_ADDRESS ?? "http://localhost"]}}; 11 | } 12 | 13 | export function done() { 14 | TonClient.default.close(); 15 | } 16 | 17 | export function loadContract(name: string): ContractPackage { 18 | function load(suffix: string) { 19 | return fs.readFileSync( 20 | path.resolve(__dirname, `${name}${suffix}`), 21 | ); 22 | } 23 | 24 | return { 25 | abi: JSON.parse(load(".abi.json").toString()), 26 | tvc: load(".tvc").toString("base64"), 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | ["@babel/preset-env", { targets: { node: "current" } }], 4 | "@babel/preset-typescript", 5 | ], 6 | }; 7 | -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /docs/assets/highlight.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --light-hl-0: #008000; 3 | --dark-hl-0: #6A9955; 4 | --light-hl-1: #000000; 5 | --dark-hl-1: #D4D4D4; 6 | --light-hl-2: #0000FF; 7 | --dark-hl-2: #569CD6; 8 | --light-hl-3: #0070C1; 9 | --dark-hl-3: #4FC1FF; 10 | --light-hl-4: #795E26; 11 | --dark-hl-4: #DCDCAA; 12 | --light-hl-5: #A31515; 13 | --dark-hl-5: #CE9178; 14 | --light-hl-6: #001080; 15 | --dark-hl-6: #9CDCFE; 16 | --light-hl-7: #AF00DB; 17 | --dark-hl-7: #C586C0; 18 | --light-hl-8: #000000FF; 19 | --dark-hl-8: #D4D4D4; 20 | --light-hl-9: #098658; 21 | --dark-hl-9: #B5CEA8; 22 | --light-hl-10: #267F99; 23 | --dark-hl-10: #4EC9B0; 24 | --light-code-background: #F5F5F5; 25 | --dark-code-background: #1E1E1E; 26 | } 27 | 28 | @media (prefers-color-scheme: light) { :root { 29 | --hl-0: var(--light-hl-0); 30 | --hl-1: var(--light-hl-1); 31 | --hl-2: var(--light-hl-2); 32 | --hl-3: var(--light-hl-3); 33 | --hl-4: var(--light-hl-4); 34 | --hl-5: var(--light-hl-5); 35 | --hl-6: var(--light-hl-6); 36 | --hl-7: var(--light-hl-7); 37 | --hl-8: var(--light-hl-8); 38 | --hl-9: var(--light-hl-9); 39 | --hl-10: var(--light-hl-10); 40 | --code-background: var(--light-code-background); 41 | } } 42 | 43 | @media (prefers-color-scheme: dark) { :root { 44 | --hl-0: var(--dark-hl-0); 45 | --hl-1: var(--dark-hl-1); 46 | --hl-2: var(--dark-hl-2); 47 | --hl-3: var(--dark-hl-3); 48 | --hl-4: var(--dark-hl-4); 49 | --hl-5: var(--dark-hl-5); 50 | --hl-6: var(--dark-hl-6); 51 | --hl-7: var(--dark-hl-7); 52 | --hl-8: var(--dark-hl-8); 53 | --hl-9: var(--dark-hl-9); 54 | --hl-10: var(--dark-hl-10); 55 | --code-background: var(--dark-code-background); 56 | } } 57 | 58 | body.light { 59 | --hl-0: var(--light-hl-0); 60 | --hl-1: var(--light-hl-1); 61 | --hl-2: var(--light-hl-2); 62 | --hl-3: var(--light-hl-3); 63 | --hl-4: var(--light-hl-4); 64 | --hl-5: var(--light-hl-5); 65 | --hl-6: var(--light-hl-6); 66 | --hl-7: var(--light-hl-7); 67 | --hl-8: var(--light-hl-8); 68 | --hl-9: var(--light-hl-9); 69 | --hl-10: var(--light-hl-10); 70 | --code-background: var(--light-code-background); 71 | } 72 | 73 | body.dark { 74 | --hl-0: var(--dark-hl-0); 75 | --hl-1: var(--dark-hl-1); 76 | --hl-2: var(--dark-hl-2); 77 | --hl-3: var(--dark-hl-3); 78 | --hl-4: var(--dark-hl-4); 79 | --hl-5: var(--dark-hl-5); 80 | --hl-6: var(--dark-hl-6); 81 | --hl-7: var(--dark-hl-7); 82 | --hl-8: var(--dark-hl-8); 83 | --hl-9: var(--dark-hl-9); 84 | --hl-10: var(--dark-hl-10); 85 | --code-background: var(--dark-code-background); 86 | } 87 | 88 | .hl-0 { color: var(--hl-0); } 89 | .hl-1 { color: var(--hl-1); } 90 | .hl-2 { color: var(--hl-2); } 91 | .hl-3 { color: var(--hl-3); } 92 | .hl-4 { color: var(--hl-4); } 93 | .hl-5 { color: var(--hl-5); } 94 | .hl-6 { color: var(--hl-6); } 95 | .hl-7 { color: var(--hl-7); } 96 | .hl-8 { color: var(--hl-8); } 97 | .hl-9 { color: var(--hl-9); } 98 | .hl-10 { color: var(--hl-10); } 99 | pre, code { background: var(--code-background); } 100 | -------------------------------------------------------------------------------- /docs/assets/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/docs/assets/icons.png -------------------------------------------------------------------------------- /docs/assets/icons@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/docs/assets/icons@2x.png -------------------------------------------------------------------------------- /docs/assets/search.js: -------------------------------------------------------------------------------- 1 | window.searchData = JSON.parse("{\"kinds\":{\"8\":\"Enumeration\",\"16\":\"Enumeration member\",\"32\":\"Variable\",\"128\":\"Class\",\"256\":\"Interface\",\"512\":\"Constructor\",\"1024\":\"Property\",\"2048\":\"Method\",\"65536\":\"Type literal\",\"4194304\":\"Type alias\"},\"rows\":[{\"id\":0,\"kind\":4194304,\"name\":\"AccountOptions\",\"url\":\"modules.html#AccountOptions\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":1,\"kind\":65536,\"name\":\"__type\",\"url\":\"modules.html#AccountOptions.__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"AccountOptions\"},{\"id\":2,\"kind\":1024,\"name\":\"initData\",\"url\":\"modules.html#AccountOptions.__type.initData\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountOptions.__type\"},{\"id\":3,\"kind\":1024,\"name\":\"signer\",\"url\":\"modules.html#AccountOptions.__type.signer\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountOptions.__type\"},{\"id\":4,\"kind\":1024,\"name\":\"address\",\"url\":\"modules.html#AccountOptions.__type.address\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountOptions.__type\"},{\"id\":5,\"kind\":1024,\"name\":\"client\",\"url\":\"modules.html#AccountOptions.__type.client\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountOptions.__type\"},{\"id\":6,\"kind\":1024,\"name\":\"useCachedState\",\"url\":\"modules.html#AccountOptions.__type.useCachedState\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountOptions.__type\"},{\"id\":7,\"kind\":4194304,\"name\":\"AccountRunOptions\",\"url\":\"modules.html#AccountRunOptions\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":8,\"kind\":65536,\"name\":\"__type\",\"url\":\"modules.html#AccountRunOptions.__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"AccountRunOptions\"},{\"id\":9,\"kind\":1024,\"name\":\"signer\",\"url\":\"modules.html#AccountRunOptions.__type.signer\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountRunOptions.__type\"},{\"id\":10,\"kind\":4194304,\"name\":\"AccountRunLocalOptions\",\"url\":\"modules.html#AccountRunLocalOptions\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":11,\"kind\":65536,\"name\":\"__type\",\"url\":\"modules.html#AccountRunLocalOptions.__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"AccountRunLocalOptions\"},{\"id\":12,\"kind\":1024,\"name\":\"performAllChecks\",\"url\":\"modules.html#AccountRunLocalOptions.__type.performAllChecks\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountRunLocalOptions.__type\"},{\"id\":13,\"kind\":256,\"name\":\"AccountGiver\",\"url\":\"interfaces/AccountGiver.html\",\"classes\":\"tsd-kind-interface\"},{\"id\":14,\"kind\":1024,\"name\":\"address\",\"url\":\"interfaces/AccountGiver.html#address\",\"classes\":\"tsd-kind-property tsd-parent-kind-interface\",\"parent\":\"AccountGiver\"},{\"id\":15,\"kind\":2048,\"name\":\"sendTo\",\"url\":\"interfaces/AccountGiver.html#sendTo\",\"classes\":\"tsd-kind-method tsd-parent-kind-interface\",\"parent\":\"AccountGiver\"},{\"id\":16,\"kind\":4194304,\"name\":\"AccountDeployOptions\",\"url\":\"modules.html#AccountDeployOptions\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":17,\"kind\":65536,\"name\":\"__type\",\"url\":\"modules.html#AccountDeployOptions.__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"AccountDeployOptions\"},{\"id\":18,\"kind\":1024,\"name\":\"initFunctionName\",\"url\":\"modules.html#AccountDeployOptions.__type.initFunctionName\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountDeployOptions.__type\"},{\"id\":19,\"kind\":1024,\"name\":\"initInput\",\"url\":\"modules.html#AccountDeployOptions.__type.initInput\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountDeployOptions.__type\"},{\"id\":20,\"kind\":1024,\"name\":\"useGiver\",\"url\":\"modules.html#AccountDeployOptions.__type.useGiver\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountDeployOptions.__type\"},{\"id\":21,\"kind\":4194304,\"name\":\"ContractPackage\",\"url\":\"modules.html#ContractPackage\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":22,\"kind\":65536,\"name\":\"__type\",\"url\":\"modules.html#ContractPackage.__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"ContractPackage\"},{\"id\":23,\"kind\":1024,\"name\":\"abi\",\"url\":\"modules.html#ContractPackage.__type.abi\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"ContractPackage.__type\"},{\"id\":24,\"kind\":1024,\"name\":\"tvc\",\"url\":\"modules.html#ContractPackage.__type.tvc\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"ContractPackage.__type\"},{\"id\":25,\"kind\":128,\"name\":\"AccountError\",\"url\":\"classes/AccountError.html\",\"classes\":\"tsd-kind-class\"},{\"id\":26,\"kind\":2048,\"name\":\"missingTVC\",\"url\":\"classes/AccountError.html#missingTVC\",\"classes\":\"tsd-kind-method tsd-parent-kind-class tsd-is-static\",\"parent\":\"AccountError\"},{\"id\":27,\"kind\":512,\"name\":\"constructor\",\"url\":\"classes/AccountError.html#constructor\",\"classes\":\"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited\",\"parent\":\"AccountError\"},{\"id\":28,\"kind\":8,\"name\":\"AccountType\",\"url\":\"enums/AccountType.html\",\"classes\":\"tsd-kind-enum\"},{\"id\":29,\"kind\":16,\"name\":\"uninit\",\"url\":\"enums/AccountType.html#uninit\",\"classes\":\"tsd-kind-enum-member tsd-parent-kind-enum\",\"parent\":\"AccountType\"},{\"id\":30,\"kind\":16,\"name\":\"active\",\"url\":\"enums/AccountType.html#active\",\"classes\":\"tsd-kind-enum-member tsd-parent-kind-enum\",\"parent\":\"AccountType\"},{\"id\":31,\"kind\":16,\"name\":\"frozen\",\"url\":\"enums/AccountType.html#frozen\",\"classes\":\"tsd-kind-enum-member tsd-parent-kind-enum\",\"parent\":\"AccountType\"},{\"id\":32,\"kind\":16,\"name\":\"nonExist\",\"url\":\"enums/AccountType.html#nonExist\",\"classes\":\"tsd-kind-enum-member tsd-parent-kind-enum\",\"parent\":\"AccountType\"},{\"id\":33,\"kind\":128,\"name\":\"Account\",\"url\":\"classes/Account.html\",\"classes\":\"tsd-kind-class\"},{\"id\":34,\"kind\":1024,\"name\":\"giversByClient\",\"url\":\"classes/Account.html#giversByClient\",\"classes\":\"tsd-kind-property tsd-parent-kind-class tsd-is-private tsd-is-static\",\"parent\":\"Account\"},{\"id\":35,\"kind\":2048,\"name\":\"findGiverForClient\",\"url\":\"classes/Account.html#findGiverForClient\",\"classes\":\"tsd-kind-method tsd-parent-kind-class tsd-is-static\",\"parent\":\"Account\"},{\"id\":36,\"kind\":2048,\"name\":\"setGiverForClient\",\"url\":\"classes/Account.html#setGiverForClient\",\"classes\":\"tsd-kind-method tsd-parent-kind-class tsd-is-static\",\"parent\":\"Account\"},{\"id\":37,\"kind\":2048,\"name\":\"createGiver\",\"url\":\"classes/Account.html#createGiver\",\"classes\":\"tsd-kind-method tsd-parent-kind-class tsd-is-private tsd-is-static\",\"parent\":\"Account\"},{\"id\":38,\"kind\":2048,\"name\":\"getGiverForClient\",\"url\":\"classes/Account.html#getGiverForClient\",\"classes\":\"tsd-kind-method tsd-parent-kind-class tsd-is-static\",\"parent\":\"Account\"},{\"id\":39,\"kind\":512,\"name\":\"constructor\",\"url\":\"classes/Account.html#constructor\",\"classes\":\"tsd-kind-constructor tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":40,\"kind\":1024,\"name\":\"contract\",\"url\":\"classes/Account.html#contract\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":41,\"kind\":1024,\"name\":\"client\",\"url\":\"classes/Account.html#client\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":42,\"kind\":1024,\"name\":\"abi\",\"url\":\"classes/Account.html#abi\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":43,\"kind\":1024,\"name\":\"signer\",\"url\":\"classes/Account.html#signer\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":44,\"kind\":1024,\"name\":\"initData\",\"url\":\"classes/Account.html#initData\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":45,\"kind\":1024,\"name\":\"useCachedState\",\"url\":\"classes/Account.html#useCachedState\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":46,\"kind\":1024,\"name\":\"address\",\"url\":\"classes/Account.html#address\",\"classes\":\"tsd-kind-property tsd-parent-kind-class tsd-is-private\",\"parent\":\"Account\"},{\"id\":47,\"kind\":1024,\"name\":\"syncLastTransLt\",\"url\":\"classes/Account.html#syncLastTransLt\",\"classes\":\"tsd-kind-property tsd-parent-kind-class tsd-is-private\",\"parent\":\"Account\"},{\"id\":48,\"kind\":1024,\"name\":\"cachedBoc\",\"url\":\"classes/Account.html#cachedBoc\",\"classes\":\"tsd-kind-property tsd-parent-kind-class tsd-is-private\",\"parent\":\"Account\"},{\"id\":49,\"kind\":1024,\"name\":\"subscriptions\",\"url\":\"classes/Account.html#subscriptions\",\"classes\":\"tsd-kind-property tsd-parent-kind-class tsd-is-private\",\"parent\":\"Account\"},{\"id\":50,\"kind\":2048,\"name\":\"getAddress\",\"url\":\"classes/Account.html#getAddress\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":51,\"kind\":2048,\"name\":\"getParamsOfDeployMessage\",\"url\":\"classes/Account.html#getParamsOfDeployMessage\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":52,\"kind\":2048,\"name\":\"calcDeployFees\",\"url\":\"classes/Account.html#calcDeployFees\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":53,\"kind\":2048,\"name\":\"deploy\",\"url\":\"classes/Account.html#deploy\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":54,\"kind\":2048,\"name\":\"deployLocal\",\"url\":\"classes/Account.html#deployLocal\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":55,\"kind\":2048,\"name\":\"calcRunFees\",\"url\":\"classes/Account.html#calcRunFees\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":56,\"kind\":2048,\"name\":\"run\",\"url\":\"classes/Account.html#run\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":57,\"kind\":2048,\"name\":\"runLocal\",\"url\":\"classes/Account.html#runLocal\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":58,\"kind\":2048,\"name\":\"needSyncWithTransaction\",\"url\":\"classes/Account.html#needSyncWithTransaction\",\"classes\":\"tsd-kind-method tsd-parent-kind-class tsd-is-private\",\"parent\":\"Account\"},{\"id\":59,\"kind\":2048,\"name\":\"boc\",\"url\":\"classes/Account.html#boc\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":60,\"kind\":2048,\"name\":\"refresh\",\"url\":\"classes/Account.html#refresh\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":61,\"kind\":2048,\"name\":\"getAccount\",\"url\":\"classes/Account.html#getAccount\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":62,\"kind\":2048,\"name\":\"subscribeAccount\",\"url\":\"classes/Account.html#subscribeAccount\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":63,\"kind\":2048,\"name\":\"subscribeTransactions\",\"url\":\"classes/Account.html#subscribeTransactions\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":64,\"kind\":2048,\"name\":\"subscribeMessages\",\"url\":\"classes/Account.html#subscribeMessages\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":65,\"kind\":2048,\"name\":\"decodeMessage\",\"url\":\"classes/Account.html#decodeMessage\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":66,\"kind\":2048,\"name\":\"decodeMessageBody\",\"url\":\"classes/Account.html#decodeMessageBody\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":67,\"kind\":2048,\"name\":\"getBalance\",\"url\":\"classes/Account.html#getBalance\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":68,\"kind\":2048,\"name\":\"subscribe\",\"url\":\"classes/Account.html#subscribe\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":69,\"kind\":2048,\"name\":\"free\",\"url\":\"classes/Account.html#free\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":70,\"kind\":32,\"name\":\"DefaultGiverContract\",\"url\":\"modules.html#DefaultGiverContract\",\"classes\":\"tsd-kind-variable\"}],\"index\":{\"version\":\"2.3.9\",\"fields\":[\"name\",\"parent\"],\"fieldVectors\":[[\"name/0\",[0,33.604]],[\"parent/0\",[]],[\"name/1\",[1,25.719]],[\"parent/1\",[0,3.149]],[\"name/2\",[2,33.604]],[\"parent/2\",[3,2.41]],[\"name/3\",[4,30.239]],[\"parent/3\",[3,2.41]],[\"name/4\",[5,30.239]],[\"parent/4\",[3,2.41]],[\"name/5\",[6,33.604]],[\"parent/5\",[3,2.41]],[\"name/6\",[7,33.604]],[\"parent/6\",[3,2.41]],[\"name/7\",[8,33.604]],[\"parent/7\",[]],[\"name/8\",[1,25.719]],[\"parent/8\",[8,3.149]],[\"name/9\",[4,30.239]],[\"parent/9\",[9,3.628]],[\"name/10\",[10,33.604]],[\"parent/10\",[]],[\"name/11\",[1,25.719]],[\"parent/11\",[10,3.149]],[\"name/12\",[11,38.712]],[\"parent/12\",[12,3.628]],[\"name/13\",[13,30.239]],[\"parent/13\",[]],[\"name/14\",[5,30.239]],[\"parent/14\",[13,2.834]],[\"name/15\",[14,38.712]],[\"parent/15\",[13,2.834]],[\"name/16\",[15,33.604]],[\"parent/16\",[]],[\"name/17\",[1,25.719]],[\"parent/17\",[15,3.149]],[\"name/18\",[16,38.712]],[\"parent/18\",[17,2.834]],[\"name/19\",[18,38.712]],[\"parent/19\",[17,2.834]],[\"name/20\",[19,38.712]],[\"parent/20\",[17,2.834]],[\"name/21\",[20,33.604]],[\"parent/21\",[]],[\"name/22\",[1,25.719]],[\"parent/22\",[20,3.149]],[\"name/23\",[21,33.604]],[\"parent/23\",[22,3.149]],[\"name/24\",[23,38.712]],[\"parent/24\",[22,3.149]],[\"name/25\",[24,30.239]],[\"parent/25\",[]],[\"name/26\",[25,38.712]],[\"parent/26\",[24,2.834]],[\"name/27\",[26,33.604]],[\"parent/27\",[24,2.834]],[\"name/28\",[27,25.719]],[\"parent/28\",[]],[\"name/29\",[28,38.712]],[\"parent/29\",[27,2.41]],[\"name/30\",[29,38.712]],[\"parent/30\",[27,2.41]],[\"name/31\",[30,38.712]],[\"parent/31\",[27,2.41]],[\"name/32\",[31,38.712]],[\"parent/32\",[27,2.41]],[\"name/33\",[32,6.523]],[\"parent/33\",[]],[\"name/34\",[33,38.712]],[\"parent/34\",[32,0.611]],[\"name/35\",[34,38.712]],[\"parent/35\",[32,0.611]],[\"name/36\",[35,38.712]],[\"parent/36\",[32,0.611]],[\"name/37\",[36,38.712]],[\"parent/37\",[32,0.611]],[\"name/38\",[37,38.712]],[\"parent/38\",[32,0.611]],[\"name/39\",[26,33.604]],[\"parent/39\",[32,0.611]],[\"name/40\",[38,38.712]],[\"parent/40\",[32,0.611]],[\"name/41\",[6,33.604]],[\"parent/41\",[32,0.611]],[\"name/42\",[21,33.604]],[\"parent/42\",[32,0.611]],[\"name/43\",[4,30.239]],[\"parent/43\",[32,0.611]],[\"name/44\",[2,33.604]],[\"parent/44\",[32,0.611]],[\"name/45\",[7,33.604]],[\"parent/45\",[32,0.611]],[\"name/46\",[5,30.239]],[\"parent/46\",[32,0.611]],[\"name/47\",[39,38.712]],[\"parent/47\",[32,0.611]],[\"name/48\",[40,38.712]],[\"parent/48\",[32,0.611]],[\"name/49\",[41,38.712]],[\"parent/49\",[32,0.611]],[\"name/50\",[42,38.712]],[\"parent/50\",[32,0.611]],[\"name/51\",[43,38.712]],[\"parent/51\",[32,0.611]],[\"name/52\",[44,38.712]],[\"parent/52\",[32,0.611]],[\"name/53\",[45,38.712]],[\"parent/53\",[32,0.611]],[\"name/54\",[46,38.712]],[\"parent/54\",[32,0.611]],[\"name/55\",[47,38.712]],[\"parent/55\",[32,0.611]],[\"name/56\",[48,38.712]],[\"parent/56\",[32,0.611]],[\"name/57\",[49,38.712]],[\"parent/57\",[32,0.611]],[\"name/58\",[50,38.712]],[\"parent/58\",[32,0.611]],[\"name/59\",[51,38.712]],[\"parent/59\",[32,0.611]],[\"name/60\",[52,38.712]],[\"parent/60\",[32,0.611]],[\"name/61\",[53,38.712]],[\"parent/61\",[32,0.611]],[\"name/62\",[54,38.712]],[\"parent/62\",[32,0.611]],[\"name/63\",[55,38.712]],[\"parent/63\",[32,0.611]],[\"name/64\",[56,38.712]],[\"parent/64\",[32,0.611]],[\"name/65\",[57,38.712]],[\"parent/65\",[32,0.611]],[\"name/66\",[58,38.712]],[\"parent/66\",[32,0.611]],[\"name/67\",[59,38.712]],[\"parent/67\",[32,0.611]],[\"name/68\",[60,38.712]],[\"parent/68\",[32,0.611]],[\"name/69\",[61,38.712]],[\"parent/69\",[32,0.611]],[\"name/70\",[62,38.712]],[\"parent/70\",[]]],\"invertedIndex\":[[\"__type\",{\"_index\":1,\"name\":{\"1\":{},\"8\":{},\"11\":{},\"17\":{},\"22\":{}},\"parent\":{}}],[\"abi\",{\"_index\":21,\"name\":{\"23\":{},\"42\":{}},\"parent\":{}}],[\"account\",{\"_index\":32,\"name\":{\"33\":{}},\"parent\":{\"34\":{},\"35\":{},\"36\":{},\"37\":{},\"38\":{},\"39\":{},\"40\":{},\"41\":{},\"42\":{},\"43\":{},\"44\":{},\"45\":{},\"46\":{},\"47\":{},\"48\":{},\"49\":{},\"50\":{},\"51\":{},\"52\":{},\"53\":{},\"54\":{},\"55\":{},\"56\":{},\"57\":{},\"58\":{},\"59\":{},\"60\":{},\"61\":{},\"62\":{},\"63\":{},\"64\":{},\"65\":{},\"66\":{},\"67\":{},\"68\":{},\"69\":{}}}],[\"accountdeployoptions\",{\"_index\":15,\"name\":{\"16\":{}},\"parent\":{\"17\":{}}}],[\"accountdeployoptions.__type\",{\"_index\":17,\"name\":{},\"parent\":{\"18\":{},\"19\":{},\"20\":{}}}],[\"accounterror\",{\"_index\":24,\"name\":{\"25\":{}},\"parent\":{\"26\":{},\"27\":{}}}],[\"accountgiver\",{\"_index\":13,\"name\":{\"13\":{}},\"parent\":{\"14\":{},\"15\":{}}}],[\"accountoptions\",{\"_index\":0,\"name\":{\"0\":{}},\"parent\":{\"1\":{}}}],[\"accountoptions.__type\",{\"_index\":3,\"name\":{},\"parent\":{\"2\":{},\"3\":{},\"4\":{},\"5\":{},\"6\":{}}}],[\"accountrunlocaloptions\",{\"_index\":10,\"name\":{\"10\":{}},\"parent\":{\"11\":{}}}],[\"accountrunlocaloptions.__type\",{\"_index\":12,\"name\":{},\"parent\":{\"12\":{}}}],[\"accountrunoptions\",{\"_index\":8,\"name\":{\"7\":{}},\"parent\":{\"8\":{}}}],[\"accountrunoptions.__type\",{\"_index\":9,\"name\":{},\"parent\":{\"9\":{}}}],[\"accounttype\",{\"_index\":27,\"name\":{\"28\":{}},\"parent\":{\"29\":{},\"30\":{},\"31\":{},\"32\":{}}}],[\"active\",{\"_index\":29,\"name\":{\"30\":{}},\"parent\":{}}],[\"address\",{\"_index\":5,\"name\":{\"4\":{},\"14\":{},\"46\":{}},\"parent\":{}}],[\"boc\",{\"_index\":51,\"name\":{\"59\":{}},\"parent\":{}}],[\"cachedboc\",{\"_index\":40,\"name\":{\"48\":{}},\"parent\":{}}],[\"calcdeployfees\",{\"_index\":44,\"name\":{\"52\":{}},\"parent\":{}}],[\"calcrunfees\",{\"_index\":47,\"name\":{\"55\":{}},\"parent\":{}}],[\"client\",{\"_index\":6,\"name\":{\"5\":{},\"41\":{}},\"parent\":{}}],[\"constructor\",{\"_index\":26,\"name\":{\"27\":{},\"39\":{}},\"parent\":{}}],[\"contract\",{\"_index\":38,\"name\":{\"40\":{}},\"parent\":{}}],[\"contractpackage\",{\"_index\":20,\"name\":{\"21\":{}},\"parent\":{\"22\":{}}}],[\"contractpackage.__type\",{\"_index\":22,\"name\":{},\"parent\":{\"23\":{},\"24\":{}}}],[\"creategiver\",{\"_index\":36,\"name\":{\"37\":{}},\"parent\":{}}],[\"decodemessage\",{\"_index\":57,\"name\":{\"65\":{}},\"parent\":{}}],[\"decodemessagebody\",{\"_index\":58,\"name\":{\"66\":{}},\"parent\":{}}],[\"defaultgivercontract\",{\"_index\":62,\"name\":{\"70\":{}},\"parent\":{}}],[\"deploy\",{\"_index\":45,\"name\":{\"53\":{}},\"parent\":{}}],[\"deploylocal\",{\"_index\":46,\"name\":{\"54\":{}},\"parent\":{}}],[\"findgiverforclient\",{\"_index\":34,\"name\":{\"35\":{}},\"parent\":{}}],[\"free\",{\"_index\":61,\"name\":{\"69\":{}},\"parent\":{}}],[\"frozen\",{\"_index\":30,\"name\":{\"31\":{}},\"parent\":{}}],[\"getaccount\",{\"_index\":53,\"name\":{\"61\":{}},\"parent\":{}}],[\"getaddress\",{\"_index\":42,\"name\":{\"50\":{}},\"parent\":{}}],[\"getbalance\",{\"_index\":59,\"name\":{\"67\":{}},\"parent\":{}}],[\"getgiverforclient\",{\"_index\":37,\"name\":{\"38\":{}},\"parent\":{}}],[\"getparamsofdeploymessage\",{\"_index\":43,\"name\":{\"51\":{}},\"parent\":{}}],[\"giversbyclient\",{\"_index\":33,\"name\":{\"34\":{}},\"parent\":{}}],[\"initdata\",{\"_index\":2,\"name\":{\"2\":{},\"44\":{}},\"parent\":{}}],[\"initfunctionname\",{\"_index\":16,\"name\":{\"18\":{}},\"parent\":{}}],[\"initinput\",{\"_index\":18,\"name\":{\"19\":{}},\"parent\":{}}],[\"missingtvc\",{\"_index\":25,\"name\":{\"26\":{}},\"parent\":{}}],[\"needsyncwithtransaction\",{\"_index\":50,\"name\":{\"58\":{}},\"parent\":{}}],[\"nonexist\",{\"_index\":31,\"name\":{\"32\":{}},\"parent\":{}}],[\"performallchecks\",{\"_index\":11,\"name\":{\"12\":{}},\"parent\":{}}],[\"refresh\",{\"_index\":52,\"name\":{\"60\":{}},\"parent\":{}}],[\"run\",{\"_index\":48,\"name\":{\"56\":{}},\"parent\":{}}],[\"runlocal\",{\"_index\":49,\"name\":{\"57\":{}},\"parent\":{}}],[\"sendto\",{\"_index\":14,\"name\":{\"15\":{}},\"parent\":{}}],[\"setgiverforclient\",{\"_index\":35,\"name\":{\"36\":{}},\"parent\":{}}],[\"signer\",{\"_index\":4,\"name\":{\"3\":{},\"9\":{},\"43\":{}},\"parent\":{}}],[\"subscribe\",{\"_index\":60,\"name\":{\"68\":{}},\"parent\":{}}],[\"subscribeaccount\",{\"_index\":54,\"name\":{\"62\":{}},\"parent\":{}}],[\"subscribemessages\",{\"_index\":56,\"name\":{\"64\":{}},\"parent\":{}}],[\"subscribetransactions\",{\"_index\":55,\"name\":{\"63\":{}},\"parent\":{}}],[\"subscriptions\",{\"_index\":41,\"name\":{\"49\":{}},\"parent\":{}}],[\"synclasttranslt\",{\"_index\":39,\"name\":{\"47\":{}},\"parent\":{}}],[\"tvc\",{\"_index\":23,\"name\":{\"24\":{}},\"parent\":{}}],[\"uninit\",{\"_index\":28,\"name\":{\"29\":{}},\"parent\":{}}],[\"usecachedstate\",{\"_index\":7,\"name\":{\"6\":{},\"45\":{}},\"parent\":{}}],[\"usegiver\",{\"_index\":19,\"name\":{\"20\":{}},\"parent\":{}}]],\"pipeline\":[]}}"); -------------------------------------------------------------------------------- /docs/assets/widgets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/docs/assets/widgets.png -------------------------------------------------------------------------------- /docs/assets/widgets@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/docs/assets/widgets@2x.png -------------------------------------------------------------------------------- /docs/classes/AccountError.html: -------------------------------------------------------------------------------- 1 | AccountError | @eversdk/appkit
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AccountError

Hierarchy

  • Error
    • AccountError

Index

Constructors

Properties

Methods

Constructors

  • Parameters

    • Optional message: string

    Returns AccountError

Properties

message: string
name: string
stack?: string

Methods

Generated using TypeDoc

-------------------------------------------------------------------------------- /docs/enums/AccountType.html: -------------------------------------------------------------------------------- 1 | AccountType | @eversdk/appkit
Options
All
  • Public
  • Public/Protected
  • All
Menu

Enumeration AccountType

2 |

Current type of the account.

3 |

Index

Enumeration members

Enumeration members

active = 1
4 |

Account exists in the blockchain with smart contract.

5 |
frozen = 2
6 |

Account exists in the blockchain but it had frozen.

7 |
nonExist = 3
8 |

Account is missing in the blockchain.

9 |
uninit = 0
10 |

Account exists in the blockchain but without smart contract.

11 |

Generated using TypeDoc

-------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | @eversdk/appkit
Options
All
  • Public
  • Public/Protected
  • All
Menu

@eversdk/appkit

2 | 3 |

Free TON JS Application Kit

4 |
5 |

This library is a part of Free TON SDK for JavaScript.

6 |

AppKit is built over the @eversdk/core package and purposed to simplify writing applications on Free TON.

7 |

Full API reference: https://tonlabs.github.io/appkit-js/

8 |

If this package helped you, please give it a star:)

9 |

Have a question? Get quick help in our channel:

10 |

Chat on Telegram

11 | 12 | 13 |

Table of Contents

14 |
15 | 35 | 36 | 37 |

Useful links

38 |
39 |
    40 |
  • Full API reference
  • 41 |
  • Appkit samples
  • 42 |
  • SDK guides - to get a deeper understanding dive into our sdk guides where you can find extensive explanations and descriptions of each step of DApp development on Free TON.
  • 43 |
44 | 45 | 46 |

Before You Start

47 |
48 |

We strongly recommend installing TONDEV utility before you start playing with TON AppKit. This utility will help you manage your tools for Free TON development.

49 | 50 | 51 |

Installation

52 |
53 |
# Install core package
npm i --save @eversdk/core

# Install lib-node bridge if you write node js application
npm i --save @eversdk/lib-node

# Or install lib-web bridge if you write web/browser application
npm i --save @eversdk/lib-web

# Or install lib-react-native if you write react-native mobile application
npm i --save @eversdk/lib-react-native

# And finally install appkit itself
npm i --save @eversdk/appkit 54 |
55 | 56 | 57 |

Setup Client Library

58 |
59 |

You must initialize the core library before the first use. The best place to do it is in the initialization code of your application.

60 | 61 | 62 |

NodeJs:

63 |
64 |
const { TonClient } = require("@eversdk/core");
const { libNode } = require("@eversdk/lib-node");

// Application initialization

TonClient.useBinaryLibrary(libNode) 65 |
66 | 67 | 68 |

Web:

69 |
70 |
import { TonClient } from "@eversdk/core";
import { libWeb } from "@eversdk/lib-web";

// Application initialization

TonClient.useBinaryLibrary(libWeb); 71 |
72 |

By default, the library loads wasm module from relative URL /tonclient.wasm.

73 |

You can specify alternative URL if you want to place (or rename) wasm module.

74 |
import { TonClient } from "@eversdk/core";
import { libWeb, libWebSetup } from "@eversdk/lib-web";

// Application initialization.

// You have to setup libWeb if the `tonclient.wasm`
// isn't located at root of your web site.
// Otherwise you havn't to call `libWebSetup`.
libWebSetup({
binaryURL: "/assets/tonclient_1_2_3.wasm",
});

TonClient.useBinaryLibrary(libWeb); 75 |
76 | 77 | 78 |

React Native:

79 |
80 |
import { TonClient } from "@eversdk/core";
import { libReactNative } from "@eversdk/lib-react-native";

// Application initialization

TonClient.useBinaryLibrary(libReactNative); 81 |
82 | 83 | 84 |

Create Client Instance

85 |
86 |

TON AppKit is built over core JS library. So you have to create an instance of TonClient to use it later with TON AppKit objects.

87 |
const client = new TonClient({
network: { endpoints: ["http://localhost"] }
}); 88 |
89 |

In this sample we create a client instance configured to use local blockchain TON OS SE instance.

90 |

If you want to work with Developer Network or Free TON network, please use the list of endpoints, listed here. Attention You must specify all the endpoints as an array in endpoints parameter, because each endpoint does not guarantee its availability, but we guarantee that at least one endpoint is operational at the moment.

91 | 92 | 93 |

A Few Words about the Code

94 |
95 |

Below we use a code snippets to illustrate AppKit usage.
In this code we omit an initialization part because it is the same.
We suppose that we are using lib-node bridge (NodeJs) to write examples. Also, we use the library to deal with local TON OS SE instance.

96 |

So the full code of each example can look like this:

97 |
const { TonClient } = require("@eversdk/core");
const { libNode } = require("@eversdk/lib-node");
const { Account } = require("@eversdk/appkit");

TonClient.useBinaryLibrary(libNode);

(async () => {
const endpoint = process.env.TON_NETWORK_ADDRESS || "http://localhost";
const client = new TonClient({ network: { endpoints: [endpoint] } });
try {
await main(client);
} catch (err) {
console.error(err);
} finally {
client.close();
}
})();

async function main(client) {
// Snippet code is here
} 98 |
99 | 100 | 101 |

Use Account Object

102 |
103 |

At the moment the key point of AppKit is an Account object (class). Application uses an Account instance to deal with specific blockchain account using specific owner ( signer in terms of TonClient library).

104 |

Each Account instance must use an ABI compliant contract. So we have to define the Contract object with an ABI and optionally tvc fields. This object must be provided to the Account constructor.

105 |

In the example below we use predefined giver already included in AppKit and predeployed in TONOS SE.

106 |
// Define Contract object.
const AccContract = {
abi: { /* ABI declarations */ },
tvc: "... base64 encoded string ...",
};

// Generate new keys pair for new account.
const keys = await client.crypto.generate_random_sign_keys();

// Create owner (signer) instance for new account.
const signer = signerKeys(keys);

// Construct Account instance.
//
// Note that this account is not deployed in the blockchain yet.
// We just create an object to deal with this account.
const acc = new Account(AccContract, { signer, client });

// We can determine the future addres of the account
// and print it to the user before deploying.
console.log(`New account future address: ${await acc.getAddress()}`);

// Deploy account to the blockchain.
// Here we use TONOS SE giver to create a positive balance
// before deploying.
await acc.deploy({ useGiver: true });

// Send external inbound message to our new account
// and receives result from external outboud message.
const response = await acc.run("someFunction", { someParam: 1 });

// Print decoded response message
console.log("Account has responded to someFunction with", response.decoded.output);

// Print current balance.
// Note that balance returned as a string in decimal representation.
// This is because of a value measure is a nano.
// So its value may not be representable using JS Number.
console.log("Account balance now is", await acc.getBalance()); 107 |
108 |

In the example above we demonstrated typical basic usage of the Account object.

109 | 110 | 111 |

Sample source code

112 |
113 |

Find the sample that demonstrates AppKit usage source code here https://github.com/tonlabs/sdk-samples/tree/master/demo/hello-wallet

114 | 115 | 116 |

Subscribe for Changes

117 |
118 |

Sometimes it is required to listen for events related to an account in realtime.

119 |

It is easy: just call one of the subscribe methods of an account instance.

120 |

For example, if we need to track all changes in the account state on the blockchain we can use subscribeAccount:

121 |
const hello = new Account(Hello, { signer });
await hello.deploy();

await hello.subscribeAccount("balance", (acc) => {
// This callback triggers every time the account data
// is changed on the blockchain
console.log("Account has updated. Current balance is ", parseInt(acc.balance));
});

await hello.subscribeMessages("boc", async (msg) => {
// This callback triggers every time the message related to this account
// is appeared on the blockchain.
// Releated messages include inbound and outbound messages.
console.log("Message is appeared ", msg);
});

// ...... do something with hello account ...........

// In addition to other cleanup stuff the `free` method
// unsubscribes all active subscriptions for this account instance.
await hello.free(); 122 |
123 | 124 | 125 |

Executing Contract on TVM

126 |
127 |

There are some situations where running the contract on the blockchain is not acceptable:

128 |
    129 |
  • Writing a tests for developing contract.
  • 130 |
  • Emulating execution for an existing account to detect failure reason or to calculate estimated fees.
  • 131 |
  • Getting information from an existing account by running its get methods.
  • 132 |
133 |

In these cases we can play with an account on the TVM included in TON SDK client library:

134 |
const hello = new Account(Hello, { signer });

// We don't deploy contract on real network.
// We just emulate it. After this call the hello instance
// will have an account boc that can be used in consequent
// calls.
await hello.deployLocal();

// We execute contract locally.
// But exactly the same way as it executes on the real blockchain.
const result = await hello.runLocal("touch", {});
console.log('Touch output', result); 135 |
136 |

We can call get method on accounts in the blockchain:

137 |
const acc = new Account(MyAccount, { address: someAddress });

// Contracts code and data will be downloaded from the blockchain
// and used to execute on the local TVM.
// Without any fees.
const lastBid = (await acc.runLocal("getLastBid", {})).decoded.output.lastBid;
console.log('Last bid is', lastBid);

// As laways we need to cleanup resources associated with insdtance.
await acc.free(); 138 |
139 |

There are some situations where running the contract on the blockchain is not acceptable:

140 |
    141 |
  • Writing a tests for developing contract.
  • 142 |
  • Emulating execution for an existing account to detect failure reason or to calculate estimated fees.
  • 143 |
  • Getting information from an existing account by running its get methods.
  • 144 |
145 |

In these cases we can play with an account on the TVM included in TON SDK client library:

146 |
const hello = new Account(Hello, { signer });

// We don't deploy contract on real network.
// We just emulate it. After this call the hello instance
// will have an account boc that can be used in consequent
// calls.
await hello.deployLocal();

// We execute contract locally.
// But exactly the same way as it executes on the real blockchain.
const result = await hello.runLocal("touch", {});
console.log('Touch output', result); 147 |
148 |

We can call get method on accounts in the blockchain:

149 |
const acc = new Account(MyAccount, { address: someAddress });

// Contracts code and data will be downloaded from the blockchain
// and used to execute on the local TVM.
// Without any fees.
const lastBid = (await acc.runLocal("getLastBid", {})).decoded.output.lastBid;
console.log('Last bid is', lastBid);

// As laways we need to cleanup resources associated with insdtance.
await acc.free(); 150 |
151 | 152 | 153 |

Interacting with Core SDK

154 |
155 |

AppKit is a convenient library built over the TON-SDK core library. Of course the AppKit doesn't cover a lot of tasks the core SDK do.

156 |

So you have to easily interact with low level SDK functions. It is really easy.

157 |

Each Account instance has a reference to the TON SDK client instance. So you can use this reference.

158 |
async function test(wallet: Account) {
const rnd = (await wallet.client.crypto.generate_random_bytes({
length: 100
})).bytes;
} 159 |
160 |

Each account instance has an abi field with ABI this account belongs to.

161 |
async function test(wallet: Account) {
const decoded = (await wallet.client.abi.decode_message_body({
abi: wallet.abi,
body: someMessageBody,
is_internal: false,
})).value;
} 162 |
163 |

Generated using TypeDoc

-------------------------------------------------------------------------------- /docs/interfaces/AccountGiver.html: -------------------------------------------------------------------------------- 1 | AccountGiver | @eversdk/appkit
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface AccountGiver

2 |

Object that can be used to send some value before 3 | deploying account.

4 |

Hierarchy

  • AccountGiver

Index

Properties

Methods

Properties

address: string

Methods

  • sendTo(address: string, value: number): Promise<void>
  • Parameters

    • address: string
    • value: number

    Returns Promise<void>

Generated using TypeDoc

-------------------------------------------------------------------------------- /docs/modules.html: -------------------------------------------------------------------------------- 1 | @eversdk/appkit
Options
All
  • Public
  • Public/Protected
  • All
Menu

@eversdk/appkit

Index

Type aliases

AccountDeployOptions: { initFunctionName?: string | null; initInput?: object; useGiver?: true | AccountGiver }
2 |

Deploy options

3 |

Type declaration

  • Optional initFunctionName?: string | null
    4 |

    Function name that will be run on deploy. Special values:

    5 |
      6 |
    • undefined (omitted): library will use constructor as a function name.
    • 7 |
    • null: library will not produce message body (no init function invocation).
    • 8 |
    9 |
  • Optional initInput?: object
    10 |

    Parameters of init function. 11 | Note: library ignores this parameter if initFunctionName is null.

    12 |
  • Optional useGiver?: true | AccountGiver
    13 |

    Giver to be used to send amount of value to deploying address 14 | before deploying.

    15 |

    If true then Account.getDefaultGiver() will be used. 16 | If omitted then application must prepay address 17 | using own logic.

    18 |
AccountOptions: { address?: string; client?: TonClient; initData?: object; signer?: Signer; useCachedState?: boolean }
19 |

Options for an account instance

20 |

Type declaration

  • Optional address?: string
    21 |

    If not specified will be calculated on contracts init state.

    22 |
  • Optional client?: TonClient
    23 |

    If not specified the Account.getDefaultClient() will be used.

    24 |
  • Optional initData?: object
    25 |

    Initial data

    26 |
  • Optional signer?: Signer
    27 |

    Default is signerNone

    28 |
  • Optional useCachedState?: boolean
    29 |

    If true, appkit aggressively caches account state. 30 | Useful for running runLocal and runLocal functions in tests.

    31 |
AccountRunLocalOptions: { performAllChecks?: boolean }
32 |

Run Local options

33 |

Type declaration

  • Optional performAllChecks?: boolean
    34 |

    If true then performs all checks and calculations as node do. 35 | If false then simplified execution is used.

    36 |
AccountRunOptions: { signer?: Signer }
37 |

Run options

38 |

Type declaration

  • Optional signer?: Signer
    39 |

    Is not specified then this.signer

    40 |
ContractPackage: { abi: AbiContract; tvc?: string }
41 |

Smart Contract Package

42 |

This object contains information about smart contract class.

43 |

Type declaration

  • abi: AbiContract
    44 |

    ABI of smart contract

    45 |
  • Optional tvc?: string
    46 |

    Compiled artifact of the smart contract. 47 | This field contains BOC with code and initial data (init state). 48 | If it is missing, then application can't deploy account of this contracts.

    49 |

Variables

DefaultGiverContract: ContractPackage = ...

Generated using TypeDoc

-------------------------------------------------------------------------------- /gitbook/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Table of contents 2 | 3 | * [Everscale JS Application Kit](../README.md) 4 | 5 | ## reference 6 | 7 | * [AppKit Reference](https://tonlabs.github.io/ever-appkit-js/) 8 | 9 | ## Samples 10 | 11 | * [AppKit Samples](https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples) 12 | 13 | ## Guides 14 | 15 | * [AppKit Guides](guides/appkit\_guides.md) 16 | * [Configure AppKit](guides/configure\_appkit.md) 17 | * [Configure Custom Giver](guides/custom\_giver.md) 18 | * [Deploy](guides/deploy.md) 19 | * [Run On-chain](guides/run\_onchain.md) 20 | * [Run ABI Get Method](guides/run\_abi\_get\_method.md) 21 | * [Work with Events](guides/work\_with\_events.md) 22 | 23 | ## Links 24 | 25 | * [AppKit JS repository](https://github.com/tonlabs/ever-appkit-js) 26 | * [EVER SDK documentation](https://docs.everos.dev/ever-sdk/) 27 | -------------------------------------------------------------------------------- /gitbook/guides/appkit_guides.md: -------------------------------------------------------------------------------- 1 | # AppKit Guides 2 | 3 | This section contains guides for working with AppKit: 4 | 5 | * [Configure AppKit](configure\_appkit.md) 6 | * [Deploy](deploy.md) 7 | * [Run on-chain](run\_onchain.md) 8 | * [Run ABI Get Method](run\_abi\_get\_method.md) 9 | * [Work with events](work\_with\_events.md) 10 | * [Configure Custom Giver](custom\_giver.md) | [Sample](https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples/custom-giver) 11 | 12 | AppKit samples are also available for the following cases, reviewed in more detail in core SDK guides: 13 | 14 | * External signing: [Core guide](https://docs.everos.dev/ever-sdk/guides/work\_with\_contracts/external\_signing) | [Sample](https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples/signing-box) 15 | * Emulate transaction: [Core guide](https://docs.everos.dev/ever-sdk/guides/work\_with\_contracts/emulate\_transaction) | [Sample](https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples/run\_executor) 16 | * Decode message: [Core guide](https://docs.everos.dev/ever-sdk/guides/work\_with\_contracts/decode\_message) | [Sample](https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples/listen-and-decode) 17 | * Estimate fees: [Core guide](https://docs.everos.dev/ever-sdk/guides/work\_with\_contracts/estimate\_fees) | [Sample](https://github.com/tonlabs/sdk-samples/blob/master/appkit-examples/fee-calculation/index.js) 18 | * Validate address, convert address: [Core guide](https://docs.everos.dev/ever-sdk/guides/work\_with\_contracts/validate\_address\_convert\_address) | [Sample](https://github.com/tonlabs/sdk-samples/blob/master/core-examples/node-js/multisig/work-with-multisig.js) 19 | * Query collection: [Core guide](https://docs.everos.dev/ever-sdk/guides/queries\_and\_subscriptions/query\_collection) | [Sample](https://github.com/tonlabs/sdk-samples/tree/master/core-examples/node-js/query) 20 | 21 | -------------------------------------------------------------------------------- /gitbook/guides/configure_appkit.md: -------------------------------------------------------------------------------- 1 | # Configure AppKit 2 | 3 | ### Using default config in AppKit 4 | 5 | In `AppKit` you can specify the default config. This will allow you to omit passing `client` object into every `AppKit` function later. If a function works with another client (another network), you need to create a client object for that network separately, like we did in the previous step, and pass it as a parameter. 6 | 7 | ```graphql 8 | TonClient.defaultConfig = { 9 | network: { 10 | // Local node URL here 11 | endpoints: ['net.ton.dev'] 12 | }, 13 | }; 14 | ``` 15 | 16 | If you are working with local blockchain [Evernode SE](https://github.com/tonlabs/evernode-se), specify [http://localhost](http://localhost) in the `endpoints`. 17 | 18 | Check the full list of [supported network endpoints](https://docs.everos.dev/ever-sdk/reference/ever-os-api/networks). 19 | 20 | You can find reference guide to `TonClient` here: [SDK API Documentation](https://docs.everos.dev/ever-sdk/reference/types-and-methods/mod\_client). 21 | -------------------------------------------------------------------------------- /gitbook/guides/custom_giver.md: -------------------------------------------------------------------------------- 1 | # Configure Custom Giver 2 | 3 | [Full Sample Code](https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples/custom-giver) 4 | 5 | By default `Account.getDefaultGiver()` is Evernode [SE giver](https://github.com/tonlabs/tonos-se/tree/master/contracts). It is integrated into Account module. We will use it. But you can always re-define it with method `Account.giver(newGiver: AccountGiver)` with the following signature: 6 | 7 | ```javascript 8 | /** 9 | * Object that can be used to send some value to an address 10 | */ 11 | export type AccountGiver = (address: string, value: number) => Promise; 12 | ``` 13 | 14 | This guide will help you to implement and configure your custom giver. In the example implementation we will use the same Evernode SE giver with its address, keys and ABI, but you can simply substitute them with your own. 15 | 16 | First of all, let's declare our Giver's address, keys and ABI: 17 | 18 | ```javascript 19 | // Address of the Giver 20 | const giverAddress = "0:ece57bcc6c530283becbbd8a3b24d3c5987cdddc3c8b7b33be6e4a6312490415"; 21 | // Keypair for the Giver 22 | const giverKeys = signerKeys({ 23 | public: "2ada2e65ab8eeab09490e3521415f45b6e42df9c760a639bcf53957550b25a16", 24 | secret: "172af540e43a524763dd53b26a066d472a97c4de37d5498170564510608250c3", 25 | }); 26 | 27 | const giverContract = { 28 | abi: { 29 | "ABI version": 2, 30 | header: ["time", "expire"], 31 | functions: [ 32 | { 33 | name: "sendTransaction", 34 | inputs: [ 35 | { 36 | "name": "dest", 37 | "type": "address", 38 | }, 39 | { 40 | "name": "value", 41 | "type": "uint128", 42 | }, 43 | { 44 | "name": "bounce", 45 | "type": "bool", 46 | }, 47 | ], 48 | outputs: [], 49 | }, 50 | { 51 | name: "getMessages", 52 | inputs: [], 53 | outputs: [ 54 | { 55 | components: [ 56 | { 57 | name: "hash", 58 | type: "uint256", 59 | }, 60 | { 61 | name: "expireAt", 62 | type: "uint64", 63 | }, 64 | ], 65 | name: "messages", 66 | type: "tuple[]", 67 | }, 68 | ], 69 | }, 70 | { 71 | name: "upgrade", 72 | inputs: [ 73 | { 74 | name: "newcode", 75 | type: "cell", 76 | }, 77 | ], 78 | outputs: [], 79 | }, 80 | { 81 | name: "constructor", 82 | inputs: [], 83 | outputs: [], 84 | }, 85 | ], 86 | data: [], 87 | events: [], 88 | }, 89 | }; 90 | ``` 91 | 92 | Next create Giver's account object, using the values from the previous step: 93 | 94 | ```javascript 95 | // Create Giver's account 96 | const giverAccount = new Account(giverContract, { 97 | client, 98 | address: giverAddress, 99 | signer: giverKeys, 100 | }); 101 | ``` 102 | 103 | Now you can implement `AccountGiver` interface: 104 | 105 | ```javascript 106 | const giverSendTo = async (address, value) => { 107 | // Run method `sendTransaction` for the Giver. You can use your custom account, 108 | // in this case, method name and arguments might vary: 109 | return await giverAccount.run("sendTransaction", { 110 | dest: address, 111 | value, 112 | bounce: false, 113 | }); 114 | }; 115 | 116 | // In order to implement giver's logics, we must implement `AccountGiver` interface 117 | const giver = { 118 | address: giverAddress, 119 | sendTo: async (address, value) => giverSendTo(address, value), 120 | }; 121 | ``` 122 | 123 | In this example, we created separated `giverSendTo` function in order to be able get result of `sendTransaction` execution, because `AccountGiver.sendTo` doesn't return any value. 124 | 125 | Configure AppKit to use our Giver: 126 | 127 | ```javascript 128 | // Set Giver for a client 129 | Account.setGiverForClient(client, giver); 130 | ``` 131 | 132 | Thats it. Now any contracts deployment using this client will lead to using your configured Giver. 133 | 134 | ## Usage examples: 135 | 136 | ### Example 1. Contract deployment 137 | 138 | In this example we will deploy test `HelloWallet` contract. 139 | 140 | ```javascript 141 | // Generate an ed25519 key pair for new account 142 | const helloAccKeys = await client.crypto.generate_random_sign_keys(); 143 | 144 | // Create test contract 145 | const helloAcc = new Account(HelloWallet, { 146 | signer: signerKeys(helloAccKeys), 147 | client, 148 | }); 149 | 150 | // Get the future address of the contract: 151 | const address = await helloAcc.getAddress(); 152 | 153 | // Request contract deployment funds form the Giver and deploy `HelloWallet` contract. 154 | await helloAcc.deploy({ useGiver: true }); 155 | console.log(`HelloWallet contract was deployed at address: ${address}`); 156 | ``` 157 | 158 | ### Example 2. Sending some funds from the Giver to a random address 159 | 160 | In this example we will send 10 tokens from our Giver to a random address and check messages and transactions, which were created during the operation. 161 | 162 | ```javascript 163 | // Generate new random keypair: 164 | const helloAcc2Keys = await client.crypto.generate_random_sign_keys(); 165 | 166 | // Create account object without client's connection. We don't need to deploy it, we just want to obtain it's future address: 167 | const helloAcc2 = new Account(HelloWallet, { 168 | signer: signerKeys(helloAcc2Keys), 169 | }); 170 | 171 | // Get address for the contract: 172 | const address2 = await helloAcc2.getAddress(); 173 | 174 | console.log("Sending funds to address:", address2); 175 | 176 | // Send funds using our separated function in order to obtain result message `id`: 177 | const result = await giverSendTo(address2, 10000000000); 178 | 179 | // Wait and get all messages and transactions, which were created during the whole operation: 180 | const transaction_tree = await client.net.query_transaction_tree({ 181 | in_msg: result.transaction.in_msg, 182 | }); 183 | 184 | // Do some checks in order to assure, that funds are received: 185 | 186 | assert.equal(transaction_tree.messages.length, 2, "There must be 2 messages"); 187 | assert(!transaction_tree.messages[1].bounce, "Expected 2nd message to be not-bounceable"); 188 | assert.equal( 189 | transaction_tree.messages[1].value, 190 | '0x2540be400' /*10 000 000 000*/, 191 | "2nd message must have a value of 10 000 000 000", 192 | ); 193 | assert.equal(transaction_tree.messages[1].dst, address2, "2nd message's destination must be " + address2); 194 | 195 | assert.equal(transaction_tree.transactions.length, 2, "There must be 2 transactions"); 196 | assert.equal( 197 | transaction_tree.transactions[1].account_addr, 198 | address2, 199 | "2nd transaction's account address must be " + address2, 200 | ); 201 | assert( 202 | transaction_tree.transactions[1].aborted, 203 | "2nd transaction must be aborted because of uninitialized account", 204 | ); 205 | 206 | console.log("Funds transferred."); 207 | ``` 208 | 209 | [Full Sample Code](https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples/custom-giver) 210 | -------------------------------------------------------------------------------- /gitbook/guides/deploy.md: -------------------------------------------------------------------------------- 1 | # Deploy 2 | 3 | Find out how to deploy a contract to Everscale Blockchain with SDK 4 | 5 | * [About Deploy](deploy.md#about-deploy) 6 | * [Deploy steps](deploy.md#deploy-steps) 7 | * [Initialize Account object](deploy.md#initialize-account-object) 8 | * [Calculate the future address of the contract](deploy.md#calculate-the-future-address-of-the-contract) 9 | * [Define deploy parameters](deploy.md#define-deploy-parameters) 10 | * [Specify Giver](deploy.md#specify-giver) 11 | * [Deploy](deploy.md#deploy) 12 | * [Sample source code](deploy.md#sample-source-code) 13 | 14 | ## About Deploy 15 | 16 | Deploy operation means that you upload contract code and initial data to the blockchain. 17 | 18 | The address of the contract can be calculated before deploy and it depends on code and data. 19 | 20 | To deploy a contract you need to sponsor its address, so that deploy fee will be paid out of these funds. 21 | 22 | ## Deploy steps 23 | 24 | Below is the sequence of steps you need to complete to deploy a contract: 25 | 26 | 1. Initialize Account object with Contract data and a pair of keys that will be used later to interact with it. 27 | 2. Calculate future address of the contract - In this case - just for information. 28 | 3. Deploy 29 | 30 | Let's take a look at every step. 31 | 32 | ## Initialize Account object 33 | 34 | To initialize an account, we need: 35 | 36 | * Contract object, that we import from `HelloContract.js`. We prepared this file when [adding contract to our app](https://docs.everos.dev/ever-sdk/guides/work\_with\_contracts/add\_contract\_to\_your\_app). 37 | * Account options, that are passed as the following structure: 38 | 39 | ``` 40 | export type AccountOptions = { 41 | /** 42 | * Initial contract data, that is stored to contract data (along with pubkey) during deploy, that will affect account address. You can pass here data defined as public in the contract 43 | */ 44 | initData?: object, 45 | /** 46 | * Default is `signerNone` 47 | Defines signature-provider that can be empty (no signature), can be a pair of keys, 48 | or a signing box interface that performs signing outside sdk. Affects account address. Read more about Signer type here https://github.com/tonlabs/TON-SDK/blob/master/docs/mod_abi.md#Signer 49 | */ 50 | signer?: Signer, 51 | /** 52 | * If not specified will be calculated from initData, tvc and pubkey. 53 | */ 54 | address?: string, 55 | /** 56 | * If not specified the Account.getDefaultClient() will be used. 57 | */ 58 | client?: TonClient, 59 | } 60 | ``` 61 | 62 | We will generate a pair of keys with `generate_random_sign_keys` function and use them as Signer in this sample. 63 | 64 | We do not have any `initData` here, we do not know the address yet, and we will use the default client, so the only field we define in the second parameter `AccountOptions` is Signer. 65 | 66 | ``` 67 | // Generate an ed25519 key pair for new account 68 | const helloAcc = new Account(HelloContract, { 69 | signer: signerKeys(await TonClient.default.crypto.generate_random_sign_keys()), 70 | }); 71 | ``` 72 | 73 | Or you can use a predefined set of keys. 74 | 75 | ``` 76 | const keys = { 77 | secret: "00232a8e5c0b156cbfe4fd41f9ca9194168fd441c18101526eec2567d36f22db" 78 | public: "f36f1bbfd0768ff4461e5743152180b9767519c40fe697cca0c1bfdfb622e11d", 79 | } 80 | ``` 81 | 82 | ## Calculate the future address of the contract 83 | 84 | Everscale blockchain requires every contract to have a positive token balance before deployment. The contract pays for the initial deployment message reducing account balance. To sponsor account before deploy we need to calculate its address. 85 | 86 | Under the hood this calculation is performed on tvc, `initData` and `pubkey`. 87 | 88 | ``` 89 | const address = await helloAcc.getAddress(); 90 | console.log(`Future address of the contract will be: ${address}`); 91 | ``` 92 | 93 | ## Define deploy parameters 94 | 95 | To deploy a contract we need to pass `AccountDeployOptions` structure into `deploy` method: 96 | 97 | ``` 98 | export type AccountDeployOptions = { 99 | /** 100 | * Function name that will be run on deploy. Special values: 101 | * - `undefined` (omitted): library will use `constructor` as a function name. 102 | * - `null`: no init function invocation. 103 | */ 104 | initFunctionName?: string | null, 105 | /** 106 | * Parameters of init function. 107 | * Note: library ignores this parameter if `initFunctionName` is `null`. 108 | */ 109 | initInput?: object, 110 | /** 111 | * Giver to be used to send amount of value to deploying address 112 | * before deploying. 113 | * 114 | * If `true` then Account.getDefaultGiver() will be used. 115 | * If omitted then application must prepay address 116 | * using own logic. 117 | */ 118 | useGiver?: true | AccountGiver, 119 | } 120 | ``` 121 | 122 | ## Specify Giver 123 | 124 | By default `Account.getDefaultGiver()` is Evernode[ SE giver](https://github.com/tonlabs/tonos-se/tree/master/contracts). It is integrated into Account module. We will use it. But you can always re-define it with method `Account.giver(newGiver: AccountGiver)` with the following signature: 125 | 126 | ``` 127 | /** 128 | * Object that can be used to send some value to an address 129 | */ 130 | export type AccountGiver = (address: string, value: number) => Promise; 131 | ``` 132 | 133 | More details about implementing your custom giver with sample code [here](custom\_giver.md). 134 | 135 | ## Deploy 136 | 137 | Because our contract has a constructor function as init function without parameters, we can omit the other 2 deploy parameters: 138 | 139 | ``` 140 | // Request contract deployment funds form a local TON OS SE giver 141 | // not suitable for other networks. 142 | // Deploy `hello` contract. 143 | await helloAcc.deploy({ useGiver: true }); 144 | console.log(`Hello contract was deployed at address: ${address}`); 145 | ``` 146 | 147 | ## Sample source code 148 | 149 | [https://github.com/tonlabs/sdk-samples/blob/master/demo/hello-wallet/index.js](https://github.com/tonlabs/sdk-samples/blob/master/demo/hello-wallet/index.js) 150 | 151 | Check out [core api documentation](https://docs.everos.dev/ever-sdk/guides/work\_with\_contracts/deploy) for more information. 152 | -------------------------------------------------------------------------------- /gitbook/guides/run_abi_get_method.md: -------------------------------------------------------------------------------- 1 | # Run ABI Get Method 2 | 3 | * [About ABI Get Method](run\_abi\_get\_method.md#about-abi-get-method) 4 | * [Run ABI get method](run\_abi\_get\_method.md#run-abi-get-method) 5 | * [Sample source code](run\_abi\_get\_method.md#sample-source-code) 6 | 7 | ## About ABI Get Method 8 | 9 | Get method is a method that is executed locally and it does not change account state. Get methods are used to retrieve contract data locally for free. 10 | 11 | ABI compatible contract - a contract which has an ABI interface. 12 | 13 | ## Run ABI get method 14 | 15 | AppKit provides `runLocal` method for running get methods of ABI-compatible contracts. 16 | 17 | ``` 18 | const dePoolAddress = "0:a07c4668a8ac1801b5ea77c86e317ca027d76c288c6da4d29d7d1fd716aff40a"; 19 | 20 | const dePoolAcc = new Account(DePoolContract, { 21 | address: dePoolAddress, 22 | client, 23 | signer: signerNone(), 24 | }); 25 | 26 | response = await dePoolAcc.runLocal("getDePoolInfo", {}); 27 | console.log(`DePool ${dePoolAddress} Info:`, response.decoded.output); 28 | const validatorWallet = response.decoded.output.validatorWallet; 29 | 30 | response = await dePoolAcc.runLocal("getParticipantInfo", { "addr": validatorWallet }); 31 | console.log(`\nValidator Wallet ${validatorWallet} Stake Info:`, response.decoded.output); 32 | 33 | response = await dePoolAcc.runLocal("getDePoolBalance", {}); 34 | console.log(`\nDePool Balance Nano Crystal:`, response.decoded.output.value0); 35 | ``` 36 | 37 | ## Sample source code 38 | 39 | Observe the full sample: [https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples/depool-statistics](https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples/depool-statistics) 40 | 41 | Check out [core api documentation](https://docs.everos.dev/ever-sdk/guides/work\_with\_contracts/run\_abi\_get\_method) for more information about running get methods. 42 | -------------------------------------------------------------------------------- /gitbook/guides/run_onchain.md: -------------------------------------------------------------------------------- 1 | # Run On-chain 2 | 3 | Learn how to run methods of a contract on-chain 4 | 5 | * [About Run](run\_onchain.md#about-run) 6 | * [Run on-chain](run\_onchain.md#run-on-chain) 7 | * [Sample source code](run\_onchain.md#sample-source-code) 8 | 9 | ## About Run 10 | 11 | Run operation means that you execute the contract's function on-chain by sending it an external inbound message. Run steps 12 | 13 | Run operation consists of few steps: 14 | 15 | 1. Creating a message; 16 | 2. Sending a message; 17 | 3. Receiving the message completion transaction; 18 | 4. Receiving external messages created by `return` function; 19 | 5. Decoding the messages bodies according to the ABI. 20 | 21 | ## Run on-chain 22 | 23 | For running methods of ABI-compatible contracts AppKit provides `run` method: 24 | 25 | ``` 26 | // Call `touch` function 27 | let response = await helloAcc.run("touch", {}); 28 | ``` 29 | 30 | ## Sample source code 31 | 32 | Observe the full sample: [https://github.com/tonlabs/sdk-samples/tree/master/demo/hello-wallet](https://github.com/tonlabs/sdk-samples/tree/master/demo/hello-wallet) 33 | 34 | Check out [core api documentation](https://docs.everos.dev/ever-sdk/guides/work\_with\_contracts/run\_onchain) for more information about running a contract. 35 | -------------------------------------------------------------------------------- /gitbook/guides/work_with_events.md: -------------------------------------------------------------------------------- 1 | # Work with Events 2 | 3 | How to work with contract events 4 | 5 | * [About events](work\_with\_events.md#about-events) 6 | * [Query/subscribe to events](work\_with\_events.md#querysubscribe-to-events) 7 | * [Query/Subscribe with SDK](work\_with\_events.md#querysubscribe-with-sdk) 8 | * [AppKit syntax](work\_with\_events.md#appkit-syntax) 9 | * [Query](work\_with\_events.md#query) 10 | * [Subscribe](work\_with\_events.md#subscribe) 11 | * [Decode](work\_with\_events.md#decode) 12 | 13 | ## About events 14 | 15 | When contract emits an event, you can fetch it from blockchain or you can subscribe to it. 16 | 17 | Events in blockchain are external outbound messages. In GraphQL API their `msg_type` is 2: 18 | 19 | ![scr1.jpg](../../.gitbook/assets/scr1.jpg) 20 | 21 | ## Query/subscribe to events 22 | 23 | You can fetch events of you contract with this filter from graphql. Try it out in playground [https://eri01.main.everos.dev/graphql](https://eri01.main.everos.dev/graphql): 24 | 25 | ``` 26 | query{ 27 | messages( 28 | filter:{ 29 | src:{ 30 | eq:"-1:67f4bf95722e1bd6df845fca7991e5e7128ce4a6d25f6d4ef027d139a11a7964" 31 | } 32 | msg_type:{ 33 | eq:2 34 | } 35 | } 36 | ) 37 | { 38 | id 39 | body 40 | } 41 | } 42 | ``` 43 | 44 | Or subscribe to them: 45 | 46 | ``` 47 | subscription{ 48 | messages( 49 | filter:{ 50 | src:{ 51 | eq:"-1:67f4bf95722e1bd6df845fca7991e5e7128ce4a6d25f6d4ef027d139a11a7964" 52 | } 53 | msg_type:{ 54 | eq:2 55 | } 56 | } 57 | ) 58 | { 59 | id 60 | body 61 | } 62 | } 63 | ``` 64 | 65 | ## Query/Subscribe with SDK 66 | 67 | Let's assume our contract code is this: 68 | 69 | ``` 70 | pragma ton-solidity >= 0.38.2; 71 | pragma AbiHeader expire; 72 | 73 | 74 | contract HelloEvents { 75 | // Event is an external message generated by the contract functions. 76 | // Here we will emit this external outbound message (event) 77 | // every time we have changed the hello text. 78 | event TextUpdated(string text, uint32 time); 79 | 80 | // Instance variable storing some user data. 81 | string helloText; 82 | 83 | // Instance variable storing the time of `constructor` call or `setHelloText` function call. 84 | uint32 textUpdateTime; 85 | 86 | // Constructor sets instance variables. 87 | // All contracts need to call `tvm.accept()` for deploying. 88 | constructor(string text) public { 89 | tvm.accept(); 90 | helloText = text; 91 | textUpdateTime = now; 92 | } 93 | 94 | // Function `setHelloText` updates instance variables 95 | // `helloText` and `textUpdateTime` 96 | // and emits `TextUpdated` event. 97 | function setHelloText(string text) external returns (string oldText) { 98 | require(msg.pubkey() == tvm.pubkey(), 100); 99 | tvm.accept(); 100 | string saveText = helloText; 101 | helloText = text; 102 | textUpdateTime = now; 103 | emit TextUpdated(helloText, textUpdateTime); 104 | return saveText; 105 | } 106 | 107 | // Function returns value of instance variable `helloText`. 108 | // This function is a get method (it does not change state and has no `accept` function) 109 | // so it can be called only on local TVM. 110 | function getHelloText() public view returns (string text) { 111 | return helloText; 112 | } 113 | 114 | // Function returns value of instance variable `textUpdateTime`. 115 | // This function is a get method (it does not change state and has no `accept` function) 116 | // so it can be called only on local TVM. 117 | function getTextUpdateTime() public view returns (uint32 time) { 118 | return textUpdateTime; 119 | } 120 | } 121 | ``` 122 | 123 | We see that we have 1 event `TextUpdated(helloText, textUpdateTime)`. 124 | 125 | ## AppKit syntax 126 | 127 | See the full sample here [https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples/listen-and-decode](https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples/listen-and-decode) 128 | 129 | ### Query 130 | 131 | To fetch all the events do this query. It uses low level api, AppKit does not provide query options for account yet. 132 | 133 | ``` 134 | result = (await client.net.query_collection({ 135 | collection: "messages", 136 | filter: { 137 | src: { 138 | eq: "-1:67f4bf95722e1bd6df845fca7991e5e7128ce4a6d25f6d4ef027d139a11a7964", 139 | }, 140 | msg_type:{ eq:2 } 141 | }, 142 | result: "boc", 143 | })).result; 144 | ``` 145 | 146 | ### Subscribe 147 | 148 | To subscribe to new events do this. Don't forget to specify your own callback. 149 | 150 | ``` 151 | await account.subscribeMessages("boc",callback) 152 | ``` 153 | 154 | ### Decode 155 | 156 | ``` 157 | const decoded = await hello.decodeMessage(msg.boc); 158 | switch (decoded.body_type) { 159 | // Message that triggered an on-chain contract call 160 | case MessageBodyType.Input: 161 | if (decoded.name === "setHelloText") { 162 | decoded.value.text = decodeText(decoded.value.text); 163 | } 164 | console.log(`External inbound message, function "${decoded.name}", parameters: `, JSON.stringify(decoded.value)); 165 | break; 166 | // External outbound message generated by a function's `return` 167 | case MessageBodyType.Output: 168 | if (decoded.name === "setHelloText") { 169 | decoded.value.oldText = decodeText(decoded.value.text); 170 | } 171 | console.log(`External outbound message, function "${decoded.name}", result`, JSON.stringify(decoded.value)); 172 | break; 173 | // Event generated by the contract 174 | case MessageBodyType.Event: 175 | if (decoded.name === "TextUpdated") { 176 | decoded.value.text = decodeText(decoded.value.text); 177 | } 178 | console.log(`External outbound message, event "${decoded.name}", parameters`, JSON.stringify(decoded.value)); 179 | break; 180 | } 181 | ``` 182 | 183 | Check out [core api documentation](https://docs.everos.dev/ever-sdk/guides/work\_with\_contracts/work\_with\_events) for more information. 184 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testPathIgnorePatterns:[ 3 | "/node_modules/", 4 | "/__tests__/utils", 5 | "/__tests__/dist", 6 | ] 7 | }; 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@eversdk/appkit", 3 | "version": "0.3.8", 4 | "description": "FreeTON SDK: Application Kit", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/tonlabs/ever-sdk-js.git" 10 | }, 11 | "scripts": { 12 | "test": "npx jest", 13 | "prepublishOnly": "npm i && npx tsc", 14 | "docs": "typedoc src/account.ts --out docs" 15 | }, 16 | "keywords": [ 17 | "TON", 18 | "Client", 19 | "FreeTON", 20 | "TONOS", 21 | "SDK" 22 | ], 23 | "author": "TON DEV SOLUTIONS LTD.", 24 | "license": "Apache-2.0", 25 | "licenses": [ 26 | { 27 | "type": "Apache-2.0", 28 | "url": "http://www.apache.org/licenses/LICENSE-2.0" 29 | } 30 | ], 31 | "homepage": "https://docs.ton.dev/", 32 | "engines": { 33 | "node": ">=6" 34 | }, 35 | "dependencies": { 36 | "@eversdk/core": "^1.38.1" 37 | }, 38 | "devDependencies": { 39 | "@babel/preset-env": "^7.13.10", 40 | "@babel/preset-typescript": "^7.13.0", 41 | "@eversdk/lib-node": "^1.38.1", 42 | "@types/jest": "^26.0.21", 43 | "@types/node": "^14.14.35", 44 | "jest": "^26.6.3", 45 | "typedoc": "^0.22.11", 46 | "typescript": "^4.0.3", 47 | "prettier": "^2.3.2" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/account.ts: -------------------------------------------------------------------------------- 1 | import { 2 | signerNone, 3 | accountForExecutorAccount, 4 | ParamsOfEncodeMessage, 5 | ResultOfProcessMessage, 6 | ResultOfRunExecutor, 7 | Signer, 8 | Abi, 9 | AbiContract, 10 | abiContract, 11 | KeyPair, 12 | signerKeys, 13 | TonClient, 14 | ResultOfSubscribeCollection, 15 | TransactionFees, 16 | accountForExecutorUninit, 17 | NetErrorCode, 18 | } from "@eversdk/core" 19 | 20 | /** 21 | * Options for an account instance 22 | */ 23 | export type AccountOptions = { 24 | /** 25 | * Initial data 26 | */ 27 | initData?: object 28 | /** 29 | * Default is `signerNone` 30 | */ 31 | signer?: Signer 32 | /** 33 | * If not specified will be calculated on contracts init state. 34 | */ 35 | address?: string 36 | /** 37 | * If not specified the Account.getDefaultClient() will be used. 38 | */ 39 | client?: TonClient 40 | /** 41 | * If true, appkit aggressively caches account state. 42 | * Useful for running `runLocal` and `runLocal` functions in tests. 43 | */ 44 | useCachedState?: boolean 45 | } 46 | 47 | /** 48 | * Run options 49 | */ 50 | export type AccountRunOptions = { 51 | /** 52 | * If not specified then this.signer 53 | */ 54 | signer?: Signer 55 | } 56 | 57 | /** 58 | * Run Local options 59 | */ 60 | export type AccountRunLocalOptions = { 61 | /** 62 | * If `true` then performs all checks and calculations as node do. 63 | * If `false` then simplified execution is used. 64 | */ 65 | performAllChecks?: boolean 66 | } 67 | 68 | /** 69 | * Object that can be used to send some value before 70 | * deploying account. 71 | */ 72 | export interface AccountGiver { 73 | address: string 74 | account: Account 75 | sendTo(address: string, value: number): Promise 76 | } 77 | 78 | /** 79 | * Deploy options 80 | */ 81 | export type AccountDeployOptions = { 82 | /** 83 | * Function name that will be run on deploy. Special values: 84 | * - `undefined` (omitted): library will use `constructor` as a function name. 85 | * - `null`: library will not produce message body (no init function invocation). 86 | */ 87 | initFunctionName?: string | null 88 | /** 89 | * Parameters of init function. 90 | * Note: library ignores this parameter if `initFunctionName` is `null`. 91 | */ 92 | initInput?: object 93 | /** 94 | * Giver to be used to send amount of value to deploying address 95 | * before deploying. 96 | * 97 | * If `true` then Account.getDefaultGiver() will be used. 98 | * If omitted then application must prepay address 99 | * using own logic. 100 | */ 101 | useGiver?: true | AccountGiver 102 | } 103 | 104 | /** 105 | * Smart Contract Package 106 | * 107 | * This object contains information about smart contract class. 108 | */ 109 | export type ContractPackage = { 110 | /** 111 | * ABI of smart contract 112 | */ 113 | abi: AbiContract 114 | /** 115 | * Compiled artifact of the smart contract. 116 | * This field contains BOC with code and initial data (init state). 117 | * If it is missing, then application can't deploy account of this contracts. 118 | */ 119 | tvc?: string 120 | } 121 | 122 | enum ERR_CODES { 123 | MISSING_TVC, 124 | ACC_NOT_EXISTS, 125 | } 126 | 127 | export class AccountError extends Error { 128 | code: ERR_CODES 129 | constructor(opt: { code: ERR_CODES; message: string }) { 130 | super(opt.message) 131 | this.code = opt.code 132 | } 133 | static missingTVC(): AccountError { 134 | return new AccountError({ 135 | code: ERR_CODES.MISSING_TVC, 136 | message: "Can't calculate deploy params: missing required TVC.", 137 | }) 138 | } 139 | static missingBOC(): AccountError { 140 | return new AccountError({ 141 | code: ERR_CODES.ACC_NOT_EXISTS, 142 | message: 143 | 'Account has an empty BOC. Possible reason is: account was deleted (has account type "NonExist")', 144 | }) 145 | } 146 | 147 | static missingAccount(): AccountError { 148 | return new AccountError({ 149 | code: ERR_CODES.ACC_NOT_EXISTS, 150 | message: "Account does not exists on the blockchain.", 151 | }) 152 | } 153 | } 154 | 155 | /** 156 | * Current type of the account. 157 | */ 158 | export enum AccountType { 159 | /** 160 | * Account exists in the blockchain but without smart contract. 161 | */ 162 | uninit = 0, 163 | /** 164 | * Account exists in the blockchain with smart contract. 165 | */ 166 | active = 1, 167 | /** 168 | * Account exists in the blockchain but it had frozen. 169 | */ 170 | frozen = 2, 171 | /** 172 | * Account is missing in the blockchain. 173 | */ 174 | nonExist = 3, 175 | } 176 | 177 | /** 178 | * Object to deal with specified account using specified signer (owner). 179 | * 180 | * Account instance can be bound to account address 181 | * or account deploy parameters that uniquely identifies 182 | * account address. 183 | */ 184 | export class Account { 185 | private static giversByClient: { 186 | client: TonClient 187 | giver: AccountGiver 188 | }[] = [] 189 | 190 | /** 191 | * Returns the giver instance assigned for specified client instance. 192 | * Or `null` if no giver is associated with this client yet. 193 | * 194 | * @param client Client instance looking for. 195 | */ 196 | static findGiverForClient(client: TonClient): AccountGiver | undefined { 197 | return this.giversByClient.find(x => x.client === client)?.giver 198 | } 199 | 200 | /** 201 | * Assigns specified giver as a default for specified client instance. 202 | * If client already has default giver it will be reassigned. 203 | * 204 | * @param client Client instance. 205 | * @param giver New giver instance or `null` if the default giver for 206 | * this client must be removed. 207 | */ 208 | static setGiverForClient(client: TonClient, giver: AccountGiver | null) { 209 | const i = this.giversByClient.findIndex(x => x.client === client) 210 | if (i >= 0) { 211 | if (giver) { 212 | this.giversByClient[i].giver = giver 213 | } else { 214 | this.giversByClient.splice(i, 1) 215 | } 216 | } else if (giver) { 217 | this.giversByClient.push({ 218 | client, 219 | giver, 220 | }) 221 | } 222 | } 223 | 224 | private static async createGiver(client: TonClient): Promise { 225 | const giverKeys = await getDefaultGiverKeys(client) 226 | const giverContract = getDefaultGiverContract(getEnv("EVERCLOUD_GIVER_TYPE") ?? "v3"); 227 | const giverAddress = await getDefaultGiverAddress(client, giverKeys, giverContract) 228 | const giver = new Account(giverContract, { 229 | client, 230 | address: giverAddress, 231 | signer: signerKeys(giverKeys), 232 | }) 233 | return { 234 | address: giverAddress, 235 | account: giver, 236 | sendTo: async (address, value) => { 237 | const topup = await giver.run("sendTransaction", { 238 | dest: address, 239 | value, 240 | bounce: false, 241 | }) 242 | if (topup.transaction.out_msgs.length == 0) { 243 | throw Error( 244 | `The giver's sendTo call should result in at least 1 internal outbound message, transaction.id: ${topup.transaction.id}`, 245 | ) 246 | } 247 | return topup 248 | }, 249 | } 250 | } 251 | 252 | /** 253 | * Returns the default giver for specified client instance. 254 | * If no giver assigned yet then new one will be created, 255 | * assigned and returned. 256 | * 257 | * @param client Client instance. 258 | */ 259 | static async getGiverForClient(client: TonClient): Promise { 260 | const existing = this.findGiverForClient(client) 261 | if (existing) { 262 | return existing 263 | } 264 | const giver = await this.createGiver(client) 265 | this.giversByClient.push({ 266 | client, 267 | giver, 268 | }) 269 | return giver 270 | } 271 | 272 | /** 273 | * Contract package used for this account. 274 | */ 275 | readonly contract: ContractPackage 276 | /** 277 | * Client instance used to perform all account related tasks. 278 | */ 279 | readonly client: TonClient 280 | /** 281 | * Abi of this account. 282 | */ 283 | readonly abi: Abi 284 | /** 285 | * Signer used to sign messages addressed to this account. 286 | */ 287 | readonly signer: Signer 288 | /** 289 | * Initial data used to form the deploy parameter. 290 | */ 291 | readonly initData: object | null 292 | /** 293 | * Allow Appkit to use the cached account state, safe for local tests only. 294 | */ 295 | readonly useCachedState: boolean 296 | 297 | private address: string | null 298 | private syncLastTransLt: string | null = null 299 | private cachedBoc: string | null = null 300 | private subscriptions: Map | null = 301 | null 302 | 303 | /** 304 | * Constructs account instance. 305 | * 306 | * @param contract Contract package containing abi and optional tvc data. 307 | * @param options Account instance options. 308 | */ 309 | constructor(contract: ContractPackage, options?: AccountOptions) { 310 | this.contract = contract 311 | this.client = options?.client ?? TonClient.default 312 | this.abi = abiContract(contract.abi) 313 | this.signer = options?.signer ?? signerNone() 314 | this.address = options?.address ?? null 315 | this.initData = options?.initData ?? null 316 | this.useCachedState = options?.useCachedState ?? false 317 | } 318 | 319 | /** 320 | * Returns address of the account. 321 | * 322 | * Uses address specified in constructor options 323 | * or calculates it from deploy data provided in constructor. 324 | */ 325 | async getAddress(): Promise { 326 | let address = this.address 327 | if (address === null) { 328 | const deployParams = this.getParamsOfDeployMessage({ 329 | initFunctionName: null, 330 | }) 331 | address = (await this.client.abi.encode_message(deployParams)) 332 | .address 333 | this.address = address 334 | } 335 | return address 336 | } 337 | 338 | /** 339 | * Returns params for encoding deploy message. 340 | * @param options Message encoding options. 341 | */ 342 | getParamsOfDeployMessage( 343 | options?: AccountDeployOptions, 344 | ): ParamsOfEncodeMessage { 345 | if (!this.contract.tvc) { 346 | throw AccountError.missingTVC() 347 | } 348 | const params: ParamsOfEncodeMessage = { 349 | abi: this.abi, 350 | signer: this.signer, 351 | deploy_set: { 352 | tvc: this.contract.tvc, 353 | }, 354 | } 355 | if (this.initData) { 356 | ;(params.deploy_set as any).initial_data = this.initData 357 | } 358 | if (options?.initFunctionName !== null) { 359 | params.call_set = { 360 | function_name: options?.initFunctionName ?? "constructor", 361 | } 362 | if (options?.initInput !== undefined) { 363 | params.call_set.input = options.initInput 364 | } 365 | } 366 | return params 367 | } 368 | 369 | /** 370 | * Calculates detailed deploy fees. 371 | */ 372 | async calcDeployFees( 373 | options?: AccountDeployOptions, 374 | ): Promise { 375 | const deployParams = this.getParamsOfDeployMessage(options) 376 | const message = await this.client.abi.encode_message(deployParams) 377 | const result = await this.client.tvm.run_executor({ 378 | account: accountForExecutorUninit(), 379 | abi: this.abi, 380 | message: message.message, 381 | }) 382 | return result.fees 383 | } 384 | 385 | /** 386 | * Deploys account into network 387 | * @param options 388 | */ 389 | async deploy( 390 | options?: AccountDeployOptions, 391 | ): Promise { 392 | const deployParams = this.getParamsOfDeployMessage(options) 393 | const useGiver = options?.useGiver 394 | const giver = 395 | useGiver === true 396 | ? await Account.getGiverForClient(this.client) 397 | : useGiver 398 | this.address = ( 399 | await this.client.abi.encode_message(deployParams) 400 | ).address 401 | if (giver) { 402 | await giver.sendTo(this.address, 10_000_000_000) 403 | } 404 | const result = await this.client.processing.process_message({ 405 | message_encode_params: deployParams, 406 | send_events: false, 407 | }) 408 | this.needSyncWithTransaction(result.transaction) 409 | return result 410 | } 411 | 412 | /** 413 | * Emulate deploy 414 | * @param options 415 | */ 416 | async deployLocal( 417 | options?: AccountDeployOptions, 418 | ): Promise { 419 | const deployParams = this.getParamsOfDeployMessage(options) 420 | const { address, message } = await this.client.abi.encode_message( 421 | deployParams, 422 | ) 423 | const result = await this.client.tvm.run_executor({ 424 | account: accountForExecutorUninit(), 425 | abi: this.abi, 426 | message, 427 | return_updated_account: true, 428 | }) 429 | this.address = address 430 | this.cachedBoc = result.account 431 | return result 432 | } 433 | 434 | /** 435 | * Calculates detailed fees for specified run parameters. 436 | * 437 | * @param functionName Name of the function according to the ABI. 438 | * @param input Object with function parameters (function parameters). 439 | */ 440 | async calcRunFees( 441 | functionName: string, 442 | input: object, 443 | ): Promise { 444 | const message = await this.client.abi.encode_message({ 445 | address: await this.getAddress(), 446 | abi: this.abi, 447 | signer: this.signer, 448 | call_set: { 449 | function_name: functionName, 450 | input, 451 | }, 452 | }) 453 | let result 454 | result = await this.client.tvm.run_executor({ 455 | account: accountForExecutorAccount(await this.boc()), 456 | abi: this.abi, 457 | message: message.message, 458 | }) 459 | return result.fees 460 | } 461 | 462 | /** 463 | * Process message on network and returns detailed information 464 | * about results including produced transaction and messages. 465 | * 466 | * @param functionName Name of the function according to the ABI. 467 | * @param input Object with function parameters (function parameters). 468 | * @param options Run options. 469 | */ 470 | async run( 471 | functionName: string, 472 | input: object, 473 | options?: AccountRunOptions, 474 | ): Promise { 475 | const result = await this.client.processing.process_message({ 476 | message_encode_params: { 477 | address: await this.getAddress(), 478 | abi: this.abi, 479 | signer: options?.signer ?? this.signer, 480 | call_set: { 481 | function_name: functionName, 482 | input, 483 | }, 484 | }, 485 | send_events: false, 486 | }) 487 | this.needSyncWithTransaction(result.transaction) 488 | return result 489 | } 490 | 491 | /** 492 | * Evaluates message on local TVM and returns decoded output. 493 | * 494 | * @param functionName Name of the function according to the ABI. 495 | * @param input Object with function parameters (function input). 496 | * @param options Run options. 497 | */ 498 | async runLocal( 499 | functionName: string, 500 | input: object, 501 | options?: AccountRunLocalOptions, 502 | ): Promise { 503 | const message = await this.client.abi.encode_message({ 504 | address: await this.getAddress(), 505 | abi: this.abi, 506 | signer: this.signer, 507 | call_set: { 508 | function_name: functionName, 509 | input, 510 | }, 511 | }) 512 | let result 513 | if (options?.performAllChecks) { 514 | result = await this.client.tvm.run_executor({ 515 | account: accountForExecutorAccount(await this.boc()), 516 | abi: this.abi, 517 | message: message.message, 518 | return_updated_account: true, 519 | }) 520 | } else { 521 | result = (await this.client.tvm.run_tvm({ 522 | account: await this.boc(), 523 | abi: this.abi, 524 | message: message.message, 525 | return_updated_account: true, 526 | })) as ResultOfRunExecutor 527 | } 528 | if (result.account) { 529 | this.cachedBoc = result.account 530 | } 531 | return result 532 | } 533 | 534 | private needSyncWithTransaction(transaction: any) { 535 | if (!transaction.aborted && transaction.lt) { 536 | this.syncLastTransLt = transaction.lt 537 | this.cachedBoc = null 538 | } 539 | } 540 | 541 | /** 542 | * Returns raw data of the account in form of BOC. 543 | * Fetches boc data from network and caches it in private field. 544 | * `runLocal` updates cached boc. 545 | * `run` drops cached boc. 546 | * This function syncs fetching boc with last `run` or `deploy` 547 | * so fetched boc 548 | */ 549 | async boc(): Promise { 550 | if (this.cachedBoc && this.useCachedState) { 551 | return this.cachedBoc 552 | } 553 | const address = await this.getAddress() 554 | const net = this.client.net 555 | if (this.syncLastTransLt) { 556 | const accounts = await net.query_collection({ 557 | collection: "accounts", 558 | filter: { 559 | id: { eq: address }, 560 | last_trans_lt: { ge: this.syncLastTransLt }, 561 | }, 562 | result: "boc", 563 | }) 564 | if (accounts.result.length > 0) { 565 | const boc = accounts.result[0].boc 566 | this.syncLastTransLt = null 567 | if (boc) { 568 | this.cachedBoc = boc 569 | return boc 570 | } 571 | throw AccountError.missingBOC() 572 | } 573 | } 574 | try { 575 | const boc = 576 | // Returns BOC or null if account was found in DB, but has "NotExists" status 577 | // Throws if: 578 | // - account NOT found in DB (err.code 603) 579 | // - some network error occurred 580 | ( 581 | await net.wait_for_collection({ 582 | collection: "accounts", 583 | filter: { id: { eq: this.address } }, 584 | result: "boc", 585 | timeout: 1000, 586 | }) 587 | ).result.boc 588 | if (boc) { 589 | this.cachedBoc = boc 590 | return boc 591 | } 592 | throw AccountError.missingBOC() 593 | } catch (waitForError: any) { 594 | const isWaitForError = 595 | waitForError.code === NetErrorCode.WaitForFailed || 596 | waitForError.code === NetErrorCode.WaitForTimeout 597 | if (isWaitForError) { 598 | try { 599 | // Checking query 600 | const { result } = await net.query_collection({ 601 | collection: "accounts", 602 | filter: { 603 | id: { eq: this.address }, 604 | }, 605 | result: "boc", 606 | }) 607 | if (result.length === 0) { 608 | throw AccountError.missingAccount() 609 | } else { 610 | const boc = result[0].boc 611 | if (boc) { 612 | this.cachedBoc = boc 613 | return boc 614 | } 615 | throw AccountError.missingBOC() 616 | } 617 | } catch (checkQueryError: any) { 618 | throw checkQueryError 619 | } 620 | } 621 | throw waitForError 622 | } 623 | } 624 | 625 | /** 626 | * Drops all cached and local data. 627 | */ 628 | refresh() { 629 | this.cachedBoc = null 630 | } 631 | 632 | /** 633 | * Returns parsed data of the account. 634 | */ 635 | async getAccount(): Promise { 636 | try { 637 | const boc = await this.boc() 638 | return (await this.client.boc.parse_account({ boc })).parsed 639 | } catch (err: any) { 640 | if (err.code === ERR_CODES.ACC_NOT_EXISTS) { 641 | return { 642 | acc_type: AccountType.nonExist, 643 | } 644 | } 645 | throw err 646 | } 647 | } 648 | 649 | async subscribeAccount( 650 | fields: string, 651 | listener: (account: any) => void | Promise, 652 | ) { 653 | await this.subscribe( 654 | "accounts", 655 | { id: { eq: await this.getAddress() } }, 656 | fields, 657 | listener, 658 | ) 659 | } 660 | 661 | async subscribeTransactions( 662 | fields: string, 663 | listener: (transaction: any) => void | Promise, 664 | ) { 665 | const address = await this.getAddress() 666 | await this.subscribe( 667 | "transactions", 668 | { 669 | account_addr: { eq: address }, 670 | status: { eq: 5 }, 671 | }, 672 | fields, 673 | listener, 674 | ) 675 | } 676 | 677 | async subscribeMessages( 678 | fields: string, 679 | listener: (message: any) => void | Promise, 680 | ) { 681 | const address = await this.getAddress() 682 | await this.subscribe( 683 | "messages", 684 | { 685 | status: { eq: 5 }, 686 | src: { eq: address }, 687 | OR: { 688 | status: { eq: 5 }, 689 | dst: { eq: address }, 690 | }, 691 | }, 692 | fields, 693 | listener, 694 | ) 695 | } 696 | 697 | async decodeMessage(message: string): Promise { 698 | return await TonClient.default.abi.decode_message({ 699 | abi: this.abi, 700 | message, 701 | }) 702 | } 703 | 704 | async decodeMessageBody(body: string, isInternal: boolean) { 705 | return await TonClient.default.abi.decode_message_body({ 706 | abi: this.abi, 707 | body, 708 | is_internal: isInternal, 709 | }) 710 | } 711 | 712 | async getBalance(): Promise { 713 | return (await this.getAccount()).balance 714 | } 715 | 716 | async subscribe( 717 | collection: string, 718 | filter: any, 719 | fields: string, 720 | listener: (data: any) => void | Promise, 721 | ) { 722 | const prevSubscription = 723 | this.subscriptions && this.subscriptions.get(collection) 724 | if (prevSubscription) { 725 | this.subscriptions?.delete(collection) 726 | await this.client.net.unsubscribe(prevSubscription) 727 | } else if (!this.subscriptions) { 728 | this.subscriptions = new Map() 729 | } 730 | const subscription = await this.client.net.subscribe_collection( 731 | { 732 | collection, 733 | filter, 734 | result: fields, 735 | }, 736 | (params, responseType) => { 737 | if (responseType === 100) { 738 | listener(params.result) 739 | } 740 | }, 741 | ) 742 | this.subscriptions?.set(collection, subscription) 743 | } 744 | 745 | /** 746 | * Free all internal resources related to this instance 747 | * and allocated inside core. 748 | * 749 | * It is a good practice to call this method when you have finished 750 | * with this Account object. 751 | * 752 | * Note that this instance still fully operable. 753 | * So you can continue to work with this instance. 754 | */ 755 | async free(): Promise { 756 | if (this.subscriptions) { 757 | const subscriptions = this.subscriptions.values() 758 | this.subscriptions = null 759 | for (const subscription of subscriptions) { 760 | await this.client.net.unsubscribe(subscription) 761 | } 762 | } 763 | } 764 | } 765 | 766 | function getEnv(name: string): any { 767 | const globalEval = eval 768 | try { 769 | return globalEval(`process.env.${name}`) 770 | } catch { 771 | return undefined 772 | } 773 | } 774 | 775 | export type GiverVersions = "v2" | "v3" 776 | 777 | export function getDefaultGiverContract(type: GiverVersions): ContractPackage { 778 | try { 779 | return { v2: DefaultGiverContract, v3: GiverV3Contract }[type] 780 | } catch (e) { 781 | throw Error(`Giver type '${type}' unknown`) 782 | } 783 | } 784 | 785 | async function getDefaultGiverKeys(client: TonClient): Promise { 786 | const definedSecret = getEnv("TON_GIVER_SECRET") 787 | if (definedSecret) { 788 | const definedKeys = 789 | await client.crypto.nacl_sign_keypair_from_secret_key({ 790 | secret: definedSecret, 791 | }) 792 | definedKeys.secret = definedKeys.secret.substring(0, 64) 793 | return definedKeys 794 | } 795 | // noinspection SpellCheckingInspection 796 | return { 797 | public: "2ada2e65ab8eeab09490e3521415f45b6e42df9c760a639bcf53957550b25a16", 798 | secret: "172af540e43a524763dd53b26a066d472a97c4de37d5498170564510608250c3", 799 | } 800 | } 801 | 802 | async function getDefaultGiverAddress( 803 | client: TonClient, 804 | keys: KeyPair, 805 | giver: ContractPackage, 806 | ): Promise { 807 | const definedAddress = getEnv("TON_GIVER_ADDRESS") 808 | if (definedAddress) { 809 | return definedAddress 810 | } 811 | return ( 812 | await client.abi.encode_message({ 813 | abi: abiContract(giver.abi), 814 | deploy_set: { 815 | tvc: giver.tvc ?? "", 816 | }, 817 | signer: signerKeys(keys), 818 | }) 819 | ).address 820 | } 821 | 822 | // noinspection SpellCheckingInspection 823 | export const DefaultGiverContract: ContractPackage = { 824 | abi: { 825 | "ABI version": 2, 826 | header: ["time", "expire"], 827 | functions: [ 828 | { 829 | name: "sendTransaction", 830 | inputs: [ 831 | { 832 | name: "dest", 833 | type: "address", 834 | }, 835 | { 836 | name: "value", 837 | type: "uint128", 838 | }, 839 | { 840 | name: "bounce", 841 | type: "bool", 842 | }, 843 | ], 844 | outputs: [], 845 | }, 846 | { 847 | name: "getMessages", 848 | inputs: [], 849 | outputs: [ 850 | { 851 | components: [ 852 | { 853 | name: "hash", 854 | type: "uint256", 855 | }, 856 | { 857 | name: "expireAt", 858 | type: "uint64", 859 | }, 860 | ], 861 | name: "messages", 862 | type: "tuple[]", 863 | }, 864 | ], 865 | }, 866 | { 867 | name: "upgrade", 868 | inputs: [ 869 | { 870 | name: "newcode", 871 | type: "cell", 872 | }, 873 | ], 874 | outputs: [], 875 | }, 876 | { 877 | name: "constructor", 878 | inputs: [], 879 | outputs: [], 880 | }, 881 | ], 882 | data: [], 883 | events: [], 884 | }, 885 | tvc: "te6ccgECIAEAA6YAAgE0BgEBAcACAgPPIAUDAQHeBAAD0CAAQdgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAIm/wD0pCAiwAGS9KDhiu1TWDD0oQkHAQr0pCD0oQgAAAIBIA0KAQL/CwH+fyHtRNAg10nCAZ/T/9MA9AX4an/4Yfhm+GKOG/QFbfhqcAGAQPQO8r3XC//4YnD4Y3D4Zn/4YeLTAAGOEoECANcYIPkBWPhCIPhl+RDyqN4j+EUgbpIwcN74Qrry4GUh0z/THzQg+CO88rki+QAg+EqBAQD0DiCRMd7y0Gb4AAwANiD4SiPIyz9ZgQEA9EP4al8E0x8B8AH4R27yfAIBIBQOAgFYEg8BCbjomPxQEAHW+EFujhLtRNDT/9MA9AX4an/4Yfhm+GLe0XBtbwL4SoEBAPSGlQHXCz9/k3BwcOKRII4yXzPIIs8L/yHPCz8xMQFvIiGkA1mAIPRDbwI0IvhKgQEA9HyVAdcLP3+TcHBw4gI1MzHoXwMhwP8RAJiOLiPQ0wH6QDAxyM+HIM6NBAAAAAAAAAAAAAAAAA90TH4ozxYhbyICyx/0AMlx+wDeMMD/jhL4QsjL//hGzwsA+EoB9ADJ7VTef/hnAQm5Fqvn8BMAtvhBbo427UTQINdJwgGf0//TAPQF+Gp/+GH4Zvhijhv0BW34anABgED0DvK91wv/+GJw+GNw+GZ/+GHi3vhG8nNx+GbR+AD4QsjL//hGzwsA+EoB9ADJ7VR/+GcCASAYFQEJuxXvk1gWAbb4QW6OEu1E0NP/0wD0Bfhqf/hh+Gb4Yt76QNcNf5XU0dDTf9/XDACV1NHQ0gDf0VRxIMjPhYDKAHPPQM4B+gKAa89AyXP7APhKgQEA9IaVAdcLP3+TcHBw4pEgFwCEjigh+CO7myL4SoEBAPRbMPhq3iL4SoEBAPR8lQHXCz9/k3BwcOICNTMx6F8G+ELIy//4Rs8LAPhKAfQAye1Uf/hnAgEgGxkBCbjkYYdQGgC++EFujhLtRNDT/9MA9AX4an/4Yfhm+GLe1NH4RSBukjBw3vhCuvLgZfgA+ELIy//4Rs8LAPhKAfQAye1U+A8g+wQg0O0e7VPwAjD4QsjL//hGzwsA+EoB9ADJ7VR/+GcCAtoeHAEBSB0ALPhCyMv/+EbPCwD4SgH0AMntVPgP8gABAUgfAFhwItDWAjHSADDcIccA3CHXDR/yvFMR3cEEIoIQ/////byx8nwB8AH4R27yfA==", 886 | } 887 | 888 | // noinspection SpellCheckingInspection 889 | export const GiverV3Contract: ContractPackage = { 890 | abi: { 891 | "ABI version": 2, 892 | "version": "2.3", 893 | "header": [ 894 | "time", 895 | "expire" 896 | ], 897 | "functions": [ 898 | { 899 | "name": "sendTransaction", 900 | "inputs": [ 901 | { 902 | "name": "dest", 903 | "type": "address" 904 | }, 905 | { 906 | "name": "value", 907 | "type": "uint128" 908 | }, 909 | { 910 | "name": "bounce", 911 | "type": "bool" 912 | } 913 | ], 914 | "outputs": [] 915 | }, 916 | { 917 | "name": "getMessages", 918 | "inputs": [], 919 | "outputs": [ 920 | { 921 | "components": [ 922 | { 923 | "name": "hash", 924 | "type": "uint256" 925 | }, 926 | { 927 | "name": "expireAt", 928 | "type": "uint32" 929 | } 930 | ], 931 | "name": "messages", 932 | "type": "tuple[]" 933 | } 934 | ] 935 | }, 936 | { 937 | "name": "upgrade", 938 | "inputs": [ 939 | { 940 | "name": "newcode", 941 | "type": "cell" 942 | } 943 | ], 944 | "outputs": [] 945 | }, 946 | { 947 | "name": "constructor", 948 | "inputs": [], 949 | "outputs": [] 950 | } 951 | ], 952 | "data": [], 953 | "events": [], 954 | "fields": [ 955 | { 956 | "name": "_pubkey", 957 | "type": "uint256" 958 | }, 959 | { 960 | "name": "_constructorFlag", 961 | "type": "bool" 962 | }, 963 | { 964 | "name": "m_messages", 965 | "type": "map(uint256,uint32)" 966 | } 967 | ] 968 | }, 969 | tvc: "te6ccgECFwEAAwAAAgE0AwEBAcACAEPQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgBCSK7VMg4wMgwP/jAiDA/uMC8gsTBgUEAAAC3O1E0NdJwwH4ZiHbPNMAAY4XgwjXGCD4KMjOzsn5AFj4QiD4ZfkQ8qjeI/hFIG6SMHDe+EK68uBlIfkBItM/0x81MSD4I7zyuSH4SoMH9A5voTHy0Gb4ACH4SiLIyx9Zgwf0Q/hqXwPTHwHbPPI8CQcDSu1E0NdJwwH4ZiLQ1wsDqTgA3CHHAOMCIdcNH/K8IeMDAds88jwSEgcEUCCCEBcjDDq64wIgghAXMr/DuuMCIIIQMV75NbrjAiCCEGi1Xz+64wIPDAoIAiIw+EJu4wD4RvJz0fgA2zzyAAkWAUTtRNDXScIBjhdw7UTQ9AVt+GqAQPQO8r3XC//4YnD4Y+MNEQM8MPhG8uBM+EJu4wAhk9TR0N76QNN/0gDR2zzbPPIAEQsWAL5UcSDIz4WAygDPhEDOAfoCgGvPQMlz+wBw+Eoggwf0hpUgWNcLH5NtXyDikyJus44qJMId4wgkpDX4I7uaIPhKgwf0WzD4at5TEoMH9HyVIFjXCx+TbV8g4mwj4xhfCAN0MPhG8uBM+EJu4wDR2zwhjiIj0NMB+kAwMcjPhyDOghCXMr/DzwuBAW8iAssf9ADJcPsAkTDi4wDyABENFgGOcG1vAvhKIIMH9IaVIFjXCx+TbV8g4pMibrOOqFR0EG8C2zwBbyIhpFUggCD0Q28CNVMjgwf0fJUgWNcLH5NtXyDibDPoXwQOABBvIgHIy//LHwMmMPhG8uBM+EJu4wDU0ds82zzyABEQFgFq+EUgbpIwcN74Qrry4GX4ANs8+A8g+wTQIIs4rbNYxwWT103Q3tdM0O0e7VOCECyo3u/tQ9gWAB7tRNDT/9MAMfQE0fhq+GIACvhG8uBMAhD0pCD0vfLAThUUABRzb2wgMC42Ni4wARagLKje79s8+A/yABYAHPhK+ELIy//Pg/QAye1U", 970 | }; 971 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./account"; 2 | -------------------------------------------------------------------------------- /tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "target": "es2016", 5 | "module": "commonjs", 6 | "moduleResolution": "node", 7 | "esModuleInterop": true, 8 | "sourceMap": true, 9 | "declaration": true, 10 | "declarationMap": true, 11 | "removeComments": false, 12 | "strict": true, 13 | "noImplicitAny": true, 14 | "noImplicitReturns": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "noUnusedParameters": true, 17 | "noUnusedLocals": true, 18 | "forceConsistentCasingInFileNames": true, 19 | "lib": ["es2017", "esnext.asynciterable"], 20 | "types": [], 21 | "baseUrl": ".", 22 | "paths": { 23 | "*" : ["types/*"] 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./dist" 6 | }, 7 | "include": [ 8 | "src/**/*" 9 | ], 10 | "exclude": [ 11 | "**/__tests__", 12 | "**/__mocks__" 13 | ] 14 | } 15 | --------------------------------------------------------------------------------