@tari-project/tarijs 0.4.2 → 0.5.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/Dockerfile +52 -0
- package/README.md +37 -2
- package/TODO.md +0 -8
- package/docusaurus/tari-docs/docs/index.md +10 -5
- package/docusaurus/tari-docs/docs/installation.md +1 -1
- package/docusaurus/tari-docs/docs/providers/_category_.json +2 -2
- package/docusaurus/tari-docs/docs/providers/indexer-provider.md +32 -0
- package/docusaurus/tari-docs/docs/signers/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/{providers → signers}/tari-universe.md +5 -5
- package/docusaurus/tari-docs/docs/{providers → signers}/wallet-connect.md +6 -7
- package/docusaurus/tari-docs/docs/{providers → signers}/wallet-daemon.md +7 -7
- package/docusaurus/tari-docs/docs/wallet/_category_.json +1 -1
- package/docusaurus/tari-docs/docs/wallet/list-substates.md +2 -3
- package/docusaurus/tari-docs/package.json +1 -1
- package/docusaurus/tari-docs/tsconfig.json +3 -1
- package/package.json +1 -1
- package/packages/builders/package.json +4 -5
- package/packages/builders/src/helpers/submitTransaction.ts +12 -12
- package/packages/builders/src/transaction/TransactionBuilder.ts +6 -7
- package/packages/builders/src/transaction/TransactionRequest.ts +10 -20
- package/packages/builders/tsconfig.json +2 -4
- package/packages/indexer_provider/package.json +31 -0
- package/packages/indexer_provider/src/index.ts +2 -0
- package/packages/indexer_provider/src/provider.ts +105 -0
- package/packages/indexer_provider/src/transports/IndexerProviderClient.ts +144 -0
- package/packages/indexer_provider/src/transports/fetch.ts +46 -0
- package/packages/indexer_provider/src/transports/index.ts +3 -0
- package/packages/indexer_provider/src/transports/rpc.ts +19 -0
- package/packages/indexer_provider/tsconfig.json +22 -0
- package/packages/metamask_signer/moon.yml +55 -0
- package/packages/{metamask_provider → metamask_signer}/package.json +3 -3
- package/packages/{metamask_provider → metamask_signer}/src/index.ts +42 -30
- package/packages/metamask_signer/tsconfig.json +19 -0
- package/packages/tari_permissions/package.json +2 -3
- package/packages/tari_permissions/src/helpers.ts +33 -0
- package/packages/tari_permissions/src/index.ts +2 -1
- package/packages/tari_permissions/src/tari_permissions.ts +59 -42
- package/packages/tari_provider/package.json +3 -2
- package/packages/tari_provider/src/TariProvider.ts +10 -25
- package/packages/tari_provider/src/index.ts +1 -3
- package/packages/tari_provider/tsconfig.json +9 -2
- package/packages/tari_signer/moon.yml +55 -0
- package/packages/tari_signer/package.json +28 -0
- package/packages/tari_signer/src/TariSigner.ts +30 -0
- package/packages/tari_signer/src/index.ts +1 -0
- package/packages/{metamask_provider → tari_signer}/tsconfig.json +0 -3
- package/packages/tari_universe/package.json +3 -3
- package/packages/tari_universe/src/index.ts +1 -1
- package/packages/tari_universe/src/{provider.ts → signer.ts} +45 -36
- package/packages/tari_universe/src/types.ts +10 -10
- package/packages/tari_universe/src/utils.ts +8 -8
- package/packages/tari_universe/tsconfig.json +2 -4
- package/packages/tarijs/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +44 -44
- package/packages/tarijs/package.json +8 -6
- package/packages/tarijs/src/index.ts +39 -28
- package/packages/tarijs/tsconfig.json +7 -1
- package/packages/tarijs_types/package.json +1 -1
- package/packages/tarijs_types/src/ConfidentialOutput.ts +1 -1
- package/packages/tarijs_types/src/ConfidentialWithdrawProof.ts +1 -1
- package/packages/tarijs_types/src/GetTransactionResultResponse.ts +8 -0
- package/packages/tarijs_types/src/Instruction.ts +8 -5
- package/packages/tarijs_types/src/ListAccountNftFromBalancesRequest.ts +5 -0
- package/packages/tarijs_types/src/Transaction.ts +1 -1
- package/packages/tarijs_types/src/TransactionArg.ts +2 -0
- package/packages/tarijs_types/src/TransactionResult.ts +1 -10
- package/packages/tarijs_types/src/TransactionStatus.ts +9 -0
- package/packages/tarijs_types/src/UnsignedTransaction.ts +1 -2
- package/packages/tarijs_types/src/helpers/index.ts +69 -0
- package/packages/tarijs_types/src/index.ts +40 -11
- package/packages/{tari_provider/src/types.ts → tarijs_types/src/signer.ts} +17 -28
- package/packages/wallet_daemon/package.json +4 -3
- package/packages/wallet_daemon/src/index.ts +1 -1
- package/packages/wallet_daemon/src/{provider.ts → signer.ts} +59 -60
- package/packages/wallet_daemon/tsconfig.json +4 -1
- package/packages/walletconnect/package.json +4 -3
- package/packages/walletconnect/src/index.ts +56 -57
- package/packages/walletconnect/tsconfig.json +4 -1
- package/pnpm-workspace.yaml +3 -3
- package/tsconfig.json +8 -2
- package/packages/tarijs_types/src/Arg.ts +0 -3
- package/packages/tarijs_types/src/ComponentAddress.ts +0 -3
- package/packages/tarijs_types/src/ConfidentialOutputStatement.ts +0 -10
- package/packages/tarijs_types/src/ConfidentialStatement.ts +0 -9
- package/packages/tarijs_types/src/ElgamalVerifiableBalance.ts +0 -4
- package/packages/tarijs_types/src/Epoch.ts +0 -3
- package/packages/tarijs_types/src/ResourceAddress.ts +0 -3
- package/packages/tarijs_types/src/TemplateAddress.ts +0 -3
- package/packages/tarijs_types/src/TransactionId.ts +0 -4
- package/packages/tarijs_types/src/ViewableBalanceProof.ts +0 -12
- /package/packages/{metamask_provider → indexer_provider}/moon.yml +0 -0
- /package/packages/{metamask_provider → metamask_signer}/src/utils.ts +0 -0
package/Dockerfile
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Use Node.js 22.13.1 as the base image
|
|
2
|
+
FROM node:22.13.1-slim
|
|
3
|
+
|
|
4
|
+
# Set working directory
|
|
5
|
+
WORKDIR /app
|
|
6
|
+
# Add proto to PATH and set environment
|
|
7
|
+
ENV PATH="/root/.proto/bin:${PATH}"
|
|
8
|
+
ENV PROTO_HOME="/root/.proto"
|
|
9
|
+
ENV SHELL="/bin/bash"
|
|
10
|
+
# Install system dependencies
|
|
11
|
+
RUN apt-get update && apt-get install -y \
|
|
12
|
+
git \
|
|
13
|
+
python3 \
|
|
14
|
+
build-essential \
|
|
15
|
+
curl \
|
|
16
|
+
&& rm -rf /var/lib/apt/lists/* \
|
|
17
|
+
&& npm install -g pnpm@latest \
|
|
18
|
+
&& curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s -- -y \
|
|
19
|
+
&& /bin/bash -c "source ~/.bashrc && source ~/.profile"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# Clone tari-dan repo at the same level (required for building)
|
|
23
|
+
WORKDIR /
|
|
24
|
+
RUN git clone https://github.com/tari-project/tari-dan.git
|
|
25
|
+
|
|
26
|
+
# Set up project
|
|
27
|
+
WORKDIR /app
|
|
28
|
+
COPY . .
|
|
29
|
+
|
|
30
|
+
# Use proto to set up the environment (with explicit shell sourcing)
|
|
31
|
+
SHELL ["/bin/bash", "-c"]
|
|
32
|
+
RUN proto use \
|
|
33
|
+
&& pnpm install \
|
|
34
|
+
&& moon tarijs:build
|
|
35
|
+
|
|
36
|
+
# Create combined dist directory and copy all dist folders while excluding node_modules
|
|
37
|
+
RUN mkdir -p /app/combined_dist && \
|
|
38
|
+
for pkg in /app/packages/*/; do \
|
|
39
|
+
if [ -d "${pkg}dist" ]; then \
|
|
40
|
+
pkg_name=$(basename $pkg); \
|
|
41
|
+
mkdir -p "/app/combined_dist/${pkg_name}/dist"; \
|
|
42
|
+
cp -r "${pkg}dist/"* "/app/combined_dist/${pkg_name}/dist/"; \
|
|
43
|
+
cp "${pkg}package.json" "/app/combined_dist/${pkg_name}/package.json"; \
|
|
44
|
+
fi \
|
|
45
|
+
done && \
|
|
46
|
+
find /app/packages -name "node_modules" -type d -exec rm -rf {} +
|
|
47
|
+
|
|
48
|
+
# Set working directory to the combined dist
|
|
49
|
+
WORKDIR /app/combined_dist
|
|
50
|
+
|
|
51
|
+
# Set default command
|
|
52
|
+
CMD ["bash"]
|
package/README.md
CHANGED
|
@@ -14,7 +14,9 @@ Please read the [TODO](TODO.md) file for upcoming features.
|
|
|
14
14
|
|
|
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
|
+
### Option 1: Local Build
|
|
18
|
+
|
|
19
|
+
To build the library locally:
|
|
18
20
|
First you must install [proto](https://moonrepo.dev/proto) to manage node and pnpm versions
|
|
19
21
|
```shell
|
|
20
22
|
proto use
|
|
@@ -22,7 +24,40 @@ pnpm install
|
|
|
22
24
|
moon tarijs:build
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
The bundled files for deployment or publication will be located under the `dist` folder.
|
|
27
|
+
The bundled files for deployment or publication will be located under the `dist` folder of each package.
|
|
28
|
+
|
|
29
|
+
### Option 2: Docker Build
|
|
30
|
+
|
|
31
|
+
Alternatively, you can build the library using Docker:
|
|
32
|
+
|
|
33
|
+
```shell
|
|
34
|
+
# Build the Docker image
|
|
35
|
+
docker build -t tarijs .
|
|
36
|
+
|
|
37
|
+
# Run the container and copy the combined dist files
|
|
38
|
+
docker create --name tarijs-build tarijs
|
|
39
|
+
docker cp tarijs-build:/app/combined_dist/ ./dist
|
|
40
|
+
docker rm tarijs-build
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
This will create a combined build output in your local `dist` directory, containing all package distributions organized by package name, with the following structure:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
dist/
|
|
47
|
+
├── tarijs/
|
|
48
|
+
├── tari_provider/
|
|
49
|
+
├── tari_permissions/
|
|
50
|
+
├── wallet_daemon/
|
|
51
|
+
├── tari_signer/
|
|
52
|
+
├── builders/
|
|
53
|
+
├── metamask_signer/
|
|
54
|
+
├── tari_universe/
|
|
55
|
+
├── tarijs_types/
|
|
56
|
+
├── indexer_provider/
|
|
57
|
+
└── walletconnect/
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Each package's dist folder contains its compiled JavaScript files, type definitions, and other build artifacts, excluding node_modules.
|
|
26
61
|
|
|
27
62
|
## Running the example site
|
|
28
63
|
|
package/TODO.md
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
# TODO
|
|
2
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
3
|
- For the example site:
|
|
9
|
-
- The button should indicate when a connection was established.
|
|
10
4
|
- 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)
|
|
@@ -7,10 +7,15 @@ slug: /
|
|
|
7
7
|
|
|
8
8
|
This is the documentation of `tari.js` library, which enables interaction with Tari L2 (Ootle) wallet using TypeScript or JavaScript.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### Note
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* Tari Metamask provider
|
|
12
|
+
> This documentation covers version **v0.5.0**.
|
|
13
|
+
>
|
|
14
|
+
> The biggest difference between version 0.4.0 and 0.5.0 is the _Signer_ and _Provider_ split. Learn more in the [Tari Provider](./providers/indexer-provider.md) and [Tari Signer](./signers/wallet-connect.md) sections.
|
|
16
15
|
|
|
16
|
+
At its core, `TariSigner` is an abstract interface implemented by multiple concrete signers. To access a wallet, you need to create an instance of one of these signers:
|
|
17
|
+
|
|
18
|
+
- [Tari WalletConnect signer](./signers/wallet-connect.md)
|
|
19
|
+
- [Tari Universe signer](./signers/tari-universe.md)
|
|
20
|
+
- [Tari Wallet Daemon signer](./signers/wallet-daemon.md)
|
|
21
|
+
- Tari Metamask signer
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"label": "Providers",
|
|
3
|
-
"position":
|
|
3
|
+
"position": 1,
|
|
4
4
|
"link": {
|
|
5
5
|
"type": "generated-index",
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "A Provider provides a connection to the blockchain, whch can be used to query its current state, but only the public one."
|
|
7
7
|
}
|
|
8
8
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 1
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Indexer Provider
|
|
6
|
+
|
|
7
|
+
This provider is designed to provide connection to the blockchain, whch can be used to query its current state, but only the public one.
|
|
8
|
+
|
|
9
|
+
## Install required dependencies
|
|
10
|
+
|
|
11
|
+
```bash npm2yarn
|
|
12
|
+
npm install @tari-project/indexer-provider @tari-project/tari-permissions
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Establish the connection
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { IndexerProvider, IndexerProviderParameters } from "@tari-project/indexer-provider";
|
|
19
|
+
import { TariPermissions } from "@tari-project/tari-permissions";
|
|
20
|
+
|
|
21
|
+
const permissions = new TariPermissions().addPermission("Admin");
|
|
22
|
+
const optionalPermissions = new TariPermissions();
|
|
23
|
+
const indexerJrpcUrl = "http://127.0.0.1:12006/json_rpc"; // example url
|
|
24
|
+
|
|
25
|
+
const params: IndexerProviderParameters = {
|
|
26
|
+
indexerJrpcUrl: indexerJrpcUrl,
|
|
27
|
+
permissions: requiredPermissions,
|
|
28
|
+
optionalPermissions: optionalPermissions,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const provider = await IndexerProvider.build(params);
|
|
32
|
+
```
|
|
@@ -2,25 +2,25 @@
|
|
|
2
2
|
sidebar_position: 2
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
# Tari Universe
|
|
5
|
+
# Tari Universe signer
|
|
6
6
|
|
|
7
|
-
This
|
|
7
|
+
This signer is designed for building Tari Universe apps.
|
|
8
8
|
|
|
9
9
|
## Install required dependencies
|
|
10
10
|
|
|
11
11
|
```bash npm2yarn
|
|
12
|
-
npm install @tari-project/tari-universe-
|
|
12
|
+
npm install @tari-project/tari-universe-signer @tari-project/tari-permissions
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Establish the connection
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
18
|
import { TariPermissions } from "@tari-project/tari-permissions";
|
|
19
|
-
import {
|
|
19
|
+
import { TariUniverseSigner } from "@tari-project/tari-universe-signer";
|
|
20
20
|
|
|
21
21
|
const permissions = new TariPermissions().addPermission("Admin");
|
|
22
22
|
const optionalPermissions = new TariPermissions();
|
|
23
|
-
const
|
|
23
|
+
const signer = new TariUniverseSigner({
|
|
24
24
|
permissions,
|
|
25
25
|
optionalPermissions,
|
|
26
26
|
});
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
sidebar_position: 1
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
# WalletConnect provider
|
|
5
|
+
# WalletConnect signer
|
|
7
6
|
|
|
8
7
|
[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
8
|
|
|
10
9
|
## Install required dependencies
|
|
11
10
|
|
|
12
11
|
```bash npm2yarn
|
|
13
|
-
npm install @tari-project/wallet-connect-
|
|
12
|
+
npm install @tari-project/wallet-connect-signer
|
|
14
13
|
```
|
|
15
14
|
|
|
16
|
-
`WalletConnect`
|
|
15
|
+
`WalletConnect` signer is browser only. This means it requires user interaction.
|
|
17
16
|
|
|
18
17
|
Establishing connection requires multiple steps.
|
|
19
18
|
|
|
@@ -24,11 +23,11 @@ Obtain a WalletConnect Project ID by registering your project on the WalletConne
|
|
|
24
23
|
## Request a connection and display wallet connect dialog
|
|
25
24
|
|
|
26
25
|
```js
|
|
27
|
-
import {
|
|
26
|
+
import { WalletConnectTariSigner } from "@tari-project/wallet-connect-signer";
|
|
28
27
|
|
|
29
28
|
const projectId = "1825b9dd9c17b5a33063ae91cbc48a6e";
|
|
30
|
-
const
|
|
31
|
-
await
|
|
29
|
+
const signer = new WalletConnectTariSigner(projectId);
|
|
30
|
+
await signer.connect();
|
|
32
31
|
```
|
|
33
32
|
|
|
34
33
|
You should see `WalletConnect` dialog:
|
|
@@ -2,31 +2,31 @@
|
|
|
2
2
|
sidebar_position: 3
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
# Wallet daemon
|
|
5
|
+
# Wallet daemon signer
|
|
6
6
|
|
|
7
|
-
This is the only
|
|
7
|
+
This is the only signer that works in both Node.js and browser environments. It enables a direct connection to a wallet via JSON-RPC.
|
|
8
8
|
|
|
9
9
|
## Install required dependencies
|
|
10
10
|
|
|
11
11
|
```bash npm2yarn
|
|
12
|
-
npm install @tari-project/wallet-daemon-
|
|
12
|
+
npm install @tari-project/wallet-daemon-signer @tari-project/tari-permissions
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Establish and test the connection
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
18
|
import { TariPermissions } from "@tari-project/tari-permissions";
|
|
19
|
-
import {
|
|
19
|
+
import { WalletDaemonTariSigner } from "@tari-project/wallet-daemon-signer";
|
|
20
20
|
|
|
21
21
|
const permissions = new TariPermissions().addPermission("Admin");
|
|
22
22
|
const serverUrl = "http://127.0.0.1:12010/json_rpc";
|
|
23
|
-
const
|
|
23
|
+
const signer = await WalletDaemonTariSigner.buildFetchProvider({
|
|
24
24
|
permissions,
|
|
25
25
|
serverUrl,
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
// Test connection
|
|
29
|
-
const account = await
|
|
29
|
+
const account = await signer.getAccount();
|
|
30
30
|
console.log(`Account address: ${account.address}`);
|
|
31
31
|
```
|
|
32
32
|
|
|
@@ -34,4 +34,4 @@ If the connection is successful, it should output an account address similar to
|
|
|
34
34
|
|
|
35
35
|
```txt
|
|
36
36
|
Account id: component_24b679b98056c7ca7e3d9f9266fec928c7f29d35e7aec546ed69f532aff40710
|
|
37
|
-
```
|
|
37
|
+
```
|
|
@@ -7,7 +7,7 @@ sidebar_position: 3
|
|
|
7
7
|
In the Tari network, substates are discrete units of state within the Tari Digital Assets Network. Each substate encapsulates a specific piece of data—such as ownership records, smart contract states, or asset balances.
|
|
8
8
|
Substates follow a create-spend lifecycle, meaning they are created, referenced, and eventually consumed or modified according to network rules.
|
|
9
9
|
|
|
10
|
-
You can query substates using the `listSubstates` method of a `
|
|
10
|
+
You can query substates using the `listSubstates` method of a `TariSigner`.
|
|
11
11
|
|
|
12
12
|
```ts
|
|
13
13
|
listSubstates(
|
|
@@ -18,7 +18,6 @@ listSubstates(
|
|
|
18
18
|
): Promise<ListSubstatesResponse>;
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
22
21
|
## List by template
|
|
23
22
|
|
|
24
23
|
```js
|
|
@@ -66,4 +65,4 @@ Output:
|
|
|
66
65
|
}
|
|
67
66
|
]
|
|
68
67
|
}
|
|
69
|
-
```
|
|
68
|
+
```
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
// This file is not used in compilation. It is here just for a nice editor experience.
|
|
3
|
+
// "composite" added to resolve the ts error: "Referenced project '/docusaurus/tari-docs' must have setting "composite": true
|
|
3
4
|
"extends": "@docusaurus/tsconfig",
|
|
4
5
|
"compilerOptions": {
|
|
5
|
-
"baseUrl": "."
|
|
6
|
+
"baseUrl": ".",
|
|
7
|
+
"composite": true
|
|
6
8
|
},
|
|
7
9
|
"exclude": [".docusaurus", "build"]
|
|
8
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tarijs-builders",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -13,10 +13,9 @@
|
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@tari-project/tari-
|
|
17
|
-
"@tari-project/tari-universe-
|
|
18
|
-
"@tari-project/tarijs-types": "workspace:^"
|
|
19
|
-
"@tari-project/typescript-bindings": "catalog:"
|
|
16
|
+
"@tari-project/tari-signer": "workspace:^",
|
|
17
|
+
"@tari-project/tari-universe-signer": "workspace:^",
|
|
18
|
+
"@tari-project/tarijs-types": "workspace:^"
|
|
20
19
|
},
|
|
21
20
|
"devDependencies": {
|
|
22
21
|
"@types/node": "catalog:",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { TariUniverseSigner } from "@tari-project/tari-universe-signer";
|
|
2
|
+
import { TariSigner } from "@tari-project/tari-signer";
|
|
3
3
|
import {
|
|
4
4
|
Transaction,
|
|
5
5
|
TransactionResult,
|
|
@@ -8,13 +8,15 @@ import {
|
|
|
8
8
|
UpSubstates,
|
|
9
9
|
FinalizeResultStatus,
|
|
10
10
|
TxResultAccept,
|
|
11
|
-
SubmitTxResult
|
|
11
|
+
SubmitTxResult,
|
|
12
|
+
ReqSubstate,
|
|
13
|
+
SubmitTransactionRequest,
|
|
12
14
|
} from "@tari-project/tarijs-types";
|
|
13
15
|
|
|
14
16
|
export function buildTransactionRequest(
|
|
15
17
|
transaction: Transaction,
|
|
16
18
|
accountId: number,
|
|
17
|
-
requiredSubstates:
|
|
19
|
+
requiredSubstates: ReqSubstate[],
|
|
18
20
|
inputRefs = [],
|
|
19
21
|
isDryRun = false,
|
|
20
22
|
network = 0,
|
|
@@ -22,8 +24,6 @@ export function buildTransactionRequest(
|
|
|
22
24
|
detectInputsUseUnversioned = true,
|
|
23
25
|
): SubmitTransactionRequest {
|
|
24
26
|
return {
|
|
25
|
-
//TODO refactor SubTxReq type to not use 'object[]' and types match
|
|
26
|
-
// https://github.com/tari-project/tari.js/issues/25
|
|
27
27
|
network,
|
|
28
28
|
account_id: accountId,
|
|
29
29
|
instructions: transaction.instructions as object[],
|
|
@@ -40,12 +40,12 @@ export function buildTransactionRequest(
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export async function submitAndWaitForTransaction(
|
|
43
|
-
|
|
43
|
+
signer: TariSigner,
|
|
44
44
|
req: SubmitTransactionRequest,
|
|
45
45
|
): Promise<SubmitTxResult> {
|
|
46
46
|
try {
|
|
47
|
-
const response = await
|
|
48
|
-
const result = await waitForTransactionResult(
|
|
47
|
+
const response = await signer.submitTransaction(req);
|
|
48
|
+
const result = await waitForTransactionResult(signer, response.transaction_id);
|
|
49
49
|
|
|
50
50
|
return {
|
|
51
51
|
response,
|
|
@@ -57,12 +57,12 @@ export async function submitAndWaitForTransaction(
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export async function waitForTransactionResult(
|
|
60
|
-
|
|
60
|
+
signer: TariSigner | TariUniverseSigner,
|
|
61
61
|
transactionId: string,
|
|
62
62
|
): Promise<TransactionResult> {
|
|
63
63
|
// eslint-disable-next-line no-constant-condition
|
|
64
64
|
while (true) {
|
|
65
|
-
const resp = await
|
|
65
|
+
const resp = await signer.getTransactionResult(transactionId);
|
|
66
66
|
const FINALIZED_STATUSES = [
|
|
67
67
|
TransactionStatus.Accepted,
|
|
68
68
|
TransactionStatus.Rejected,
|
|
@@ -75,7 +75,7 @@ export async function waitForTransactionResult(
|
|
|
75
75
|
throw new Error(`Transaction rejected: ${JSON.stringify(resp.result)}`);
|
|
76
76
|
}
|
|
77
77
|
if (FINALIZED_STATUSES.includes(resp.status)) {
|
|
78
|
-
return resp as
|
|
78
|
+
return resp as TransactionResult;
|
|
79
79
|
}
|
|
80
80
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
81
81
|
}
|
|
@@ -13,24 +13,23 @@ import {
|
|
|
13
13
|
Transaction,
|
|
14
14
|
TransactionSignature,
|
|
15
15
|
UnsignedTransaction,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
PublishedTemplateAddress,
|
|
17
|
+
TransactionArg,
|
|
18
18
|
} from "@tari-project/tarijs-types";
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
export interface TransactionConstructor {
|
|
22
|
-
new(unsignedTransaction: UnsignedTransaction, signatures: TransactionSignature[]): Transaction;
|
|
21
|
+
new (unsignedTransaction: UnsignedTransaction, signatures: TransactionSignature[]): Transaction;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
export interface TariFunctionDefinition {
|
|
26
25
|
functionName: string;
|
|
27
|
-
args?:
|
|
28
|
-
templateAddress:
|
|
26
|
+
args?: TransactionArg[];
|
|
27
|
+
templateAddress: PublishedTemplateAddress;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
export interface TariMethodDefinition {
|
|
32
31
|
methodName: string;
|
|
33
|
-
args?:
|
|
32
|
+
args?: TransactionArg[];
|
|
34
33
|
componentAddress: ComponentAddress;
|
|
35
34
|
}
|
|
36
35
|
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
Instruction,
|
|
4
4
|
SubstateRequirement,
|
|
5
5
|
Transaction,
|
|
6
|
-
TransactionId,
|
|
7
6
|
TransactionSignature,
|
|
8
7
|
UnsignedTransaction,
|
|
9
8
|
VersionedSubstateId,
|
|
@@ -12,7 +11,7 @@ import {
|
|
|
12
11
|
///TODO this implementation is not fully done, see:
|
|
13
12
|
/// https://github.com/tari-project/tari-dan/blob/development/dan_layer/transaction/src/transaction.rs
|
|
14
13
|
export class TransactionRequest implements Transaction {
|
|
15
|
-
id:
|
|
14
|
+
id: string;
|
|
16
15
|
feeInstructions: Array<Instruction>;
|
|
17
16
|
instructions: Array<Instruction>;
|
|
18
17
|
inputs: Array<SubstateRequirement>;
|
|
@@ -23,7 +22,7 @@ export class TransactionRequest implements Transaction {
|
|
|
23
22
|
filledInputs: VersionedSubstateId[];
|
|
24
23
|
|
|
25
24
|
constructor(unsignedTransaction: UnsignedTransaction, signatures: TransactionSignature[]) {
|
|
26
|
-
this.id =
|
|
25
|
+
this.id = "";
|
|
27
26
|
this.feeInstructions = unsignedTransaction.feeInstructions;
|
|
28
27
|
this.instructions = unsignedTransaction.instructions;
|
|
29
28
|
this.inputs = unsignedTransaction.inputs;
|
|
@@ -34,23 +33,10 @@ export class TransactionRequest implements Transaction {
|
|
|
34
33
|
this.filledInputs = [];
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
private calculateHash(): TransactionId {
|
|
38
|
-
return "";
|
|
39
|
-
}
|
|
40
|
-
|
|
41
36
|
withFilledInputs(filled_inputs: Array<VersionedSubstateId>): this {
|
|
42
37
|
return { ...this, filled_inputs };
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
getId(): TransactionId {
|
|
46
|
-
return this.id;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
checkId(): boolean {
|
|
50
|
-
const id = this.calculateHash();
|
|
51
|
-
return id === this.id;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
40
|
getUnsignedTransaction(): UnsignedTransaction {
|
|
55
41
|
return this.unsignedTransaction;
|
|
56
42
|
}
|
|
@@ -67,10 +53,6 @@ export class TransactionRequest implements Transaction {
|
|
|
67
53
|
return this.signatures;
|
|
68
54
|
}
|
|
69
55
|
|
|
70
|
-
getHash(): string {
|
|
71
|
-
return this.id;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
56
|
getInputs(): SubstateRequirement[] {
|
|
75
57
|
return this.inputs;
|
|
76
58
|
}
|
|
@@ -90,4 +72,12 @@ export class TransactionRequest implements Transaction {
|
|
|
90
72
|
getMaxEpoch(): Epoch | undefined {
|
|
91
73
|
return this.maxEpoch;
|
|
92
74
|
}
|
|
75
|
+
|
|
76
|
+
setId(id: string): void {
|
|
77
|
+
this.id = id;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
getId(): string {
|
|
81
|
+
return this.id;
|
|
82
|
+
}
|
|
93
83
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tari-project/indexer-provider",
|
|
3
|
+
"version": "0.5.1",
|
|
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-permissions": "workspace:^",
|
|
17
|
+
"@tari-project/tari-provider": "workspace:^",
|
|
18
|
+
"@tari-project/tarijs-types": "workspace:^",
|
|
19
|
+
"@tari-project/typescript-bindings": "catalog:",
|
|
20
|
+
"@tari-project/wallet_jrpc_client": "catalog:"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "catalog:",
|
|
24
|
+
"typescript": "catalog:"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"/dist"
|
|
28
|
+
],
|
|
29
|
+
"main": "dist/index.js",
|
|
30
|
+
"types": "dist/index.d.ts"
|
|
31
|
+
}
|