@tari-project/tarijs 0.5.0 → 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 -4
- package/docusaurus/tari-docs/docs/providers/indexer-provider.md +3 -3
- package/docusaurus/tari-docs/package.json +1 -1
- package/package.json +1 -1
- package/packages/builders/package.json +2 -3
- package/packages/builders/src/helpers/submitTransaction.ts +5 -5
- package/packages/builders/src/transaction/TransactionBuilder.ts +6 -7
- package/packages/builders/src/transaction/TransactionRequest.ts +10 -20
- package/packages/indexer_provider/package.json +1 -1
- package/packages/indexer_provider/src/provider.ts +10 -10
- package/packages/metamask_signer/package.json +1 -1
- package/packages/metamask_signer/src/index.ts +34 -27
- package/packages/tari_permissions/package.json +1 -1
- package/packages/tari_provider/package.json +3 -2
- package/packages/tari_provider/src/TariProvider.ts +5 -5
- package/packages/tari_provider/src/index.ts +0 -1
- package/packages/tari_provider/tsconfig.json +9 -2
- package/packages/tari_signer/package.json +1 -1
- package/packages/tari_signer/src/TariSigner.ts +13 -18
- package/packages/tari_signer/src/index.ts +0 -1
- package/packages/tari_universe/package.json +1 -1
- package/packages/tari_universe/src/signer.ts +23 -28
- package/packages/tari_universe/src/types.ts +0 -5
- package/packages/tarijs/package.json +1 -1
- package/packages/tarijs/src/index.ts +12 -14
- 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 +11 -4
- package/packages/tarijs_types/src/index.ts +28 -10
- package/packages/{tari_provider/src/types.ts → tarijs_types/src/signer.ts} +26 -49
- package/packages/wallet_daemon/package.json +1 -1
- package/packages/wallet_daemon/src/signer.ts +33 -32
- package/packages/walletconnect/package.json +1 -1
- package/packages/walletconnect/src/index.ts +33 -33
- package/packages/tari_signer/src/types.ts +0 -84
- 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/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
|
@@ -2,7 +2,3 @@
|
|
|
2
2
|
|
|
3
3
|
- For the example site:
|
|
4
4
|
- The `TariConnect` button could be made into a reusable React component, ready to be imported by any web.
|
|
5
|
-
- Typescript-bindings
|
|
6
|
-
- [Types refactor and cleanup](https://github.com/tari-project/tari.js/issues/29)
|
|
7
|
-
- Other
|
|
8
|
-
- Configure prettier to not change entire file while saving
|
|
@@ -9,18 +9,18 @@ This provider is designed to provide connection to the blockchain, whch can be u
|
|
|
9
9
|
## Install required dependencies
|
|
10
10
|
|
|
11
11
|
```bash npm2yarn
|
|
12
|
-
npm install @tari-project/
|
|
12
|
+
npm install @tari-project/indexer-provider @tari-project/tari-permissions
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Establish the connection
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
|
+
import { IndexerProvider, IndexerProviderParameters } from "@tari-project/indexer-provider";
|
|
18
19
|
import { TariPermissions } from "@tari-project/tari-permissions";
|
|
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 indexerJrpcUrl = "http://127.0.0.1:12006/json_rpc";
|
|
23
|
+
const indexerJrpcUrl = "http://127.0.0.1:12006/json_rpc"; // example url
|
|
24
24
|
|
|
25
25
|
const params: IndexerProviderParameters = {
|
|
26
26
|
indexerJrpcUrl: indexerJrpcUrl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tarijs-builders",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@tari-project/tari-signer": "workspace:^",
|
|
17
17
|
"@tari-project/tari-universe-signer": "workspace:^",
|
|
18
|
-
"@tari-project/tarijs-types": "workspace:^"
|
|
19
|
-
"@tari-project/typescript-bindings": "catalog:"
|
|
18
|
+
"@tari-project/tarijs-types": "workspace:^"
|
|
20
19
|
},
|
|
21
20
|
"devDependencies": {
|
|
22
21
|
"@types/node": "catalog:",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TariUniverseSigner } from "@tari-project/tari-universe-signer";
|
|
2
|
-
import { TariSigner
|
|
2
|
+
import { TariSigner } from "@tari-project/tari-signer";
|
|
3
3
|
import {
|
|
4
4
|
Transaction,
|
|
5
5
|
TransactionResult,
|
|
@@ -9,12 +9,14 @@ import {
|
|
|
9
9
|
FinalizeResultStatus,
|
|
10
10
|
TxResultAccept,
|
|
11
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[],
|
|
@@ -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
|
}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GetSubstateRequest,
|
|
3
|
-
ListSubstatesRequest,
|
|
4
|
-
ListSubstatesResponse,
|
|
5
|
-
Substate,
|
|
6
|
-
TariProvider,
|
|
7
|
-
TransactionResult,
|
|
8
|
-
} from "@tari-project/tari-provider";
|
|
1
|
+
import { TariProvider } from "@tari-project/tari-provider";
|
|
9
2
|
import { TariPermissions } from "@tari-project/tari-permissions";
|
|
10
3
|
import { IndexerProviderClient } from "./transports";
|
|
11
4
|
import {
|
|
@@ -15,7 +8,14 @@ import {
|
|
|
15
8
|
substateIdToString,
|
|
16
9
|
SubstatesListRequest,
|
|
17
10
|
} from "@tari-project/typescript-bindings";
|
|
18
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
convertStringToTransactionStatus,
|
|
13
|
+
GetSubstateRequest,
|
|
14
|
+
GetTransactionResultResponse,
|
|
15
|
+
ListSubstatesRequest,
|
|
16
|
+
ListSubstatesResponse,
|
|
17
|
+
Substate,
|
|
18
|
+
} from "@tari-project/tarijs-types";
|
|
19
19
|
|
|
20
20
|
export interface IndexerProviderParameters {
|
|
21
21
|
indexerJrpcUrl: string;
|
|
@@ -88,7 +88,7 @@ export class IndexerProvider implements TariProvider {
|
|
|
88
88
|
return resp;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
public async getTransactionResult(transactionId: string): Promise<
|
|
91
|
+
public async getTransactionResult(transactionId: string): Promise<GetTransactionResultResponse> {
|
|
92
92
|
const resp = await this.client.getTransactionResult({ transaction_id: transactionId });
|
|
93
93
|
|
|
94
94
|
return {
|
|
@@ -8,11 +8,18 @@ import {
|
|
|
8
8
|
TemplateDefinition,
|
|
9
9
|
Substate,
|
|
10
10
|
ListSubstatesResponse,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
AccountData,
|
|
12
|
+
ListSubstatesRequest,
|
|
13
|
+
GetTransactionResultResponse,
|
|
14
|
+
} from "@tari-project/tarijs-types";
|
|
13
15
|
import { MetaMaskInpageProvider } from "@metamask/providers";
|
|
14
16
|
import { connectSnap, getSnap, isFlask, Snap } from "./utils";
|
|
15
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
ConfidentialViewVaultBalanceRequest,
|
|
19
|
+
ListAccountNftRequest,
|
|
20
|
+
ListAccountNftResponse,
|
|
21
|
+
SubstateType,
|
|
22
|
+
} from "@tari-project/typescript-bindings";
|
|
16
23
|
|
|
17
24
|
export const MetamaskNotInstalled = "METAMASK_NOT_INSTALLED";
|
|
18
25
|
export const MetamaskIsNotFlask = "METAMASK_IS_NOT_FLASK";
|
|
@@ -64,7 +71,7 @@ export class MetamaskTariSigner implements TariSigner {
|
|
|
64
71
|
return this.metamaskConnected;
|
|
65
72
|
}
|
|
66
73
|
|
|
67
|
-
public async createFreeTestCoins(account_id: number): Promise<
|
|
74
|
+
public async createFreeTestCoins(account_id: number): Promise<AccountData> {
|
|
68
75
|
const res = (await this.metamaskRequest("getFreeTestCoins", {
|
|
69
76
|
amount: 1000000,
|
|
70
77
|
account_id,
|
|
@@ -78,7 +85,7 @@ export class MetamaskTariSigner implements TariSigner {
|
|
|
78
85
|
};
|
|
79
86
|
}
|
|
80
87
|
|
|
81
|
-
async getAccount(): Promise<
|
|
88
|
+
async getAccount(): Promise<AccountData> {
|
|
82
89
|
return (await this.metamaskRequest("getAccountData", { account_id: 0 })) as any;
|
|
83
90
|
}
|
|
84
91
|
|
|
@@ -91,12 +98,12 @@ export class MetamaskTariSigner implements TariSigner {
|
|
|
91
98
|
return { value: substate, address: { substate_id, version } };
|
|
92
99
|
}
|
|
93
100
|
|
|
94
|
-
async listSubstates(
|
|
95
|
-
filter_by_template
|
|
96
|
-
filter_by_type
|
|
97
|
-
limit
|
|
98
|
-
offset
|
|
99
|
-
): Promise<ListSubstatesResponse> {
|
|
101
|
+
async listSubstates({
|
|
102
|
+
filter_by_template,
|
|
103
|
+
filter_by_type,
|
|
104
|
+
limit,
|
|
105
|
+
offset,
|
|
106
|
+
}: ListSubstatesRequest): Promise<ListSubstatesResponse> {
|
|
100
107
|
const res = (await this.metamaskRequest("listSubstates", {
|
|
101
108
|
filter_by_template,
|
|
102
109
|
filter_by_type,
|
|
@@ -126,7 +133,7 @@ export class MetamaskTariSigner implements TariSigner {
|
|
|
126
133
|
return { transaction_id: resp.transaction_id };
|
|
127
134
|
}
|
|
128
135
|
|
|
129
|
-
public async getTransactionResult(transactionId: string): Promise<
|
|
136
|
+
public async getTransactionResult(transactionId: string): Promise<GetTransactionResultResponse> {
|
|
130
137
|
// This request returns the response from the indexer get_transaction_result request
|
|
131
138
|
const resp: Maybe<any> = await this.metamaskRequest("getTransactionResult", { transaction_id: transactionId });
|
|
132
139
|
|
|
@@ -139,7 +146,7 @@ export class MetamaskTariSigner implements TariSigner {
|
|
|
139
146
|
transaction_id: transactionId,
|
|
140
147
|
status: TransactionStatus.Pending,
|
|
141
148
|
result: null,
|
|
142
|
-
} as
|
|
149
|
+
} as GetTransactionResultResponse;
|
|
143
150
|
}
|
|
144
151
|
|
|
145
152
|
if (!resp?.result?.Finalized) {
|
|
@@ -152,7 +159,7 @@ export class MetamaskTariSigner implements TariSigner {
|
|
|
152
159
|
transaction_id: transactionId,
|
|
153
160
|
status: newStatus,
|
|
154
161
|
result: resp.result.Finalized.execution_result.finalize,
|
|
155
|
-
} as
|
|
162
|
+
} as GetTransactionResultResponse;
|
|
156
163
|
}
|
|
157
164
|
|
|
158
165
|
public async getPublicKey(_branch: string, index: number): Promise<string> {
|
|
@@ -165,20 +172,20 @@ export class MetamaskTariSigner implements TariSigner {
|
|
|
165
172
|
return resp.public_key;
|
|
166
173
|
}
|
|
167
174
|
|
|
168
|
-
public async getConfidentialVaultBalances(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
): Promise<VaultBalances> {
|
|
174
|
-
const
|
|
175
|
-
view_key_id
|
|
176
|
-
vault_id
|
|
177
|
-
minimum_expected_value
|
|
178
|
-
maximum_expected_value
|
|
179
|
-
})
|
|
175
|
+
public async getConfidentialVaultBalances({
|
|
176
|
+
vault_id,
|
|
177
|
+
maximum_expected_value,
|
|
178
|
+
minimum_expected_value,
|
|
179
|
+
view_key_id,
|
|
180
|
+
}: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances> {
|
|
181
|
+
const resp = await this.metamaskRequest("getConfidentialVaultBalances", {
|
|
182
|
+
view_key_id,
|
|
183
|
+
vault_id,
|
|
184
|
+
minimum_expected_value,
|
|
185
|
+
maximum_expected_value,
|
|
186
|
+
});
|
|
180
187
|
|
|
181
|
-
return { balances:
|
|
188
|
+
return { balances: resp as Map<string, number | null> };
|
|
182
189
|
}
|
|
183
190
|
|
|
184
191
|
getTemplateDefinition(template_address: string): Promise<TemplateDefinition> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tari-provider",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@tari-project/typescript-bindings": "catalog:"
|
|
16
|
+
"@tari-project/typescript-bindings": "catalog:",
|
|
17
|
+
"@tari-project/tarijs-types": "workspace:^"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
20
|
"@types/node": "catalog:",
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type { ListTemplatesResponse } from "@tari-project/typescript-bindings";
|
|
1
|
+
import type { GetTemplateDefinitionResponse, ListTemplatesResponse } from "@tari-project/typescript-bindings";
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
GetTransactionResultResponse,
|
|
4
4
|
TemplateDefinition,
|
|
5
5
|
Substate,
|
|
6
6
|
ListSubstatesResponse,
|
|
7
7
|
GetSubstateRequest,
|
|
8
8
|
ListSubstatesRequest,
|
|
9
|
-
} from "
|
|
9
|
+
} from "@tari-project/tarijs-types";
|
|
10
10
|
|
|
11
11
|
export interface TariProvider {
|
|
12
12
|
providerName: string;
|
|
13
13
|
isConnected(): boolean;
|
|
14
14
|
getSubstate(req: GetSubstateRequest): Promise<Substate>;
|
|
15
|
-
getTransactionResult(transactionId: string): Promise<
|
|
16
|
-
getTemplateDefinition(template_address: string): Promise<
|
|
15
|
+
getTransactionResult(transactionId: string): Promise<GetTransactionResultResponse>;
|
|
16
|
+
getTemplateDefinition(template_address: string): Promise<GetTemplateDefinitionResponse>;
|
|
17
17
|
listSubstates(req: ListSubstatesRequest): Promise<ListSubstatesResponse>;
|
|
18
18
|
listTemplates(limit?: number): Promise<ListTemplatesResponse>;
|
|
19
19
|
}
|
|
@@ -1,35 +1,30 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ConfidentialViewVaultBalanceRequest,
|
|
3
|
+
ListAccountNftRequest,
|
|
4
|
+
ListAccountNftResponse,
|
|
5
|
+
} from "@tari-project/typescript-bindings";
|
|
2
6
|
import {
|
|
3
|
-
|
|
7
|
+
GetTransactionResultResponse,
|
|
8
|
+
AccountData,
|
|
4
9
|
SubmitTransactionRequest,
|
|
5
|
-
TransactionResult,
|
|
6
10
|
SubmitTransactionResponse,
|
|
7
11
|
VaultBalances,
|
|
8
12
|
TemplateDefinition,
|
|
9
13
|
Substate,
|
|
10
14
|
ListSubstatesResponse,
|
|
11
|
-
|
|
15
|
+
ListSubstatesRequest,
|
|
16
|
+
} from "@tari-project/tarijs-types";
|
|
12
17
|
|
|
13
18
|
export interface TariSigner {
|
|
14
19
|
signerName: string;
|
|
15
20
|
isConnected(): boolean;
|
|
16
|
-
getAccount(): Promise<
|
|
21
|
+
getAccount(): Promise<AccountData>;
|
|
17
22
|
getSubstate(substate_address: string): Promise<Substate>;
|
|
18
23
|
submitTransaction(req: SubmitTransactionRequest): Promise<SubmitTransactionResponse>;
|
|
19
|
-
getTransactionResult(transactionId: string): Promise<
|
|
24
|
+
getTransactionResult(transactionId: string): Promise<GetTransactionResultResponse>;
|
|
20
25
|
getTemplateDefinition(template_address: string): Promise<TemplateDefinition>;
|
|
21
26
|
getPublicKey(branch: string, index: number): Promise<string>;
|
|
22
|
-
getConfidentialVaultBalances(
|
|
23
|
-
|
|
24
|
-
vaultId: string,
|
|
25
|
-
min: number | null,
|
|
26
|
-
max: number | null,
|
|
27
|
-
): Promise<VaultBalances>;
|
|
28
|
-
listSubstates(
|
|
29
|
-
filter_by_template: string | null,
|
|
30
|
-
filter_by_type: SubstateType | null,
|
|
31
|
-
limit: number | null,
|
|
32
|
-
offset: number | null,
|
|
33
|
-
): Promise<ListSubstatesResponse>;
|
|
27
|
+
getConfidentialVaultBalances(req: ConfidentialViewVaultBalanceRequest): Promise<VaultBalances>;
|
|
28
|
+
listSubstates(req: ListSubstatesRequest): Promise<ListSubstatesResponse>;
|
|
34
29
|
getNftsList(req: ListAccountNftRequest): Promise<ListAccountNftResponse>;
|
|
35
30
|
}
|