@arkecosystem/typescript-crypto 0.0.3 → 0.0.5
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/.github/workflows/ci.yml +23 -23
- package/.github/workflows/format.yml +80 -0
- package/.github/workflows/publish.yml +1 -1
- package/.prettierrc.json +8 -0
- package/dist/enums/ContractAbiType.d.ts.map +1 -1
- package/dist/exceptions/index.d.ts.map +1 -1
- package/dist/identities/PrivateKey.d.ts +2 -2
- package/dist/identities/PrivateKey.d.ts.map +1 -1
- package/dist/identities/PrivateKey.js +1 -1
- package/dist/identities/WIF.d.ts.map +1 -1
- package/dist/identities/WIF.js +2 -2
- package/dist/index.js +532 -626
- package/dist/networks/AbstractNetwork.d.ts +1 -1
- package/dist/networks/AbstractNetwork.d.ts.map +1 -1
- package/dist/networks/Mainnet.d.ts +1 -1
- package/dist/networks/Mainnet.d.ts.map +1 -1
- package/dist/networks/Mainnet.js +1 -1
- package/dist/networks/Testnet.d.ts +1 -1
- package/dist/networks/Testnet.d.ts.map +1 -1
- package/dist/networks/Testnet.js +1 -1
- package/dist/transactions/Deserializer.d.ts +5 -5
- package/dist/transactions/Deserializer.d.ts.map +1 -1
- package/dist/transactions/Deserializer.js +18 -18
- package/dist/transactions/Serializer.d.ts +0 -1
- package/dist/transactions/Serializer.d.ts.map +1 -1
- package/dist/transactions/Serializer.js +0 -3
- package/dist/transactions/builders/AbstractTransactionBuilder.d.ts +7 -6
- package/dist/transactions/builders/AbstractTransactionBuilder.d.ts.map +1 -1
- package/dist/transactions/builders/AbstractTransactionBuilder.js +15 -8
- package/dist/transactions/builders/EvmCallBuilder.d.ts +3 -3
- package/dist/transactions/builders/EvmCallBuilder.d.ts.map +1 -1
- package/dist/transactions/builders/MultipaymentBuilder.d.ts +5 -4
- package/dist/transactions/builders/MultipaymentBuilder.d.ts.map +1 -1
- package/dist/transactions/builders/MultipaymentBuilder.js +6 -2
- package/dist/transactions/builders/TransferBuilder.d.ts +4 -3
- package/dist/transactions/builders/TransferBuilder.d.ts.map +1 -1
- package/dist/transactions/builders/TransferBuilder.js +4 -0
- package/dist/transactions/builders/UnvoteBuilder.d.ts +3 -3
- package/dist/transactions/builders/UnvoteBuilder.d.ts.map +1 -1
- package/dist/transactions/builders/UnvoteBuilder.js +1 -1
- package/dist/transactions/builders/UsernameRegistrationBuilder.d.ts +3 -3
- package/dist/transactions/builders/UsernameRegistrationBuilder.d.ts.map +1 -1
- package/dist/transactions/builders/UsernameRegistrationBuilder.js +1 -1
- package/dist/transactions/builders/UsernameResignationBuilder.d.ts +3 -3
- package/dist/transactions/builders/UsernameResignationBuilder.d.ts.map +1 -1
- package/dist/transactions/builders/UsernameResignationBuilder.js +1 -1
- package/dist/transactions/builders/ValidatorRegistrationBuilder.d.ts +3 -3
- package/dist/transactions/builders/ValidatorRegistrationBuilder.d.ts.map +1 -1
- package/dist/transactions/builders/ValidatorRegistrationBuilder.js +4 -2
- package/dist/transactions/builders/ValidatorResignationBuilder.d.ts +3 -3
- package/dist/transactions/builders/ValidatorResignationBuilder.d.ts.map +1 -1
- package/dist/transactions/builders/ValidatorResignationBuilder.js +1 -1
- package/dist/transactions/builders/VoteBuilder.d.ts +3 -3
- package/dist/transactions/builders/VoteBuilder.d.ts.map +1 -1
- package/dist/transactions/builders/VoteBuilder.js +1 -1
- package/dist/transactions/types/AbstractTransaction.d.ts +2 -5
- package/dist/transactions/types/AbstractTransaction.d.ts.map +1 -1
- package/dist/transactions/types/AbstractTransaction.js +13 -15
- package/dist/transactions/types/EvmCall.d.ts +0 -3
- package/dist/transactions/types/EvmCall.d.ts.map +1 -1
- package/dist/transactions/types/EvmCall.js +0 -8
- package/dist/transactions/types/Multipayment.d.ts +1 -3
- package/dist/transactions/types/Multipayment.d.ts.map +1 -1
- package/dist/transactions/types/Multipayment.js +1 -8
- package/dist/transactions/types/Transfer.d.ts +0 -3
- package/dist/transactions/types/Transfer.d.ts.map +1 -1
- package/dist/transactions/types/Transfer.js +0 -8
- package/dist/transactions/types/Unvote.d.ts +0 -3
- package/dist/transactions/types/Unvote.d.ts.map +1 -1
- package/dist/transactions/types/Unvote.js +0 -8
- package/dist/transactions/types/UsernameRegistration.d.ts +1 -3
- package/dist/transactions/types/UsernameRegistration.d.ts.map +1 -1
- package/dist/transactions/types/UsernameRegistration.js +0 -7
- package/dist/transactions/types/UsernameResignation.d.ts +0 -3
- package/dist/transactions/types/UsernameResignation.d.ts.map +1 -1
- package/dist/transactions/types/UsernameResignation.js +0 -7
- package/dist/transactions/types/ValidatorRegistration.d.ts +1 -3
- package/dist/transactions/types/ValidatorRegistration.d.ts.map +1 -1
- package/dist/transactions/types/ValidatorRegistration.js +0 -8
- package/dist/transactions/types/ValidatorResignation.d.ts +0 -3
- package/dist/transactions/types/ValidatorResignation.d.ts.map +1 -1
- package/dist/transactions/types/ValidatorResignation.js +0 -8
- package/dist/transactions/types/Vote.d.ts +1 -3
- package/dist/transactions/types/Vote.d.ts.map +1 -1
- package/dist/transactions/types/Vote.js +0 -8
- package/dist/types.d.ts +19 -19
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/Abi/ArgumentDecoder.js +6 -6
- package/dist/utils/Abi/json/Abi.Consensus.json +15 -45
- package/dist/utils/Abi/json/Abi.Usernames.json +9 -27
- package/dist/utils/AbiDecoder.d.ts.map +1 -1
- package/dist/utils/AbiDecoder.js +3 -0
- package/dist/utils/AbiEncoder.d.ts +1 -1
- package/dist/utils/AbiEncoder.d.ts.map +1 -1
- package/dist/utils/AbiEncoder.js +2 -1
- package/dist/utils/Message.d.ts +1 -1
- package/dist/utils/Message.d.ts.map +1 -1
- package/dist/utils/Message.js +1 -1
- package/dist/utils/TransactionUtils.d.ts +0 -1
- package/dist/utils/TransactionUtils.d.ts.map +1 -1
- package/dist/utils/TransactionUtils.js +15 -18
- package/dist/utils/UnitConverter.d.ts.map +1 -1
- package/dist/utils/UnitConverter.js +12 -12
- package/eslint.config.mjs +19 -0
- package/jest.config.ts +6 -6
- package/package.json +6 -2
- package/src/enums/Constants.ts +1 -1
- package/src/enums/ContractAbiType.ts +4 -4
- package/src/exceptions/index.ts +1 -1
- package/src/identities/PrivateKey.ts +3 -3
- package/src/identities/WIF.ts +2 -3
- package/src/networks/AbstractNetwork.ts +3 -3
- package/src/networks/Mainnet.ts +3 -3
- package/src/networks/Testnet.ts +1 -1
- package/src/transactions/Deserializer.ts +39 -30
- package/src/transactions/Serializer.ts +1 -5
- package/src/transactions/builders/AbstractTransactionBuilder.ts +20 -11
- package/src/transactions/builders/EvmCallBuilder.ts +3 -3
- package/src/transactions/builders/MultipaymentBuilder.ts +13 -6
- package/src/transactions/builders/TransferBuilder.ts +8 -3
- package/src/transactions/builders/UnvoteBuilder.ts +4 -4
- package/src/transactions/builders/UsernameRegistrationBuilder.ts +4 -4
- package/src/transactions/builders/UsernameResignationBuilder.ts +4 -4
- package/src/transactions/builders/ValidatorRegistrationBuilder.ts +8 -5
- package/src/transactions/builders/ValidatorResignationBuilder.ts +4 -4
- package/src/transactions/builders/VoteBuilder.ts +4 -4
- package/src/transactions/types/AbstractTransaction.ts +17 -24
- package/src/transactions/types/EvmCall.ts +0 -15
- package/src/transactions/types/Multipayment.ts +3 -15
- package/src/transactions/types/Transfer.ts +0 -15
- package/src/transactions/types/Unvote.ts +0 -15
- package/src/transactions/types/UsernameRegistration.ts +1 -13
- package/src/transactions/types/UsernameResignation.ts +0 -14
- package/src/transactions/types/ValidatorRegistration.ts +1 -14
- package/src/transactions/types/ValidatorResignation.ts +0 -15
- package/src/transactions/types/Vote.ts +1 -14
- package/src/types.ts +19 -19
- package/src/utils/Abi/ArgumentDecoder.ts +6 -6
- package/src/utils/Abi/json/Abi.Consensus.json +1641 -1671
- package/src/utils/Abi/json/Abi.Multipayment.json +108 -108
- package/src/utils/Abi/json/Abi.Usernames.json +880 -898
- package/src/utils/AbiBase.ts +1 -1
- package/src/utils/AbiDecoder.ts +6 -3
- package/src/utils/AbiEncoder.ts +3 -2
- package/src/utils/Message.ts +1 -1
- package/src/utils/TransactionUtils.ts +24 -28
- package/src/utils/UnitConverter.ts +29 -29
- package/tests/fixtures/global.json +4 -4
- package/tests/fixtures/identity.json +10 -10
- package/tests/fixtures/transactions/evm-sign.json +4 -4
- package/tests/fixtures/transactions/multipayment-empty.json +4 -4
- package/tests/fixtures/transactions/multipayment-single.json +4 -4
- package/tests/fixtures/transactions/multipayment.json +4 -4
- package/tests/fixtures/transactions/transfer-0.json +4 -4
- package/tests/fixtures/transactions/transfer-large-amount.json +4 -4
- package/tests/fixtures/transactions/transfer.json +4 -4
- package/tests/fixtures/transactions/unvote.json +4 -4
- package/tests/fixtures/transactions/username-registration.json +4 -4
- package/tests/fixtures/transactions/username-resignation.json +4 -4
- package/tests/fixtures/transactions/validator-registration.json +4 -4
- package/tests/fixtures/transactions/validator-resignation.json +4 -4
- package/tests/fixtures/transactions/vote.json +4 -4
- package/tests/unit/configuration/Network.test.ts +52 -0
- package/tests/unit/identities/Address.test.ts +4 -4
- package/tests/unit/identities/PrivateKey.test.ts +5 -5
- package/tests/unit/identities/PublicKey.test.ts +9 -9
- package/tests/unit/identities/WIF.test.ts +1 -1
- package/tests/unit/transactions/Deserializer.test.ts +81 -63
- package/tests/unit/transactions/Serializer.test.ts +11 -1
- package/tests/unit/transactions/builders/EvmCallBuilder.test.ts +76 -9
- package/tests/unit/transactions/builders/MultipaymentBuilder.test.ts +125 -17
- package/tests/unit/transactions/builders/TransferBuilder.test.ts +146 -47
- package/tests/unit/transactions/builders/UnvoteBuilder.test.ts +75 -8
- package/tests/unit/transactions/builders/UsernameRegistrationBuilder.test.ts +75 -8
- package/tests/unit/transactions/builders/UsernameResignationBuilder.test.ts +75 -8
- package/tests/unit/transactions/builders/ValidatorRegistrationBuilder.test.ts +103 -8
- package/tests/unit/transactions/builders/ValidatorResignationBuilder.test.ts +75 -8
- package/tests/unit/transactions/builders/VoteBuilder.test.ts +75 -8
- package/tests/unit/transactions/types/AbstractTransaction.test.ts +27 -30
- package/tests/unit/transactions/types/EvmCall.test.ts +22 -0
- package/tests/unit/transactions/types/Multipayment.test.ts +38 -0
- package/tests/unit/transactions/types/Transfer.test.ts +18 -0
- package/tests/unit/transactions/types/Unvote.test.ts +18 -0
- package/tests/unit/transactions/types/UsernameRegistration.test.ts +22 -0
- package/tests/unit/transactions/types/UsernameResignation.test.ts +18 -0
- package/tests/unit/transactions/types/ValidatorRegistration.test.ts +22 -0
- package/tests/unit/transactions/types/ValidatorResignation.test.ts +18 -0
- package/tests/unit/transactions/types/Vote.test.ts +20 -0
- package/tests/unit/utils/Abi/ArgumentDecoder.test.ts +17 -16
- package/tests/unit/utils/AbiEncoder.test.ts +2 -2
- package/tests/unit/utils/Message.test.ts +1 -1
- package/tests/unit/utils/TransactionUtils.test.ts +1 -5
- package/tests/unit/utils/UnitConverter.test.ts +81 -47
- package/tsconfig.json +1 -1
- package/.eslintrc.js +0 -12
- package/prettier.config.js +0 -8
@@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
};
|
10
10
|
import { Address } from "@/identities/Address";
|
11
11
|
import { Constants } from "@/enums/Constants";
|
12
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
13
12
|
import { PublicKey } from "@/identities/PublicKey";
|
14
13
|
import { Serializer } from "@/transactions/Serializer";
|
15
14
|
import { TransactionUtils } from "@/utils/TransactionUtils";
|
15
|
+
import BigNumber from "bignumber.js";
|
16
16
|
export class AbstractTransaction {
|
17
17
|
constructor(data) {
|
18
18
|
this.data = Object.assign({}, data);
|
@@ -22,9 +22,6 @@ export class AbstractTransaction {
|
|
22
22
|
this.data.data = this.getPayload();
|
23
23
|
return this;
|
24
24
|
}
|
25
|
-
getId() {
|
26
|
-
return TransactionUtils.getId(this.data);
|
27
|
-
}
|
28
25
|
sign(privateKey) {
|
29
26
|
return __awaiter(this, void 0, void 0, function* () {
|
30
27
|
const hash = TransactionUtils.toBuffer(this.data, true).toString("hex");
|
@@ -38,7 +35,7 @@ export class AbstractTransaction {
|
|
38
35
|
recoverSender() {
|
39
36
|
const publicKey = this.recoverPublicKey();
|
40
37
|
this.data["senderPublicKey"] = publicKey.publicKey;
|
41
|
-
this.data["
|
38
|
+
this.data["from"] = Address.fromPublicKey(publicKey.publicKey);
|
42
39
|
}
|
43
40
|
verify() {
|
44
41
|
const recoveredPublicKey = this.recoverPublicKey();
|
@@ -48,29 +45,33 @@ export class AbstractTransaction {
|
|
48
45
|
}
|
49
46
|
return recoveredPublicKey.publicKey === senderPublicKey;
|
50
47
|
}
|
51
|
-
|
48
|
+
toObject() {
|
52
49
|
return [
|
53
50
|
"gasPrice",
|
54
51
|
"network",
|
55
|
-
"
|
56
|
-
"
|
52
|
+
"hash",
|
53
|
+
"gas",
|
57
54
|
"nonce",
|
58
55
|
"senderPublicKey",
|
59
|
-
"
|
56
|
+
"to",
|
60
57
|
"value",
|
61
58
|
"data",
|
62
59
|
"r",
|
63
60
|
"s",
|
64
61
|
"v",
|
65
62
|
].reduce((acc, key) => {
|
66
|
-
|
67
|
-
|
63
|
+
let value = this.data[key];
|
64
|
+
if (typeof value === "bigint") {
|
65
|
+
value = BigNumber(value).toFixed();
|
66
|
+
}
|
67
|
+
if (value !== undefined) {
|
68
|
+
acc[key] = value;
|
68
69
|
}
|
69
70
|
return acc;
|
70
71
|
}, {});
|
71
72
|
}
|
72
73
|
toJson() {
|
73
|
-
return JSON.stringify(this.
|
74
|
+
return JSON.stringify(this.toObject());
|
74
75
|
}
|
75
76
|
hash(skipSignature = false) {
|
76
77
|
return TransactionUtils.toHash(this.data, skipSignature);
|
@@ -84,7 +85,4 @@ export class AbstractTransaction {
|
|
84
85
|
}
|
85
86
|
return PublicKey.recover(Buffer.from(this.hash(true), "hex"), BigInt(`0x${this.data.r}`), BigInt(`0x${this.data.s}`), this.data.v - Constants.ETHEREUM_RECOVERY_ID_OFFSET);
|
86
87
|
}
|
87
|
-
decodePayload(data, type = ContractAbiType.CONSENSUS) {
|
88
|
-
throw new Error("Method not implemented.");
|
89
|
-
}
|
90
88
|
}
|
@@ -1,8 +1,5 @@
|
|
1
|
-
import { AbiResult, TransactionData } from "@/types";
|
2
1
|
import { AbstractTransaction } from "./AbstractTransaction";
|
3
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
4
2
|
export declare class EvmCall extends AbstractTransaction {
|
5
3
|
getPayload(): string;
|
6
|
-
protected decodePayload(data: TransactionData, type?: ContractAbiType): AbiResult | null;
|
7
4
|
}
|
8
5
|
//# sourceMappingURL=EvmCall.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EvmCall.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/EvmCall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"EvmCall.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/EvmCall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,qBAAa,OAAQ,SAAQ,mBAAmB;IAC/C,UAAU,IAAI,MAAM;CAGpB"}
|
@@ -1,14 +1,6 @@
|
|
1
1
|
import { AbstractTransaction } from "./AbstractTransaction";
|
2
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
3
|
-
import { Deserializer } from "@/transactions/Deserializer";
|
4
2
|
export class EvmCall extends AbstractTransaction {
|
5
3
|
getPayload() {
|
6
4
|
return this.data["data"] || "";
|
7
5
|
}
|
8
|
-
decodePayload(data, type = ContractAbiType.CONSENSUS) {
|
9
|
-
if (!data["data"]) {
|
10
|
-
return null;
|
11
|
-
}
|
12
|
-
return Deserializer.decodePayload(data, type);
|
13
|
-
}
|
14
6
|
}
|
@@ -1,9 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { TransactionData } from "@/types";
|
2
2
|
import { AbstractTransaction } from "./AbstractTransaction";
|
3
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
4
3
|
export declare class Multipayment extends AbstractTransaction {
|
5
4
|
constructor(data: TransactionData);
|
6
5
|
getPayload(): string;
|
7
|
-
protected decodePayload(data: TransactionData, type?: ContractAbiType): AbiResult | null;
|
8
6
|
}
|
9
7
|
//# sourceMappingURL=Multipayment.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Multipayment.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/Multipayment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"Multipayment.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/Multipayment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,qBAAa,YAAa,SAAQ,mBAAmB;gBACjC,IAAI,EAAE,eAAe;IAmBxC,UAAU,IAAI,MAAM;CAUpB"}
|
@@ -3,7 +3,6 @@ import { AbiEncoder } from "@/utils/AbiEncoder";
|
|
3
3
|
import { AbiFunction } from "@/enums/AbiFunction";
|
4
4
|
import { AbstractTransaction } from "./AbstractTransaction";
|
5
5
|
import { ContractAbiType } from "@/enums/ContractAbiType";
|
6
|
-
import { Deserializer } from "@/transactions/Deserializer";
|
7
6
|
export class Multipayment extends AbstractTransaction {
|
8
7
|
constructor(data) {
|
9
8
|
let payload;
|
@@ -24,15 +23,9 @@ export class Multipayment extends AbstractTransaction {
|
|
24
23
|
super(data);
|
25
24
|
}
|
26
25
|
getPayload() {
|
27
|
-
if (!this.data["pay"]) {
|
26
|
+
if (!this.data["pay"] || (Array.isArray(this.data["pay"]) && this.data["pay"].length === 0)) {
|
28
27
|
return "";
|
29
28
|
}
|
30
29
|
return new AbiEncoder(ContractAbiType.MULTIPAYMENT).encodeFunctionCall(AbiFunction.MULTIPAYMENT, this.data["pay"]);
|
31
30
|
}
|
32
|
-
decodePayload(data, type = ContractAbiType.CONSENSUS) {
|
33
|
-
if (!data["data"]) {
|
34
|
-
return null;
|
35
|
-
}
|
36
|
-
return Deserializer.decodePayload(data, ContractAbiType.MULTIPAYMENT);
|
37
|
-
}
|
38
31
|
}
|
@@ -1,8 +1,5 @@
|
|
1
|
-
import { AbiResult, TransactionData } from "@/types";
|
2
1
|
import { AbstractTransaction } from "./AbstractTransaction";
|
3
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
4
2
|
export declare class Transfer extends AbstractTransaction {
|
5
3
|
getPayload(): string;
|
6
|
-
protected decodePayload(data: TransactionData, type?: ContractAbiType): AbiResult | null;
|
7
4
|
}
|
8
5
|
//# sourceMappingURL=Transfer.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Transfer.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/Transfer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"Transfer.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/Transfer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,qBAAa,QAAS,SAAQ,mBAAmB;IAChD,UAAU,IAAI,MAAM;CAGpB"}
|
@@ -1,14 +1,6 @@
|
|
1
1
|
import { AbstractTransaction } from "./AbstractTransaction";
|
2
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
3
|
-
import { Deserializer } from "@/transactions/Deserializer";
|
4
2
|
export class Transfer extends AbstractTransaction {
|
5
3
|
getPayload() {
|
6
4
|
return "";
|
7
5
|
}
|
8
|
-
decodePayload(data, type = ContractAbiType.CONSENSUS) {
|
9
|
-
if (!data["data"]) {
|
10
|
-
return null;
|
11
|
-
}
|
12
|
-
return Deserializer.decodePayload(data, type);
|
13
|
-
}
|
14
6
|
}
|
@@ -1,8 +1,5 @@
|
|
1
|
-
import { AbiResult, TransactionData } from "@/types";
|
2
1
|
import { AbstractTransaction } from "./AbstractTransaction";
|
3
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
4
2
|
export declare class Unvote extends AbstractTransaction {
|
5
3
|
getPayload(): string;
|
6
|
-
protected decodePayload(data: TransactionData, type?: ContractAbiType): AbiResult | null;
|
7
4
|
}
|
8
5
|
//# sourceMappingURL=Unvote.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Unvote.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/Unvote.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"Unvote.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/Unvote.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,qBAAa,MAAO,SAAQ,mBAAmB;IAC9C,UAAU,IAAI,MAAM;CAGpB"}
|
@@ -1,16 +1,8 @@
|
|
1
1
|
import { AbiEncoder } from "@/utils/AbiEncoder";
|
2
2
|
import { AbiFunction } from "@/enums/AbiFunction";
|
3
3
|
import { AbstractTransaction } from "./AbstractTransaction";
|
4
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
5
|
-
import { Deserializer } from "@/transactions/Deserializer";
|
6
4
|
export class Unvote extends AbstractTransaction {
|
7
5
|
getPayload() {
|
8
6
|
return new AbiEncoder().encodeFunctionCall(AbiFunction.UNVOTE, []);
|
9
7
|
}
|
10
|
-
decodePayload(data, type = ContractAbiType.CONSENSUS) {
|
11
|
-
if (!data["data"]) {
|
12
|
-
return null;
|
13
|
-
}
|
14
|
-
return Deserializer.decodePayload(data, type);
|
15
|
-
}
|
16
8
|
}
|
@@ -1,9 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { TransactionData } from "@/types";
|
2
2
|
import { AbstractTransaction } from "./AbstractTransaction";
|
3
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
4
3
|
export declare class UsernameRegistration extends AbstractTransaction {
|
5
4
|
constructor(data: TransactionData);
|
6
5
|
getPayload(): string;
|
7
|
-
protected decodePayload(data: TransactionData, type?: ContractAbiType): AbiResult | null;
|
8
6
|
}
|
9
7
|
//# sourceMappingURL=UsernameRegistration.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UsernameRegistration.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/UsernameRegistration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"UsernameRegistration.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/UsernameRegistration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,qBAAa,oBAAqB,SAAQ,mBAAmB;gBACzC,IAAI,EAAE,eAAe;IAaxC,UAAU,IAAI,MAAM;CASpB"}
|
@@ -3,7 +3,6 @@ import { AbiEncoder } from "@/utils/AbiEncoder";
|
|
3
3
|
import { AbiFunction } from "@/enums/AbiFunction";
|
4
4
|
import { AbstractTransaction } from "./AbstractTransaction";
|
5
5
|
import { ContractAbiType } from "@/enums/ContractAbiType";
|
6
|
-
import { Deserializer } from "@/transactions/Deserializer";
|
7
6
|
export class UsernameRegistration extends AbstractTransaction {
|
8
7
|
constructor(data) {
|
9
8
|
let payload;
|
@@ -24,10 +23,4 @@ export class UsernameRegistration extends AbstractTransaction {
|
|
24
23
|
this.data["username"],
|
25
24
|
]);
|
26
25
|
}
|
27
|
-
decodePayload(data, type = ContractAbiType.CONSENSUS) {
|
28
|
-
if (!data["data"]) {
|
29
|
-
return null;
|
30
|
-
}
|
31
|
-
return Deserializer.decodePayload(data, ContractAbiType.USERNAMES);
|
32
|
-
}
|
33
26
|
}
|
@@ -1,8 +1,5 @@
|
|
1
|
-
import { AbiResult, TransactionData } from "@/types";
|
2
1
|
import { AbstractTransaction } from "./AbstractTransaction";
|
3
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
4
2
|
export declare class UsernameResignation extends AbstractTransaction {
|
5
3
|
getPayload(): string;
|
6
|
-
protected decodePayload(data: TransactionData, type?: ContractAbiType): AbiResult | null;
|
7
4
|
}
|
8
5
|
//# sourceMappingURL=UsernameResignation.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UsernameResignation.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/UsernameResignation.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"UsernameResignation.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/UsernameResignation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,qBAAa,mBAAoB,SAAQ,mBAAmB;IAC3D,UAAU,IAAI,MAAM;CAGpB"}
|
@@ -2,15 +2,8 @@ import { AbiEncoder } from "@/utils/AbiEncoder";
|
|
2
2
|
import { AbiFunction } from "@/enums/AbiFunction";
|
3
3
|
import { AbstractTransaction } from "./AbstractTransaction";
|
4
4
|
import { ContractAbiType } from "@/enums/ContractAbiType";
|
5
|
-
import { Deserializer } from "@/transactions/Deserializer";
|
6
5
|
export class UsernameResignation extends AbstractTransaction {
|
7
6
|
getPayload() {
|
8
7
|
return new AbiEncoder(ContractAbiType.USERNAMES).encodeFunctionCall(AbiFunction.USERNAME_RESIGNATION, []);
|
9
8
|
}
|
10
|
-
decodePayload(data, type = ContractAbiType.CONSENSUS) {
|
11
|
-
if (!data["data"]) {
|
12
|
-
return null;
|
13
|
-
}
|
14
|
-
return Deserializer.decodePayload(data, ContractAbiType.USERNAMES);
|
15
|
-
}
|
16
9
|
}
|
@@ -1,9 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { TransactionData } from "@/types";
|
2
2
|
import { AbstractTransaction } from "./AbstractTransaction";
|
3
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
4
3
|
export declare class ValidatorRegistration extends AbstractTransaction {
|
5
4
|
constructor(data: TransactionData);
|
6
5
|
getPayload(): string;
|
7
|
-
protected decodePayload(data: TransactionData, type?: ContractAbiType): AbiResult | null;
|
8
6
|
}
|
9
7
|
//# sourceMappingURL=ValidatorRegistration.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ValidatorRegistration.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/ValidatorRegistration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"ValidatorRegistration.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/ValidatorRegistration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,qBAAa,qBAAsB,SAAQ,mBAAmB;gBAC1C,IAAI,EAAE,eAAe;IAaxC,UAAU,IAAI,MAAM;CASpB"}
|
@@ -2,8 +2,6 @@ import { AbiDecoder } from "@/utils/AbiDecoder";
|
|
2
2
|
import { AbiEncoder } from "@/utils/AbiEncoder";
|
3
3
|
import { AbiFunction } from "@/enums/AbiFunction";
|
4
4
|
import { AbstractTransaction } from "./AbstractTransaction";
|
5
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
6
|
-
import { Deserializer } from "@/transactions/Deserializer";
|
7
5
|
export class ValidatorRegistration extends AbstractTransaction {
|
8
6
|
constructor(data) {
|
9
7
|
let payload;
|
@@ -24,10 +22,4 @@ export class ValidatorRegistration extends AbstractTransaction {
|
|
24
22
|
this.data["validatorPublicKey"],
|
25
23
|
]);
|
26
24
|
}
|
27
|
-
decodePayload(data, type = ContractAbiType.CONSENSUS) {
|
28
|
-
if (!data["data"]) {
|
29
|
-
return null;
|
30
|
-
}
|
31
|
-
return Deserializer.decodePayload(data, type);
|
32
|
-
}
|
33
25
|
}
|
@@ -1,8 +1,5 @@
|
|
1
|
-
import { AbiResult, TransactionData } from "@/types";
|
2
1
|
import { AbstractTransaction } from "./AbstractTransaction";
|
3
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
4
2
|
export declare class ValidatorResignation extends AbstractTransaction {
|
5
3
|
getPayload(): string;
|
6
|
-
protected decodePayload(data: TransactionData, type?: ContractAbiType): AbiResult | null;
|
7
4
|
}
|
8
5
|
//# sourceMappingURL=ValidatorResignation.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ValidatorResignation.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/ValidatorResignation.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"ValidatorResignation.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/ValidatorResignation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,qBAAa,oBAAqB,SAAQ,mBAAmB;IAC5D,UAAU,IAAI,MAAM;CAGpB"}
|
@@ -1,16 +1,8 @@
|
|
1
1
|
import { AbiEncoder } from "@/utils/AbiEncoder";
|
2
2
|
import { AbiFunction } from "@/enums/AbiFunction";
|
3
3
|
import { AbstractTransaction } from "./AbstractTransaction";
|
4
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
5
|
-
import { Deserializer } from "@/transactions/Deserializer";
|
6
4
|
export class ValidatorResignation extends AbstractTransaction {
|
7
5
|
getPayload() {
|
8
6
|
return new AbiEncoder().encodeFunctionCall(AbiFunction.VALIDATOR_RESIGNATION, []);
|
9
7
|
}
|
10
|
-
decodePayload(data, type = ContractAbiType.CONSENSUS) {
|
11
|
-
if (!data["data"]) {
|
12
|
-
return null;
|
13
|
-
}
|
14
|
-
return Deserializer.decodePayload(data, type);
|
15
|
-
}
|
16
8
|
}
|
@@ -1,9 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { TransactionData } from "@/types";
|
2
2
|
import { AbstractTransaction } from "./AbstractTransaction";
|
3
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
4
3
|
export declare class Vote extends AbstractTransaction {
|
5
4
|
constructor(data: TransactionData);
|
6
5
|
getPayload(): string;
|
7
|
-
protected decodePayload(data: TransactionData, type?: ContractAbiType): AbiResult | null;
|
8
6
|
}
|
9
7
|
//# sourceMappingURL=Vote.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Vote.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/Vote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"Vote.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/Vote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,qBAAa,IAAK,SAAQ,mBAAmB;gBACzB,IAAI,EAAE,eAAe;IAaxC,UAAU,IAAI,MAAM;CAOpB"}
|
@@ -2,8 +2,6 @@ import { AbiDecoder } from "@/utils/AbiDecoder";
|
|
2
2
|
import { AbiEncoder } from "@/utils/AbiEncoder";
|
3
3
|
import { AbiFunction } from "@/enums/AbiFunction";
|
4
4
|
import { AbstractTransaction } from "./AbstractTransaction";
|
5
|
-
import { ContractAbiType } from "@/enums/ContractAbiType";
|
6
|
-
import { Deserializer } from "@/transactions/Deserializer";
|
7
5
|
export class Vote extends AbstractTransaction {
|
8
6
|
constructor(data) {
|
9
7
|
let payload;
|
@@ -22,10 +20,4 @@ export class Vote extends AbstractTransaction {
|
|
22
20
|
}
|
23
21
|
return new AbiEncoder().encodeFunctionCall(AbiFunction.VOTE, [this.data["vote"]]);
|
24
22
|
}
|
25
|
-
decodePayload(data, type = ContractAbiType.CONSENSUS) {
|
26
|
-
if (!data["data"]) {
|
27
|
-
return null;
|
28
|
-
}
|
29
|
-
return Deserializer.decodePayload(data, type);
|
30
|
-
}
|
31
23
|
}
|
package/dist/types.d.ts
CHANGED
@@ -1,56 +1,56 @@
|
|
1
|
+
import BigNumber from "bignumber.js";
|
1
2
|
import { Result } from "ethers";
|
2
|
-
export
|
3
|
+
export interface TransactionData {
|
3
4
|
gasPrice?: string | null;
|
4
5
|
network?: number | string | null;
|
5
|
-
|
6
|
-
|
6
|
+
hash?: string | null;
|
7
|
+
gas?: string | null;
|
7
8
|
nonce?: number | string | null;
|
8
9
|
senderPublicKey?: string | null;
|
9
|
-
|
10
|
+
to?: string | null;
|
10
11
|
value?: string | null;
|
11
12
|
data?: string | null;
|
12
13
|
r?: string;
|
13
14
|
s?: string;
|
14
15
|
v?: number;
|
15
|
-
[key: string]: number | string | undefined | null |
|
16
|
-
}
|
17
|
-
export
|
16
|
+
[key: string]: number | string | undefined | null | unknown[] | string;
|
17
|
+
}
|
18
|
+
export interface AbiResult {
|
18
19
|
functionName: string;
|
19
20
|
args: Result;
|
20
|
-
}
|
21
|
-
export
|
21
|
+
}
|
22
|
+
export interface SignedMessage {
|
22
23
|
publicKey: string;
|
23
24
|
signature: string;
|
24
25
|
message: string;
|
25
|
-
}
|
26
|
+
}
|
26
27
|
export interface ITransaction {
|
27
28
|
data: TransactionData;
|
28
29
|
serialized: Buffer | undefined;
|
29
30
|
getPayload(): string;
|
30
31
|
refreshPayloadData(): ITransaction;
|
31
|
-
|
32
|
-
sign(privateKey: any): Promise<ITransaction>;
|
32
|
+
sign(privateKey: unknown): Promise<ITransaction>;
|
33
33
|
recoverSender(): void;
|
34
34
|
verify(): boolean;
|
35
|
-
|
35
|
+
toObject(): TransactionData;
|
36
36
|
toJson(): string;
|
37
37
|
hash(skipSignature?: boolean): string;
|
38
38
|
serialize(skipSignature?: boolean): Buffer;
|
39
39
|
}
|
40
40
|
export interface ITransactionBuilder<T extends ITransactionBuilder<T>> {
|
41
41
|
transaction: ITransaction;
|
42
|
-
|
43
|
-
gasPrice(gasPrice: string): T;
|
44
|
-
|
42
|
+
gas(gas: string | BigNumber): T;
|
43
|
+
gasPrice(gasPrice: string | BigNumber): T;
|
44
|
+
to(to: string): T;
|
45
45
|
nonce(nonce: string): T;
|
46
46
|
network(network: number): T;
|
47
47
|
sign(passphrase: string): Promise<T>;
|
48
48
|
verify(): boolean;
|
49
|
-
|
49
|
+
toObject(): TransactionData;
|
50
50
|
toJson(): string;
|
51
51
|
}
|
52
52
|
export interface ITransferBuilder extends ITransactionBuilder<ITransferBuilder> {
|
53
|
-
value(value: string): ITransferBuilder;
|
53
|
+
value(value: string | BigNumber): ITransferBuilder;
|
54
54
|
}
|
55
55
|
export interface IVoteBuilder extends ITransactionBuilder<IVoteBuilder> {
|
56
56
|
vote(vote: string): IVoteBuilder;
|
@@ -65,7 +65,7 @@ export interface IEvmCallBuilder extends ITransactionBuilder<IEvmCallBuilder> {
|
|
65
65
|
payload(payload: string): IEvmCallBuilder;
|
66
66
|
}
|
67
67
|
export interface IMultipaymentBuilder extends ITransactionBuilder<IMultipaymentBuilder> {
|
68
|
-
pay(address: string, amount: string): IMultipaymentBuilder;
|
68
|
+
pay(address: string, amount: string | BigNumber): IMultipaymentBuilder;
|
69
69
|
}
|
70
70
|
export interface IBasicTransactionBuilder extends ITransactionBuilder<IBasicTransactionBuilder> {
|
71
71
|
}
|
package/dist/types.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
@@ -1,21 +1,21 @@
|
|
1
1
|
import { AbiCoder } from "ethers";
|
2
2
|
export class ArgumentDecoder {
|
3
3
|
constructor(bytes) {
|
4
|
-
this.bytes = Buffer.from(bytes,
|
4
|
+
this.bytes = Buffer.from(bytes, "hex");
|
5
5
|
}
|
6
6
|
decodeString() {
|
7
|
-
return new AbiCoder().decode([
|
7
|
+
return new AbiCoder().decode(["string"], this.bytes)[0].toString();
|
8
8
|
}
|
9
9
|
decodeAddress() {
|
10
|
-
return new AbiCoder().decode([
|
10
|
+
return new AbiCoder().decode(["address"], this.bytes).toString();
|
11
11
|
}
|
12
12
|
decodeUnsignedInt() {
|
13
|
-
return new AbiCoder().decode([
|
13
|
+
return new AbiCoder().decode(["uint"], this.bytes)[0].toString();
|
14
14
|
}
|
15
15
|
decodeSignedInt() {
|
16
|
-
return new AbiCoder().decode([
|
16
|
+
return new AbiCoder().decode(["int"], this.bytes)[0].toString();
|
17
17
|
}
|
18
18
|
decodeBool() {
|
19
|
-
return new AbiCoder().decode([
|
19
|
+
return new AbiCoder().decode(["bool"], this.bytes)[0] === true;
|
20
20
|
}
|
21
21
|
}
|