@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
|
@@ -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
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tarijs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -16,15 +16,17 @@
|
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@metamask/providers": "catalog:",
|
|
19
|
-
"@tari-project/metamask-
|
|
19
|
+
"@tari-project/metamask-signer": "workspace:^",
|
|
20
20
|
"@tari-project/tari-permissions": "workspace:^",
|
|
21
|
-
"@tari-project/tari-
|
|
22
|
-
"@tari-project/tari-universe-
|
|
21
|
+
"@tari-project/tari-signer": "workspace:^",
|
|
22
|
+
"@tari-project/tari-universe-signer": "workspace:^",
|
|
23
23
|
"@tari-project/tarijs-builders": "workspace:^",
|
|
24
24
|
"@tari-project/tarijs-types": "workspace:^",
|
|
25
25
|
"@tari-project/typescript-bindings": "catalog:",
|
|
26
|
-
"@tari-project/wallet-connect-
|
|
27
|
-
"@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:^"
|
|
28
30
|
},
|
|
29
31
|
"devDependencies": {
|
|
30
32
|
"@types/node": "catalog:",
|
|
@@ -1,28 +1,13 @@
|
|
|
1
|
+
import { TariSigner } from "@tari-project/tari-signer";
|
|
1
2
|
import { TariProvider } from "@tari-project/tari-provider";
|
|
2
3
|
import * as utils from "./utils";
|
|
3
4
|
import { Network } from "./network";
|
|
4
|
-
import {
|
|
5
|
-
Account,
|
|
6
|
-
TransactionStatus,
|
|
7
|
-
TransactionResult,
|
|
8
|
-
SubmitTransactionResponse,
|
|
9
|
-
SubmitTransactionRequest,
|
|
10
|
-
VaultBalances,
|
|
11
|
-
VaultData,
|
|
12
|
-
TemplateDefinition,
|
|
13
|
-
SubstateRequirement,
|
|
14
|
-
Substate,
|
|
15
|
-
} from "@tari-project/tari-provider";
|
|
16
|
-
import { MetamaskTariProvider } from "@tari-project/metamask-provider";
|
|
5
|
+
import { MetamaskTariSigner } from "@tari-project/metamask-signer";
|
|
17
6
|
import { MetaMaskInpageProvider } from "@metamask/providers";
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
WalletDaemonParameters,
|
|
21
|
-
TariPermissions,
|
|
22
|
-
} from "@tari-project/wallet-daemon-provider";
|
|
23
|
-
import { TariUniverseProvider, TariUniverseProviderParameters } from "@tari-project/tari-universe-provider";
|
|
7
|
+
import { WalletDaemonTariSigner, WalletDaemonParameters, TariPermissions } from "@tari-project/wallet-daemon-signer";
|
|
8
|
+
import { TariUniverseSigner, TariUniverseSignerParameters } from "@tari-project/tari-universe-signer";
|
|
24
9
|
import * as permissions from "@tari-project/tari-permissions";
|
|
25
|
-
import {
|
|
10
|
+
import { WalletConnectTariSigner } from "@tari-project/wallet-connect-signer";
|
|
26
11
|
import {
|
|
27
12
|
TransactionBuilder,
|
|
28
13
|
TransactionRequest,
|
|
@@ -34,38 +19,64 @@ import {
|
|
|
34
19
|
} from "@tari-project/tarijs-builders";
|
|
35
20
|
import * as templates from "./templates";
|
|
36
21
|
import { parseCbor, getCborValueByPath } from "./cbor";
|
|
22
|
+
import { IndexerProvider, IndexerProviderParameters } from "@tari-project/indexer-provider";
|
|
23
|
+
import {
|
|
24
|
+
convertStringToTransactionStatus,
|
|
25
|
+
convertHexStringToU256Array,
|
|
26
|
+
convertU256ToHexString,
|
|
27
|
+
createNftAddressFromResource,
|
|
28
|
+
createNftAddressFromToken,
|
|
29
|
+
TransactionStatus,
|
|
30
|
+
GetTransactionResultResponse,
|
|
31
|
+
AccountData,
|
|
32
|
+
SubmitTransactionResponse,
|
|
33
|
+
SubmitTransactionRequest,
|
|
34
|
+
VaultBalances,
|
|
35
|
+
VaultData,
|
|
36
|
+
TemplateDefinition,
|
|
37
|
+
SubstateRequirement,
|
|
38
|
+
Substate,
|
|
39
|
+
} from "@tari-project/tarijs-types";
|
|
37
40
|
|
|
38
41
|
export * from "@tari-project/tarijs-types";
|
|
39
42
|
export {
|
|
40
43
|
utils,
|
|
41
44
|
Network,
|
|
45
|
+
TariSigner,
|
|
42
46
|
TariProvider,
|
|
43
|
-
|
|
47
|
+
AccountData,
|
|
44
48
|
TransactionStatus,
|
|
45
|
-
|
|
49
|
+
GetTransactionResultResponse,
|
|
46
50
|
SubmitTransactionResponse,
|
|
47
51
|
SubmitTransactionRequest,
|
|
48
52
|
VaultBalances,
|
|
49
53
|
VaultData,
|
|
50
54
|
TemplateDefinition,
|
|
51
55
|
SubstateRequirement,
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
MetamaskTariSigner,
|
|
57
|
+
WalletDaemonTariSigner,
|
|
54
58
|
WalletDaemonParameters,
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
TariUniverseSigner,
|
|
60
|
+
TariUniverseSignerParameters,
|
|
57
61
|
TariPermissions,
|
|
58
62
|
MetaMaskInpageProvider,
|
|
59
63
|
Substate,
|
|
60
|
-
|
|
61
|
-
WalletConnectTariProvider,
|
|
64
|
+
WalletConnectTariSigner,
|
|
62
65
|
TransactionBuilder,
|
|
63
66
|
TransactionRequest,
|
|
67
|
+
IndexerProvider,
|
|
68
|
+
IndexerProviderParameters,
|
|
69
|
+
convertStringToTransactionStatus,
|
|
64
70
|
buildTransactionRequest,
|
|
65
71
|
submitAndWaitForTransaction,
|
|
66
72
|
waitForTransactionResult,
|
|
67
73
|
fromWorkspace,
|
|
68
74
|
toWorkspace,
|
|
75
|
+
convertHexStringToU256Array,
|
|
76
|
+
convertU256ToHexString,
|
|
77
|
+
createNftAddressFromResource,
|
|
78
|
+
createNftAddressFromToken,
|
|
79
|
+
permissions,
|
|
69
80
|
templates,
|
|
70
81
|
parseCbor,
|
|
71
82
|
getCborValueByPath,
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
"path": "../builders"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
|
-
"path": "../
|
|
18
|
+
"path": "../indexer_provider"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "../metamask_signer"
|
|
19
22
|
},
|
|
20
23
|
{
|
|
21
24
|
"path": "../tari_permissions"
|
|
@@ -23,6 +26,9 @@
|
|
|
23
26
|
{
|
|
24
27
|
"path": "../tari_provider"
|
|
25
28
|
},
|
|
29
|
+
{
|
|
30
|
+
"path": "../tari_signer"
|
|
31
|
+
},
|
|
26
32
|
{
|
|
27
33
|
"path": "../tari_universe"
|
|
28
34
|
},
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FinalizeResult } from "@tari-project/typescript-bindings";
|
|
2
|
+
import { TransactionStatus } from "./TransactionStatus";
|
|
3
|
+
|
|
4
|
+
export type GetTransactionResultResponse = {
|
|
5
|
+
transaction_id: string;
|
|
6
|
+
status: TransactionStatus;
|
|
7
|
+
result: FinalizeResult | null;
|
|
8
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ComponentAddress, LogLevel } from "@tari-project/typescript-bindings";
|
|
2
|
-
import {
|
|
1
|
+
import { ComponentAddress, LogLevel, PublishedTemplateAddress } from "@tari-project/typescript-bindings";
|
|
2
|
+
import { TransactionArg } from "./TransactionArg";
|
|
3
3
|
import { ConfidentialClaim } from "./ConfidentialClaim";
|
|
4
4
|
import { Amount } from "./Amount";
|
|
5
5
|
import { ConfidentialOutput } from "./ConfidentialOutput";
|
|
6
|
-
import { TemplateAddress } from "./TemplateAddress";
|
|
7
6
|
|
|
8
7
|
export type Instruction =
|
|
9
8
|
| CreateAccount
|
|
@@ -17,8 +16,12 @@ export type Instruction =
|
|
|
17
16
|
| CreateFreeTestCoins;
|
|
18
17
|
|
|
19
18
|
export type CreateAccount = { CreateAccount: { owner_public_key: string; workspace_bucket: string | null } };
|
|
20
|
-
export type CallFunction = {
|
|
21
|
-
|
|
19
|
+
export type CallFunction = {
|
|
20
|
+
CallFunction: { template_address: PublishedTemplateAddress; function: string; args: Array<TransactionArg> };
|
|
21
|
+
};
|
|
22
|
+
export type CallMethod = {
|
|
23
|
+
CallMethod: { component_address: ComponentAddress; method: string; args: Array<TransactionArg> };
|
|
24
|
+
};
|
|
22
25
|
export type PutLastInstructionOutputOnWorkspace = { PutLastInstructionOutputOnWorkspace: { key: number[] } };
|
|
23
26
|
export type EmitLog = { EmitLog: { level: LogLevel; message: string } };
|
|
24
27
|
export type ClaimBurn = { ClaimBurn: { claim: ConfidentialClaim } };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Instruction } from "./Instruction";
|
|
2
2
|
import { SubstateRequirement } from "./SubstateRequirement";
|
|
3
|
-
import { Epoch } from "./Epoch";
|
|
4
3
|
import { VersionedSubstateId } from "./VersionedSubstateId";
|
|
5
4
|
import { TransactionSignature } from "./TransactionSignature";
|
|
5
|
+
import { Epoch } from "@tari-project/typescript-bindings";
|
|
6
6
|
|
|
7
7
|
export interface Transaction {
|
|
8
8
|
id: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TransactionStatus } from "./TransactionStatus";
|
|
1
2
|
import { FinalizeResult } from "./FinalizeResult";
|
|
2
3
|
|
|
3
4
|
export type SubmitTransactionResponse = {
|
|
@@ -9,16 +10,6 @@ export interface SubmitTxResult {
|
|
|
9
10
|
result: TransactionResult;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export enum TransactionStatus {
|
|
13
|
-
New,
|
|
14
|
-
DryRun,
|
|
15
|
-
Pending,
|
|
16
|
-
Accepted,
|
|
17
|
-
Rejected,
|
|
18
|
-
InvalidTransaction,
|
|
19
|
-
OnlyFeeAccepted,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
13
|
export type TransactionResult = {
|
|
23
14
|
transaction_id: string;
|
|
24
15
|
status: TransactionStatus;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { Epoch } from "@tari-project/typescript-bindings";
|
|
1
2
|
import { Instruction } from "./Instruction";
|
|
2
|
-
import { Epoch } from "./Epoch";
|
|
3
3
|
import { SubstateRequirement } from "./SubstateRequirement";
|
|
4
4
|
import { VersionedSubstateId } from "./VersionedSubstateId";
|
|
5
5
|
|
|
6
|
-
//TODO refactor type (https://github.com/tari-project/tari.js/issues/29)
|
|
7
6
|
// differs from bindings implementation because of 'Instruction'
|
|
8
7
|
export interface UnsignedTransaction {
|
|
9
8
|
feeInstructions: Instruction[];
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { NonFungibleId, NonFungibleToken, ResourceAddress } from "@tari-project/typescript-bindings";
|
|
2
|
+
import { TransactionStatus } from "../TransactionStatus";
|
|
3
|
+
export {
|
|
4
|
+
substateIdToString,
|
|
5
|
+
stringToSubstateId,
|
|
6
|
+
shortenSubstateId,
|
|
7
|
+
shortenString,
|
|
8
|
+
rejectReasonToString,
|
|
9
|
+
getSubstateDiffFromTransactionResult,
|
|
10
|
+
getRejectReasonFromTransactionResult,
|
|
11
|
+
jrpcPermissionToString,
|
|
12
|
+
} from "@tari-project/typescript-bindings";
|
|
13
|
+
|
|
14
|
+
export function convertStringToTransactionStatus(status: string): TransactionStatus {
|
|
15
|
+
switch (status) {
|
|
16
|
+
case "New":
|
|
17
|
+
return TransactionStatus.New;
|
|
18
|
+
case "DryRun":
|
|
19
|
+
return TransactionStatus.DryRun;
|
|
20
|
+
case "Pending":
|
|
21
|
+
return TransactionStatus.Pending;
|
|
22
|
+
case "Accepted":
|
|
23
|
+
return TransactionStatus.Accepted;
|
|
24
|
+
case "Rejected":
|
|
25
|
+
return TransactionStatus.Rejected;
|
|
26
|
+
case "InvalidTransaction":
|
|
27
|
+
return TransactionStatus.InvalidTransaction;
|
|
28
|
+
case "OnlyFeeAccepted":
|
|
29
|
+
return TransactionStatus.OnlyFeeAccepted;
|
|
30
|
+
default:
|
|
31
|
+
throw new Error(`Unknown status: ${status}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Function to create the Nft address
|
|
36
|
+
// address format: nft_RESOURCEADDR_uuid_TOKENID
|
|
37
|
+
export function createNftAddressFromToken(token: NonFungibleToken): string {
|
|
38
|
+
return createNftAddressFromResource(token.resource_address, token.nft_id);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function convertU256ToHexString(id: NonFungibleId): string {
|
|
42
|
+
if ("U256" in id && Array.isArray(id.U256)) {
|
|
43
|
+
return id.U256.map((num) => num.toString(16).padStart(2, "0")).join("");
|
|
44
|
+
}
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function convertHexStringToU256Array(hexString: string): number[] {
|
|
49
|
+
const cleanHexString = hexString.replace(/[^0-9a-fA-F]/g, "");
|
|
50
|
+
const u256Array: number[] = [];
|
|
51
|
+
|
|
52
|
+
for (let i = 0; i < cleanHexString.length; i += 2) {
|
|
53
|
+
const hexPair = cleanHexString.slice(i, i + 2);
|
|
54
|
+
u256Array.push(parseInt(hexPair, 16));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return u256Array;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function createNftAddressFromResource(address: ResourceAddress, tokenId: NonFungibleId): string {
|
|
61
|
+
let nftAddress = "nft_";
|
|
62
|
+
const resourceAddress = address.replace(/^resource_/, "");
|
|
63
|
+
nftAddress += resourceAddress;
|
|
64
|
+
nftAddress += "_uuid_";
|
|
65
|
+
const nftIdHexString = convertU256ToHexString(tokenId);
|
|
66
|
+
nftAddress += nftIdHexString;
|
|
67
|
+
|
|
68
|
+
return nftAddress;
|
|
69
|
+
}
|