@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
package/.editorconfig
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# EditorConfig is awesome: https://EditorConfig.org
|
2
|
+
|
3
|
+
# top-most EditorConfig file
|
4
|
+
root = true
|
5
|
+
|
6
|
+
[*]
|
7
|
+
indent_style = tab
|
8
|
+
indent_size = 4
|
9
|
+
end_of_line = lf
|
10
|
+
charset = utf-8
|
11
|
+
trim_trailing_whitespace = true
|
12
|
+
insert_final_newline = true
|
13
|
+
|
14
|
+
[*.yml]
|
15
|
+
indent_style = space
|
16
|
+
indent_size = 2
|
package/.eslintrc.js
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<!--
|
2
|
+
Thanks for your interest in the project. Bugs filed and PRs submitted are appreciated!
|
3
|
+
|
4
|
+
Please make sure you're familiar with and follow the instructions in the [contributing guidelines](https://ark.dev/docs/program-incentives/guidelines/contributing).
|
5
|
+
|
6
|
+
Please fill out the information below to expedite the review and (hopefully) merge of your pull request!
|
7
|
+
-->
|
8
|
+
|
9
|
+
## Summary
|
10
|
+
|
11
|
+
<!-- What changes are being made? -->
|
12
|
+
|
13
|
+
<!-- Why are these changes necessary? -->
|
14
|
+
|
15
|
+
<!-- How were these changes implemented? -->
|
16
|
+
|
17
|
+
## Checklist
|
18
|
+
|
19
|
+
<!-- Have you done all of these things? -->
|
20
|
+
|
21
|
+
- [ ] Documentation _(if necessary)_
|
22
|
+
- [ ] Tests _(if necessary)_
|
23
|
+
|
24
|
+
<!-- Feel free to add additional comments. -->
|
@@ -0,0 +1,36 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: push
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
strategy:
|
10
|
+
matrix:
|
11
|
+
node-version: [20.12.2]
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v4
|
15
|
+
with:
|
16
|
+
ref: ${{ github.head_ref }}
|
17
|
+
token: ${{ secrets.GH_TOKEN }}
|
18
|
+
|
19
|
+
- uses: pnpm/action-setup@v4
|
20
|
+
with:
|
21
|
+
version: 9
|
22
|
+
|
23
|
+
- uses: actions/setup-node@v4
|
24
|
+
with:
|
25
|
+
node-version: ${{ matrix.node-version }}
|
26
|
+
cache: pnpm
|
27
|
+
|
28
|
+
- name: Update System
|
29
|
+
run: sudo apt-get update
|
30
|
+
|
31
|
+
- name: Install
|
32
|
+
run: pnpm install
|
33
|
+
|
34
|
+
- run: pnpm run build
|
35
|
+
|
36
|
+
- run: pnpm test
|
@@ -0,0 +1,56 @@
|
|
1
|
+
name: Publish Package
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
|
6
|
+
push:
|
7
|
+
branches:
|
8
|
+
- main
|
9
|
+
- develop
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
publish:
|
13
|
+
# Only run if commit message starts with 'release:'
|
14
|
+
if: startsWith(github.event.head_commit.message, 'release:') || github.event_name == 'workflow_dispatch'
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
|
17
|
+
strategy:
|
18
|
+
matrix:
|
19
|
+
node-version: [20.x]
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v4
|
23
|
+
|
24
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
25
|
+
uses: actions/setup-node@v4
|
26
|
+
with:
|
27
|
+
node-version: ${{ matrix.node-version }}
|
28
|
+
registry-url: "https://registry.npmjs.org/"
|
29
|
+
|
30
|
+
- name: Cache pnpm modules
|
31
|
+
uses: actions/cache@v4
|
32
|
+
env:
|
33
|
+
cache-name: cache-pnpm-modules
|
34
|
+
with:
|
35
|
+
path: ~/.pnpm-store
|
36
|
+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/package.json') }}
|
37
|
+
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-
|
38
|
+
|
39
|
+
- name: Install pnpm
|
40
|
+
uses: pnpm/action-setup@v4
|
41
|
+
with:
|
42
|
+
version: 9.x
|
43
|
+
|
44
|
+
- name: Install dependencies
|
45
|
+
run: pnpm install
|
46
|
+
|
47
|
+
- name: Build
|
48
|
+
run: pnpm run build
|
49
|
+
|
50
|
+
- name: Publish (develop branch)
|
51
|
+
if: github.ref == 'refs/heads/develop'
|
52
|
+
run: NPM_AUTH_TOKEN=${{ secrets.NODE_AUTH_TOKEN_ARK }} npm publish --access=public --publish-branch=develop --tag=next
|
53
|
+
|
54
|
+
- name: Publish (main branch)
|
55
|
+
if: github.ref == 'refs/heads/main'
|
56
|
+
run: NPM_AUTH_TOKEN=${{ secrets.NODE_AUTH_TOKEN_ARK }} npm publish --access=public
|
package/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# ARK TypeScript - Crypto
|
2
|
+
|
3
|
+
> A simple TypeScript Cryptography Implementation for the ARK Blockchain.
|
4
|
+
|
5
|
+
## Documentation
|
6
|
+
|
7
|
+
You can find installation instructions and detailed instructions on how to use this package at the dedicated documentation site.
|
8
|
+
|
9
|
+
## Development
|
10
|
+
|
11
|
+
[pnpm](https://pnpm.io/) is used in this repository as package manager, make sure you have it installed before working on this repository.
|
12
|
+
|
13
|
+
### Tests
|
14
|
+
|
15
|
+
You can run the tests with `pnpm test`. This will run the jest test suite with additional parameters to handle the crypto package.
|
16
|
+
|
17
|
+
### Releases
|
18
|
+
|
19
|
+
Releases are handled by a GitHub action that runs when it detects a commit prefixed with `release:`. Make sure to update the version of the package prior to opening a release PR by running `npm version <version> -m "release: %s"`, e.g. `npm version 1.0.0 -m "release: %s"`. This will update the `package.json` with the right version number.
|
20
|
+
|
21
|
+
## Security
|
22
|
+
|
23
|
+
If you discover a security vulnerability within this package, please send an e-mail to security@ardenthq.com. All security vulnerabilities will be promptly addressed.
|
24
|
+
|
25
|
+
## Credits
|
26
|
+
|
27
|
+
This project exists thanks to all the people who [contribute](../../contributors).
|
28
|
+
|
29
|
+
## License
|
30
|
+
|
31
|
+
[MIT](LICENSE) © [Ardent](https://ardenthq.com)
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Network.d.ts","sourceRoot":"","sources":["../../src/configuration/Network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,qBAAa,OAAO;IACnB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAkB;WAE1B,GAAG,IAAI,eAAe;WAQtB,GAAG,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;CAGjD"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./Network";
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export declare enum AbiFunction {
|
2
|
+
VOTE = "vote",
|
3
|
+
UNVOTE = "unvote",
|
4
|
+
VALIDATOR_REGISTRATION = "registerValidator",
|
5
|
+
VALIDATOR_RESIGNATION = "resignValidator",
|
6
|
+
USERNAME_REGISTRATION = "registerUsername",
|
7
|
+
USERNAME_RESIGNATION = "resignUsername",
|
8
|
+
MULTIPAYMENT = "pay"
|
9
|
+
}
|
10
|
+
//# sourceMappingURL=AbiFunction.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AbiFunction.d.ts","sourceRoot":"","sources":["../../src/enums/AbiFunction.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACtB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,sBAAsB,sBAAsB;IAC5C,qBAAqB,oBAAoB;IACzC,qBAAqB,qBAAqB;IAC1C,oBAAoB,mBAAmB;IACvC,YAAY,QAAQ;CACpB"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export var AbiFunction;
|
2
|
+
(function (AbiFunction) {
|
3
|
+
AbiFunction["VOTE"] = "vote";
|
4
|
+
AbiFunction["UNVOTE"] = "unvote";
|
5
|
+
AbiFunction["VALIDATOR_REGISTRATION"] = "registerValidator";
|
6
|
+
AbiFunction["VALIDATOR_RESIGNATION"] = "resignValidator";
|
7
|
+
AbiFunction["USERNAME_REGISTRATION"] = "registerUsername";
|
8
|
+
AbiFunction["USERNAME_RESIGNATION"] = "resignUsername";
|
9
|
+
AbiFunction["MULTIPAYMENT"] = "pay";
|
10
|
+
})(AbiFunction || (AbiFunction = {}));
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../../src/enums/Constants.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACpB,eAAe,OAAO;IACtB,2BAA2B,KAAK;CAChC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ContractAbiType.d.ts","sourceRoot":"","sources":["../../src/enums/ContractAbiType.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACvB,MAAM,WAAiB;IACvB,SAAS,cAAiB;IAC1B,YAAY,iBAAiB;IAC7B,SAAS,cAAiB;CAC7B"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export var ContractAbiType;
|
2
|
+
(function (ContractAbiType) {
|
3
|
+
ContractAbiType["CUSTOM"] = "custom";
|
4
|
+
ContractAbiType["CONSENSUS"] = "consensus";
|
5
|
+
ContractAbiType["MULTIPAYMENT"] = "multipayment";
|
6
|
+
ContractAbiType["USERNAMES"] = "usernames";
|
7
|
+
})(ContractAbiType || (ContractAbiType = {}));
|
@@ -0,0 +1,6 @@
|
|
1
|
+
export declare enum ContractAddresses {
|
2
|
+
CONSENSUS = "0x535B3D7A252fa034Ed71F0C53ec0C6F784cB64E1",
|
3
|
+
MULTIPAYMENT = "0x00EFd0D4639191C49908A7BddbB9A11A994A8527",
|
4
|
+
USERNAMES = "0x2c1DE3b4Dbb4aDebEbB5dcECAe825bE2a9fc6eb6"
|
5
|
+
}
|
6
|
+
//# sourceMappingURL=ContractAddresses.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ContractAddresses.d.ts","sourceRoot":"","sources":["../../src/enums/ContractAddresses.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC5B,SAAS,+CAA+C;IACxD,YAAY,+CAA+C;IAC3D,SAAS,+CAA+C;CACxD"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
export var ContractAddresses;
|
2
|
+
(function (ContractAddresses) {
|
3
|
+
ContractAddresses["CONSENSUS"] = "0x535B3D7A252fa034Ed71F0C53ec0C6F784cB64E1";
|
4
|
+
ContractAddresses["MULTIPAYMENT"] = "0x00EFd0D4639191C49908A7BddbB9A11A994A8527";
|
5
|
+
ContractAddresses["USERNAMES"] = "0x2c1DE3b4Dbb4aDebEbB5dcECAe825bE2a9fc6eb6";
|
6
|
+
})(ContractAddresses || (ContractAddresses = {}));
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/enums/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"InvalidUsernameException.d.ts","sourceRoot":"","sources":["../../src/exceptions/InvalidUsernameException.ts"],"names":[],"mappings":"AAAA,qBAAa,wBAAyB,SAAQ,KAAK;gBACtC,OAAO,EAAE,MAAM;CAI3B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./InvalidUsernameException";
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export declare class Address {
|
2
|
+
static fromPassphrase(passphrase: string): string;
|
3
|
+
static fromPublicKey(publicKey: string): string;
|
4
|
+
static fromPrivateKey(privateKey: string): string;
|
5
|
+
static validate(address: string): boolean;
|
6
|
+
}
|
7
|
+
//# sourceMappingURL=Address.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Address.d.ts","sourceRoot":"","sources":["../../src/identities/Address.ts"],"names":[],"mappings":"AAEA,qBAAa,OAAO;IACnB,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAIjD,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAI/C,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAIjD,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;CAGzC"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { ethers, sha256 } from "ethers";
|
2
|
+
export class Address {
|
3
|
+
static fromPassphrase(passphrase) {
|
4
|
+
return this.fromPrivateKey(sha256(Buffer.from(passphrase)));
|
5
|
+
}
|
6
|
+
static fromPublicKey(publicKey) {
|
7
|
+
return ethers.computeAddress(`0x${publicKey}`);
|
8
|
+
}
|
9
|
+
static fromPrivateKey(privateKey) {
|
10
|
+
return new ethers.Wallet(privateKey).address;
|
11
|
+
}
|
12
|
+
static validate(address) {
|
13
|
+
return ethers.isAddress(address);
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { ethers } from "ethers";
|
2
|
+
type RecoverableSignature = {
|
3
|
+
r: string;
|
4
|
+
s: string;
|
5
|
+
v: number;
|
6
|
+
};
|
7
|
+
export declare class PrivateKey {
|
8
|
+
privateKey: string;
|
9
|
+
constructor(keyPair: ethers.Wallet);
|
10
|
+
static fromPassphrase(passphrase: string): PrivateKey;
|
11
|
+
static fromHex(hex: string): PrivateKey;
|
12
|
+
static fromWif(wif: string): PrivateKey;
|
13
|
+
sign(message: string): RecoverableSignature;
|
14
|
+
}
|
15
|
+
export {};
|
16
|
+
//# sourceMappingURL=PrivateKey.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PrivateKey.d.ts","sourceRoot":"","sources":["../../src/identities/PrivateKey.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAqB,MAAM,QAAQ,CAAC;AAMnD,KAAK,oBAAoB,GAAG;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV,CAAC;AAEF,qBAAa,UAAU;IACf,UAAU,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,CAAC,MAAM;IAIlC,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU;IAIrD,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAMvC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAMvC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB;CAa3C"}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import * as WIF from "wif";
|
2
|
+
import { ethers, keccak256, sha256 } from "ethers";
|
3
|
+
import { signRecoverable } from "tiny-secp256k1";
|
4
|
+
import { Constants } from "../enums/Constants";
|
5
|
+
import { Network } from "../configuration/Network";
|
6
|
+
export class PrivateKey {
|
7
|
+
constructor(keyPair) {
|
8
|
+
this.privateKey = keyPair.privateKey.substring(2);
|
9
|
+
}
|
10
|
+
static fromPassphrase(passphrase) {
|
11
|
+
return PrivateKey.fromHex(sha256(Buffer.from(passphrase)));
|
12
|
+
}
|
13
|
+
static fromHex(hex) {
|
14
|
+
const wallet = new ethers.Wallet(hex);
|
15
|
+
return new PrivateKey(wallet);
|
16
|
+
}
|
17
|
+
static fromWif(wif) {
|
18
|
+
const decodedWif = WIF.decode(wif, Buffer.from(Network.get().getWif(), "hex").readUInt8());
|
19
|
+
return PrivateKey.fromHex(Buffer.from(decodedWif.privateKey).toString("hex"));
|
20
|
+
}
|
21
|
+
sign(message) {
|
22
|
+
const hash = Buffer.from(keccak256("0x" + message).slice(2), "hex");
|
23
|
+
const signature = signRecoverable(hash, Buffer.from(this.privateKey, "hex"));
|
24
|
+
const signatureHex = Buffer.from(signature.signature).toString("hex");
|
25
|
+
return {
|
26
|
+
r: signatureHex.slice(0, 64).toString(),
|
27
|
+
s: signatureHex.slice(64, 128).toString(),
|
28
|
+
v: signature.recoveryId + Constants.ETHEREUM_RECOVERY_ID_OFFSET,
|
29
|
+
};
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export declare class PublicKey {
|
2
|
+
publicKey: string;
|
3
|
+
constructor(publicKey: string);
|
4
|
+
static fromPassphrase(passphrase: string): PublicKey;
|
5
|
+
static fromHex(publicKey: string): PublicKey;
|
6
|
+
static recover(message: Buffer, signatureRS: Buffer, v: number): PublicKey;
|
7
|
+
}
|
8
|
+
//# sourceMappingURL=PublicKey.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PublicKey.d.ts","sourceRoot":"","sources":["../../src/identities/PublicKey.ts"],"names":[],"mappings":"AAGA,qBAAa,SAAS;IACd,SAAS,EAAE,MAAM,CAAC;gBAEb,SAAS,EAAE,MAAM;IAI7B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS;IAMpD,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAM5C,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS;CAY1E"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { sha256, SigningKey } from "ethers";
|
2
|
+
import { recover } from "tiny-secp256k1";
|
3
|
+
export class PublicKey {
|
4
|
+
constructor(publicKey) {
|
5
|
+
this.publicKey = publicKey;
|
6
|
+
}
|
7
|
+
static fromPassphrase(passphrase) {
|
8
|
+
const publicKey = SigningKey.computePublicKey(sha256(Buffer.from(passphrase)), true).substring(2);
|
9
|
+
return new PublicKey(publicKey);
|
10
|
+
}
|
11
|
+
static fromHex(publicKey) {
|
12
|
+
const computedPublicKey = SigningKey.computePublicKey(`0x${publicKey}`).substring(2);
|
13
|
+
return new PublicKey(computedPublicKey);
|
14
|
+
}
|
15
|
+
static recover(message, signatureRS, v) {
|
16
|
+
if (v < 0 || v > 3) {
|
17
|
+
throw new Error("Bad Recovery Id");
|
18
|
+
}
|
19
|
+
const recoveryId = v;
|
20
|
+
// Can't get the recover method to return null so we are enforcing the type here
|
21
|
+
const signature = recover(message, signatureRS, recoveryId, true);
|
22
|
+
return new PublicKey(Buffer.from(signature).toString("hex"));
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"WIF.d.ts","sourceRoot":"","sources":["../../src/identities/WIF.ts"],"names":[],"mappings":"AAKA,qBAAa,GAAG;IACf,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;CASjD"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { Network } from "../configuration/Network";
|
2
|
+
import * as WIFPackage from "wif";
|
3
|
+
import { PrivateKey } from "./PrivateKey";
|
4
|
+
export class WIF {
|
5
|
+
static fromPassphrase(passphrase) {
|
6
|
+
const privateKey = PrivateKey.fromPassphrase(passphrase);
|
7
|
+
return WIFPackage.encode({
|
8
|
+
version: Buffer.from(Network.get().getWif(), 'hex').readUInt8(),
|
9
|
+
privateKey: Buffer.from(privateKey.privateKey, 'hex'),
|
10
|
+
compressed: true,
|
11
|
+
});
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identities/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC"}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
for (let key of __getOwnPropNames(from))
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
11
|
+
}
|
12
|
+
return to;
|
13
|
+
};
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
16
|
+
var index_exports = {};
|
17
|
+
module.exports = __toCommonJS(index_exports);
|
18
|
+
__reExport(index_exports, require("./configuration"), module.exports);
|
19
|
+
__reExport(index_exports, require("./enums"), module.exports);
|
20
|
+
__reExport(index_exports, require("./exceptions"), module.exports);
|
21
|
+
__reExport(index_exports, require("./identities"), module.exports);
|
22
|
+
__reExport(index_exports, require("./networks"), module.exports);
|
23
|
+
__reExport(index_exports, require("./transactions"), module.exports);
|
24
|
+
__reExport(index_exports, require("./utils"), module.exports);
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AbstractNetwork.d.ts","sourceRoot":"","sources":["../../src/networks/AbstractNetwork.ts"],"names":[],"mappings":"AAAA,8BAAsB,eAAe;IACjC,QAAQ,CAAC,OAAO,IAAI,MAAM;IAE1B,QAAQ,CAAC,KAAK,IAAI,MAAM;IAExB,QAAQ,CAAC,MAAM,IAAI,MAAM;CAC5B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Mainnet.d.ts","sourceRoot":"","sources":["../../src/networks/Mainnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAAa,OAAQ,SAAQ,eAAe;IACpC,OAAO,IAAI,MAAM;IAIjB,KAAK,IAAI,MAAM;IAIf,MAAM,IAAI,MAAM;CAGvB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Testnet.d.ts","sourceRoot":"","sources":["../../src/networks/Testnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAAa,OAAQ,SAAQ,eAAe;IACpC,OAAO,IAAI,MAAM;IAIjB,KAAK,IAAI,MAAM;IAIf,MAAM,IAAI,MAAM;CAGvB"}
|