@tari-project/tarijs 0.4.0 → 0.4.2
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 +26 -0
- package/.github/workflows/documentation-deploy.yml +44 -0
- package/.github/workflows/documentation-test-deploy.yml +20 -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 +33 -0
- package/.prettierrc +12 -0
- package/.prototools +9 -0
- package/CODEOWNERS +3 -0
- package/README.md +66 -0
- package/TODO.md +12 -0
- package/docusaurus/tari-docs/README.md +41 -0
- package/docusaurus/tari-docs/docs/index.md +16 -0
- package/docusaurus/tari-docs/docs/installation.md +27 -0
- package/docusaurus/tari-docs/docs/providers/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/providers/tari-universe.md +27 -0
- package/docusaurus/tari-docs/docs/providers/wallet-connect.md +52 -0
- package/docusaurus/tari-docs/docs/providers/wallet-daemon.md +37 -0
- package/docusaurus/tari-docs/docs/wallet/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/wallet/default-account.md +51 -0
- package/docusaurus/tari-docs/docs/wallet/get-substate.md +110 -0
- package/docusaurus/tari-docs/docs/wallet/list-substates.md +69 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/build-execute-request.md +38 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/index.md +14 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-function.md +17 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-method.md +17 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/fee.md +28 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/index.md +426 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/inputs.md +24 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/instruction.md +108 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/min-max-epoch.md +19 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/raw-instructions.md +16 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/save-var.md +63 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/transaction-internals.md +20 -0
- package/docusaurus/tari-docs/docs/wallet/template-definition.md +101 -0
- package/docusaurus/tari-docs/docusaurus.config.ts +108 -0
- package/docusaurus/tari-docs/moon.yml +41 -0
- package/docusaurus/tari-docs/package.json +49 -0
- package/docusaurus/tari-docs/sidebars.ts +7 -0
- package/docusaurus/tari-docs/src/components/HomepageFeatures/index.tsx +69 -0
- package/docusaurus/tari-docs/src/components/HomepageFeatures/styles.module.css +11 -0
- package/docusaurus/tari-docs/src/css/custom.css +30 -0
- package/docusaurus/tari-docs/src/pages/index.module.css +23 -0
- package/docusaurus/tari-docs/src/pages/index.tsx +44 -0
- package/docusaurus/tari-docs/static/.nojekyll +0 -0
- package/docusaurus/tari-docs/static/img/favicon.png +0 -0
- package/docusaurus/tari-docs/static/img/meta-image.png +0 -0
- package/docusaurus/tari-docs/static/img/tari/wallet-connect-1.png +0 -0
- package/docusaurus/tari-docs/static/img/tari/wallet-connect-2.png +0 -0
- package/docusaurus/tari-docs/static/img/tari/wallet-connect-3.png +0 -0
- package/docusaurus/tari-docs/static/img/tari-logo.svg +30 -0
- package/docusaurus/tari-docs/tsconfig.json +8 -0
- package/package.json +4 -28
- package/packages/builders/moon.yml +55 -0
- package/packages/builders/package.json +30 -0
- package/packages/builders/src/helpers/index.ts +2 -0
- package/packages/builders/src/helpers/submitTransaction.ts +97 -0
- package/packages/builders/src/helpers/workspace.ts +32 -0
- 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 +34 -0
- package/packages/tari_provider/src/index.ts +3 -0
- package/packages/tari_provider/src/types.ts +84 -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/packages/tari_universe/src/index.ts +3 -0
- package/packages/tari_universe/src/provider.ts +120 -0
- package/packages/tari_universe/src/types.ts +33 -0
- 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 +71 -0
- package/packages/tarijs/package.json +40 -0
- package/packages/tarijs/src/cbor.spec.ts +259 -0
- package/packages/tarijs/src/cbor.ts +114 -0
- package/packages/tarijs/src/index.ts +72 -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/packages/tarijs_types/src/ResourceAddress.ts +3 -0
- package/packages/tarijs_types/src/SubstateDiff.ts +9 -0
- package/packages/tarijs_types/src/SubstateRequirement.ts +6 -0
- package/packages/tarijs_types/src/TemplateAddress.ts +3 -0
- package/packages/tarijs_types/src/Transaction.ts +16 -0
- 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/packages/tarijs_types/src/VersionedSubstateId.ts +6 -0
- package/packages/tarijs_types/src/ViewableBalanceProof.ts +12 -0
- package/packages/tarijs_types/src/Workspace.ts +3 -0
- package/packages/tarijs_types/src/index.ts +25 -0
- 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/packages/wallet_daemon/src/index.ts +5 -0
- 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 +15 -0
- package/tsconfig.json +45 -0
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -13
- package/dist/network.d.ts +0 -8
- package/dist/network.js +0 -9
- package/dist/templates/Account.d.ts +0 -65
- package/dist/templates/Account.js +0 -31
- package/dist/templates/Pool.d.ts +0 -29
- package/dist/templates/Pool.js +0 -20
- package/dist/templates/Tariswap.d.ts +0 -64
- 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/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,26 @@
|
|
|
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
|
|
26
|
+
- run: moon :test
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: Deploy documentation to GitHub Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
name: Build Docusaurus
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0
|
|
16
|
+
- uses: 'moonrepo/setup-toolchain@v0'
|
|
17
|
+
with:
|
|
18
|
+
auto-install: true
|
|
19
|
+
- run: pnpm install
|
|
20
|
+
- run: moon tari-docs:build
|
|
21
|
+
- name: Upload Build Artifact
|
|
22
|
+
uses: actions/upload-pages-artifact@v3
|
|
23
|
+
with:
|
|
24
|
+
path: docusaurus/tari-docs/build
|
|
25
|
+
|
|
26
|
+
deploy:
|
|
27
|
+
name: Deploy to GitHub Pages
|
|
28
|
+
needs: build
|
|
29
|
+
|
|
30
|
+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
|
|
31
|
+
permissions:
|
|
32
|
+
pages: write # to deploy to Pages
|
|
33
|
+
id-token: write # to verify the deployment originates from an appropriate source
|
|
34
|
+
|
|
35
|
+
# Deploy to the github-pages environment
|
|
36
|
+
environment:
|
|
37
|
+
name: github-pages
|
|
38
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
39
|
+
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
steps:
|
|
42
|
+
- name: Deploy to GitHub Pages
|
|
43
|
+
id: deployment
|
|
44
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Test documentation deployment
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test-deploy:
|
|
10
|
+
name: Test documentation deployment
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0
|
|
16
|
+
- uses: 'moonrepo/setup-toolchain@v0'
|
|
17
|
+
with:
|
|
18
|
+
auto-install: true
|
|
19
|
+
- run: pnpm install
|
|
20
|
+
- run: moon tari-docs: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,33 @@
|
|
|
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
|
+
- 'docusaurus/*'
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Configures the version control system to utilize within the workspace. A VCS
|
|
22
|
+
# is required for determining touched (added, modified, etc) files, calculating file hashes,
|
|
23
|
+
# computing affected files, and much more.
|
|
24
|
+
vcs:
|
|
25
|
+
# The client to use when managing the repository.
|
|
26
|
+
# Accepts "git". Defaults to "git".
|
|
27
|
+
manager: 'git'
|
|
28
|
+
|
|
29
|
+
# The default branch (master/main/trunk) in the repository for comparing the
|
|
30
|
+
# local branch against. For git, this is is typically "master" or "main",
|
|
31
|
+
# and must include the remote prefix (before /).
|
|
32
|
+
defaultBranch: 'main'
|
|
33
|
+
|
package/.prettierrc
ADDED
package/.prototools
ADDED
package/CODEOWNERS
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# tari.js
|
|
2
|
+
|
|
3
|
+
This project provides a unified TypeScript library to connect and send requests to a Tari wallet. It's intended for web application developers that want to interact with a Tari wallet (connect, get substates, submit transactions, etc.).
|
|
4
|
+
|
|
5
|
+
Tari wallets supported:
|
|
6
|
+
* Tari Wallet Daemon
|
|
7
|
+
* MetaMask through the [tari-snap](https://github.com/tari-project/tari-snap)
|
|
8
|
+
|
|
9
|
+
An example site (under the `example` folder) contains a web project that allows the user to connect to any type of Tari wallet and perform common actions.
|
|
10
|
+
|
|
11
|
+
Please read the [TODO](TODO.md) file for upcoming features.
|
|
12
|
+
|
|
13
|
+
## Library building
|
|
14
|
+
|
|
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
|
+
|
|
17
|
+
To build the library:
|
|
18
|
+
First you must install [proto](https://moonrepo.dev/proto) to manage node and pnpm versions
|
|
19
|
+
```shell
|
|
20
|
+
proto use
|
|
21
|
+
pnpm install
|
|
22
|
+
moon tarijs:build
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The bundled files for deployment or publication will be located under the `dist` folder.
|
|
26
|
+
|
|
27
|
+
## Running the example site
|
|
28
|
+
|
|
29
|
+
To run the example site you will need to:
|
|
30
|
+
* Compile the library following the previous section.
|
|
31
|
+
* Have access to a Tari Wallet Daemon and to the Tari MetaMask Snap.
|
|
32
|
+
* Copy the `example/.env.example` file to `example/.env` and edit the correct environment variable values.
|
|
33
|
+
|
|
34
|
+
To run in development mode, in the packages/tarijs folder:
|
|
35
|
+
```shell
|
|
36
|
+
cd example
|
|
37
|
+
moon tarijs:build
|
|
38
|
+
pnpm run dev
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For building and distribution, in the packages/tarijs folder
|
|
42
|
+
```shell
|
|
43
|
+
cd example
|
|
44
|
+
moon tarijs:build
|
|
45
|
+
```
|
|
46
|
+
The distribution files will be under the `example/dist` folder.
|
|
47
|
+
|
|
48
|
+
## Documentation
|
|
49
|
+
|
|
50
|
+
This monorepo includes a documentation site located in the `docusaurus` folder. It's built using [Docusaurus](https://docusaurus.io/) and generates a static website.
|
|
51
|
+
|
|
52
|
+
### Modifying the Documentation
|
|
53
|
+
|
|
54
|
+
To start the documentation site:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
$ moon tari-docs:start
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This will open the documentation site in your browser at `http://localhost:3000/tari.js/`
|
|
61
|
+
|
|
62
|
+
You can now update the documentation by editing files in the `docusaurus/tari-docs/docs/` folder. Changes will be reflected automatically.
|
|
63
|
+
|
|
64
|
+
### Publishing documentation
|
|
65
|
+
|
|
66
|
+
The documentation is hosted on GitHub Pages and served from the `/docs` folder of the `gh-pages` branch. The `documentation-deploy.yml` workflow defines the deployment process.
|
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)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Website
|
|
2
|
+
|
|
3
|
+
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
|
|
4
|
+
|
|
5
|
+
### Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
$ yarn
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Local Development
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
$ yarn start
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
|
|
18
|
+
|
|
19
|
+
### Build
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
$ yarn build
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
|
|
26
|
+
|
|
27
|
+
### Deployment
|
|
28
|
+
|
|
29
|
+
Using SSH:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
$ USE_SSH=true yarn deploy
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Not using SSH:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
$ GIT_USER=<Your GitHub username> yarn deploy
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 1
|
|
3
|
+
slug: /
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Overview
|
|
7
|
+
|
|
8
|
+
This is the documentation of `tari.js` library, which enables interaction with Tari L2 (Ootle) wallet using TypeScript or JavaScript.
|
|
9
|
+
|
|
10
|
+
At its core, `TariProvider` is an abstract interface implemented by multiple concrete providers. To access a wallet, you need to create an instance of one of these providers:
|
|
11
|
+
|
|
12
|
+
* [Tari WalletConnect provider](./providers/wallet-connect.md)
|
|
13
|
+
* [Tari Universe provider](./providers/tari-universe.md)
|
|
14
|
+
* [Tari Wallet Daemon provider](./providers/wallet-daemon.md)
|
|
15
|
+
* Tari Metamask provider
|
|
16
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 2
|
|
3
|
+
title: Installation
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Installation
|
|
7
|
+
|
|
8
|
+
`tari.js` consists of a set of [packages](https://github.com/tari-project/tari.js/tree/main/packages).
|
|
9
|
+
|
|
10
|
+
Usually, you will need to install the base package and at least one package that implements a concrete provider.
|
|
11
|
+
|
|
12
|
+
## Install base package
|
|
13
|
+
|
|
14
|
+
```bash npm2yarn
|
|
15
|
+
npm install @tari-project/tarijs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Install a provider
|
|
19
|
+
|
|
20
|
+
For this documentation, we will use the `Wallet Daemon Provider`, which allows direct connection to the wallet if you are hosting it locally.
|
|
21
|
+
However, you are free to install any other available provider.
|
|
22
|
+
|
|
23
|
+
```bash npm2yarn
|
|
24
|
+
npm install @tari-project/wallet-daemon-provider
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
We will review all providers on their dedicated pages.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 2
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Tari Universe provider
|
|
6
|
+
|
|
7
|
+
This provider is designed for building Tari Universe apps.
|
|
8
|
+
|
|
9
|
+
## Install required dependencies
|
|
10
|
+
|
|
11
|
+
```bash npm2yarn
|
|
12
|
+
npm install @tari-project/tari-universe-provider @tari-project/tari-permissions
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Establish the connection
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { TariPermissions } from "@tari-project/tari-permissions";
|
|
19
|
+
import { TariUniverseProvider } from "@tari-project/tari-universe-provider";
|
|
20
|
+
|
|
21
|
+
const permissions = new TariPermissions().addPermission("Admin");
|
|
22
|
+
const optionalPermissions = new TariPermissions();
|
|
23
|
+
const provider = new TariUniverseProvider({
|
|
24
|
+
permissions,
|
|
25
|
+
optionalPermissions,
|
|
26
|
+
});
|
|
27
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 1
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# WalletConnect provider
|
|
7
|
+
|
|
8
|
+
[WalletConnect](https://walletconnect.network/) is an open-source protocol that lets users connect their cryptocurrency wallets to decentralized applications (dApps) in a secure way. It uses QR codes or deep linking to establish a connection between the wallet and the dApp, allowing users to interact with dApps without exposing their private keys.
|
|
9
|
+
|
|
10
|
+
## Install required dependencies
|
|
11
|
+
|
|
12
|
+
```bash npm2yarn
|
|
13
|
+
npm install @tari-project/wallet-connect-provider
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`WalletConnect` provider is browser only. This means it requires user interaction.
|
|
17
|
+
|
|
18
|
+
Establishing connection requires multiple steps.
|
|
19
|
+
|
|
20
|
+
## Obtain WalletConnect Project ID
|
|
21
|
+
|
|
22
|
+
Obtain a WalletConnect Project ID by registering your project on the WalletConnect Cloud. This ID is then used to connect your dApp to the WalletConnect infrastructure, facilitating communication between the dApp and user wallets.
|
|
23
|
+
|
|
24
|
+
## Request a connection and display wallet connect dialog
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import { WalletConnectTariProvider } from "@tari-project/wallet-connect-provider";
|
|
28
|
+
|
|
29
|
+
const projectId = "1825b9dd9c17b5a33063ae91cbc48a6e";
|
|
30
|
+
const provider = new WalletConnectTariProvider(projectId);
|
|
31
|
+
await provider.connect();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
You should see `WalletConnect` dialog:
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
## Copy connection link to clipboard
|
|
39
|
+
|
|
40
|
+
Click the copy link icon in the top right corner.
|
|
41
|
+
|
|
42
|
+
## Authorize the connection in your wallet
|
|
43
|
+
|
|
44
|
+
Authorize the connection by clicking `Connect with WalletConnect` button in your wallet.
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
## Success!
|
|
51
|
+
|
|
52
|
+
Go back to your web application, and the connection should now be established.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 3
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Wallet daemon provider
|
|
6
|
+
|
|
7
|
+
This is the only provider that works in both Node.js and browser environments. It enables a direct connection to a wallet via JSON-RPC.
|
|
8
|
+
|
|
9
|
+
## Install required dependencies
|
|
10
|
+
|
|
11
|
+
```bash npm2yarn
|
|
12
|
+
npm install @tari-project/wallet-daemon-provider @tari-project/tari-permissions
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Establish and test the connection
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { TariPermissions } from "@tari-project/tari-permissions";
|
|
19
|
+
import { WalletDaemonTariProvider } from "@tari-project/wallet-daemon-provider";
|
|
20
|
+
|
|
21
|
+
const permissions = new TariPermissions().addPermission("Admin");
|
|
22
|
+
const serverUrl = "http://127.0.0.1:12010/json_rpc";
|
|
23
|
+
const provider = await WalletDaemonTariProvider.buildFetchProvider({
|
|
24
|
+
permissions,
|
|
25
|
+
serverUrl,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Test connection
|
|
29
|
+
const account = await provider.getAccount();
|
|
30
|
+
console.log(`Account address: ${account.address}`);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If the connection is successful, it should output an account address similar to the following:
|
|
34
|
+
|
|
35
|
+
```txt
|
|
36
|
+
Account id: component_24b679b98056c7ca7e3d9f9266fec928c7f29d35e7aec546ed69f532aff40710
|
|
37
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 1
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Account
|
|
6
|
+
|
|
7
|
+
The provider is linked to an account in your wallet.
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
const account = await provider.getAccount();
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This call returns the account details:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"account_id": 1,
|
|
18
|
+
"address": "component_24b679b98056c7ca7e3d9f9266fec928c7f29d35e7aec546ed69f532aff40710",
|
|
19
|
+
"public_key": "a6534c991a5c034b2f81af809b9577fe6b5425f810de292c0a4d4d43793a8f50",
|
|
20
|
+
"resources": [
|
|
21
|
+
{
|
|
22
|
+
"type": "Confidential",
|
|
23
|
+
"resource_address": "resource_0101010101010101010101010101010101010101010101010101010101010101",
|
|
24
|
+
"balance": 999999643,
|
|
25
|
+
"vault_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35bf23f7b434c7e61c4d0b7057",
|
|
26
|
+
"token_symbol": "XTR"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "Fungible",
|
|
30
|
+
"resource_address": "resource_217d58767480fbaa48693e11de34baf7fd727e33ee7627f0c4e5b78def378e57",
|
|
31
|
+
"balance": 990,
|
|
32
|
+
"vault_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35ba5d265d0bfc518baa4de2fa",
|
|
33
|
+
"token_symbol": "token-a"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"type": "Fungible",
|
|
37
|
+
"resource_address": "resource_9cdad1188895b080885a64abb71a66a4a4cb1d81d1a55f018a0472b91ee2b47b",
|
|
38
|
+
"balance": 990,
|
|
39
|
+
"vault_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d352289e045361315cf27335067",
|
|
40
|
+
"token_symbol": "token-b"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "Fungible",
|
|
44
|
+
"resource_address": "resource_c3df71792220ec8f3d3896991d49e100096020f8e26bce2cd16ba5c27831f988",
|
|
45
|
+
"balance": 20,
|
|
46
|
+
"vault_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35f2bfd6b4ca0aa2ba2fcc4769",
|
|
47
|
+
"token_symbol": "LP"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
```
|