@tari-project/tarijs 0.3.1 → 0.4.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/.github/ISSUE_TEMPLATE/bug_report.md +36 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +27 -0
- package/.github/dependabot.yml +8 -0
- package/.github/workflows/ci.yml +25 -0
- package/.github/workflows/npm_publish.yml +26 -0
- package/.github/workflows/pr_signed_commits_check.yml +19 -0
- package/.github/workflows/pr_title.yml +30 -0
- package/.moon/toolchain.yml +6 -0
- package/.moon/workspace.yml +32 -0
- package/.prettierrc +12 -0
- package/.prototools +9 -0
- package/CODEOWNERS +3 -0
- package/README.md +9 -8
- package/TODO.md +12 -0
- package/package.json +6 -24
- package/packages/builders/moon.yml +55 -0
- package/packages/builders/package.json +30 -0
- package/packages/builders/src/helpers/submitTransaction.ts +97 -0
- package/{dist/builders/helpers/workspace.js → packages/builders/src/helpers/workspace.ts} +10 -7
- package/packages/builders/src/index.ts +9 -0
- package/packages/builders/src/transaction/TransactionBuilder.ts +276 -0
- package/packages/builders/src/transaction/TransactionRequest.ts +93 -0
- package/packages/builders/src/transaction/index.ts +2 -0
- package/packages/builders/tsconfig.json +24 -0
- package/packages/metamask_provider/moon.yml +55 -0
- package/packages/metamask_provider/package.json +30 -0
- package/packages/metamask_provider/src/index.ts +232 -0
- package/packages/metamask_provider/src/utils.ts +86 -0
- package/packages/metamask_provider/tsconfig.json +21 -0
- package/packages/tari_permissions/moon.yml +55 -0
- package/packages/tari_permissions/package.json +26 -0
- package/packages/tari_permissions/src/index.ts +1 -0
- package/packages/tari_permissions/src/tari_permissions.ts +312 -0
- package/packages/tari_permissions/tsconfig.json +15 -0
- package/packages/tari_provider/moon.yml +55 -0
- package/packages/tari_provider/package.json +27 -0
- package/packages/tari_provider/src/TariProvider.ts +35 -0
- package/packages/tari_provider/src/index.ts +3 -0
- package/packages/tari_provider/src/types.ts +82 -0
- package/packages/tari_provider/tsconfig.json +11 -0
- package/packages/tari_universe/moon.yml +55 -0
- package/packages/tari_universe/package.json +31 -0
- package/{dist/providers/tari_universe/index.d.ts → packages/tari_universe/src/index.ts} +1 -1
- package/packages/tari_universe/src/provider.ts +135 -0
- package/{dist/providers/tari_universe/types.d.ts → packages/tari_universe/src/types.ts} +20 -17
- package/packages/tari_universe/src/utils.ts +23 -0
- package/packages/tari_universe/tsconfig.json +24 -0
- package/packages/tarijs/integration-tests/.env +1 -0
- package/packages/tarijs/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +191 -0
- package/packages/tarijs/moon.yml +63 -0
- package/packages/tarijs/package.json +39 -0
- package/packages/tarijs/src/index.ts +69 -0
- package/packages/tarijs/src/network.ts +8 -0
- package/packages/tarijs/src/templates/Account.ts +98 -0
- package/packages/tarijs/src/templates/Pool.ts +42 -0
- package/packages/tarijs/src/templates/Tariswap.ts +101 -0
- package/packages/tarijs/src/templates/TemplateFactory.ts +22 -0
- package/packages/tarijs/src/templates/TestFaucet.ts +72 -0
- package/{dist/utils.js → packages/tarijs/src/utils.ts} +4 -3
- package/packages/tarijs/tsconfig.json +39 -0
- package/packages/tarijs/vitest.config.ts +9 -0
- package/packages/tarijs_types/moon.yml +55 -0
- package/packages/tarijs_types/package.json +27 -0
- package/packages/tarijs_types/src/Amount.ts +113 -0
- package/packages/tarijs_types/src/Arg.ts +3 -0
- package/packages/tarijs_types/src/ComponentAddress.ts +3 -0
- package/packages/tarijs_types/src/ConfidentialClaim.ts +9 -0
- package/packages/tarijs_types/src/ConfidentialOutput.ts +9 -0
- package/packages/tarijs_types/src/ConfidentialOutputStatement.ts +10 -0
- package/packages/tarijs_types/src/ConfidentialStatement.ts +9 -0
- package/packages/tarijs_types/src/ConfidentialWithdrawProof.ts +8 -0
- package/packages/tarijs_types/src/ElgamalVerifiableBalance.ts +4 -0
- package/packages/tarijs_types/src/Epoch.ts +3 -0
- package/packages/tarijs_types/src/FinalizeResult.ts +17 -0
- package/packages/tarijs_types/src/Instruction.ts +29 -0
- package/{dist/builders/types/ResourceAddress.js → packages/tarijs_types/src/ResourceAddress.ts} +2 -1
- package/{dist/builders/types/SubstateDiff.d.ts → packages/tarijs_types/src/SubstateDiff.ts} +4 -2
- package/{dist/builders/types/SubstateRequirement.d.ts → packages/tarijs_types/src/SubstateRequirement.ts} +3 -2
- package/{dist/builders/types/TemplateAddress.js → packages/tarijs_types/src/TemplateAddress.ts} +2 -1
- package/{dist/builders/types/Transaction.d.ts → packages/tarijs_types/src/Transaction.ts} +9 -8
- package/packages/tarijs_types/src/TransactionId.ts +4 -0
- package/packages/tarijs_types/src/TransactionResult.ts +26 -0
- package/packages/tarijs_types/src/TransactionSignature.ts +4 -0
- package/packages/tarijs_types/src/UnsignedTransaction.ts +15 -0
- package/{dist/builders/types/VersionedSubstateId.d.ts → packages/tarijs_types/src/VersionedSubstateId.ts} +3 -2
- package/packages/tarijs_types/src/ViewableBalanceProof.ts +12 -0
- package/{dist/builders/types/Workspace.d.ts → packages/tarijs_types/src/Workspace.ts} +1 -1
- package/{dist/builders/types/index.d.ts → packages/tarijs_types/src/index.ts} +4 -3
- package/packages/tarijs_types/tsconfig.json +15 -0
- package/packages/wallet_daemon/moon.yml +55 -0
- package/packages/wallet_daemon/package.json +29 -0
- package/{dist/providers/wallet_daemon/index.d.ts → packages/wallet_daemon/src/index.ts} +3 -1
- package/packages/wallet_daemon/src/provider.ts +263 -0
- package/packages/wallet_daemon/src/webrtc.ts +229 -0
- package/packages/wallet_daemon/src/webrtc_transport.ts +27 -0
- package/packages/wallet_daemon/tsconfig.json +21 -0
- package/packages/walletconnect/moon.yml +55 -0
- package/packages/walletconnect/package.json +32 -0
- package/packages/walletconnect/src/index.ts +274 -0
- package/packages/walletconnect/tsconfig.json +21 -0
- package/pnpm-workspace.yaml +14 -0
- package/tsconfig.json +42 -0
- package/dist/builders/helpers/index.js +0 -2
- package/dist/builders/helpers/submitTransaction.d.ts +0 -13
- package/dist/builders/helpers/submitTransaction.js +0 -62
- package/dist/builders/helpers/workspace.d.ts +0 -23
- package/dist/builders/index.d.ts +0 -3
- package/dist/builders/index.js +0 -3
- package/dist/builders/transaction/TransactionBuilder.d.ts +0 -44
- package/dist/builders/transaction/TransactionBuilder.js +0 -164
- package/dist/builders/transaction/TransactionRequest.d.ts +0 -27
- package/dist/builders/transaction/TransactionRequest.js +0 -67
- package/dist/builders/transaction/index.d.ts +0 -2
- package/dist/builders/transaction/index.js +0 -2
- package/dist/builders/types/Amount.d.ts +0 -23
- package/dist/builders/types/Amount.js +0 -93
- package/dist/builders/types/Arg.d.ts +0 -1
- package/dist/builders/types/Arg.js +0 -1
- package/dist/builders/types/Builder.d.ts +0 -47
- package/dist/builders/types/Builder.js +0 -1
- package/dist/builders/types/ComponentAddress.d.ts +0 -1
- package/dist/builders/types/ComponentAddress.js +0 -1
- package/dist/builders/types/ConfidentialClaim.d.ts +0 -8
- package/dist/builders/types/ConfidentialClaim.js +0 -1
- package/dist/builders/types/ConfidentialOutput.d.ts +0 -8
- package/dist/builders/types/ConfidentialOutput.js +0 -1
- package/dist/builders/types/ConfidentialOutputStatement.d.ts +0 -9
- package/dist/builders/types/ConfidentialOutputStatement.js +0 -1
- package/dist/builders/types/ConfidentialStatement.d.ts +0 -8
- package/dist/builders/types/ConfidentialStatement.js +0 -1
- package/dist/builders/types/ConfidentialWithdrawProof.d.ts +0 -7
- package/dist/builders/types/ConfidentialWithdrawProof.js +0 -1
- package/dist/builders/types/ElgamalVerifiableBalance.d.ts +0 -4
- package/dist/builders/types/ElgamalVerifiableBalance.js +0 -1
- package/dist/builders/types/Epoch.d.ts +0 -1
- package/dist/builders/types/Epoch.js +0 -1
- package/dist/builders/types/FinalizeResult.d.ts +0 -20
- package/dist/builders/types/FinalizeResult.js +0 -1
- package/dist/builders/types/Instruction.d.ts +0 -56
- package/dist/builders/types/Instruction.js +0 -1
- package/dist/builders/types/ResourceAddress.d.ts +0 -1
- package/dist/builders/types/SubstateDiff.js +0 -1
- package/dist/builders/types/SubstateRequirement.js +0 -1
- package/dist/builders/types/TemplateAddress.d.ts +0 -1
- package/dist/builders/types/Transaction.js +0 -1
- package/dist/builders/types/TransactionId.d.ts +0 -1
- package/dist/builders/types/TransactionId.js +0 -1
- package/dist/builders/types/TransactionResult.d.ts +0 -22
- package/dist/builders/types/TransactionResult.js +0 -10
- package/dist/builders/types/TransactionSignature.d.ts +0 -4
- package/dist/builders/types/TransactionSignature.js +0 -1
- package/dist/builders/types/UnsignedTransaction.d.ts +0 -12
- package/dist/builders/types/UnsignedTransaction.js +0 -1
- package/dist/builders/types/VersionedSubstateId.js +0 -1
- package/dist/builders/types/ViewableBalanceProof.d.ts +0 -10
- package/dist/builders/types/ViewableBalanceProof.js +0 -2
- package/dist/builders/types/Workspace.js +0 -1
- package/dist/builders/types/index.js +0 -2
- package/dist/index.d.ts +0 -13
- package/dist/index.js +0 -12
- package/dist/providers/index.d.ts +0 -16
- package/dist/providers/index.js +0 -1
- package/dist/providers/metamask/index.d.ts +0 -30
- package/dist/providers/metamask/index.js +0 -168
- package/dist/providers/metamask/utils.d.ts +0 -38
- package/dist/providers/metamask/utils.js +0 -55
- package/dist/providers/tari_universe/index.js +0 -3
- package/dist/providers/tari_universe/provider.d.ts +0 -23
- package/dist/providers/tari_universe/provider.js +0 -89
- package/dist/providers/tari_universe/types.js +0 -1
- package/dist/providers/tari_universe/utils.d.ts +0 -2
- package/dist/providers/tari_universe/utils.js +0 -16
- package/dist/providers/types.d.ts +0 -69
- package/dist/providers/types.js +0 -10
- package/dist/providers/wallet_daemon/index.js +0 -3
- package/dist/providers/wallet_daemon/provider.d.ts +0 -43
- package/dist/providers/wallet_daemon/provider.js +0 -198
- package/dist/providers/wallet_daemon/tari_permissions.d.ts +0 -216
- package/dist/providers/wallet_daemon/tari_permissions.js +0 -282
- package/dist/providers/wallet_daemon/webrtc.d.ts +0 -20
- package/dist/providers/wallet_daemon/webrtc.js +0 -201
- package/dist/providers/wallet_daemon/webrtc_transport.d.ts +0 -10
- package/dist/providers/wallet_daemon/webrtc_transport.js +0 -18
- package/dist/providers/walletconnect/index.d.ts +0 -23
- package/dist/providers/walletconnect/index.js +0 -221
- package/dist/templates/Account.d.ts +0 -65
- package/dist/templates/Account.js +0 -31
- package/dist/templates/Pool.d.ts +0 -30
- package/dist/templates/Pool.js +0 -20
- package/dist/templates/Tariswap.d.ts +0 -65
- package/dist/templates/Tariswap.js +0 -36
- package/dist/templates/TemplateFactory.d.ts +0 -9
- package/dist/templates/TemplateFactory.js +0 -18
- package/dist/templates/TestFaucet.d.ts +0 -49
- package/dist/templates/TestFaucet.js +0 -31
- package/dist/templates/index.js +0 -5
- package/dist/utils.d.ts +0 -2
- /package/{dist/builders/helpers/index.d.ts → packages/builders/src/helpers/index.ts} +0 -0
- /package/{dist/templates/index.d.ts → packages/tarijs/src/templates/index.ts} +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: "[TITLE]"
|
|
5
|
+
labels: 'bug-report'
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Steps to reproduce the behavior:
|
|
15
|
+
1. Go to '...'
|
|
16
|
+
2. Click on '....'
|
|
17
|
+
3. Scroll down to '....'
|
|
18
|
+
4. See error
|
|
19
|
+
|
|
20
|
+
**Expected behavior**
|
|
21
|
+
A clear and concise description of what you expected to happen.
|
|
22
|
+
|
|
23
|
+
**Screenshots**
|
|
24
|
+
If applicable, add screenshots to help explain your problem.
|
|
25
|
+
|
|
26
|
+
**Desktop (please complete the following information):**
|
|
27
|
+
- OS & Version: [e.g. iOS 10.2.1]
|
|
28
|
+
- Browser & Version [e.g. chrome v71.0.12345]
|
|
29
|
+
|
|
30
|
+
**Smartphone (please complete the following information):**
|
|
31
|
+
- Device: [e.g. iPhone6]
|
|
32
|
+
- OS: [e.g. iOS8.1]
|
|
33
|
+
- Browser & Version [e.g. stock browser v0.1.2]
|
|
34
|
+
|
|
35
|
+
**Additional context**
|
|
36
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Description
|
|
2
|
+
---
|
|
3
|
+
|
|
4
|
+
Motivation and Context
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
How Has This Been Tested?
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
What process can a PR reviewer use to test or verify this change?
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<!-- Checklist -->
|
|
14
|
+
<!-- 1. Is the title of your PR in the form that would make nice release notes? The title, excluding the conventional commit
|
|
15
|
+
tag, will be included exactly as is in the CHANGELOG, so please think about it carefully. -->
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Breaking Changes
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
- [x] None
|
|
22
|
+
- [ ] Requires data directory on base node to be deleted
|
|
23
|
+
- [ ] Requires hard fork
|
|
24
|
+
- [ ] Other - Please specify
|
|
25
|
+
|
|
26
|
+
<!-- Does this include a breaking change? If so, include this line as a footer -->
|
|
27
|
+
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a database, resync the chain -->
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: CI
|
|
3
|
+
|
|
4
|
+
'on':
|
|
5
|
+
pull_request:
|
|
6
|
+
types:
|
|
7
|
+
- opened
|
|
8
|
+
- reopened
|
|
9
|
+
- synchronize
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
# https://docs.github.com/en/actions/examples/using-concurrency-expressions-and-a-test-matrix
|
|
13
|
+
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
|
|
14
|
+
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/v') || github.ref != 'refs/heads/main' }}
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
build:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- uses: 'moonrepo/setup-toolchain@v0'
|
|
22
|
+
with:
|
|
23
|
+
auto-install: true
|
|
24
|
+
- run: pnpm install
|
|
25
|
+
- run: moon :build
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
# Publishing the package to the npm registry when the version number changes
|
|
3
|
+
# See https://github.com/marketplace/actions/npm-publish for more information
|
|
4
|
+
name: Publish Package to npmjs
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: main
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: 'moonrepo/setup-toolchain@v0'
|
|
16
|
+
with:
|
|
17
|
+
auto-install: true
|
|
18
|
+
- run: pnpm install --frozen-lockfile
|
|
19
|
+
- run: moon :build
|
|
20
|
+
- name: Publish
|
|
21
|
+
run: |
|
|
22
|
+
pnpm config set git-checks false
|
|
23
|
+
pnpm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
|
|
24
|
+
pnpm publish --access public --no-git-checks -r
|
|
25
|
+
env:
|
|
26
|
+
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
# Checks if the comments are signed or not
|
|
3
|
+
name: PR - Signed commits check
|
|
4
|
+
|
|
5
|
+
'on':
|
|
6
|
+
pull_request_target
|
|
7
|
+
|
|
8
|
+
permissions: {}
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
check-signed-commits:
|
|
12
|
+
name: Check signed commits in PR
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
pull-requests: write
|
|
17
|
+
steps:
|
|
18
|
+
- name: Check signed commits in PR
|
|
19
|
+
uses: 1Password/check-signed-commits-action@v1
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
# Checks that PR titles conform to Conventional Commits
|
|
3
|
+
# See https://www.conventionalcommits.org/en/v1.0.0/ for more information
|
|
4
|
+
name: PR
|
|
5
|
+
|
|
6
|
+
'on':
|
|
7
|
+
pull_request:
|
|
8
|
+
types:
|
|
9
|
+
- opened
|
|
10
|
+
- reopened
|
|
11
|
+
- edited
|
|
12
|
+
- synchronize
|
|
13
|
+
|
|
14
|
+
concurrency:
|
|
15
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
16
|
+
cancel-in-progress: true
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
check-title:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- name: install
|
|
23
|
+
run: |
|
|
24
|
+
npm install -g @commitlint/cli @commitlint/config-conventional
|
|
25
|
+
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js
|
|
26
|
+
- name: lint
|
|
27
|
+
run: |
|
|
28
|
+
echo "$PR_TITLE" | commitlint
|
|
29
|
+
env:
|
|
30
|
+
PR_TITLE: ${{github.event.pull_request.title}}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# https://moonrepo.dev/docs/config/workspace
|
|
2
|
+
$schema: 'https://moonrepo.dev/schemas/workspace.json'
|
|
3
|
+
|
|
4
|
+
# Require a specific version of moon while running commands, otherwise fail.
|
|
5
|
+
# versionConstraint: '>=1.0.0'
|
|
6
|
+
|
|
7
|
+
# Extend and inherit an external configuration file. Must be a valid HTTPS URL or file system path.
|
|
8
|
+
# extends: './shared/workspace.yml'
|
|
9
|
+
|
|
10
|
+
# REQUIRED: A map of all projects found within the workspace, or a list or file system globs.
|
|
11
|
+
# When using a map, each entry requires a unique project ID as the map key, and a file system
|
|
12
|
+
# path to the project folder as the map value. File paths are relative from the workspace root,
|
|
13
|
+
# and cannot reference projects located outside the workspace boundary.
|
|
14
|
+
projects:
|
|
15
|
+
- 'apps/*'
|
|
16
|
+
- 'packages/*'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Configures the version control system to utilize within the workspace. A VCS
|
|
21
|
+
# is required for determining touched (added, modified, etc) files, calculating file hashes,
|
|
22
|
+
# computing affected files, and much more.
|
|
23
|
+
vcs:
|
|
24
|
+
# The client to use when managing the repository.
|
|
25
|
+
# Accepts "git". Defaults to "git".
|
|
26
|
+
manager: 'git'
|
|
27
|
+
|
|
28
|
+
# The default branch (master/main/trunk) in the repository for comparing the
|
|
29
|
+
# local branch against. For git, this is is typically "master" or "main",
|
|
30
|
+
# and must include the remote prefix (before /).
|
|
31
|
+
defaultBranch: 'main'
|
|
32
|
+
|
package/.prettierrc
ADDED
package/.prototools
ADDED
package/CODEOWNERS
ADDED
package/README.md
CHANGED
|
@@ -15,9 +15,11 @@ Please read the [TODO](TODO.md) file for upcoming features.
|
|
|
15
15
|
You must have the [tari-dan](https://github.com/tari-project/tari-dan) repo cloned at the same folder level as this repo.
|
|
16
16
|
|
|
17
17
|
To build the library:
|
|
18
|
+
First you must install [proto](https://moonrepo.dev/proto) to manage node and pnpm versions
|
|
18
19
|
```shell
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
proto use
|
|
21
|
+
pnpm install
|
|
22
|
+
moon tarijs:build
|
|
21
23
|
```
|
|
22
24
|
|
|
23
25
|
The bundled files for deployment or publication will be located under the `dist` folder.
|
|
@@ -29,18 +31,17 @@ To run the example site you will need to:
|
|
|
29
31
|
* Have access to a Tari Wallet Daemon and to the Tari MetaMask Snap.
|
|
30
32
|
* Copy the `example/.env.example` file to `example/.env` and edit the correct environment variable values.
|
|
31
33
|
|
|
32
|
-
To run in development mode:
|
|
34
|
+
To run in development mode, in the packages/tarijs folder:
|
|
33
35
|
```shell
|
|
34
36
|
cd example
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
moon tarijs:build
|
|
38
|
+
pnpm run dev
|
|
37
39
|
```
|
|
38
40
|
|
|
39
|
-
For building and distribution
|
|
41
|
+
For building and distribution, in the packages/tarijs folder
|
|
40
42
|
```shell
|
|
41
43
|
cd example
|
|
42
|
-
|
|
43
|
-
npm run build
|
|
44
|
+
moon tarijs:build
|
|
44
45
|
```
|
|
45
46
|
The distribution files will be under the `example/dist` folder.
|
|
46
47
|
|
package/TODO.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# TODO
|
|
2
|
+
|
|
3
|
+
- In the wallet provider interface:
|
|
4
|
+
- Full TypeScript class definitions for transaction requests (instructions, etc.).
|
|
5
|
+
- Common return types for both types of wallets.
|
|
6
|
+
- Implement `getSubstate` method for the Tari Wallet Daemon provider.
|
|
7
|
+
- Add account balance to `getAccountData` method for the Tari Wallet Daemon provider.
|
|
8
|
+
- For the example site:
|
|
9
|
+
- The button should indicate when a connection was established.
|
|
10
|
+
- The `TariConnect` button could be made into a reusable React component, ready to be imported by any web.
|
|
11
|
+
- Typescript-bindings
|
|
12
|
+
- [Types refactor and cleanup](https://github.com/tari-project/tari.js/issues/29)
|
package/package.json
CHANGED
|
@@ -1,33 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tarijs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"publishConfig": {
|
|
7
|
-
"access": "public"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"build": "tsc -b",
|
|
11
|
-
"integration-tests": "vitest run integration-tests"
|
|
12
|
-
},
|
|
13
6
|
"keywords": [],
|
|
14
7
|
"author": "",
|
|
15
8
|
"license": "ISC",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"@tari-project/typescript-bindings": "^1.4.0",
|
|
19
|
-
"@tari-project/wallet_jrpc_client": "^1.4.0",
|
|
20
|
-
"@walletconnect/modal": "^2.6.2",
|
|
21
|
-
"@walletconnect/universal-provider": "^2.13.3"
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": "22.13.1"
|
|
22
11
|
},
|
|
23
12
|
"devDependencies": {
|
|
24
|
-
"@
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
"files": [
|
|
29
|
-
"/dist"
|
|
30
|
-
],
|
|
31
|
-
"main": "dist/index.js",
|
|
32
|
-
"types": "dist/index.d.ts"
|
|
33
|
-
}
|
|
13
|
+
"@moonrepo/cli": "^1.32.1"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
language: "typescript"
|
|
2
|
+
platform: "node"
|
|
3
|
+
type: "library"
|
|
4
|
+
|
|
5
|
+
fileGroups:
|
|
6
|
+
configs:
|
|
7
|
+
- "tsconfig.json"
|
|
8
|
+
- "package.json"
|
|
9
|
+
- "eslint.config.ts"
|
|
10
|
+
sources:
|
|
11
|
+
- "src/**/*"
|
|
12
|
+
tests:
|
|
13
|
+
- "integration-tests/**/*"
|
|
14
|
+
|
|
15
|
+
tasks:
|
|
16
|
+
build:
|
|
17
|
+
command: "pnpm run build"
|
|
18
|
+
inputs:
|
|
19
|
+
- "@files(sources)"
|
|
20
|
+
- "@files(configs)"
|
|
21
|
+
outputs:
|
|
22
|
+
- "dist"
|
|
23
|
+
format:
|
|
24
|
+
command: "pnpm run format"
|
|
25
|
+
inputs:
|
|
26
|
+
- "@files(sources)"
|
|
27
|
+
- "@files(configs)"
|
|
28
|
+
- "@files(tests)"
|
|
29
|
+
options:
|
|
30
|
+
runInCI: false
|
|
31
|
+
lint:
|
|
32
|
+
command: "pnpm run lint:fix"
|
|
33
|
+
inputs:
|
|
34
|
+
- "@files(sources)"
|
|
35
|
+
- "@files(configs)"
|
|
36
|
+
- "@files(tests)"
|
|
37
|
+
options:
|
|
38
|
+
runInCI: false
|
|
39
|
+
deps:
|
|
40
|
+
- "build"
|
|
41
|
+
|
|
42
|
+
lintCheck:
|
|
43
|
+
command: "pnpm run lint"
|
|
44
|
+
inputs:
|
|
45
|
+
- "@files(sources)"
|
|
46
|
+
- "@files(configs)"
|
|
47
|
+
- "@files(tests)"
|
|
48
|
+
deps:
|
|
49
|
+
- "build"
|
|
50
|
+
formatCheck:
|
|
51
|
+
command: "pnpm run format:check"
|
|
52
|
+
inputs:
|
|
53
|
+
- "@files(sources)"
|
|
54
|
+
- "@files(configs)"
|
|
55
|
+
- "@files(tests)"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tari-project/tarijs-builders",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc -b"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@tari-project/tari-provider": "workspace:^",
|
|
17
|
+
"@tari-project/tari-universe-provider": "workspace:^",
|
|
18
|
+
"@tari-project/tarijs-types": "workspace:^",
|
|
19
|
+
"@tari-project/typescript-bindings": "catalog:"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "catalog:",
|
|
23
|
+
"typescript": "catalog:"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"/dist"
|
|
27
|
+
],
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"types": "dist/index.d.ts"
|
|
30
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { TariUniverseProvider } from "@tari-project/tari-universe-provider";
|
|
2
|
+
import { TariProvider, SubmitTransactionRequest, SubstateRequirement } from "@tari-project/tari-provider";
|
|
3
|
+
import {
|
|
4
|
+
Transaction,
|
|
5
|
+
TransactionResult,
|
|
6
|
+
TransactionStatus,
|
|
7
|
+
DownSubstates,
|
|
8
|
+
UpSubstates,
|
|
9
|
+
FinalizeResultStatus,
|
|
10
|
+
TxResultAccept,
|
|
11
|
+
SubmitTxResult
|
|
12
|
+
} from "@tari-project/tarijs-types";
|
|
13
|
+
|
|
14
|
+
export function buildTransactionRequest(
|
|
15
|
+
transaction: Transaction,
|
|
16
|
+
accountId: number,
|
|
17
|
+
requiredSubstates: SubstateRequirement[],
|
|
18
|
+
inputRefs = [],
|
|
19
|
+
isDryRun = false,
|
|
20
|
+
network = 0,
|
|
21
|
+
isSealSignerAuthorized = true,
|
|
22
|
+
detectInputsUseUnversioned = true,
|
|
23
|
+
): SubmitTransactionRequest {
|
|
24
|
+
return {
|
|
25
|
+
//TODO refactor SubTxReq type to not use 'object[]' and types match
|
|
26
|
+
// https://github.com/tari-project/tari.js/issues/25
|
|
27
|
+
network,
|
|
28
|
+
account_id: accountId,
|
|
29
|
+
instructions: transaction.instructions as object[],
|
|
30
|
+
fee_instructions: transaction.feeInstructions as object[],
|
|
31
|
+
inputs: transaction.inputs,
|
|
32
|
+
input_refs: inputRefs as object[],
|
|
33
|
+
required_substates: requiredSubstates,
|
|
34
|
+
is_dry_run: isDryRun,
|
|
35
|
+
min_epoch: transaction.minEpoch ?? null,
|
|
36
|
+
max_epoch: transaction.maxEpoch ?? null,
|
|
37
|
+
is_seal_signer_authorized: isSealSignerAuthorized,
|
|
38
|
+
detect_inputs_use_unversioned: detectInputsUseUnversioned,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function submitAndWaitForTransaction(
|
|
43
|
+
provider: TariProvider,
|
|
44
|
+
req: SubmitTransactionRequest,
|
|
45
|
+
): Promise<SubmitTxResult> {
|
|
46
|
+
try {
|
|
47
|
+
const response = await provider.submitTransaction(req);
|
|
48
|
+
const result = await waitForTransactionResult(provider, response.transaction_id);
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
response,
|
|
52
|
+
result,
|
|
53
|
+
};
|
|
54
|
+
} catch (e) {
|
|
55
|
+
throw new Error(`Transaction failed: ${e}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function waitForTransactionResult(
|
|
60
|
+
provider: TariProvider | TariUniverseProvider,
|
|
61
|
+
transactionId: string,
|
|
62
|
+
): Promise<TransactionResult> {
|
|
63
|
+
// eslint-disable-next-line no-constant-condition
|
|
64
|
+
while (true) {
|
|
65
|
+
const resp = await provider.getTransactionResult(transactionId);
|
|
66
|
+
const FINALIZED_STATUSES = [
|
|
67
|
+
TransactionStatus.Accepted,
|
|
68
|
+
TransactionStatus.Rejected,
|
|
69
|
+
TransactionStatus.InvalidTransaction,
|
|
70
|
+
TransactionStatus.OnlyFeeAccepted,
|
|
71
|
+
TransactionStatus.DryRun,
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
if (resp.status == TransactionStatus.Rejected) {
|
|
75
|
+
throw new Error(`Transaction rejected: ${JSON.stringify(resp.result)}`);
|
|
76
|
+
}
|
|
77
|
+
if (FINALIZED_STATUSES.includes(resp.status)) {
|
|
78
|
+
return resp as any as TransactionResult; //TODO fix: type mismatch (https://github.com/tari-project/tari.js/issues/29)
|
|
79
|
+
}
|
|
80
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function getAcceptResultSubstates(
|
|
85
|
+
txResult: TransactionResult,
|
|
86
|
+
): { upSubstates: UpSubstates; downSubstates: DownSubstates } | undefined {
|
|
87
|
+
const result = txResult.result?.result;
|
|
88
|
+
|
|
89
|
+
if (result && isAccept(result)) {
|
|
90
|
+
return { upSubstates: result.Accept.up_substates, downSubstates: result.Accept.down_substates };
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function isAccept(result: FinalizeResultStatus): result is TxResultAccept {
|
|
96
|
+
return "Accept" in result;
|
|
97
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { WorkspaceArg } from "@tari-project/tarijs-types";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
*
|
|
3
5
|
* @param key workspace name
|
|
@@ -11,10 +13,11 @@
|
|
|
11
13
|
* key: "bucket.0" -> [ 98, 117, 99, 107, 101, 116, 46, 48 ]
|
|
12
14
|
* key: "bucket.1" -> [ 98, 117, 99, 107, 101, 116, 46, 49 ]
|
|
13
15
|
*/
|
|
14
|
-
export function toWorkspace(key) {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
export function toWorkspace(key: string): number[] {
|
|
17
|
+
const encoder = new TextEncoder();
|
|
18
|
+
return Array.from(encoder.encode(key));
|
|
17
19
|
}
|
|
20
|
+
|
|
18
21
|
/**
|
|
19
22
|
*
|
|
20
23
|
* @param key workspace name
|
|
@@ -22,8 +25,8 @@ export function toWorkspace(key) {
|
|
|
22
25
|
* @example
|
|
23
26
|
* key: "bucket" -> { Workspace: [ 98, 117, 99, 107, 101, 116 ] }
|
|
24
27
|
*/
|
|
25
|
-
export function fromWorkspace(key) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
export function fromWorkspace(key: string): WorkspaceArg {
|
|
29
|
+
const encoder = new TextEncoder();
|
|
30
|
+
const encodedKey = encoder.encode(key);
|
|
31
|
+
return { Workspace: Array.from(encodedKey) };
|
|
29
32
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "@tari-project/tarijs-types";
|
|
2
|
+
export { TransactionBuilder, TransactionRequest, TariMethodDefinition, TariFunctionDefinition } from "./transaction";
|
|
3
|
+
export {
|
|
4
|
+
buildTransactionRequest,
|
|
5
|
+
submitAndWaitForTransaction,
|
|
6
|
+
waitForTransactionResult,
|
|
7
|
+
fromWorkspace,
|
|
8
|
+
toWorkspace,
|
|
9
|
+
} from "./helpers";
|