@firmachain/firma-js 0.2.45 → 0.2.46

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 (79) hide show
  1. package/dist/sdk/FirmaBankService.d.ts +2 -0
  2. package/dist/sdk/FirmaBankService.js +59 -16
  3. package/dist/sdk/FirmaMintService.d.ts +6 -0
  4. package/dist/sdk/FirmaMintService.js +67 -0
  5. package/dist/sdk/FirmaSDK.d.ts +3 -1
  6. package/dist/sdk/FirmaSDK.js +4 -1
  7. package/dist/sdk/FirmaUtil.d.ts +1 -0
  8. package/dist/sdk/FirmaUtil.js +5 -0
  9. package/dist/sdk/firmachain/mint/MintQueryClient.d.ts +5 -0
  10. package/dist/sdk/firmachain/mint/MintQueryClient.js +71 -0
  11. package/dist/sdk/firmachain/mint/index.d.ts +2 -0
  12. package/dist/sdk/firmachain/mint/index.js +18 -0
  13. package/dist/test/00.wallet.test.d.ts +1 -0
  14. package/dist/test/00.wallet.test.js +87 -0
  15. package/dist/test/000./354/227/220/354/226/264/353/223/234/353/236/215_/353/246/254/354/212/244/355/205/214/354/235/264/355/201/254.test.d.ts +1 -0
  16. package/dist/test/000./354/227/220/354/226/264/353/223/234/353/236/215_/353/246/254/354/212/244/355/205/214/354/235/264/355/201/254.test.js +302 -0
  17. package/dist/test/000./354/236/254/353/213/250/352/264/200/353/240/250.test.d.ts +1 -0
  18. package/dist/test/000./354/236/254/353/213/250/352/264/200/353/240/250.test.js +436 -0
  19. package/dist/test/01.contract_tx.test.d.ts +1 -0
  20. package/dist/test/01.contract_tx.test.js +146 -0
  21. package/dist/test/02.contract_query.test.d.ts +1 -0
  22. package/dist/test/02.contract_query.test.js +219 -0
  23. package/dist/test/03.contract_scenario.test.d.ts +1 -0
  24. package/dist/test/03.contract_scenario.test.js +559 -0
  25. package/dist/test/04.bank_tx.test.d.ts +1 -0
  26. package/dist/test/04.bank_tx.test.js +124 -0
  27. package/dist/test/05.bank_query.test.d.ts +1 -0
  28. package/dist/test/05.bank_query.test.js +164 -0
  29. package/dist/test/06.feegrant_tx.test.d.ts +1 -0
  30. package/dist/test/06.feegrant_tx.test.js +173 -0
  31. package/dist/test/07.feegrant_query.test.d.ts +1 -0
  32. package/dist/test/07.feegrant_query.test.js +81 -0
  33. package/dist/test/08.gas_estimate.test.d.ts +1 -0
  34. package/dist/test/08.gas_estimate.test.js +702 -0
  35. package/dist/test/09.ipfs.test.d.ts +1 -0
  36. package/dist/test/09.ipfs.test.js +69 -0
  37. package/dist/test/10.nft_tx.test.d.ts +1 -0
  38. package/dist/test/10.nft_tx.test.js +137 -0
  39. package/dist/test/11.nft_query.test.d.ts +1 -0
  40. package/dist/test/11.nft_query.test.js +167 -0
  41. package/dist/test/12.staking_tx.test.d.ts +1 -0
  42. package/dist/test/12.staking_tx.test.js +213 -0
  43. package/dist/test/13.staking_query.test.d.ts +1 -0
  44. package/dist/test/13.staking_query.test.js +206 -0
  45. package/dist/test/14.distribution_tx.test.d.ts +1 -0
  46. package/dist/test/14.distribution_tx.test.js +176 -0
  47. package/dist/test/15.distribution_query.test.d.ts +1 -0
  48. package/dist/test/15.distribution_query.test.js +216 -0
  49. package/dist/test/16.gov_tx.test.d.ts +1 -0
  50. package/dist/test/16.gov_tx.test.js +237 -0
  51. package/dist/test/17.gov_query.test.d.ts +1 -0
  52. package/dist/test/17.gov_query.test.js +115 -0
  53. package/dist/test/18.util.test.d.ts +1 -0
  54. package/dist/test/18.util.test.js +246 -0
  55. package/dist/test/19.chain.test.d.ts +1 -0
  56. package/dist/test/19.chain.test.js +67 -0
  57. package/dist/test/20.slashing_query.test.d.ts +1 -0
  58. package/dist/test/20.slashing_query.test.js +82 -0
  59. package/dist/test/21.token_tx.test.d.ts +1 -0
  60. package/dist/test/21.token_tx.test.js +154 -0
  61. package/dist/test/22.token_query.test.d.ts +1 -0
  62. package/dist/test/22.token_query.test.js +96 -0
  63. package/dist/test/23.authz_tx.test.d.ts +1 -0
  64. package/dist/test/23.authz_tx.test.js +468 -0
  65. package/dist/test/24.authz_query.test.d.ts +1 -0
  66. package/dist/test/24.authz_query.test.js +140 -0
  67. package/dist/test/25.cosmwasm_tx.test.d.ts +1 -0
  68. package/dist/test/25.cosmwasm_tx.test.js +188 -0
  69. package/dist/test/26.cosmwasm_query.test.d.ts +1 -0
  70. package/dist/test/26.cosmwasm_query.test.js +167 -0
  71. package/dist/test/27.arbitary_sign.test.d.ts +1 -0
  72. package/dist/test/27.arbitary_sign.test.js +164 -0
  73. package/dist/test/28.ibc_tx.test.d.ts +1 -0
  74. package/dist/test/28.ibc_tx.test.js +83 -0
  75. package/dist/test/29.mint_query.copy.d.ts +1 -0
  76. package/dist/test/29.mint_query.copy.js +54 -0
  77. package/dist/test/config_test.d.ts +5 -0
  78. package/dist/test/config_test.js +27 -0
  79. package/package.json +1 -1
