@tari-project/tarijs 0.5.5 → 0.8.0
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/PULL_REQUEST_TEMPLATE.md +2 -12
- package/.github/workflows/check-package-versions.yml +22 -0
- package/Dockerfile +2 -2
- package/README.md +1 -1
- package/docusaurus/tari-docs/docs/provider-vs-signer.md +27 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/inputs.md +0 -1
- package/docusaurus/tari-docs/package-lock.json +17964 -0
- package/docusaurus/tari-docs/package.json +2 -2
- package/package.json +1 -1
- package/packages/builders/package.json +3 -2
- package/packages/builders/src/helpers/index.ts +1 -1
- package/packages/builders/src/helpers/workspace.ts +32 -22
- package/packages/builders/src/index.ts +1 -2
- package/packages/builders/src/transaction/TransactionBuilder.ts +105 -38
- package/packages/builders/src/transaction/TransactionRequest.ts +36 -33
- package/packages/indexer_provider/package.json +1 -1
- package/packages/metamask_signer/package.json +1 -1
- package/packages/metamask_signer/src/index.ts +1 -1
- package/packages/tari_permissions/package.json +1 -1
- package/packages/tari_permissions/src/tari_permissions.ts +1 -17
- package/packages/tari_provider/package.json +1 -1
- package/packages/tari_signer/package.json +1 -1
- package/packages/tari_universe/package.json +1 -1
- package/packages/tarijs/package.json +1 -1
- package/packages/tarijs/src/index.ts +0 -4
- package/packages/tarijs/test/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +80 -1
- package/packages/tarijs_types/package.json +1 -1
- package/packages/tarijs_types/src/Instruction.ts +7 -3
- package/packages/tarijs_types/src/SubstateType.ts +1 -1
- package/packages/tarijs_types/src/Workspace.ts +1 -1
- package/packages/wallet_daemon/package.json +1 -1
- package/packages/wallet_daemon/src/signer.ts +1 -0
- package/packages/walletconnect/package.json +1 -1
- package/packages/walletconnect/src/index.ts +1 -0
- package/pnpm-workspace.yaml +2 -2
- package/scripts/check_versions.sh +42 -0
- package/scripts/set_package_versions.sh +39 -0
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
waitForTransactionResult,
|
|
13
13
|
WalletDaemonTariSigner,
|
|
14
14
|
} from "../../../src";
|
|
15
|
-
import { inspect } from "util";
|
|
16
15
|
|
|
17
16
|
function buildSigner(): Promise<WalletDaemonTariSigner> {
|
|
18
17
|
const permissions = new TariPermissions().addPermission("Admin");
|
|
@@ -156,6 +155,50 @@ describe("WalletDaemonTariSigner", () => {
|
|
|
156
155
|
|
|
157
156
|
expect(txResult.status).toEqual(TransactionStatus.DryRun);
|
|
158
157
|
});
|
|
158
|
+
|
|
159
|
+
it("submits a transaction, that uses workspaces", async () => {
|
|
160
|
+
const workspaceId = "bucket";
|
|
161
|
+
const signer = await buildSigner();
|
|
162
|
+
const account = await signer.getAccount();
|
|
163
|
+
const xtrAddress = account.resources[0].resource_address;
|
|
164
|
+
|
|
165
|
+
const fee = new Amount(2000);
|
|
166
|
+
const builder = new TransactionBuilder();
|
|
167
|
+
builder.feeTransactionPayFromComponent(account.address, fee.getStringValue());
|
|
168
|
+
|
|
169
|
+
builder.callMethod(
|
|
170
|
+
{
|
|
171
|
+
componentAddress: account.address,
|
|
172
|
+
methodName: "withdraw",
|
|
173
|
+
},
|
|
174
|
+
[xtrAddress, 10],
|
|
175
|
+
);
|
|
176
|
+
builder.saveVar(workspaceId);
|
|
177
|
+
builder.callMethod(
|
|
178
|
+
{
|
|
179
|
+
componentAddress: account.address,
|
|
180
|
+
methodName: "deposit",
|
|
181
|
+
},
|
|
182
|
+
[workspaceId],
|
|
183
|
+
);
|
|
184
|
+
const transaction = builder.build();
|
|
185
|
+
|
|
186
|
+
const isDryRun = false;
|
|
187
|
+
const inputRefs = undefined;
|
|
188
|
+
const network = Network.LocalNet;
|
|
189
|
+
const requiredSubstates = [{ substate_id: account.address }];
|
|
190
|
+
const submitTransactionRequest = buildTransactionRequest(
|
|
191
|
+
transaction,
|
|
192
|
+
account.account_id,
|
|
193
|
+
requiredSubstates,
|
|
194
|
+
inputRefs,
|
|
195
|
+
isDryRun,
|
|
196
|
+
network,
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const txResult = await submitAndWaitForTransaction(signer, submitTransactionRequest);
|
|
200
|
+
expect(txResult.result.status).toBe(TransactionStatus.Accepted);
|
|
201
|
+
});
|
|
159
202
|
});
|
|
160
203
|
|
|
161
204
|
describe("getAccountBalances", () => {
|
|
@@ -294,4 +337,40 @@ describe("WalletDaemonTariSigner", () => {
|
|
|
294
337
|
expect(failure).toEqual("1 dangling address allocations remain after transaction execution");
|
|
295
338
|
});
|
|
296
339
|
});
|
|
340
|
+
|
|
341
|
+
describe("assertBucketContains", () => {
|
|
342
|
+
it("fails if bucket does not exist", async () => {
|
|
343
|
+
const signer = await buildSigner();
|
|
344
|
+
const account = await signer.getAccount();
|
|
345
|
+
|
|
346
|
+
const fee = new Amount(2000);
|
|
347
|
+
const builder = new TransactionBuilder();
|
|
348
|
+
builder.feeTransactionPayFromComponent(account.address, fee.getStringValue());
|
|
349
|
+
builder.assertBucketContains("not_exist", "resource_0000000000000000000000000000000000000000000000000000000000000000", Amount.newAmount(1));
|
|
350
|
+
const transaction = builder.build();
|
|
351
|
+
|
|
352
|
+
const isDryRun = false;
|
|
353
|
+
const inputRefs = undefined;
|
|
354
|
+
const network = Network.LocalNet;
|
|
355
|
+
const requiredSubstates = [{ substate_id: account.address }];
|
|
356
|
+
const submitTransactionRequest = buildTransactionRequest(
|
|
357
|
+
transaction,
|
|
358
|
+
account.account_id,
|
|
359
|
+
requiredSubstates,
|
|
360
|
+
inputRefs,
|
|
361
|
+
isDryRun,
|
|
362
|
+
network,
|
|
363
|
+
);
|
|
364
|
+
|
|
365
|
+
const txResult = await submitAndWaitForTransaction(signer, submitTransactionRequest);
|
|
366
|
+
|
|
367
|
+
expect(txResult.result.status).toBe(TransactionStatus.OnlyFeeAccepted);
|
|
368
|
+
|
|
369
|
+
const executionResult = txResult.result.result?.result;
|
|
370
|
+
const reason =
|
|
371
|
+
executionResult && "AcceptFeeRejectRest" in executionResult && executionResult.AcceptFeeRejectRest[1];
|
|
372
|
+
const failure = reason && typeof reason === "object" && "ExecutionFailure" in reason && reason.ExecutionFailure;
|
|
373
|
+
expect(failure).toContain("Item at id 0 does not exist on the workspace");
|
|
374
|
+
});
|
|
375
|
+
});
|
|
297
376
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentAddress, LogLevel, PublishedTemplateAddress, SubstateType } from "@tari-project/typescript-bindings";
|
|
1
|
+
import { ComponentAddress, ResourceAddress, LogLevel, PublishedTemplateAddress, SubstateType, WorkspaceOffsetId } from "@tari-project/typescript-bindings";
|
|
2
2
|
import { TransactionArg } from "./TransactionArg";
|
|
3
3
|
import { ConfidentialClaim } from "./ConfidentialClaim";
|
|
4
4
|
import { Amount } from "./Amount";
|
|
@@ -14,7 +14,8 @@ export type Instruction =
|
|
|
14
14
|
| ClaimValidatorFees
|
|
15
15
|
| DropAllProofsInWorkspace
|
|
16
16
|
| CreateFreeTestCoins
|
|
17
|
-
| AllocateAddress
|
|
17
|
+
| AllocateAddress
|
|
18
|
+
| AssertBucketContains;
|
|
18
19
|
|
|
19
20
|
export type CreateAccount = { CreateAccount: { owner_public_key: string; workspace_bucket: string | null } };
|
|
20
21
|
export type CallFunction = {
|
|
@@ -23,7 +24,7 @@ export type CallFunction = {
|
|
|
23
24
|
export type CallMethod = {
|
|
24
25
|
CallMethod: { component_address: ComponentAddress; method: string; args: Array<TransactionArg> };
|
|
25
26
|
};
|
|
26
|
-
export type PutLastInstructionOutputOnWorkspace = { PutLastInstructionOutputOnWorkspace: { key:
|
|
27
|
+
export type PutLastInstructionOutputOnWorkspace = { PutLastInstructionOutputOnWorkspace: { key: string } };
|
|
27
28
|
export type EmitLog = { EmitLog: { level: LogLevel; message: string } };
|
|
28
29
|
export type ClaimBurn = { ClaimBurn: { claim: ConfidentialClaim } };
|
|
29
30
|
export type ClaimValidatorFees = { ClaimValidatorFees: { epoch: number; validator_public_key: string } };
|
|
@@ -34,3 +35,6 @@ export type CreateFreeTestCoins = {
|
|
|
34
35
|
export type AllocateAddress = {
|
|
35
36
|
AllocateAddress: { substate_type: SubstateType; workspace_id: string };
|
|
36
37
|
};
|
|
38
|
+
export type AssertBucketContains = {
|
|
39
|
+
AssertBucketContains: { key: WorkspaceOffsetId; resource_address: ResourceAddress; min_amount: Amount };
|
|
40
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type SubstateType = "Component" | "Resource" | "Vault" | "UnclaimedConfidentialOutput" | "NonFungible" | "TransactionReceipt" | "
|
|
1
|
+
export type SubstateType = "Component" | "Resource" | "Vault" | "UnclaimedConfidentialOutput" | "NonFungible" | "TransactionReceipt" | "ValidatorFeePool" | "Template";
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -8,8 +8,8 @@ catalog:
|
|
|
8
8
|
vitest: ^3.0.4
|
|
9
9
|
vite: ^6.1.0
|
|
10
10
|
"@types/node": ^22.13.1
|
|
11
|
-
"@tari-project/typescript-bindings":
|
|
12
|
-
"@tari-project/wallet_jrpc_client": ^1.
|
|
11
|
+
"@tari-project/typescript-bindings": ">=1.9.0"
|
|
12
|
+
"@tari-project/wallet_jrpc_client": ^1.6.0
|
|
13
13
|
"@metamask/providers": ^18.2.0
|
|
14
14
|
"@walletconnect/universal-provider": ^2.13.3
|
|
15
15
|
"@walletconnect/modal": ^2.6.2
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
IFS=$'\n\t'
|
|
4
|
+
|
|
5
|
+
echo "Finding all package.json files and extracting versions..."
|
|
6
|
+
|
|
7
|
+
declare -a versions
|
|
8
|
+
|
|
9
|
+
# Find all package.json files, excluding node_modules, and extract the version
|
|
10
|
+
while IFS= read -r file; do
|
|
11
|
+
version=$(jq -r '.version' "$file")
|
|
12
|
+
if [[ -z "$version" || "$version" == "null" ]]; then
|
|
13
|
+
echo "::error::Could not find 'version' field in $file"
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
16
|
+
echo "Found version '$version' in $file"
|
|
17
|
+
versions+=("$version")
|
|
18
|
+
done < <(find . -name 'package.json' -not -path '*/node_modules/*')
|
|
19
|
+
|
|
20
|
+
if [ ${#versions[@]} -eq 0 ]; then
|
|
21
|
+
echo "Error: No package.json files with a 'version' field were found."
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
reference_version=${versions[0]}
|
|
26
|
+
echo "Reference version: $reference_version"
|
|
27
|
+
|
|
28
|
+
all_same=true
|
|
29
|
+
for version in "${versions[@]}"; do
|
|
30
|
+
if [ "$version" != "$reference_version" ]; then
|
|
31
|
+
echo "Error: Mismatched version found! '$version' does not match '$reference_version'."
|
|
32
|
+
all_same=false
|
|
33
|
+
break
|
|
34
|
+
fi
|
|
35
|
+
done
|
|
36
|
+
|
|
37
|
+
if [ "$all_same" = false ]; then
|
|
38
|
+
echo "❌ ::error::All package.json versions are NOT the same. Please unify them."
|
|
39
|
+
exit 1
|
|
40
|
+
else
|
|
41
|
+
echo "✅ All package.json versions are consistent: $reference_version"
|
|
42
|
+
fi
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# This script sets the package versions in all package.json files for the workspace.
|
|
5
|
+
|
|
6
|
+
# Usage: ./scripts/set_package_versions.sh <version>
|
|
7
|
+
if [ "$#" -ne 1 ]; then
|
|
8
|
+
echo "Usage: $0 <version>"
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
gitroot=$(git rev-parse --show-toplevel)
|
|
13
|
+
|
|
14
|
+
VERSION=$1
|
|
15
|
+
# Find all package.json files in the workspace
|
|
16
|
+
pushd "${gitroot}/packages" > /dev/null
|
|
17
|
+
find . -depth -maxdepth 2 -name 'package.json' | while read -r package_json; do
|
|
18
|
+
# Update the version in the package.json file
|
|
19
|
+
jq --arg version "$VERSION" '.version = $version' "$package_json" > "$package_json.tmp" && mv "$package_json.tmp" "$package_json"
|
|
20
|
+
echo "Updated version in $package_json to $VERSION"
|
|
21
|
+
done
|
|
22
|
+
popd > /dev/null
|
|
23
|
+
|
|
24
|
+
pushd "${gitroot}/docusaurus/tari-docs" > /dev/null
|
|
25
|
+
jq --arg version "$VERSION" '.version = $version' package.json > package.json.tmp && mv package.json.tmp package.json
|
|
26
|
+
echo "Updated docusaurus package.json version to $VERSION"
|
|
27
|
+
popd > /dev/null
|
|
28
|
+
|
|
29
|
+
pushd "${gitroot}" > /dev/null
|
|
30
|
+
# Update the version in the root package.json
|
|
31
|
+
jq --arg version "$VERSION" '.version = $version' package.json > package.json.tmp && mv package.json.tmp package.json
|
|
32
|
+
echo "Updated root package.json version to $VERSION"
|
|
33
|
+
|
|
34
|
+
pnpm install
|
|
35
|
+
|
|
36
|
+
echo "Running check_versions script to verify versions..."
|
|
37
|
+
./scripts/check_versions.sh
|
|
38
|
+
popd > /dev/null
|
|
39
|
+
|