@arkecosystem/typescript-crypto 0.0.10 → 0.0.12

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 (62) hide show
  1. package/dist/enums/index.d.ts +0 -1
  2. package/dist/enums/index.d.ts.map +1 -1
  3. package/dist/enums/index.js +0 -1
  4. package/dist/identities/PrivateKey.d.ts.map +1 -1
  5. package/dist/identities/PrivateKey.js +3 -4
  6. package/dist/index.js +33 -46
  7. package/dist/transactions/Deserializer.d.ts.map +1 -1
  8. package/dist/transactions/Deserializer.js +18 -16
  9. package/dist/transactions/builders/AbstractTransactionBuilder.d.ts +1 -2
  10. package/dist/transactions/builders/AbstractTransactionBuilder.d.ts.map +1 -1
  11. package/dist/transactions/builders/AbstractTransactionBuilder.js +7 -13
  12. package/dist/transactions/types/AbstractTransaction.d.ts.map +1 -1
  13. package/dist/transactions/types/AbstractTransaction.js +4 -6
  14. package/dist/types.d.ts +2 -4
  15. package/dist/types.d.ts.map +1 -1
  16. package/dist/utils/Message.js +1 -1
  17. package/dist/utils/TransactionUtils.d.ts.map +1 -1
  18. package/dist/utils/TransactionUtils.js +14 -12
  19. package/package.json +1 -1
  20. package/src/enums/index.ts +0 -1
  21. package/src/identities/PrivateKey.ts +3 -4
  22. package/src/transactions/Deserializer.ts +22 -19
  23. package/src/transactions/builders/AbstractTransactionBuilder.ts +7 -15
  24. package/src/transactions/types/AbstractTransaction.ts +4 -6
  25. package/src/types.ts +2 -4
  26. package/src/utils/Message.ts +1 -1
  27. package/src/utils/TransactionUtils.ts +11 -8
  28. package/tests/fixtures/identity.json +2 -1
  29. package/tests/fixtures/message-sign.json +1 -1
  30. package/tests/fixtures/sign-compact.json +1 -1
  31. package/tests/fixtures/transactions/evm-sign.json +7 -7
  32. package/tests/fixtures/transactions/multipayment-empty.json +7 -7
  33. package/tests/fixtures/transactions/multipayment-single.json +7 -7
  34. package/tests/fixtures/transactions/multipayment.json +7 -7
  35. package/tests/fixtures/transactions/transfer-0.json +7 -7
  36. package/tests/fixtures/transactions/transfer-large-amount.json +7 -7
  37. package/tests/fixtures/transactions/transfer-legacy-second-signature.json +8 -8
  38. package/tests/fixtures/transactions/transfer.json +7 -7
  39. package/tests/fixtures/transactions/unvote.json +7 -7
  40. package/tests/fixtures/transactions/username-registration.json +7 -7
  41. package/tests/fixtures/transactions/username-resignation.json +7 -7
  42. package/tests/fixtures/transactions/validator-registration.json +8 -8
  43. package/tests/fixtures/transactions/validator-resignation.json +7 -7
  44. package/tests/fixtures/transactions/vote.json +7 -7
  45. package/tests/unit/identities/PublicKey.test.ts +3 -4
  46. package/tests/unit/transactions/Deserializer.test.ts +12 -11
  47. package/tests/unit/transactions/Serializer.test.ts +5 -6
  48. package/tests/unit/transactions/builders/EvmCallBuilder.test.ts +7 -14
  49. package/tests/unit/transactions/builders/MultipaymentBuilder.test.ts +15 -29
  50. package/tests/unit/transactions/builders/TransferBuilder.test.ts +15 -29
  51. package/tests/unit/transactions/builders/UnvoteBuilder.test.ts +7 -14
  52. package/tests/unit/transactions/builders/UsernameRegistrationBuilder.test.ts +8 -15
  53. package/tests/unit/transactions/builders/UsernameResignationBuilder.test.ts +7 -14
  54. package/tests/unit/transactions/builders/ValidatorRegistrationBuilder.test.ts +9 -18
  55. package/tests/unit/transactions/builders/ValidatorResignationBuilder.test.ts +7 -14
  56. package/tests/unit/transactions/builders/VoteBuilder.test.ts +7 -14
  57. package/tests/unit/transactions/types/AbstractTransaction.test.ts +6 -8
  58. package/tests/unit/utils/TransactionUtils.test.ts +5 -7
  59. package/dist/enums/Constants.d.ts +0 -5
  60. package/dist/enums/Constants.d.ts.map +0 -1
  61. package/dist/enums/Constants.js +0 -5
  62. package/src/enums/Constants.ts +0 -4
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "data": {
3
- "network": 10000,
4
3
  "nonce": "1",
5
4
  "gasPrice": "5000000000",
6
- "gas": "200000",
5
+ "gasLimit": "200000",
7
6
  "to": "0x535B3D7A252fa034Ed71F0C53ec0C6F784cB64E1",
8
7
  "value": "0",
9
8
  "data": "b85f5da2",
10
- "v": 28,
11
- "r": "5670e5d314906eeaf92da15b55eaeabbb92814874f2fe6c72bcbee7e13e7ff40",
12
- "s": "32a34c8438e441d10e83180b5a8a84cf1bfb92fc0fe8b53cd23dc4105631b83d",
9
+ "network": 11812,
10
+ "v": 1,
11
+ "r": "c4cdcf1e6ea401db32e3688aeb2e89e790ce2ea82b57a0125585ba085d6cec5c",
12
+ "s": "0a8cde2f42b20a5b6aeb3a4d8443fc5c31f2c3af5eb698551a057bd5709847e3",
13
13
  "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d",
14
14
  "from": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd",
15
- "hash": "2dc3b976d8dee25e2ecf341c1493670d9d087cc338ed63f764c0eb9e28869dc3"
15
+ "hash": "6bfc80b761bba22759f282a0639637f402e86ca07ca952833e0590592a661401"
16
16
  },
