@tari-project/tarijs 0.3.1 → 0.4.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/.github/ISSUE_TEMPLATE/bug_report.md +36 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +27 -0
- package/.github/dependabot.yml +8 -0
- package/.github/workflows/ci.yml +25 -0
- package/.github/workflows/npm_publish.yml +26 -0
- package/.github/workflows/pr_signed_commits_check.yml +19 -0
- package/.github/workflows/pr_title.yml +30 -0
- package/.moon/toolchain.yml +6 -0
- package/.moon/workspace.yml +32 -0
- package/.prettierrc +12 -0
- package/.prototools +9 -0
- package/CODEOWNERS +3 -0
- package/README.md +9 -8
- package/TODO.md +12 -0
- package/package.json +6 -24
- package/packages/builders/moon.yml +55 -0
- package/packages/builders/package.json +30 -0
- package/packages/builders/src/helpers/submitTransaction.ts +97 -0
- package/{dist/builders/helpers/workspace.js → packages/builders/src/helpers/workspace.ts} +10 -7
- package/packages/builders/src/index.ts +9 -0
- package/packages/builders/src/transaction/TransactionBuilder.ts +276 -0
- package/packages/builders/src/transaction/TransactionRequest.ts +93 -0
- package/packages/builders/src/transaction/index.ts +2 -0
- package/packages/builders/tsconfig.json +24 -0
- package/packages/metamask_provider/moon.yml +55 -0
- package/packages/metamask_provider/package.json +30 -0
- package/packages/metamask_provider/src/index.ts +232 -0
- package/packages/metamask_provider/src/utils.ts +86 -0
- package/packages/metamask_provider/tsconfig.json +21 -0
- package/packages/tari_permissions/moon.yml +55 -0
- package/packages/tari_permissions/package.json +26 -0
- package/packages/tari_permissions/src/index.ts +1 -0
- package/packages/tari_permissions/src/tari_permissions.ts +312 -0
- package/packages/tari_permissions/tsconfig.json +15 -0
- package/packages/tari_provider/moon.yml +55 -0
- package/packages/tari_provider/package.json +27 -0
- package/packages/tari_provider/src/TariProvider.ts +35 -0
- package/packages/tari_provider/src/index.ts +3 -0
- package/packages/tari_provider/src/types.ts +82 -0
- package/packages/tari_provider/tsconfig.json +11 -0
- package/packages/tari_universe/moon.yml +55 -0
- package/packages/tari_universe/package.json +31 -0
- package/{dist/providers/tari_universe/index.d.ts → packages/tari_universe/src/index.ts} +1 -1
- package/packages/tari_universe/src/provider.ts +135 -0
- package/{dist/providers/tari_universe/types.d.ts → packages/tari_universe/src/types.ts} +20 -17
- package/packages/tari_universe/src/utils.ts +23 -0
- package/packages/tari_universe/tsconfig.json +24 -0
- package/packages/tarijs/integration-tests/.env +1 -0
- package/packages/tarijs/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +191 -0
- package/packages/tarijs/moon.yml +63 -0
- package/packages/tarijs/package.json +39 -0
- package/packages/tarijs/src/index.ts +69 -0
- package/packages/tarijs/src/network.ts +8 -0
- package/packages/tarijs/src/templates/Account.ts +98 -0
- package/packages/tarijs/src/templates/Pool.ts +42 -0
- package/packages/tarijs/src/templates/Tariswap.ts +101 -0
- package/packages/tarijs/src/templates/TemplateFactory.ts +22 -0
- package/packages/tarijs/src/templates/TestFaucet.ts +72 -0
- package/{dist/utils.js → packages/tarijs/src/utils.ts} +4 -3
- package/packages/tarijs/tsconfig.json +39 -0
- package/packages/tarijs/vitest.config.ts +9 -0
- package/packages/tarijs_types/moon.yml +55 -0
- package/packages/tarijs_types/package.json +27 -0
- package/packages/tarijs_types/src/Amount.ts +113 -0
- package/packages/tarijs_types/src/Arg.ts +3 -0
- package/packages/tarijs_types/src/ComponentAddress.ts +3 -0
- package/packages/tarijs_types/src/ConfidentialClaim.ts +9 -0
- package/packages/tarijs_types/src/ConfidentialOutput.ts +9 -0
- package/packages/tarijs_types/src/ConfidentialOutputStatement.ts +10 -0
- package/packages/tarijs_types/src/ConfidentialStatement.ts +9 -0
- package/packages/tarijs_types/src/ConfidentialWithdrawProof.ts +8 -0
- package/packages/tarijs_types/src/ElgamalVerifiableBalance.ts +4 -0
- package/packages/tarijs_types/src/Epoch.ts +3 -0
- package/packages/tarijs_types/src/FinalizeResult.ts +17 -0
- package/packages/tarijs_types/src/Instruction.ts +29 -0
- package/{dist/builders/types/ResourceAddress.js → packages/tarijs_types/src/ResourceAddress.ts} +2 -1
- package/{dist/builders/types/SubstateDiff.d.ts → packages/tarijs_types/src/SubstateDiff.ts} +4 -2
- package/{dist/builders/types/SubstateRequirement.d.ts → packages/tarijs_types/src/SubstateRequirement.ts} +3 -2
- package/{dist/builders/types/TemplateAddress.js → packages/tarijs_types/src/TemplateAddress.ts} +2 -1
- package/{dist/builders/types/Transaction.d.ts → packages/tarijs_types/src/Transaction.ts} +9 -8
- package/packages/tarijs_types/src/TransactionId.ts +4 -0
- package/packages/tarijs_types/src/TransactionResult.ts +26 -0
- package/packages/tarijs_types/src/TransactionSignature.ts +4 -0
- package/packages/tarijs_types/src/UnsignedTransaction.ts +15 -0
- package/{dist/builders/types/VersionedSubstateId.d.ts → packages/tarijs_types/src/VersionedSubstateId.ts} +3 -2
- package/packages/tarijs_types/src/ViewableBalanceProof.ts +12 -0
- package/{dist/builders/types/Workspace.d.ts → packages/tarijs_types/src/Workspace.ts} +1 -1
- package/{dist/builders/types/index.d.ts → packages/tarijs_types/src/index.ts} +4 -3
- package/packages/tarijs_types/tsconfig.json +15 -0
- package/packages/wallet_daemon/moon.yml +55 -0
- package/packages/wallet_daemon/package.json +29 -0
- package/{dist/providers/wallet_daemon/index.d.ts → packages/wallet_daemon/src/index.ts} +3 -1
- package/packages/wallet_daemon/src/provider.ts +263 -0
- package/packages/wallet_daemon/src/webrtc.ts +229 -0
- package/packages/wallet_daemon/src/webrtc_transport.ts +27 -0
- package/packages/wallet_daemon/tsconfig.json +21 -0
- package/packages/walletconnect/moon.yml +55 -0
- package/packages/walletconnect/package.json +32 -0
- package/packages/walletconnect/src/index.ts +274 -0
- package/packages/walletconnect/tsconfig.json +21 -0
- package/pnpm-workspace.yaml +14 -0
- package/tsconfig.json +42 -0
- package/dist/builders/helpers/index.js +0 -2
- package/dist/builders/helpers/submitTransaction.d.ts +0 -13
- package/dist/builders/helpers/submitTransaction.js +0 -62
- package/dist/builders/helpers/workspace.d.ts +0 -23
- package/dist/builders/index.d.ts +0 -3
- package/dist/builders/index.js +0 -3
- package/dist/builders/transaction/TransactionBuilder.d.ts +0 -44
- package/dist/builders/transaction/TransactionBuilder.js +0 -164
- package/dist/builders/transaction/TransactionRequest.d.ts +0 -27
- package/dist/builders/transaction/TransactionRequest.js +0 -67
- package/dist/builders/transaction/index.d.ts +0 -2
- package/dist/builders/transaction/index.js +0 -2
- package/dist/builders/types/Amount.d.ts +0 -23
- package/dist/builders/types/Amount.js +0 -93
- package/dist/builders/types/Arg.d.ts +0 -1
- package/dist/builders/types/Arg.js +0 -1
- package/dist/builders/types/Builder.d.ts +0 -47
- package/dist/builders/types/Builder.js +0 -1
- package/dist/builders/types/ComponentAddress.d.ts +0 -1
- package/dist/builders/types/ComponentAddress.js +0 -1
- package/dist/builders/types/ConfidentialClaim.d.ts +0 -8
- package/dist/builders/types/ConfidentialClaim.js +0 -1
- package/dist/builders/types/ConfidentialOutput.d.ts +0 -8
- package/dist/builders/types/ConfidentialOutput.js +0 -1
- package/dist/builders/types/ConfidentialOutputStatement.d.ts +0 -9
- package/dist/builders/types/ConfidentialOutputStatement.js +0 -1
- package/dist/builders/types/ConfidentialStatement.d.ts +0 -8
- package/dist/builders/types/ConfidentialStatement.js +0 -1
- package/dist/builders/types/ConfidentialWithdrawProof.d.ts +0 -7
- package/dist/builders/types/ConfidentialWithdrawProof.js +0 -1
- package/dist/builders/types/ElgamalVerifiableBalance.d.ts +0 -4
- package/dist/builders/types/ElgamalVerifiableBalance.js +0 -1
- package/dist/builders/types/Epoch.d.ts +0 -1
- package/dist/builders/types/Epoch.js +0 -1
- package/dist/builders/types/FinalizeResult.d.ts +0 -20
- package/dist/builders/types/FinalizeResult.js +0 -1
- package/dist/builders/types/Instruction.d.ts +0 -56
- package/dist/builders/types/Instruction.js +0 -1
- package/dist/builders/types/ResourceAddress.d.ts +0 -1
- package/dist/builders/types/SubstateDiff.js +0 -1
- package/dist/builders/types/SubstateRequirement.js +0 -1
- package/dist/builders/types/TemplateAddress.d.ts +0 -1
- package/dist/builders/types/Transaction.js +0 -1
- package/dist/builders/types/TransactionId.d.ts +0 -1
- package/dist/builders/types/TransactionId.js +0 -1
- package/dist/builders/types/TransactionResult.d.ts +0 -22
- package/dist/builders/types/TransactionResult.js +0 -10
- package/dist/builders/types/TransactionSignature.d.ts +0 -4
- package/dist/builders/types/TransactionSignature.js +0 -1
- package/dist/builders/types/UnsignedTransaction.d.ts +0 -12
- package/dist/builders/types/UnsignedTransaction.js +0 -1
- package/dist/builders/types/VersionedSubstateId.js +0 -1
- package/dist/builders/types/ViewableBalanceProof.d.ts +0 -10
- package/dist/builders/types/ViewableBalanceProof.js +0 -2
- package/dist/builders/types/Workspace.js +0 -1
- package/dist/builders/types/index.js +0 -2
- package/dist/index.d.ts +0 -13
- package/dist/index.js +0 -12
- package/dist/providers/index.d.ts +0 -16
- package/dist/providers/index.js +0 -1
- package/dist/providers/metamask/index.d.ts +0 -30
- package/dist/providers/metamask/index.js +0 -168
- package/dist/providers/metamask/utils.d.ts +0 -38
- package/dist/providers/metamask/utils.js +0 -55
- package/dist/providers/tari_universe/index.js +0 -3
- package/dist/providers/tari_universe/provider.d.ts +0 -23
- package/dist/providers/tari_universe/provider.js +0 -89
- package/dist/providers/tari_universe/types.js +0 -1
- package/dist/providers/tari_universe/utils.d.ts +0 -2
- package/dist/providers/tari_universe/utils.js +0 -16
- package/dist/providers/types.d.ts +0 -69
- package/dist/providers/types.js +0 -10
- package/dist/providers/wallet_daemon/index.js +0 -3
- package/dist/providers/wallet_daemon/provider.d.ts +0 -43
- package/dist/providers/wallet_daemon/provider.js +0 -198
- package/dist/providers/wallet_daemon/tari_permissions.d.ts +0 -216
- package/dist/providers/wallet_daemon/tari_permissions.js +0 -282
- package/dist/providers/wallet_daemon/webrtc.d.ts +0 -20
- package/dist/providers/wallet_daemon/webrtc.js +0 -201
- package/dist/providers/wallet_daemon/webrtc_transport.d.ts +0 -10
- package/dist/providers/wallet_daemon/webrtc_transport.js +0 -18
- package/dist/providers/walletconnect/index.d.ts +0 -23
- package/dist/providers/walletconnect/index.js +0 -221
- package/dist/templates/Account.d.ts +0 -65
- package/dist/templates/Account.js +0 -31
- package/dist/templates/Pool.d.ts +0 -30
- package/dist/templates/Pool.js +0 -20
- package/dist/templates/Tariswap.d.ts +0 -65
- package/dist/templates/Tariswap.js +0 -36
- package/dist/templates/TemplateFactory.d.ts +0 -9
- package/dist/templates/TemplateFactory.js +0 -18
- package/dist/templates/TestFaucet.d.ts +0 -49
- package/dist/templates/TestFaucet.js +0 -31
- package/dist/templates/index.js +0 -5
- package/dist/utils.d.ts +0 -2
- /package/{dist/builders/helpers/index.d.ts → packages/builders/src/helpers/index.ts} +0 -0
- /package/{dist/templates/index.d.ts → packages/tarijs/src/templates/index.ts} +0 -0
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { TransactionStatus, } from "../types";
|
|
2
|
-
import UniversalProvider from '@walletconnect/universal-provider';
|
|
3
|
-
import { WalletConnectModal } from '@walletconnect/modal';
|
|
4
|
-
import { substateIdToString } from "@tari-project/wallet_jrpc_client";
|
|
5
|
-
const walletConnectParams = {
|
|
6
|
-
requiredNamespaces: {
|
|
7
|
-
tari: {
|
|
8
|
-
methods: [
|
|
9
|
-
'tari_getSubstate',
|
|
10
|
-
'tari_getDefaultAccount',
|
|
11
|
-
'tari_getAccountBalances',
|
|
12
|
-
'tari_submitTransaction',
|
|
13
|
-
'tari_getTransactionResult',
|
|
14
|
-
'tari_getTemplate',
|
|
15
|
-
'tari_createKey',
|
|
16
|
-
'tari_viewConfidentialVaultBalance',
|
|
17
|
-
'tari_createFreeTestCoins',
|
|
18
|
-
'tari_listSubstates'
|
|
19
|
-
],
|
|
20
|
-
chains: [
|
|
21
|
-
'tari:devnet',
|
|
22
|
-
],
|
|
23
|
-
events: ['chainChanged", "accountsChanged']
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
export class WalletConnectTariProvider {
|
|
28
|
-
providerName = "WalletConnect";
|
|
29
|
-
projectId;
|
|
30
|
-
wcProvider;
|
|
31
|
-
wcSession;
|
|
32
|
-
constructor(projectId) {
|
|
33
|
-
this.projectId = projectId;
|
|
34
|
-
this.wcProvider = null;
|
|
35
|
-
this.wcSession = null;
|
|
36
|
-
}
|
|
37
|
-
async connect() {
|
|
38
|
-
if (this.wcProvider && this.wcSession)
|
|
39
|
-
return;
|
|
40
|
-
// initialize WalletConnect
|
|
41
|
-
const projectId = this.projectId;
|
|
42
|
-
this.wcProvider = await UniversalProvider.init({
|
|
43
|
-
projectId,
|
|
44
|
-
// TODO: parameterize the relay URL
|
|
45
|
-
relayUrl: 'wss://relay.walletconnect.com'
|
|
46
|
-
});
|
|
47
|
-
// open UI modal with the connection URI
|
|
48
|
-
const { uri, approval } = await this.wcProvider.client.connect(walletConnectParams);
|
|
49
|
-
const walletConnectModal = new WalletConnectModal({
|
|
50
|
-
projectId
|
|
51
|
-
});
|
|
52
|
-
if (uri) {
|
|
53
|
-
walletConnectModal.openModal({ uri });
|
|
54
|
-
}
|
|
55
|
-
// wait for the wallet to approve the connection
|
|
56
|
-
console.log("waiting for session approval from the wallet app");
|
|
57
|
-
const session = await approval();
|
|
58
|
-
// at this point session is open
|
|
59
|
-
console.log("session approved by the wallet");
|
|
60
|
-
this.wcSession = session;
|
|
61
|
-
}
|
|
62
|
-
async sendRequest(method, params) {
|
|
63
|
-
if (!this.wcProvider) {
|
|
64
|
-
throw "WalletConnect provider not initialized";
|
|
65
|
-
}
|
|
66
|
-
if (!this.wcSession) {
|
|
67
|
-
throw "WalletConnect session not initialized";
|
|
68
|
-
}
|
|
69
|
-
const requestResult = await this.wcProvider.client.request({
|
|
70
|
-
topic: this.wcSession.topic,
|
|
71
|
-
chainId: 'tari:devnet',
|
|
72
|
-
request: {
|
|
73
|
-
method,
|
|
74
|
-
params
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
console.log({ requestResult });
|
|
78
|
-
return requestResult;
|
|
79
|
-
}
|
|
80
|
-
isConnected() {
|
|
81
|
-
// TODO: check status in the session
|
|
82
|
-
return this.wcSession !== null;
|
|
83
|
-
}
|
|
84
|
-
async getAccount() {
|
|
85
|
-
const { account, public_key } = await this.sendRequest('tari_getDefaultAccount', {});
|
|
86
|
-
const { balances } = await this.sendRequest('tari_getAccountBalances', { account: { ComponentAddress: account.address }, refresh: false
|
|
87
|
-
});
|
|
88
|
-
return {
|
|
89
|
-
account_id: account.key_index,
|
|
90
|
-
address: account.address,
|
|
91
|
-
public_key,
|
|
92
|
-
// TODO: should be vaults not resources
|
|
93
|
-
resources: balances.map((b) => ({
|
|
94
|
-
type: b.resource_type,
|
|
95
|
-
resource_address: b.resource_address,
|
|
96
|
-
balance: b.balance + b.confidential_balance,
|
|
97
|
-
vault_id: (typeof (b.vault_address) === "object" && 'Vault' in b.vault_address) ? b.vault_address.Vault : b.vault_address,
|
|
98
|
-
token_symbol: b.token_symbol,
|
|
99
|
-
}))
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
async getSubstate(substate_address) {
|
|
103
|
-
const method = 'tari_getSubstate';
|
|
104
|
-
const params = { substate_id: substate_address };
|
|
105
|
-
const { value, record } = await this.sendRequest(method, params);
|
|
106
|
-
return {
|
|
107
|
-
value,
|
|
108
|
-
address: {
|
|
109
|
-
substate_id: record.substate_id,
|
|
110
|
-
version: record.version
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
async listSubstates(filter_by_template, filter_by_type, limit, offset) {
|
|
115
|
-
const method = 'tari_listSubstates';
|
|
116
|
-
const params = {
|
|
117
|
-
filter_by_template,
|
|
118
|
-
filter_by_type,
|
|
119
|
-
limit,
|
|
120
|
-
offset
|
|
121
|
-
};
|
|
122
|
-
const res = await this.sendRequest(method, params);
|
|
123
|
-
const substates = res.substates.map((s) => ({
|
|
124
|
-
substate_id: substateIdToString(s.substate_id),
|
|
125
|
-
module_name: s.module_name,
|
|
126
|
-
version: s.version,
|
|
127
|
-
template_address: s.template_address
|
|
128
|
-
}));
|
|
129
|
-
return { substates };
|
|
130
|
-
}
|
|
131
|
-
async createFreeTestCoins() {
|
|
132
|
-
const method = 'tari_createFreeTestCoins';
|
|
133
|
-
const params = {
|
|
134
|
-
account: { Name: "template_web" },
|
|
135
|
-
amount: 1000000,
|
|
136
|
-
max_fee: null,
|
|
137
|
-
key_id: 0
|
|
138
|
-
};
|
|
139
|
-
const res = await this.sendRequest(method, params);
|
|
140
|
-
return {
|
|
141
|
-
account_id: res.account.key_index,
|
|
142
|
-
address: res.account.address.Component,
|
|
143
|
-
public_key: res.public_key,
|
|
144
|
-
resources: []
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
async submitTransaction(req) {
|
|
148
|
-
const method = 'tari_submitTransaction';
|
|
149
|
-
const params = {
|
|
150
|
-
transaction: {
|
|
151
|
-
V1: {
|
|
152
|
-
network: req.network,
|
|
153
|
-
fee_instructions: req.fee_instructions,
|
|
154
|
-
instructions: req.instructions,
|
|
155
|
-
inputs: req.required_substates.map((s) => ({
|
|
156
|
-
// TODO: Hmm The bindings want a SubstateId object, but the wallet only wants a string. Any is used to skip type checking here
|
|
157
|
-
substate_id: s.substate_id,
|
|
158
|
-
version: s.version ?? null,
|
|
159
|
-
})),
|
|
160
|
-
min_epoch: null,
|
|
161
|
-
max_epoch: null,
|
|
162
|
-
is_seal_signer_authorized: req.is_seal_signer_authorized,
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
signing_key_index: req.account_id,
|
|
166
|
-
autofill_inputs: [],
|
|
167
|
-
detect_inputs: true,
|
|
168
|
-
proof_ids: [],
|
|
169
|
-
detect_inputs_use_unversioned: req.detect_inputs_use_unversioned,
|
|
170
|
-
};
|
|
171
|
-
const res = await this.sendRequest(method, params);
|
|
172
|
-
return { transaction_id: res.transaction_id };
|
|
173
|
-
}
|
|
174
|
-
async getTransactionResult(transactionId) {
|
|
175
|
-
const res = await this.sendRequest('tari_getTransactionResult', { transaction_id: transactionId });
|
|
176
|
-
return {
|
|
177
|
-
transaction_id: transactionId,
|
|
178
|
-
status: convertStringToTransactionStatus(res.status),
|
|
179
|
-
result: res.result,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
async getTemplateDefinition(template_address) {
|
|
183
|
-
let resp = await this.sendRequest('tari_getTemplate', { template_address });
|
|
184
|
-
return resp.template_definition;
|
|
185
|
-
}
|
|
186
|
-
async getPublicKey(branch, index) {
|
|
187
|
-
const res = await this.sendRequest('tari_createKey', { branch: branch, specific_index: index });
|
|
188
|
-
return res.public_key;
|
|
189
|
-
}
|
|
190
|
-
async getConfidentialVaultBalances(viewKeyId, vaultId, min, max) {
|
|
191
|
-
const method = 'tari_viewConfidentialVaultBalance';
|
|
192
|
-
const params = {
|
|
193
|
-
view_key_id: viewKeyId,
|
|
194
|
-
vault_id: vaultId,
|
|
195
|
-
minimum_expected_value: min,
|
|
196
|
-
maximum_expected_value: max,
|
|
197
|
-
};
|
|
198
|
-
const res = await this.sendRequest(method, params);
|
|
199
|
-
return { balances: res.balances };
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
function convertStringToTransactionStatus(status) {
|
|
203
|
-
switch (status) {
|
|
204
|
-
case "New":
|
|
205
|
-
return TransactionStatus.New;
|
|
206
|
-
case "DryRun":
|
|
207
|
-
return TransactionStatus.DryRun;
|
|
208
|
-
case "Pending":
|
|
209
|
-
return TransactionStatus.Pending;
|
|
210
|
-
case "Accepted":
|
|
211
|
-
return TransactionStatus.Accepted;
|
|
212
|
-
case "Rejected":
|
|
213
|
-
return TransactionStatus.Rejected;
|
|
214
|
-
case "InvalidTransaction":
|
|
215
|
-
return TransactionStatus.InvalidTransaction;
|
|
216
|
-
case "OnlyFeeAccepted":
|
|
217
|
-
return TransactionStatus.OnlyFeeAccepted;
|
|
218
|
-
default:
|
|
219
|
-
throw new Error(`Unknown status: ${status}`);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { ConfidentialWithdrawProof, NonFungibleId, ResourceAddress } from "@tari-project/typescript-bindings";
|
|
2
|
-
import { Amount } from "../builders/types/Amount";
|
|
3
|
-
import { TariMethodDefinition, WorkspaceArg } from "../builders/types";
|
|
4
|
-
import { TemplateFactory } from "./TemplateFactory";
|
|
5
|
-
/**
|
|
6
|
-
* Adds a fee instruction that calls the "take_fee" method on a component.
|
|
7
|
-
* This method must exist and return a Bucket with containing revealed confidential XTR resource.
|
|
8
|
-
* This allows the fee to originate from sources other than the transaction sender's account.
|
|
9
|
-
* The fee instruction will lock up the "max_fee" amount for the duration of the transaction.
|
|
10
|
-
* @param componentAddress
|
|
11
|
-
* @param maxFee
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
interface PayFeeMethod extends TariMethodDefinition {
|
|
15
|
-
methodName: "pay_fee";
|
|
16
|
-
args?: [Amount];
|
|
17
|
-
}
|
|
18
|
-
interface PayFeeConfidentialMethod extends TariMethodDefinition {
|
|
19
|
-
methodName: "pay_fee_confidential";
|
|
20
|
-
args?: [ConfidentialWithdrawProof];
|
|
21
|
-
}
|
|
22
|
-
interface WithdrawMethod extends TariMethodDefinition {
|
|
23
|
-
methodName: "withdraw";
|
|
24
|
-
args?: [string, Amount];
|
|
25
|
-
}
|
|
26
|
-
interface DepositMethod extends TariMethodDefinition {
|
|
27
|
-
methodName: "deposit";
|
|
28
|
-
args?: WorkspaceArg[];
|
|
29
|
-
}
|
|
30
|
-
interface CreateProofForResourceMethod extends TariMethodDefinition {
|
|
31
|
-
methodName: "create_proof_for_resource";
|
|
32
|
-
args?: [ResourceAddress];
|
|
33
|
-
}
|
|
34
|
-
interface CreateProofByAmountMethod extends TariMethodDefinition {
|
|
35
|
-
methodName: "create_proof_by_amount";
|
|
36
|
-
args?: [ResourceAddress, Amount];
|
|
37
|
-
}
|
|
38
|
-
interface CreateProofByNonFungibleIdsMethod extends TariMethodDefinition {
|
|
39
|
-
methodName: "create_proof_by_non_fungible_ids";
|
|
40
|
-
args?: [ResourceAddress, NonFungibleId[]];
|
|
41
|
-
}
|
|
42
|
-
interface BalanceMethod extends TariMethodDefinition {
|
|
43
|
-
methodName: "balance";
|
|
44
|
-
args?: [ResourceAddress];
|
|
45
|
-
}
|
|
46
|
-
interface GetBalancesMethod extends TariMethodDefinition {
|
|
47
|
-
methodName: "get_balances";
|
|
48
|
-
args?: [];
|
|
49
|
-
}
|
|
50
|
-
export declare class AccountTemplate extends TemplateFactory {
|
|
51
|
-
templateAddress: string;
|
|
52
|
-
deposit: DepositMethod;
|
|
53
|
-
withdraw: WithdrawMethod;
|
|
54
|
-
createProofByAmount: CreateProofByAmountMethod;
|
|
55
|
-
createProofByNonFungibleIds: CreateProofByNonFungibleIdsMethod;
|
|
56
|
-
createProofForResource: CreateProofForResourceMethod;
|
|
57
|
-
balance: BalanceMethod;
|
|
58
|
-
getBalances: GetBalancesMethod;
|
|
59
|
-
payFee: PayFeeMethod;
|
|
60
|
-
payFeeConfidential: PayFeeConfidentialMethod;
|
|
61
|
-
constructor(templateAddress: string);
|
|
62
|
-
protected _initFunctions(): void;
|
|
63
|
-
protected _initMethods(): void;
|
|
64
|
-
}
|
|
65
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { TemplateFactory } from "./TemplateFactory";
|
|
2
|
-
export class AccountTemplate extends TemplateFactory {
|
|
3
|
-
templateAddress;
|
|
4
|
-
deposit;
|
|
5
|
-
withdraw;
|
|
6
|
-
createProofByAmount;
|
|
7
|
-
createProofByNonFungibleIds;
|
|
8
|
-
createProofForResource;
|
|
9
|
-
balance;
|
|
10
|
-
getBalances;
|
|
11
|
-
payFee;
|
|
12
|
-
payFeeConfidential;
|
|
13
|
-
constructor(templateAddress) {
|
|
14
|
-
super(templateAddress);
|
|
15
|
-
this.templateAddress = templateAddress;
|
|
16
|
-
this._initFunctions();
|
|
17
|
-
this._initMethods();
|
|
18
|
-
}
|
|
19
|
-
_initFunctions() { }
|
|
20
|
-
_initMethods() {
|
|
21
|
-
this.deposit = this._defineMethod("deposit");
|
|
22
|
-
this.withdraw = this._defineMethod("withdraw");
|
|
23
|
-
this.createProofByAmount = this._defineMethod("create_proof_by_amount");
|
|
24
|
-
this.createProofByNonFungibleIds = this._defineMethod("create_proof_by_non_fungible_ids");
|
|
25
|
-
this.createProofForResource = this._defineMethod("create_proof_for_resource");
|
|
26
|
-
this.balance = this._defineMethod("balance");
|
|
27
|
-
this.getBalances = this._defineMethod("get_balances");
|
|
28
|
-
this.payFee = this._defineMethod("pay_fee");
|
|
29
|
-
this.payFeeConfidential = this._defineMethod("pay_fee_confidential");
|
|
30
|
-
}
|
|
31
|
-
}
|
package/dist/templates/Pool.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { TariMethodDefinition } from "../builders/types/Builder";
|
|
2
|
-
import { WorkspaceArg } from "../builders/types/Workspace";
|
|
3
|
-
import { TemplateFactory } from "./TemplateFactory";
|
|
4
|
-
interface CreatePool extends TariMethodDefinition {
|
|
5
|
-
methodName: "create_pool";
|
|
6
|
-
args?: [string, string];
|
|
7
|
-
}
|
|
8
|
-
interface AddLiquidityMethod extends TariMethodDefinition {
|
|
9
|
-
methodName: "add_liquidity";
|
|
10
|
-
args?: WorkspaceArg[];
|
|
11
|
-
}
|
|
12
|
-
interface RemoveLiquidityMethod extends TariMethodDefinition {
|
|
13
|
-
methodName: "remove_liquidity";
|
|
14
|
-
args?: WorkspaceArg[];
|
|
15
|
-
}
|
|
16
|
-
interface SwapMethod extends TariMethodDefinition {
|
|
17
|
-
methodName: "swap";
|
|
18
|
-
args?: (WorkspaceArg | string)[];
|
|
19
|
-
}
|
|
20
|
-
export declare class PoolTemplate extends TemplateFactory {
|
|
21
|
-
templateAddress: string;
|
|
22
|
-
createPool: CreatePool;
|
|
23
|
-
addLiquidity: AddLiquidityMethod;
|
|
24
|
-
removeLiquidity: RemoveLiquidityMethod;
|
|
25
|
-
swap: SwapMethod;
|
|
26
|
-
constructor(templateAddress: string);
|
|
27
|
-
protected _initFunctions(): void;
|
|
28
|
-
protected _initMethods(): void;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
package/dist/templates/Pool.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { TemplateFactory } from "./TemplateFactory";
|
|
2
|
-
export class PoolTemplate extends TemplateFactory {
|
|
3
|
-
templateAddress;
|
|
4
|
-
createPool;
|
|
5
|
-
addLiquidity;
|
|
6
|
-
removeLiquidity;
|
|
7
|
-
swap;
|
|
8
|
-
constructor(templateAddress) {
|
|
9
|
-
super(templateAddress);
|
|
10
|
-
this.templateAddress = templateAddress;
|
|
11
|
-
this._initFunctions();
|
|
12
|
-
this._initMethods();
|
|
13
|
-
}
|
|
14
|
-
_initFunctions() { }
|
|
15
|
-
_initMethods() {
|
|
16
|
-
this.addLiquidity = this._defineMethod("add_liquidity");
|
|
17
|
-
this.removeLiquidity = this._defineMethod("remove_liquidity");
|
|
18
|
-
this.swap = this._defineMethod("swap");
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Amount, ConfidentialWithdrawProof, ResourceAddress } from "../builders/types";
|
|
2
|
-
import { TariFunctionDefinition, TariMethodDefinition, WorkspaceArg } from "../builders/types";
|
|
3
|
-
import { TemplateFactory } from "./TemplateFactory";
|
|
4
|
-
interface NewPoolFunction extends TariFunctionDefinition {
|
|
5
|
-
functionName: "new";
|
|
6
|
-
args?: [ResourceAddress, ResourceAddress, Amount];
|
|
7
|
-
}
|
|
8
|
-
interface MintFunction extends TariFunctionDefinition {
|
|
9
|
-
functionName: "mint";
|
|
10
|
-
args?: [Amount];
|
|
11
|
-
}
|
|
12
|
-
interface MintWithSymbolFunction extends TariFunctionDefinition {
|
|
13
|
-
functionName: "mint_with_symbol";
|
|
14
|
-
args?: [Amount, string];
|
|
15
|
-
}
|
|
16
|
-
interface PayFeeMethod extends TariMethodDefinition {
|
|
17
|
-
methodName: "pay_fee";
|
|
18
|
-
args?: [string];
|
|
19
|
-
}
|
|
20
|
-
interface PayFeeConfidentialMethod extends TariMethodDefinition {
|
|
21
|
-
methodName: "pay_fee_confidential";
|
|
22
|
-
args?: [ConfidentialWithdrawProof];
|
|
23
|
-
}
|
|
24
|
-
interface TotalSupplyMethod extends TariMethodDefinition {
|
|
25
|
-
methodName: "total_supply";
|
|
26
|
-
args?: [];
|
|
27
|
-
}
|
|
28
|
-
interface WithdrawMethod extends TariMethodDefinition {
|
|
29
|
-
methodName: "withdraw";
|
|
30
|
-
args?: [string, string];
|
|
31
|
-
}
|
|
32
|
-
interface AddLiquidityMethod extends TariMethodDefinition {
|
|
33
|
-
methodName: "add_liquidity";
|
|
34
|
-
args?: WorkspaceArg[];
|
|
35
|
-
}
|
|
36
|
-
interface RemoveLiquidityMethod extends TariMethodDefinition {
|
|
37
|
-
methodName: "remove_liquidity";
|
|
38
|
-
args?: WorkspaceArg[];
|
|
39
|
-
}
|
|
40
|
-
interface DepositMethod extends TariMethodDefinition {
|
|
41
|
-
methodName: "deposit";
|
|
42
|
-
args?: WorkspaceArg[];
|
|
43
|
-
}
|
|
44
|
-
interface SwapMethod extends TariMethodDefinition {
|
|
45
|
-
methodName: "swap";
|
|
46
|
-
args?: (WorkspaceArg | string)[];
|
|
47
|
-
}
|
|
48
|
-
export declare class TariswapTemplate extends TemplateFactory {
|
|
49
|
-
templateAddress: string;
|
|
50
|
-
newPool: NewPoolFunction;
|
|
51
|
-
mint: MintFunction;
|
|
52
|
-
mintWithSymbol: MintWithSymbolFunction;
|
|
53
|
-
totalSupply: TotalSupplyMethod;
|
|
54
|
-
payFee: PayFeeMethod;
|
|
55
|
-
payFeeConfidential: PayFeeConfidentialMethod;
|
|
56
|
-
withdraw: WithdrawMethod;
|
|
57
|
-
addLiquidity: AddLiquidityMethod;
|
|
58
|
-
removeLiquidity: RemoveLiquidityMethod;
|
|
59
|
-
deposit: DepositMethod;
|
|
60
|
-
swap: SwapMethod;
|
|
61
|
-
constructor(templateAddress: string);
|
|
62
|
-
protected _initFunctions(): void;
|
|
63
|
-
protected _initMethods(): void;
|
|
64
|
-
}
|
|
65
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { TemplateFactory } from "./TemplateFactory";
|
|
2
|
-
export class TariswapTemplate extends TemplateFactory {
|
|
3
|
-
templateAddress;
|
|
4
|
-
newPool;
|
|
5
|
-
mint;
|
|
6
|
-
mintWithSymbol;
|
|
7
|
-
totalSupply;
|
|
8
|
-
payFee;
|
|
9
|
-
payFeeConfidential;
|
|
10
|
-
withdraw;
|
|
11
|
-
addLiquidity;
|
|
12
|
-
removeLiquidity;
|
|
13
|
-
deposit;
|
|
14
|
-
swap;
|
|
15
|
-
constructor(templateAddress) {
|
|
16
|
-
super(templateAddress);
|
|
17
|
-
this.templateAddress = templateAddress;
|
|
18
|
-
this._initFunctions();
|
|
19
|
-
this._initMethods();
|
|
20
|
-
}
|
|
21
|
-
_initFunctions() {
|
|
22
|
-
this.newPool = this._defineFunction("new");
|
|
23
|
-
this.mint = this._defineFunction("mint");
|
|
24
|
-
this.mintWithSymbol = this._defineFunction("mint_with_symbol");
|
|
25
|
-
}
|
|
26
|
-
_initMethods() {
|
|
27
|
-
this.totalSupply = this._defineMethod("total_supply");
|
|
28
|
-
this.payFee = this._defineMethod("pay_fee");
|
|
29
|
-
this.payFeeConfidential = this._defineMethod("pay_fee_confidential");
|
|
30
|
-
this.withdraw = this._defineMethod("withdraw");
|
|
31
|
-
this.addLiquidity = this._defineMethod("add_liquidity");
|
|
32
|
-
this.removeLiquidity = this._defineMethod("remove_liquidity");
|
|
33
|
-
this.deposit = this._defineMethod("deposit");
|
|
34
|
-
this.swap = this._defineMethod("swap");
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { TariFunctionDefinition, TariMethodDefinition } from "../builders/types";
|
|
2
|
-
export declare abstract class TemplateFactory {
|
|
3
|
-
templateAddress: string;
|
|
4
|
-
constructor(templateAddress: string);
|
|
5
|
-
_defineFunction<T extends TariFunctionDefinition>(name: T["functionName"]): T;
|
|
6
|
-
_defineMethod<T extends TariMethodDefinition>(name: T["methodName"]): T;
|
|
7
|
-
protected abstract _initFunctions(): void;
|
|
8
|
-
protected abstract _initMethods(): void;
|
|
9
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export class TemplateFactory {
|
|
2
|
-
templateAddress;
|
|
3
|
-
constructor(templateAddress) {
|
|
4
|
-
this.templateAddress = templateAddress;
|
|
5
|
-
}
|
|
6
|
-
_defineFunction(name) {
|
|
7
|
-
return {
|
|
8
|
-
templateAddress: this.templateAddress,
|
|
9
|
-
functionName: name,
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
_defineMethod(name) {
|
|
13
|
-
return {
|
|
14
|
-
componentAddress: this.templateAddress,
|
|
15
|
-
methodName: name,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Amount, ConfidentialWithdrawProof, TariFunctionDefinition, TariMethodDefinition } from "../builders/types";
|
|
2
|
-
import { TemplateFactory } from "./TemplateFactory";
|
|
3
|
-
interface MintFunction extends TariFunctionDefinition {
|
|
4
|
-
functionName: "mint";
|
|
5
|
-
args?: [string];
|
|
6
|
-
}
|
|
7
|
-
interface MintWithSymbolFunction extends TariFunctionDefinition {
|
|
8
|
-
functionName: "mint_with_symbol";
|
|
9
|
-
args?: [amount: string, symbol: string];
|
|
10
|
-
}
|
|
11
|
-
interface PayFeeMethod extends TariMethodDefinition {
|
|
12
|
-
methodName: "pay_fee";
|
|
13
|
-
args?: [Amount];
|
|
14
|
-
}
|
|
15
|
-
interface PayFeeConfidentialMethod extends TariMethodDefinition {
|
|
16
|
-
methodName: "pay_fee_confidential";
|
|
17
|
-
args?: [ConfidentialWithdrawProof];
|
|
18
|
-
}
|
|
19
|
-
interface TakeFreeCoinsMethod extends TariMethodDefinition {
|
|
20
|
-
methodName: "take_free_coins";
|
|
21
|
-
args?: [];
|
|
22
|
-
}
|
|
23
|
-
interface TakeFreeCoinsConfidentialMethod extends TariMethodDefinition {
|
|
24
|
-
methodName: "take_free_coins_confidential";
|
|
25
|
-
args?: [ConfidentialWithdrawProof];
|
|
26
|
-
}
|
|
27
|
-
interface BurnCoinsMethod extends TariMethodDefinition {
|
|
28
|
-
methodName: "burn_coins";
|
|
29
|
-
args?: [BigInt];
|
|
30
|
-
}
|
|
31
|
-
interface TotalSupplyMethod extends TariMethodDefinition {
|
|
32
|
-
methodName: "total_supply";
|
|
33
|
-
args?: [];
|
|
34
|
-
}
|
|
35
|
-
export declare class TestFaucet extends TemplateFactory {
|
|
36
|
-
templateAddress: string;
|
|
37
|
-
mint: MintFunction;
|
|
38
|
-
mintWithSymbol: MintWithSymbolFunction;
|
|
39
|
-
takeFreeCoins: TakeFreeCoinsMethod;
|
|
40
|
-
takeFreeCoinsConfidential: TakeFreeCoinsConfidentialMethod;
|
|
41
|
-
burnCoins: BurnCoinsMethod;
|
|
42
|
-
totalSupply: TotalSupplyMethod;
|
|
43
|
-
payFee: PayFeeMethod;
|
|
44
|
-
payFeeConfidential: PayFeeConfidentialMethod;
|
|
45
|
-
constructor(templateAddress: string);
|
|
46
|
-
protected _initFunctions(): void;
|
|
47
|
-
protected _initMethods(): void;
|
|
48
|
-
}
|
|
49
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { TemplateFactory } from "./TemplateFactory";
|
|
2
|
-
export class TestFaucet extends TemplateFactory {
|
|
3
|
-
templateAddress;
|
|
4
|
-
mint;
|
|
5
|
-
mintWithSymbol;
|
|
6
|
-
takeFreeCoins;
|
|
7
|
-
takeFreeCoinsConfidential;
|
|
8
|
-
burnCoins;
|
|
9
|
-
totalSupply;
|
|
10
|
-
payFee;
|
|
11
|
-
payFeeConfidential;
|
|
12
|
-
constructor(templateAddress) {
|
|
13
|
-
super(templateAddress);
|
|
14
|
-
this.templateAddress = templateAddress;
|
|
15
|
-
this._initFunctions();
|
|
16
|
-
this._initMethods();
|
|
17
|
-
}
|
|
18
|
-
_initFunctions() {
|
|
19
|
-
this.mint = this._defineFunction("mint");
|
|
20
|
-
this.mintWithSymbol = this._defineFunction("mint_with_symbol");
|
|
21
|
-
}
|
|
22
|
-
_initMethods() {
|
|
23
|
-
this.takeFreeCoins = this._defineMethod("take_free_coins");
|
|
24
|
-
this.takeFreeCoinsConfidential =
|
|
25
|
-
this._defineMethod("take_free_coins_confidential");
|
|
26
|
-
this.burnCoins = this._defineMethod("burn_coins");
|
|
27
|
-
this.totalSupply = this._defineMethod("total_supply");
|
|
28
|
-
this.payFee = this._defineMethod("pay_fee");
|
|
29
|
-
this.payFeeConfidential = this._defineMethod("pay_fee_confidential");
|
|
30
|
-
}
|
|
31
|
-
}
|
package/dist/templates/index.js
DELETED
package/dist/utils.d.ts
DELETED
|
File without changes
|
|
File without changes
|