Skip to content

Commit 0410872

Browse files
committed
updata axios version
1 parent f1e0cf4 commit 0410872

File tree

3 files changed

+103
-50
lines changed

3 files changed

+103
-50
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"dependencies": {
2424
"@babel/runtime": "^7.0.0",
25-
"axios": "^0.19.0",
25+
"axios": "^0.21.1",
2626
"babel-runtime": "^6.26.0",
2727
"bignumber.js": "^7.2.1",
2828
"elliptic": "^6.5.3",

src/utils/ethersUtils.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
2-
import {utils} from 'ethers';
1+
import { utils } from "ethers";
32

43
const keccak256 = utils.keccak256;
54
const sha256 = utils.sha256;
65
const toUtf8Bytes = utils.toUtf8Bytes;
6+
const toUtf8String = utils.toUtf8String;
77
const recoverAddress = utils.recoverAddress;
88
const SigningKey = utils.SigningKey;
99
const AbiCoder = utils.AbiCoder;
@@ -12,7 +12,8 @@ export {
1212
keccak256,
1313
sha256,
1414
toUtf8Bytes,
15+
toUtf8String,
1516
recoverAddress,
1617
SigningKey,
17-
AbiCoder
18-
}
18+
AbiCoder,
19+
};

test/index.test.js

+97-45
Original file line numberDiff line numberDiff line change
@@ -1134,114 +1134,153 @@ describe('TronWeb Instance', function () {
11341134
});
11351135

