@firmachain/firma-js 0.2.17 → 0.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +136 -136
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.js +16 -0
  5. package/dist/sdk/FirmaBankService.d.ts +15 -0
  6. package/dist/sdk/FirmaBankService.js +211 -0
  7. package/dist/sdk/FirmaChainService.d.ts +8 -0
  8. package/dist/sdk/FirmaChainService.js +86 -0
  9. package/dist/sdk/FirmaConfig.d.ts +16 -0
  10. package/dist/sdk/FirmaConfig.js +55 -0
  11. package/dist/sdk/FirmaContractService.d.ts +31 -0
  12. package/dist/sdk/FirmaContractService.js +413 -0
  13. package/dist/sdk/FirmaDistributionService.d.ts +31 -0
  14. package/dist/sdk/FirmaDistributionService.js +524 -0
  15. package/dist/sdk/FirmaFeeGrantService.d.ts +21 -0
  16. package/dist/sdk/FirmaFeeGrantService.js +341 -0
  17. package/dist/sdk/FirmaGovService.d.ts +35 -0
  18. package/dist/sdk/FirmaGovService.js +775 -0
  19. package/dist/sdk/FirmaIpfsService.d.ts +12 -0
  20. package/dist/sdk/FirmaIpfsService.js +185 -0
  21. package/dist/sdk/FirmaMobileSDK.d.ts +27 -0
  22. package/dist/sdk/FirmaMobileSDK.js +45 -0
  23. package/dist/sdk/FirmaNftService.d.ts +31 -0
  24. package/dist/sdk/FirmaNftService.js +372 -0
  25. package/dist/sdk/FirmaSDK.d.ts +29 -0
  26. package/dist/sdk/FirmaSDK.js +48 -0
  27. package/dist/sdk/FirmaSlashingService.d.ts +9 -0
  28. package/dist/sdk/FirmaSlashingService.js +105 -0
  29. package/dist/sdk/FirmaStakingService.d.ts +34 -0
  30. package/dist/sdk/FirmaStakingService.js +604 -0
  31. package/dist/sdk/FirmaTokenService.d.ts +26 -0
  32. package/dist/sdk/FirmaTokenService.js +416 -0
  33. package/dist/sdk/FirmaUtil.d.ts +26 -0
  34. package/dist/sdk/FirmaUtil.js +210 -0
  35. package/dist/sdk/FirmaWalletService.d.ts +36 -0
  36. package/dist/sdk/FirmaWalletService.js +309 -0
  37. package/dist/sdk/firmachain/amino/addresses.d.ts +5 -0
  38. package/dist/sdk/firmachain/amino/addresses.js +46 -0
  39. package/dist/sdk/firmachain/amino/aminomsgs.d.ts +281 -0
  40. package/dist/sdk/firmachain/amino/aminomsgs.js +77 -0
  41. package/dist/sdk/firmachain/amino/aminotypes.d.ts +22 -0
  42. package/dist/sdk/firmachain/amino/aminotypes.js +521 -0
  43. package/dist/sdk/firmachain/amino/coins.d.ts +30 -0
  44. package/dist/sdk/firmachain/amino/coins.js +69 -0
  45. package/dist/sdk/firmachain/amino/encoding.d.ts +24 -0
  46. package/dist/sdk/firmachain/amino/encoding.js +234 -0
  47. package/dist/sdk/firmachain/amino/multisig.d.ts +10 -0
  48. package/dist/sdk/firmachain/amino/multisig.js +42 -0
  49. package/dist/sdk/firmachain/amino/paths.d.ts +6 -0
  50. package/dist/sdk/firmachain/amino/paths.js +18 -0
  51. package/dist/sdk/firmachain/amino/pubkeys.d.ts +47 -0
  52. package/dist/sdk/firmachain/amino/pubkeys.js +29 -0
  53. package/dist/sdk/firmachain/amino/secp256k1hdwallet.d.ts +94 -0
  54. package/dist/sdk/firmachain/amino/secp256k1hdwallet.js +437 -0
  55. package/dist/sdk/firmachain/amino/secp256k1wallet.d.ts +23 -0
  56. package/dist/sdk/firmachain/amino/secp256k1wallet.js +141 -0
  57. package/dist/sdk/firmachain/amino/signature.d.ts +16 -0
  58. package/dist/sdk/firmachain/amino/signature.js +36 -0
  59. package/dist/sdk/firmachain/amino/signdoc.d.ts +26 -0
  60. package/dist/sdk/firmachain/amino/signdoc.js +42 -0
  61. package/dist/sdk/firmachain/amino/signer.d.ts +33 -0
  62. package/dist/sdk/firmachain/amino/signer.js +2 -0
  63. package/dist/sdk/firmachain/amino/stdtx.d.ts +15 -0
  64. package/dist/sdk/firmachain/amino/stdtx.js +17 -0
  65. package/dist/sdk/firmachain/amino/wallet.d.ts +32 -0
  66. package/dist/sdk/firmachain/amino/wallet.js +132 -0
  67. package/dist/sdk/firmachain/bank/BankQueryClient.d.ts +12 -0
  68. package/dist/sdk/firmachain/bank/BankQueryClient.js +116 -0
  69. package/dist/sdk/firmachain/bank/BankTxClient.d.ts +17 -0
  70. package/dist/sdk/firmachain/bank/BankTxClient.js +40 -0
  71. package/dist/sdk/firmachain/bank/index.d.ts +3 -0
  72. package/dist/sdk/firmachain/bank/index.js +15 -0
  73. package/dist/sdk/firmachain/common/ITxClient.d.ts +15 -0
  74. package/dist/sdk/firmachain/common/ITxClient.js +102 -0
  75. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.d.ts +27 -0
  76. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +165 -0
  77. package/dist/sdk/firmachain/common/LedgerWallet.d.ts +14 -0
  78. package/dist/sdk/firmachain/common/LedgerWallet.js +147 -0
  79. package/dist/sdk/firmachain/common/QueryCommon.d.ts +4 -0
  80. package/dist/sdk/firmachain/common/QueryCommon.js +2 -0
  81. package/dist/sdk/firmachain/common/TendermintQueryClient.d.ts +42 -0
  82. package/dist/sdk/firmachain/common/TendermintQueryClient.js +108 -0
  83. package/dist/sdk/firmachain/common/TxCommon.d.ts +94 -0
  84. package/dist/sdk/firmachain/common/TxCommon.js +34 -0
  85. package/dist/sdk/firmachain/common/accounts.d.ts +16 -0
  86. package/dist/sdk/firmachain/common/accounts.js +64 -0
  87. package/dist/sdk/firmachain/common/index.d.ts +2 -0
  88. package/dist/sdk/firmachain/common/index.js +14 -0
  89. package/dist/sdk/firmachain/common/signing.d.ts +10 -0
  90. package/dist/sdk/firmachain/common/signing.js +75 -0
  91. package/dist/sdk/firmachain/common/signingstargateclient.d.ts +37 -0
  92. package/dist/sdk/firmachain/common/signingstargateclient.js +298 -0
  93. package/dist/sdk/firmachain/common/stargateclient.d.ts +46 -0
  94. package/dist/sdk/firmachain/common/stargateclient.js +211 -0
  95. package/dist/sdk/firmachain/contract/ContractQueryClient.d.ts +32 -0
  96. package/dist/sdk/firmachain/contract/ContractQueryClient.js +156 -0
  97. package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +17 -0
  98. package/dist/sdk/firmachain/contract/ContractTxClient.js +40 -0
  99. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +69 -0
  100. package/dist/sdk/firmachain/contract/ContractTxTypes.js +483 -0
  101. package/dist/sdk/firmachain/contract/index.d.ts +3 -0
  102. package/dist/sdk/firmachain/contract/index.js +15 -0
  103. package/dist/sdk/firmachain/distribution/DistributionQueryClient.d.ts +18 -0
  104. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +167 -0
  105. package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +27 -0
  106. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +48 -0
  107. package/dist/sdk/firmachain/distribution/index.d.ts +3 -0
  108. package/dist/sdk/firmachain/distribution/index.js +15 -0
  109. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.d.ts +17 -0
  110. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +86 -0
  111. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +17 -0
  112. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +40 -0
  113. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +76 -0
  114. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +194 -0
  115. package/dist/sdk/firmachain/feegrant/index.d.ts +2 -0
  116. package/dist/sdk/firmachain/feegrant/index.js +15 -0
  117. package/dist/sdk/firmachain/google/protobuf/any.d.ts +128 -0
  118. package/dist/sdk/firmachain/google/protobuf/any.js +106 -0
  119. package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +996 -0
  120. package/dist/sdk/firmachain/google/protobuf/descriptor.js +5329 -0
  121. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +91 -0
  122. package/dist/sdk/firmachain/google/protobuf/duration.js +107 -0
  123. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +109 -0
  124. package/dist/sdk/firmachain/google/protobuf/timestamp.js +107 -0
  125. package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +61 -0
  126. package/dist/sdk/firmachain/gov/GovQueryClient.js +152 -0
  127. package/dist/sdk/firmachain/gov/GovTxClient.d.ts +22 -0
  128. package/dist/sdk/firmachain/gov/GovTxClient.js +44 -0
  129. package/dist/sdk/firmachain/gov/index.d.ts +3 -0
  130. package/dist/sdk/firmachain/gov/index.js +15 -0
  131. package/dist/sdk/firmachain/nft/NftQueryClient.d.ts +20 -0
  132. package/dist/sdk/firmachain/nft/NftQueryClient.js +125 -0
  133. package/dist/sdk/firmachain/nft/NftTxClient.d.ts +22 -0
  134. package/dist/sdk/firmachain/nft/NftTxClient.js +44 -0
  135. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +86 -0
  136. package/dist/sdk/firmachain/nft/NftTxTypes.js +424 -0
  137. package/dist/sdk/firmachain/nft/index.d.ts +3 -0
  138. package/dist/sdk/firmachain/nft/index.js +15 -0
  139. package/dist/sdk/firmachain/slashing/SlashingQueryClient.d.ts +22 -0
  140. package/dist/sdk/firmachain/slashing/SlashingQueryClient.js +101 -0
  141. package/dist/sdk/firmachain/slashing/index.d.ts +2 -0
  142. package/dist/sdk/firmachain/slashing/index.js +14 -0
  143. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +93 -0
  144. package/dist/sdk/firmachain/staking/StakingQueryClient.js +223 -0
  145. package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +32 -0
  146. package/dist/sdk/firmachain/staking/StakingTxClient.js +52 -0
  147. package/dist/sdk/firmachain/staking/index.d.ts +3 -0
  148. package/dist/sdk/firmachain/staking/index.js +15 -0
  149. package/dist/sdk/firmachain/token/TokenQueryClient.d.ts +24 -0
  150. package/dist/sdk/firmachain/token/TokenQueryClient.js +106 -0
  151. package/dist/sdk/firmachain/token/TokenTxClient.d.ts +27 -0
  152. package/dist/sdk/firmachain/token/TokenTxClient.js +48 -0
  153. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +116 -0
  154. package/dist/sdk/firmachain/token/TokenTxTypes.js +685 -0
  155. package/dist/sdk/firmachain/token/index.d.ts +3 -0
  156. package/dist/sdk/firmachain/token/index.js +15 -0
  157. package/package.json +54 -54
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 FirmaChain, PTE.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2021 FirmaChain, PTE.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,137 +1,137 @@
1
- # firma-js
2
-
3
- [![npm version](https://badge.fury.io/js/%40firmachain%2Ffirma-js.svg)](https://badge.fury.io/js/%40firmachain%2Ffirma-js)
4
- [![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/firmachain/firma-js)](https://github.com/firmachain/firma-js/releases)
5
- [![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/firmachain/firma-js/blob/master/LICENSE)
6
- ![Lines of code](https://img.shields.io/tokei/lines/github/firmachain/firma-js)
7
-
8
- The Javascript & TypeScript SDK for FirmaChain
9
-
10
- Firma-js is a SDK for writing applications based on javascript & typescript. You can use it client web app or Node.js. This SDK is created inspired by cosmjs and several sdk. All functions of the FirmaChain can be accessed at the service level.
11
-
12
- ## Features
13
- Most cosmos sdk features are supported
14
- - Wallet / Bank
15
- - Nft / Contract
16
- - Ipfs / Gov
17
- - Staking / Distribution
18
- - Feegrant ...and so one
19
-
20
- </br>
21
-
22
-
23
- ## Install
24
- You can install `firma-js` using [NPM](https://www.npmjs.com/package/@firmachain/firma-js)
25
- ```
26
- yarn add @firmachain/firma-js
27
- ```
28
- or
29
- ```
30
- npm i @firmachain/firma-js
31
- ```
32
-
33
- ## Usage
34
- ### Initializing SDK
35
- ```js
36
- import { FirmaSDK } from "@firmachain/firma-js"
37
- import { FirmaConfig } from "@firmachain/firma-js"
38
-
39
- // use preset config
40
- const firma = new FirmaSDK(FirmaConfig.TestNetConfig);
41
-
42
- // or use custom set
43
- let chainConfig = {
44
- chainID: "imperium-2",
45
- rpcAddress: "http://127.0.0.1:26657",
46
- restApiAddress: "http://127.0.0.1:1317",
47
- ipfsNodeAddress: "ipfs-api-firma-devnet.firmachain.org",
48
- ipfsNodePort: 5001,
49
- ipfsWebApiAddress: "https://ipfs-firma-devnet.firmachain.org",
50
- hdPath: "m/44'/7777777'/",
51
- prefix: "firma",
52
- denom: "ufct",
53
- isShowLog: true,
54
- }
55
-
56
- const firma = new FirmaSDK(chainConfig);
57
-
58
- ```
59
-
60
- ### Create wallet account
61
- ```js
62
- // create new wallet
63
- const newWallet = await firma.Wallet.newWallet();
64
-
65
- // generateMnemonic
66
- const mnemonic = await firma.Wallet.generateMnemonic();
67
- const index = 0;
68
-
69
- // or from mnemonic
70
- const wallet = await firma.Wallet.fromMnemonic(mnemonic, index);
71
- console.log(await wallet.getAddress());
72
- ```
73
-
74
- ### Import account by private key
75
- ```js
76
- const privateKey = wallet.getPrivateKey();
77
- const wallet1 = await firma.Wallet.fromPrivateKey(privateKey);
78
- ```
79
-
80
- ### Get chaion status (include height, time etc)
81
- ```js
82
- const result = await firma.Chain.getChainStatus();
83
- console.log(result);
84
- ```
85
-
86
- ### Get FIRMA balance of specific account
87
- ```js
88
- const address = await wallet.getAddress();
89
- const balance = await firma.Bank.getBalance(address);
90
- console.log("balance: " + balance);
91
- ```
92
-
93
- ### Get transaction by hash
94
- ```js
95
- const txHash = "0xC5509A32CF57798F8C3185DFAF03BD2D09DFC04FE842283ECA9298F5F60E340F";
96
- const result = await firma.Chain.getTransactionByHash(txHash);
97
- console.log(result);
98
- ```
99
-
100
- ### Bank send - create tx and broadcast
101
- ```js
102
- const fctAmount = 10;
103
- let result = await firma.Bank.send(wallet, address, fctAmount);
104
- ```
105
-
106
- ### Bank send - extended version
107
- ```js
108
- const fctAmount = 10;
109
- let result = await firma.Bank.send(wallet, address, fctAmount, { memo: "", fee: 3000, gas: 200000 });
110
- ```
111
-
112
- ### Calculate gas
113
- ```js
114
- let gas = await firma.Bank.getGasEstimationSend(wallet, address, fctAmount);
115
- ```
116
-
117
- ### Mint NFT
118
- ```js
119
- const tokenURI = "https://ipfs-firma-devnet.firmachain.org/ipfs/QmYsezxzunake9EmyoU4HsWKEyHQLgE3syTEpTSQEhNChA";
120
- let result = await firma.Nft.mint(wallet, tokenURI);
121
- ```
122
-
123
- ### Transfer NFT
124
- ```js
125
- const tokenId = 1;
126
- let result = await firma.Nft.transfer(wallet, address, tokenId);
127
- ```
128
-
129
- ### Burn NFT
130
- ```js
131
- const tokenId = 1;
132
- let result = await firma.Nft.burn(wallet, tokenId);
133
- ```
134
-
135
- You can see everything usage of firma-js on the test folder.
136
- </br>
1
+ # firma-js
2
+
3
+ [![npm version](https://badge.fury.io/js/%40firmachain%2Ffirma-js.svg)](https://badge.fury.io/js/%40firmachain%2Ffirma-js)
4
+ [![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/firmachain/firma-js)](https://github.com/firmachain/firma-js/releases)
5
+ [![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/firmachain/firma-js/blob/master/LICENSE)
6
+ ![Lines of code](https://img.shields.io/tokei/lines/github/firmachain/firma-js)
7
+
8
+ The Javascript & TypeScript SDK for FirmaChain
9
+
10
+ Firma-js is a SDK for writing applications based on javascript & typescript. You can use it client web app or Node.js. This SDK is created inspired by cosmjs and several sdk. All functions of the FirmaChain can be accessed at the service level.
11
+
12
+ ## Features
13
+ Most cosmos sdk features are supported
14
+ - Wallet / Bank
15
+ - Nft / Contract
16
+ - Ipfs / Gov
17
+ - Staking / Distribution
18
+ - Feegrant ...and so one
19
+
20
+ </br>
21
+
22
+
23
+ ## Install
24
+ You can install `firma-js` using [NPM](https://www.npmjs.com/package/@firmachain/firma-js)
25
+ ```
26
+ yarn add @firmachain/firma-js
27
+ ```
28
+ or
29
+ ```
30
+ npm i @firmachain/firma-js
31
+ ```
32
+
33
+ ## Usage
34
+ ### Initializing SDK
35
+ ```js
36
+ import { FirmaSDK } from "@firmachain/firma-js"
37
+ import { FirmaConfig } from "@firmachain/firma-js"
38
+
39
+ // use preset config
40
+ const firma = new FirmaSDK(FirmaConfig.TestNetConfig);
41
+
42
+ // or use custom set
43
+ let chainConfig = {
44
+ chainID: "imperium-2",
45
+ rpcAddress: "http://127.0.0.1:26657",
46
+ restApiAddress: "http://127.0.0.1:1317",
47
+ ipfsNodeAddress: "ipfs-api-firma-devnet.firmachain.org",
48
+ ipfsNodePort: 5001,
49
+ ipfsWebApiAddress: "https://ipfs-firma-devnet.firmachain.org",
50
+ hdPath: "m/44'/7777777'/",
51
+ prefix: "firma",
52
+ denom: "ufct",
53
+ isShowLog: true,
54
+ }
55
+
56
+ const firma = new FirmaSDK(chainConfig);
57
+
58
+ ```
59
+
60
+ ### Create wallet account
61
+ ```js
62
+ // create new wallet
63
+ const newWallet = await firma.Wallet.newWallet();
64
+
65
+ // generateMnemonic
66
+ const mnemonic = await firma.Wallet.generateMnemonic();
67
+ const index = 0;
68
+
69
+ // or from mnemonic
70
+ const wallet = await firma.Wallet.fromMnemonic(mnemonic, index);
71
+ console.log(await wallet.getAddress());
72
+ ```
73
+
74
+ ### Import account by private key
75
+ ```js
76
+ const privateKey = wallet.getPrivateKey();
77
+ const wallet1 = await firma.Wallet.fromPrivateKey(privateKey);
78
+ ```
79
+
80
+ ### Get chaion status (include height, time etc)
81
+ ```js
82
+ const result = await firma.Chain.getChainStatus();
83
+ console.log(result);
84
+ ```
85
+
86
+ ### Get FIRMA balance of specific account
87
+ ```js
88
+ const address = await wallet.getAddress();
89
+ const balance = await firma.Bank.getBalance(address);
90
+ console.log("balance: " + balance);
91
+ ```
92
+
93
+ ### Get transaction by hash
94
+ ```js
95
+ const txHash = "0xC5509A32CF57798F8C3185DFAF03BD2D09DFC04FE842283ECA9298F5F60E340F";
96
+ const result = await firma.Chain.getTransactionByHash(txHash);
97
+ console.log(result);
98
+ ```
99
+
100
+ ### Bank send - create tx and broadcast
101
+ ```js
102
+ const fctAmount = 10;
103
+ let result = await firma.Bank.send(wallet, address, fctAmount);
104
+ ```
105
+
106
+ ### Bank send - extended version
107
+ ```js
108
+ const fctAmount = 10;
109
+ let result = await firma.Bank.send(wallet, address, fctAmount, { memo: "", fee: 3000, gas: 200000 });
110
+ ```
111
+
112
+ ### Calculate gas
113
+ ```js
114
+ let gas = await firma.Bank.getGasEstimationSend(wallet, address, fctAmount);
115
+ ```
116
+
117
+ ### Mint NFT
118
+ ```js
119
+ const tokenURI = "https://ipfs-firma-devnet.firmachain.org/ipfs/QmYsezxzunake9EmyoU4HsWKEyHQLgE3syTEpTSQEhNChA";
120
+ let result = await firma.Nft.mint(wallet, tokenURI);
121
+ ```
122
+
123
+ ### Transfer NFT
124
+ ```js
125
+ const tokenId = 1;
126
+ let result = await firma.Nft.transfer(wallet, address, tokenId);
127
+ ```
128
+
129
+ ### Burn NFT
130
+ ```js
131
+ const tokenId = 1;
132
+ let result = await firma.Nft.burn(wallet, tokenId);
133
+ ```
134
+
135
+ You can see everything usage of firma-js on the test folder.
136
+ </br>
137
137
  https://github.com/FirmaChain/firma-js/tree/main/test
@@ -0,0 +1,4 @@
1
+ export * from './sdk/FirmaSDK';
2
+ export * from './sdk/FirmaMobileSDK';
3
+ export * from './sdk/FirmaConfig';
4
+ export * from './sdk/FirmaUtil';
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./sdk/FirmaSDK"), exports);
14
+ __exportStar(require("./sdk/FirmaMobileSDK"), exports);
15
+ __exportStar(require("./sdk/FirmaConfig"), exports);
16
+ __exportStar(require("./sdk/FirmaUtil"), exports);
@@ -0,0 +1,15 @@
1
+ import { TxMisc, Token } from "./firmachain/bank";
2
+ import { FirmaWalletService } from "./FirmaWalletService";
3
+ import { FirmaConfig } from "./FirmaConfig";
4
+ import { BroadcastTxResponse } from "./firmachain/common/stargateclient";
5
+ export declare class FirmaBankService {
6
+ private readonly config;
7
+ constructor(config: FirmaConfig);
8
+ getGasEstimationSend(wallet: FirmaWalletService, targetAddress: string, amount: number, txMisc?: TxMisc): Promise<number>;
9
+ sendToken(wallet: FirmaWalletService, targetAddress: string, tokenID: string, amount: number, decimal: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
10
+ send(wallet: FirmaWalletService, targetAddress: string, amount: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
11
+ getTokenBalanceList(address: string): Promise<Token[]>;
12
+ getTokenBalance(address: string, tokenID: string): Promise<string>;
13
+ getBalance(address: string): Promise<string>;
14
+ private getSignedTxSend;
15
+ }
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.FirmaBankService = void 0;
40
+ var bank_1 = require("./firmachain/bank");
41
+ var FirmaUtil_1 = require("./FirmaUtil");
42
+ var FirmaBankService = /** @class */ (function () {
43
+ function FirmaBankService(config) {
44
+ this.config = config;
45
+ }
46
+ FirmaBankService.prototype.getGasEstimationSend = function (wallet, targetAddress, amount, txMisc) {
47
+ if (txMisc === void 0) { txMisc = bank_1.DefaultTxMisc; }
48
+ return __awaiter(this, void 0, void 0, function () {
49
+ var txRaw, error_1;
50
+ return __generator(this, function (_a) {
51
+ switch (_a.label) {
52
+ case 0:
53
+ _a.trys.push([0, 3, , 4]);
54
+ return [4 /*yield*/, this.getSignedTxSend(wallet, targetAddress, this.config.denom, FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount), txMisc)];
55
+ case 1:
56
+ txRaw = _a.sent();
57
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
58
+ case 2: return [2 /*return*/, _a.sent()];
59
+ case 3:
60
+ error_1 = _a.sent();
61
+ FirmaUtil_1.FirmaUtil.printLog(error_1);
62
+ throw error_1;
63
+ case 4: return [2 /*return*/];
64
+ }
65
+ });
66
+ });
67
+ };
68
+ FirmaBankService.prototype.sendToken = function (wallet, targetAddress, tokenID, amount, decimal, txMisc) {
69
+ if (txMisc === void 0) { txMisc = bank_1.DefaultTxMisc; }
70
+ return __awaiter(this, void 0, void 0, function () {
71
+ var txRaw, bankTxClient, error_2;
72
+ return __generator(this, function (_a) {
73
+ switch (_a.label) {
74
+ case 0:
75
+ _a.trys.push([0, 3, , 4]);
76
+ return [4 /*yield*/, this.getSignedTxSend(wallet, targetAddress, tokenID, FirmaUtil_1.FirmaUtil.getUTokenStringFromToken(amount, decimal), txMisc)];
77
+ case 1:
78
+ txRaw = _a.sent();
79
+ bankTxClient = new bank_1.BankTxClient(wallet, this.config.rpcAddress);
80
+ return [4 /*yield*/, bankTxClient.broadcast(txRaw)];
81
+ case 2: return [2 /*return*/, _a.sent()];
82
+ case 3:
83
+ error_2 = _a.sent();
84
+ FirmaUtil_1.FirmaUtil.printLog(error_2);
85
+ throw error_2;
86
+ case 4: return [2 /*return*/];
87
+ }
88
+ });
89
+ });
90
+ };
91
+ FirmaBankService.prototype.send = function (wallet, targetAddress, amount, txMisc) {
92
+ if (txMisc === void 0) { txMisc = bank_1.DefaultTxMisc; }
93
+ return __awaiter(this, void 0, void 0, function () {
94
+ var txRaw, bankTxClient, error_3;
95
+ return __generator(this, function (_a) {
96
+ switch (_a.label) {
97
+ case 0:
98
+ _a.trys.push([0, 3, , 4]);
99
+ return [4 /*yield*/, this.getSignedTxSend(wallet, targetAddress, this.config.denom, FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount), txMisc)];
100
+ case 1:
101
+ txRaw = _a.sent();
102
+ bankTxClient = new bank_1.BankTxClient(wallet, this.config.rpcAddress);
103
+ return [4 /*yield*/, bankTxClient.broadcast(txRaw)];
104
+ case 2: return [2 /*return*/, _a.sent()];
105
+ case 3:
106
+ error_3 = _a.sent();
107
+ FirmaUtil_1.FirmaUtil.printLog(error_3);
108
+ throw error_3;
109
+ case 4: return [2 /*return*/];
110
+ }
111
+ });
112
+ });
113
+ };
114
+ FirmaBankService.prototype.getTokenBalanceList = function (address) {
115
+ return __awaiter(this, void 0, void 0, function () {
116
+ var bankQueryClient, result, tokenList, i, error_4;
117
+ return __generator(this, function (_a) {
118
+ switch (_a.label) {
119
+ case 0:
120
+ _a.trys.push([0, 2, , 3]);
121
+ bankQueryClient = new bank_1.BankQueryClient(this.config.restApiAddress);
122
+ return [4 /*yield*/, bankQueryClient.queryBalanceList(address)];
123
+ case 1:
124
+ result = _a.sent();
125
+ tokenList = [];
126
+ for (i = 0; i < result.length; i++) {
127
+ // ignore config.denom
128
+ if (result[i].denom === this.config.denom)
129
+ continue;
130
+ tokenList.push(result[i]);
131
+ }
132
+ return [2 /*return*/, tokenList];
133
+ case 2:
134
+ error_4 = _a.sent();
135
+ FirmaUtil_1.FirmaUtil.printLog(error_4);
136
+ throw error_4;
137
+ case 3: return [2 /*return*/];
138
+ }
139
+ });
140
+ });
141
+ };
142
+ FirmaBankService.prototype.getTokenBalance = function (address, tokenID) {
143
+ return __awaiter(this, void 0, void 0, function () {
144
+ var bankQueryClient, result, error_5;
145
+ return __generator(this, function (_a) {
146
+ switch (_a.label) {
147
+ case 0:
148
+ _a.trys.push([0, 2, , 3]);
149
+ bankQueryClient = new bank_1.BankQueryClient(this.config.restApiAddress);
150
+ return [4 /*yield*/, bankQueryClient.queryTokenBalance(address, tokenID)];
151
+ case 1:
152
+ result = _a.sent();
153
+ return [2 /*return*/, result.amount];
154
+ case 2:
155
+ error_5 = _a.sent();
156
+ FirmaUtil_1.FirmaUtil.printLog(error_5);
157
+ throw error_5;
158
+ case 3: return [2 /*return*/];
159
+ }
160
+ });
161
+ });
162
+ };
163
+ FirmaBankService.prototype.getBalance = function (address) {
164
+ return __awaiter(this, void 0, void 0, function () {
165
+ var bankQueryClient, result, error_6;
166
+ return __generator(this, function (_a) {
167
+ switch (_a.label) {
168
+ case 0:
169
+ _a.trys.push([0, 2, , 3]);
170
+ bankQueryClient = new bank_1.BankQueryClient(this.config.restApiAddress);
171
+ return [4 /*yield*/, bankQueryClient.queryBalance(address, this.config.denom)];
172
+ case 1:
173
+ result = _a.sent();
174
+ return [2 /*return*/, result.amount];
175
+ case 2:
176
+ error_6 = _a.sent();
177
+ FirmaUtil_1.FirmaUtil.printLog(error_6);
178
+ throw error_6;
179
+ case 3: return [2 /*return*/];
180
+ }
181
+ });
182
+ });
183
+ };
184
+ FirmaBankService.prototype.getSignedTxSend = function (wallet, targetAddress, denom, amount, txMisc) {
185
+ if (txMisc === void 0) { txMisc = bank_1.DefaultTxMisc; }
186
+ return __awaiter(this, void 0, void 0, function () {
187
+ var bankTxClient, address, sendAmount, message, error_7;
188
+ return __generator(this, function (_a) {
189
+ switch (_a.label) {
190
+ case 0:
191
+ _a.trys.push([0, 3, , 4]);
192
+ bankTxClient = new bank_1.BankTxClient(wallet, this.config.rpcAddress);
193
+ return [4 /*yield*/, wallet.getAddress()];
194
+ case 1:
195
+ address = _a.sent();
196
+ sendAmount = { denom: denom, amount: amount };
197
+ message = bankTxClient.msgSend({ fromAddress: address, toAddress: targetAddress, amount: [sendAmount] });
198
+ return [4 /*yield*/, bankTxClient.sign([message], bank_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
199
+ case 2: return [2 /*return*/, _a.sent()];
200
+ case 3:
201
+ error_7 = _a.sent();
202
+ FirmaUtil_1.FirmaUtil.printLog(error_7);
203
+ throw error_7;
204
+ case 4: return [2 /*return*/];
205
+ }
206
+ });
207
+ });
208
+ };
209
+ return FirmaBankService;
210
+ }());
211
+ exports.FirmaBankService = FirmaBankService;
@@ -0,0 +1,8 @@
1
+ import { FirmaConfig } from "./FirmaConfig";
2
+ import { ChainSyncInfo, TransactionHash } from "./firmachain/common/TendermintQueryClient";
3
+ export declare class ChainService {
4
+ private readonly config;
5
+ constructor(config: FirmaConfig);
6
+ getChainSyncInfo(): Promise<ChainSyncInfo>;
7
+ getTransactionByHash(txHash: string): Promise<TransactionHash>;
8
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ChainService = void 0;
40
+ var FirmaUtil_1 = require("./FirmaUtil");
41
+ var TendermintQueryClient_1 = require("./firmachain/common/TendermintQueryClient");
42
+ var ChainService = /** @class */ (function () {
43
+ function ChainService(config) {
44
+ this.config = config;
45
+ }
46
+ ChainService.prototype.getChainSyncInfo = function () {
47
+ return __awaiter(this, void 0, void 0, function () {
48
+ var queryClient, error_1;
49
+ return __generator(this, function (_a) {
50
+ switch (_a.label) {
51
+ case 0:
52
+ _a.trys.push([0, 2, , 3]);
53
+ queryClient = new TendermintQueryClient_1.TendermintQueryClient(this.config.rpcAddress);
54
+ return [4 /*yield*/, queryClient.queryChainSyncInfo()];
55
+ case 1: return [2 /*return*/, _a.sent()];
56
+ case 2:
57
+ error_1 = _a.sent();
58
+ FirmaUtil_1.FirmaUtil.printLog(error_1);
59
+ throw error_1;
60
+ case 3: return [2 /*return*/];
61
+ }
62
+ });
63
+ });
64
+ };
65
+ ChainService.prototype.getTransactionByHash = function (txHash) {
66
+ return __awaiter(this, void 0, void 0, function () {
67
+ var queryClient, error_2;
68
+ return __generator(this, function (_a) {
69
+ switch (_a.label) {
70
+ case 0:
71
+ _a.trys.push([0, 2, , 3]);
72
+ queryClient = new TendermintQueryClient_1.TendermintQueryClient(this.config.rpcAddress);
73
+ return [4 /*yield*/, queryClient.queryTransactionHash(txHash)];
74
+ case 1: return [2 /*return*/, _a.sent()];
75
+ case 2:
76
+ error_2 = _a.sent();
77
+ FirmaUtil_1.FirmaUtil.printLog(error_2);
78
+ throw error_2;
79
+ case 3: return [2 /*return*/];
80
+ }
81
+ });
82
+ });
83
+ };
84
+ return ChainService;
85
+ }());
86
+ exports.ChainService = ChainService;