@tari-project/tarijs 0.3.0 → 0.4.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.
Files changed (105) hide show
  1. package/dist/index.d.ts +11 -10
  2. package/dist/index.js +10 -9
  3. package/dist/network.d.ts +8 -0
  4. package/dist/network.js +9 -0
  5. package/dist/templates/Account.d.ts +2 -2
  6. package/dist/templates/Pool.d.ts +1 -2
  7. package/dist/templates/Tariswap.d.ts +1 -2
  8. package/dist/templates/TemplateFactory.d.ts +1 -1
  9. package/dist/templates/TestFaucet.d.ts +1 -1
  10. package/package.json +20 -12
  11. package/README.md +0 -46
  12. package/dist/builders/helpers/index.d.ts +0 -2
  13. package/dist/builders/helpers/index.js +0 -2
  14. package/dist/builders/helpers/submitTransaction.d.ts +0 -13
  15. package/dist/builders/helpers/submitTransaction.js +0 -59
  16. package/dist/builders/helpers/workspace.d.ts +0 -23
  17. package/dist/builders/helpers/workspace.js +0 -29
  18. package/dist/builders/index.d.ts +0 -3
  19. package/dist/builders/index.js +0 -3
  20. package/dist/builders/transaction/TransactionBuilder.d.ts +0 -44
  21. package/dist/builders/transaction/TransactionBuilder.js +0 -164
  22. package/dist/builders/transaction/TransactionRequest.d.ts +0 -27
  23. package/dist/builders/transaction/TransactionRequest.js +0 -67
  24. package/dist/builders/transaction/index.d.ts +0 -2
  25. package/dist/builders/transaction/index.js +0 -2
  26. package/dist/builders/types/Amount.d.ts +0 -23
  27. package/dist/builders/types/Amount.js +0 -93
  28. package/dist/builders/types/Arg.d.ts +0 -1
  29. package/dist/builders/types/Arg.js +0 -1
  30. package/dist/builders/types/Builder.d.ts +0 -47
  31. package/dist/builders/types/Builder.js +0 -1
  32. package/dist/builders/types/ComponentAddress.d.ts +0 -1
  33. package/dist/builders/types/ComponentAddress.js +0 -1
  34. package/dist/builders/types/ConfidentialClaim.d.ts +0 -8
  35. package/dist/builders/types/ConfidentialClaim.js +0 -1
  36. package/dist/builders/types/ConfidentialOutput.d.ts +0 -8
  37. package/dist/builders/types/ConfidentialOutput.js +0 -1
  38. package/dist/builders/types/ConfidentialOutputStatement.d.ts +0 -9
  39. package/dist/builders/types/ConfidentialOutputStatement.js +0 -1
  40. package/dist/builders/types/ConfidentialStatement.d.ts +0 -8
  41. package/dist/builders/types/ConfidentialStatement.js +0 -1
  42. package/dist/builders/types/ConfidentialWithdrawProof.d.ts +0 -7
  43. package/dist/builders/types/ConfidentialWithdrawProof.js +0 -1
  44. package/dist/builders/types/ElgamalVerifiableBalance.d.ts +0 -4
  45. package/dist/builders/types/ElgamalVerifiableBalance.js +0 -1
  46. package/dist/builders/types/Epoch.d.ts +0 -1
  47. package/dist/builders/types/Epoch.js +0 -1
  48. package/dist/builders/types/FinalizeResult.d.ts +0 -20
  49. package/dist/builders/types/FinalizeResult.js +0 -1
  50. package/dist/builders/types/Instruction.d.ts +0 -56
  51. package/dist/builders/types/Instruction.js +0 -1
  52. package/dist/builders/types/ResourceAddress.d.ts +0 -1
  53. package/dist/builders/types/ResourceAddress.js +0 -2
  54. package/dist/builders/types/SubstateDiff.d.ts +0 -7
  55. package/dist/builders/types/SubstateDiff.js +0 -1
  56. package/dist/builders/types/SubstateRequirement.d.ts +0 -5
  57. package/dist/builders/types/SubstateRequirement.js +0 -1
  58. package/dist/builders/types/TemplateAddress.d.ts +0 -1
  59. package/dist/builders/types/TemplateAddress.js +0 -2
  60. package/dist/builders/types/Transaction.d.ts +0 -15
  61. package/dist/builders/types/Transaction.js +0 -1
  62. package/dist/builders/types/TransactionId.d.ts +0 -1
  63. package/dist/builders/types/TransactionId.js +0 -1
  64. package/dist/builders/types/TransactionResult.d.ts +0 -22
  65. package/dist/builders/types/TransactionResult.js +0 -10
  66. package/dist/builders/types/TransactionSignature.d.ts +0 -4
  67. package/dist/builders/types/TransactionSignature.js +0 -1
  68. package/dist/builders/types/UnsignedTransaction.d.ts +0 -12
  69. package/dist/builders/types/UnsignedTransaction.js +0 -1
  70. package/dist/builders/types/VersionedSubstateId.d.ts +0 -5
  71. package/dist/builders/types/VersionedSubstateId.js +0 -1
  72. package/dist/builders/types/ViewableBalanceProof.d.ts +0 -10
  73. package/dist/builders/types/ViewableBalanceProof.js +0 -2
  74. package/dist/builders/types/Workspace.d.ts +0 -3
  75. package/dist/builders/types/Workspace.js +0 -1
  76. package/dist/builders/types/index.d.ts +0 -24
  77. package/dist/builders/types/index.js +0 -2
  78. package/dist/providers/index.d.ts +0 -16
  79. package/dist/providers/index.js +0 -1
  80. package/dist/providers/metamask/index.d.ts +0 -30
  81. package/dist/providers/metamask/index.js +0 -168
  82. package/dist/providers/metamask/utils.d.ts +0 -38
  83. package/dist/providers/metamask/utils.js +0 -55
  84. package/dist/providers/tari_universe/index.d.ts +0 -3
  85. package/dist/providers/tari_universe/index.js +0 -3
  86. package/dist/providers/tari_universe/provider.d.ts +0 -23
  87. package/dist/providers/tari_universe/provider.js +0 -89
  88. package/dist/providers/tari_universe/types.d.ts +0 -30
  89. package/dist/providers/tari_universe/types.js +0 -1
  90. package/dist/providers/tari_universe/utils.d.ts +0 -2
  91. package/dist/providers/tari_universe/utils.js +0 -16
  92. package/dist/providers/types.d.ts +0 -66
  93. package/dist/providers/types.js +0 -10
  94. package/dist/providers/wallet_daemon/index.d.ts +0 -3
  95. package/dist/providers/wallet_daemon/index.js +0 -3
  96. package/dist/providers/wallet_daemon/provider.d.ts +0 -35
  97. package/dist/providers/wallet_daemon/provider.js +0 -173
  98. package/dist/providers/wallet_daemon/tari_permissions.d.ts +0 -216
  99. package/dist/providers/wallet_daemon/tari_permissions.js +0 -282
  100. package/dist/providers/wallet_daemon/webrtc.d.ts +0 -20
  101. package/dist/providers/wallet_daemon/webrtc.js +0 -201
  102. package/dist/providers/wallet_daemon/webrtc_transport.d.ts +0 -10
  103. package/dist/providers/wallet_daemon/webrtc_transport.js +0 -18
  104. package/dist/providers/walletconnect/index.d.ts +0 -23
  105. package/dist/providers/walletconnect/index.js +0 -217
