@firmachain/firma-js 0.2.22 → 0.2.26

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.
package/README.md CHANGED
@@ -36,21 +36,27 @@ npm i @firmachain/firma-js
36
36
  import { FirmaSDK } from "@firmachain/firma-js"
37
37
  import { FirmaConfig } from "@firmachain/firma-js"
38
38
 
39
- // use preset config
39
+ // use preset config : testnet
40
40
  const firma = new FirmaSDK(FirmaConfig.TestNetConfig);
41
41
 
42
+ // use preset config : mainnet
43
+ const firma = new FirmaSDK(FirmaConfig.MainNetConfig);
44
+
42
45
  // or use custom set
46
+
43
47
  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,
48
+ chainID: "colosseum-1",
49
+ rpcAddress: "https://lcd-mainnet.firmachain.dev:26657",
50
+ restApiAddress: "https://lcd-mainnet.firmachain.dev:1317",
51
+ ipfsNodeAddress: "https://ipfs-dev.firmachain.dev",
52
+ ipfsNodePort: 5001,
53
+ ipfsWebApiAddress: "https://ipfs-dev.firmachain.dev",
54
+ hdPath: "m/44'/7777777'/",
55
+ prefix: "firma",
56
+ denom: "ufct",
57
+ defaultFee: 30000,
58
+ defaultGas: 300000,
59
+ isShowLog: false,
54
60
  }
55
61
 
56
62
  const firma = new FirmaSDK(chainConfig);
@@ -106,7 +112,7 @@ let result = await firma.Bank.send(wallet, address, fctAmount);
106
112
  ### Bank send - extended version
107
113
  ```js
108
114
  const fctAmount = 10;
109
- let result = await firma.Bank.send(wallet, address, fctAmount, { memo: "", fee: 3000, gas: 200000 });
115
+ let result = await firma.Bank.send(wallet, address, fctAmount, { memo: "", fee: 30000, gas: 300000 });
110
116
  ```
111
117
 
112
118
  ### Calculate gas
@@ -134,4 +140,4 @@ let result = await firma.Nft.burn(wallet, tokenId);
134
140
 
135
141
  You can see everything usage of firma-js on the test folder.
136
142
  </br>
