@firmachain/firma-js 0.2.64 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/README.md +1 -1
  2. package/dist/sdk/FirmaAuthzService.d.ts +8 -8
  3. package/dist/sdk/FirmaAuthzService.js +12 -6
  4. package/dist/sdk/FirmaBankService.d.ts +4 -4
  5. package/dist/sdk/FirmaContractService.d.ts +4 -4
  6. package/dist/sdk/FirmaCosmWasmCw20.d.ts +14 -14
  7. package/dist/sdk/FirmaCosmWasmCw721.d.ts +14 -14
  8. package/dist/sdk/FirmaCosmWasmCwBridge.d.ts +9 -9
  9. package/dist/sdk/FirmaCosmWasmCwMarketplace.d.ts +8 -8
  10. package/dist/sdk/FirmaCosmWasmService.d.ts +8 -8
  11. package/dist/sdk/FirmaCosmWasmService.js +2 -3
  12. package/dist/sdk/FirmaDistributionService.d.ts +6 -6
  13. package/dist/sdk/FirmaFeeGrantService.d.ts +4 -4
  14. package/dist/sdk/FirmaGovService.d.ts +27 -16
  15. package/dist/sdk/FirmaGovService.js +305 -195
  16. package/dist/sdk/FirmaIbcService.d.ts +3 -4
  17. package/dist/sdk/FirmaIbcService.js +5 -2
  18. package/dist/sdk/FirmaNftService.d.ts +5 -5
  19. package/dist/sdk/FirmaStakingService.d.ts +6 -6
  20. package/dist/sdk/FirmaTokenService.d.ts +5 -5
  21. package/dist/sdk/FirmaUtil.d.ts +1 -1
  22. package/dist/sdk/FirmaUtil.js +12 -14
  23. package/dist/sdk/firmachain/amino/addresses.js +1 -1
  24. package/dist/sdk/firmachain/amino/aminomsgs.d.ts +10 -0
  25. package/dist/sdk/firmachain/amino/aminomsgs.js +5 -1
  26. package/dist/sdk/firmachain/amino/aminotypes.js +27 -10
  27. package/dist/sdk/firmachain/amino/coins.d.ts +14 -2
  28. package/dist/sdk/firmachain/amino/coins.js +26 -5
  29. package/dist/sdk/firmachain/amino/encoding.d.ts +10 -1
  30. package/dist/sdk/firmachain/amino/encoding.js +21 -3
  31. package/dist/sdk/firmachain/amino/signdoc.d.ts +21 -3
  32. package/dist/sdk/firmachain/amino/signdoc.js +37 -11
  33. package/dist/sdk/firmachain/amino/signer.d.ts +2 -1
  34. package/dist/sdk/firmachain/authz/AuthzTxTypes.d.ts +7 -6
  35. package/dist/sdk/firmachain/authz/AuthzTxTypes.js +7 -6
  36. package/dist/sdk/firmachain/bank/BankQueryClient.js +1 -1
  37. package/dist/sdk/firmachain/common/CommonTxClient.js +11 -9
  38. package/dist/sdk/firmachain/common/ITxClient.d.ts +6 -6
  39. package/dist/sdk/firmachain/common/ITxClient.js +82 -24
  40. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.d.ts +4 -9
  41. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +37 -32
  42. package/dist/sdk/firmachain/common/LedgerWallet.js +4 -8
  43. package/dist/sdk/firmachain/common/TxCommon.d.ts +1 -2
  44. package/dist/sdk/firmachain/common/accounts.d.ts +7 -3
  45. package/dist/sdk/firmachain/common/accounts.js +28 -33
  46. package/dist/sdk/firmachain/common/aminotypes.d.ts +19 -0
  47. package/dist/sdk/firmachain/common/aminotypes.js +74 -0
  48. package/dist/sdk/firmachain/common/events.d.ts +32 -0
  49. package/dist/sdk/firmachain/common/events.js +18 -0
  50. package/dist/sdk/firmachain/common/fee.d.ts +26 -0
  51. package/dist/sdk/firmachain/common/fee.js +83 -0
  52. package/dist/sdk/firmachain/common/index.d.ts +1 -0
  53. package/dist/sdk/firmachain/common/index.js +3 -0
  54. package/dist/sdk/firmachain/common/modules/auth/queries.d.ts +15 -0
  55. package/dist/sdk/firmachain/common/modules/auth/queries.js +64 -0
  56. package/dist/sdk/firmachain/common/modules/authz/aminomessages.d.ts +2 -0
  57. package/dist/sdk/firmachain/common/modules/authz/aminomessages.js +15 -0
  58. package/dist/sdk/firmachain/common/modules/authz/messages.d.ts +2 -0
  59. package/dist/sdk/firmachain/common/modules/authz/messages.js +9 -0
  60. package/dist/sdk/firmachain/common/modules/authz/queries.d.ts +10 -0
  61. package/dist/sdk/firmachain/common/modules/authz/queries.js +88 -0
  62. package/dist/sdk/firmachain/common/modules/bank/aminomessages.d.ts +35 -0
  63. package/dist/sdk/firmachain/common/modules/bank/aminomessages.js +85 -0
  64. package/dist/sdk/firmachain/common/modules/bank/messages.d.ts +8 -0
  65. package/dist/sdk/firmachain/common/modules/bank/messages.js +12 -0
  66. package/dist/sdk/firmachain/common/modules/bank/queries.d.ts +15 -0
  67. package/dist/sdk/firmachain/common/modules/bank/queries.js +128 -0
  68. package/dist/sdk/firmachain/common/modules/crisis/aminomessages.d.ts +14 -0
  69. package/dist/sdk/firmachain/common/modules/crisis/aminomessages.js +11 -0
  70. package/dist/sdk/firmachain/common/modules/distribution/aminomessages.d.ts +44 -0
  71. package/dist/sdk/firmachain/common/modules/distribution/aminomessages.js +113 -0
  72. package/dist/sdk/firmachain/common/modules/distribution/messages.d.ts +8 -0
  73. package/dist/sdk/firmachain/common/modules/distribution/messages.js +15 -0
  74. package/dist/sdk/firmachain/common/modules/distribution/queries.d.ts +16 -0
  75. package/dist/sdk/firmachain/common/modules/distribution/queries.js +171 -0
  76. package/dist/sdk/firmachain/common/modules/evidence/aminomessages.d.ts +18 -0
  77. package/dist/sdk/firmachain/common/modules/evidence/aminomessages.js +11 -0
  78. package/dist/sdk/firmachain/common/modules/feegrant/aminomessages.d.ts +2 -0
  79. package/dist/sdk/firmachain/common/modules/feegrant/aminomessages.js +14 -0
  80. package/dist/sdk/firmachain/common/modules/feegrant/messages.d.ts +2 -0
  81. package/dist/sdk/firmachain/common/modules/feegrant/messages.js +8 -0
  82. package/dist/sdk/firmachain/common/modules/feegrant/queries.d.ts +9 -0
  83. package/dist/sdk/firmachain/common/modules/feegrant/queries.js +81 -0
  84. package/dist/sdk/firmachain/common/modules/gov/aminomessages.d.ts +79 -0
  85. package/dist/sdk/firmachain/common/modules/gov/aminomessages.js +152 -0
  86. package/dist/sdk/firmachain/common/modules/gov/messages.d.ts +29 -0
  87. package/dist/sdk/firmachain/common/modules/gov/messages.js +38 -0
  88. package/dist/sdk/firmachain/common/modules/gov/queries.d.ts +19 -0
  89. package/dist/sdk/firmachain/common/modules/gov/queries.js +160 -0
  90. package/dist/sdk/firmachain/common/modules/group/aminomessages.d.ts +2 -0
  91. package/dist/sdk/firmachain/common/modules/group/aminomessages.js +8 -0
  92. package/dist/sdk/firmachain/common/modules/group/messages.d.ts +2 -0
  93. package/dist/sdk/firmachain/common/modules/group/messages.js +28 -0
  94. package/dist/sdk/firmachain/common/modules/ibc/aminomessages.d.ts +38 -0
  95. package/dist/sdk/firmachain/common/modules/ibc/aminomessages.js +55 -0
  96. package/dist/sdk/firmachain/common/modules/ibc/messages.d.ts +8 -0
  97. package/dist/sdk/firmachain/common/modules/ibc/messages.js +32 -0
  98. package/dist/sdk/firmachain/common/modules/ibc/queries.d.ts +58 -0
  99. package/dist/sdk/firmachain/common/modules/ibc/queries.js +576 -0
  100. package/dist/sdk/firmachain/common/modules/index.d.ts +32 -0
  101. package/dist/sdk/firmachain/common/modules/index.js +101 -0
  102. package/dist/sdk/firmachain/common/modules/mint/queries.d.ts +21 -0
  103. package/dist/sdk/firmachain/common/modules/mint/queries.js +95 -0
  104. package/dist/sdk/firmachain/common/modules/slashing/aminomessages.d.ts +12 -0
  105. package/dist/sdk/firmachain/common/modules/slashing/aminomessages.js +11 -0
  106. package/dist/sdk/firmachain/common/modules/slashing/queries.d.ts +10 -0
  107. package/dist/sdk/firmachain/common/modules/slashing/queries.js +88 -0
  108. package/dist/sdk/firmachain/common/modules/staking/aminomessages.d.ts +112 -0
  109. package/dist/sdk/firmachain/common/modules/staking/aminomessages.js +234 -0
  110. package/dist/sdk/firmachain/common/modules/staking/messages.d.ts +33 -0
  111. package/dist/sdk/firmachain/common/modules/staking/messages.js +37 -0
  112. package/dist/sdk/firmachain/common/modules/staking/queries.d.ts +23 -0
  113. package/dist/sdk/firmachain/common/modules/staking/queries.js +242 -0
  114. package/dist/sdk/firmachain/common/modules/tx/queries.d.ts +11 -0
  115. package/dist/sdk/firmachain/common/modules/tx/queries.js +103 -0
  116. package/dist/sdk/firmachain/common/modules/vesting/aminomessages.d.ts +16 -0
  117. package/dist/sdk/firmachain/common/modules/vesting/aminomessages.js +56 -0
  118. package/dist/sdk/firmachain/common/modules/vesting/messages.d.ts +2 -0
  119. package/dist/sdk/firmachain/common/modules/vesting/messages.js +7 -0
  120. package/dist/sdk/firmachain/common/queryclient/index.d.ts +2 -0
  121. package/dist/sdk/firmachain/common/queryclient/index.js +10 -0
  122. package/dist/sdk/firmachain/common/queryclient/queryclient.d.ts +75 -0
  123. package/dist/sdk/firmachain/common/queryclient/queryclient.js +157 -0
  124. package/dist/sdk/firmachain/common/queryclient/utils.d.ts +33 -0
  125. package/dist/sdk/firmachain/common/queryclient/utils.js +101 -0
  126. package/dist/sdk/firmachain/common/search.d.ts +10 -0
  127. package/dist/sdk/firmachain/common/search.js +7 -0
  128. package/dist/sdk/firmachain/common/signing.d.ts +8 -3
  129. package/dist/sdk/firmachain/common/signing.js +24 -12
  130. package/dist/sdk/firmachain/common/signingstargateclient.d.ts +107 -30
  131. package/dist/sdk/firmachain/common/signingstargateclient.js +445 -128
  132. package/dist/sdk/firmachain/common/stargateclient.d.ts +184 -20
  133. package/dist/sdk/firmachain/common/stargateclient.js +351 -35
  134. package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +2 -2
  135. package/dist/sdk/firmachain/contract/ContractTxClient.js +4 -4
  136. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +1 -1
  137. package/dist/sdk/firmachain/contract/ContractTxTypes.js +3 -3
  138. package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +1 -1
  139. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +5 -5
  140. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +10 -8
  141. package/dist/sdk/firmachain/google/protobuf/any.d.ts +3 -2
  142. package/dist/sdk/firmachain/google/protobuf/any.js +2 -1
  143. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +3 -2
  144. package/dist/sdk/firmachain/google/protobuf/duration.js +2 -1
  145. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +3 -2
  146. package/dist/sdk/firmachain/google/protobuf/timestamp.js +2 -1
  147. package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +13 -1
  148. package/dist/sdk/firmachain/gov/GovQueryClient.js +9 -2
  149. package/dist/sdk/firmachain/gov/GovTxClient.d.ts +12 -0
  150. package/dist/sdk/firmachain/gov/GovTxClient.js +11 -1
  151. package/dist/sdk/firmachain/nft/NftTxClient.d.ts +3 -3
  152. package/dist/sdk/firmachain/nft/NftTxClient.js +6 -6
  153. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +1 -1
  154. package/dist/sdk/firmachain/nft/NftTxTypes.js +4 -4
  155. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +1 -0
  156. package/dist/sdk/firmachain/staking/StakingQueryClient.js +0 -1
  157. package/dist/sdk/firmachain/token/TokenTxClient.d.ts +4 -4
  158. package/dist/sdk/firmachain/token/TokenTxClient.js +8 -8
  159. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +1 -1
  160. package/dist/sdk/firmachain/token/TokenTxTypes.js +5 -5
  161. package/dist/test/00.wallet.test.js +15 -9
  162. package/dist/test/01.contract_tx.test.js +53 -45
  163. package/dist/test/02.contract_query.test.js +54 -31
  164. package/dist/test/03.contract_scenario.test.js +170 -326
  165. package/dist/test/04.bank_tx.test.js +58 -59
  166. package/dist/test/05.bank_query.test.js +51 -56
  167. package/dist/test/06.feegrant_tx.test.js +74 -89
  168. package/dist/test/07.feegrant_query.test.js +69 -27
  169. package/dist/test/08.gas_estimate.test.js +422 -392
  170. package/dist/test/09.ipfs.test.js +3 -3
  171. package/dist/test/10.nft_tx.test.js +108 -76
  172. package/dist/test/11.nft_query.test.js +41 -46
  173. package/dist/test/12.staking_tx.test.js +81 -98
  174. package/dist/test/13.staking_query.test.js +66 -12
  175. package/dist/test/14.distribution_tx.test.js +69 -78
  176. package/dist/test/15.distribution_query.test.js +81 -57
  177. package/dist/test/16.gov_tx.test.js +247 -107
  178. package/dist/test/17.gov_query.test.js +48 -9
  179. package/dist/test/18.util.test.js +6 -1
  180. package/dist/test/19.chain.test.js +50 -4
  181. package/dist/test/20.slashing_query.test.js +31 -1
  182. package/dist/test/21.token_tx.test.js +48 -56
  183. package/dist/test/22.token_query.test.js +24 -20
  184. package/dist/test/23.authz_tx.test.js +119 -240
  185. package/dist/test/24.authz_query.test.js +116 -56
  186. package/dist/test/25.cosmwasm_tx.test.js +95 -57
  187. package/dist/test/26.cosmwasm_query.test.js +66 -26
  188. package/dist/test/27.arbitary_sign.test.js +59 -67
  189. package/dist/test/28.ibc_tx.test.js +29 -17
  190. package/dist/test/29.mint_query.test.js +2 -0
  191. package/dist/test/30.cw20_tx.test.js +161 -226
  192. package/dist/test/31.cw20_query.test.js +183 -37
  193. package/dist/test/32.cw721_tx.test.js +147 -149
  194. package/dist/test/33.cw721_query.test.js +188 -36
  195. package/dist/test/34.cw_bridge_tx.test.js +266 -155
  196. package/dist/test/35.cw_bridge_tx_low.test.js +221 -81
  197. package/dist/test/36.cw_bridge_query.test.js +157 -21
  198. package/dist/test/37.cw_marketplace_tx.test.js +22 -22
  199. package/dist/test/38.cw_marketplace_query.test.js +9 -9
  200. package/dist/test/config_test.d.ts +10 -4
  201. package/dist/test/config_test.js +16 -9
  202. package/dist/test/config_test.sample.d.ts +11 -0
  203. package/dist/test/config_test.sample.js +14 -0
  204. package/package.json +9 -7
  205. package/dist/sdk/firmachain/common/signingaminostargateclient.d.ts +0 -50
  206. package/dist/sdk/firmachain/common/signingaminostargateclient.js +0 -267