@@ -0,0 +1,188 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var chai_1 = require("chai");
43
+ var FirmaSDK_1 = require("../sdk/FirmaSDK");
44
+ var FirmaUtil_1 = require("../sdk/FirmaUtil");
45
+ var config_test_1 = require("./config_test");
46
+ var fs_1 = __importDefault(require("fs"));
47
+ var types_1 = require("cosmjs-types/cosmwasm/wasm/v1/types");
48
+ describe('[25. CosmWasm Tx Test]', function () {
49
+ var firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
50
+ // sample : cw_nameservice.wasm
51
+ // https://docs.cosmwasm.com/docs/1.0/getting-started/compile-contract
52
+ var codeId = "";
53
+ var contractAddress = "";
54
+ it('CosmWasm StoreCode', function () { return __awaiter(void 0, void 0, void 0, function () {
55
+ var aliceWallet, aliceAddress, wasmFile, array, gas, fee, everyBodyAccessConfig, result, data;
56
+ return __generator(this, function (_a) {
57
+ switch (_a.label) {
58
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
59
+ case 1:
60
+ aliceWallet = _a.sent();
61
+ return [4 /*yield*/, aliceWallet.getAddress()];
62
+ case 2:
63
+ aliceAddress = _a.sent();
64
+ wasmFile = fs_1.default.readFileSync("./test/sample/cw_nameservice.wasm");
65
+ array = new Uint8Array(wasmFile.buffer);
66
+ gas = 3000000;
67
+ fee = FirmaUtil_1.FirmaUtil.getUFCTFromFCT(0.3);
68
+ everyBodyAccessConfig = { permission: types_1.AccessType.ACCESS_TYPE_EVERYBODY, address: "" };
69
+ return [4 /*yield*/, firma.CosmWasm.storeCode(aliceWallet, array, everyBodyAccessConfig, { gas: gas, fee: fee })];
70
+ case 3:
71
+ result = _a.sent();
72
+ data = JSON.parse(result.rawLog);
73
+ codeId = data[0]["events"][1]["attributes"][1]["value"];
74
+ //console.log(codeId);
75
+ //console.log(result);
76
+ (0, chai_1.expect)(result.code).to.be.equal(0);
77
+ return [2 /*return*/];
78
+ }
79
+ });
80
+ }); });
81
+ it('CosmWasm InstantiateContract', function () { return __awaiter(void 0, void 0, void 0, function () {
82
+ var aliceWallet, admin, label, gas, fee, funds, testData, result, data;
83
+ return __generator(this, function (_a) {
84
+ switch (_a.label) {
85
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
86
+ case 1:
87
+ aliceWallet = _a.sent();
88
+ return [4 /*yield*/, aliceWallet.getAddress()];
89
+ case 2:
90
+ admin = _a.sent();
91
+ label = "test1";
92
+ gas = 3000000;
93
+ fee = FirmaUtil_1.FirmaUtil.getUFCTFromFCT(0.3);
94
+ funds = [];
95
+ testData = JSON.stringify({ "purchase_price": { "amount": "100", "denom": "ufct" }, "transfer_price": { "amount": "999", "denom": "ufct" } });
96
+ return [4 /*yield*/, firma.CosmWasm.instantiateContract(aliceWallet, admin, codeId, label, testData, funds, { gas: gas, fee: fee })];
97
+ case 3:
98
+ result = _a.sent();
99
+ data = JSON.parse(result.rawLog);
100
+ contractAddress = data[0]["events"][0]["attributes"][0]["value"];
101
+ (0, chai_1.expect)(result.code).to.be.equal(0);
102
+ return [2 /*return*/];
103
+ }
104
+ });
105
+ }); });
106
+ it('CosmWasm ExecuteContract', function () { return __awaiter(void 0, void 0, void 0, function () {
107
+ var aliceWallet, gas, fee, testData, amountFCT, funds, result;
108
+ return __generator(this, function (_a) {
109
+ switch (_a.label) {
110
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
111
+ case 1:
112
+ aliceWallet = _a.sent();
113
+ gas = 3000000;
114
+ fee = FirmaUtil_1.FirmaUtil.getUFCTFromFCT(0.3);
115
+ testData = JSON.stringify({ "register": { "name": "fred" } });
116
+ amountFCT = 0.01;
117
+ funds = [{ denom: firma.Config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountFCT) }];
118
+ return [4 /*yield*/, firma.CosmWasm.executeContract(aliceWallet, contractAddress, testData, funds, { gas: gas, fee: fee })];
119
+ case 2:
120
+ result = _a.sent();
121
+ //console.log(result);
122
+ (0, chai_1.expect)(result.code).to.be.equal(0);
123
+ return [2 /*return*/];
124
+ }
125
+ });
126
+ }); });
127
+ it('CosmWasm UpdateAdmin', function () { return __awaiter(void 0, void 0, void 0, function () {
128
+ var aliceWallet, bobWallet, bobAddress, gas, fee, result;
129
+ return __generator(this, function (_a) {
130
+ switch (_a.label) {
131
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
132
+ case 1:
133
+ aliceWallet = _a.sent();
134
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
135
+ case 2:
136
+ bobWallet = _a.sent();
137
+ return [4 /*yield*/, bobWallet.getAddress()];
138
+ case 3:
139
+ bobAddress = _a.sent();
140
+ gas = 3000000;
141
+ fee = FirmaUtil_1.FirmaUtil.getUFCTFromFCT(0.3);
142
+ return [4 /*yield*/, firma.CosmWasm.updateAdmin(aliceWallet, contractAddress, bobAddress, { gas: gas, fee: fee })];
143
+ case 4:
144
+ result = _a.sent();
145
+ //console.log(result);
146
+ (0, chai_1.expect)(result.code).to.be.equal(0);
147
+ return [2 /*return*/];
148
+ }
149
+ });
150
+ }); });
151
+ it('CosmWasm ClearAdmin', function () { return __awaiter(void 0, void 0, void 0, function () {
152
+ var aliceWallet, gas, fee, result;
153
+ return __generator(this, function (_a) {
154
+ switch (_a.label) {
155
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
156
+ case 1:
157
+ aliceWallet = _a.sent();
158
+ gas = 3000000;
159
+ fee = FirmaUtil_1.FirmaUtil.getUFCTFromFCT(0.3);
160
+ return [4 /*yield*/, firma.CosmWasm.clearAdmin(aliceWallet, contractAddress, { gas: gas, fee: fee })];
161
+ case 2:
162
+ result = _a.sent();
163
+ //console.log(result);
164
+ (0, chai_1.expect)(result.code).to.be.equal(0);
165
+ return [2 /*return*/];
166
+ }
167
+ });
168
+ }); });
169
+ it.skip('CosmWasm MigrateContract', function () { return __awaiter(void 0, void 0, void 0, function () {
170
+ var aliceWallet, gas, fee, testData, result;
171
+ return __generator(this, function (_a) {
172
+ switch (_a.label) {
173
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
174
+ case 1:
175
+ aliceWallet = _a.sent();
176
+ gas = 3000000;
177
+ fee = FirmaUtil_1.FirmaUtil.getUFCTFromFCT(0.3);
178
+ testData = JSON.stringify({ "purchase_price": { "amount": "1000", "denom": "ufct" }, "transfer_price": { "amount": "9990", "denom": "ufct" } });
179
+ return [4 /*yield*/, firma.CosmWasm.migrateContract(aliceWallet, contractAddress, codeId, testData, { gas: gas, fee: fee })];
180
+ case 2:
181
+ result = _a.sent();
182
+ //console.log(result);
183
+ (0, chai_1.expect)(result.code).to.be.equal(0);
184
+ return [2 /*return*/];
185
+ }
186
+ });
187
+ }); });
188
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,167 @@
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
+ var FirmaSDK_1 = require("../sdk/FirmaSDK");
40
+ var config_test_1 = require("./config_test");
41
+ describe('[26. cosmwasm query Test]', function () {
42
+ var firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
43
+ var contractAddress = "";
44
+ it('CosmWasm getCodeList', function () { return __awaiter(void 0, void 0, void 0, function () {
45
+ var result;
46
+ return __generator(this, function (_a) {
47
+ switch (_a.label) {
48
+ case 0: return [4 /*yield*/, firma.CosmWasm.getCodeList()];
49
+ case 1:
50
+ result = _a.sent();
51
+ return [2 /*return*/];
52
+ }
53
+ });
54
+ }); });
55
+ it('CosmWasm getCodeData', function () { return __awaiter(void 0, void 0, void 0, function () {
56
+ var codeId, result;
57
+ return __generator(this, function (_a) {
58
+ switch (_a.label) {
59
+ case 0:
60
+ codeId = "1";
61
+ return [4 /*yield*/, firma.CosmWasm.getCodeData(codeId)];
62
+ case 1:
63
+ result = _a.sent();
64
+ return [2 /*return*/];
65
+ }
66
+ });
67
+ }); });
68
+ it('CosmWasm getCodeData', function () { return __awaiter(void 0, void 0, void 0, function () {
69
+ var codeId, result;
70
+ return __generator(this, function (_a) {
71
+ switch (_a.label) {
72
+ case 0:
73
+ codeId = "1";
74
+ return [4 /*yield*/, firma.CosmWasm.getCodeData(codeId)];
75
+ case 1:
76
+ result = _a.sent();
77
+ return [2 /*return*/];
78
+ }
79
+ });
80
+ }); });
81
+ it('CosmWasm getContractListFromCodeId', function () { return __awaiter(void 0, void 0, void 0, function () {
82
+ var codeId, result;
83
+ return __generator(this, function (_a) {
84
+ switch (_a.label) {
85
+ case 0:
86
+ codeId = "1";
87
+ return [4 /*yield*/, firma.CosmWasm.getContractListFromCodeId(codeId)];
88
+ case 1:
89
+ result = _a.sent();
90
+ contractAddress = result[0];
91
+ return [2 /*return*/];
92
+ }
93
+ });
94
+ }); });
95
+ it('CosmWasm getPinnedCodeList', function () { return __awaiter(void 0, void 0, void 0, function () {
96
+ var codeList;
97
+ return __generator(this, function (_a) {
98
+ switch (_a.label) {
99
+ case 0: return [4 /*yield*/, firma.CosmWasm.getPinnedCodeList()];
100
+ case 1:
101
+ codeList = _a.sent();
102
+ return [2 /*return*/];
103
+ }
104
+ });
105
+ }); });
106
+ // ContractInfo gets the contract meta data
107
+ it('CosmWasm getContractInfo', function () { return __awaiter(void 0, void 0, void 0, function () {
108
+ var result;
109
+ return __generator(this, function (_a) {
110
+ switch (_a.label) {
111
+ case 0: return [4 /*yield*/, firma.CosmWasm.getContractInfo(contractAddress)];
112
+ case 1:
113
+ result = _a.sent();
114
+ return [2 /*return*/];
115
+ }
116
+ });
117
+ }); });
118
+ it('CosmWasm getContractHistory', function () { return __awaiter(void 0, void 0, void 0, function () {
119
+ var result;
120
+ return __generator(this, function (_a) {
121
+ switch (_a.label) {
122
+ case 0: return [4 /*yield*/, firma.CosmWasm.getContractHistory(contractAddress)];
123
+ case 1:
124
+ result = _a.sent();
125
+ return [2 /*return*/];
126
+ }
127
+ });
128
+ }); });
129
+ // AllContractState gets all raw store data for a single contract
130
+ it('CosmWasm getContractState', function () { return __awaiter(void 0, void 0, void 0, function () {
131
+ var result;
132
+ return __generator(this, function (_a) {
133
+ switch (_a.label) {
134
+ case 0: return [4 /*yield*/, firma.CosmWasm.getContractState(contractAddress)];
135
+ case 1:
136
+ result = _a.sent();
137
+ return [2 /*return*/];
138
+ }
139
+ });
140
+ }); });
141
+ it('CosmWasm getContractRawQueryData', function () { return __awaiter(void 0, void 0, void 0, function () {
142
+ var hexString, result;
143
+ return __generator(this, function (_a) {
144
+ switch (_a.label) {
145
+ case 0:
146
+ hexString = '0006636F6E666967';
147
+ return [4 /*yield*/, firma.CosmWasm.getContractRawQueryData(contractAddress, hexString)];
148
+ case 1:
149
+ result = _a.sent();
150
+ return [2 /*return*/];
151
+ }
152
+ });
153
+ }); });
154
+ it('CosmWasm getContractSmartQueryData', function () { return __awaiter(void 0, void 0, void 0, function () {
155
+ var query, result;
156
+ return __generator(this, function (_a) {
157
+ switch (_a.label) {
158
+ case 0:
159
+ query = '{"resolve_record": { "name": "fred" }}';
160
+ return [4 /*yield*/, firma.CosmWasm.getContractSmartQueryData(contractAddress, query)];
161
+ case 1:
162
+ result = _a.sent();
163
+ return [2 /*return*/];
164
+ }
165
+ });
166
+ }); });
167
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,164 @@
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
+ var chai_1 = require("chai");
40
+ var FirmaSDK_1 = require("../sdk/FirmaSDK");
41
+ var FirmaUtil_1 = require("../sdk/FirmaUtil");
42
+ var config_test_1 = require("./config_test");
43
+ var bank_1 = require("../sdk/firmachain/bank");
44
+ describe('[27. arbitary sign]', function () {
45
+ var firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
46
+ // https://docs.cosmos.network/master/architecture/adr-036-arbitrary-signature.html
47
+ // https://github.com/cosmos/cosmjs/issues/844
48
+ // https://github.com/cosmos/cosmjs/pull/847
49
+ it('arbitary sign & verify basic test', function () { return __awaiter(void 0, void 0, void 0, function () {
50
+ var aliceWallet, testMsg, signatureResult, jsonString, finalData, isMatch;
51
+ return __generator(this, function (_a) {
52
+ switch (_a.label) {
53
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
54
+ case 1:
55
+ aliceWallet = _a.sent();
56
+ testMsg = "3936a4db-1d18-4cb6-8274-bccb1541f021";
57
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.experimentalAdr36Sign(aliceWallet, testMsg)];
58
+ case 2:
59
+ signatureResult = _a.sent();
60
+ jsonString = JSON.stringify(signatureResult);
61
+ finalData = JSON.parse(jsonString);
62
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.experimentalAdr36Verify(finalData, testMsg)];
63
+ case 3:
64
+ isMatch = _a.sent();
65
+ //console.log(isMatch);
66
+ (0, chai_1.expect)(isMatch).to.be.equal(true);
67
+ return [2 /*return*/];
68
+ }
69
+ });
70
+ }); });
71
+ it('direct sign & verify basic test', function () { return __awaiter(void 0, void 0, void 0, function () {
72
+ var aliceWallet, bobWallet, amountFCT, aliceAddress, alicePubkey, bobAddress, sendAmount, msgSend, stringSignDoc, signDoc, commonTxClient, extTxRaw, valid;
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
76
+ case 1:
77
+ aliceWallet = _a.sent();
78
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
79
+ case 2:
80
+ bobWallet = _a.sent();
81
+ amountFCT = 9;
82
+ return [4 /*yield*/, aliceWallet.getAddress()];
83
+ case 3:
84
+ aliceAddress = _a.sent();
85
+ return [4 /*yield*/, aliceWallet.getPubKey()];
86
+ case 4:
87
+ alicePubkey = _a.sent();
88
+ return [4 /*yield*/, bobWallet.getAddress()];
89
+ case 5:
90
+ bobAddress = _a.sent();
91
+ sendAmount = { denom: firma.Config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountFCT) };
92
+ msgSend = bank_1.BankTxClient.msgSend({
93
+ fromAddress: aliceAddress,
94
+ toAddress: bobAddress,
95
+ amount: [sendAmount]
96
+ });
97
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.makeSignDocWithStringify(aliceAddress, alicePubkey, [msgSend])];
98
+ case 6:
99
+ stringSignDoc = _a.sent();
100
+ signDoc = FirmaUtil_1.FirmaUtil.parseSignDocValues(stringSignDoc);
101
+ commonTxClient = FirmaUtil_1.FirmaUtil.getCommonTxClient(aliceWallet);
102
+ return [4 /*yield*/, commonTxClient.signDirectForSignDoc(aliceAddress, signDoc)];
103
+ case 7:
104
+ extTxRaw = _a.sent();
105
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.verifyDirectSignature(aliceAddress, extTxRaw.signature, signDoc)];
106
+ case 8:
107
+ valid = _a.sent();
108
+ (0, chai_1.expect)(valid).to.be.equal(true);
109
+ return [2 /*return*/];
110
+ }
111
+ });
112
+ }); });
113
+ it('direct sign & verify & send basic test', function () { return __awaiter(void 0, void 0, void 0, function () {
114
+ var aliceWallet, bobWallet, amountFCT, aliceAddress, alicePubkey, bobAddress, sendAmount, msgSend, signDoc, stringSignDoc, newSignDoc, commonTxClient, extTxRaw, valid, result;
115
+ return __generator(this, function (_a) {
116
+ switch (_a.label) {
117
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
118
+ case 1:
119
+ aliceWallet = _a.sent();
120
+ return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.bobMnemonic)];
121
+ case 2:
122
+ bobWallet = _a.sent();
123
+ amountFCT = 9;
124
+ return [4 /*yield*/, aliceWallet.getAddress()];
125
+ case 3:
126
+ aliceAddress = _a.sent();
127
+ return [4 /*yield*/, aliceWallet.getPubKey()];
128
+ case 4:
129
+ alicePubkey = _a.sent();
130
+ return [4 /*yield*/, bobWallet.getAddress()];
131
+ case 5:
132
+ bobAddress = _a.sent();
133
+ sendAmount = { denom: firma.Config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amountFCT) };
134
+ msgSend = bank_1.BankTxClient.msgSend({
135
+ fromAddress: aliceAddress,
136
+ toAddress: bobAddress,
137
+ amount: [sendAmount]
138
+ });
139
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.makeSignDoc(aliceAddress, alicePubkey, [msgSend])];
140
+ case 6:
141
+ signDoc = _a.sent();
142
+ stringSignDoc = FirmaUtil_1.FirmaUtil.stringifySignDocValues(signDoc);
143
+ newSignDoc = FirmaUtil_1.FirmaUtil.parseSignDocValues(stringSignDoc);
144
+ commonTxClient = FirmaUtil_1.FirmaUtil.getCommonTxClient(aliceWallet);
145
+ return [4 /*yield*/, commonTxClient.signDirectForSignDoc(aliceAddress, newSignDoc)];
146
+ case 7:
147
+ extTxRaw = _a.sent();
148
+ return [4 /*yield*/, FirmaUtil_1.FirmaUtil.verifyDirectSignature(aliceAddress, extTxRaw.signature, newSignDoc)];
149
+ case 8:
150
+ valid = _a.sent();
151
+ if (!valid) return [3 /*break*/, 10];
152
+ return [4 /*yield*/, commonTxClient.broadcast(extTxRaw.txRaw)];
153
+ case 9:
154
+ result = _a.sent();
155
+ //console.log(result);
156
+ (0, chai_1.expect)(result.code).to.be.equal(0);
157
+ _a.label = 10;
158
+ case 10:
159
+ (0, chai_1.expect)(valid).to.be.equal(true);
160
+ return [2 /*return*/];
161
+ }
162
+ });
163
+ }); });
164
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,83 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var client_1 = require("cosmjs-types/ibc/core/client/v1/client");
43
+ var long_1 = __importDefault(require("long"));
44
+ var FirmaSDK_1 = require("../sdk/FirmaSDK");
45
+ var FirmaUtil_1 = require("../sdk/FirmaUtil");
46
+ var config_test_1 = require("./config_test");
47
+ describe('[28. IBC Tx Test]', function () {
48
+ var firma = new FirmaSDK_1.FirmaSDK(config_test_1.TestChainConfig);
49
+ it.skip('IBC transfer', function () { return __awaiter(void 0, void 0, void 0, function () {
50
+ var aliceWallet, sourcePort, sourceChannel, denom, amount, receiver, clientState, revison_height, revison_number, height, timeStamp, timeoutTimeStamp, gas, fee, result;
51
+ return __generator(this, function (_a) {
52
+ switch (_a.label) {
53
+ case 0: return [4 /*yield*/, firma.Wallet.fromMnemonic(config_test_1.aliceMnemonic)];
54
+ case 1:
55
+ aliceWallet = _a.sent();
56
+ sourcePort = "transfer";
57
+ sourceChannel = "channel-3";
58
+ denom = "ufct";
59
+ amount = "1000000";
60
+ receiver = "firma1320eclh4dwzx89qjap2q5n2hna07zs2vm8tzlu";
61
+ return [4 /*yield*/, firma.Ibc.getClientState(sourceChannel, sourcePort)];
62
+ case 2:
63
+ clientState = _a.sent();
64
+ revison_height = clientState.identified_client_state.client_state.latest_height.revision_height;
65
+ revison_number = clientState.identified_client_state.client_state.latest_height.revision_number;
66
+ height = client_1.Height.fromPartial({
67
+ revisionHeight: long_1.default.fromString(revison_height, true).add(long_1.default.fromNumber(1000)),
68
+ revisionNumber: long_1.default.fromString(revison_number, true),
69
+ });
70
+ timeStamp = (Date.now() + 600000).toString() + "000000";
71
+ timeoutTimeStamp = long_1.default.fromString(timeStamp, true);
72
+ return [4 /*yield*/, firma.Ibc.getGasEstimationTransfer(aliceWallet, sourcePort, sourceChannel, denom, amount, receiver, height, timeoutTimeStamp)];
73
+ case 3:
74
+ gas = _a.sent();
75
+ fee = FirmaUtil_1.FirmaUtil.getUFCTFromFCT(gas * 0.1);
76
+ return [4 /*yield*/, firma.Ibc.transfer(aliceWallet, sourcePort, sourceChannel, denom, amount, receiver, height, timeoutTimeStamp, { gas: gas, fee: fee })];
77
+ case 4:
78
+ result = _a.sent();
79
+ return [2 /*return*/];
80
+ }
81
+ });
82
+ }); });
83
+ });
@@ -0,0 +1 @@
1
+ export {};