17
- "serialized": "02f86e822710018085012a05f20083030d4094535b3d7a252fa034ed71f0c53ec0c6f784cb64e18084b85f5da2c001a05670e5d314906eeaf92da15b55eaeabbb92814874f2fe6c72bcbee7e13e7ff40a032a34c8438e441d10e83180b5a8a84cf1bfb92fc0fe8b53cd23dc4105631b83d"
17
+ "serialized": "f86b0185012a05f20083030d4094535b3d7a252fa034ed71f0c53ec0c6f784cb64e18084b85f5da2825c6ca0c4cdcf1e6ea401db32e3688aeb2e89e790ce2ea82b57a0125585ba085d6cec5ca00a8cde2f42b20a5b6aeb3a4d8443fc5c31f2c3af5eb698551a057bd5709847e3"
18
18
  }
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "data": {
3
- "network": 10000,
4
3
  "nonce": "1",
5
4
  "gasPrice": "5000000000",
6
- "gas": "200000",
5
+ "gasLimit": "200000",
7
6
  "to": "0x535B3D7A252fa034Ed71F0C53ec0C6F784cB64E1",
8
7
  "value": "0",
9
8
  "data": "6dd7d8ea000000000000000000000000c3bbe9b1cee1ff85ad72b87414b0e9b7f2366763",
10
- "v": 27,
11
- "r": "67734fadb38bd9cd584d39fc08af836f15dd6337b05511b312add11a3586451a",
12
- "s": "08ba89cec57c38b1e1f488d3507b9cbe1a21aa3f441482e62bd9c1eef61d3bd9",
9
+ "network": 11812,
10
+ "v": 1,
11
+ "r": "48cdb8cd112e05823e227319b66f2ef5e89c16ff5c568edab1cfa5f3fd8401c0",
12
+ "s": "264a4bcd27a62696e15e8588765b2739c3ed34f4b83aacd87998b2ac4c4335ec",
13
13
  "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d",
14
14
  "from": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd",
15
- "hash": "351114ee096ad8a02ddb7abee6f4fe283b8dadceff17157722d7a8153de710c1"
15
+ "hash": "7885cf77a0b272488efa03ed14994f2560490d14bd5df9b5fbdb7a6f389c8713"
16
16
  },
17
- "serialized": "02f88e822710018085012a05f20083030d4094535b3d7a252fa034ed71f0c53ec0c6f784cb64e180a46dd7d8ea000000000000000000000000c3bbe9b1cee1ff85ad72b87414b0e9b7f2366763c080a067734fadb38bd9cd584d39fc08af836f15dd6337b05511b312add11a3586451aa008ba89cec57c38b1e1f488d3507b9cbe1a21aa3f441482e62bd9c1eef61d3bd9"
17
+ "serialized": "f88b0185012a05f20083030d4094535b3d7a252fa034ed71f0c53ec0c6f784cb64e180a46dd7d8ea000000000000000000000000c3bbe9b1cee1ff85ad72b87414b0e9b7f2366763825c6ca048cdb8cd112e05823e227319b66f2ef5e89c16ff5c568edab1cfa5f3fd8401c0a0264a4bcd27a62696e15e8588765b2739c3ed34f4b83aacd87998b2ac4c4335ec"
18
18
  }
@@ -1,8 +1,7 @@
1
- import fixture from "@tests/fixtures/identity.json";
2
- import fixtureTransaction from "@tests/fixtures/transactions/transfer.json";
3
-
4
1
  import { PublicKey } from "@/identities/PublicKey";
5
2
  import { TransactionUtils } from "@/utils/TransactionUtils";
3
+ import fixture from "@tests/fixtures/identity.json";
4
+ import fixtureTransaction from "@tests/fixtures/transactions/transfer.json";
6
5
 