@@ -1,173 +0,0 @@
1
- import { TariPermissions, } from "./tari_permissions";
2
- import { TariConnection } from "./webrtc";
3
- import { TransactionStatus, } from "../types";
4
- import { WalletDaemonClient, stringToSubstateId, substateIdToString, } from "@tari-project/wallet_jrpc_client";
5
- import { WebRtcRpcTransport } from "./webrtc_transport";
6
- export const WalletDaemonNotConnected = 'WALLET_DAEMON_NOT_CONNECTED';
7
- export const Unsupported = 'UNSUPPORTED';
8
- export class WalletDaemonTariProvider {
9
- providerName = "WalletDaemon";
10
- params;
11
- client;
12
- constructor(params, connection) {
13
- this.params = params;
14
- this.client = connection;
15
- }
16
- static async build(params) {
17
- const allPermissions = new TariPermissions();
18
- allPermissions.addPermissions(params.permissions);
19
- allPermissions.addPermissions(params.optionalPermissions);
20
- console.log({ allPermissions });
21
- let connection = new TariConnection(params.signalingServerUrl, params.webRtcConfig);
22
- const client = WalletDaemonClient.new(WebRtcRpcTransport.new(connection));
23
- await connection.init(allPermissions, (conn) => {
24
- params.onConnection?.();
25
- if (conn.token) {
26
- client.setToken(conn.token);
27
- }
28
- });
29
- return new WalletDaemonTariProvider(params, client);
30
- }
31
- get token() {
32
- return this.client.getTransport().token();
33
- }
34
- get tokenUrl() {
35
- if (!this.token) {
36
- return undefined;
37
- }
38
- const name = this.params.name && encodeURIComponent(this.params.name) || '';
39
- const token = this.token;
40
- const permissions = JSON.stringify(this.params.permissions);
41
- const optionalPermissions = JSON.stringify(this.params.optionalPermissions);
42
- return `tari://${name}/${token}/${permissions}/${optionalPermissions}`;
43
- }
44
- isConnected() {
45
- return this.client.getTransport().isConnected();
46
- }
47
- async createFreeTestCoins() {
48
- const res = await this.client.createFreeTestCoins({
49
- account: { Name: "template_web" },
50
- amount: 1000000,
51
- max_fee: null,
52
- key_id: 0
53
- });
54
- return {
55
- account_id: res.account.key_index,
56
- address: res.account.address.Component,
57
- public_key: res.public_key,
58
- resources: []
59
- };
60
- }
61
- async getAccount() {
62
- const { account, public_key } = await this.client.accountsGetDefault({});
63
- const { balances } = await this.client.accountsGetBalances({ account: { ComponentAddress: account.address.Component }, refresh: false });
64
- return {
65
- account_id: account.key_index,
66
- address: account.address.Component,
67
- public_key,
68
- // TODO: should be vaults not resources
69
- resources: balances.map((b) => ({
70
- type: b.resource_type,
71
- resource_address: b.resource_address,
72
- balance: b.balance + b.confidential_balance,
73
- vault_id: ('Vault' in b.vault_address) ? b.vault_address.Vault : b.vault_address,
74
- token_symbol: b.token_symbol,
75
- }))
76
- };
77
- }
78
- async getAccountBalances(componentAddress) {
79
- return await this.client.accountsGetBalances({ account: { ComponentAddress: componentAddress }, refresh: true });
80
- }
81
- async getSubstate(substate_id) {
82
- const substateId = stringToSubstateId(substate_id);
83
- const { value, record } = await this.client.substatesGet({ substate_id: substateId });
84
- return {
85
- value,
86
- address: {
87
- substate_id: substateIdToString(record.substate_id),
88
- version: record.version
89
- }
90
- };
91
- }
92
- async submitTransaction(req) {
93
- const params = {
94
- transaction: {
95
- instructions: req.instructions,
96
- fee_instructions: req.fee_instructions,
97
- inputs: req.required_substates.map((s) => ({
98
- // TODO: Hmm The bindings want a SubstateId object, but the wallet only wants a string. Any is used to skip type checking here
99
- substate_id: s.substate_id,
100
- version: s.version
101
- })),
102
- min_epoch: null,
103
- max_epoch: null,
104
- },
105
- signing_key_index: req.account_id,
106
- autofill_inputs: [],
107
- detect_inputs: true,
108
- proof_ids: [],
109
- };
110
- const res = await this.client.submitTransaction(params);
111
- return { transaction_id: res.transaction_id };
112
- }
113
- async getTransactionResult(transactionId) {
114
- const res = await this.client.getTransactionResult({ transaction_id: transactionId });
115
- return {
116
- transaction_id: transactionId,
117
- status: convertStringToTransactionStatus(res.status),
118
- result: res.result,
119
- };
120
- }
121
- async getPublicKey(branch, index) {
122
- const res = await this.client.createKey({ branch: branch, specific_index: index });
123
- return res.public_key;
124
- }
125
- async getTemplateDefinition(template_address) {
126
- let resp = await this.client.templatesGet({ template_address });
127
- return resp.template_definition;
128
- }
129
- async getConfidentialVaultBalances(viewKeyId, vaultId, min = null, max = null) {
130
- const res = await this.client.viewVaultBalance({
131
- view_key_id: viewKeyId,
132
- vault_id: vaultId,
133
- minimum_expected_value: min,
134
- maximum_expected_value: max,
135
- });
136
- return { balances: res.balances };
137
- }
138
- async listSubstates(filter_by_template, filter_by_type, limit, offset) {
139
- const resp = await this.client.substatesList({
140
- filter_by_template,
141
- filter_by_type,
142
- limit,
143
- offset
144
- });
145
- const substates = resp.substates.map((s) => ({
146
- substate_id: substateIdToString(s.substate_id),
147
- module_name: s.module_name,
148
- version: s.version,
149
- template_address: s.template_address
150
- }));
151
- return { substates };
152
- }
153
- }
154
- function convertStringToTransactionStatus(status) {
155
- switch (status) {
156
- case "New":
157
- return TransactionStatus.New;
158
- case "DryRun":
159
- return TransactionStatus.DryRun;
160
- case "Pending":
161
- return TransactionStatus.Pending;
162
- case "Accepted":
163
- return TransactionStatus.Accepted;
164
- case "Rejected":
165
- return TransactionStatus.Rejected;
166
- case "InvalidTransaction":
167
- return TransactionStatus.InvalidTransaction;
168
- case "OnlyFeeAccepted":
169
- return TransactionStatus.OnlyFeeAccepted;
170
- default:
171
- throw new Error(`Unknown status: ${status}`);
172
- }
173
- }
@@ -1,216 +0,0 @@
1
- export declare class Hash {
2
- private value;
3
- constructor(value: number[]);
4
- toJSON(): number[];
5
- }
6
- export declare enum TAG {
7
- ComponentAddress = 128,
8
- Metadata = 129,
9
- NonFungibleAddress = 130,
10
- ResourceAddress = 131,
11
- VaultId = 132,
12
- TransactionReceipt = 134,
13
- FeeClaim = 135
14
- }
15
- export declare class Tagged {
16
- private value;
17
- private tag;
18
- constructor(tag: number, value: any);
19
- toJSON(): {
20
- "@@TAGGED@@": any[];
21
- };
22
- }
23
- export declare class ResourceAddress {
24
- private tagged;
25
- constructor(hash: Hash);
26
- toJSON(): {
27
- "@@TAGGED@@": any[];
28
- };
29
- }
30
- export declare class UnclaimedConfidentialOutputAddress {
31
- private hash;
32
- constructor(hash: Hash);
33
- toJSON(): number[];
34
- }
35
- export type u64 = number;
36
- export type u32 = number;
37
- export declare class U256 {
38
- private value;
39
- constructor(value: number[]);
40
- toJSON(): number[];
41
- }
42
- export type NonFungibleIdType = u32 | u64 | string | U256;
43
- export declare class NonFungibleId {
44
- private value;
45
- constructor(value: NonFungibleIdType);
46
- toJSON(): {
47
- string: string;
48
- Uint64?: undefined;
49
- U256?: undefined;
50
- } | {
51
- Uint64: number;
52
- string?: undefined;
53
- U256?: undefined;
54
- } | {
55
- U256: U256;
56
- string?: undefined;
57
- Uint64?: undefined;
58
- };
59
- }
60
- export declare class NonFungibleAddressContents {
61
- private resource_address;
62
- private id;
63
- constructor(resource_address: ResourceAddress, id: NonFungibleId);
64
- toJSON(): {
65
- resource_address: ResourceAddress;
66
- id: NonFungibleId;
67
- };
68
- }
69
- export declare class NonFungibleAddress {
70
- private tagged;
71
- constructor(value: NonFungibleAddressContents);
72
- toJSON(): {
73
- "@@TAGGED@@": any[];
74
- };
75
- }
76
- export declare class NonFungibleIndexAddress {
77
- private resource_address;
78
- private index;
79
- constructor(resource_address: ResourceAddress, index: number);
80
- toJSON(): {
81
- resource_address: ResourceAddress;
82
- index: number;
83
- };
84
- }
85
- export declare class ComponentAddress {
86
- private tagged;
87
- constructor(hash: Hash);
88
- toJSON(): {
89
- "@@TAGGED@@": any[];
90
- };
91
- }
92
- export declare class VaultId {
93
- private tagged;
94
- constructor(hash: Hash);
95
- toJSON(): {
96
- "@@TAGGED@@": any[];
97
- };
98
- }
99
- export type SubstateAddressType = ResourceAddress | ComponentAddress | VaultId | UnclaimedConfidentialOutputAddress | NonFungibleAddress | NonFungibleIndexAddress;
100
- export declare class SubstateAddress {
101
- private value;
102
- constructor(value: SubstateAddressType);
103
- toJSON(): {
104
- Component: ComponentAddress;
105
- Resource?: undefined;
106
- Vault?: undefined;
107
- UnclaimedConfidentialOutput?: undefined;
108
- NonFungible?: undefined;
109
- NonFungibleIndex?: undefined;
110
- } | {
111
- Resource: ResourceAddress;
112
- Component?: undefined;
113
- Vault?: undefined;
114
- UnclaimedConfidentialOutput?: undefined;
115
- NonFungible?: undefined;
116
- NonFungibleIndex?: undefined;
117
- } | {
118
- Vault: VaultId;
119
- Component?: undefined;
120
- Resource?: undefined;
121
- UnclaimedConfidentialOutput?: undefined;
122
- NonFungible?: undefined;
123
- NonFungibleIndex?: undefined;
124
- } | {
125
- UnclaimedConfidentialOutput: UnclaimedConfidentialOutputAddress;
126
- Component?: undefined;
127
- Resource?: undefined;
128
- Vault?: undefined;
129
- NonFungible?: undefined;
130
- NonFungibleIndex?: undefined;
131
- } | {
132
- NonFungible: NonFungibleAddress;
133
- Component?: undefined;
134
- Resource?: undefined;
135
- Vault?: undefined;
136
- UnclaimedConfidentialOutput?: undefined;
137
- NonFungibleIndex?: undefined;
138
- } | {
139
- NonFungibleIndex: NonFungibleIndexAddress;
140
- Component?: undefined;
141
- Resource?: undefined;
142
- Vault?: undefined;
143
- UnclaimedConfidentialOutput?: undefined;
144
- NonFungible?: undefined;
145
- };
146
- }
147
- export declare class TariPermissionAccountBalance {
148
- private value;
149
- constructor(value: SubstateAddress);
150
- toJSON(): {
151
- AccountBalance: SubstateAddress;
152
- };
153
- }
154
- export declare class TariPermissionAccountInfo {
155
- constructor();
156
- toJSON(): string;
157
- }
158
- export declare class TariPermissionAccountList {
159
- private value?;
160
- constructor(value?: ComponentAddress);
161
- toJSON(): {
162
- AccountList: ComponentAddress | null;
163
- };
164
- }
165
- export declare class TariPermissionKeyList {
166
- constructor();
167
- toJSON(): string;
168
- }
169
- export declare class TariPermissionTransactionGet {
170
- constructor();
171
- toJSON(): string;
172
- }
173
- export declare class TariPermissionTransactionSend {
174
- private value?;
175
- constructor(value?: SubstateAddress);
176
- toJSON(): {
177
- TransactionSend: null;
178
- } | {
179
- TransactionSend: SubstateAddress;
180
- };
181
- }
182
- export declare class TariPermissionGetNft {
183
- private value0?;
184
- private value1?;
185
- constructor(value0?: SubstateAddress, value1?: ResourceAddress);
186
- toJSON(): {
187
- GetNft: (ResourceAddress | SubstateAddress | undefined)[];
188
- };
189
- }
190
- export declare class TariPermissionNftGetOwnershipProof {
191
- private value?;
192
- constructor(value?: ResourceAddress);
193
- toJSON(): {
194
- NftGetOwnershipProof: ResourceAddress | undefined;
195
- };
196
- }
197
- export declare class TariPermissionTransactionsGet {
198
- constructor();
199
- toJSON(): string;
200
- }
201
- export declare class TariPermissionSubstatesRead {
202
- constructor();
203
- toJSON(): string;
204
- }
205
- export declare class TariPermissionTemplatesRead {
206
- constructor();
207
- toJSON(): string;
208
- }
209
- export type TariPermission = TariPermissionNftGetOwnershipProof | TariPermissionAccountBalance | TariPermissionAccountInfo | TariPermissionAccountList | TariPermissionKeyList | TariPermissionTransactionGet | TariPermissionTransactionSend | TariPermissionGetNft | TariPermissionTransactionsGet | TariPermissionSubstatesRead | TariPermissionTemplatesRead | string;
210
- export declare class TariPermissions {
211
- private permissions;
212
- constructor();
213
- addPermission(permission: TariPermission): this;
214
- addPermissions(other: TariPermissions): this;
215
- toJSON(): TariPermission[];
216
- }
@@ -1,282 +0,0 @@
1
- export class Hash {
2
- value;
3
- constructor(value) {
4
- this.value = value;
5
- }
6
- toJSON() {
7
- return this.value;
8
- }
9
- }
10
- export var TAG;
11
- (function (TAG) {
12
- TAG[TAG["ComponentAddress"] = 128] = "ComponentAddress";
13
- TAG[TAG["Metadata"] = 129] = "Metadata";
14
- TAG[TAG["NonFungibleAddress"] = 130] = "NonFungibleAddress";
15
- TAG[TAG["ResourceAddress"] = 131] = "ResourceAddress";
16
- TAG[TAG["VaultId"] = 132] = "VaultId";
17
- TAG[TAG["TransactionReceipt"] = 134] = "TransactionReceipt";
18
- TAG[TAG["FeeClaim"] = 135] = "FeeClaim";
19
- })(TAG || (TAG = {}));
20
- export class Tagged {
21
- value;
22
- tag;
23
- constructor(tag, value) {
24
- this.tag = tag;
25
- this.value = value;
26
- }
27
- toJSON() {
28
- return { "@@TAGGED@@": [this.tag, this.value] };
29
- }
30
- }
31
- export class ResourceAddress {
32
- tagged;
33
- constructor(hash) {
34
- this.tagged = new Tagged(TAG.ResourceAddress, hash);
35
- }
36
- toJSON() {
37
- return this.tagged.toJSON();
38
- }
39
- }
40
- export class UnclaimedConfidentialOutputAddress {
41
- hash;
42
- constructor(hash) {
43
- this.hash = hash;
44
- }
45
- toJSON() {
46
- return this.hash.toJSON();
47
- }
48
- }
49
- export class U256 {
50
- value;
51
- constructor(value) {
52
- this.value = value;
53
- }
54
- toJSON() {
55
- return this.value;
56
- }
57
- }
58
- export class NonFungibleId {
59
- value;
60
- constructor(value) {
61
- this.value = value;
62
- }
63
- toJSON() {
64
- switch (typeof this.value) {
65
- case 'string':
66
- return { 'string': this.value };
67
- case 'number':
68
- return { 'Uint64': this.value };
69
- }
70
- return { 'U256': this.value };
71
- }
72
- }
73
- export class NonFungibleAddressContents {
74
- resource_address;
75
- id;
76
- constructor(resource_address, id) {
77
- this.resource_address = resource_address;
78
- this.id = id;
79
- }
80
- toJSON() {
81
- return { "resource_address": this.resource_address, "id": this.id };
82
- }
83
- }
84
- export class NonFungibleAddress {
85
- tagged;
86
- constructor(value) {
87
- this.tagged = new Tagged(TAG.NonFungibleAddress, value);
88
- }
89
- toJSON() {
90
- return this.tagged.toJSON();
91
- }
92
- }
93
- export class NonFungibleIndexAddress {
94
- resource_address;
95
- index;
96
- constructor(resource_address, index) {
97
- this.resource_address = resource_address;
98
- this.index = index;
99
- }
100
- toJSON() {
101
- return { "resource_address": this.resource_address, "index": this.index };
102
- }
103
- }
104
- export class ComponentAddress {
105
- tagged;
106
- constructor(hash) {
107
- this.tagged = new Tagged(TAG.ComponentAddress, hash);
108
- }
109
- toJSON() {
110
- return this.tagged.toJSON();
111
- }
112
- }
113
- export class VaultId {
114
- tagged;
115
- constructor(hash) {
116
- this.tagged = new Tagged(TAG.VaultId, hash);
117
- }
118
- toJSON() {
119
- return this.tagged.toJSON();
120
- }
121
- }
122
- export class SubstateAddress {
123
- value;
124
- constructor(value) {
125
- this.value = value;
126
- }
127
- toJSON() {
128
- if (this.value instanceof ComponentAddress) {
129
- return { "Component": this.value };
130
- }
131
- else if (this.value instanceof ResourceAddress) {
132
- return { "Resource": this.value };
133
- }
134
- else if (this.value instanceof VaultId) {
135
- return { "Vault": this.value };
136
- }
137
- else if (this.value instanceof UnclaimedConfidentialOutputAddress) {
138
- return { "UnclaimedConfidentialOutput": this.value };
139
- }
140
- else if (this.value instanceof NonFungibleAddress) {
141
- return { "NonFungible": this.value };
142
- }
143
- else if (this.value instanceof NonFungibleIndexAddress) {
144
- return { "NonFungibleIndex": this.value };
145
- }
146
- throw "Unknown type";
147
- }
148
- }
149
- export class TariPermissionAccountBalance {
150
- value;
151
- constructor(value) {
152
- this.value = value;
153
- }
154
- toJSON() {
155
- console.log("stringify", this.value);
156
- return { "AccountBalance": this.value };
157
- }
158
- }
159
- export class TariPermissionAccountInfo {
160
- constructor() { }
161
- toJSON() {
162
- return "AccountInfo";
163
- }
164
- }
165
- export class TariPermissionAccountList {
166
- value;
167
- constructor(value) {
168
- if (value === undefined) {
169
- this.value = null;
170
- }
171
- else {
172
- this.value = value;
173
- }
174
- }
175
- toJSON() {
176
- console.log('JSON TariPermissionAccountList', this.value);
177
- if (this.value === undefined) {
178
- return { "AccountList": null };
179
- }
180
- else {
181
- return { "AccountList": this.value };
182
- }
183
- }
184
- }
185
- export class TariPermissionKeyList {
186
- constructor() { }
187
- toJSON() {
188
- return "KeyList";
189
- }
190
- }
191
- export class TariPermissionTransactionGet {
192
- constructor() { }
193
- toJSON() {
194
- return "TransactionGet";
195
- }
196
- }
197
- export class TariPermissionTransactionSend {
198
- value;
199
- constructor(value) {
200
- this.value = value;
201
- }
202
- toJSON() {
203
- console.log('JSON TariPermissionTransactionSend', this.value);
204
- if (this.value === undefined) {
205
- return { "TransactionSend": null };
206
- }
207
- else {
208
- return { "TransactionSend": this.value };
209
- }
210
- }
211
- }
212
- export class TariPermissionGetNft {
213
- value0;
214
- value1;
215
- constructor(value0, value1) {
216
- this.value0 = value0;
217
- this.value1 = value1;
218
- }
219
- toJSON() {
220
- return { "GetNft": [this.value0, this.value1] };
221
- }
222
- }
223
- export class TariPermissionNftGetOwnershipProof {
224
- value;
225
- constructor(value) {
226
- this.value = value;
227
- }
228
- toJSON() {
229
- return { "NftGetOwnershipProof": this.value };
230
- }
231
- }
232
- export class TariPermissionTransactionsGet {
233
- constructor() { }
234
- toJSON() {
235
- return "TransactionGet";
236
- }
237
- }
238
- export class TariPermissionSubstatesRead {
239
- constructor() { }
240
- toJSON() {
241
- return "SubstatesRead";
242
- }
243
- }
244
- export class TariPermissionTemplatesRead {
245
- constructor() { }
246
- toJSON() {
247
- return "TemplatesRead";
248
- }
249
- }
250
- // export enum TariPermission {
251
- // AccountBalance = "AccountBalance",
252
- // AccountInfo = "AccountInfo",
253
- // AccountList = "AccountList",
254
- // KeyList = "KeyList",
255
- // TransactionGet = "TransactionGet",
256
- // TransactionSend = "TransactionSend",
257
- // GetNft = "GetNft",
258
- // NftGetOwnershipProof = "NftGetOwnershipProof",
259
- // TransactionsGet = "TransactionsGet",
260
- // SubstatesRead = "SubstatesRead",
261
- // TemplatesRead = "TemplatesRead",
262
- // }
263
- export class TariPermissions {
264
- permissions;
265
- constructor() {
266
- this.permissions = [];
267
- }
268
- addPermission(permission) {
269
- this.permissions.push(permission);
270
- return this;
271
- }
272
- addPermissions(other) {
273
- this.permissions.push(...other.permissions);
274
- return this;
275
- }
276
- toJSON() {
277
- return this.permissions;
278
- }
279
- }
280
- // TariPermissionType.prototype.toString = function () {
281
- // return "wtf"
282
- // }
@@ -1,20 +0,0 @@
1
- import { TariPermissions } from "./tari_permissions";
2
- import { transports } from "@tari-project/wallet_jrpc_client";
3
- export declare class TariConnection {
4
- private _peerConnection;
5
- private _dataChannel;
6
- private _signalingServer;
7
- private _callbacks;
8
- private _offer?;
9
- private _walletToken;
10
- onopen: (() => void) | undefined;
11
- onConnection: ((conn: TariConnection) => void) | undefined;
12
- constructor(signalig_server_url?: string, config?: RTCConfiguration);
13
- get token(): string | undefined;
14
- init(permissions: TariPermissions, onConnection: ((conn: TariConnection) => void) | undefined): Promise<void>;
15
- private setAnswer;
16
- private signalingServerPolling;
17
- isConnected(): boolean;
18
- sendMessage<T>(request: transports.RpcRequest, token: string | undefined, timeout_secs?: number | null): Promise<T>;
19
- private config;
20
- }