tenzro-sdk 0.1.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/LICENSE +201 -0
- package/README.md +107 -0
- package/dist/agent-payments.d.ts +47 -0
- package/dist/agent-payments.d.ts.map +1 -0
- package/dist/agent-payments.js +76 -0
- package/dist/agent-payments.js.map +1 -0
- package/dist/agent.d.ts +177 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +300 -0
- package/dist/agent.js.map +1 -0
- package/dist/ap2.d.ts +54 -0
- package/dist/ap2.d.ts.map +1 -0
- package/dist/ap2.js +88 -0
- package/dist/ap2.js.map +1 -0
- package/dist/app.d.ts +186 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +317 -0
- package/dist/app.js.map +1 -0
- package/dist/bridge.d.ts +64 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +93 -0
- package/dist/bridge.js.map +1 -0
- package/dist/canton.d.ts +36 -0
- package/dist/canton.d.ts.map +1 -0
- package/dist/canton.js +46 -0
- package/dist/canton.js.map +1 -0
- package/dist/circuit-breaker.d.ts +35 -0
- package/dist/circuit-breaker.d.ts.map +1 -0
- package/dist/circuit-breaker.js +53 -0
- package/dist/circuit-breaker.js.map +1 -0
- package/dist/client.d.ts +134 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +265 -0
- package/dist/client.js.map +1 -0
- package/dist/compliance.d.ts +83 -0
- package/dist/compliance.d.ts.map +1 -0
- package/dist/compliance.js +74 -0
- package/dist/compliance.js.map +1 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +24 -0
- package/dist/config.js.map +1 -0
- package/dist/contract.d.ts +68 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +59 -0
- package/dist/contract.js.map +1 -0
- package/dist/crypto.d.ts +112 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +97 -0
- package/dist/crypto.js.map +1 -0
- package/dist/custody.d.ts +114 -0
- package/dist/custody.d.ts.map +1 -0
- package/dist/custody.js +96 -0
- package/dist/custody.js.map +1 -0
- package/dist/debridge.d.ts +129 -0
- package/dist/debridge.d.ts.map +1 -0
- package/dist/debridge.js +93 -0
- package/dist/debridge.js.map +1 -0
- package/dist/erc7802.d.ts +36 -0
- package/dist/erc7802.d.ts.map +1 -0
- package/dist/erc7802.js +52 -0
- package/dist/erc7802.js.map +1 -0
- package/dist/events.d.ts +112 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +70 -0
- package/dist/events.js.map +1 -0
- package/dist/governance.d.ts +55 -0
- package/dist/governance.d.ts.map +1 -0
- package/dist/governance.js +77 -0
- package/dist/governance.js.map +1 -0
- package/dist/identity.d.ts +102 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +147 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/inference.d.ts +27 -0
- package/dist/inference.d.ts.map +1 -0
- package/dist/inference.js +43 -0
- package/dist/inference.js.map +1 -0
- package/dist/marketplace.d.ts +44 -0
- package/dist/marketplace.d.ts.map +1 -0
- package/dist/marketplace.js +74 -0
- package/dist/marketplace.js.map +1 -0
- package/dist/nanopayment.d.ts +53 -0
- package/dist/nanopayment.d.ts.map +1 -0
- package/dist/nanopayment.js +81 -0
- package/dist/nanopayment.js.map +1 -0
- package/dist/nft.d.ts +127 -0
- package/dist/nft.d.ts.map +1 -0
- package/dist/nft.js +99 -0
- package/dist/nft.js.map +1 -0
- package/dist/payment.d.ts +71 -0
- package/dist/payment.d.ts.map +1 -0
- package/dist/payment.js +105 -0
- package/dist/payment.js.map +1 -0
- package/dist/provider.d.ts +351 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +368 -0
- package/dist/provider.js.map +1 -0
- package/dist/rpc.d.ts +35 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +127 -0
- package/dist/rpc.js.map +1 -0
- package/dist/settlement.d.ts +52 -0
- package/dist/settlement.d.ts.map +1 -0
- package/dist/settlement.js +86 -0
- package/dist/settlement.js.map +1 -0
- package/dist/skill.d.ts +55 -0
- package/dist/skill.d.ts.map +1 -0
- package/dist/skill.js +79 -0
- package/dist/skill.js.map +1 -0
- package/dist/staking.d.ts +42 -0
- package/dist/staking.d.ts.map +1 -0
- package/dist/staking.js +62 -0
- package/dist/staking.js.map +1 -0
- package/dist/streaming.d.ts +83 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +193 -0
- package/dist/streaming.js.map +1 -0
- package/dist/task.d.ts +46 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +76 -0
- package/dist/task.js.map +1 -0
- package/dist/tee.d.ts +88 -0
- package/dist/tee.d.ts.map +1 -0
- package/dist/tee.js +62 -0
- package/dist/tee.js.map +1 -0
- package/dist/token.d.ts +165 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/token.js +80 -0
- package/dist/token.js.map +1 -0
- package/dist/tool.d.ts +55 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +79 -0
- package/dist/tool.js.map +1 -0
- package/dist/types.d.ts +1318 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +117 -0
- package/dist/types.js.map +1 -0
- package/dist/wallet.d.ts +44 -0
- package/dist/wallet.d.ts.map +1 -0
- package/dist/wallet.js +75 -0
- package/dist/wallet.js.map +1 -0
- package/dist/zk.d.ts +66 -0
- package/dist/zk.d.ts.map +1 -0
- package/dist/zk.js +58 -0
- package/dist/zk.js.map +1 -0
- package/package.json +41 -0
package/dist/app.js
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppClient = void 0;
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
const rpc_1 = require("./rpc");
|
|
6
|
+
function newAppState() {
|
|
7
|
+
return {
|
|
8
|
+
users: new Map(),
|
|
9
|
+
policies: new Map(),
|
|
10
|
+
sessions: new Map(),
|
|
11
|
+
stats: {
|
|
12
|
+
totalGasSpent: 0n,
|
|
13
|
+
totalInferenceCost: 0,
|
|
14
|
+
totalBridgeFees: 0n,
|
|
15
|
+
userCount: 0,
|
|
16
|
+
transactionCount: 0,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// AppClient
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
/**
|
|
24
|
+
* Application client -- the primary interface for developers building on Tenzro.
|
|
25
|
+
*
|
|
26
|
+
* Wraps a master wallet and provides methods to:
|
|
27
|
+
* - Create and fund user wallets
|
|
28
|
+
* - Sponsor gas for user transactions (paymaster)
|
|
29
|
+
* - Manage spending policies and session keys
|
|
30
|
+
* - Track usage and costs
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const app = await AppClient.create("https://rpc.tenzro.network", "your-master-wallet-private-key");
|
|
35
|
+
*
|
|
36
|
+
* // Create a user wallet (funded from master)
|
|
37
|
+
* const user = await app.createUserWallet("alice", 100_000_000_000_000_000n);
|
|
38
|
+
*
|
|
39
|
+
* // Sponsor an inference request
|
|
40
|
+
* const result = await app.sponsorInference(user.address, "gemma3-270m", "Hello world");
|
|
41
|
+
*
|
|
42
|
+
* // Check usage
|
|
43
|
+
* const stats = await app.getUsageStats();
|
|
44
|
+
* console.log("Total gas spent:", stats.totalGasSpent);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
class AppClient {
|
|
48
|
+
rpc;
|
|
49
|
+
tenzroClient;
|
|
50
|
+
masterWalletInfo;
|
|
51
|
+
state;
|
|
52
|
+
constructor(rpc, tenzroClient, masterWallet) {
|
|
53
|
+
this.rpc = rpc;
|
|
54
|
+
this.tenzroClient = tenzroClient;
|
|
55
|
+
this.masterWalletInfo = masterWallet;
|
|
56
|
+
this.state = newAppState();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a new AppClient with a master wallet private key.
|
|
60
|
+
*
|
|
61
|
+
* The private key should be the hex-encoded Ed25519 or Secp256k1 key that
|
|
62
|
+
* controls the developer's master wallet.
|
|
63
|
+
*/
|
|
64
|
+
static async create(rpcUrl, masterPrivateKey) {
|
|
65
|
+
const config = { endpoint: rpcUrl, timeout: 30000 };
|
|
66
|
+
const tenzroClient = new client_1.TenzroClient(config);
|
|
67
|
+
const rpc = new rpc_1.RpcClient(rpcUrl, undefined, 30000);
|
|
68
|
+
// Derive master wallet address from the private key
|
|
69
|
+
const walletInfo = await rpc.call("tenzro_createAccount", [{ private_key: masterPrivateKey }]);
|
|
70
|
+
const masterWallet = {
|
|
71
|
+
address: walletInfo.address ?? "0x0",
|
|
72
|
+
publicKey: walletInfo.public_key ?? "",
|
|
73
|
+
};
|
|
74
|
+
return new AppClient(rpc, tenzroClient, masterWallet);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Connect using an API key that resolves to a master wallet on the server.
|
|
78
|
+
*/
|
|
79
|
+
static async fromApiKey(rpcUrl, apiKey) {
|
|
80
|
+
const config = { endpoint: rpcUrl, timeout: 30000 };
|
|
81
|
+
const tenzroClient = new client_1.TenzroClient(config);
|
|
82
|
+
const rpc = new rpc_1.RpcClient(rpcUrl, undefined, 30000);
|
|
83
|
+
const walletInfo = await rpc.call("tenzro_resolveApiKey", [{ api_key: apiKey }]);
|
|
84
|
+
const masterWallet = {
|
|
85
|
+
address: walletInfo.address ?? "0x0",
|
|
86
|
+
publicKey: walletInfo.public_key ?? "",
|
|
87
|
+
};
|
|
88
|
+
return new AppClient(rpc, tenzroClient, masterWallet);
|
|
89
|
+
}
|
|
90
|
+
// -------------------------------------------------------------------------
|
|
91
|
+
// User Management
|
|
92
|
+
// -------------------------------------------------------------------------
|
|
93
|
+
/**
|
|
94
|
+
* Create a sub-wallet for a user, funded from the master wallet.
|
|
95
|
+
*
|
|
96
|
+
* 1. Creates a new keypair via `tenzro_createWallet`
|
|
97
|
+
* 2. Transfers `initialFundingWei` TNZO from master to the new wallet
|
|
98
|
+
* 3. Tracks the user locally for policy enforcement
|
|
99
|
+
*/
|
|
100
|
+
async createUserWallet(label, initialFundingWei) {
|
|
101
|
+
const walletInfo = await this.rpc.call("tenzro_createWallet");
|
|
102
|
+
const userAddress = walletInfo.address ?? "0x0";
|
|
103
|
+
// Fund from master
|
|
104
|
+
if (initialFundingWei > 0n) {
|
|
105
|
+
await this.rpc.call("eth_sendRawTransaction", [
|
|
106
|
+
{
|
|
107
|
+
from: this.masterWalletInfo.address,
|
|
108
|
+
to: userAddress,
|
|
109
|
+
value: `0x${initialFundingWei.toString(16)}`,
|
|
110
|
+
},
|
|
111
|
+
]);
|
|
112
|
+
}
|
|
113
|
+
const user = {
|
|
114
|
+
address: userAddress,
|
|
115
|
+
label,
|
|
116
|
+
createdAt: new Date().toISOString(),
|
|
117
|
+
};
|
|
118
|
+
this.state.users.set(userAddress, user);
|
|
119
|
+
this.state.stats.userCount += 1;
|
|
120
|
+
this.state.stats.transactionCount += 1;
|
|
121
|
+
return user;
|
|
122
|
+
}
|
|
123
|
+
/** Fund an existing user wallet from the master wallet. */
|
|
124
|
+
async fundUserWallet(userAddress, amountWei) {
|
|
125
|
+
const txHash = await this.rpc.call("eth_sendRawTransaction", [
|
|
126
|
+
{
|
|
127
|
+
from: this.masterWalletInfo.address,
|
|
128
|
+
to: userAddress,
|
|
129
|
+
value: `0x${amountWei.toString(16)}`,
|
|
130
|
+
},
|
|
131
|
+
]);
|
|
132
|
+
this.state.stats.transactionCount += 1;
|
|
133
|
+
return { txHash, amount: amountWei };
|
|
134
|
+
}
|
|
135
|
+
/** List all user wallets created by this app. */
|
|
136
|
+
async listUserWallets() {
|
|
137
|
+
return Array.from(this.state.users.values());
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Set spending limits for a user wallet.
|
|
141
|
+
* Policies are enforced locally before submitting sponsored transactions.
|
|
142
|
+
*/
|
|
143
|
+
async setUserLimits(userAddress, dailyLimit, perTxLimit) {
|
|
144
|
+
const policy = {
|
|
145
|
+
dailyLimit,
|
|
146
|
+
perTxLimit,
|
|
147
|
+
dailySpent: 0n,
|
|
148
|
+
};
|
|
149
|
+
this.state.policies.set(userAddress, policy);
|
|
150
|
+
const user = this.state.users.get(userAddress);
|
|
151
|
+
if (user) {
|
|
152
|
+
user.spendingPolicy = policy;
|
|
153
|
+
}
|
|
154
|
+
return policy;
|
|
155
|
+
}
|
|
156
|
+
/** Create a session key for a user with scoped permissions and expiry. */
|
|
157
|
+
async createSessionKey(userAddress, durationSecs, allowedOps) {
|
|
158
|
+
const now = Math.floor(Date.now() / 1000);
|
|
159
|
+
const prefix = userAddress.slice(0, 8);
|
|
160
|
+
const session = {
|
|
161
|
+
sessionId: `sess_${prefix}_${now.toString(16)}`,
|
|
162
|
+
expiresAt: new Date((now + durationSecs) * 1000).toISOString(),
|
|
163
|
+
operations: allowedOps,
|
|
164
|
+
};
|
|
165
|
+
this.state.sessions.set(session.sessionId, session);
|
|
166
|
+
return session;
|
|
167
|
+
}
|
|
168
|
+
// -------------------------------------------------------------------------
|
|
169
|
+
// Sponsored Operations (master wallet pays)
|
|
170
|
+
// -------------------------------------------------------------------------
|
|
171
|
+
/**
|
|
172
|
+
* Send a transaction on behalf of a user (master pays gas).
|
|
173
|
+
*/
|
|
174
|
+
async sponsorTransaction(userAddress, to, amountWei) {
|
|
175
|
+
this.enforceSpendingPolicy(userAddress, amountWei);
|
|
176
|
+
const txHash = await this.rpc.call("eth_sendRawTransaction", [
|
|
177
|
+
{
|
|
178
|
+
from: this.masterWalletInfo.address,
|
|
179
|
+
to,
|
|
180
|
+
value: `0x${amountWei.toString(16)}`,
|
|
181
|
+
sponsor: this.masterWalletInfo.address,
|
|
182
|
+
on_behalf_of: userAddress,
|
|
183
|
+
},
|
|
184
|
+
]);
|
|
185
|
+
this.state.stats.transactionCount += 1;
|
|
186
|
+
this.state.stats.totalGasSpent += 21000000000000n;
|
|
187
|
+
const policy = this.state.policies.get(userAddress);
|
|
188
|
+
if (policy) {
|
|
189
|
+
policy.dailySpent += amountWei;
|
|
190
|
+
}
|
|
191
|
+
return { txHash };
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Run inference on behalf of a user (master pays).
|
|
195
|
+
*/
|
|
196
|
+
async sponsorInference(userAddress, modelId, message) {
|
|
197
|
+
const response = await this.rpc.call("tenzro_chat", [
|
|
198
|
+
{
|
|
199
|
+
model: modelId,
|
|
200
|
+
messages: [{ role: "user", content: message }],
|
|
201
|
+
caller_address: this.masterWalletInfo.address,
|
|
202
|
+
on_behalf_of: userAddress,
|
|
203
|
+
},
|
|
204
|
+
]);
|
|
205
|
+
const output = response?.choices?.[0]?.message?.content ?? "";
|
|
206
|
+
const tokens = response?.usage?.total_tokens ?? 0;
|
|
207
|
+
const cost = response?.usage?.cost ?? 0;
|
|
208
|
+
this.state.stats.totalInferenceCost += cost;
|
|
209
|
+
this.state.stats.transactionCount += 1;
|
|
210
|
+
return { output, tokens, cost, modelId };
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Spawn an agent on behalf of a user (master pays).
|
|
214
|
+
*/
|
|
215
|
+
async sponsorAgent(userAddress, agentName, capabilities) {
|
|
216
|
+
const response = await this.rpc.call("tenzro_registerAgent", [
|
|
217
|
+
{
|
|
218
|
+
name: agentName,
|
|
219
|
+
display_name: agentName,
|
|
220
|
+
capabilities,
|
|
221
|
+
creator: this.masterWalletInfo.address,
|
|
222
|
+
on_behalf_of: userAddress,
|
|
223
|
+
},
|
|
224
|
+
]);
|
|
225
|
+
this.state.stats.transactionCount += 1;
|
|
226
|
+
return {
|
|
227
|
+
agentId: response.agent_id ?? "",
|
|
228
|
+
walletAddress: response.wallet_address ?? "",
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Bridge tokens on behalf of a user (master pays bridge fees).
|
|
233
|
+
*/
|
|
234
|
+
async sponsorBridge(userAddress, token, fromChain, toChain, amount, recipient) {
|
|
235
|
+
const response = await this.rpc.call("tenzro_bridgeTokens", [
|
|
236
|
+
{
|
|
237
|
+
token,
|
|
238
|
+
from_chain: fromChain,
|
|
239
|
+
to_chain: toChain,
|
|
240
|
+
amount,
|
|
241
|
+
recipient,
|
|
242
|
+
fee_payer: this.masterWalletInfo.address,
|
|
243
|
+
on_behalf_of: userAddress,
|
|
244
|
+
},
|
|
245
|
+
]);
|
|
246
|
+
const fee = BigInt(response.fee ?? "0");
|
|
247
|
+
this.state.stats.totalBridgeFees += fee;
|
|
248
|
+
this.state.stats.transactionCount += 1;
|
|
249
|
+
return {
|
|
250
|
+
txHash: response.tx_hash ?? "",
|
|
251
|
+
status: response.status ?? "pending",
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Post a task to the marketplace on behalf of a user (master pays budget).
|
|
256
|
+
*/
|
|
257
|
+
async sponsorTask(userAddress, title, description, taskType, budgetWei) {
|
|
258
|
+
this.enforceSpendingPolicy(userAddress, budgetWei);
|
|
259
|
+
const response = await this.rpc.call("tenzro_postTask", [
|
|
260
|
+
{
|
|
261
|
+
title,
|
|
262
|
+
description,
|
|
263
|
+
task_type: taskType,
|
|
264
|
+
max_price: `0x${budgetWei.toString(16)}`,
|
|
265
|
+
poster: this.masterWalletInfo.address,
|
|
266
|
+
on_behalf_of: userAddress,
|
|
267
|
+
},
|
|
268
|
+
]);
|
|
269
|
+
this.state.stats.transactionCount += 1;
|
|
270
|
+
const policy = this.state.policies.get(userAddress);
|
|
271
|
+
if (policy) {
|
|
272
|
+
policy.dailySpent += budgetWei;
|
|
273
|
+
}
|
|
274
|
+
return { taskId: response.task_id ?? "" };
|
|
275
|
+
}
|
|
276
|
+
// -------------------------------------------------------------------------
|
|
277
|
+
// Master Wallet Info
|
|
278
|
+
// -------------------------------------------------------------------------
|
|
279
|
+
/** Get master wallet balance in wei. */
|
|
280
|
+
async getMasterBalance() {
|
|
281
|
+
const hex = await this.rpc.call("tenzro_getBalance", [
|
|
282
|
+
this.masterWalletInfo.address,
|
|
283
|
+
]);
|
|
284
|
+
return BigInt(hex);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Get aggregated usage statistics for this app instance.
|
|
288
|
+
* Statistics are tracked locally since the AppClient was created.
|
|
289
|
+
*/
|
|
290
|
+
async getUsageStats() {
|
|
291
|
+
return { ...this.state.stats };
|
|
292
|
+
}
|
|
293
|
+
/** Returns the master wallet information. */
|
|
294
|
+
get masterWallet() {
|
|
295
|
+
return this.masterWalletInfo;
|
|
296
|
+
}
|
|
297
|
+
/** Get the underlying TenzroClient for advanced operations. */
|
|
298
|
+
get client() {
|
|
299
|
+
return this.tenzroClient;
|
|
300
|
+
}
|
|
301
|
+
// -------------------------------------------------------------------------
|
|
302
|
+
// Internal helpers
|
|
303
|
+
// -------------------------------------------------------------------------
|
|
304
|
+
enforceSpendingPolicy(userAddress, amountWei) {
|
|
305
|
+
const policy = this.state.policies.get(userAddress);
|
|
306
|
+
if (!policy)
|
|
307
|
+
return;
|
|
308
|
+
if (amountWei > policy.perTxLimit) {
|
|
309
|
+
throw new Error(`Amount ${amountWei} exceeds per-transaction limit ${policy.perTxLimit} for user ${userAddress}`);
|
|
310
|
+
}
|
|
311
|
+
if (policy.dailySpent + amountWei > policy.dailyLimit) {
|
|
312
|
+
throw new Error(`Amount ${amountWei} would exceed daily limit ${policy.dailyLimit} (already spent ${policy.dailySpent}) for user ${userAddress}`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
exports.AppClient = AppClient;
|
|
317
|
+
//# sourceMappingURL=app.js.map
|
package/dist/app.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"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;YAC3D,IAAI,CAAC,gBAAgB,CAAC,OAAO;SAC9B,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa;QACjB,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAED,6CAA6C;IAC7C,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED,+DAA+D;IAC/D,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,4EAA4E;IAC5E,mBAAmB;IACnB,4EAA4E;IAEpE,qBAAqB,CAC3B,WAAmB,EACnB,SAAiB;QAEjB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,IAAI,SAAS,GAAG,MAAM,CAAC,UAAU,EAAE;YACjC,MAAM,IAAI,KAAK,CACb,UAAU,SAAS,kCAAkC,MAAM,CAAC,UAAU,aAAa,WAAW,EAAE,CACjG,CAAC;SACH;QACD,IAAI,MAAM,CAAC,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC,UAAU,EAAE;YACrD,MAAM,IAAI,KAAK,CACb,UAAU,SAAS,6BAA6B,MAAM,CAAC,UAAU,mBAAmB,MAAM,CAAC,UAAU,cAAc,WAAW,EAAE,CACjI,CAAC;SACH;IACH,CAAC;CACF;AA/YD,8BA+YC"}
|
package/dist/bridge.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { RpcClient } from './rpc';
|
|
2
|
+
import type { BridgeTransfer, BridgeRoute, BridgeAdapter, BridgeFee, TransferStatus } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Client for cross-chain bridge operations.
|
|
5
|
+
* Supports bridging tokens between Tenzro, Ethereum, Solana, Base, and other chains
|
|
6
|
+
* via LayerZero V2, Chainlink CCIP, deBridge DLN, and Canton adapters.
|
|
7
|
+
*
|
|
8
|
+
* **LayerZero V2:** OFT transfers use `uint64 amountSD` (shared decimals) with TYPE_3
|
|
9
|
+
* options encoding. Supported chain EIDs include Ethereum (30101), BSC (30102),
|
|
10
|
+
* Avalanche (30106), Polygon (30109), Arbitrum (30110), Optimism (30111), zkSync (30165),
|
|
11
|
+
* Base (30184), Solana (30168), Sei (30280), Sonic (30332), Berachain (30362),
|
|
12
|
+
* Story (30364), Monad (30390), MegaETH (30398), Tron (30420).
|
|
13
|
+
*
|
|
14
|
+
* **Chainlink CCIP:** Uses `allowOutOfOrderExecution = true`. Router addresses:
|
|
15
|
+
* BSC `0x34B03Cb9086d7D758AC55af71584F81A598759FE`,
|
|
16
|
+
* Base `0x881e3A65B4d4a04dD529061dd0071cf975F58bCD`.
|
|
17
|
+
*
|
|
18
|
+
* **deBridge DLN:** Order status tracked via `stats-api.dln.trade`.
|
|
19
|
+
* `ClaimedUnlock`/`SentUnlock` statuses map to `Filled`.
|
|
20
|
+
*/
|
|
21
|
+
export declare class BridgeClient {
|
|
22
|
+
private readonly rpc;
|
|
23
|
+
constructor(rpc: RpcClient);
|
|
24
|
+
/**
|
|
25
|
+
* Bridge tokens from one chain to another.
|
|
26
|
+
* @param fromChain - Source chain identifier (e.g., "tenzro", "ethereum", "solana")
|
|
27
|
+
* @param toChain - Destination chain identifier
|
|
28
|
+
* @param token - Token to bridge (e.g., "TNZO", "USDC")
|
|
29
|
+
* @param amount - Amount to bridge (decimal string)
|
|
30
|
+
* @param recipient - Recipient address on the destination chain
|
|
31
|
+
* @param adapter - Optional bridge adapter to use (e.g., "layerzero", "ccip", "debridge")
|
|
32
|
+
* @returns Bridge transfer details
|
|
33
|
+
*/
|
|
34
|
+
bridgeTokens(fromChain: string, toChain: string, token: string, amount: string, recipient: string, adapter?: string): Promise<BridgeTransfer>;
|
|
35
|
+
/**
|
|
36
|
+
* Get available bridge routes between two chains.
|
|
37
|
+
* @param fromChain - Source chain identifier
|
|
38
|
+
* @param toChain - Destination chain identifier
|
|
39
|
+
* @param token - Optional token filter
|
|
40
|
+
* @returns Array of available routes with fee and timing estimates
|
|
41
|
+
*/
|
|
42
|
+
getRoutes(fromChain: string, toChain: string, token?: string): Promise<BridgeRoute[]>;
|
|
43
|
+
/**
|
|
44
|
+
* List all registered bridge adapters.
|
|
45
|
+
* @returns Array of bridge adapter information
|
|
46
|
+
*/
|
|
47
|
+
listAdapters(): Promise<BridgeAdapter[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Get the current status of a bridge transfer.
|
|
50
|
+
* @param transferId - The transfer identifier
|
|
51
|
+
* @returns Transfer status with source and destination transaction hashes
|
|
52
|
+
*/
|
|
53
|
+
getTransferStatus(transferId: string): Promise<TransferStatus>;
|
|
54
|
+
/**
|
|
55
|
+
* Estimate the fee for a bridge transfer.
|
|
56
|
+
* @param fromChain - Source chain identifier
|
|
57
|
+
* @param toChain - Destination chain identifier
|
|
58
|
+
* @param token - Token to bridge
|
|
59
|
+
* @param amount - Amount to bridge (decimal string)
|
|
60
|
+
* @returns Fee estimate
|
|
61
|
+
*/
|
|
62
|
+
estimateFee(fromChain: string, toChain: string, token: string, amount: string): Promise<BridgeFee>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,aAAa,EACb,SAAS,EACT,cAAc,EACf,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAE3C;;;;;;;;;OASG;IACG,YAAY,CAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC;IAa1B;;;;;;OAMG;IACG,SAAS,CACb,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,EAAE,CAAC;IAMzB;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAI9C;;;;OAIG;IACG,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAMpE;;;;;;;OAOG;IACG,WAAW,CACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,SAAS,CAAC;CAKtB"}
|
package/dist/bridge.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BridgeClient = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Client for cross-chain bridge operations.
|
|
6
|
+
* Supports bridging tokens between Tenzro, Ethereum, Solana, Base, and other chains
|
|
7
|
+
* via LayerZero V2, Chainlink CCIP, deBridge DLN, and Canton adapters.
|
|
8
|
+
*
|
|
9
|
+
* **LayerZero V2:** OFT transfers use `uint64 amountSD` (shared decimals) with TYPE_3
|
|
10
|
+
* options encoding. Supported chain EIDs include Ethereum (30101), BSC (30102),
|
|
11
|
+
* Avalanche (30106), Polygon (30109), Arbitrum (30110), Optimism (30111), zkSync (30165),
|
|
12
|
+
* Base (30184), Solana (30168), Sei (30280), Sonic (30332), Berachain (30362),
|
|
13
|
+
* Story (30364), Monad (30390), MegaETH (30398), Tron (30420).
|
|
14
|
+
*
|
|
15
|
+
* **Chainlink CCIP:** Uses `allowOutOfOrderExecution = true`. Router addresses:
|
|
16
|
+
* BSC `0x34B03Cb9086d7D758AC55af71584F81A598759FE`,
|
|
17
|
+
* Base `0x881e3A65B4d4a04dD529061dd0071cf975F58bCD`.
|
|
18
|
+
*
|
|
19
|
+
* **deBridge DLN:** Order status tracked via `stats-api.dln.trade`.
|
|
20
|
+
* `ClaimedUnlock`/`SentUnlock` statuses map to `Filled`.
|
|
21
|
+
*/
|
|
22
|
+
class BridgeClient {
|
|
23
|
+
rpc;
|
|
24
|
+
constructor(rpc) {
|
|
25
|
+
this.rpc = rpc;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Bridge tokens from one chain to another.
|
|
29
|
+
* @param fromChain - Source chain identifier (e.g., "tenzro", "ethereum", "solana")
|
|
30
|
+
* @param toChain - Destination chain identifier
|
|
31
|
+
* @param token - Token to bridge (e.g., "TNZO", "USDC")
|
|
32
|
+
* @param amount - Amount to bridge (decimal string)
|
|
33
|
+
* @param recipient - Recipient address on the destination chain
|
|
34
|
+
* @param adapter - Optional bridge adapter to use (e.g., "layerzero", "ccip", "debridge")
|
|
35
|
+
* @returns Bridge transfer details
|
|
36
|
+
*/
|
|
37
|
+
async bridgeTokens(fromChain, toChain, token, amount, recipient, adapter) {
|
|
38
|
+
return this.rpc.call('tenzro_bridgeTokens', [
|
|
39
|
+
{
|
|
40
|
+
from_chain: fromChain,
|
|
41
|
+
to_chain: toChain,
|
|
42
|
+
token,
|
|
43
|
+
amount,
|
|
44
|
+
recipient,
|
|
45
|
+
adapter,
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get available bridge routes between two chains.
|
|
51
|
+
* @param fromChain - Source chain identifier
|
|
52
|
+
* @param toChain - Destination chain identifier
|
|
53
|
+
* @param token - Optional token filter
|
|
54
|
+
* @returns Array of available routes with fee and timing estimates
|
|
55
|
+
*/
|
|
56
|
+
async getRoutes(fromChain, toChain, token) {
|
|
57
|
+
return this.rpc.call('tenzro_getBridgeRoutes', [
|
|
58
|
+
{ from_chain: fromChain, to_chain: toChain, token },
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* List all registered bridge adapters.
|
|
63
|
+
* @returns Array of bridge adapter information
|
|
64
|
+
*/
|
|
65
|
+
async listAdapters() {
|
|
66
|
+
return this.rpc.call('tenzro_listBridgeAdapters');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the current status of a bridge transfer.
|
|
70
|
+
* @param transferId - The transfer identifier
|
|
71
|
+
* @returns Transfer status with source and destination transaction hashes
|
|
72
|
+
*/
|
|
73
|
+
async getTransferStatus(transferId) {
|
|
74
|
+
return this.rpc.call('tenzro_getBridgeTransferStatus', [
|
|
75
|
+
{ transfer_id: transferId },
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Estimate the fee for a bridge transfer.
|
|
80
|
+
* @param fromChain - Source chain identifier
|
|
81
|
+
* @param toChain - Destination chain identifier
|
|
82
|
+
* @param token - Token to bridge
|
|
83
|
+
* @param amount - Amount to bridge (decimal string)
|
|
84
|
+
* @returns Fee estimate
|
|
85
|
+
*/
|
|
86
|
+
async estimateFee(fromChain, toChain, token, amount) {
|
|
87
|
+
return this.rpc.call('tenzro_estimateBridgeFee', [
|
|
88
|
+
{ from_chain: fromChain, to_chain: toChain, token, amount },
|
|
89
|
+
]);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.BridgeClient = BridgeClient;
|
|
93
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":";;;AASA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,YAAY;IACM;IAA7B,YAA6B,GAAc;QAAd,QAAG,GA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
1
|
+
import type { RpcClient } from './rpc';
|
|
2
|
+
import type { CantonDomain, DamlContract, ListDamlContractsParams, DamlCommandParams, DamlCommandResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Client for Canton / DAML enterprise ledger operations.
|
|
5
|
+
* Interact with Canton synchronization domains and DAML smart contracts.
|
|
6
|
+
*
|
|
7
|
+
* Uses Canton 3.x JSON Ledger API v2 endpoints:
|
|
8
|
+
* - Commands: `POST /v2/commands/submit-and-wait-for-transaction`
|
|
9
|
+
* - Active contracts: `POST /v2/state/active-contracts` (with `identifierFilter`)
|
|
10
|
+
* - Events: `POST /v2/events/events-by-contract-id`
|
|
11
|
+
*/
|
|
12
|
+
export declare class CantonClient {
|
|
13
|
+
private readonly rpc;
|
|
14
|
+
constructor(rpc: RpcClient);
|
|
15
|
+
/**
|
|
16
|
+
* List all Canton synchronization domains connected to this node.
|
|
17
|
+
* @returns Array of domain information
|
|
18
|
+
*/
|
|
19
|
+
listDomains(): Promise<CantonDomain[]>;
|
|
20
|
+
/**
|
|
21
|
+
* List DAML contracts with optional filtering.
|
|
22
|
+
* Queries the Canton 3.x active-contracts endpoint with `identifierFilter`
|
|
23
|
+
* for template-based filtering.
|
|
24
|
+
* @param params - Optional filter by domain, template, party, with pagination
|
|
25
|
+
* @returns Array of DAML contracts
|
|
26
|
+
*/
|
|
27
|
+
listContracts(params?: ListDamlContractsParams): Promise<DamlContract[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Submit a DAML command (create or exercise) to a Canton domain.
|
|
30
|
+
* Uses the Canton 3.x `submit-and-wait-for-transaction` endpoint.
|
|
31
|
+
* @param params - Command parameters including domain, template, payload, and optional choice
|
|
32
|
+
* @returns Command result with status and events
|
|
33
|
+
*/
|
|
34
|
+
submitCommand(params: DamlCommandParams): Promise<DamlCommandResult>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=canton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canton.d.ts","sourceRoot":"","sources":["../src/canton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;GAQG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAE3C;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAI5C;;;;;;OAMG;IACG,aAAa,CAAC,MAAM,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAI9E;;;;;OAKG;IACG,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAG3E"}
|
package/dist/canton.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CantonClient = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Client for Canton / DAML enterprise ledger operations.
|
|
6
|
+
* Interact with Canton synchronization domains and DAML smart contracts.
|
|
7
|
+
*
|
|
8
|
+
* Uses Canton 3.x JSON Ledger API v2 endpoints:
|
|
9
|
+
* - Commands: `POST /v2/commands/submit-and-wait-for-transaction`
|
|
10
|
+
* - Active contracts: `POST /v2/state/active-contracts` (with `identifierFilter`)
|
|
11
|
+
* - Events: `POST /v2/events/events-by-contract-id`
|
|
12
|
+
*/
|
|
13
|
+
class CantonClient {
|
|
14
|
+
rpc;
|
|
15
|
+
constructor(rpc) {
|
|
16
|
+
this.rpc = rpc;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* List all Canton synchronization domains connected to this node.
|
|
20
|
+
* @returns Array of domain information
|
|
21
|
+
*/
|
|
22
|
+
async listDomains() {
|
|
23
|
+
return this.rpc.call('tenzro_listCantonDomains', []);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* List DAML contracts with optional filtering.
|
|
27
|
+
* Queries the Canton 3.x active-contracts endpoint with `identifierFilter`
|
|
28
|
+
* for template-based filtering.
|
|
29
|
+
* @param params - Optional filter by domain, template, party, with pagination
|
|
30
|
+
* @returns Array of DAML contracts
|
|
31
|
+
*/
|
|
32
|
+
async listContracts(params) {
|
|
33
|
+
return this.rpc.call('tenzro_listDamlContracts', [params ?? {}]);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Submit a DAML command (create or exercise) to a Canton domain.
|
|
37
|
+
* Uses the Canton 3.x `submit-and-wait-for-transaction` endpoint.
|
|
38
|
+
* @param params - Command parameters including domain, template, payload, and optional choice
|
|
39
|
+
* @returns Command result with status and events
|
|
40
|
+
*/
|
|
41
|
+
async submitCommand(params) {
|
|
42
|
+
return this.rpc.call('tenzro_submitDamlCommand', [params]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.CantonClient = CantonClient;
|
|
46
|
+
//# sourceMappingURL=canton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canton.js","sourceRoot":"","sources":["../src/canton.ts"],"names":[],"mappings":";;;AASA;;;;;;;;GAQG;AACH,MAAa,YAAY;IACM;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C;;;OAGG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAiB,0BAA0B,EAAE,EAAE,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,aAAa,CAAC,MAAgC;QAClD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAiB,0BAA0B,EAAE,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,aAAa,CAAC,MAAyB;QAC3C,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAoB,0BAA0B,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAChF,CAAC;CACF;AA/BD,oCA+BC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { RpcClient } from './rpc';
|
|
2
|
+
import type { ProviderHealth, CircuitBreakerStatus, CircuitBreakerConfig, ConfigResult, ResetResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Client for circuit breaker configuration and provider health monitoring.
|
|
5
|
+
* Manages automatic failure detection and recovery for inference providers.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CircuitBreakerClient {
|
|
8
|
+
private readonly rpc;
|
|
9
|
+
constructor(rpc: RpcClient);
|
|
10
|
+
/**
|
|
11
|
+
* Get health information for a specific provider.
|
|
12
|
+
* @param providerId - The provider identifier
|
|
13
|
+
* @returns Provider health status including success rate and circuit state
|
|
14
|
+
*/
|
|
15
|
+
getProviderHealth(providerId: string): Promise<ProviderHealth>;
|
|
16
|
+
/**
|
|
17
|
+
* List all circuit breakers and their current status.
|
|
18
|
+
* @returns Array of circuit breaker statuses
|
|
19
|
+
*/
|
|
20
|
+
listCircuitBreakers(): Promise<CircuitBreakerStatus[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Configure the circuit breaker for a specific provider.
|
|
23
|
+
* @param providerId - The provider identifier
|
|
24
|
+
* @param config - Circuit breaker configuration
|
|
25
|
+
* @returns Configuration result
|
|
26
|
+
*/
|
|
27
|
+
configureBreaker(providerId: string, config: CircuitBreakerConfig): Promise<ConfigResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Reset a circuit breaker to closed state.
|
|
30
|
+
* @param providerId - The provider identifier to reset
|
|
31
|
+
* @returns Reset result with new circuit state
|
|
32
|
+
*/
|
|
33
|
+
resetBreaker(providerId: string): Promise<ResetResult>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=circuit-breaker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circuit-breaker.d.ts","sourceRoot":"","sources":["../src/circuit-breaker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,qBAAa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAE3C;;;;OAIG;IACG,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAMpE;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAI5D;;;;;OAKG;IACG,gBAAgB,CACpB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,YAAY,CAAC;IAMxB;;;;OAIG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAK7D"}
|