7
6
  it("should get the address from passphrase", () => {
8
7
  const actual = PublicKey.fromPassphrase(fixture.passphrase);
@@ -18,7 +17,7 @@ it("should get the address from hex", () => {
18
17
 
19
18
  it("should recover a public key", () => {
20
19
  const hash = TransactionUtils.toHash(fixtureTransaction.data, true);
21
- const v = fixtureTransaction.data.v - 27;
20
+ const v = fixtureTransaction.data.v;
22
21
  const r = BigInt(`0x${fixtureTransaction.data.r}`);
23
22
  const s = BigInt(`0x${fixtureTransaction.data.s}`);
24
23
 
@@ -1,4 +1,3 @@
1
- import { Deserializer } from "@/transactions/Deserializer";
2
1
  import {
3
2
  EvmCall,
4
3
  Multipayment,
@@ -9,6 +8,8 @@ import {
9
8
  ValidatorResignation,
10
9
  Vote,
11
10
  } from "@/transactions/types";
11
+
12
+ import { Deserializer } from "@/transactions/Deserializer";
12
13
  import { Transfer } from "@/transactions/types/Transfer";
13
14
  import fixtureTransfer from "@tests/fixtures/transactions/transfer.json";
14
15
 
@@ -40,7 +41,7 @@ it("should deserialize transfer", () => {
40
41
  "hash",
41
42
  "nonce",
42
43
  "gasPrice",
43
- "gas",
44
+ "gasLimit",
44
45
  "value",
45
46
  "v",
46
47
  "r",
@@ -54,7 +55,7 @@ it("should deserialize transfer", () => {
54
55
  it("should deserialize a transfer signed with a passphrase", async () => {
55
56
  const fixture = await getFixture("transfer");
56
57
 
57
- const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gas", "value", "v", "r", "s"]);
58
+ const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gasLimit", "value", "v", "r", "s"]);
58
59
 
59
60
  expect(transaction).toBeInstanceOf(Transfer);
60
61
  });
@@ -62,7 +63,7 @@ it("should deserialize a transfer signed with a passphrase", async () => {
62
63
  it("should deserialize a transfer signed with a passphrase with 0 value", async () => {
63
64
  const fixture = await getFixture("transfer-0");
64
65
 
65
- const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gas", "value", "v", "r", "s"]);
66
+ const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gasLimit", "value", "v", "r", "s"]);
66
67
 
67
68
  expect(transaction).toBeInstanceOf(EvmCall);
68
69
  });
@@ -70,7 +71,7 @@ it("should deserialize a transfer signed with a passphrase with 0 value", async
70
71
  it("should deserialize a vote signed with a passphrase", async () => {
71
72
  const fixture = await getFixture("vote");
72
73
 
73
- const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gas", "value", "v", "r", "s"]);
74
+ const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gasLimit", "value", "v", "r", "s"]);
74
75
 
75
76
  expect(transaction.data["vote"]).toEqual("0xC3bBE9B1CeE1ff85Ad72b87414B0E9B7F2366763");
76
77
 
@@ -82,7 +83,7 @@ it("should deserialize a vote signed with a passphrase", async () => {
82
83
  it("should deserialize a unvote signed with a passphrase", async () => {
83
84
  const fixture = await getFixture("unvote");
84
85
 
85
- const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gas", "value", "v", "r", "s"]);
86
+ const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gasLimit", "value", "v", "r", "s"]);
86
87
 
87
88
  expect(transaction).toBeInstanceOf(Unvote);
88
89
  });
@@ -90,7 +91,7 @@ it("should deserialize a unvote signed with a passphrase", async () => {
90
91
  it("should deserialize a validator registration signed with a passphrase", async () => {
91
92
  const fixture = await getFixture("validator-registration");
92
93
 
93
- const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gas", "value", "v", "r", "s"]);
94
+ const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gasLimit", "value", "v", "r", "s"]);
94
95
 
95
96
  expect(transaction).toBeInstanceOf(ValidatorRegistration);
96
97
  });
@@ -98,7 +99,7 @@ it("should deserialize a validator registration signed with a passphrase", async
98
99
  it("should deserialize a validator resignation signed with a passphrase", async () => {
99
100
  const fixture = await getFixture("validator-resignation");
100
101
 
101
- const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gas", "value", "v", "r", "s"]);
102
+ const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gasLimit", "value", "v", "r", "s"]);
102
103
 
103
104
  expect(transaction).toBeInstanceOf(ValidatorResignation);
104
105
  });
@@ -106,7 +107,7 @@ it("should deserialize a validator resignation signed with a passphrase", async
106
107
  it("should deserialize a username registration signed with a passphrase", async () => {
107
108
  const fixture = await getFixture("username-registration");
108
109
 
109
- const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gas", "value", "v", "r", "s"]);
110
+ const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gasLimit", "value", "v", "r", "s"]);
110
111
 
111
112
  expect(transaction).toBeInstanceOf(UsernameRegistration);
112
113
  });
@@ -114,7 +115,7 @@ it("should deserialize a username registration signed with a passphrase", async
114
115
  it("should deserialize a username resignation signed with a passphrase", async () => {
115
116
  const fixture = await getFixture("username-resignation");
116
117
 
117
- const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gas", "value", "v", "r", "s"]);
118
+ const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gasLimit", "value", "v", "r", "s"]);
118
119
 
119
120
  expect(transaction).toBeInstanceOf(UsernameResignation);
120
121
  });
@@ -122,7 +123,7 @@ it("should deserialize a username resignation signed with a passphrase", async (
122
123
  it("should deserialize a multipayment signed with a passphrase", async () => {
123
124
  const fixture = await getFixture("multipayment");
124
125
 
125
- const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gas", "value", "v", "r", "s"]);
126
+ const transaction = assertDeserialized(fixture, ["hash", "nonce", "gasPrice", "gasLimit", "value", "v", "r", "s"]);
126
127
 
127
128
  expect(transaction).toBeInstanceOf(Multipayment);
128
129
  });
@@ -1,7 +1,6 @@
1
- import fixtureTransfer from "@tests/fixtures/transactions/transfer.json";
2
-
3
- import { Transfer } from "@/transactions/types/Transfer";
4
1
  import { Serializer } from "../../../src/transactions/Serializer";
2
+ import { Transfer } from "@/transactions/types/Transfer";
3
+ import fixtureTransfer from "@tests/fixtures/transactions/transfer.json";
5
4
 
6
5
  it("should serialize a transfer transaction", () => {
7
6
  const transaction = new Transfer(fixtureTransfer.data);
@@ -12,8 +11,8 @@ it("should serialize a transfer transaction", () => {
12
11
  it("should serialize a transfer transaction without a signature", () => {
13
12
  const transaction = new Transfer(fixtureTransfer.data);
14
13
 
15
- // We slice the first few bytes because the serialization is different when the transaction is signed
16
- expect(new Serializer(transaction).serialize(true).toString("hex").slice(4)).toEqual(
17
- fixtureTransfer["serialized"].slice(6, 90),
14
+ // We slice the first few bytes and last bytes (dummy signature) because the serialization is different when the transaction is signed
15
+ expect(new Serializer(transaction).serialize(true).toString("hex").slice(4, 78)).toEqual(
16
+ fixtureTransfer["serialized"].slice(6, 80),
18
17
  );
19
18
  });
@@ -1,8 +1,7 @@
1
+ import { EvmCallBuilder } from "@/transactions/builders/EvmCallBuilder";
1
2
  import fixture from "@tests/fixtures/transactions/evm-sign.json";
2
3
  import identityFixture from "@tests/fixtures/identity.json";
3
4
 
4
- import { EvmCallBuilder } from "@/transactions/builders/EvmCallBuilder";
5
-
6
5
  it("should build a transaction", async () => {
7
6
  const transaction = (
8
7
  await EvmCallBuilder.new()
@@ -10,15 +9,13 @@ it("should build a transaction", async () => {
10
9
  .to(fixture.data.to)
11
10
  .nonce(fixture.data.nonce)
12
11
  .gasPrice(fixture.data.gasPrice)
13
- .gas(fixture.data.gas)
14
- .network(fixture.data.network)
12
+ .gasLimit(fixture.data.gasLimit)
15
13
  .sign(identityFixture.passphrase)
16
14
  ).transaction;
17
15
 
18
16
  expect(transaction.data.gasPrice).toBe(fixture.data.gasPrice);
19
17
  expect(transaction.data.nonce).toBe(fixture.data.nonce);
20
- expect(transaction.data.network).toBe(fixture.data.network);
21
- expect(transaction.data.gas).toBe(fixture.data.gas);
18
+ expect(transaction.data.gasLimit).toBe(fixture.data.gasLimit);
22
19
  expect(transaction.data.to).toBe(fixture.data.to);
23
20
  expect(transaction.data.value).toBe(fixture.data.value);
24
21
  expect(transaction.data.v).toBe(fixture.data.v);
@@ -35,8 +32,7 @@ it("should sign a transaction", async () => {
35
32
 
36
33
  expect(transaction.data.gasPrice).toBe(fixture.data.gasPrice);
37
34
  expect(transaction.data.nonce).toBe(fixture.data.nonce);
38
- expect(transaction.data.network).toBe(fixture.data.network);
39
- expect(transaction.data.gas).toBe(fixture.data.gas);
35
+ expect(transaction.data.gasLimit).toBe(fixture.data.gasLimit);
40
36
  expect(transaction.data.to).toBe(fixture.data.to);
41
37
  expect(transaction.data.value).toBe(fixture.data.value);
42
38
  expect(transaction.data.v).toBe(fixture.data.v);
@@ -62,8 +58,7 @@ it("should convert to an array", async () => {
62
58
  to: fixture.data.to,
63
59
  value: fixture.data.value,
64
60
  gasPrice: fixture.data.gasPrice,
65
- gas: fixture.data.gas,
66
- network: fixture.data.network,
61
+ gasLimit: fixture.data.gasLimit,
67
62
  nonce: fixture.data.nonce,
68
63
  v: fixture.data.v,
69
64
  r: fixture.data.r,
@@ -79,9 +74,8 @@ it("should convert to json", async () => {
79
74
  expect(transaction.toJson()).toEqual(
80
75
  JSON.stringify({
81
76
  gasPrice: fixture.data.gasPrice,
82
- network: fixture.data.network,
83
77
  hash: fixture.data.hash,
84
- gas: fixture.data.gas,
78
+ gasLimit: fixture.data.gasLimit,
85
79
  nonce: fixture.data.nonce,
86
80
  senderPublicKey: fixture.data.senderPublicKey,
87
81
  to: fixture.data.to,
@@ -100,9 +94,8 @@ it("should convert to string", async () => {
100
94
  expect(transaction.toString()).toEqual(
101
95
  JSON.stringify({
102
96
  gasPrice: fixture.data.gasPrice,
103
- network: fixture.data.network,
104
97
  hash: fixture.data.hash,
105
- gas: fixture.data.gas,
98
+ gasLimit: fixture.data.gasLimit,
106
99
  nonce: fixture.data.nonce,
107
100
  senderPublicKey: fixture.data.senderPublicKey,
108
101
  to: fixture.data.to,
@@ -1,26 +1,23 @@
1
+ import { MultipaymentBuilder } from "@/transactions/builders/MultipaymentBuilder";
2
+ import { UnitConverter } from "@/utils/UnitConverter";
1
3
  import fixture from "@tests/fixtures/transactions/multipayment.json";
2
4
  import fixtureEmpty from "@tests/fixtures/transactions/multipayment-empty.json";
3
5
  import fixtureSingle from "@tests/fixtures/transactions/multipayment-single.json";
4
6
  import identityFixture from "@tests/fixtures/identity.json";
5
7
 
6
- import { MultipaymentBuilder } from "@/transactions/builders/MultipaymentBuilder";
7
- import { UnitConverter } from "@/utils/UnitConverter";
8
-
9
8
  it("should build a transaction", async () => {
10
9
  const transaction = (
11
10
  await MultipaymentBuilder.new()
12
11
  .pay("0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", "100000")
13
12
  .pay("0xc3bbe9b1cee1ff85ad72b87414b0e9b7f2366763", "200000")
14
13
  .gasPrice(fixture.data.gasPrice)
15
- .gas(fixture.data.gas)
16
- .network(fixture.data.network)
14
+ .gasLimit(fixture.data.gasLimit)
17
15
  .sign(identityFixture.passphrase)
18
16
  ).transaction;
19
17
 
20
18
  expect(transaction.data.gasPrice).toBe(fixture.data.gasPrice);
21
19
  expect(transaction.data.nonce).toBe(fixture.data.nonce);
22
- expect(transaction.data.network).toBe(fixture.data.network);
23
- expect(transaction.data.gas).toBe(fixture.data.gas);
20
+ expect(transaction.data.gasLimit).toBe(fixture.data.gasLimit);
24
21
  expect(transaction.data.to).toBe(fixture.data.to);
25
22
  expect(transaction.data.value).toBe(fixture.data.value);
26
23
  expect(transaction.data.v).toBe(fixture.data.v);
@@ -38,8 +35,7 @@ it("should sign a transaction", async () => {
38
35
 
39
36
  expect(transaction.data.gasPrice).toBe(fixture.data.gasPrice);
40
37
  expect(transaction.data.nonce).toBe(fixture.data.nonce);
41
- expect(transaction.data.network).toBe(fixture.data.network);
42
- expect(transaction.data.gas).toBe(fixture.data.gas);
38
+ expect(transaction.data.gasLimit).toBe(fixture.data.gasLimit);
43
39
  expect(transaction.data.to).toBe(fixture.data.to);
44
40
  expect(transaction.data.value).toBe(BigInt(fixture.data.value));
45
41
  expect(transaction.data.v).toBe(fixture.data.v);
@@ -56,15 +52,13 @@ it("should build a transaction with a single payment", async () => {
56
52
  await MultipaymentBuilder.new()
57
53
  .pay("0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", "100000")
58
54
  .gasPrice(fixtureSingle.data.gasPrice)
59
- .gas(fixtureSingle.data.gas)
60
- .network(fixtureSingle.data.network)
55
+ .gasLimit(fixtureSingle.data.gasLimit)
61
56
  .sign(identityFixture.passphrase)
62
57
  ).transaction;
63
58
 
64
59
  expect(transaction.data.gasPrice).toBe(fixtureSingle.data.gasPrice);
65
60
  expect(transaction.data.nonce).toBe(fixtureSingle.data.nonce);
66
- expect(transaction.data.network).toBe(fixtureSingle.data.network);
67
- expect(transaction.data.gas).toBe(fixtureSingle.data.gas);
61
+ expect(transaction.data.gasLimit).toBe(fixtureSingle.data.gasLimit);
68
62
  expect(transaction.data.to).toBe(fixtureSingle.data.to);
69
63
  expect(transaction.data.value).toBe(fixtureSingle.data.value);
70
64
  expect(transaction.data.v).toBe(fixtureSingle.data.v);
@@ -80,15 +74,13 @@ it("should build a transaction with an empty payment", async () => {
80
74
  const transaction = (
81
75
  await MultipaymentBuilder.new()
82
76
  .gasPrice(fixtureEmpty.data.gasPrice)
83
- .gas(fixtureEmpty.data.gas)
84
- .network(fixtureEmpty.data.network)
77
+ .gasLimit(fixtureEmpty.data.gasLimit)
85
78
  .sign(identityFixture.passphrase)
86
79
  ).transaction;
87
80
 
88
81
  expect(transaction.data.gasPrice).toBe(fixtureEmpty.data.gasPrice);
89
82
  expect(transaction.data.nonce).toBe(fixtureEmpty.data.nonce);
90
- expect(transaction.data.network).toBe(fixtureEmpty.data.network);
91
- expect(transaction.data.gas).toBe(fixtureEmpty.data.gas);
83
+ expect(transaction.data.gasLimit).toBe(fixtureEmpty.data.gasLimit);
92
84
  expect(transaction.data.to).toBe(fixtureEmpty.data.to);
93
85
  expect(transaction.data.value).toBe(fixtureEmpty.data.value);
94
86
  expect(transaction.data.v).toBe(fixtureEmpty.data.v);
@@ -106,15 +98,13 @@ it("should handle bignumber values", async () => {
106
98
  .pay("0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", UnitConverter.parseUnits("100000", "wei"))
107
99
  .pay("0xc3bbe9b1cee1ff85ad72b87414b0e9b7f2366763", UnitConverter.parseUnits("200000", "wei"))
108
100
  .gasPrice(UnitConverter.parseUnits(fixture.data.gasPrice, "wei"))
109
- .gas(UnitConverter.parseUnits(fixture.data.gas, "wei"))
110
- .network(fixture.data.network)
101
+ .gasLimit(UnitConverter.parseUnits(fixture.data.gasLimit, "wei"))
111
102
  .sign(identityFixture.passphrase)
112
103
  ).transaction;
113
104
 
114
105
  expect(transaction.data.gasPrice).toBe(fixture.data.gasPrice);
115
106
  expect(transaction.data.nonce).toBe(fixture.data.nonce);
116
- expect(transaction.data.network).toBe(fixture.data.network);
117
- expect(transaction.data.gas).toBe(fixture.data.gas);
107
+ expect(transaction.data.gasLimit).toBe(fixture.data.gasLimit);
118
108
  expect(transaction.data.to).toBe(fixture.data.to);
119
109
  expect(transaction.data.value).toBe(fixture.data.value);
120
110
  expect(transaction.data.v).toBe(fixture.data.v);
@@ -129,8 +119,7 @@ it("should handle bignumber values", async () => {
129
119
  it("should track value correctly on pay when initially not set", async () => {
130
120
  const builder = await MultipaymentBuilder.new()
131
121
  .gasPrice(fixtureSingle.data.gasPrice)
132
- .gas(fixtureSingle.data.gas)
133
- .network(fixtureSingle.data.network);
122
+ .gasLimit(fixtureSingle.data.gasLimit);
134
123
 
135
124
  builder.transaction.data.value = undefined;
136
125
 
@@ -153,8 +142,7 @@ it("should convert to an array", async () => {
153
142
  to: fixture.data.to,
154
143
  value: fixture.data.value,
155
144
  gasPrice: fixture.data.gasPrice,
156
- gas: fixture.data.gas,
157
- network: fixture.data.network,
145
+ gasLimit: fixture.data.gasLimit,
158
146
  nonce: fixture.data.nonce,
159
147
  v: fixture.data.v,
160
148
  r: fixture.data.r,
@@ -170,9 +158,8 @@ it("should convert to json", async () => {
170
158
  expect(transaction.toJson()).toEqual(
171
159
  JSON.stringify({
172
160
  gasPrice: fixture.data.gasPrice,
173
- network: fixture.data.network,
174
161
  hash: fixture.data.hash,
175
- gas: fixture.data.gas,
162
+ gasLimit: fixture.data.gasLimit,
176
163
  nonce: fixture.data.nonce,
177
164
  senderPublicKey: fixture.data.senderPublicKey,
178
165
  to: fixture.data.to,
@@ -191,9 +178,8 @@ it("should convert to string", async () => {
191
178
  expect(transaction.toString()).toEqual(
192
179
  JSON.stringify({
193
180
  gasPrice: fixture.data.gasPrice,
194
- network: fixture.data.network,
195
181
  hash: fixture.data.hash,
196
- gas: fixture.data.gas,
182
+ gasLimit: fixture.data.gasLimit,
197
183
  nonce: fixture.data.nonce,
198
184
  senderPublicKey: fixture.data.senderPublicKey,
199
185
  to: fixture.data.to,
@@ -1,11 +1,10 @@
1
+ import { TransferBuilder } from "@/transactions/builders/TransferBuilder";
2
+ import { UnitConverter } from "@/utils/UnitConverter";
1
3
  import fixture from "@tests/fixtures/transactions/transfer.json";
2
4
  import legacySecondSignatureFixture from "@tests/fixtures/transactions/transfer-legacy-second-signature.json";
3
5
  import fixtureTransferLargeAmount from "@tests/fixtures/transactions/transfer-large-amount.json";
4
6
  import identityFixture from "@tests/fixtures/identity.json";
5
7
 
6
- import { TransferBuilder } from "@/transactions/builders/TransferBuilder";
7
- import { UnitConverter } from "@/utils/UnitConverter";
8
-
9
8
  it("should build a transaction", async () => {
10
9
  const transaction = (
11
10
  await TransferBuilder.new()
@@ -13,15 +12,13 @@ it("should build a transaction", async () => {
13
12
  .to(fixture.data.to)
14
13
  .nonce(fixture.data.nonce)
15
14
  .gasPrice(fixture.data.gasPrice)
16
- .gas(fixture.data.gas)
17
- .network(fixture.data.network)
15
+ .gasLimit(fixture.data.gasLimit)
18
16
  .sign(identityFixture.passphrase)
19
17
  ).transaction;
20
18
 
21
19
  expect(transaction.data.gasPrice).toBe(fixture.data.gasPrice);
22
20
  expect(transaction.data.nonce).toBe(fixture.data.nonce);
23
- expect(transaction.data.network).toBe(fixture.data.network);
24
- expect(transaction.data.gas).toBe(fixture.data.gas);
21
+ expect(transaction.data.gasLimit).toBe(fixture.data.gasLimit);
25
22
  expect(transaction.data.to).toBe(fixture.data.to);
26
23
  expect(transaction.data.value).toBe(fixture.data.value);
27
24
  expect(transaction.data.v).toBe(fixture.data.v);
@@ -38,8 +35,7 @@ it("should sign a transaction", async () => {
38
35
 
39
36
  expect(transaction.data.gasPrice).toBe(fixture.data.gasPrice);
40
37
  expect(transaction.data.nonce).toBe(fixture.data.nonce);
41
- expect(transaction.data.network).toBe(fixture.data.network);
42
- expect(transaction.data.gas).toBe(fixture.data.gas);
38
+ expect(transaction.data.gasLimit).toBe(fixture.data.gasLimit);
43
39
  expect(transaction.data.to).toBe(fixture.data.to);
44
40
  expect(transaction.data.value).toBe(fixture.data.value);
45
41
  expect(transaction.data.v).toBe(fixture.data.v);
@@ -58,22 +54,19 @@ it("should build a transaction using legacy second signature", async () => {
58
54
  .to(legacySecondSignatureFixture.data.to)
59
55
  .nonce(legacySecondSignatureFixture.data.nonce)
60
56
  .gasPrice(legacySecondSignatureFixture.data.gasPrice)
61
- .gas(legacySecondSignatureFixture.data.gas)
62
- .network(legacySecondSignatureFixture.data.network)
63
- .legacySecondSign(identityFixture.passphrase, identityFixture.passphrase)
57
+ .gasLimit(legacySecondSignatureFixture.data.gasLimit)
58
+ .legacySecondSign(identityFixture.passphrase, identityFixture.secondPassphrase)
64
59
  ).transaction;
65
60
 
66
61
  expect(transaction.data.gasPrice).toBe(legacySecondSignatureFixture.data.gasPrice);
62
+ expect(transaction.data.gasLimit).toBe(legacySecondSignatureFixture.data.gasLimit);
67
63
  expect(transaction.data.nonce).toBe(legacySecondSignatureFixture.data.nonce);
68
- expect(transaction.data.network).toBe(legacySecondSignatureFixture.data.network);
69
- expect(transaction.data.gas).toBe(legacySecondSignatureFixture.data.gas);
70
64
  expect(transaction.data.to).toBe(legacySecondSignatureFixture.data.to);
71
65
  expect(transaction.data.value).toBe(legacySecondSignatureFixture.data.value);
72
66
  expect(transaction.data.v).toBe(legacySecondSignatureFixture.data.v);
73
67
  expect(transaction.data.r).toBe(legacySecondSignatureFixture.data.r);
74
68
  expect(transaction.data.s).toBe(legacySecondSignatureFixture.data.s);
75
69
  expect(transaction.data.hash).toBe(legacySecondSignatureFixture.data.hash);
76
- expect(transaction.data.hash).toBe(legacySecondSignatureFixture.data.hash);
77
70
  expect(transaction.data.legacySecondSignature).toBe(legacySecondSignatureFixture.data.legacySecondSignature);
78
71
 
79
72
  expect(transaction.serialize().toString("hex")).toEqual(legacySecondSignatureFixture.serialized);
@@ -87,15 +80,13 @@ it("should handle large amounts", async () => {
87
80
  .to(fixtureTransferLargeAmount.data.to)
88
81
  .nonce(fixtureTransferLargeAmount.data.nonce)
89
82
  .gasPrice(fixtureTransferLargeAmount.data.gasPrice)
90
- .gas(fixtureTransferLargeAmount.data.gas)
91
- .network(fixtureTransferLargeAmount.data.network)
83
+ .gasLimit(fixtureTransferLargeAmount.data.gasLimit)
92
84
  .sign(identityFixture.passphrase)
93
85
  ).transaction;
94
86
 
95
87
  expect(transaction.data.gasPrice).toBe(fixtureTransferLargeAmount.data.gasPrice);
96
88
  expect(transaction.data.nonce).toBe(fixtureTransferLargeAmount.data.nonce);
97
- expect(transaction.data.network).toBe(fixtureTransferLargeAmount.data.network);
98
- expect(transaction.data.gas).toBe(fixtureTransferLargeAmount.data.gas);
89
+ expect(transaction.data.gasLimit).toBe(fixtureTransferLargeAmount.data.gasLimit);
99
90
  expect(transaction.data.to).toBe(fixtureTransferLargeAmount.data.to);
100
91
  expect(transaction.data.value).toBe(fixtureTransferLargeAmount.data.value);
101
92
  expect(transaction.data.v).toBe(fixtureTransferLargeAmount.data.v);
@@ -114,15 +105,13 @@ it("should handle a bignumber value", async () => {
114
105
  .to(fixture.data.to)
115
106
  .nonce(fixture.data.nonce)
116
107
  .gasPrice(UnitConverter.parseUnits(fixture.data.gasPrice, "wei"))
117
- .gas(UnitConverter.parseUnits(fixture.data.gas, "wei"))
118
- .network(fixture.data.network)
108
+ .gasLimit(UnitConverter.parseUnits(fixture.data.gasLimit, "wei"))
119
109
  .sign(identityFixture.passphrase)
120
110
  ).transaction;
121
111
 
122
112
  expect(transaction.data.gasPrice).toBe(fixture.data.gasPrice);
123
113
  expect(transaction.data.nonce).toBe(fixture.data.nonce);
124
- expect(transaction.data.network).toBe(fixture.data.network);
125
- expect(transaction.data.gas).toBe(fixture.data.gas);
114
+ expect(transaction.data.gasLimit).toBe(fixture.data.gasLimit);
126
115
  expect(transaction.data.to).toBe(fixture.data.to);
127
116
  expect(transaction.data.value).toBe(fixture.data.value);
128
117
  expect(transaction.data.v).toBe(fixture.data.v);
@@ -148,8 +137,7 @@ it("should convert to an array", async () => {
148
137
  to: fixture.data.to,
149
138
  value: fixture.data.value,
150
139
  gasPrice: fixture.data.gasPrice,
151
- gas: fixture.data.gas,
152
- network: fixture.data.network,
140
+ gasLimit: fixture.data.gasLimit,
153
141
  nonce: fixture.data.nonce,
154
142
  v: fixture.data.v,
155
143
  r: fixture.data.r,
@@ -165,9 +153,8 @@ it("should convert to json", async () => {
165
153
  expect(transaction.toJson()).toEqual(
166
154
  JSON.stringify({
167
155
  gasPrice: fixture.data.gasPrice,
168
- network: fixture.data.network,
169
156
  hash: fixture.data.hash,
170
- gas: fixture.data.gas,
157
+ gasLimit: fixture.data.gasLimit,
171
158
  nonce: fixture.data.nonce,
172
159
  senderPublicKey: fixture.data.senderPublicKey,
173
160
  to: fixture.data.to,
@@ -186,9 +173,8 @@ it("should convert to string", async () => {
186
173
  expect(transaction.toString()).toEqual(
187
174
  JSON.stringify({
188
175
  gasPrice: fixture.data.gasPrice,
189
- network: fixture.data.network,
190
176
  hash: fixture.data.hash,
191
- gas: fixture.data.gas,
177
+ gasLimit: fixture.data.gasLimit,
192
178
  nonce: fixture.data.nonce,
193
179
  senderPublicKey: fixture.data.senderPublicKey,
194
180
  to: fixture.data.to,
@@ -1,22 +1,19 @@
1
+ import { UnvoteBuilder } from "@/transactions/builders/UnvoteBuilder";
1
2
  import fixture from "@tests/fixtures/transactions/unvote.json";
2
3
  import identityFixture from "@tests/fixtures/identity.json";
3
4
 
4
- import { UnvoteBuilder } from "@/transactions/builders/UnvoteBuilder";
5
-
6
5
  it("should build a transaction", async () => {
7
6
  const transaction = (
8
7
  await UnvoteBuilder.new()
9
8
  .nonce(fixture.data.nonce)
10
9
  .gasPrice(fixture.data.gasPrice)
11
- .gas(fixture.data.gas)
12
- .network(fixture.data.network)
10
+ .gasLimit(fixture.data.gasLimit)
13
11
  .sign(identityFixture.passphrase)
14
12
  ).transaction;
15
13
 
16
14
  expect(transaction.data.gasPrice).toBe(fixture.data.gasPrice);
17
15
  expect(transaction.data.nonce).toBe(fixture.data.nonce);
18
- expect(transaction.data.network).toBe(fixture.data.network);
19
- expect(transaction.data.gas).toBe(fixture.data.gas);
16
+ expect(transaction.data.gasLimit).toBe(fixture.data.gasLimit);
20
17
  expect(transaction.data.to).toBe(fixture.data.to);
21
18
  expect(transaction.data.value).toBe(fixture.data.value);
22
19
  expect(transaction.data.v).toBe(fixture.data.v);
@@ -33,8 +30,7 @@ it("should sign a transaction", async () => {
33
30
 
34
31
  expect(transaction.data.gasPrice).toBe(fixture.data.gasPrice);
35
32
  expect(transaction.data.nonce).toBe(fixture.data.nonce);
36
- expect(transaction.data.network).toBe(fixture.data.network);
37
- expect(transaction.data.gas).toBe(fixture.data.gas);
33
+ expect(transaction.data.gasLimit).toBe(fixture.data.gasLimit);
38
34
  expect(transaction.data.to).toBe(fixture.data.to);
39
35
  expect(transaction.data.value).toBe(fixture.data.value);
40
36
  expect(transaction.data.v).toBe(fixture.data.v);
@@ -60,8 +56,7 @@ it("should convert to an array", async () => {
60
56
  to: fixture.data.to,
61
57
  value: fixture.data.value,
62
58
  gasPrice: fixture.data.gasPrice,
63
- gas: fixture.data.gas,
64
- network: fixture.data.network,
59
+ gasLimit: fixture.data.gasLimit,
65
60
  nonce: fixture.data.nonce,
66
61
  v: fixture.data.v,
67
62
  r: fixture.data.r,
@@ -77,9 +72,8 @@ it("should convert to json", async () => {
77
72
  expect(transaction.toJson()).toEqual(
78
73
  JSON.stringify({
79
74
  gasPrice: fixture.data.gasPrice,
80
- network: fixture.data.network,
81
75
  hash: fixture.data.hash,
82
- gas: fixture.data.gas,
76
+ gasLimit: fixture.data.gasLimit,
83
77
  nonce: fixture.data.nonce,
84
78
  senderPublicKey: fixture.data.senderPublicKey,
85
79
  to: fixture.data.to,
@@ -98,9 +92,8 @@ it("should convert to string", async () => {
98
92
  expect(transaction.toString()).toEqual(
99
93
  JSON.stringify({
100
94
  gasPrice: fixture.data.gasPrice,
101
- network: fixture.data.network,
102
95
  hash: fixture.data.hash,
103
- gas: fixture.data.gas,
96
+ gasLimit: fixture.data.gasLimit,
104
97
  nonce: fixture.data.nonce,
105
98
  senderPublicKey: fixture.data.senderPublicKey,
106
99
  to: fixture.data.to,