@@ -36,106 +36,166 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ var chai_1 = require("chai");
39
40
  var AuthzTxTypes_1 = require("../sdk/firmachain/authz/AuthzTxTypes");
40
41
  var FirmaSDK_1 = require("../sdk/FirmaSDK");
41
42
  var config_test_1 = require("./config_test");
42
43
  describe('[24. Authz query Test]', function () {
43
44
  var firma;
45
+ var aliceWallet;
46
+ var aliceAddress;
47
+ var bobWallet;
48
+ var bobAddress;
44
49
  beforeEach(function () {
45
- firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
50
+ return __awaiter(this, void 0, void 0, function () {
51
+ return __generator(this, function (_a) {
52
+ switch (_a.label) {
53
+ case 0:
54
+ firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
55
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
56
+ case 1:
57
+ aliceWallet = _a.sent();
58
+ return [4 /*yield*/, aliceWallet.getAddress()];
59
+ case 2:
60
+ aliceAddress = _a.sent();
61
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
62
+ case 3:
63
+ bobWallet = _a.sent();
64
+ return [4 /*yield*/, bobWallet.getAddress()];
65
+ case 4:
66
+ bobAddress = _a.sent();
67
+ return [4 /*yield*/, initializeGrant()];
68
+ case 5:
69
+ _a.sent();
70
+ return [2 /*return*/];
71
+ }
72
+ });
73
+ });
46
74
  });
75
+ var initializeGrant = function () {
76
+ return __awaiter(this, void 0, void 0, function () {
77
+ var expirationDate, delegationInfo, validatorAddress, amountFCT, grantResult, msg, genericResult, maxFCT, delegateResult, redelegateResult, undelegateResult;
78
+ return __generator(this, function (_a) {
79
+ switch (_a.label) {
80
+ case 0:
81
+ expirationDate = new Date();
82
+ expirationDate.setFullYear(expirationDate.getFullYear() + 1);
83
+ return [4 /*yield*/, firma.Staking.getTotalDelegationInfo(aliceAddress)];
84
+ case 1:
85
+ delegationInfo = (_a.sent()).dataList;
86
+ validatorAddress = delegationInfo[0].delegation.validator_address;
87
+ amountFCT = 9;
88
+ return [4 /*yield*/, firma.Authz.grantSendAuthorization(aliceWallet, bobAddress, expirationDate, amountFCT)];
89
+ case 2:
90
+ grantResult = _a.sent();
91
+ chai_1.expect(grantResult.code).to.equal(0);
92
+ msg = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward";
93
+ return [4 /*yield*/, firma.Authz.grantGenericAuthorization(aliceWallet, bobAddress, msg, expirationDate)];
94
+ case 3:
95
+ genericResult = _a.sent();
96
+ chai_1.expect(genericResult.code).to.be.equal(0);
97
+ maxFCT = 100;
98
+ return [4 /*yield*/, firma.Authz.grantStakeAuthorization(aliceWallet, bobAddress, [validatorAddress], AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_DELEGATE, expirationDate, maxFCT)];
99
+ case 4:
100
+ delegateResult = _a.sent();
101
+ chai_1.expect(delegateResult.code).to.be.equal(0);
102
+ return [4 /*yield*/, firma.Authz.grantStakeAuthorization(aliceWallet, bobAddress, [validatorAddress], AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_REDELEGATE, expirationDate, maxFCT)];
103
+ case 5:
104
+ redelegateResult = _a.sent();
105
+ chai_1.expect(redelegateResult.code).to.be.equal(0);
106
+ return [4 /*yield*/, firma.Authz.grantStakeAuthorization(aliceWallet, bobAddress, [validatorAddress], AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_UNDELEGATE, expirationDate, maxFCT)];
107
+ case 6:
108
+ undelegateResult = _a.sent();
109
+ chai_1.expect(undelegateResult.code).to.be.equal(0);
110
+ return [2 /*return*/];
111
+ }
112
+ });
113
+ });
114
+ };
47
115
  it('Authz getSendGrantData', function () { return __awaiter(void 0, void 0, void 0, function () {
48
- var granter, grantee, result;
116
+ var result, grant, revokeResult;
49
117
  return __generator(this, function (_a) {
50
118
  switch (_a.label) {
51
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
52
- case 1: return [4 /*yield*/, (_a.sent()).getAddress()];
119
+ case 0: return [4 /*yield*/, firma.Authz.getSendGrantData(aliceAddress, bobAddress)];
120
+ case 1:
121
+ result = (_a.sent()).dataList;
122
+ chai_1.expect(result.length).to.be.greaterThan(0);
123
+ grant = result[0];
124
+ chai_1.expect(grant).to.have.property('authorization');
125
+ chai_1.expect(grant).to.have.property('expiration');
126
+ return [4 /*yield*/, firma.Authz.revokeSendAuthorization(aliceWallet, bobAddress)];
53
127
  case 2:
54
- granter = _a.sent();
55
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
56
- case 3: return [4 /*yield*/, (_a.sent()).getAddress()];
57
- case 4:
58
- grantee = _a.sent();
59
- return [4 /*yield*/, firma.Authz.getSendGrantData(granter, grantee)];
60
- case 5:
61
- result = _a.sent();
128
+ revokeResult = _a.sent();
129
+ chai_1.expect(revokeResult.code).to.equal(0);
62
130
  return [2 /*return*/];
63
131
  }
64
132
  });
65
133
  }); });
66
134
  it('Authz getGenericGrantData', function () { return __awaiter(void 0, void 0, void 0, function () {
67
- var granter, grantee, msg, result;
135
+ var expirationDate, amountFCT, msg, result, grant;
68
136
  return __generator(this, function (_a) {
69
137
  switch (_a.label) {
70
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
71
- case 1: return [4 /*yield*/, (_a.sent()).getAddress()];
72
- case 2:
73
- granter = _a.sent();
74
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
75
- case 3: return [4 /*yield*/, (_a.sent()).getAddress()];
76
- case 4:
77
- grantee = _a.sent();
138
+ case 0:
139
+ expirationDate = new Date();
140
+ expirationDate.setFullYear(expirationDate.getFullYear() + 1);
141
+ amountFCT = 9;
78
142
  msg = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward";
79
- return [4 /*yield*/, firma.Authz.getGenericGrantData(granter, grantee, msg)];
80
- case 5:
143
+ return [4 /*yield*/, firma.Authz.getGenericGrantData(aliceAddress, bobAddress, msg)];
144
+ case 1:
81
145
  result = (_a.sent()).dataList;
146
+ // This test may fail if the grant does not exist.
147
+ chai_1.expect(result.length).to.be.greaterThan(0);
148
+ grant = result[0];
149
+ chai_1.expect(grant).to.have.property('authorization');
150
+ chai_1.expect(grant).to.have.property('expiration');
82
151
  return [2 /*return*/];
83
152
  }
84
153
  });
85
154
  }); });
86
155
  it('Authz getStakingGrantData - delegate', function () { return __awaiter(void 0, void 0, void 0, function () {
87
- var granter, grantee, result;
156
+ var result, grant;
88
157
  return __generator(this, function (_a) {
89
158
  switch (_a.label) {
90
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
91
- case 1: return [4 /*yield*/, (_a.sent()).getAddress()];
92
- case 2:
93
- granter = _a.sent();
94
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
95
- case 3: return [4 /*yield*/, (_a.sent()).getAddress()];
96
- case 4:
97
- grantee = _a.sent();
98
- return [4 /*yield*/, firma.Authz.getStakingGrantData(granter, grantee, AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_DELEGATE)];
99
- case 5:
159
+ case 0: return [4 /*yield*/, firma.Authz.getStakingGrantData(aliceAddress, bobAddress, AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_DELEGATE)];
160
+ case 1:
100
161
  result = (_a.sent()).dataList;
162
+ // This test may fail if the grant does not exist.
163
+ chai_1.expect(result.length).to.be.greaterThan(0);
164
+ grant = result[0];
165
+ chai_1.expect(grant).to.have.property('authorization');
166
+ chai_1.expect(grant).to.have.property('expiration');
101
167
  return [2 /*return*/];
102
168
  }
103
169
  });
104
170
  }); });
105
171
  it('Authz getStakingGrantData - redelegate', function () { return __awaiter(void 0, void 0, void 0, function () {
106
- var granter, grantee, result;
172
+ var result, grant;
107
173
  return __generator(this, function (_a) {
108
174
  switch (_a.label) {
109
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
110
- case 1: return [4 /*yield*/, (_a.sent()).getAddress()];
111
- case 2:
112
- granter = _a.sent();
113
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
114
- case 3: return [4 /*yield*/, (_a.sent()).getAddress()];
115
- case 4:
116
- grantee = _a.sent();
117
- return [4 /*yield*/, firma.Authz.getStakingGrantData(granter, grantee, AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_REDELEGATE)];
118
- case 5:
175
+ case 0: return [4 /*yield*/, firma.Authz.getStakingGrantData(aliceAddress, bobAddress, AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_REDELEGATE)];
176
+ case 1:
119
177
  result = (_a.sent()).dataList;
178
+ // This test may fail if the grant does not exist.
179
+ chai_1.expect(result.length).to.be.greaterThan(0);
180
+ grant = result[0];
181
+ chai_1.expect(grant).to.have.property('authorization');
182
+ chai_1.expect(grant).to.have.property('expiration');
120
183
  return [2 /*return*/];
121
184
  }
122
185
  });
123
186
  }); });
124
187
  it('Authz getStakingGrantData - undelegate', function () { return __awaiter(void 0, void 0, void 0, function () {
125
- var granter, grantee, result;
188
+ var result, grant;
126
189
  return __generator(this, function (_a) {
127
190
  switch (_a.label) {
128
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
129
- case 1: return [4 /*yield*/, (_a.sent()).getAddress()];
130
- case 2:
131
- granter = _a.sent();
132
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
133
- case 3: return [4 /*yield*/, (_a.sent()).getAddress()];
134
- case 4:
135
- grantee = _a.sent();
136
- return [4 /*yield*/, firma.Authz.getStakingGrantData(granter, grantee, AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_UNDELEGATE)];
137
- case 5:
191
+ case 0: return [4 /*yield*/, firma.Authz.getStakingGrantData(aliceAddress, bobAddress, AuthzTxTypes_1.AuthorizationType.AUTHORIZATION_TYPE_UNDELEGATE)];
192
+ case 1:
138
193
  result = (_a.sent()).dataList;
194
+ // This test may fail if the grant does not exist.
195
+ chai_1.expect(result.length).to.be.greaterThan(0);
196
+ grant = result[0];
197
+ chai_1.expect(grant).to.have.property('authorization');
198
+ chai_1.expect(grant).to.have.property('expiration');
139
199
  return [2 /*return*/];
140
200
  }
141
201
  });
@@ -35,154 +35,192 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
+ var __values = (this && this.__values) || function(o) {
39
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
+ if (m) return m.call(o);
41
+ if (o && typeof o.length === "number") return {
42
+ next: function () {
43
+ if (o && i >= o.length) o = void 0;
44
+ return { value: o && o[i++], done: !o };
45
+ }
46
+ };
47
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
+ };
38
49
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
51
  };
41
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
+ var fs_1 = __importDefault(require("fs"));
42
54
  var chai_1 = require("chai");
43
55
  var FirmaSDK_1 = require("../sdk/FirmaSDK");
44
56
  var FirmaUtil_1 = require("../sdk/FirmaUtil");
45
- var config_test_1 = require("./config_test");
46
- var fs_1 = __importDefault(require("fs"));
47
57
  var FirmaCosmWasmService_1 = require("../sdk/FirmaCosmWasmService");
58
+ var config_test_1 = require("./config_test");
48
59
  describe('[25. CosmWasm Tx Test]', function () {
49
60
  var firma;
61
+ var aliceWallet;
62
+ var bobWallet;
63
+ var aliceAddress;
64
+ var bobAddress;
65
+ var extractValue = function (events, eventType, attrKey) {
66
+ var e_1, _a, e_2, _b;
67
+ try {
68
+ for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) {
69
+ var event_1 = events_1_1.value;
70
+ if (event_1.type === eventType) {
71
+ try {
72
+ for (var _c = (e_2 = void 0, __values(event_1.attributes)), _d = _c.next(); !_d.done; _d = _c.next()) {
73
+ var attr = _d.value;
74
+ if (attr.key === attrKey) {
75
+ return attr.value;
76
+ }
77
+ }
78
+ }
79
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
80
+ finally {
81
+ try {
82
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
83
+ }
84
+ finally { if (e_2) throw e_2.error; }
85
+ }
86
+ }
87
+ }
88
+ }
89
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
90
+ finally {
91
+ try {
92
+ if (events_1_1 && !events_1_1.done && (_a = events_1.return)) _a.call(events_1);
93
+ }
94
+ finally { if (e_1) throw e_1.error; }
95
+ }
96
+ return "";
97
+ };
50
98
  beforeEach(function () {
51
- firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
99
+ return __awaiter(this, void 0, void 0, function () {
100
+ return __generator(this, function (_a) {
101
+ switch (_a.label) {
102
+ case 0:
103
+ firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
104
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
105
+ case 1:
106
+ aliceWallet = _a.sent();
107
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
108
+ case 2:
109
+ bobWallet = _a.sent();
110
+ return [4 /*yield*/, aliceWallet.getAddress()];
111
+ case 3:
112
+ aliceAddress = _a.sent();
113
+ return [4 /*yield*/, bobWallet.getAddress()];
114
+ case 4:
115
+ bobAddress = _a.sent();
116
+ return [2 /*return*/];
117
+ }
118
+ });
119
+ });
52
120
  });
53
121
  // sample : cw_nameservice.wasm
54
122
  // https://docs.cosmwasm.com/docs/1.0/getting-started/compile-contract
55
123
  var codeId = "";
56
124
  var contractAddress = "";
57
125
  it('CosmWasm StoreCode', function () { return __awaiter(void 0, void 0, void 0, function () {
58
- var aliceWallet, aliceAddress, wasmFile, array, gas, fee, everyBodyAccessConfig, result, data;
126
+ var wasmFile, array, gas, fee, everyBodyAccessConfig, result;
59
127
  return __generator(this, function (_a) {
60
128
  switch (_a.label) {
61
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
62
- case 1:
63
- aliceWallet = _a.sent();
64
- return [4 /*yield*/, aliceWallet.getAddress()];
65
- case 2:
66
- aliceAddress = _a.sent();
129
+ case 0:
67
130
  wasmFile = fs_1.default.readFileSync("./test/sample/cw_nameservice.wasm");
68
131
  array = new Uint8Array(wasmFile.buffer);
69
132
  gas = 3000000;
70
133
  fee = FirmaUtil_1.FirmaUtil.getUFCTFromFCT(0.3);
71
- everyBodyAccessConfig = { permission: FirmaCosmWasmService_1.AccessType.ACCESS_TYPE_EVERYBODY, address: "" };
134
+ everyBodyAccessConfig = { permission: FirmaCosmWasmService_1.AccessType.ACCESS_TYPE_EVERYBODY, address: "", addresses: [] };
72
135
  return [4 /*yield*/, firma.CosmWasm.storeCode(aliceWallet, array, everyBodyAccessConfig, { gas: gas, fee: fee })];
73
- case 3:
136
+ case 1:
74
137
  result = _a.sent();
75
- data = JSON.parse(result.rawLog);
76
- codeId = data[0]["events"][1]["attributes"][1]["value"];
77
- //console.log(codeId);
78
- //console.log(result);
138
+ codeId = extractValue(result.events, "store_code", "code_id");
79
139
  chai_1.expect(result.code).to.be.equal(0);
80
140
  return [2 /*return*/];
81
141
  }
82
142
  });
83
143
  }); });
84
144
  it('CosmWasm InstantiateContract', function () { return __awaiter(void 0, void 0, void 0, function () {
85
- var aliceWallet, admin, label, gas, fee, funds, testData, result, data;
145
+ var admin, label, gas, fee, funds, testData, result;
86
146
  return __generator(this, function (_a) {
87
147
  switch (_a.label) {
88
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
89
- case 1:
90
- aliceWallet = _a.sent();
91
- return [4 /*yield*/, aliceWallet.getAddress()];
92
- case 2:
93
- admin = _a.sent();
148
+ case 0:
149
+ admin = aliceAddress;
94
150
  label = "test1";
95
151
  gas = 3000000;
96
152
  fee = FirmaUtil_1.FirmaUtil.getUFCTFromFCT(0.3);
97
153
  funds = [];
98
154
  testData = JSON.stringify({ "purchase_price": { "amount": "100", "denom": "ufct" }, "transfer_price": { "amount": "999", "denom": "ufct" } });
99
155
  return [4 /*yield*/, firma.CosmWasm.instantiateContract(aliceWallet, admin, codeId, label, testData, funds, { gas: gas, fee: fee })];
100
- case 3:
156
+ case 1:
101
157
  result = _a.sent();
102
- data = JSON.parse(result.rawLog);
103
- contractAddress = data[0]["events"][0]["attributes"][0]["value"];
158
+ contractAddress = extractValue(result.events, "instantiate", "_contract_address");
104
159
  chai_1.expect(result.code).to.be.equal(0);
105
160
  return [2 /*return*/];
106
161
  }
107
162
  });
108
163
  }); });
109
164
  it('CosmWasm ExecuteContract', function () { return __awaiter(void 0, void 0, void 0, function () {
110
- var aliceWallet, gas, fee, testData, amountFCT, funds, result;
165
+ var gas, fee, testData, amountFCT, funds, result;
111
166
  return __generator(this, function (_a) {
112
167
  switch (_a.label) {
113
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
114
- case 1:
115
- aliceWallet = _a.sent();
168
+ case 0:
116
169
  gas = 3000000;
117
170
  fee = FirmaUtil_1.FirmaUtil.getUFCTFromFCT(0.3);
118
171
  testData = JSON.stringify({ "register": { "name": "fred" } });
119
172
  amountFCT = 0.01;
120
173
  funds = [{ denom: firma.Config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountFCT) }];
121
174
  return [4 /*yield*/, firma.CosmWasm.executeContract(aliceWallet, contractAddress, testData, funds, { gas: gas, fee: fee })];
122
- case 2:
175
+ case 1:
123
176
  result = _a.sent();
124
- //console.log(result);
125
177
  chai_1.expect(result.code).to.be.equal(0);
126
178
  return [2 /*return*/];
127
179
  }
128
180
  });
129
181
  }); });
130
182
  it('CosmWasm UpdateAdmin', function () { return __awaiter(void 0, void 0, void 0, function () {
131
- var aliceWallet, bobWallet, bobAddress, gas, fee, result;
183
+ var gas, fee, result;
132
184
  return __generator(this, function (_a) {
133
185
  switch (_a.label) {
134
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
135
- case 1:
136
- aliceWallet = _a.sent();
137
- return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
138
- case 2:
139
- bobWallet = _a.sent();
140
- return [4 /*yield*/, bobWallet.getAddress()];
141
- case 3:
142
- bobAddress = _a.sent();
186
+ case 0:
143
187
  gas = 3000000;
144
188
  fee = FirmaUtil_1.FirmaUtil.getUFCTFromFCT(0.3);
145
189
  return [4 /*yield*/, firma.CosmWasm.updateAdmin(aliceWallet, contractAddress, bobAddress, { gas: gas, fee: fee })];
146
- case 4:
190
+ case 1:
147
191
  result = _a.sent();
148
- //console.log(result);
149
192
  chai_1.expect(result.code).to.be.equal(0);
150
193
  return [2 /*return*/];
151
194
  }
152
195
  });
153
196
  }); });
154
197
  it('CosmWasm ClearAdmin', function () { return __awaiter(void 0, void 0, void 0, function () {
155
- var aliceWallet, gas, fee, result;
198
+ var gas, fee, result;
156
199
  return __generator(this, function (_a) {
157
200
  switch (_a.label) {
158
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
159
- case 1:
160
- aliceWallet = _a.sent();
201
+ case 0:
161
202
  gas = 3000000;
162
203
  fee = FirmaUtil_1.FirmaUtil.getUFCTFromFCT(0.3);
163
- return [4 /*yield*/, firma.CosmWasm.clearAdmin(aliceWallet, contractAddress, { gas: gas, fee: fee })];
164
- case 2:
204
+ return [4 /*yield*/, firma.CosmWasm.clearAdmin(bobWallet, contractAddress, { gas: gas, fee: fee })];
205
+ case 1:
165
206
  result = _a.sent();
166
- //console.log(result);
167
207
  chai_1.expect(result.code).to.be.equal(0);
168
208
  return [2 /*return*/];
169
209
  }
170
210
  });
171
211
  }); });
212
+ // This test requires specific conditions, so it is skipped by default
172
213
  it.skip('CosmWasm MigrateContract', function () { return __awaiter(void 0, void 0, void 0, function () {
173
- var aliceWallet, gas, fee, testData, result;
214
+ var gas, fee, testData, result;
174
215
  return __generator(this, function (_a) {
175
216
  switch (_a.label) {
176
- case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
177
- case 1:
178
- aliceWallet = _a.sent();
217
+ case 0:
179
218
  gas = 3000000;
180
219
  fee = FirmaUtil_1.FirmaUtil.getUFCTFromFCT(0.3);
181
220
  testData = JSON.stringify({ "purchase_price": { "amount": "1000", "denom": "ufct" }, "transfer_price": { "amount": "9990", "denom": "ufct" } });
182
221
  return [4 /*yield*/, firma.CosmWasm.migrateContract(aliceWallet, contractAddress, codeId, testData, { gas: gas, fee: fee })];
183
- case 2:
222
+ case 1:
184
223
  result = _a.sent();
185
- //console.log(result);
186
224
  chai_1.expect(result.code).to.be.equal(0);
187
225
  return [2 /*return*/];
188
226
  }
@@ -36,6 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ var chai_1 = require("chai");
39
40
  var FirmaSDK_1 = require("../sdk/FirmaSDK");
40
41
  var config_test_1 = require("./config_test");
41
42
  describe('[26. cosmwasm query Test]', function () {
@@ -44,52 +45,59 @@ describe('[26. cosmwasm query Test]', function () {
44
45
  firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
45
46
  });
46
47
  var contractAddress = "";
48
+ var codeId = "";
47
49
  it('CosmWasm getCodeList', function () { return __awaiter(void 0, void 0, void 0, function () {
48
- var result;
50
+ var result, codeInfo;
49
51
  return __generator(this, function (_a) {
50
52
  switch (_a.label) {
51
53
  case 0: return [4 /*yield*/, firma.CosmWasm.getCodeList()];
52
54
  case 1:
53
55
  result = _a.sent();
56
+ chai_1.expect(result.length).to.be.greaterThan(0);
57
+ codeId = result[0].code_id;
58
+ codeInfo = result[0];
59
+ chai_1.expect(codeInfo).to.have.property('code_id');
60
+ chai_1.expect(codeInfo).to.have.property('creator');
61
+ chai_1.expect(codeInfo).to.have.property('data_hash');
54
62
  return [2 /*return*/];
55
63
  }
56
64
  });
57
65
  }); });
58
66
  it('CosmWasm getCodeData', function () { return __awaiter(void 0, void 0, void 0, function () {
59
- var codeId, result;
67
+ var result, codeInfo;
60
68
  return __generator(this, function (_a) {
61
69
  switch (_a.label) {
62
- case 0:
63
- codeId = "1";
64
- return [4 /*yield*/, firma.CosmWasm.getCodeData(codeId)];
65
- case 1:
66
- result = _a.sent();
67
- return [2 /*return*/];
68
- }
69
- });
70
- }); });
71
- it('CosmWasm getCodeData', function () { return __awaiter(void 0, void 0, void 0, function () {
72
- var codeId, result;
73
- return __generator(this, function (_a) {
74
- switch (_a.label) {
75
- case 0:
76
- codeId = "1";
77
- return [4 /*yield*/, firma.CosmWasm.getCodeData(codeId)];
70
+ case 0: return [4 /*yield*/, firma.CosmWasm.getCodeData(codeId)];
78
71
  case 1:
79
72
  result = _a.sent();
73
+ chai_1.expect(result).to.not.be.null;
74
+ chai_1.expect(result).to.have.property('code_info');
75
+ chai_1.expect(result).to.have.property('data');
76
+ codeInfo = result.code_info;
77
+ chai_1.expect(codeInfo).to.have.property('code_id', codeId);
78
+ chai_1.expect(codeInfo).to.have.property('creator');
79
+ chai_1.expect(codeInfo).to.have.property('data_hash');
80
+ chai_1.expect(result.data).to.be.a('string');
80
81
  return [2 /*return*/];
81
82
  }
82
83
  });
83
84
  }); });
84
85
  it('CosmWasm getContractListFromCodeId', function () { return __awaiter(void 0, void 0, void 0, function () {
85
- var codeId, result;
86
+ var result;
86
87
  return __generator(this, function (_a) {
87
88
  switch (_a.label) {
88
- case 0:
89
- codeId = "132";
90
- return [4 /*yield*/, firma.CosmWasm.getContractListFromCodeId(codeId)];
89
+ case 0: return [4 /*yield*/, firma.CosmWasm.getContractListFromCodeId(codeId)];
91
90
  case 1:
92
91
  result = _a.sent();
92
+ chai_1.expect(result).to.not.be.null;
93
+ chai_1.expect(result).to.have.property('dataList');
94
+ chai_1.expect(result).to.have.property('pagination');
95
+ chai_1.expect(result.dataList).to.be.an('array');
96
+ chai_1.expect(result.dataList.length).to.be.greaterThan(0);
97
+ chai_1.expect(result.dataList[0]).to.be.a('string');
98
+ chai_1.expect(result.pagination).to.have.property('next_key');
99
+ chai_1.expect(result.pagination).to.have.property('total');
100
+ contractAddress = result.dataList[0];
93
101
  return [2 /*return*/];
94
102
  }
95
103
  });
@@ -101,41 +109,71 @@ describe('[26. cosmwasm query Test]', function () {
101
109
  case 0: return [4 /*yield*/, firma.CosmWasm.getPinnedCodeList()];
102
110
  case 1:
103
111
  codeList = _a.sent();
112
+ chai_1.expect(codeList).to.be.an('array');
104
113
  return [2 /*return*/];
105
114
  }
106
115
  });
107
116
  }); });
108
117
  // ContractInfo gets the contract meta data
109
118
  it('CosmWasm getContractInfo', function () { return __awaiter(void 0, void 0, void 0, function () {
110
- var result;
119
+ var result, contractInfo;
111
120
  return __generator(this, function (_a) {
112
121
  switch (_a.label) {
113
122
  case 0: return [4 /*yield*/, firma.CosmWasm.getContractInfo(contractAddress)];
114
123
  case 1:
115
124
  result = _a.sent();
125
+ chai_1.expect(result).to.not.be.null;
126
+ chai_1.expect(result).to.have.property('address', contractAddress);
127
+ chai_1.expect(result).to.have.property('contract_info');
128
+ contractInfo = result.contract_info;
129
+ chai_1.expect(contractInfo).to.have.property('code_id');
130
+ chai_1.expect(contractInfo).to.have.property('creator');
131
+ chai_1.expect(contractInfo).to.have.property('admin');
132
+ chai_1.expect(contractInfo).to.have.property('label');
133
+ chai_1.expect(contractInfo).to.have.property('created');
134
+ chai_1.expect(contractInfo).to.have.property('ibc_port_id');
135
+ chai_1.expect(contractInfo).to.have.property('extension');
136
+ chai_1.expect(contractInfo.created).to.have.property('block_height');
137
+ chai_1.expect(contractInfo.created).to.have.property('tx_index');
116
138
  return [2 /*return*/];
117
139
  }
118
140
  });
119
141
  }); });
120
142
  it('CosmWasm getContractHistory', function () { return __awaiter(void 0, void 0, void 0, function () {
121
- var result;
143
+ var result, history;
122
144
  return __generator(this, function (_a) {
123
145
  switch (_a.label) {
124
146
  case 0: return [4 /*yield*/, firma.CosmWasm.getContractHistory(contractAddress)];
125
147
  case 1:
126
148
  result = _a.sent();
149
+ chai_1.expect(result).to.be.an('array');
150
+ chai_1.expect(result.length).to.be.greaterThan(0);
151
+ history = result[0];
152
+ chai_1.expect(history).to.have.property('operation');
153
+ chai_1.expect(history).to.have.property('code_id');
154
+ chai_1.expect(history).to.have.property('updated');
155
+ chai_1.expect(history).to.have.property('msg');
156
+ chai_1.expect(history.updated).to.have.property('block_height');
157
+ chai_1.expect(history.updated).to.have.property('tx_index');
158
+ chai_1.expect(history.msg).to.have.property('purchase_price');
159
+ chai_1.expect(history.msg).to.have.property('transfer_price');
127
160
  return [2 /*return*/];
128
161
  }
129
162
  });
130
163
  }); });
131
164
  // AllContractState gets all raw store data for a single contract
132
165
  it('CosmWasm getContractState', function () { return __awaiter(void 0, void 0, void 0, function () {
133
- var result;
166
+ var result, model;
134
167
  return __generator(this, function (_a) {
135
168
  switch (_a.label) {
136
169
  case 0: return [4 /*yield*/, firma.CosmWasm.getContractState(contractAddress)];
137
170
  case 1:
138
171
  result = _a.sent();
172
+ chai_1.expect(result).to.be.an('array');
173
+ chai_1.expect(result.length).to.be.greaterThan(0);
174
+ model = result[0];
175
+ chai_1.expect(model).to.have.property('key');
176
+ chai_1.expect(model).to.have.property('value');
139
177
  return [2 /*return*/];
140
178
  }
141
179
  });
@@ -149,6 +187,7 @@ describe('[26. cosmwasm query Test]', function () {
149
187
  return [4 /*yield*/, firma.CosmWasm.getContractRawQueryData(contractAddress, hexString)];
150
188
  case 1:
151
189
  result = _a.sent();
190
+ chai_1.expect(result).to.be.a('string');
152
191
  return [2 /*return*/];
153
192
  }
154
193
  });
@@ -158,10 +197,11 @@ describe('[26. cosmwasm query Test]', function () {
158
197
  return __generator(this, function (_a) {
159
198
  switch (_a.label) {
160
199
  case 0:
161
- query = '{"resolve_record": { "name": "fred" }}';
200
+ query = '{"config":{}}';
162
201
  return [4 /*yield*/, firma.CosmWasm.getContractSmartQueryData(contractAddress, query)];
163
202
  case 1:
164
203
  result = _a.sent();
204
+ chai_1.expect(result).to.be.a('string');
165
205
  return [2 /*return*/];
166
206
  }
167
207
  });