11361136
describe("#testTronGrid", function () {
1137-
11381137
describe("#testTronGridApiKey", function () {
1139-
11401138
it("should add the parameter TRON-PRO-API-KEY=Key to the header of the request", async function () {
1141-
11421139
const tronWeb = tronWebBuilder.createInstance({
11431140
fullHost: TEST_TRON_GRID_API,
11441141
headers: { "TRON-PRO-API-KEY": TEST_TRON_HEADER_API_KEY },
11451142
});
11461143

1147-
assert.equal(tronWeb.fullNode.headers['TRON-PRO-API-KEY'], TEST_TRON_HEADER_API_KEY);
1148-
assert.equal(tronWeb.eventServer.headers['TRON-PRO-API-KEY'], TEST_TRON_HEADER_API_KEY);
1144+
assert.equal(
1145+
tronWeb.fullNode.headers["TRON-PRO-API-KEY"],
1146+
TEST_TRON_HEADER_API_KEY
1147+
);
1148+
assert.equal(
1149+
tronWeb.eventServer.headers["TRON-PRO-API-KEY"],
1150+
TEST_TRON_HEADER_API_KEY
1151+
);
11491152

11501153
const account = await tronWeb.trx.getAccount();
11511154
assert.equal(typeof account, "object");
11521155

1153-
const tx = await tronWeb.event.getEventsByContractAddress(tronWeb.defaultAddress.base58);
1156+
const tx = await tronWeb.event.getEventsByContractAddress(
1157+
tronWeb.defaultAddress.base58
1158+
);
11541159
assert.equal(typeof tx, "object");
11551160
});
11561161

11571162
it("should add the parameter TRON-PRO-API-KEY=Key to the header of the event request", async function () {
1158-
11591163
const tronWeb = tronWebBuilder.createInstance({
11601164
fullHost: TEST_TRON_GRID_API,
11611165
headers: { "TRON-PRO-API-KEY": TEST_TRON_HEADER_API_KEY },
11621166
eventHeaders: { "TRON-PRO-API-KEY": TEST_TRON_HEADER_API_KEY },
11631167
});
11641168

1165-
assert.equal(tronWeb.fullNode.headers['TRON-PRO-API-KEY'], TEST_TRON_HEADER_API_KEY);
1166-
assert.equal(tronWeb.eventServer.headers['TRON-PRO-API-KEY'], TEST_TRON_HEADER_API_KEY);
1169+
assert.equal(
1170+
tronWeb.fullNode.headers["TRON-PRO-API-KEY"],
1171+
TEST_TRON_HEADER_API_KEY
1172+
);
1173+
assert.equal(
1174+
tronWeb.eventServer.headers["TRON-PRO-API-KEY"],
1175+
TEST_TRON_HEADER_API_KEY
1176+
);
11671177

11681178
const account = await tronWeb.trx.getAccount();
11691179
assert.equal(typeof account, "object");
11701180

1171-
const tx = await tronWeb.event.getEventsByContractAddress(tronWeb.defaultAddress.base58);
1181+
const tx = await tronWeb.event.getEventsByContractAddress(
1182+
tronWeb.defaultAddress.base58
1183+
);
11721184
assert.equal(typeof tx, "object");
11731185
});
11741186

1175-
11761187
it("should set the parameter TRON-PRO-API-KEY=Key to the header of the request", async function () {
1177-
11781188
const tronWeb = tronWebBuilder.createInstance({
11791189
fullHost: TEST_TRON_GRID_API,
11801190
});
11811191
tronWeb.setHeader({ "TRON-PRO-API-KEY": TEST_TRON_HEADER_API_KEY });
11821192

1183-
assert.equal(tronWeb.fullNode.headers['TRON-PRO-API-KEY'], TEST_TRON_HEADER_API_KEY);
1184-
assert.equal(tronWeb.eventServer.headers['TRON-PRO-API-KEY'], TEST_TRON_HEADER_API_KEY);
1193+
assert.equal(
1194+
tronWeb.fullNode.headers["TRON-PRO-API-KEY"],
1195+
TEST_TRON_HEADER_API_KEY
1196+
);
1197+
assert.equal(
1198+
tronWeb.eventServer.headers["TRON-PRO-API-KEY"],
1199+
TEST_TRON_HEADER_API_KEY
1200+
);
11851201

11861202
const account = await tronWeb.trx.getAccount();
11871203
assert.equal(typeof account, "object");
11881204

1189-
const tx = await tronWeb.event.getEventsByContractAddress(tronWeb.defaultAddress.base58);
1205+
const tx = await tronWeb.event.getEventsByContractAddress(
1206+
tronWeb.defaultAddress.base58
1207+
);
11901208
assert.equal(typeof tx, "object");
11911209
});
11921210

1193-
11941211
it("should set the parameter TRON-PRO-API-KEY=Key to the header of the fullNode request", async function () {
1195-
11961212
const tronWeb = tronWebBuilder.createInstance({
11971213
fullHost: TEST_TRON_GRID_API,
11981214
});
1199-
tronWeb.setFullNodeHeader({ "TRON-PRO-API-KEY": TEST_TRON_HEADER_API_KEY });
1215+
tronWeb.setFullNodeHeader({
1216+
"TRON-PRO-API-KEY": TEST_TRON_HEADER_API_KEY,
1217+
});
12001218

1201-
assert.equal(tronWeb.fullNode.headers['TRON-PRO-API-KEY'], TEST_TRON_HEADER_API_KEY);
1202-
assert.equal(tronWeb.eventServer.headers['TRON-PRO-API-KEY'], undefined);
1219+
assert.equal(
1220+
tronWeb.fullNode.headers["TRON-PRO-API-KEY"],
1221+
TEST_TRON_HEADER_API_KEY
1222+
);
1223+
assert.equal(
1224+
tronWeb.eventServer.headers["TRON-PRO-API-KEY"],
1225+
undefined
1226+
);
12031227

12041228
const account = await tronWeb.trx.getAccount();
12051229
assert.equal(typeof account, "object");
12061230

12071231
try {
1208-
await tronWeb.event.getEventsByContractAddress(tronWeb.defaultAddress.base58);
1232+
await tronWeb.event.getEventsByContractAddress(
1233+
tronWeb.defaultAddress.base58
1234+
);
12091235
} catch (error) {
12101236
assert.equal(error.statusCode, 401);
12111237
}
12121238
});
12131239

1214-
12151240
it("should set the parameter TRON-PRO-API-KEY=Key to the header of the event request", async function () {
1216-
12171241
const tronWeb = tronWebBuilder.createInstance({
12181242
fullHost: TEST_TRON_GRID_API,
12191243
});
1220-
tronWeb.setEventHeader({ "TRON-PRO-API-KEY": TEST_TRON_HEADER_API_KEY });
1244+
tronWeb.setEventHeader({
1245+
"TRON-PRO-API-KEY": TEST_TRON_HEADER_API_KEY,
1246+
});
12211247

1222-
assert.equal(tronWeb.fullNode.headers['TRON-PRO-API-KEY'], undefined);
1223-
assert.equal(tronWeb.eventServer.headers['TRON-PRO-API-KEY'], TEST_TRON_HEADER_API_KEY);
1248+
assert.equal(
1249+
tronWeb.fullNode.headers["TRON-PRO-API-KEY"],
1250+
undefined
1251+
);
1252+
assert.equal(
1253+
tronWeb.eventServer.headers["TRON-PRO-API-KEY"],
1254+
TEST_TRON_HEADER_API_KEY
1255+
);
12241256

12251257
try {
12261258
await tronWeb.trx.getAccount();
12271259
} catch (error) {
12281260
assert.equal(error.response.status, 401);
12291261
}
12301262

1231-
const tx = await tronWeb.event.getEventsByContractAddress(tronWeb.defaultAddress.base58);
1263+
const tx = await tronWeb.event.getEventsByContractAddress(
1264+
tronWeb.defaultAddress.base58
1265+
);
12321266
assert.equal(typeof tx, "object");
12331267
});
12341268

12351269
it("should set the valid key to the header of the request", async function () {
1236-
1237-
const FAKE_KEY = "ABCEDF"
1270+
const FAKE_KEY = "ABCEDF";
12381271
const tronWeb = tronWebBuilder.createInstance({
12391272
fullHost: TEST_TRON_GRID_API,
12401273
headers: { "TRON-PRO-API-KEY": FAKE_KEY },
12411274
});
12421275

1243-
assert.equal(tronWeb.fullNode.headers['TRON-PRO-API-KEY'], FAKE_KEY);
1244-
assert.equal(tronWeb.eventServer.headers['TRON-PRO-API-KEY'], FAKE_KEY);
1276+
assert.equal(
1277+
tronWeb.fullNode.headers["TRON-PRO-API-KEY"],
1278+
FAKE_KEY
1279+
);
1280+
assert.equal(
1281+
tronWeb.eventServer.headers["TRON-PRO-API-KEY"],
1282+
FAKE_KEY
1283+
);
12451284

12461285
try {
12471286
await tronWeb.trx.getAccount();
@@ -1250,61 +1289,75 @@ describe("#testTronGrid", function () {
12501289
}
12511290

12521291
try {
1253-
await tronWeb.event.getEventsByContractAddress(tronWeb.defaultAddress.base58);
1292+
await tronWeb.event.getEventsByContractAddress(
1293+
tronWeb.defaultAddress.base58
1294+
);
12541295
} catch (error) {
12551296
assert.equal(error.statusCode, 401);
12561297
}
12571298
});
12581299

12591300
it("should set the valid key to the header of the fullnode request", async function () {
1260-
1261-
const FAKE_KEY = "ABCEDF"
1301+
const FAKE_KEY = "ABCEDF";
12621302
const tronWeb = tronWebBuilder.createInstance({
12631303
fullHost: TEST_TRON_GRID_API,
12641304
headers: { "TRON-PRO-API-KEY": FAKE_KEY },
12651305
eventHeaders: { "TRON-PRO-API-KEY": TEST_TRON_HEADER_API_KEY },
12661306
});
12671307

1268-
assert.equal(tronWeb.fullNode.headers['TRON-PRO-API-KEY'], FAKE_KEY);
1269-
assert.equal(tronWeb.eventServer.headers['TRON-PRO-API-KEY'], TEST_TRON_HEADER_API_KEY);
1308+
assert.equal(
1309+
tronWeb.fullNode.headers["TRON-PRO-API-KEY"],
1310+
FAKE_KEY
1311+
);
1312+
assert.equal(
1313+
tronWeb.eventServer.headers["TRON-PRO-API-KEY"],
1314+
TEST_TRON_HEADER_API_KEY
1315+
);
12701316

12711317
try {
12721318
await tronWeb.trx.getAccount();
12731319
} catch (error) {
12741320
assert.equal(error.response.status, 401);
12751321
}
12761322

1277-
const tx = await tronWeb.event.getEventsByContractAddress(tronWeb.defaultAddress.base58);
1323+
const tx = await tronWeb.event.getEventsByContractAddress(
1324+
tronWeb.defaultAddress.base58
1325+
);
12781326
assert.equal(typeof tx, "object");
12791327
});
12801328

12811329
it("should set the valid key to the header of the event request", async function () {
1282-
1283-
const FAKE_KEY = "ABCEDF"
1330+
const FAKE_KEY = "ABCEDF";
12841331
const tronWeb = tronWebBuilder.createInstance({
12851332
fullHost: TEST_TRON_GRID_API,
12861333
headers: { "TRON-PRO-API-KEY": TEST_TRON_HEADER_API_KEY },
12871334
eventHeaders: { "TRON-PRO-API-KEY": FAKE_KEY },
12881335
});
12891336

1290-
assert.equal(tronWeb.fullNode.headers['TRON-PRO-API-KEY'], TEST_TRON_HEADER_API_KEY);
1291-
assert.equal(tronWeb.eventServer.headers['TRON-PRO-API-KEY'], FAKE_KEY);
1337+
assert.equal(
1338+
tronWeb.fullNode.headers["TRON-PRO-API-KEY"],
1339+
TEST_TRON_HEADER_API_KEY
1340+
);
1341+
assert.equal(
1342+
tronWeb.eventServer.headers["TRON-PRO-API-KEY"],
1343+
FAKE_KEY
1344+
);
12921345

12931346
const account = await tronWeb.trx.getAccount();
12941347
assert.equal(typeof account, "object");
12951348

12961349
try {
1297-
await tronWeb.event.getEventsByContractAddress(tronWeb.defaultAddress.base58);
1350+
await tronWeb.event.getEventsByContractAddress(
1351+
tronWeb.defaultAddress.base58
1352+
);
12981353
} catch (error) {
12991354
assert.equal(error.statusCode, 401);
13001355
}
13011356
});
13021357
});
13031358

13041359
describe("#testTronGridJwtKey", function () {
1305-
13061360
it("should add the parameter Authorization=Key to the header of the request", async function () {
1307-
13081361
const token = jwt.sign(
13091362
{ aud: "trongrid.io" },
13101363
TEST_TRON_HEADER_JWT_PRIVATE_KEY,
@@ -1330,7 +1383,6 @@ describe("#testTronGrid", function () {
13301383
});
13311384

13321385
it("should the valid exp to the payload of the sign", async function () {
1333-
13341386
const token = jwt.sign(
13351387
{
13361388
exp: 0,

0 commit comments

Comments
 (0)