@arkecosystem/typescript-crypto 0.0.1
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/.editorconfig +16 -0
- package/.eslintrc.js +12 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +24 -0
- package/.github/workflows/ci.yml +36 -0
- package/.github/workflows/publish.yml +56 -0
- package/.vscode/settings.json +2 -0
- package/README.md +31 -0
- package/dist/configuration/Network.d.ts +7 -0
- package/dist/configuration/Network.d.ts.map +1 -0
- package/dist/configuration/Network.js +12 -0
- package/dist/configuration/index.d.ts +2 -0
- package/dist/configuration/index.d.ts.map +1 -0
- package/dist/configuration/index.js +1 -0
- package/dist/enums/AbiFunction.d.ts +10 -0
- package/dist/enums/AbiFunction.d.ts.map +1 -0
- package/dist/enums/AbiFunction.js +10 -0
- package/dist/enums/Constants.d.ts +5 -0
- package/dist/enums/Constants.d.ts.map +1 -0
- package/dist/enums/Constants.js +5 -0
- package/dist/enums/ContractAbiType.d.ts +7 -0
- package/dist/enums/ContractAbiType.d.ts.map +1 -0
- package/dist/enums/ContractAbiType.js +7 -0
- package/dist/enums/ContractAddresses.d.ts +6 -0
- package/dist/enums/ContractAddresses.d.ts.map +1 -0
- package/dist/enums/ContractAddresses.js +6 -0
- package/dist/enums/index.d.ts +5 -0
- package/dist/enums/index.d.ts.map +1 -0
- package/dist/enums/index.js +4 -0
- package/dist/exceptions/InvalidUsernameException.d.ts +4 -0
- package/dist/exceptions/InvalidUsernameException.d.ts.map +1 -0
- package/dist/exceptions/InvalidUsernameException.js +6 -0
- package/dist/exceptions/index.d.ts +2 -0
- package/dist/exceptions/index.d.ts.map +1 -0
- package/dist/exceptions/index.js +1 -0
- package/dist/identities/Address.d.ts +7 -0
- package/dist/identities/Address.d.ts.map +1 -0
- package/dist/identities/Address.js +15 -0
- package/dist/identities/PrivateKey.d.ts +16 -0
- package/dist/identities/PrivateKey.d.ts.map +1 -0
- package/dist/identities/PrivateKey.js +31 -0
- package/dist/identities/PublicKey.d.ts +8 -0
- package/dist/identities/PublicKey.d.ts.map +1 -0
- package/dist/identities/PublicKey.js +24 -0
- package/dist/identities/WIF.d.ts +4 -0
- package/dist/identities/WIF.d.ts.map +1 -0
- package/dist/identities/WIF.js +13 -0
- package/dist/identities/index.d.ts +5 -0
- package/dist/identities/index.d.ts.map +1 -0
- package/dist/identities/index.js +4 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/networks/AbstractNetwork.d.ts +6 -0
- package/dist/networks/AbstractNetwork.d.ts.map +1 -0
- package/dist/networks/AbstractNetwork.js +2 -0
- package/dist/networks/Mainnet.d.ts +7 -0
- package/dist/networks/Mainnet.d.ts.map +1 -0
- package/dist/networks/Mainnet.js +12 -0
- package/dist/networks/Testnet.d.ts +7 -0
- package/dist/networks/Testnet.d.ts.map +1 -0
- package/dist/networks/Testnet.js +12 -0
- package/dist/networks/index.d.ts +4 -0
- package/dist/networks/index.d.ts.map +1 -0
- package/dist/networks/index.js +3 -0
- package/dist/transactions/Deserializer.d.ts +18 -0
- package/dist/transactions/Deserializer.d.ts.map +1 -0
- package/dist/transactions/Deserializer.js +106 -0
- package/dist/transactions/Serializer.d.ts +9 -0
- package/dist/transactions/Serializer.d.ts.map +1 -0
- package/dist/transactions/Serializer.js +16 -0
- package/dist/transactions/builders/AbstractTransactionBuilder.d.ts +17 -0
- package/dist/transactions/builders/AbstractTransactionBuilder.d.ts.map +1 -0
- package/dist/transactions/builders/AbstractTransactionBuilder.js +54 -0
- package/dist/transactions/builders/EvmCallBuilder.d.ts +9 -0
- package/dist/transactions/builders/EvmCallBuilder.d.ts.map +1 -0
- package/dist/transactions/builders/EvmCallBuilder.js +18 -0
- package/dist/transactions/builders/MultipaymentBuilder.d.ts +9 -0
- package/dist/transactions/builders/MultipaymentBuilder.d.ts.map +1 -0
- package/dist/transactions/builders/MultipaymentBuilder.js +25 -0
- package/dist/transactions/builders/TransferBuilder.d.ts +8 -0
- package/dist/transactions/builders/TransferBuilder.d.ts.map +1 -0
- package/dist/transactions/builders/TransferBuilder.js +15 -0
- package/dist/transactions/builders/UnvoteBuilder.d.ts +8 -0
- package/dist/transactions/builders/UnvoteBuilder.d.ts.map +1 -0
- package/dist/transactions/builders/UnvoteBuilder.js +15 -0
- package/dist/transactions/builders/UsernameRegistrationBuilder.d.ts +9 -0
- package/dist/transactions/builders/UsernameRegistrationBuilder.d.ts.map +1 -0
- package/dist/transactions/builders/UsernameRegistrationBuilder.js +22 -0
- package/dist/transactions/builders/UsernameResignationBuilder.d.ts +8 -0
- package/dist/transactions/builders/UsernameResignationBuilder.d.ts.map +1 -0
- package/dist/transactions/builders/UsernameResignationBuilder.js +15 -0
- package/dist/transactions/builders/ValidatorRegistrationBuilder.d.ts +9 -0
- package/dist/transactions/builders/ValidatorRegistrationBuilder.d.ts.map +1 -0
- package/dist/transactions/builders/ValidatorRegistrationBuilder.js +20 -0
- package/dist/transactions/builders/ValidatorResignationBuilder.d.ts +8 -0
- package/dist/transactions/builders/ValidatorResignationBuilder.d.ts.map +1 -0
- package/dist/transactions/builders/ValidatorResignationBuilder.js +15 -0
- package/dist/transactions/builders/VoteBuilder.d.ts +9 -0
- package/dist/transactions/builders/VoteBuilder.d.ts.map +1 -0
- package/dist/transactions/builders/VoteBuilder.js +20 -0
- package/dist/transactions/builders/index.d.ts +11 -0
- package/dist/transactions/builders/index.d.ts.map +1 -0
- package/dist/transactions/builders/index.js +10 -0
- package/dist/transactions/index.d.ts +5 -0
- package/dist/transactions/index.d.ts.map +1 -0
- package/dist/transactions/index.js +4 -0
- package/dist/transactions/types/AbstractTransaction.d.ts +22 -0
- package/dist/transactions/types/AbstractTransaction.d.ts.map +1 -0
- package/dist/transactions/types/AbstractTransaction.js +79 -0
- package/dist/transactions/types/EvmCall.d.ts +8 -0
- package/dist/transactions/types/EvmCall.d.ts.map +1 -0
- package/dist/transactions/types/EvmCall.js +14 -0
- package/dist/transactions/types/Multipayment.d.ts +9 -0
- package/dist/transactions/types/Multipayment.d.ts.map +1 -0
- package/dist/transactions/types/Multipayment.js +38 -0
- package/dist/transactions/types/Transfer.d.ts +8 -0
- package/dist/transactions/types/Transfer.d.ts.map +1 -0
- package/dist/transactions/types/Transfer.js +14 -0
- package/dist/transactions/types/Unvote.d.ts +8 -0
- package/dist/transactions/types/Unvote.d.ts.map +1 -0
- package/dist/transactions/types/Unvote.js +16 -0
- package/dist/transactions/types/UsernameRegistration.d.ts +9 -0
- package/dist/transactions/types/UsernameRegistration.d.ts.map +1 -0
- package/dist/transactions/types/UsernameRegistration.js +33 -0
- package/dist/transactions/types/UsernameResignation.d.ts +8 -0
- package/dist/transactions/types/UsernameResignation.d.ts.map +1 -0
- package/dist/transactions/types/UsernameResignation.js +16 -0
- package/dist/transactions/types/ValidatorRegistration.d.ts +9 -0
- package/dist/transactions/types/ValidatorRegistration.d.ts.map +1 -0
- package/dist/transactions/types/ValidatorRegistration.js +33 -0
- package/dist/transactions/types/ValidatorResignation.d.ts +8 -0
- package/dist/transactions/types/ValidatorResignation.d.ts.map +1 -0
- package/dist/transactions/types/ValidatorResignation.js +16 -0
- package/dist/transactions/types/Vote.d.ts +9 -0
- package/dist/transactions/types/Vote.d.ts.map +1 -0
- package/dist/transactions/types/Vote.js +31 -0
- package/dist/transactions/types/index.d.ts +11 -0
- package/dist/transactions/types/index.d.ts.map +1 -0
- package/dist/transactions/types/index.js +10 -0
- package/dist/types.d.ts +72 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils/Abi/ArgumentDecoder.d.ts +10 -0
- package/dist/utils/Abi/ArgumentDecoder.d.ts.map +1 -0
- package/dist/utils/Abi/ArgumentDecoder.js +21 -0
- package/dist/utils/Abi/json/Abi.Consensus.json +1673 -0
- package/dist/utils/Abi/json/Abi.Multipayment.json +110 -0
- package/dist/utils/Abi/json/Abi.Usernames.json +900 -0
- package/dist/utils/AbiBase.d.ts +8 -0
- package/dist/utils/AbiBase.d.ts.map +1 -0
- package/dist/utils/AbiBase.js +25 -0
- package/dist/utils/AbiDecoder.d.ts +6 -0
- package/dist/utils/AbiDecoder.d.ts.map +1 -0
- package/dist/utils/AbiDecoder.js +14 -0
- package/dist/utils/AbiEncoder.d.ts +5 -0
- package/dist/utils/AbiEncoder.d.ts.map +1 -0
- package/dist/utils/AbiEncoder.js +6 -0
- package/dist/utils/Helpers.d.ts +19 -0
- package/dist/utils/Helpers.d.ts.map +1 -0
- package/dist/utils/Helpers.js +38 -0
- package/dist/utils/Message.d.ts +14 -0
- package/dist/utils/Message.d.ts.map +1 -0
- package/dist/utils/Message.js +43 -0
- package/dist/utils/Slot.d.ts +5 -0
- package/dist/utils/Slot.d.ts.map +1 -0
- package/dist/utils/Slot.js +9 -0
- package/dist/utils/TransactionUtils.d.ts +7 -0
- package/dist/utils/TransactionUtils.d.ts.map +1 -0
- package/dist/utils/TransactionUtils.js +35 -0
- package/dist/utils/UnitConverter.d.ts +8 -0
- package/dist/utils/UnitConverter.d.ts.map +1 -0
- package/dist/utils/UnitConverter.js +48 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/jest.config.ts +14 -0
- package/package.json +59 -0
- package/prettier.config.js +8 -0
- package/src/configuration/Network.ts +18 -0
- package/src/configuration/index.ts +1 -0
- package/src/enums/AbiFunction.ts +9 -0
- package/src/enums/Constants.ts +4 -0
- package/src/enums/ContractAbiType.ts +6 -0
- package/src/enums/ContractAddresses.ts +5 -0
- package/src/enums/index.ts +4 -0
- package/src/exceptions/InvalidUsernameException.ts +6 -0
- package/src/exceptions/index.ts +1 -0
- package/src/identities/Address.ts +19 -0
- package/src/identities/PrivateKey.ts +49 -0
- package/src/identities/PublicKey.ts +28 -0
- package/src/identities/WIF.ts +16 -0
- package/src/identities/index.ts +4 -0
- package/src/index.ts +7 -0
- package/src/networks/AbstractNetwork.ts +7 -0
- package/src/networks/Mainnet.ts +15 -0
- package/src/networks/Testnet.ts +15 -0
- package/src/networks/index.ts +3 -0
- package/src/transactions/Deserializer.ts +140 -0
- package/src/transactions/Serializer.ts +24 -0
- package/src/transactions/builders/AbstractTransactionBuilder.ts +81 -0
- package/src/transactions/builders/EvmCallBuilder.ts +24 -0
- package/src/transactions/builders/MultipaymentBuilder.ts +37 -0
- package/src/transactions/builders/TransferBuilder.ts +22 -0
- package/src/transactions/builders/UnvoteBuilder.ts +21 -0
- package/src/transactions/builders/UsernameRegistrationBuilder.ts +35 -0
- package/src/transactions/builders/UsernameResignationBuilder.ts +21 -0
- package/src/transactions/builders/ValidatorRegistrationBuilder.ts +32 -0
- package/src/transactions/builders/ValidatorResignationBuilder.ts +21 -0
- package/src/transactions/builders/VoteBuilder.ts +29 -0
- package/src/transactions/builders/index.ts +10 -0
- package/src/transactions/index.ts +4 -0
- package/src/transactions/types/AbstractTransaction.ts +118 -0
- package/src/transactions/types/EvmCall.ts +22 -0
- package/src/transactions/types/Multipayment.ts +51 -0
- package/src/transactions/types/Transfer.ts +22 -0
- package/src/transactions/types/Unvote.ts +24 -0
- package/src/transactions/types/UsernameRegistration.ts +44 -0
- package/src/transactions/types/UsernameResignation.ts +24 -0
- package/src/transactions/types/ValidatorRegistration.ts +44 -0
- package/src/transactions/types/ValidatorResignation.ts +24 -0
- package/src/transactions/types/Vote.ts +42 -0
- package/src/transactions/types/index.ts +10 -0
- package/src/types.ts +86 -0
- package/src/utils/Abi/ArgumentDecoder.ts +29 -0
- package/src/utils/Abi/json/Abi.Consensus.json +1673 -0
- package/src/utils/Abi/json/Abi.Multipayment.json +110 -0
- package/src/utils/Abi/json/Abi.Usernames.json +900 -0
- package/src/utils/AbiBase.ts +32 -0
- package/src/utils/AbiDecoder.ts +19 -0
- package/src/utils/AbiEncoder.ts +7 -0
- package/src/utils/Helpers.ts +46 -0
- package/src/utils/Message.ts +63 -0
- package/src/utils/Slot.ts +11 -0
- package/src/utils/TransactionUtils.ts +43 -0
- package/src/utils/UnitConverter.ts +57 -0
- package/src/utils/index.ts +8 -0
- package/tests/fixtures/global.json +10 -0
- package/tests/fixtures/identity.json +11 -0
- package/tests/fixtures/message-sign.json +5 -0
- package/tests/fixtures/sign-compact.json +10 -0
- package/tests/fixtures/transactions/evm-sign.json +18 -0
- package/tests/fixtures/transactions/multipayment-empty.json +18 -0
- package/tests/fixtures/transactions/multipayment-single.json +18 -0
- package/tests/fixtures/transactions/multipayment.json +18 -0
- package/tests/fixtures/transactions/transfer-0.json +18 -0
- package/tests/fixtures/transactions/transfer-large-amount.json +18 -0
- package/tests/fixtures/transactions/transfer.json +18 -0
- package/tests/fixtures/transactions/unvote.json +18 -0
- package/tests/fixtures/transactions/username-registration.json +18 -0
- package/tests/fixtures/transactions/username-resignation.json +18 -0
- package/tests/fixtures/transactions/validator-registration.json +18 -0
- package/tests/fixtures/transactions/validator-resignation.json +18 -0
- package/tests/fixtures/transactions/vote.json +18 -0
- package/tests/unit/identities/Address.test.ts +26 -0
- package/tests/unit/identities/PrivateKey.test.ts +36 -0
- package/tests/unit/identities/PublicKey.test.ts +39 -0
- package/tests/unit/identities/WIF.test.ts +8 -0
- package/tests/unit/transactions/Deserializer.test.ts +138 -0
- package/tests/unit/transactions/Serializer.test.ts +9 -0
- package/tests/unit/transactions/builders/EvmCallBuilder.test.ts +49 -0
- package/tests/unit/transactions/builders/MultipaymentBuilder.test.ts +99 -0
- package/tests/unit/transactions/builders/TransferBuilder.test.ts +73 -0
- package/tests/unit/transactions/builders/UnvoteBuilder.test.ts +47 -0
- package/tests/unit/transactions/builders/UsernameRegistrationBuilder.test.ts +54 -0
- package/tests/unit/transactions/builders/UsernameResignationBuilder.test.ts +48 -0
- package/tests/unit/transactions/builders/ValidatorRegistrationBuilder.test.ts +51 -0
- package/tests/unit/transactions/builders/ValidatorResignationBuilder.test.ts +48 -0
- package/tests/unit/transactions/builders/VoteBuilder.test.ts +48 -0
- package/tests/unit/transactions/types/AbstractTransaction.test.ts +145 -0
- package/tests/unit/utils/Abi/ArgumentDecoder.test.ts +55 -0
- package/tests/unit/utils/AbiDecoder.test.ts +44 -0
- package/tests/unit/utils/AbiEncoder.test.ts +30 -0
- package/tests/unit/utils/Helpers.test.ts +120 -0
- package/tests/unit/utils/Message.test.ts +104 -0
- package/tests/unit/utils/Slot.test.ts +69 -0
- package/tests/unit/utils/TransactionUtils.test.ts +31 -0
- package/tests/unit/utils/UnitConverter.test.ts +71 -0
- package/tsconfig.json +20 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/networks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { AbiResult, ITransaction, TransactionData } from "../types";
|
2
|
+
import { ContractAbiType } from "../enums/ContractAbiType";
|
3
|
+
export declare class Deserializer {
|
4
|
+
SIGNATURE_SIZE: number;
|
5
|
+
RECOVERY_SIZE: number;
|
6
|
+
encoded_rlp: string;
|
7
|
+
serialized: string;
|
8
|
+
constructor(serialized: string);
|
9
|
+
static new(serialized: string): Deserializer;
|
10
|
+
deserialize(): ITransaction;
|
11
|
+
guessTransactionFromData(data: TransactionData): ITransaction;
|
12
|
+
static decodePayload(data: TransactionData, abiType?: ContractAbiType): AbiResult | null;
|
13
|
+
static parseNumber(value: string): number;
|
14
|
+
static parseBigNumber(value: string): string;
|
15
|
+
static parseAddress(value: string): string | undefined;
|
16
|
+
static parseHex(value: string): string;
|
17
|
+
}
|
18
|
+
//# sourceMappingURL=Deserializer.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Deserializer.d.ts","sourceRoot":"","sources":["../../src/transactions/Deserializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAIpE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAO3D,qBAAa,YAAY;IACxB,cAAc,SAAM;IACpB,aAAa,SAAK;IAElB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;gBAEP,UAAU,EAAE,MAAM;IAK9B,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY;IAI5C,WAAW,IAAI,YAAY;IA6B3B,wBAAwB,CAAC,IAAI,EAAE,eAAe,GAAG,YAAY;IAgD7D,MAAM,CAAC,aAAa,CACnB,IAAI,EAAE,eAAe,EACrB,OAAO,GAAE,eAA2C,GAClD,SAAS,GAAG,IAAI;IAiBnB,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAIzC,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI5C,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAItD,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAGtC"}
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import BigNumber from "bignumber.js";
|
2
|
+
import { Constants } from "../enums/Constants";
|
3
|
+
import { ContractAbiType } from "../enums/ContractAbiType";
|
4
|
+
import { Transfer } from "./types/Transfer";
|
5
|
+
import { decodeRlp } from "ethers";
|
6
|
+
import { EvmCall, Multipayment, Unvote, UsernameRegistration, UsernameResignation, ValidatorRegistration, ValidatorResignation, Vote } from "./types";
|
7
|
+
import { AbiFunction } from "../enums";
|
8
|
+
import { AbiDecoder } from "../utils";
|
9
|
+
export class Deserializer {
|
10
|
+
constructor(serialized) {
|
11
|
+
this.SIGNATURE_SIZE = 64;
|
12
|
+
this.RECOVERY_SIZE = 1;
|
13
|
+
this.serialized = serialized;
|
14
|
+
this.encoded_rlp = "0x" + serialized.substring(2);
|
15
|
+
}
|
16
|
+
static new(serialized) {
|
17
|
+
return new Deserializer(serialized);
|
18
|
+
}
|
19
|
+
deserialize() {
|
20
|
+
const decodedRlp = decodeRlp(this.encoded_rlp);
|
21
|
+
const data = {
|
22
|
+
network: Number(decodedRlp[0]),
|
23
|
+
nonce: Deserializer.parseNumber(decodedRlp[1]),
|
24
|
+
gasPrice: Deserializer.parseNumber(decodedRlp[3]).toString(),
|
25
|
+
gasLimit: Deserializer.parseNumber(decodedRlp[4]).toString(),
|
26
|
+
recipientAddress: Deserializer.parseAddress(decodedRlp[5]),
|
27
|
+
value: Deserializer.parseBigNumber(decodedRlp[6]),
|
28
|
+
data: Deserializer.parseHex(decodedRlp[7]),
|
29
|
+
};
|
30
|
+
if (decodedRlp.length === 12) {
|
31
|
+
data["v"] = Deserializer.parseNumber(decodedRlp[9]) + Constants.ETHEREUM_RECOVERY_ID_OFFSET;
|
32
|
+
data["r"] = Deserializer.parseHex(decodedRlp[10]);
|
33
|
+
data["s"] = Deserializer.parseHex(decodedRlp[11]);
|
34
|
+
}
|
35
|
+
const transaction = this.guessTransactionFromData(data);
|
36
|
+
transaction.data = data;
|
37
|
+
transaction.recoverSender();
|
38
|
+
transaction.data["id"] = transaction.getId();
|
39
|
+
return transaction;
|
40
|
+
}
|
41
|
+
guessTransactionFromData(data) {
|
42
|
+
const multipaymentPayloadData = Deserializer.decodePayload(data, ContractAbiType.MULTIPAYMENT);
|
43
|
+
if (multipaymentPayloadData !== null) {
|
44
|
+
const functionName = multipaymentPayloadData.functionName;
|
45
|
+
if (functionName == AbiFunction.MULTIPAYMENT) {
|
46
|
+
return new Multipayment(data);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
if (data.value !== "0") {
|
50
|
+
return new Transfer(data);
|
51
|
+
}
|
52
|
+
const consensusPayloadData = Deserializer.decodePayload(data);
|
53
|
+
if (consensusPayloadData !== null) {
|
54
|
+
const functionName = consensusPayloadData.functionName;
|
55
|
+
if (functionName == AbiFunction.VOTE) {
|
56
|
+
return new Vote(data);
|
57
|
+
}
|
58
|
+
if (functionName == AbiFunction.UNVOTE) {
|
59
|
+
return new Unvote(data);
|
60
|
+
}
|
61
|
+
if (functionName == AbiFunction.VALIDATOR_REGISTRATION) {
|
62
|
+
return new ValidatorRegistration(data);
|
63
|
+
}
|
64
|
+
if (functionName == AbiFunction.VALIDATOR_RESIGNATION) {
|
65
|
+
return new ValidatorResignation(data);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
const usernamePayloadData = Deserializer.decodePayload(data, ContractAbiType.USERNAMES);
|
69
|
+
if (usernamePayloadData !== null) {
|
70
|
+
const functionName = usernamePayloadData.functionName;
|
71
|
+
if (functionName == AbiFunction.USERNAME_REGISTRATION) {
|
72
|
+
return new UsernameRegistration(data);
|
73
|
+
}
|
74
|
+
if (functionName == AbiFunction.USERNAME_RESIGNATION) {
|
75
|
+
return new UsernameResignation(data);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
return new EvmCall(data);
|
79
|
+
}
|
80
|
+
static decodePayload(data, abiType = ContractAbiType.CONSENSUS) {
|
81
|
+
const payload = data.data;
|
82
|
+
if (!payload) {
|
83
|
+
return null;
|
84
|
+
}
|
85
|
+
const decoder = new AbiDecoder(abiType);
|
86
|
+
try {
|
87
|
+
return decoder.decodeFunctionData(payload);
|
88
|
+
}
|
89
|
+
catch (e) {
|
90
|
+
//
|
91
|
+
}
|
92
|
+
return null;
|
93
|
+
}
|
94
|
+
static parseNumber(value) {
|
95
|
+
return value === "0x" ? 0 : Number(value);
|
96
|
+
}
|
97
|
+
static parseBigNumber(value) {
|
98
|
+
return (value === "0x" ? new BigNumber(0) : new BigNumber(value)).toString(10);
|
99
|
+
}
|
100
|
+
static parseAddress(value) {
|
101
|
+
return value === "0x" ? undefined : value;
|
102
|
+
}
|
103
|
+
static parseHex(value) {
|
104
|
+
return value.replace(/^0x/, "");
|
105
|
+
}
|
106
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { ITransaction } from "../types";
|
2
|
+
export declare class Serializer {
|
3
|
+
transaction: ITransaction;
|
4
|
+
constructor(transaction: ITransaction);
|
5
|
+
static new(transaction: ITransaction): Serializer;
|
6
|
+
static getBytes(transaction: ITransaction, skipSignature?: boolean): Buffer;
|
7
|
+
serialize(skipSignature?: boolean): Buffer;
|
8
|
+
}
|
9
|
+
//# sourceMappingURL=Serializer.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Serializer.d.ts","sourceRoot":"","sources":["../../src/transactions/Serializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,qBAAa,UAAU;IACf,WAAW,EAAE,YAAY,CAAC;gBAErB,WAAW,EAAE,YAAY;IAIrC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,YAAY,GAAG,UAAU;IAIjD,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,GAAE,OAAe,GAAG,MAAM;IAIlF,SAAS,CAAC,aAAa,GAAE,OAAe,GAAG,MAAM;CAKjD"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { TransactionUtils } from "../utils/TransactionUtils";
|
2
|
+
export class Serializer {
|
3
|
+
constructor(transaction) {
|
4
|
+
this.transaction = transaction;
|
5
|
+
}
|
6
|
+
static new(transaction) {
|
7
|
+
return new this(transaction);
|
8
|
+
}
|
9
|
+
static getBytes(transaction, skipSignature = false) {
|
10
|
+
return transaction.serialize(skipSignature);
|
11
|
+
}
|
12
|
+
serialize(skipSignature = false) {
|
13
|
+
this.transaction.serialized = TransactionUtils.toBuffer(this.transaction.data, skipSignature);
|
14
|
+
return this.transaction.serialized;
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { ITransaction, ITransactionBuilder, TransactionData } from "../../types";
|
2
|
+
export declare abstract class AbstractTransactionBuilder<T extends ITransactionBuilder<T>> implements ITransactionBuilder<T> {
|
3
|
+
transaction: ITransaction;
|
4
|
+
constructor(data?: Record<string, any>);
|
5
|
+
gasLimit(gasLimit: string): T;
|
6
|
+
recipientAddress(recipientAddress: string): T;
|
7
|
+
gasPrice(gasPrice: string): T;
|
8
|
+
nonce(nonce: string): T;
|
9
|
+
network(network: number): T;
|
10
|
+
sign(passphrase: string): T;
|
11
|
+
verify(): boolean;
|
12
|
+
toArray(): TransactionData;
|
13
|
+
toJson(): string;
|
14
|
+
toString(): string;
|
15
|
+
protected abstract getTransactionInstance(data?: Record<string, any>): ITransaction;
|
16
|
+
}
|
17
|
+
//# sourceMappingURL=AbstractTransactionBuilder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AbstractTransactionBuilder.d.ts","sourceRoot":"","sources":["../../../src/transactions/builders/AbstractTransactionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAMjF,8BAAsB,0BAA0B,CAAC,CAAC,SAAS,mBAAmB,CAAC,CAAC,CAAC,CAAE,YAAW,mBAAmB,CAAC,CAAC,CAAC;IAC5G,WAAW,EAAE,YAAY,CAAC;gBAErB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAc/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC;IAM7B,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,GAAG,CAAC;IAM7C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC;IAM7B,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC;IAMvB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC;IAM3B,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC;IAU3B,MAAM,IAAI,OAAO;IAIjB,OAAO,IAAI,eAAe;IAI1B,MAAM,IAAI,MAAM;IAIhB,QAAQ,IAAI,MAAM;IAIzB,SAAS,CAAC,QAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY;CACnF"}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import { Network } from "../../configuration/Network";
|
2
|
+
import { PrivateKey } from "../../identities/PrivateKey";
|
3
|
+
import { PublicKey } from "../../identities/PublicKey";
|
4
|
+
export class AbstractTransactionBuilder {
|
5
|
+
constructor(data) {
|
6
|
+
this.transaction = this.getTransactionInstance(data !== null && data !== void 0 ? data : {
|
7
|
+
value: "0",
|
8
|
+
senderPublicKey: "",
|
9
|
+
gasPrice: "5",
|
10
|
+
nonce: "1",
|
11
|
+
network: Network.get().chainId(),
|
12
|
+
gasLimit: 1000000,
|
13
|
+
data: "",
|
14
|
+
});
|
15
|
+
}
|
16
|
+
gasLimit(gasLimit) {
|
17
|
+
this.transaction.data.gasLimit = gasLimit;
|
18
|
+
return this;
|
19
|
+
}
|
20
|
+
recipientAddress(recipientAddress) {
|
21
|
+
this.transaction.data.recipientAddress = recipientAddress;
|
22
|
+
return this;
|
23
|
+
}
|
24
|
+
gasPrice(gasPrice) {
|
25
|
+
this.transaction.data.gasPrice = gasPrice;
|
26
|
+
return this;
|
27
|
+
}
|
28
|
+
nonce(nonce) {
|
29
|
+
this.transaction.data.nonce = nonce;
|
30
|
+
return this;
|
31
|
+
}
|
32
|
+
network(network) {
|
33
|
+
this.transaction.data.network = network;
|
34
|
+
return this;
|
35
|
+
}
|
36
|
+
sign(passphrase) {
|
37
|
+
this.transaction.data.senderPublicKey = PublicKey.fromPassphrase(passphrase).publicKey;
|
38
|
+
this.transaction = this.transaction.sign(PrivateKey.fromPassphrase(passphrase));
|
39
|
+
this.transaction.data.id = this.transaction.getId();
|
40
|
+
return this;
|
41
|
+
}
|
42
|
+
verify() {
|
43
|
+
return this.transaction.verify();
|
44
|
+
}
|
45
|
+
toArray() {
|
46
|
+
return this.transaction.toArray();
|
47
|
+
}
|
48
|
+
toJson() {
|
49
|
+
return this.transaction.toJson();
|
50
|
+
}
|
51
|
+
toString() {
|
52
|
+
return this.toJson();
|
53
|
+
}
|
54
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { IEvmCallBuilder, ITransaction } from "../../types";
|
2
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
3
|
+
export declare class EvmCallBuilder extends AbstractTransactionBuilder<IEvmCallBuilder> implements IEvmCallBuilder {
|
4
|
+
constructor(data?: Record<string, any>);
|
5
|
+
static new(data?: Record<string, any>): IEvmCallBuilder;
|
6
|
+
payload(payload: string): IEvmCallBuilder;
|
7
|
+
protected getTransactionInstance(data?: Record<string, any>): ITransaction;
|
8
|
+
}
|
9
|
+
//# sourceMappingURL=EvmCallBuilder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"EvmCallBuilder.d.ts","sourceRoot":"","sources":["../../../src/transactions/builders/EvmCallBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAmB,MAAM,aAAa,CAAC;AAE7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAI1E,qBAAa,cAAe,SAAQ,0BAA0B,CAAC,eAAe,CAAE,YAAW,eAAe;gBACtF,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;WAI/B,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,eAAe;IAIvD,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe;IAKhD,SAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY;CAG1E"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
2
|
+
import { EvmCall } from "../types/EvmCall";
|
3
|
+
import { Helpers } from "../../utils/Helpers";
|
4
|
+
export class EvmCallBuilder extends AbstractTransactionBuilder {
|
5
|
+
constructor(data) {
|
6
|
+
super(data);
|
7
|
+
}
|
8
|
+
static new(data) {
|
9
|
+
return new this(data);
|
10
|
+
}
|
11
|
+
payload(payload) {
|
12
|
+
this.transaction.data["data"] = Helpers.removeLeadingHexZero(payload);
|
13
|
+
return this;
|
14
|
+
}
|
15
|
+
getTransactionInstance(data) {
|
16
|
+
return new EvmCall(data);
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { IMultipaymentBuilder, ITransaction } from "../../types";
|
2
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
3
|
+
export declare class MultipaymentBuilder extends AbstractTransactionBuilder<IMultipaymentBuilder> implements IMultipaymentBuilder {
|
4
|
+
constructor(data?: Record<string, any>);
|
5
|
+
static new(data?: Record<string, any>): IMultipaymentBuilder;
|
6
|
+
pay(address: string, amount: string): IMultipaymentBuilder;
|
7
|
+
protected getTransactionInstance(data?: Record<string, any>): ITransaction;
|
8
|
+
}
|
9
|
+
//# sourceMappingURL=MultipaymentBuilder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MultipaymentBuilder.d.ts","sourceRoot":"","sources":["../../../src/transactions/builders/MultipaymentBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAmB,MAAM,aAAa,CAAC;AAElF,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAI1E,qBAAa,mBACZ,SAAQ,0BAA0B,CAAC,oBAAoB,CACvD,YAAW,oBAAoB;gBAEZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;WAM/B,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,oBAAoB;IAI5D,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,oBAAoB;IAajE,SAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY;CAG1E"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
2
|
+
import { ContractAddresses } from "../../enums/ContractAddresses";
|
3
|
+
import { Multipayment } from "../types/Multipayment";
|
4
|
+
export class MultipaymentBuilder extends AbstractTransactionBuilder {
|
5
|
+
constructor(data) {
|
6
|
+
super(data);
|
7
|
+
this.recipientAddress(ContractAddresses.MULTIPAYMENT);
|
8
|
+
}
|
9
|
+
static new(data) {
|
10
|
+
return new this(data);
|
11
|
+
}
|
12
|
+
pay(address, amount) {
|
13
|
+
var _a;
|
14
|
+
let payload = this.transaction.data["pay"];
|
15
|
+
payload[0].push(address);
|
16
|
+
payload[1].push(amount);
|
17
|
+
this.transaction.data.pay = payload;
|
18
|
+
this.transaction.data.value = (BigInt((_a = this.transaction.data.value) !== null && _a !== void 0 ? _a : 0) + BigInt(amount)).toString();
|
19
|
+
this.transaction.refreshPayloadData();
|
20
|
+
return this;
|
21
|
+
}
|
22
|
+
getTransactionInstance(data) {
|
23
|
+
return new Multipayment(data);
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { ITransaction, ITransferBuilder } from "../../types";
|
2
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
3
|
+
export declare class TransferBuilder extends AbstractTransactionBuilder<ITransferBuilder> implements ITransferBuilder {
|
4
|
+
static new(data?: Record<string, any>): ITransferBuilder;
|
5
|
+
value(value: string): ITransferBuilder;
|
6
|
+
protected getTransactionInstance(data?: Record<string, any>): ITransaction;
|
7
|
+
}
|
8
|
+
//# sourceMappingURL=TransferBuilder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"TransferBuilder.d.ts","sourceRoot":"","sources":["../../../src/transactions/builders/TransferBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAE9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAG1E,qBAAa,eAAgB,SAAQ,0BAA0B,CAAC,gBAAgB,CAAE,YAAW,gBAAgB;WAC9F,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,gBAAgB;IAIxD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB;IAQ7C,SAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY;CAG1E"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
2
|
+
import { Transfer } from "../types/Transfer";
|
3
|
+
export class TransferBuilder extends AbstractTransactionBuilder {
|
4
|
+
static new(data) {
|
5
|
+
return new this(data);
|
6
|
+
}
|
7
|
+
value(value) {
|
8
|
+
this.transaction.data.value = value;
|
9
|
+
this.transaction.refreshPayloadData();
|
10
|
+
return this;
|
11
|
+
}
|
12
|
+
getTransactionInstance(data) {
|
13
|
+
return new Transfer(data);
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { IBasicTransactionBuilder, ITransaction } from "../../types";
|
2
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
3
|
+
export declare class UnvoteBuilder extends AbstractTransactionBuilder<IBasicTransactionBuilder> {
|
4
|
+
constructor(data?: Record<string, any>);
|
5
|
+
static new(data?: Record<string, any>): IBasicTransactionBuilder;
|
6
|
+
protected getTransactionInstance(data?: Record<string, any>): ITransaction;
|
7
|
+
}
|
8
|
+
//# sourceMappingURL=UnvoteBuilder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"UnvoteBuilder.d.ts","sourceRoot":"","sources":["../../../src/transactions/builders/UnvoteBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAmB,MAAM,aAAa,CAAC;AAEtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAI1E,qBAAa,aAAc,SAAQ,0BAA0B,CAAC,wBAAwB,CAAC;gBACnE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;WAM/B,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,wBAAwB;IAIvE,SAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY;CAG1E"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
2
|
+
import { ContractAddresses } from "../../enums/ContractAddresses";
|
3
|
+
import { Unvote } from "../types/Unvote";
|
4
|
+
export class UnvoteBuilder extends AbstractTransactionBuilder {
|
5
|
+
constructor(data) {
|
6
|
+
super(data);
|
7
|
+
this.recipientAddress(ContractAddresses.CONSENSUS);
|
8
|
+
}
|
9
|
+
static new(data) {
|
10
|
+
return new this(data);
|
11
|
+
}
|
12
|
+
getTransactionInstance(data) {
|
13
|
+
return new Unvote(data);
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { ITransaction, IUsernameRegistrationBuilder } from "../../types";
|
2
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
3
|
+
export declare class UsernameRegistrationBuilder extends AbstractTransactionBuilder<IUsernameRegistrationBuilder> implements IUsernameRegistrationBuilder {
|
4
|
+
constructor(data?: Record<string, any>);
|
5
|
+
static new(data?: Record<string, any>): IUsernameRegistrationBuilder;
|
6
|
+
username(username: string): IUsernameRegistrationBuilder;
|
7
|
+
protected getTransactionInstance(data?: Record<string, any>): ITransaction;
|
8
|
+
}
|
9
|
+
//# sourceMappingURL=UsernameRegistrationBuilder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"UsernameRegistrationBuilder.d.ts","sourceRoot":"","sources":["../../../src/transactions/builders/UsernameRegistrationBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,4BAA4B,EAAmB,MAAM,aAAa,CAAC;AAE1F,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAK1E,qBAAa,2BACZ,SAAQ,0BAA0B,CAAC,4BAA4B,CAC/D,YAAW,4BAA4B;gBAEpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;WAM/B,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,4BAA4B;IAIpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,4BAA4B;IAU/D,SAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY;CAG1E"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
2
|
+
import { ContractAddresses } from "../../enums/ContractAddresses";
|
3
|
+
import { Helpers } from "../../utils/Helpers";
|
4
|
+
import { UsernameRegistration } from "../types/UsernameRegistration";
|
5
|
+
export class UsernameRegistrationBuilder extends AbstractTransactionBuilder {
|
6
|
+
constructor(data) {
|
7
|
+
super(data);
|
8
|
+
this.recipientAddress(ContractAddresses.USERNAMES);
|
9
|
+
}
|
10
|
+
static new(data) {
|
11
|
+
return new this(data);
|
12
|
+
}
|
13
|
+
username(username) {
|
14
|
+
Helpers.isValidUsername(username);
|
15
|
+
this.transaction.data.username = username;
|
16
|
+
this.transaction.refreshPayloadData();
|
17
|
+
return this;
|
18
|
+
}
|
19
|
+
getTransactionInstance(data) {
|
20
|
+
return new UsernameRegistration(data);
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { IBasicTransactionBuilder, ITransaction } from "../../types";
|
2
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
3
|
+
export declare class UsernameResignationBuilder extends AbstractTransactionBuilder<IBasicTransactionBuilder> {
|
4
|
+
constructor(data?: Record<string, any>);
|
5
|
+
static new(data?: Record<string, any>): IBasicTransactionBuilder;
|
6
|
+
protected getTransactionInstance(data?: Record<string, any>): ITransaction;
|
7
|
+
}
|
8
|
+
//# sourceMappingURL=UsernameResignationBuilder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"UsernameResignationBuilder.d.ts","sourceRoot":"","sources":["../../../src/transactions/builders/UsernameResignationBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAmB,MAAM,aAAa,CAAC;AAEtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAI1E,qBAAa,0BAA2B,SAAQ,0BAA0B,CAAC,wBAAwB,CAAC;gBAChF,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;WAM/B,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,wBAAwB;IAIvE,SAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY;CAG1E"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
2
|
+
import { ContractAddresses } from "../../enums/ContractAddresses";
|
3
|
+
import { UsernameResignation } from "../types/UsernameResignation";
|
4
|
+
export class UsernameResignationBuilder extends AbstractTransactionBuilder {
|
5
|
+
constructor(data) {
|
6
|
+
super(data);
|
7
|
+
this.recipientAddress(ContractAddresses.USERNAMES);
|
8
|
+
}
|
9
|
+
static new(data) {
|
10
|
+
return new this(data);
|
11
|
+
}
|
12
|
+
getTransactionInstance(data) {
|
13
|
+
return new UsernameResignation(data);
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { ITransaction, IValidatorRegistrationBuilder } from "../../types";
|
2
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
3
|
+
export declare class ValidatorRegistrationBuilder extends AbstractTransactionBuilder<IValidatorRegistrationBuilder> implements IValidatorRegistrationBuilder {
|
4
|
+
constructor(data?: Record<string, any>);
|
5
|
+
static new(data?: Record<string, any>): IValidatorRegistrationBuilder;
|
6
|
+
validatorPublicKey(validatorPublicKey: string): IValidatorRegistrationBuilder;
|
7
|
+
protected getTransactionInstance(data?: Record<string, any>): ITransaction;
|
8
|
+
}
|
9
|
+
//# sourceMappingURL=ValidatorRegistrationBuilder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ValidatorRegistrationBuilder.d.ts","sourceRoot":"","sources":["../../../src/transactions/builders/ValidatorRegistrationBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,6BAA6B,EAAmB,MAAM,aAAa,CAAC;AAE3F,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAI1E,qBAAa,4BACZ,SAAQ,0BAA0B,CAAC,6BAA6B,CAChE,YAAW,6BAA6B;gBAErB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;WAM/B,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,6BAA6B;IAIrE,kBAAkB,CAAC,kBAAkB,EAAE,MAAM,GAAG,6BAA6B;IAQpF,SAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY;CAG1E"}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
2
|
+
import { ContractAddresses } from "../../enums/ContractAddresses";
|
3
|
+
import { ValidatorRegistration } from "../types/ValidatorRegistration";
|
4
|
+
export class ValidatorRegistrationBuilder extends AbstractTransactionBuilder {
|
5
|
+
constructor(data) {
|
6
|
+
super(data);
|
7
|
+
this.recipientAddress(ContractAddresses.CONSENSUS);
|
8
|
+
}
|
9
|
+
static new(data) {
|
10
|
+
return new this(data);
|
11
|
+
}
|
12
|
+
validatorPublicKey(validatorPublicKey) {
|
13
|
+
this.transaction.data.validatorPublicKey = validatorPublicKey;
|
14
|
+
this.transaction.refreshPayloadData();
|
15
|
+
return this;
|
16
|
+
}
|
17
|
+
getTransactionInstance(data) {
|
18
|
+
return new ValidatorRegistration(data);
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { IBasicTransactionBuilder, ITransaction } from "../../types";
|
2
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
3
|
+
export declare class ValidatorResignationBuilder extends AbstractTransactionBuilder<IBasicTransactionBuilder> {
|
4
|
+
constructor(data?: Record<string, any>);
|
5
|
+
static new(data?: Record<string, any>): IBasicTransactionBuilder;
|
6
|
+
protected getTransactionInstance(data?: Record<string, any>): ITransaction;
|
7
|
+
}
|
8
|
+
//# sourceMappingURL=ValidatorResignationBuilder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ValidatorResignationBuilder.d.ts","sourceRoot":"","sources":["../../../src/transactions/builders/ValidatorResignationBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAmB,MAAM,aAAa,CAAC;AAEtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAI1E,qBAAa,2BAA4B,SAAQ,0BAA0B,CAAC,wBAAwB,CAAC;gBACjF,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;WAM/B,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,wBAAwB;IAIvE,SAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY;CAG1E"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
2
|
+
import { ContractAddresses } from "../../enums/ContractAddresses";
|
3
|
+
import { ValidatorResignation } from "../types/ValidatorResignation";
|
4
|
+
export class ValidatorResignationBuilder extends AbstractTransactionBuilder {
|
5
|
+
constructor(data) {
|
6
|
+
super(data);
|
7
|
+
this.recipientAddress(ContractAddresses.CONSENSUS);
|
8
|
+
}
|
9
|
+
static new(data) {
|
10
|
+
return new this(data);
|
11
|
+
}
|
12
|
+
getTransactionInstance(data) {
|
13
|
+
return new ValidatorResignation(data);
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { ITransaction, IVoteBuilder } from "../../types";
|
2
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
3
|
+
export declare class VoteBuilder extends AbstractTransactionBuilder<IVoteBuilder> implements IVoteBuilder {
|
4
|
+
constructor(data?: Record<string, any>);
|
5
|
+
static new(data?: Record<string, any>): IVoteBuilder;
|
6
|
+
vote(vote: string): IVoteBuilder;
|
7
|
+
protected getTransactionInstance(data?: Record<string, any>): ITransaction;
|
8
|
+
}
|
9
|
+
//# sourceMappingURL=VoteBuilder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"VoteBuilder.d.ts","sourceRoot":"","sources":["../../../src/transactions/builders/VoteBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAmB,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAI1E,qBAAa,WAAY,SAAQ,0BAA0B,CAAC,YAAY,CAAE,YAAW,YAAY;gBAC7E,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;WAM/B,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY;IAIpD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAQvC,SAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY;CAG1E"}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { AbstractTransactionBuilder } from "./AbstractTransactionBuilder";
|
2
|
+
import { ContractAddresses } from "../../enums/ContractAddresses";
|
3
|
+
import { Vote } from "../types/Vote";
|
4
|
+
export class VoteBuilder extends AbstractTransactionBuilder {
|
5
|
+
constructor(data) {
|
6
|
+
super(data);
|
7
|
+
this.recipientAddress(ContractAddresses.CONSENSUS);
|
8
|
+
}
|
9
|
+
static new(data) {
|
10
|
+
return new this(data);
|
11
|
+
}
|
12
|
+
vote(vote) {
|
13
|
+
this.transaction.data.vote = vote;
|
14
|
+
this.transaction.refreshPayloadData();
|
15
|
+
return this;
|
16
|
+
}
|
17
|
+
getTransactionInstance(data) {
|
18
|
+
return new Vote(data);
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export * from "./AbstractTransactionBuilder";
|
2
|
+
export * from "./EvmCallBuilder";
|
3
|
+
export * from "./MultipaymentBuilder";
|
4
|
+
export * from "./TransferBuilder";
|
5
|
+
export * from "./UnvoteBuilder";
|
6
|
+
export * from "./ValidatorRegistrationBuilder";
|
7
|
+
export * from "./ValidatorResignationBuilder";
|
8
|
+
export * from "./UsernameRegistrationBuilder";
|
9
|
+
export * from "./UsernameResignationBuilder";
|
10
|
+
export * from "./VoteBuilder";
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transactions/builders/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,eAAe,CAAC"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export * from "./AbstractTransactionBuilder";
|
2
|
+
export * from "./EvmCallBuilder";
|
3
|
+
export * from "./MultipaymentBuilder";
|
4
|
+
export * from "./TransferBuilder";
|
5
|
+
export * from "./UnvoteBuilder";
|
6
|
+
export * from "./ValidatorRegistrationBuilder";
|
7
|
+
export * from "./ValidatorResignationBuilder";
|
8
|
+
export * from "./UsernameRegistrationBuilder";
|
9
|
+
export * from "./UsernameResignationBuilder";
|
10
|
+
export * from "./VoteBuilder";
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { AbiResult, ITransaction, TransactionData } from "../../types";
|
2
|
+
import { ContractAbiType } from "../../enums/ContractAbiType";
|
3
|
+
import { PrivateKey } from "../../identities/PrivateKey";
|
4
|
+
import { PublicKey } from "../../identities/PublicKey";
|
5
|
+
export declare abstract class AbstractTransaction implements ITransaction {
|
6
|
+
data: TransactionData;
|
7
|
+
serialized: Buffer | undefined;
|
8
|
+
constructor(data: TransactionData);
|
9
|
+
abstract getPayload(): string;
|
10
|
+
refreshPayloadData(): this;
|
11
|
+
getId(): string;
|
12
|
+
sign(privateKey: PrivateKey): ITransaction;
|
13
|
+
recoverSender(): void;
|
14
|
+
verify(): boolean;
|
15
|
+
toArray(): TransactionData;
|
16
|
+
toJson(): string;
|
17
|
+
hash(skipSignature?: boolean): string;
|
18
|
+
serialize(skipSignature?: boolean): Buffer;
|
19
|
+
protected recoverPublicKey(): PublicKey;
|
20
|
+
protected decodePayload(data: TransactionData, type?: ContractAbiType): AbiResult | null;
|
21
|
+
}
|
22
|
+
//# sourceMappingURL=AbstractTransaction.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AbstractTransaction.d.ts","sourceRoot":"","sources":["../../../src/transactions/types/AbstractTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAIvE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAIvD,8BAAsB,mBAAoB,YAAW,YAAY;IACzD,IAAI,EAAE,eAAe,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEnB,IAAI,EAAE,eAAe;aAMxB,UAAU,IAAI,MAAM;IAE7B,kBAAkB,IAAI,IAAI;IAM1B,KAAK,IAAI,MAAM;IAIf,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,YAAY;IAY1C,aAAa,IAAI,IAAI;IAOrB,MAAM,IAAI,OAAO;IAWjB,OAAO,IAAI,eAAe;IAuB1B,MAAM,IAAI,MAAM;IAIhB,IAAI,CAAC,aAAa,GAAE,OAAe,GAAG,MAAM;IAI5C,SAAS,CAAC,aAAa,GAAE,OAAe,GAAG,MAAM;IAIxD,SAAS,CAAC,gBAAgB,IAAI,SAAS;IAYvC,SAAS,CAAC,aAAa,CACtB,IAAI,EAAE,eAAe,EACrB,IAAI,GAAE,eAA2C,GAC/C,SAAS,GAAG,IAAI;CAGnB"}
|