@tari-project/tarijs 0.4.1 → 0.5.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/workflows/ci.yml +2 -1
- package/.github/workflows/documentation-deploy.yml +44 -0
- package/.github/workflows/documentation-test-deploy.yml +20 -0
- package/.moon/workspace.yml +1 -0
- package/README.md +19 -0
- package/TODO.md +2 -6
- package/docusaurus/tari-docs/README.md +41 -0
- package/docusaurus/tari-docs/docs/index.md +21 -0
- package/docusaurus/tari-docs/docs/installation.md +27 -0
- package/docusaurus/tari-docs/docs/providers/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/providers/indexer-provider.md +32 -0
- package/docusaurus/tari-docs/docs/signers/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/signers/tari-universe.md +27 -0
- package/docusaurus/tari-docs/docs/signers/wallet-connect.md +51 -0
- package/docusaurus/tari-docs/docs/signers/wallet-daemon.md +37 -0
- package/docusaurus/tari-docs/docs/wallet/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/wallet/default-account.md +51 -0
- package/docusaurus/tari-docs/docs/wallet/get-substate.md +110 -0
- package/docusaurus/tari-docs/docs/wallet/list-substates.md +68 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/build-execute-request.md +38 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/index.md +14 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-function.md +17 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-method.md +17 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/fee.md +28 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/index.md +426 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/inputs.md +24 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/instruction.md +108 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/min-max-epoch.md +19 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/raw-instructions.md +16 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/save-var.md +63 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/transaction-internals.md +20 -0
- package/docusaurus/tari-docs/docs/wallet/template-definition.md +101 -0
- package/docusaurus/tari-docs/docusaurus.config.ts +108 -0
- package/docusaurus/tari-docs/moon.yml +41 -0
- package/docusaurus/tari-docs/package.json +49 -0
- package/docusaurus/tari-docs/sidebars.ts +7 -0
- package/docusaurus/tari-docs/src/components/HomepageFeatures/index.tsx +69 -0
- package/docusaurus/tari-docs/src/components/HomepageFeatures/styles.module.css +11 -0
- package/docusaurus/tari-docs/src/css/custom.css +30 -0
- package/docusaurus/tari-docs/src/pages/index.module.css +23 -0
- package/docusaurus/tari-docs/src/pages/index.tsx +44 -0
- package/docusaurus/tari-docs/static/.nojekyll +0 -0
- package/docusaurus/tari-docs/static/img/favicon.png +0 -0
- package/docusaurus/tari-docs/static/img/meta-image.png +0 -0
- package/docusaurus/tari-docs/static/img/tari/wallet-connect-1.png +0 -0
- package/docusaurus/tari-docs/static/img/tari/wallet-connect-2.png +0 -0
- package/docusaurus/tari-docs/static/img/tari/wallet-connect-3.png +0 -0
- package/docusaurus/tari-docs/static/img/tari-logo.svg +30 -0
- package/docusaurus/tari-docs/tsconfig.json +10 -0
- package/package.json +1 -1
- package/packages/builders/package.json +3 -3
- package/packages/builders/src/helpers/submitTransaction.ts +8 -8
- 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 +11 -6
- 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 +1 -1
- package/packages/tari_provider/src/TariProvider.ts +7 -23
- package/packages/tari_provider/src/index.ts +1 -2
- package/packages/tari_provider/src/types.ts +38 -24
- package/packages/tari_signer/moon.yml +55 -0
- package/packages/tari_signer/package.json +28 -0
- package/packages/tari_signer/src/TariSigner.ts +35 -0
- package/packages/tari_signer/src/index.ts +2 -0
- package/packages/tari_signer/src/types.ts +84 -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} +32 -33
- package/packages/tari_universe/src/types.ts +15 -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/moon.yml +8 -0
- package/packages/tarijs/package.json +9 -6
- package/packages/tarijs/src/cbor.spec.ts +259 -0
- package/packages/tarijs/src/cbor.ts +114 -0
- package/packages/tarijs/src/index.ts +31 -15
- package/packages/tarijs/tsconfig.json +7 -1
- package/packages/tarijs_types/package.json +1 -1
- package/packages/tarijs_types/src/helpers/index.ts +62 -0
- package/packages/tarijs_types/src/index.ts +12 -1
- 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} +45 -47
- package/packages/wallet_daemon/tsconfig.json +4 -1
- package/packages/walletconnect/package.json +4 -3
- package/packages/walletconnect/src/index.ts +42 -43
- package/packages/walletconnect/tsconfig.json +4 -1
- package/pnpm-workspace.yaml +4 -3
- package/tsconfig.json +11 -2
- /package/packages/{metamask_provider → indexer_provider}/moon.yml +0 -0
- /package/packages/{metamask_provider → metamask_signer}/src/utils.ts +0 -0
|
@@ -6,25 +6,30 @@ import {
|
|
|
6
6
|
VaultBalances,
|
|
7
7
|
ListSubstatesResponse,
|
|
8
8
|
SubmitTransactionRequest,
|
|
9
|
-
|
|
10
|
-
TransactionResult
|
|
11
|
-
} from "@tari-project/tari-
|
|
9
|
+
TariSigner,
|
|
10
|
+
TransactionResult,
|
|
11
|
+
} from "@tari-project/tari-signer";
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
SignerRequest,
|
|
14
|
+
SignerMethodNames,
|
|
15
|
+
SignerReturnType,
|
|
16
|
+
TariUniverseSignerParameters,
|
|
17
17
|
WindowSize,
|
|
18
|
+
ListAccountNftFromBalancesRequest,
|
|
18
19
|
} from "./types";
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
import {
|
|
21
|
+
AccountsGetBalancesResponse,
|
|
22
|
+
ListAccountNftRequest,
|
|
23
|
+
ListAccountNftResponse,
|
|
24
|
+
SubstateType,
|
|
25
|
+
} from "@tari-project/wallet_jrpc_client";
|
|
26
|
+
import { sendSignerCall } from "./utils";
|
|
27
|
+
|
|
28
|
+
export class TariUniverseSigner implements TariSigner {
|
|
29
|
+
public signerName = "TariUniverse";
|
|
25
30
|
private __id = 0;
|
|
26
31
|
|
|
27
|
-
public constructor(public params:
|
|
32
|
+
public constructor(public params: TariUniverseSignerParameters) {
|
|
28
33
|
const filterResizeEvent = function (event: MessageEvent) {
|
|
29
34
|
if (event.data && event.data.type === "resize") {
|
|
30
35
|
const resizeEvent = new CustomEvent("resize", {
|
|
@@ -36,11 +41,11 @@ export class TariUniverseProvider implements TariProvider {
|
|
|
36
41
|
window.addEventListener("message", (event) => filterResizeEvent(event), false);
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
private async sendRequest<MethodName extends
|
|
40
|
-
req: Omit<
|
|
41
|
-
): Promise<
|
|
44
|
+
private async sendRequest<MethodName extends SignerMethodNames>(
|
|
45
|
+
req: Omit<SignerRequest<MethodName>, "id">,
|
|
46
|
+
): Promise<SignerReturnType<MethodName>> {
|
|
42
47
|
const id = ++this.__id;
|
|
43
|
-
return
|
|
48
|
+
return sendSignerCall(req, id);
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
public isConnected(): boolean {
|
|
@@ -84,21 +89,7 @@ export class TariUniverseProvider implements TariProvider {
|
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
public async getAccount(): Promise<Account> {
|
|
87
|
-
|
|
88
|
-
const { balances } = await this.getAccountBalances(address);
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
account_id,
|
|
92
|
-
address,
|
|
93
|
-
public_key,
|
|
94
|
-
resources: balances.map((b: any) => ({
|
|
95
|
-
type: b.resource_type,
|
|
96
|
-
resource_address: b.resource_address,
|
|
97
|
-
balance: b.balance + b.confidential_balance,
|
|
98
|
-
vault_id: "Vault" in b.vault_address ? b.vault_address.Vault : b.vault_address,
|
|
99
|
-
token_symbol: b.token_symbol,
|
|
100
|
-
})),
|
|
101
|
-
};
|
|
92
|
+
return this.sendRequest({ methodName: "getAccount", args: [] });
|
|
102
93
|
}
|
|
103
94
|
|
|
104
95
|
public async getAccountBalances(componentAddress: string): Promise<AccountsGetBalancesResponse> {
|
|
@@ -132,4 +123,12 @@ export class TariUniverseProvider implements TariProvider {
|
|
|
132
123
|
public async getTemplateDefinition(template_address: string): Promise<TemplateDefinition> {
|
|
133
124
|
return this.sendRequest({ methodName: "getTemplateDefinition", args: [template_address] });
|
|
134
125
|
}
|
|
126
|
+
|
|
127
|
+
public async getNftsList(req: ListAccountNftRequest): Promise<ListAccountNftResponse> {
|
|
128
|
+
return this.sendRequest({ methodName: "getNftsList", args: [req] });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public async getNftsFromAccountBalances(req: ListAccountNftFromBalancesRequest): Promise<ListAccountNftResponse> {
|
|
132
|
+
return this.sendRequest({ methodName: "getNftsFromAccountBalances", args: [req] });
|
|
133
|
+
}
|
|
135
134
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TariPermissions } from "@tari-project/tari-permissions";
|
|
2
|
-
import {
|
|
2
|
+
import { TariUniverseSigner } from "./signer";
|
|
3
|
+
import { BalanceEntry } from "@tari-project/typescript-bindings";
|
|
3
4
|
|
|
4
|
-
export type
|
|
5
|
+
export type TariUniverseSignerParameters = {
|
|
5
6
|
permissions: TariPermissions;
|
|
6
7
|
optionalPermissions: TariPermissions;
|
|
7
8
|
name?: string;
|
|
@@ -15,19 +16,23 @@ export type WindowSize = {
|
|
|
15
16
|
|
|
16
17
|
export type PickMatching<T, V> = { [K in keyof T as T[K] extends V ? K : never]: T[K] };
|
|
17
18
|
export type ExtractMethods<T> = PickMatching<T, Function>;
|
|
18
|
-
export type
|
|
19
|
-
export type
|
|
20
|
-
export type
|
|
19
|
+
export type SignerMethods = ExtractMethods<TariUniverseSigner>;
|
|
20
|
+
export type SignerMethodNames = keyof SignerMethods;
|
|
21
|
+
export type SignerReturnType<T extends SignerMethodNames> = Awaited<ReturnType<SignerMethods[T]>>;
|
|
21
22
|
|
|
22
|
-
export type
|
|
23
|
+
export type SignerRequest<T extends SignerMethodNames> = {
|
|
23
24
|
id: number;
|
|
24
25
|
methodName: T;
|
|
25
|
-
args: Parameters<
|
|
26
|
+
args: Parameters<SignerMethods[T]>;
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
export type
|
|
29
|
+
export type SignerResponse<T extends SignerMethodNames> = {
|
|
29
30
|
id: number;
|
|
30
|
-
type: "
|
|
31
|
-
result:
|
|
31
|
+
type: "signer-call";
|
|
32
|
+
result: SignerReturnType<T>;
|
|
32
33
|
resultError?: string;
|
|
33
34
|
};
|
|
35
|
+
|
|
36
|
+
export interface ListAccountNftFromBalancesRequest {
|
|
37
|
+
balances: Array<BalanceEntry>;
|
|
38
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SignerMethodNames, SignerRequest, SignerResponse, SignerReturnType } from "./types";
|
|
2
2
|
|
|
3
|
-
export function
|
|
4
|
-
req: Omit<
|
|
3
|
+
export function sendSignerCall<MethodName extends SignerMethodNames>(
|
|
4
|
+
req: Omit<SignerRequest<MethodName>, "id">,
|
|
5
5
|
id: number,
|
|
6
|
-
): Promise<
|
|
7
|
-
return new Promise<
|
|
8
|
-
const event_ref = (resp: MessageEvent<
|
|
6
|
+
): Promise<SignerReturnType<MethodName>> {
|
|
7
|
+
return new Promise<SignerReturnType<MethodName>>((resolve, reject) => {
|
|
8
|
+
const event_ref = (resp: MessageEvent<SignerResponse<MethodName>>) => {
|
|
9
9
|
if (resp.data.resultError) {
|
|
10
10
|
window.removeEventListener("message", event_ref);
|
|
11
11
|
reject(resp.data.resultError);
|
|
12
12
|
}
|
|
13
|
-
if (resp && resp.data && resp.data.id && resp.data.id === id && resp.data.type === "
|
|
13
|
+
if (resp && resp.data && resp.data.id && resp.data.id === id && resp.data.type === "signer-call") {
|
|
14
14
|
window.removeEventListener("message", event_ref);
|
|
15
15
|
resolve(resp.data.result);
|
|
16
16
|
}
|
|
@@ -18,6 +18,6 @@ export function sendProviderCall<MethodName extends ProviderMethodNames>(
|
|
|
18
18
|
|
|
19
19
|
window.addEventListener("message", event_ref, false);
|
|
20
20
|
|
|
21
|
-
window.parent.postMessage({ ...req, id, type: "
|
|
21
|
+
window.parent.postMessage({ ...req, id, type: "signer-call" }, "*");
|
|
22
22
|
});
|
|
23
23
|
}
|
|
@@ -7,15 +7,13 @@
|
|
|
7
7
|
"outDir": "./dist",
|
|
8
8
|
"rootDir": "./src"
|
|
9
9
|
},
|
|
10
|
-
"include": [
|
|
11
|
-
"src/**/*"
|
|
12
|
-
],
|
|
10
|
+
"include": ["src/**/*"],
|
|
13
11
|
"references": [
|
|
14
12
|
{
|
|
15
13
|
"path": "../tari_permissions"
|
|
16
14
|
},
|
|
17
15
|
{
|
|
18
|
-
"path": "../
|
|
16
|
+
"path": "../tari_signer"
|
|
19
17
|
},
|
|
20
18
|
{
|
|
21
19
|
"path": "../tarijs_types"
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { assert, describe, expect, it } from "vitest";
|
|
2
2
|
|
|
3
|
-
import { SubmitTransactionRequest, TariPermissions,
|
|
3
|
+
import { SubmitTransactionRequest, TariPermissions, WalletDaemonTariSigner } from "../../src";
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
function buildSigner(): Promise<WalletDaemonTariSigner> {
|
|
6
6
|
const permissions = new TariPermissions().addPermission("Admin");
|
|
7
7
|
const serverUrl = process.env.WALLET_DAEMON_JSON_RPC_URL;
|
|
8
8
|
assert(serverUrl, "WALLET_DAEMON_JSON_RPC_URL must be set");
|
|
9
|
-
return
|
|
9
|
+
return WalletDaemonTariSigner.buildFetchSigner({
|
|
10
10
|
permissions,
|
|
11
11
|
serverUrl,
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
describe("
|
|
16
|
-
describe("
|
|
17
|
-
it("returns the
|
|
18
|
-
const
|
|
19
|
-
expect(
|
|
15
|
+
describe("WalletDaemonTariSigner", () => {
|
|
16
|
+
describe("signerName", () => {
|
|
17
|
+
it("returns the signer name", async () => {
|
|
18
|
+
const signer = await buildSigner();
|
|
19
|
+
expect(signer.signerName).toBe("WalletDaemon");
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
describe("isConnected", () => {
|
|
24
24
|
it("is always connected", async () => {
|
|
25
|
-
const
|
|
26
|
-
expect(
|
|
25
|
+
const signer = await buildSigner();
|
|
26
|
+
expect(signer.isConnected()).toBe(true);
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
describe("getAccount", () => {
|
|
31
31
|
it("returns account information", async () => {
|
|
32
|
-
const
|
|
33
|
-
const account = await
|
|
32
|
+
const signer = await buildSigner();
|
|
33
|
+
const account = await signer.getAccount();
|
|
34
34
|
|
|
35
35
|
expect(account).toMatchObject({
|
|
36
36
|
account_id: expect.any(Number),
|
|
@@ -42,10 +42,10 @@ describe("WalletDaemonTariProvider", () => {
|
|
|
42
42
|
|
|
43
43
|
describe("getSubstate", () => {
|
|
44
44
|
it("returns substate details", async () => {
|
|
45
|
-
const
|
|
46
|
-
const listedSubstates = await
|
|
45
|
+
const signer = await buildSigner();
|
|
46
|
+
const listedSubstates = await signer.listSubstates(null, null, 1, 0);
|
|
47
47
|
const firstSubstate = listedSubstates.substates[0];
|
|
48
|
-
const substate = await
|
|
48
|
+
const substate = await signer.getSubstate(firstSubstate.substate_id);
|
|
49
49
|
|
|
50
50
|
expect(substate).toMatchObject({
|
|
51
51
|
value: expect.any(Object),
|
|
@@ -59,10 +59,10 @@ describe("WalletDaemonTariProvider", () => {
|
|
|
59
59
|
|
|
60
60
|
describe("getTransactionResult", () => {
|
|
61
61
|
it("returns transaction result", async () => {
|
|
62
|
-
const
|
|
62
|
+
const signer = await buildSigner();
|
|
63
63
|
|
|
64
64
|
const id = "d5f5a26e7272b1bba7bed331179e555e28c40d92ba3cde1e9ba2b4316e50f486";
|
|
65
|
-
const txResult = await
|
|
65
|
+
const txResult = await signer.getTransactionResult(id);
|
|
66
66
|
expect(txResult).toMatchObject({
|
|
67
67
|
transaction_id: id,
|
|
68
68
|
});
|
|
@@ -71,21 +71,21 @@ describe("WalletDaemonTariProvider", () => {
|
|
|
71
71
|
|
|
72
72
|
describe("submitTransaction", () => {
|
|
73
73
|
it("submits a transaction", async () => {
|
|
74
|
-
const
|
|
74
|
+
const signer = await buildSigner();
|
|
75
75
|
|
|
76
|
-
const account = await
|
|
76
|
+
const account = await signer.getAccount();
|
|
77
77
|
|
|
78
78
|
const fee = 2000;
|
|
79
79
|
const fee_instructions = [
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
{
|
|
81
|
+
CallMethod: {
|
|
82
|
+
component_address: account.address,
|
|
83
|
+
method: "pay_fee",
|
|
84
|
+
args: [`Amount(${fee})`],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
87
|
];
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
const request: SubmitTransactionRequest = {
|
|
90
90
|
network: 0x10, // LocalNet
|
|
91
91
|
account_id: account.account_id,
|
|
@@ -100,7 +100,7 @@ describe("WalletDaemonTariProvider", () => {
|
|
|
100
100
|
is_seal_signer_authorized: true,
|
|
101
101
|
detect_inputs_use_unversioned: true,
|
|
102
102
|
};
|
|
103
|
-
const result = await
|
|
103
|
+
const result = await signer.submitTransaction(request);
|
|
104
104
|
|
|
105
105
|
expect(result).toMatchObject({
|
|
106
106
|
transaction_id: expect.any(String),
|
|
@@ -110,10 +110,10 @@ describe("WalletDaemonTariProvider", () => {
|
|
|
110
110
|
|
|
111
111
|
describe("getAccountBalances", () => {
|
|
112
112
|
it("returns account balances", async () => {
|
|
113
|
-
const
|
|
113
|
+
const signer = await buildSigner();
|
|
114
114
|
|
|
115
|
-
const account = await
|
|
116
|
-
const accountBalances = await
|
|
115
|
+
const account = await signer.getAccount();
|
|
116
|
+
const accountBalances = await signer.getAccountBalances(account.address);
|
|
117
117
|
|
|
118
118
|
expect(accountBalances).toHaveProperty("address");
|
|
119
119
|
|
|
@@ -139,22 +139,22 @@ describe("WalletDaemonTariProvider", () => {
|
|
|
139
139
|
|
|
140
140
|
describe("getTemplateDefinition", () => {
|
|
141
141
|
it("returns template definition", async () => {
|
|
142
|
-
const
|
|
142
|
+
const signer = await buildSigner();
|
|
143
143
|
const accountTemplateAddress = "0000000000000000000000000000000000000000000000000000000000000000";
|
|
144
|
-
const templateDefinition = await
|
|
144
|
+
const templateDefinition = await signer.getTemplateDefinition(accountTemplateAddress);
|
|
145
145
|
|
|
146
146
|
expect(templateDefinition).toMatchObject({
|
|
147
147
|
V1: {
|
|
148
148
|
functions: expect.any(Array),
|
|
149
|
-
}
|
|
149
|
+
},
|
|
150
150
|
});
|
|
151
151
|
});
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
describe("getPublicKey", () => {
|
|
155
155
|
it("returns public key", async () => {
|
|
156
|
-
const
|
|
157
|
-
const publicKey = await
|
|
156
|
+
const signer = await buildSigner();
|
|
157
|
+
const publicKey = await signer.getPublicKey("transaction", 0);
|
|
158
158
|
|
|
159
159
|
expect(publicKey).toEqual(expect.any(String));
|
|
160
160
|
});
|
|
@@ -162,28 +162,28 @@ describe("WalletDaemonTariProvider", () => {
|
|
|
162
162
|
|
|
163
163
|
describe("listSubstates", () => {
|
|
164
164
|
it("returns substates", async () => {
|
|
165
|
-
const
|
|
166
|
-
const { substates } = await
|
|
165
|
+
const signer = await buildSigner();
|
|
166
|
+
const { substates } = await signer.listSubstates(null, null, 10, 0);
|
|
167
167
|
|
|
168
168
|
expect(substates.length).toBeGreaterThan(0);
|
|
169
169
|
});
|
|
170
170
|
|
|
171
171
|
it("filters substates by template address", async () => {
|
|
172
|
-
const
|
|
173
|
-
const { substates } = await
|
|
172
|
+
const signer = await buildSigner();
|
|
173
|
+
const { substates } = await signer.listSubstates(null, null, 10, 0);
|
|
174
174
|
|
|
175
175
|
const substateWithTemplate = substates.find((substate) => substate.template_address);
|
|
176
176
|
assert(substateWithTemplate, "No substate with template found");
|
|
177
177
|
|
|
178
|
-
const templateAddress = substateWithTemplate.template_address
|
|
179
|
-
const { substates: filteredSubstates } = await
|
|
178
|
+
const templateAddress = substateWithTemplate.template_address;
|
|
179
|
+
const { substates: filteredSubstates } = await signer.listSubstates(templateAddress, null, 10, 0);
|
|
180
180
|
|
|
181
181
|
expect(filteredSubstates.every((substate) => substate.template_address === templateAddress)).toBe(true);
|
|
182
182
|
});
|
|
183
183
|
|
|
184
184
|
it("filters substates by type", async () => {
|
|
185
|
-
const
|
|
186
|
-
const { substates } = await
|
|
185
|
+
const signer = await buildSigner();
|
|
186
|
+
const { substates } = await signer.listSubstates(null, "Component", 10, 0);
|
|
187
187
|
|
|
188
188
|
expect(substates.every((substate) => substate.module_name)).toBe(true);
|
|
189
189
|
});
|
package/packages/tarijs/moon.yml
CHANGED
|
@@ -54,6 +54,14 @@ tasks:
|
|
|
54
54
|
- "@files(configs)"
|
|
55
55
|
- "@files(tests)"
|
|
56
56
|
test:
|
|
57
|
+
command: "pnpm run test"
|
|
58
|
+
inputs:
|
|
59
|
+
- "@files(sources)"
|
|
60
|
+
- "@files(tests)"
|
|
61
|
+
- "@files(configs)"
|
|
62
|
+
deps:
|
|
63
|
+
- "build"
|
|
64
|
+
integration-test:
|
|
57
65
|
command: "pnpm run integration-tests"
|
|
58
66
|
inputs:
|
|
59
67
|
- "@files(sources)"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tarijs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc -b",
|
|
11
|
+
"test": "vitest run src",
|
|
11
12
|
"integration-tests": "vitest run integration-tests"
|
|
12
13
|
},
|
|
13
14
|
"keywords": [],
|
|
@@ -15,15 +16,17 @@
|
|
|
15
16
|
"license": "ISC",
|
|
16
17
|
"dependencies": {
|
|
17
18
|
"@metamask/providers": "catalog:",
|
|
18
|
-
"@tari-project/metamask-
|
|
19
|
+
"@tari-project/metamask-signer": "workspace:^",
|
|
19
20
|
"@tari-project/tari-permissions": "workspace:^",
|
|
20
|
-
"@tari-project/tari-
|
|
21
|
-
"@tari-project/tari-universe-
|
|
21
|
+
"@tari-project/tari-signer": "workspace:^",
|
|
22
|
+
"@tari-project/tari-universe-signer": "workspace:^",
|
|
22
23
|
"@tari-project/tarijs-builders": "workspace:^",
|
|
23
24
|
"@tari-project/tarijs-types": "workspace:^",
|
|
24
25
|
"@tari-project/typescript-bindings": "catalog:",
|
|
25
|
-
"@tari-project/wallet-connect-
|
|
26
|
-
"@tari-project/wallet-daemon-
|
|
26
|
+
"@tari-project/wallet-connect-signer": "workspace:^",
|
|
27
|
+
"@tari-project/wallet-daemon-signer": "workspace:^",
|
|
28
|
+
"@tari-project/tari-provider": "workspace:^",
|
|
29
|
+
"@tari-project/indexer-provider": "workspace:^"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
32
|
"@types/node": "catalog:",
|