137
- https://github.com/FirmaChain/firma-js/tree/main/test
143
+ https://github.com/FirmaChain/firma-js/tree/main/test
@@ -46,16 +46,16 @@ var FirmaConfig = /** @class */ (function () {
46
46
  };
47
47
  FirmaConfig.MainNetConfig = {
48
48
  chainID: "colosseum-1",
49
- rpcAddress: "https://lcd-mainnet.firmachain.org:26657",
50
- restApiAddress: "https://lcd-mainnet.firmachain.org:1317",
49
+ rpcAddress: "https://lcd-mainnet.firmachain.dev:26657",
50
+ restApiAddress: "https://lcd-mainnet.firmachain.dev:1317",
51
51
  ipfsNodeAddress: "https://ipfs-dev.firmachain.dev",
52
52
  ipfsNodePort: 5001,
53
53
  ipfsWebApiAddress: "https://ipfs-dev.firmachain.dev",
54
54
  hdPath: "m/44'/7777777'/",
55
55
  prefix: "firma",
56
56
  denom: "ufct",
57
- defaultFee: 20000,
58
- defaultGas: 200000,
57
+ defaultFee: 30000,
58
+ defaultGas: 300000,
59
59
  isShowLog: false,
60
60
  };
61
61
  return FirmaConfig;
@@ -17,7 +17,9 @@ export declare class FirmaUtil {
17
17
  static getUFCTStringFromFCT(fctAmount: number): string;
18
18
  static getFCTStringFromUFCT(uFctAmount: number): string;
19
19
  static getFileHash(filePath: string): Promise<string>;
20
- static getFileHashFromBuffer(buffer: Uint8Array): Promise<string>;
20
+ static getFileHashFromBuffer(buffer: Uint8Array): string;
21
+ static getSha1HashFromString(text: string): string;
22
+ static getHashFromString(text: string): string;
21
23
  static isValidAddress(address: string): boolean;
22
24
  static getValOperAddressFromAccAddress(address: string): string;
23
25
  static getAccAddressFromValOperAddress(address: string): string;
@@ -43,6 +43,7 @@ var TendermintQueryClient_1 = require("./firmachain/common/TendermintQueryClient
43
43
  var encoding_1 = require("@cosmjs/encoding");
44
44
  var LedgerSigningStargateClient_1 = require("./firmachain/common/LedgerSigningStargateClient");
45
45
  var CryptoJS = require("crypto-js");
46
+ var sha1 = require("crypto-js/sha1");
46
47
  var sha256 = require("crypto-js/sha256");
47
48
  var encHex = require("crypto-js/enc-hex");
48
49
  var FirmaUtil = /** @class */ (function () {
@@ -115,13 +116,16 @@ var FirmaUtil = /** @class */ (function () {
115
116
  });
116
117
  };
117
118
  FirmaUtil.getFileHashFromBuffer = function (buffer) {
118
- return __awaiter(this, void 0, void 0, function () {
119
- var data;
120
- return __generator(this, function (_a) {
121
- data = CryptoJS.lib.WordArray.create(buffer);
122
- return [2 /*return*/, sha256(data).toString(encHex)];
123
- });
124
- });
119
+ var data = CryptoJS.lib.WordArray.create(buffer);
120
+ return sha256(data).toString(encHex);
121
+ };
122
+ FirmaUtil.getSha1HashFromString = function (text) {
123
+ var data = CryptoJS.lib.WordArray.create(text);
124
+ return sha1(data).toString(encHex);
125
+ };
126
+ FirmaUtil.getHashFromString = function (text) {
127
+ var data = CryptoJS.lib.WordArray.create(text);
128
+ return sha256(data).toString(encHex);
125
129
  };
126
130
  FirmaUtil.isValidAddress = function (address) {
127
131
  try {
@@ -62,6 +62,9 @@ var TendermintQueryClient = /** @class */ (function () {
62
62
  case 1:
63
63
  result = _a.sent();
64
64
  data = result.data.result.response.value;
65
+ if (result.data.result.response.code != 0) {
66
+ throw result.data.result.response.log;
67
+ }
65
68
  jsonString = Buffer.from(data, "base64").toString("utf8");
66
69
  jsonData = JSON.parse(jsonString);
67
70
  return [2 /*return*/, Number.parseInt(jsonData.gas_info.gas_used)];
@@ -23,7 +23,7 @@ export interface RedelegationInfo {
23
23
  initial_balance: string;
24
24
  shares_dst: string;
25
25
  };
26
- balances: string;
26
+ balance: string;
27
27
  }[];
28
28
  }
29
29
  export interface UndelegationInfo {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firmachain/firma-js",
3
- "version": "0.2.22",
3
+ "version": "0.2.26",
4
4
  "description": "The Official FirmaChain Javascript SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -8,7 +8,7 @@
8
8
  "dist"
9
9
  ],
10
10
  "scripts": {
11
- "test": "mocha test/**/*.test.ts -r ts-node/register --timeout 120000",
11
+ "test": "mocha test/**/*.test.ts -r ts-node/register --timeout 1200000",
12
12
  "lint": "eslint src test --ext .ts,.tsx",
13
13
  "nodemon": "nodemon",
14
14
  "dev": "ts-node ./test/test_index.ts",
@@ -40,7 +40,8 @@
40
40
  "cosmjs-types": "^0.2.0",
41
41
  "crypto-js": "^4.1.1",
42
42
  "ipfs-http-client": "^52.0.5",
43
- "protobufjs": "^6.10.2"
43
+ "protobufjs": "^6.10.2",
44
+ "readline-sync": "^1.4.10"
44
45
  },
45
46
  "devDependencies": {
46
47
  "@types/chai": "^4.2.21",
@@ -52,4 +53,4 @@
52
53
  "ts-node": "^10.2.1",
53
54
  "typescript": "^4.3.5"
54
55
  }
55
- }
56
+ }