@tari-project/tari-permissions 0.4.0 → 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/dist/helpers.d.ts +2 -0
- package/dist/helpers.js +29 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/tari_permissions.d.ts +4 -0
- package/dist/tari_permissions.js +22 -25
- package/package.json +1 -1
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TariPermissionAccountBalance, TariPermissionAccountInfo, TariPermissionAccountList, TariPermissionGetNft, TariPermissionKeyList, TariPermissionNftGetOwnershipProof, TariPermissionTransactionGet, TariPermissionTransactionSend, } from "./tari_permissions";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
export function createPermissionFromType(permission) {
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(permission, "AccountBalance")) {
|
|
5
|
+
return new TariPermissionAccountBalance(permission.AccountBalance);
|
|
6
|
+
}
|
|
7
|
+
else if (permission === "AccountInfo") {
|
|
8
|
+
return new TariPermissionAccountInfo();
|
|
9
|
+
}
|
|
10
|
+
else if (Object.prototype.hasOwnProperty.call(permission, "AccountList")) {
|
|
11
|
+
return new TariPermissionAccountList(permission.AccountList);
|
|
12
|
+
}
|
|
13
|
+
else if (permission == "KeyList") {
|
|
14
|
+
return new TariPermissionKeyList();
|
|
15
|
+
}
|
|
16
|
+
else if (Object.prototype.hasOwnProperty.call(permission, "TransactionSend")) {
|
|
17
|
+
return new TariPermissionTransactionSend(permission.TransactionSend);
|
|
18
|
+
}
|
|
19
|
+
else if (permission === "TransactionGet") {
|
|
20
|
+
return new TariPermissionTransactionGet();
|
|
21
|
+
}
|
|
22
|
+
else if (Object.prototype.hasOwnProperty.call(permission, "GetNft")) {
|
|
23
|
+
return new TariPermissionGetNft(permission.GetNft);
|
|
24
|
+
}
|
|
25
|
+
else if (Object.prototype.hasOwnProperty.call(permission, "NftGetOwnershipProof")) {
|
|
26
|
+
return new TariPermissionNftGetOwnershipProof(permission.NftGetOwnershipProof);
|
|
27
|
+
}
|
|
28
|
+
return permission;
|
|
29
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./tari_permissions";
|
|
2
|
+
export * from "./helpers";
|
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./tari_permissions";
|
|
2
|
+
export * from "./helpers";
|
package/dist/tari_permissions.js
CHANGED
|
@@ -62,12 +62,12 @@ export class NonFungibleId {
|
|
|
62
62
|
}
|
|
63
63
|
toJSON() {
|
|
64
64
|
switch (typeof this.value) {
|
|
65
|
-
case
|
|
66
|
-
return {
|
|
67
|
-
case
|
|
68
|
-
return {
|
|
65
|
+
case "string":
|
|
66
|
+
return { string: this.value };
|
|
67
|
+
case "number":
|
|
68
|
+
return { Uint64: this.value };
|
|
69
69
|
}
|
|
70
|
-
return {
|
|
70
|
+
return { U256: this.value };
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
export class NonFungibleAddressContents {
|
|
@@ -78,7 +78,7 @@ export class NonFungibleAddressContents {
|
|
|
78
78
|
this.id = id;
|
|
79
79
|
}
|
|
80
80
|
toJSON() {
|
|
81
|
-
return {
|
|
81
|
+
return { resource_address: this.resource_address, id: this.id };
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
export class NonFungibleAddress {
|
|
@@ -98,7 +98,7 @@ export class NonFungibleIndexAddress {
|
|
|
98
98
|
this.index = index;
|
|
99
99
|
}
|
|
100
100
|
toJSON() {
|
|
101
|
-
return {
|
|
101
|
+
return { resource_address: this.resource_address, index: this.index };
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
export class ComponentAddress {
|
|
@@ -126,22 +126,22 @@ export class SubstateAddress {
|
|
|
126
126
|
}
|
|
127
127
|
toJSON() {
|
|
128
128
|
if (this.value instanceof ComponentAddress) {
|
|
129
|
-
return {
|
|
129
|
+
return { Component: this.value };
|
|
130
130
|
}
|
|
131
131
|
else if (this.value instanceof ResourceAddress) {
|
|
132
|
-
return {
|
|
132
|
+
return { Resource: this.value };
|
|
133
133
|
}
|
|
134
134
|
else if (this.value instanceof VaultId) {
|
|
135
|
-
return {
|
|
135
|
+
return { Vault: this.value };
|
|
136
136
|
}
|
|
137
137
|
else if (this.value instanceof UnclaimedConfidentialOutputAddress) {
|
|
138
|
-
return {
|
|
138
|
+
return { UnclaimedConfidentialOutput: this.value };
|
|
139
139
|
}
|
|
140
140
|
else if (this.value instanceof NonFungibleAddress) {
|
|
141
|
-
return {
|
|
141
|
+
return { NonFungible: this.value };
|
|
142
142
|
}
|
|
143
143
|
else if (this.value instanceof NonFungibleIndexAddress) {
|
|
144
|
-
return {
|
|
144
|
+
return { NonFungibleIndex: this.value };
|
|
145
145
|
}
|
|
146
146
|
throw "Unknown type";
|
|
147
147
|
}
|
|
@@ -153,7 +153,7 @@ export class TariPermissionAccountBalance {
|
|
|
153
153
|
}
|
|
154
154
|
toJSON() {
|
|
155
155
|
console.log("stringify", this.value);
|
|
156
|
-
return {
|
|
156
|
+
return { AccountBalance: this.value };
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
export class TariPermissionAccountInfo {
|
|
@@ -173,12 +173,12 @@ export class TariPermissionAccountList {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
toJSON() {
|
|
176
|
-
console.log(
|
|
176
|
+
console.log("JSON TariPermissionAccountList", this.value);
|
|
177
177
|
if (this.value === undefined) {
|
|
178
|
-
return {
|
|
178
|
+
return { AccountList: null };
|
|
179
179
|
}
|
|
180
180
|
else {
|
|
181
|
-
return {
|
|
181
|
+
return { AccountList: this.value };
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
}
|
|
@@ -200,12 +200,12 @@ export class TariPermissionTransactionSend {
|
|
|
200
200
|
this.value = value;
|
|
201
201
|
}
|
|
202
202
|
toJSON() {
|
|
203
|
-
console.log(
|
|
203
|
+
console.log("JSON TariPermissionTransactionSend", this.value);
|
|
204
204
|
if (this.value === undefined) {
|
|
205
|
-
return {
|
|
205
|
+
return { TransactionSend: null };
|
|
206
206
|
}
|
|
207
207
|
else {
|
|
208
|
-
return {
|
|
208
|
+
return { TransactionSend: this.value };
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
}
|
|
@@ -217,7 +217,7 @@ export class TariPermissionGetNft {
|
|
|
217
217
|
this.value1 = value1;
|
|
218
218
|
}
|
|
219
219
|
toJSON() {
|
|
220
|
-
return {
|
|
220
|
+
return { GetNft: [this.value0, this.value1] };
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
export class TariPermissionNftGetOwnershipProof {
|
|
@@ -226,7 +226,7 @@ export class TariPermissionNftGetOwnershipProof {
|
|
|
226
226
|
this.value = value;
|
|
227
227
|
}
|
|
228
228
|
toJSON() {
|
|
229
|
-
return {
|
|
229
|
+
return { NftGetOwnershipProof: this.value };
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
export class TariPermissionTransactionsGet {
|
|
@@ -277,6 +277,3 @@ export class TariPermissions {
|
|
|
277
277
|
return this.permissions;
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
|
-
// TariPermissionType.prototype.toString = function () {
|
|
281
|
-
// return "wtf"
|
|
282
|
-
// }
|