@tari-project/tarijs 0.10.1 → 0.12.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/README.md +127 -67
- package/TODO.md +91 -3
- package/docusaurus/tari-docs/README.md +200 -17
- package/docusaurus/tari-docs/docs/api-reference.md +665 -0
- package/docusaurus/tari-docs/docs/contributing.md +619 -0
- package/docusaurus/tari-docs/docs/guides/getting-started-tutorial.md +965 -0
- package/docusaurus/tari-docs/docs/guides/production-deployment.md +977 -0
- package/docusaurus/tari-docs/docs/index.md +114 -11
- package/docusaurus/tari-docs/docs/installation.md +142 -1
- package/docusaurus/tari-docs/docs/signers/metamask.md +529 -0
- package/docusaurus/tari-docs/docs/troubleshooting.md +661 -0
- package/docusaurus/tari-docs/package.json +4 -4
- package/eslint.config.mjs +9 -0
- package/examples/vite-typescript-react/README.md +9 -0
- package/examples/vite-typescript-react/eslint.config.js +23 -0
- package/examples/vite-typescript-react/index.html +13 -0
- package/examples/vite-typescript-react/package.json +35 -0
- package/examples/vite-typescript-react/public/vite.svg +1 -0
- package/examples/vite-typescript-react/src/App.css +42 -0
- package/examples/vite-typescript-react/src/App.tsx +50 -0
- package/examples/vite-typescript-react/src/assets/react.svg +1 -0
- package/examples/vite-typescript-react/src/index.css +68 -0
- package/examples/vite-typescript-react/src/main.tsx +10 -0
- package/examples/vite-typescript-react/src/vite-env.d.ts +1 -0
- package/examples/vite-typescript-react/tsconfig.app.json +27 -0
- package/examples/vite-typescript-react/tsconfig.json +7 -0
- package/examples/vite-typescript-react/tsconfig.node.json +25 -0
- package/examples/vite-typescript-react/vite.config.ts +7 -0
- package/package.json +16 -3
- package/packages/builders/package.json +2 -2
- package/packages/builders/src/helpers/submitTransaction.ts +10 -35
- package/packages/builders/src/transaction/TransactionBuilder.ts +227 -29
- package/packages/indexer_provider/package.json +2 -2
- package/packages/indexer_provider/src/provider.ts +5 -5
- package/packages/indexer_provider/tsconfig.json +4 -2
- package/packages/metamask_signer/package.json +2 -2
- package/packages/metamask_signer/src/index.ts +3 -15
- package/packages/{tari_permissions → permissions}/package.json +2 -2
- package/packages/{tari_permissions → permissions}/src/helpers.ts +1 -1
- package/packages/permissions/src/index.ts +2 -0
- package/packages/{tari_permissions/src/tari_permissions.ts → permissions/src/permissions.ts} +56 -6
- package/packages/react-mui-connect-button/moon.yml +71 -0
- package/packages/react-mui-connect-button/package.json +40 -0
- package/packages/react-mui-connect-button/src/Logos.tsx +60 -0
- package/packages/react-mui-connect-button/src/TariConnectButton.tsx +51 -0
- package/packages/react-mui-connect-button/src/TariWalletSelectionDialog.tsx +116 -0
- package/packages/react-mui-connect-button/src/content/tari-logo-white.svg +18 -0
- package/packages/react-mui-connect-button/src/content/tari-logo.svg +18 -0
- package/packages/react-mui-connect-button/src/content/walletconnect-logo.svg +13 -0
- package/packages/react-mui-connect-button/src/defaultPermissions.ts +0 -0
- package/packages/react-mui-connect-button/src/index.ts +24 -0
- package/packages/react-mui-connect-button/tsconfig.json +31 -0
- package/packages/tari_provider/package.json +2 -2
- package/packages/tari_provider/src/TariProvider.ts +6 -1
- package/packages/tari_signer/package.json +2 -2
- package/packages/tari_universe/package.json +2 -2
- package/packages/tari_universe/tsconfig.json +4 -2
- package/packages/tarijs/package.json +2 -2
- package/packages/tarijs/src/index.ts +27 -49
- package/packages/tarijs/src/templates/Account.ts +7 -4
- package/packages/tarijs/test/integration-tests/.env +1 -1
- package/packages/tarijs/test/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +112 -73
- package/packages/tarijs/tsconfig.json +6 -4
- package/packages/tarijs/vitest.config.ts +2 -1
- package/packages/tarijs_types/package.json +4 -3
- package/packages/tarijs_types/src/Account.ts +68 -0
- package/packages/tarijs_types/src/Amount.ts +5 -1
- package/packages/tarijs_types/src/TransactionResult.ts +1 -8
- package/packages/tarijs_types/src/consts.ts +3 -0
- package/packages/tarijs_types/src/helpers/index.ts +4 -0
- package/packages/tarijs_types/src/helpers/simpleResult.ts +345 -0
- package/packages/tarijs_types/src/helpers/txResult.ts +1 -2
- package/packages/tarijs_types/src/index.ts +8 -0
- package/packages/tarijs_types/src/signer.ts +1 -1
- package/packages/wallet_daemon/package.json +2 -2
- package/packages/wallet_daemon/src/provider.ts +8 -6
- package/packages/wallet_daemon/src/signer.ts +18 -8
- package/packages/wallet_daemon/tsconfig.json +1 -1
- package/packages/walletconnect/package.json +3 -2
- package/packages/walletconnect/src/index.ts +54 -28
- package/packages/walletconnect/tsconfig.json +3 -0
- package/pnpm-workspace.yaml +15 -7
- package/scripts/check_versions.sh +4 -0
- package/scripts/clean_everything.sh +38 -0
- package/tsconfig.json +6 -0
- package/typedoc.json +10 -0
- package/packages/tari_permissions/src/index.ts +0 -2
- /package/packages/{tari_permissions → permissions}/moon.yml +0 -0
- /package/packages/{tari_permissions → permissions}/tsconfig.json +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export { TariConnectButton, TariConnectButtonProps } from "./TariConnectButton";
|
|
2
|
+
export { TariWalletSelectionDialog, WalletSelectionProps } from "./TariWalletSelectionDialog";
|
|
3
|
+
import {
|
|
4
|
+
TariPermissionAccountInfo,
|
|
5
|
+
TariPermissionKeyList,
|
|
6
|
+
TariPermissions, TariPermissionSubstatesRead, TariPermissionTemplatesRead, TariPermissionTransactionSend,
|
|
7
|
+
TariPermissionTransactionsGet,
|
|
8
|
+
} from "@tari-project/tari-permissions";
|
|
9
|
+
|
|
10
|
+
export function defaultPermissions() {
|
|
11
|
+
// Minimal permissions for the example site
|
|
12
|
+
// But each application will have different permission needs
|
|
13
|
+
const walletDaemonPermissions = new TariPermissions();
|
|
14
|
+
walletDaemonPermissions
|
|
15
|
+
// Required for createFreeTestCoins
|
|
16
|
+
.addPermission("Admin")
|
|
17
|
+
.addPermission(new TariPermissionKeyList())
|
|
18
|
+
.addPermission(new TariPermissionAccountInfo())
|
|
19
|
+
.addPermission(new TariPermissionTransactionsGet())
|
|
20
|
+
.addPermission(new TariPermissionSubstatesRead())
|
|
21
|
+
.addPermission(new TariPermissionTemplatesRead())
|
|
22
|
+
.addPermission(new TariPermissionTransactionSend());
|
|
23
|
+
return walletDaemonPermissions;
|
|
24
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"jsx": "react-jsx",
|
|
5
|
+
"module": "ES2020",
|
|
6
|
+
"target": "ESNext",
|
|
7
|
+
"moduleResolution": "Bundler",
|
|
8
|
+
"outDir": "./dist",
|
|
9
|
+
"rootDir": "./src"
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"src/**/*"
|
|
13
|
+
],
|
|
14
|
+
"references": [
|
|
15
|
+
{
|
|
16
|
+
"path": "../permissions"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "../tari_provider"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "../tari_signer"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"path": "../wallet_daemon"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "../walletconnect"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tari-provider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"build": "tsc -b"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [],
|
|
13
|
-
"author": "",
|
|
13
|
+
"author": "The Tari Community",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@tari-project/typescript-bindings": "catalog:",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { GetTemplateDefinitionResponse, ListTemplatesResponse } from "@tari-project/typescript-bindings";
|
|
2
2
|
import {
|
|
3
3
|
GetTransactionResultResponse,
|
|
4
|
-
TemplateDefinition,
|
|
5
4
|
Substate,
|
|
6
5
|
ListSubstatesResponse,
|
|
7
6
|
GetSubstateRequest,
|
|
@@ -10,10 +9,16 @@ import {
|
|
|
10
9
|
|
|
11
10
|
export interface TariProvider {
|
|
12
11
|
providerName: string;
|
|
12
|
+
|
|
13
13
|
isConnected(): boolean;
|
|
14
|
+
|
|
14
15
|
getSubstate(req: GetSubstateRequest): Promise<Substate>;
|
|
16
|
+
|
|
15
17
|
getTransactionResult(transactionId: string): Promise<GetTransactionResultResponse>;
|
|
18
|
+
|
|
16
19
|
getTemplateDefinition(template_address: string): Promise<GetTemplateDefinitionResponse>;
|
|
20
|
+
|
|
17
21
|
listSubstates(req: ListSubstatesRequest): Promise<ListSubstatesResponse>;
|
|
22
|
+
|
|
18
23
|
listTemplates(limit?: number): Promise<ListTemplatesResponse>;
|
|
19
24
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tari-signer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"build": "tsc -b"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [],
|
|
13
|
-
"author": "",
|
|
13
|
+
"author": "The Tari Community",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@tari-project/tarijs-types": "workspace:^",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tari-universe-signer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"build": "tsc -b"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [],
|
|
13
|
-
"author": "",
|
|
13
|
+
"author": "The Tari Community",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@tari-project/tari-permissions": "workspace:^",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tarijs-all",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"integration-tests": "vitest run integration-tests"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [],
|
|
15
|
-
"author": "",
|
|
15
|
+
"author": "The Tari Community",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@metamask/providers": "catalog:",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export { MetaMaskInpageProvider } from "@metamask/providers";
|
|
2
|
+
export { TariSigner } from "@tari-project/tari-signer";
|
|
3
|
+
export { TariProvider } from "@tari-project/tari-provider";
|
|
4
|
+
export { MetamaskTariSigner } from "@tari-project/metamask-signer";
|
|
5
|
+
export {
|
|
6
6
|
WalletDaemonTariSigner,
|
|
7
7
|
WalletDaemonParameters,
|
|
8
8
|
WalletDaemonFetchParameters,
|
|
@@ -10,16 +10,16 @@ import {
|
|
|
10
10
|
TariPermissions,
|
|
11
11
|
WalletDaemonTariProvider,
|
|
12
12
|
} from "@tari-project/wallet-daemon-signer";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export { TariUniverseSigner, TariUniverseSignerParameters } from "@tari-project/tari-universe-signer";
|
|
14
|
+
export { WalletConnectTariSigner } from "@tari-project/wallet-connect-signer";
|
|
15
|
+
export {
|
|
16
16
|
TransactionBuilder,
|
|
17
17
|
TransactionRequest,
|
|
18
18
|
buildTransactionRequest,
|
|
19
19
|
submitAndWaitForTransaction,
|
|
20
20
|
waitForTransactionResult,
|
|
21
21
|
} from "@tari-project/tarijs-builders";
|
|
22
|
-
|
|
22
|
+
export {
|
|
23
23
|
convertStringToTransactionStatus,
|
|
24
24
|
convertHexStringToU256Array,
|
|
25
25
|
convertU256ToHexString,
|
|
@@ -39,50 +39,28 @@ import {
|
|
|
39
39
|
parseCbor,
|
|
40
40
|
getCborValueByPath,
|
|
41
41
|
} from "@tari-project/tarijs-types";
|
|
42
|
-
|
|
42
|
+
export { IndexerProvider, IndexerProviderParameters } from "@tari-project/indexer-provider";
|
|
43
|
+
export {
|
|
44
|
+
Amount,
|
|
45
|
+
BuiltInAccount,
|
|
46
|
+
VaultSubstate,
|
|
47
|
+
TransactionArg,
|
|
48
|
+
ConfidentialClaim,
|
|
49
|
+
ConfidentialOutput,
|
|
50
|
+
ConfidentialWithdrawProof,
|
|
51
|
+
SubstateType,
|
|
52
|
+
SimpleTransactionResult,
|
|
53
|
+
SimpleSubstateDiff,
|
|
54
|
+
AnySubstate,
|
|
55
|
+
DownSubstate,
|
|
56
|
+
UpSubstate,
|
|
57
|
+
TransactionSignature,
|
|
58
|
+
} from "@tari-project/tarijs-types";
|
|
59
|
+
|
|
43
60
|
import * as templates from "./templates";
|
|
44
61
|
import * as permissions from "@tari-project/tari-permissions";
|
|
45
62
|
|
|
46
|
-
export * from "@tari-project/tarijs-types";
|
|
47
63
|
export {
|
|
48
64
|
permissions,
|
|
49
65
|
templates,
|
|
50
|
-
Network,
|
|
51
|
-
TariSigner,
|
|
52
|
-
TariProvider,
|
|
53
|
-
AccountData,
|
|
54
|
-
TransactionStatus,
|
|
55
|
-
GetTransactionResultResponse,
|
|
56
|
-
SubmitTransactionRequest,
|
|
57
|
-
VaultBalances,
|
|
58
|
-
VaultData,
|
|
59
|
-
TemplateDefinition,
|
|
60
|
-
MetamaskTariSigner,
|
|
61
|
-
WalletDaemonTariSigner,
|
|
62
|
-
WalletDaemonTariProvider,
|
|
63
|
-
WalletDaemonParameters,
|
|
64
|
-
WalletDaemonFetchParameters,
|
|
65
|
-
WalletDaemonBaseParameters,
|
|
66
|
-
TariUniverseSigner,
|
|
67
|
-
TariUniverseSignerParameters,
|
|
68
|
-
TariPermissions,
|
|
69
|
-
MetaMaskInpageProvider,
|
|
70
|
-
Substate,
|
|
71
|
-
WalletConnectTariSigner,
|
|
72
|
-
TransactionBuilder,
|
|
73
|
-
TransactionRequest,
|
|
74
|
-
IndexerProvider,
|
|
75
|
-
IndexerProviderParameters,
|
|
76
|
-
convertStringToTransactionStatus,
|
|
77
|
-
buildTransactionRequest,
|
|
78
|
-
submitAndWaitForTransaction,
|
|
79
|
-
waitForTransactionResult,
|
|
80
|
-
convertHexStringToU256Array,
|
|
81
|
-
convertU256ToHexString,
|
|
82
|
-
createNftAddressFromResource,
|
|
83
|
-
createNftAddressFromToken,
|
|
84
|
-
parseCbor,
|
|
85
|
-
getCborValueByPath,
|
|
86
|
-
fromHexString,
|
|
87
|
-
toHexString,
|
|
88
66
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ConfidentialWithdrawProof, NonFungibleId, ResourceAddress } from "@tari-project/typescript-bindings";
|
|
2
2
|
import { Amount } from "@tari-project/tarijs-types";
|
|
3
|
-
import { TariMethodDefinition, WorkspaceArg
|
|
3
|
+
import { TariMethodDefinition, WorkspaceArg } from "@tari-project/tarijs-builders";
|
|
4
4
|
import { TemplateFactory } from "./TemplateFactory";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Adds a fee instruction that calls the "
|
|
7
|
+
* Adds a fee instruction that calls the "pay_fee" method on a component.
|
|
8
8
|
* This method must exist and return a Bucket with containing revealed confidential XTR resource.
|
|
9
9
|
* This allows the fee to originate from sources other than the transaction sender's account.
|
|
10
10
|
* The fee instruction will lock up the "max_fee" amount for the duration of the transaction.
|
|
@@ -16,8 +16,9 @@ interface PayFeeMethod extends TariMethodDefinition {
|
|
|
16
16
|
methodName: "pay_fee";
|
|
17
17
|
args?: [Amount];
|
|
18
18
|
}
|
|
19
|
+
|
|
19
20
|
// /**
|
|
20
|
-
// * Adds a fee instruction that calls the "
|
|
21
|
+
// * Adds a fee instruction that calls the "pay_fee_confidential" method on a component.
|
|
21
22
|
// * This method must exist and return a Bucket with containing revealed confidential XTR resource.
|
|
22
23
|
// * This allows the fee to originate from sources other than the transaction sender's account.
|
|
23
24
|
// * @param componentAddress
|
|
@@ -81,7 +82,9 @@ export class AccountTemplate extends TemplateFactory {
|
|
|
81
82
|
this._initMethods();
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
protected _initFunctions(): void {
|
|
85
|
+
protected _initFunctions(): void {
|
|
86
|
+
}
|
|
87
|
+
|
|
85
88
|
protected _initMethods(): void {
|
|
86
89
|
this.deposit = this._defineMethod<DepositMethod>("deposit");
|
|
87
90
|
this.withdraw = this._defineMethod<WithdrawMethod>("withdraw");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
WALLET_DAEMON_JSON_RPC_URL=http://127.0.0.1:
|
|
1
|
+
WALLET_DAEMON_JSON_RPC_URL=http://127.0.0.1:12008/json_rpc
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { assert, describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
2
|
import {
|
|
4
|
-
Amount,
|
|
5
|
-
buildTransactionRequest,
|
|
6
|
-
Network,
|
|
7
|
-
submitAndWaitForTransaction,
|
|
8
|
-
SubmitTransactionRequest,
|
|
9
3
|
TariPermissions,
|
|
10
4
|
TransactionBuilder,
|
|
11
|
-
TransactionStatus,
|
|
12
|
-
waitForTransactionResult,
|
|
13
5
|
WalletDaemonTariSigner,
|
|
6
|
+
Amount, Network, SubmitTransactionRequest, TransactionStatus,
|
|
7
|
+
submitAndWaitForTransaction,
|
|
8
|
+
buildTransactionRequest,
|
|
9
|
+
waitForTransactionResult,
|
|
14
10
|
} from "../../../src";
|
|
15
|
-
import { Instruction
|
|
11
|
+
import { Instruction } from "@tari-project/typescript-bindings";
|
|
12
|
+
import { XTR } from "@tari-project/tarijs-types";
|
|
16
13
|
|
|
17
14
|
function buildSigner(): Promise<WalletDaemonTariSigner> {
|
|
18
15
|
const permissions = new TariPermissions().addPermission("Admin");
|
|
@@ -81,10 +78,14 @@ describe("WalletDaemonTariSigner", () => {
|
|
|
81
78
|
const signer = await buildSigner();
|
|
82
79
|
|
|
83
80
|
const id = "d5f5a26e7272b1bba7bed331179e555e28c40d92ba3cde1e9ba2b4316e50f486";
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
try {
|
|
82
|
+
const txResult = await signer.getTransactionResult(id);
|
|
83
|
+
expect(txResult).toMatchObject({
|
|
84
|
+
transaction_id: id,
|
|
85
|
+
});
|
|
86
|
+
} catch (e) {
|
|
87
|
+
console.warn("Skipping getTransactionResult test, transaction not found", e);
|
|
88
|
+
}
|
|
88
89
|
});
|
|
89
90
|
});
|
|
90
91
|
|
|
@@ -98,7 +99,7 @@ describe("WalletDaemonTariSigner", () => {
|
|
|
98
99
|
const fee_instructions = [
|
|
99
100
|
{
|
|
100
101
|
CallMethod: {
|
|
101
|
-
|
|
102
|
+
call: { Address: account.address },
|
|
102
103
|
method: "pay_fee",
|
|
103
104
|
args: [`Amount(${fee})`],
|
|
104
105
|
},
|
|
@@ -157,34 +158,80 @@ describe("WalletDaemonTariSigner", () => {
|
|
|
157
158
|
expect(txResult.status).toEqual(TransactionStatus.DryRun);
|
|
158
159
|
});
|
|
159
160
|
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
|
|
162
|
+
it("creates an account", async () => {
|
|
162
163
|
const signer = await buildSigner();
|
|
163
164
|
const account = await signer.getAccount();
|
|
164
|
-
const
|
|
165
|
+
const nextKey = await signer.newTransactionKey();
|
|
165
166
|
|
|
166
|
-
const fee = new
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
const fee = Amount.new(2000);
|
|
168
|
+
const transaction1 = TransactionBuilder
|
|
169
|
+
.new(Network.LocalNet)
|
|
170
|
+
.feeTransactionPayFromComponent(account.address, fee)
|
|
171
|
+
.createAccount(nextKey)
|
|
172
|
+
.buildUnsignedTransaction();
|
|
170
173
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
methodName: "withdraw",
|
|
175
|
-
},
|
|
176
|
-
[xtrAddress, 10],
|
|
174
|
+
const submitTransactionRequest1 = buildTransactionRequest(
|
|
175
|
+
transaction1,
|
|
176
|
+
account.account_id,
|
|
177
177
|
);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
178
|
+
|
|
179
|
+
const txResult1 = await submitAndWaitForTransaction(signer, submitTransactionRequest1);
|
|
180
|
+
expect(txResult1.status).toBe(TransactionStatus.Accepted);
|
|
181
|
+
const newAccountId = txResult1.getResultingAccounts()[0].substate_id;
|
|
182
|
+
|
|
183
|
+
const transaction = TransactionBuilder
|
|
184
|
+
.new(Network.LocalNet)
|
|
185
|
+
.feeTransactionPayFromComponent(account.address, fee)
|
|
186
|
+
.callMethod({ componentAddress: account.address, methodName: "withdraw" }, [XTR, 10])
|
|
187
|
+
.saveVar("bucket")
|
|
188
|
+
.callMethod(
|
|
189
|
+
{ componentAddress: newAccountId, methodName: "deposit" },
|
|
190
|
+
[{ Workspace: "bucket" }],
|
|
191
|
+
)
|
|
192
|
+
.buildUnsignedTransaction();
|
|
193
|
+
|
|
194
|
+
const submitTransactionRequest = buildTransactionRequest(
|
|
195
|
+
transaction,
|
|
196
|
+
account.account_id,
|
|
185
197
|
);
|
|
186
|
-
|
|
187
|
-
const
|
|
198
|
+
|
|
199
|
+
const txResult = await submitAndWaitForTransaction(signer, submitTransactionRequest);
|
|
200
|
+
const vaults = txResult.getResultingVaults();
|
|
201
|
+
expect(vaults.length).toBe(2); // Original vault + new vault
|
|
202
|
+
// Find the vault not in the fee account
|
|
203
|
+
const vault = vaults.find((v) => !account.vaults.some((av) => v.id == av.vault_id));
|
|
204
|
+
expect(vault).toBeDefined();
|
|
205
|
+
expect(vault!.balance.value).toBe(BigInt(10));
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it("submits a transaction, that uses workspaces", async () => {
|
|
209
|
+
const signer = await buildSigner();
|
|
210
|
+
const account = await signer.getAccount();
|
|
211
|
+
const xtrAddress = account.vaults[0].resource_address;
|
|
212
|
+
|
|
213
|
+
const fee = new Amount(2000);
|
|
214
|
+
const network = Network.LocalNet;
|
|
215
|
+
const transaction = TransactionBuilder
|
|
216
|
+
.new(network)
|
|
217
|
+
.feeTransactionPayFromComponent(account.address, fee)
|
|
218
|
+
.callMethod(
|
|
219
|
+
{
|
|
220
|
+
componentAddress: account.address,
|
|
221
|
+
methodName: "withdraw",
|
|
222
|
+
},
|
|
223
|
+
[xtrAddress, 10],
|
|
224
|
+
)
|
|
225
|
+
.saveVar("bucket")
|
|
226
|
+
.callMethod(
|
|
227
|
+
{
|
|
228
|
+
componentAddress: account.address,
|
|
229
|
+
methodName: "deposit",
|
|
230
|
+
},
|
|
231
|
+
[{ Workspace: "bucket" }],
|
|
232
|
+
)
|
|
233
|
+
.addInput({ substate_id: account.address, version: null })
|
|
234
|
+
.buildUnsignedTransaction();
|
|
188
235
|
|
|
189
236
|
const submitTransactionRequest = buildTransactionRequest(
|
|
190
237
|
transaction,
|
|
@@ -192,7 +239,7 @@ describe("WalletDaemonTariSigner", () => {
|
|
|
192
239
|
);
|
|
193
240
|
|
|
194
241
|
const txResult = await submitAndWaitForTransaction(signer, submitTransactionRequest);
|
|
195
|
-
expect(txResult.
|
|
242
|
+
expect(txResult.status).toBe(TransactionStatus.Accepted);
|
|
196
243
|
});
|
|
197
244
|
});
|
|
198
245
|
|
|
@@ -216,7 +263,7 @@ describe("WalletDaemonTariSigner", () => {
|
|
|
216
263
|
expect(accountBalances.balances.length).toBeGreaterThan(0);
|
|
217
264
|
|
|
218
265
|
expect(accountBalances.balances[0]).toMatchObject({
|
|
219
|
-
balance: expect.any(
|
|
266
|
+
balance: expect.any(String),
|
|
220
267
|
resource_address: expect.any(String),
|
|
221
268
|
resource_type: expect.any(String),
|
|
222
269
|
token_symbol: expect.any(String),
|
|
@@ -271,7 +318,11 @@ describe("WalletDaemonTariSigner", () => {
|
|
|
271
318
|
});
|
|
272
319
|
|
|
273
320
|
const substateWithTemplate = substates.find((substate) => substate.template_address);
|
|
274
|
-
|
|
321
|
+
if (!substateWithTemplate) {
|
|
322
|
+
// This depends on a certain setup - so if we dont have this precondition, we skip the test
|
|
323
|
+
console.warn("No substate with template found, skipping test");
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
275
326
|
|
|
276
327
|
const templateAddress = substateWithTemplate.template_address;
|
|
277
328
|
const { substates: filteredSubstates } = await signer.listSubstates({
|
|
@@ -302,32 +353,22 @@ describe("WalletDaemonTariSigner", () => {
|
|
|
302
353
|
const signer = await buildSigner();
|
|
303
354
|
const account = await signer.getAccount();
|
|
304
355
|
|
|
305
|
-
const fee = new
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
356
|
+
const fee = Amount.new(2000);
|
|
357
|
+
const transaction = TransactionBuilder.new(Network.LocalNet)
|
|
358
|
+
.feeTransactionPayFromComponent(account.address, fee)
|
|
359
|
+
.allocateAddress("Component", "id-1")
|
|
360
|
+
.buildUnsignedTransaction();
|
|
310
361
|
|
|
311
|
-
const isDryRun = false;
|
|
312
|
-
const inputRefs = undefined;
|
|
313
|
-
const network = Network.LocalNet;
|
|
314
|
-
const requiredSubstates = [{ substate_id: account.address }];
|
|
315
362
|
const submitTransactionRequest = buildTransactionRequest(
|
|
316
363
|
transaction,
|
|
317
364
|
account.account_id,
|
|
318
|
-
requiredSubstates,
|
|
319
|
-
inputRefs,
|
|
320
|
-
isDryRun,
|
|
321
|
-
network,
|
|
322
365
|
);
|
|
323
366
|
|
|
324
367
|
const txResult = await submitAndWaitForTransaction(signer, submitTransactionRequest);
|
|
325
368
|
|
|
326
|
-
expect(txResult.
|
|
369
|
+
expect(txResult.status).toBe(TransactionStatus.OnlyFeeAccepted);
|
|
327
370
|
|
|
328
|
-
const
|
|
329
|
-
const reason =
|
|
330
|
-
executionResult && "AcceptFeeRejectRest" in executionResult && executionResult.AcceptFeeRejectRest[1];
|
|
371
|
+
const reason = txResult.anyRejectReason.unwrap();
|
|
331
372
|
const failure = reason && typeof reason === "object" && "ExecutionFailure" in reason && reason.ExecutionFailure;
|
|
332
373
|
expect(failure).toEqual("1 dangling address allocations remain after transaction execution");
|
|
333
374
|
});
|
|
@@ -339,33 +380,31 @@ describe("WalletDaemonTariSigner", () => {
|
|
|
339
380
|
const account = await signer.getAccount();
|
|
340
381
|
|
|
341
382
|
const fee = new Amount(2000);
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
383
|
+
const transaction = TransactionBuilder.new(Network.LocalNet)
|
|
384
|
+
.feeTransactionPayFromComponent(account.address, fee)
|
|
385
|
+
// Have to use add instruction to submit the transaction since this error is caught by the builder
|
|
386
|
+
// .assertBucketContains("not_exist", "resource_0000000000000000000000000000000000000000000000000000000000000000", Amount.new(1))
|
|
387
|
+
.addInstruction({
|
|
388
|
+
AssertBucketContains: {
|
|
389
|
+
key: { id: 123, offset: null },
|
|
390
|
+
resource_address: "resource_0000000000000000000000000000000000000000000000000000000000000000",
|
|
391
|
+
min_amount: 1,
|
|
392
|
+
},
|
|
393
|
+
})
|
|
394
|
+
.buildUnsignedTransaction();
|
|
346
395
|
|
|
347
|
-
const isDryRun = false;
|
|
348
|
-
const inputRefs = undefined;
|
|
349
|
-
const network = Network.LocalNet;
|
|
350
|
-
const requiredSubstates = [{ substate_id: account.address }];
|
|
351
396
|
const submitTransactionRequest = buildTransactionRequest(
|
|
352
397
|
transaction,
|
|
353
398
|
account.account_id,
|
|
354
|
-
requiredSubstates,
|
|
355
|
-
inputRefs,
|
|
356
|
-
isDryRun,
|
|
357
|
-
network,
|
|
358
399
|
);
|
|
359
400
|
|
|
360
401
|
const txResult = await submitAndWaitForTransaction(signer, submitTransactionRequest);
|
|
361
402
|
|
|
362
|
-
expect(txResult.
|
|
403
|
+
expect(txResult.status).toBe(TransactionStatus.OnlyFeeAccepted);
|
|
363
404
|
|
|
364
|
-
const
|
|
365
|
-
const reason =
|
|
366
|
-
executionResult && "AcceptFeeRejectRest" in executionResult && executionResult.AcceptFeeRejectRest[1];
|
|
405
|
+
const reason = txResult.anyRejectReason.unwrap();
|
|
367
406
|
const failure = reason && typeof reason === "object" && "ExecutionFailure" in reason && reason.ExecutionFailure;
|
|
368
|
-
expect(failure).toContain("Item at id
|
|
407
|
+
expect(failure).toContain("Item at id 123 does not exist on the workspace (existing ids: [])");
|
|
369
408
|
});
|
|
370
409
|
});
|
|
371
410
|
});
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"module": "
|
|
5
|
-
"target": "
|
|
4
|
+
"module": "ES2022",
|
|
5
|
+
"target": "ES2022",
|
|
6
6
|
"moduleResolution": "Bundler",
|
|
7
7
|
"outDir": "./dist",
|
|
8
8
|
"rootDir": "./src"
|
|
9
9
|
},
|
|
10
|
-
"include": [
|
|
10
|
+
"include": [
|
|
11
|
+
"src/**/*"
|
|
12
|
+
],
|
|
11
13
|
"references": [
|
|
12
14
|
{
|
|
13
15
|
"path": "../builders"
|
|
@@ -19,7 +21,7 @@
|
|
|
19
21
|
"path": "../metamask_signer"
|
|
20
22
|
},
|
|
21
23
|
{
|
|
22
|
-
"path": "../
|
|
24
|
+
"path": "../permissions"
|
|
23
25
|
},
|
|
24
26
|
{
|
|
25
27
|
"path": "../tari_provider"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tarijs-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
"build": "tsc -b"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [],
|
|
13
|
-
"author": "",
|
|
13
|
+
"author": "The Tari Community",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@tari-project/typescript-bindings": "catalog:"
|
|
16
|
+
"@tari-project/typescript-bindings": "catalog:",
|
|
17
|
+
"@thames/monads": "^0.7.0"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
20
|
"@types/node": "catalog:",
|