@tari-project/tarijs 0.4.2 → 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/TODO.md +2 -6
- 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 +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 +6 -21
- package/packages/tari_provider/src/index.ts +1 -2
- package/packages/tari_provider/src/types.ts +36 -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} +29 -15
- 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/package.json +8 -6
- package/packages/tarijs/src/index.ts +28 -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 +3 -3
- package/tsconfig.json +8 -2
- /package/packages/{metamask_provider → indexer_provider}/moon.yml +0 -0
- /package/packages/{metamask_provider → metamask_signer}/src/utils.ts +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { RpcRequest, RpcTransport, RpcTransportOptions } from "./rpc";
|
|
2
|
+
|
|
3
|
+
export default class FetchRpcTransport implements RpcTransport {
|
|
4
|
+
private url: string;
|
|
5
|
+
|
|
6
|
+
constructor(url: string) {
|
|
7
|
+
this.url = url;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static new(url: string) {
|
|
11
|
+
return new FetchRpcTransport(url);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async sendRequest<T>(data: RpcRequest, options: RpcTransportOptions): Promise<T> {
|
|
15
|
+
const headers: { [key: string]: string } = {
|
|
16
|
+
"Content-Type": "application/json",
|
|
17
|
+
};
|
|
18
|
+
if (options?.token) {
|
|
19
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let controller = new AbortController();
|
|
23
|
+
let signal = controller.signal;
|
|
24
|
+
|
|
25
|
+
const timeoutId = options.timeout_millis
|
|
26
|
+
? setTimeout(() => {
|
|
27
|
+
controller.abort("Timeout");
|
|
28
|
+
}, options.timeout_millis)
|
|
29
|
+
: null;
|
|
30
|
+
|
|
31
|
+
const response = await fetch(this.url, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
body: JSON.stringify(data),
|
|
34
|
+
headers,
|
|
35
|
+
signal,
|
|
36
|
+
});
|
|
37
|
+
if (timeoutId) {
|
|
38
|
+
clearTimeout(timeoutId);
|
|
39
|
+
}
|
|
40
|
+
const json = await response.json();
|
|
41
|
+
if (json.error) {
|
|
42
|
+
throw new Error(`${json.error.code}: ${json.error.message}`);
|
|
43
|
+
}
|
|
44
|
+
return json.result;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import FetchRpcTransport from "./fetch";
|
|
2
|
+
|
|
3
|
+
export { FetchRpcTransport };
|
|
4
|
+
|
|
5
|
+
export interface RpcTransport {
|
|
6
|
+
sendRequest<T>(request: RpcRequest, options: RpcTransportOptions): Promise<T>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface RpcTransportOptions {
|
|
10
|
+
token?: string;
|
|
11
|
+
timeout_millis?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface RpcRequest {
|
|
15
|
+
id: number;
|
|
16
|
+
jsonrpc: string;
|
|
17
|
+
method: string;
|
|
18
|
+
params: any;
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "ES2020",
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"moduleResolution": "Bundler",
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src"
|
|
9
|
+
},
|
|
10
|
+
"include": ["src/**/*"],
|
|
11
|
+
"references": [
|
|
12
|
+
{
|
|
13
|
+
"path": "../tari_permissions"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "../tari_provider"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "../tarijs_types"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
language: "typescript"
|
|
2
|
+
platform: "node"
|
|
3
|
+
type: "library"
|
|
4
|
+
|
|
5
|
+
fileGroups:
|
|
6
|
+
configs:
|
|
7
|
+
- "tsconfig.json"
|
|
8
|
+
- "package.json"
|
|
9
|
+
- "eslint.config.ts"
|
|
10
|
+
sources:
|
|
11
|
+
- "src/**/*"
|
|
12
|
+
tests:
|
|
13
|
+
- "integration-tests/**/*"
|
|
14
|
+
|
|
15
|
+
tasks:
|
|
16
|
+
build:
|
|
17
|
+
command: "pnpm run build"
|
|
18
|
+
inputs:
|
|
19
|
+
- "@files(sources)"
|
|
20
|
+
- "@files(configs)"
|
|
21
|
+
outputs:
|
|
22
|
+
- "dist"
|
|
23
|
+
format:
|
|
24
|
+
command: "pnpm run format"
|
|
25
|
+
inputs:
|
|
26
|
+
- "@files(sources)"
|
|
27
|
+
- "@files(configs)"
|
|
28
|
+
- "@files(tests)"
|
|
29
|
+
options:
|
|
30
|
+
runInCI: false
|
|
31
|
+
lint:
|
|
32
|
+
command: "pnpm run lint:fix"
|
|
33
|
+
inputs:
|
|
34
|
+
- "@files(sources)"
|
|
35
|
+
- "@files(configs)"
|
|
36
|
+
- "@files(tests)"
|
|
37
|
+
options:
|
|
38
|
+
runInCI: false
|
|
39
|
+
deps:
|
|
40
|
+
- "build"
|
|
41
|
+
|
|
42
|
+
lintCheck:
|
|
43
|
+
command: "pnpm run lint"
|
|
44
|
+
inputs:
|
|
45
|
+
- "@files(sources)"
|
|
46
|
+
- "@files(configs)"
|
|
47
|
+
- "@files(tests)"
|
|
48
|
+
deps:
|
|
49
|
+
- "build"
|
|
50
|
+
formatCheck:
|
|
51
|
+
command: "pnpm run format:check"
|
|
52
|
+
inputs:
|
|
53
|
+
- "@files(sources)"
|
|
54
|
+
- "@files(configs)"
|
|
55
|
+
- "@files(tests)"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@tari-project/metamask-
|
|
3
|
-
"version": "0.
|
|
2
|
+
"name": "@tari-project/metamask-signer",
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@metamask/providers": "catalog:",
|
|
17
|
-
"@tari-project/tari-
|
|
17
|
+
"@tari-project/tari-signer": "workspace:^",
|
|
18
18
|
"@tari-project/tarijs-types": "workspace:^",
|
|
19
19
|
"@tari-project/typescript-bindings": "catalog:"
|
|
20
20
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TariSigner } from "@tari-project/tari-signer";
|
|
2
2
|
import {
|
|
3
3
|
SubmitTransactionRequest,
|
|
4
4
|
TransactionResult,
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
TemplateDefinition,
|
|
9
9
|
Substate,
|
|
10
10
|
ListSubstatesResponse,
|
|
11
|
-
Account
|
|
12
|
-
} from "@tari-project/tari-
|
|
11
|
+
Account,
|
|
12
|
+
} from "@tari-project/tari-signer";
|
|
13
13
|
import { MetaMaskInpageProvider } from "@metamask/providers";
|
|
14
14
|
import { connectSnap, getSnap, isFlask, Snap } from "./utils";
|
|
15
|
-
import { SubstateType } from "@tari-project/typescript-bindings";
|
|
15
|
+
import { ListAccountNftRequest, ListAccountNftResponse, SubstateType } from "@tari-project/typescript-bindings";
|
|
16
16
|
|
|
17
17
|
export const MetamaskNotInstalled = "METAMASK_NOT_INSTALLED";
|
|
18
18
|
export const MetamaskIsNotFlask = "METAMASK_IS_NOT_FLASK";
|
|
@@ -20,8 +20,8 @@ export const TariSnapNotInstalled = "TARI_SNAP_NOT_INSTALLED";
|
|
|
20
20
|
|
|
21
21
|
type Maybe<T> = T | null | undefined;
|
|
22
22
|
|
|
23
|
-
export class
|
|
24
|
-
public
|
|
23
|
+
export class MetamaskTariSigner implements TariSigner {
|
|
24
|
+
public signerName = "Metamask";
|
|
25
25
|
snapId: string;
|
|
26
26
|
snapVersion: string | undefined;
|
|
27
27
|
metamask: MetaMaskInpageProvider;
|
|
@@ -212,6 +212,11 @@ export class MetamaskTariProvider implements TariProvider {
|
|
|
212
212
|
|
|
213
213
|
return resp as T;
|
|
214
214
|
}
|
|
215
|
+
|
|
216
|
+
public async getNftsList(req: ListAccountNftRequest): Promise<ListAccountNftResponse> {
|
|
217
|
+
const resp = (await this.metamaskRequest("getNftsList", req)) as ListAccountNftResponse;
|
|
218
|
+
return resp;
|
|
219
|
+
}
|
|
215
220
|
}
|
|
216
221
|
|
|
217
222
|
function convertToStatus(result: any): TransactionStatus {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "ES2020",
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"moduleResolution": "Bundler",
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src"
|
|
9
|
+
},
|
|
10
|
+
"include": ["src/**/*"],
|
|
11
|
+
"references": [
|
|
12
|
+
{
|
|
13
|
+
"path": "../tari_signer"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "../tarijs_types"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/tari-permissions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
"keywords": [],
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "ISC",
|
|
15
|
-
"dependencies": {
|
|
16
|
-
},
|
|
15
|
+
"dependencies": {},
|
|
17
16
|
"devDependencies": {
|
|
18
17
|
"@types/node": "catalog:",
|
|
19
18
|
"typescript": "catalog:"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TariPermission,
|
|
3
|
+
TariPermissionAccountBalance,
|
|
4
|
+
TariPermissionAccountInfo,
|
|
5
|
+
TariPermissionAccountList,
|
|
6
|
+
TariPermissionGetNft,
|
|
7
|
+
TariPermissionKeyList,
|
|
8
|
+
TariPermissionNftGetOwnershipProof,
|
|
9
|
+
TariPermissionTransactionGet,
|
|
10
|
+
TariPermissionTransactionSend,
|
|
11
|
+
} from "./tari_permissions";
|
|
12
|
+
|
|
13
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
14
|
+
export function createPermissionFromType(permission: any): TariPermission {
|
|
15
|
+
if (Object.prototype.hasOwnProperty.call(permission, "AccountBalance")) {
|
|
16
|
+
return new TariPermissionAccountBalance(permission.AccountBalance);
|
|
17
|
+
} else if (permission === "AccountInfo") {
|
|
18
|
+
return new TariPermissionAccountInfo();
|
|
19
|
+
} else if (Object.prototype.hasOwnProperty.call(permission, "AccountList")) {
|
|
20
|
+
return new TariPermissionAccountList(permission.AccountList);
|
|
21
|
+
} else if (permission == "KeyList") {
|
|
22
|
+
return new TariPermissionKeyList();
|
|
23
|
+
} else if (Object.prototype.hasOwnProperty.call(permission, "TransactionSend")) {
|
|
24
|
+
return new TariPermissionTransactionSend(permission.TransactionSend);
|
|
25
|
+
} else if (permission === "TransactionGet") {
|
|
26
|
+
return new TariPermissionTransactionGet();
|
|
27
|
+
} else if (Object.prototype.hasOwnProperty.call(permission, "GetNft")) {
|
|
28
|
+
return new TariPermissionGetNft(permission.GetNft);
|
|
29
|
+
} else if (Object.prototype.hasOwnProperty.call(permission, "NftGetOwnershipProof")) {
|
|
30
|
+
return new TariPermissionNftGetOwnershipProof(permission.NftGetOwnershipProof);
|
|
31
|
+
}
|
|
32
|
+
return permission;
|
|
33
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./tari_permissions";
|
|
2
|
+
export * from "./helpers";
|
|
@@ -26,11 +26,10 @@ export class Tagged {
|
|
|
26
26
|
this.value = value;
|
|
27
27
|
}
|
|
28
28
|
toJSON() {
|
|
29
|
-
return { "@@TAGGED@@": [this.tag, this.value] }
|
|
29
|
+
return { "@@TAGGED@@": [this.tag, this.value] };
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
34
33
|
export class ResourceAddress {
|
|
35
34
|
private tagged: Tagged;
|
|
36
35
|
constructor(hash: Hash) {
|
|
@@ -72,12 +71,12 @@ export class NonFungibleId {
|
|
|
72
71
|
}
|
|
73
72
|
toJSON() {
|
|
74
73
|
switch (typeof this.value) {
|
|
75
|
-
case
|
|
76
|
-
return {
|
|
77
|
-
case
|
|
78
|
-
return {
|
|
74
|
+
case "string":
|
|
75
|
+
return { string: this.value };
|
|
76
|
+
case "number":
|
|
77
|
+
return { Uint64: this.value };
|
|
79
78
|
}
|
|
80
|
-
return {
|
|
79
|
+
return { U256: this.value };
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
|
|
@@ -89,14 +88,14 @@ export class NonFungibleAddressContents {
|
|
|
89
88
|
this.id = id;
|
|
90
89
|
}
|
|
91
90
|
toJSON() {
|
|
92
|
-
return {
|
|
91
|
+
return { resource_address: this.resource_address, id: this.id };
|
|
93
92
|
}
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
export class NonFungibleAddress {
|
|
97
96
|
private tagged: Tagged;
|
|
98
97
|
constructor(value: NonFungibleAddressContents) {
|
|
99
|
-
this.tagged = new Tagged(TAG.NonFungibleAddress, value)
|
|
98
|
+
this.tagged = new Tagged(TAG.NonFungibleAddress, value);
|
|
100
99
|
}
|
|
101
100
|
toJSON() {
|
|
102
101
|
return this.tagged.toJSON();
|
|
@@ -111,7 +110,7 @@ export class NonFungibleIndexAddress {
|
|
|
111
110
|
this.index = index;
|
|
112
111
|
}
|
|
113
112
|
toJSON() {
|
|
114
|
-
return {
|
|
113
|
+
return { resource_address: this.resource_address, index: this.index };
|
|
115
114
|
}
|
|
116
115
|
}
|
|
117
116
|
|
|
@@ -121,7 +120,7 @@ export class ComponentAddress {
|
|
|
121
120
|
this.tagged = new Tagged(TAG.ComponentAddress, hash);
|
|
122
121
|
}
|
|
123
122
|
toJSON() {
|
|
124
|
-
return this.tagged.toJSON()
|
|
123
|
+
return this.tagged.toJSON();
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
|
|
@@ -131,12 +130,17 @@ export class VaultId {
|
|
|
131
130
|
this.tagged = new Tagged(TAG.VaultId, hash);
|
|
132
131
|
}
|
|
133
132
|
toJSON() {
|
|
134
|
-
return this.tagged.toJSON()
|
|
133
|
+
return this.tagged.toJSON();
|
|
135
134
|
}
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
export type SubstateAddressType =
|
|
139
|
-
|
|
137
|
+
export type SubstateAddressType =
|
|
138
|
+
| ResourceAddress
|
|
139
|
+
| ComponentAddress
|
|
140
|
+
| VaultId
|
|
141
|
+
| UnclaimedConfidentialOutputAddress
|
|
142
|
+
| NonFungibleAddress
|
|
143
|
+
| NonFungibleIndexAddress;
|
|
140
144
|
|
|
141
145
|
export class SubstateAddress {
|
|
142
146
|
private value: SubstateAddressType;
|
|
@@ -145,19 +149,19 @@ export class SubstateAddress {
|
|
|
145
149
|
}
|
|
146
150
|
toJSON() {
|
|
147
151
|
if (this.value instanceof ComponentAddress) {
|
|
148
|
-
return {
|
|
152
|
+
return { Component: this.value };
|
|
149
153
|
} else if (this.value instanceof ResourceAddress) {
|
|
150
|
-
return {
|
|
154
|
+
return { Resource: this.value };
|
|
151
155
|
} else if (this.value instanceof VaultId) {
|
|
152
|
-
return {
|
|
156
|
+
return { Vault: this.value };
|
|
153
157
|
} else if (this.value instanceof UnclaimedConfidentialOutputAddress) {
|
|
154
|
-
return {
|
|
158
|
+
return { UnclaimedConfidentialOutput: this.value };
|
|
155
159
|
} else if (this.value instanceof NonFungibleAddress) {
|
|
156
|
-
return {
|
|
160
|
+
return { NonFungible: this.value };
|
|
157
161
|
} else if (this.value instanceof NonFungibleIndexAddress) {
|
|
158
|
-
return {
|
|
162
|
+
return { NonFungibleIndex: this.value };
|
|
159
163
|
}
|
|
160
|
-
throw "Unknown type"
|
|
164
|
+
throw "Unknown type";
|
|
161
165
|
}
|
|
162
166
|
}
|
|
163
167
|
|
|
@@ -167,15 +171,15 @@ export class TariPermissionAccountBalance {
|
|
|
167
171
|
this.value = value;
|
|
168
172
|
}
|
|
169
173
|
toJSON() {
|
|
170
|
-
console.log("stringify", this.value)
|
|
171
|
-
return {
|
|
174
|
+
console.log("stringify", this.value);
|
|
175
|
+
return { AccountBalance: this.value };
|
|
172
176
|
}
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
export class TariPermissionAccountInfo {
|
|
176
180
|
constructor() {}
|
|
177
181
|
toJSON() {
|
|
178
|
-
return "AccountInfo"
|
|
182
|
+
return "AccountInfo";
|
|
179
183
|
}
|
|
180
184
|
}
|
|
181
185
|
|
|
@@ -189,11 +193,11 @@ export class TariPermissionAccountList {
|
|
|
189
193
|
}
|
|
190
194
|
}
|
|
191
195
|
toJSON() {
|
|
192
|
-
console.log(
|
|
196
|
+
console.log("JSON TariPermissionAccountList", this.value);
|
|
193
197
|
if (this.value === undefined) {
|
|
194
|
-
return {
|
|
198
|
+
return { AccountList: null };
|
|
195
199
|
} else {
|
|
196
|
-
return {
|
|
200
|
+
return { AccountList: this.value };
|
|
197
201
|
}
|
|
198
202
|
}
|
|
199
203
|
}
|
|
@@ -201,14 +205,14 @@ export class TariPermissionAccountList {
|
|
|
201
205
|
export class TariPermissionKeyList {
|
|
202
206
|
constructor() {}
|
|
203
207
|
toJSON() {
|
|
204
|
-
return "KeyList"
|
|
208
|
+
return "KeyList";
|
|
205
209
|
}
|
|
206
210
|
}
|
|
207
211
|
|
|
208
212
|
export class TariPermissionTransactionGet {
|
|
209
213
|
constructor() {}
|
|
210
214
|
toJSON() {
|
|
211
|
-
return "TransactionGet"
|
|
215
|
+
return "TransactionGet";
|
|
212
216
|
}
|
|
213
217
|
}
|
|
214
218
|
export class TariPermissionTransactionSend {
|
|
@@ -217,11 +221,11 @@ export class TariPermissionTransactionSend {
|
|
|
217
221
|
this.value = value;
|
|
218
222
|
}
|
|
219
223
|
toJSON() {
|
|
220
|
-
console.log(
|
|
224
|
+
console.log("JSON TariPermissionTransactionSend", this.value);
|
|
221
225
|
if (this.value === undefined) {
|
|
222
|
-
return {
|
|
226
|
+
return { TransactionSend: null };
|
|
223
227
|
} else {
|
|
224
|
-
return {
|
|
228
|
+
return { TransactionSend: this.value };
|
|
225
229
|
}
|
|
226
230
|
}
|
|
227
231
|
}
|
|
@@ -234,7 +238,7 @@ export class TariPermissionGetNft {
|
|
|
234
238
|
this.value1 = value1;
|
|
235
239
|
}
|
|
236
240
|
toJSON() {
|
|
237
|
-
return {
|
|
241
|
+
return { GetNft: [this.value0, this.value1] };
|
|
238
242
|
}
|
|
239
243
|
}
|
|
240
244
|
|
|
@@ -244,32 +248,44 @@ export class TariPermissionNftGetOwnershipProof {
|
|
|
244
248
|
this.value = value;
|
|
245
249
|
}
|
|
246
250
|
toJSON() {
|
|
247
|
-
return {
|
|
251
|
+
return { NftGetOwnershipProof: this.value };
|
|
248
252
|
}
|
|
249
253
|
}
|
|
250
254
|
|
|
251
255
|
export class TariPermissionTransactionsGet {
|
|
252
256
|
constructor() {}
|
|
253
257
|
toJSON() {
|
|
254
|
-
return "TransactionGet"
|
|
258
|
+
return "TransactionGet";
|
|
255
259
|
}
|
|
256
260
|
}
|
|
257
261
|
|
|
258
262
|
export class TariPermissionSubstatesRead {
|
|
259
263
|
constructor() {}
|
|
260
264
|
toJSON() {
|
|
261
|
-
return "SubstatesRead"
|
|
265
|
+
return "SubstatesRead";
|
|
262
266
|
}
|
|
263
267
|
}
|
|
264
268
|
|
|
265
269
|
export class TariPermissionTemplatesRead {
|
|
266
270
|
constructor() {}
|
|
267
271
|
toJSON() {
|
|
268
|
-
return "TemplatesRead"
|
|
272
|
+
return "TemplatesRead";
|
|
269
273
|
}
|
|
270
274
|
}
|
|
271
275
|
|
|
272
|
-
export type TariPermission =
|
|
276
|
+
export type TariPermission =
|
|
277
|
+
| TariPermissionNftGetOwnershipProof
|
|
278
|
+
| TariPermissionAccountBalance
|
|
279
|
+
| TariPermissionAccountInfo
|
|
280
|
+
| TariPermissionAccountList
|
|
281
|
+
| TariPermissionKeyList
|
|
282
|
+
| TariPermissionTransactionGet
|
|
283
|
+
| TariPermissionTransactionSend
|
|
284
|
+
| TariPermissionGetNft
|
|
285
|
+
| TariPermissionTransactionsGet
|
|
286
|
+
| TariPermissionSubstatesRead
|
|
287
|
+
| TariPermissionTemplatesRead
|
|
288
|
+
| string;
|
|
273
289
|
|
|
274
290
|
// export enum TariPermission {
|
|
275
291
|
// AccountBalance = "AccountBalance",
|
|
@@ -289,7 +305,7 @@ export class TariPermissions {
|
|
|
289
305
|
private permissions: TariPermission[];
|
|
290
306
|
|
|
291
307
|
constructor() {
|
|
292
|
-
this.permissions = []
|
|
308
|
+
this.permissions = [];
|
|
293
309
|
}
|
|
294
310
|
|
|
295
311
|
addPermission(permission: TariPermission): this {
|
|
@@ -307,6 +323,7 @@ export class TariPermissions {
|
|
|
307
323
|
}
|
|
308
324
|
}
|
|
309
325
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
326
|
+
export type TappletPermissions = {
|
|
327
|
+
requiredPermissions: TariPermission[];
|
|
328
|
+
optionalPermissions: TariPermission[];
|
|
329
|
+
};
|
|
@@ -1,34 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ListTemplatesResponse } from "@tari-project/typescript-bindings";
|
|
2
2
|
import {
|
|
3
|
-
Account,
|
|
4
|
-
SubmitTransactionRequest,
|
|
5
3
|
TransactionResult,
|
|
6
|
-
SubmitTransactionResponse,
|
|
7
|
-
VaultBalances,
|
|
8
4
|
TemplateDefinition,
|
|
9
5
|
Substate,
|
|
10
6
|
ListSubstatesResponse,
|
|
7
|
+
GetSubstateRequest,
|
|
8
|
+
ListSubstatesRequest,
|
|
11
9
|
} from "./types";
|
|
12
10
|
|
|
13
11
|
export interface TariProvider {
|
|
14
12
|
providerName: string;
|
|
15
13
|
isConnected(): boolean;
|
|
16
|
-
|
|
17
|
-
getSubstate(substate_address: string): Promise<Substate>;
|
|
18
|
-
submitTransaction(req: SubmitTransactionRequest): Promise<SubmitTransactionResponse>;
|
|
14
|
+
getSubstate(req: GetSubstateRequest): Promise<Substate>;
|
|
19
15
|
getTransactionResult(transactionId: string): Promise<TransactionResult>;
|
|
20
16
|
getTemplateDefinition(template_address: string): Promise<TemplateDefinition>;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
viewKeyId: number,
|
|
24
|
-
vaultId: string,
|
|
25
|
-
min: number | null,
|
|
26
|
-
max: number | null,
|
|
27
|
-
): Promise<VaultBalances>;
|
|
28
|
-
listSubstates(
|
|
29
|
-
filter_by_template: string | null,
|
|
30
|
-
filter_by_type: SubstateType | null,
|
|
31
|
-
limit: number | null,
|
|
32
|
-
offset: number | null,
|
|
33
|
-
): Promise<ListSubstatesResponse>;
|
|
17
|
+
listSubstates(req: ListSubstatesRequest): Promise<ListSubstatesResponse>;
|
|
18
|
+
listTemplates(limit?: number): Promise<ListTemplatesResponse>;
|
|
34
19
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FinalizeResult } from "@tari-project/typescript-bindings";
|
|
1
|
+
import { FinalizeResult, SubstateType } from "@tari-project/typescript-bindings";
|
|
2
2
|
|
|
3
3
|
export type SubstateMetadata = {
|
|
4
4
|
substate_id: string;
|
|
@@ -12,25 +12,6 @@ export type SubstateRequirement = {
|
|
|
12
12
|
version?: number | null;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export type SubmitTransactionRequest = {
|
|
16
|
-
network: number;
|
|
17
|
-
account_id: number;
|
|
18
|
-
instructions: object[];
|
|
19
|
-
fee_instructions: object[];
|
|
20
|
-
inputs: object[];
|
|
21
|
-
input_refs: object[];
|
|
22
|
-
required_substates: SubstateRequirement[];
|
|
23
|
-
is_dry_run: boolean;
|
|
24
|
-
min_epoch: number | null;
|
|
25
|
-
max_epoch: number | null;
|
|
26
|
-
is_seal_signer_authorized: boolean;
|
|
27
|
-
detect_inputs_use_unversioned: boolean;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type SubmitTransactionResponse = {
|
|
31
|
-
transaction_id: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
15
|
export type TransactionResult = {
|
|
35
16
|
transaction_id: string;
|
|
36
17
|
status: TransactionStatus;
|
|
@@ -71,6 +52,41 @@ export interface TemplateDefinition {
|
|
|
71
52
|
[key: string]: any;
|
|
72
53
|
}
|
|
73
54
|
|
|
55
|
+
export type SubmitTransactionRequest = {
|
|
56
|
+
network: number;
|
|
57
|
+
account_id: number;
|
|
58
|
+
instructions: object[];
|
|
59
|
+
fee_instructions: object[];
|
|
60
|
+
inputs: object[];
|
|
61
|
+
input_refs: object[];
|
|
62
|
+
required_substates: SubstateRequirement[];
|
|
63
|
+
is_dry_run: boolean;
|
|
64
|
+
min_epoch: number | null;
|
|
65
|
+
max_epoch: number | null;
|
|
66
|
+
is_seal_signer_authorized: boolean;
|
|
67
|
+
detect_inputs_use_unversioned: boolean;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type SubmitTransactionResponse = {
|
|
71
|
+
transaction_id: string;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export type ListSubstatesRequest = {
|
|
75
|
+
filter_by_template: string | null;
|
|
76
|
+
filter_by_type: SubstateType | null;
|
|
77
|
+
limit: number | null;
|
|
78
|
+
offset: number | null;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type ListSubstatesResponse = {
|
|
82
|
+
substates: Array<SubstateMetadata>;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export type GetSubstateRequest = {
|
|
86
|
+
substate_address: string;
|
|
87
|
+
version: number | null;
|
|
88
|
+
};
|
|
89
|
+
|
|
74
90
|
export interface Substate {
|
|
75
91
|
value: any;
|
|
76
92
|
address: {
|
|
@@ -78,7 +94,3 @@ export interface Substate {
|
|
|
78
94
|
version: number;
|
|
79
95
|
};
|
|
80
96
|
}
|
|
81
|
-
|
|
82
|
-
export type ListSubstatesResponse = {
|
|
83
|
-
substates: Array<SubstateMetadata>;
|
|
84
|
-
};
|