@trustware/sdk-staging 1.1.10-staging.0 → 1.1.11-staging.2
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/README.md +54 -21
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/{core-BPLiD1UG.d.ts → core-B1WCJfDI.d.ts} +15 -2
- package/dist/{core-B7Ez-5-r.d.cts → core-CeNTuqPz.d.cts} +15 -2
- package/dist/core.cjs +365 -279
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.mjs +363 -278
- package/dist/core.mjs.map +1 -1
- package/dist/index.cjs +375 -170
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.mjs +373 -169
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-B6NNV-E_.d.ts → manager-Bw8b1wSD.d.ts} +136 -21
- package/dist/{manager-BwjyFjjz.d.cts → manager-DNGk1YkR.d.cts} +136 -21
- package/dist/{metadata-BiTMMvlY.d.ts → metadata-C__KMeuz.d.ts} +1 -1
- package/dist/{metadata-HCflXcsF.d.cts → metadata-Dk4R8_-T.d.cts} +1 -1
- package/dist/smart-account.cjs +49 -44
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.d.cts +17 -12
- package/dist/smart-account.d.ts +17 -12
- package/dist/smart-account.mjs +49 -44
- package/dist/smart-account.mjs.map +1 -1
- package/dist/wallet.cjs +54 -39
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +3 -3
- package/dist/wallet.d.ts +3 -3
- package/dist/wallet.mjs +54 -39
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +369 -170
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +369 -169
- package/dist/widget.mjs.map +1 -1
- package/package.json +73 -5
package/README.md
CHANGED
|
@@ -37,8 +37,6 @@ The current widget flow is:
|
|
|
37
37
|
|
|
38
38
|
`Home -> Select Token -> Confirm Deposit -> Processing -> Success/Error`
|
|
39
39
|
|
|
40
|
-
The refactored widget keeps the same behavior, but the configuration surface is now documented around the actual `TrustwareConfigOptions` shape and the current widget step model.
|
|
41
|
-
|
|
42
40
|
## Installation
|
|
43
41
|
|
|
44
42
|
Supports React `18.2+` and `19`.
|
|
@@ -115,7 +113,7 @@ type TrustwareConfigOptions = {
|
|
|
115
113
|
};
|
|
116
114
|
};
|
|
117
115
|
autoDetectProvider?: boolean;
|
|
118
|
-
theme?:
|
|
116
|
+
theme?: "light" | "dark" | "system"; // TrustwareTheme
|
|
119
117
|
messages?: Partial<TrustwareWidgetMessages>;
|
|
120
118
|
retry?: RetryConfig;
|
|
121
119
|
walletConnect?: WalletConnectConfig;
|
|
@@ -172,7 +170,8 @@ type TrustwareConfigOptions = {
|
|
|
172
170
|
### Other Config Groups
|
|
173
171
|
|
|
174
172
|
- `autoDetectProvider`: enables Trustware-managed wallet discovery.
|
|
175
|
-
- `theme`: widget color
|
|
173
|
+
- `theme`: widget color mode — `"light" | "dark" | "system"` (default
|
|
174
|
+
`"system"`). Switch it at runtime with `Trustware.setTheme("dark")`.
|
|
176
175
|
- `messages`: top-level copy overrides.
|
|
177
176
|
- `retry`: API retry and rate-limit behavior.
|
|
178
177
|
- `walletConnect`: WalletConnect overrides.
|
|
@@ -232,6 +231,13 @@ export function DepositPanel() {
|
|
|
232
231
|
}
|
|
233
232
|
```
|
|
234
233
|
|
|
234
|
+
`useWagmi` (like `useEIP1193`) is a plain adapter factory, not a React hook,
|
|
235
|
+
despite the `use` prefix. If your ESLint setup runs `react-hooks/rules-of-hooks`
|
|
236
|
+
it will flag the call inside the `useMemo` callback above; silence it with an
|
|
237
|
+
`eslint-disable-next-line react-hooks/rules-of-hooks` comment — the call is
|
|
238
|
+
safe. See [docs.trustware.io](https://docs.trustware.io/guides/embedded-wallets#adapt-the-embedded-wallet)
|
|
239
|
+
for the same pattern with embedded wallets.
|
|
240
|
+
|
|
235
241
|
Use this mode when:
|
|
236
242
|
|
|
237
243
|
- your app already owns wallet state
|
|
@@ -285,19 +291,28 @@ Use this when you want Trustware’s routing and wallet plumbing without the wid
|
|
|
285
291
|
```ts
|
|
286
292
|
import { Trustware } from "@trustware/sdk";
|
|
287
293
|
|
|
294
|
+
// buildRoute states both sides explicitly. fromAmount is in the source token's
|
|
295
|
+
// smallest unit, and the estimate comes back on the route — there is no
|
|
296
|
+
// separate quote call.
|
|
288
297
|
const route = await Trustware.buildRoute({
|
|
289
|
-
|
|
298
|
+
fromChain: "1",
|
|
299
|
+
fromToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum
|
|
300
|
+
toChain: "8453",
|
|
301
|
+
toToken: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // native on Base
|
|
302
|
+
fromAmount: "25000000", // 25 USDC (6 decimals)
|
|
290
303
|
fromAddress: await Trustware.getAddress(),
|
|
304
|
+
toAddress: "0xDestination...",
|
|
291
305
|
});
|
|
306
|
+
console.log(route.route?.estimate, route.finalExchangeRate);
|
|
292
307
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
fromAddress: await Trustware.getAddress(),
|
|
298
|
-
});
|
|
308
|
+
// Or let the SDK own route + submit + receipt + polling. Missing route fields
|
|
309
|
+
// come from the provider config; the sender comes from the attached wallet.
|
|
310
|
+
const tx = await Trustware.runTopUp({ fromAmount: "25000000" });
|
|
311
|
+
console.log(tx.status, tx.destTxHash);
|
|
299
312
|
```
|
|
300
313
|
|
|
314
|
+
See [docs.trustware.io](https://docs.trustware.io) for the full headless flow.
|
|
315
|
+
|
|
301
316
|
## Common Config Examples
|
|
302
317
|
|
|
303
318
|
### Fixed Amount Deposit
|
|
@@ -347,26 +362,44 @@ Trustware.setDestinationAddress("0xDestination...");
|
|
|
347
362
|
|
|
348
363
|
## Rate Limiting
|
|
349
364
|
|
|
350
|
-
|
|
365
|
+
The API is rate limited per API key, and that limit is shared by everyone using
|
|
366
|
+
your key — not per end user. Your key's limit, its remaining requests and the
|
|
367
|
+
window boundary come back on every response (`X-RateLimit-Limit`, `-Remaining`,
|
|
368
|
+
`-Reset`, plus `Retry-After` on a 429).
|
|
369
|
+
|
|
370
|
+
The SDK retries 429s on the schedule those headers state — it keeps no schedule
|
|
371
|
+
of its own to disagree with them. It waits exactly as long as the server asks,
|
|
372
|
+
for as long as the total stays under 10 seconds. Past that it stops and throws,
|
|
373
|
+
because how long your app can afford to block is the one thing the server can't
|
|
374
|
+
know. If a response carries no timing at all, the SDK stops rather than
|
|
375
|
+
guessing: the limit is a fixed window, so an invented delay either lands inside
|
|
376
|
+
the same closed window or overshoots one it could have read exactly.
|
|
377
|
+
|
|
378
|
+
None of that is configurable — the limit is enforced server-side, so no client
|
|
379
|
+
setting can widen it. If you need more headroom, ask us to raise the limit on
|
|
380
|
+
your key. `retry` configures observability only:
|
|
351
381
|
|
|
352
382
|
```ts
|
|
353
383
|
const config = {
|
|
354
384
|
...trustwareConfig,
|
|
355
385
|
retry: {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
386
|
+
onRateLimitInfo: (info) => console.debug(info.remaining, "requests left"),
|
|
387
|
+
onRateLimited: (info, attempt) => console.warn("429", attempt, info),
|
|
388
|
+
onRateLimitApproaching: (info) => showSoftWarning(info),
|
|
359
389
|
approachingThreshold: 5,
|
|
360
390
|
},
|
|
361
391
|
} satisfies TrustwareConfigOptions;
|
|
362
392
|
```
|
|
363
393
|
|
|
364
|
-
|
|
394
|
+
`RateLimitError` distinguishes the two ways the SDK gives up:
|
|
395
|
+
|
|
396
|
+
- `retriesExhausted: false` — the wait is known and simply longer than the SDK
|
|
397
|
+
will block for. `rateLimitInfo.retryAfter` holds it, so show the user when to
|
|
398
|
+
come back instead of leaving them on a spinner.
|
|
399
|
+
- `retriesExhausted: true` — the response carried no usable timing, so there was
|
|
400
|
+
nothing to retry against.
|
|
365
401
|
|
|
366
402
|
## Docs
|
|
367
403
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
- [Backend RPC Offload PDR](docs/backend-rpc-offload-pdr.md)
|
|
371
|
-
- [Widget Architecture Boundaries](docs/widget-architecture-boundaries.md)
|
|
372
|
-
- [Widget Refactor Baseline](docs/widget-refactor-baseline.md)
|
|
404
|
+
Full API reference, integration guides, and examples live at
|
|
405
|
+
[docs.trustware.io](https://docs.trustware.io).
|
package/dist/constants.cjs
CHANGED
|
@@ -30,7 +30,7 @@ __export(constants_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(constants_exports);
|
|
32
32
|
var SDK_NAME = "@trustware/sdk";
|
|
33
|
-
var SDK_VERSION = "1.1.
|
|
33
|
+
var SDK_VERSION = "1.1.11-staging.2";
|
|
34
34
|
var API_ROOT = "https://bv-staging-api.trustware.io";
|
|
35
35
|
var GTM_ID = "GTM-TZDGNCXB";
|
|
36
36
|
var API_PREFIX = "/api";
|
package/dist/constants.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as BuildRouteResult, k as Transaction, T as TrustwareConfigOptions, i as WalletInterFaceAPI,
|
|
1
|
+
import { n as BuildRouteResult, k as Transaction, T as TrustwareConfigOptions, i as WalletInterFaceAPI, A as ResolvedTrustwareConfig, X as TrustwareTheme, a2 as WalletIdentity, w as walletManager, Z as WalletAddressResolution, aa as buildRoute, ab as buildDepositAddress, ac as submitReceipt, ad as submitStepReceipt, ae as getStatus, af as pollStatus } from './manager-Bw8b1wSD.js';
|
|
2
2
|
import { C as ChainDef, c as ChainType, G as GetBalancesOptions, B as BalanceRow, a as BalanceStreamOptions, W as WalletAddressBalanceWrapper } from './blockchain-BxAFzp0s.js';
|
|
3
3
|
import { T as Token } from './types-BJY9r-mz.js';
|
|
4
4
|
|
|
@@ -26,7 +26,19 @@ declare function getBalances(chainRef: string | number, address: string, opts?:
|
|
|
26
26
|
declare function getBalancesByAddress(address: string, opts?: BalanceStreamOptions): Promise<WalletAddressBalanceWrapper[]>;
|
|
27
27
|
declare function getBalancesByAddressStream(address: string, opts?: BalanceStreamOptions): AsyncGenerator<WalletAddressBalanceWrapper[], void, void>;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
type SendRouteTransactionOptions = {
|
|
30
|
+
/**
|
|
31
|
+
* The caller has already run the plan's approval flow (checked allowances,
|
|
32
|
+
* sent any approves, waited for confirmation). Skips the internal
|
|
33
|
+
* ensureApprovals pass entirely — re-reading an allowance immediately
|
|
34
|
+
* after its approve confirms can return pre-block state from a different
|
|
35
|
+
* RPC node, which made the SDK prompt for the same approval twice
|
|
36
|
+
* (BVT-330). Exactly one path must own the approval decision per
|
|
37
|
+
* execution; this flag is how a caller claims that ownership.
|
|
38
|
+
*/
|
|
39
|
+
approvalsEnsured?: boolean;
|
|
40
|
+
};
|
|
41
|
+
declare function sendRouteTransaction(b: BuildRouteResult, fallbackChainId?: number | string, options?: SendRouteTransactionOptions): Promise<string>;
|
|
30
42
|
declare function runTopUp(params: {
|
|
31
43
|
fromChain?: string;
|
|
32
44
|
toChain?: string;
|
|
@@ -127,6 +139,7 @@ declare const Trustware: {
|
|
|
127
139
|
buildRoute: typeof buildRoute;
|
|
128
140
|
buildDepositAddress: typeof buildDepositAddress;
|
|
129
141
|
submitReceipt: typeof submitReceipt;
|
|
142
|
+
submitStepReceipt: typeof submitStepReceipt;
|
|
130
143
|
getStatus: typeof getStatus;
|
|
131
144
|
pollStatus: typeof pollStatus;
|
|
132
145
|
getBalances: typeof getBalances;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as BuildRouteResult, k as Transaction, T as TrustwareConfigOptions, i as WalletInterFaceAPI,
|
|
1
|
+
import { n as BuildRouteResult, k as Transaction, T as TrustwareConfigOptions, i as WalletInterFaceAPI, A as ResolvedTrustwareConfig, X as TrustwareTheme, a2 as WalletIdentity, w as walletManager, Z as WalletAddressResolution, aa as buildRoute, ab as buildDepositAddress, ac as submitReceipt, ad as submitStepReceipt, ae as getStatus, af as pollStatus } from './manager-DNGk1YkR.cjs';
|
|
2
2
|
import { C as ChainDef, c as ChainType, G as GetBalancesOptions, B as BalanceRow, a as BalanceStreamOptions, W as WalletAddressBalanceWrapper } from './blockchain-BxAFzp0s.cjs';
|
|
3
3
|
import { T as Token } from './types-DX3HtFcn.cjs';
|
|
4
4
|
|
|
@@ -26,7 +26,19 @@ declare function getBalances(chainRef: string | number, address: string, opts?:
|
|
|
26
26
|
declare function getBalancesByAddress(address: string, opts?: BalanceStreamOptions): Promise<WalletAddressBalanceWrapper[]>;
|
|
27
27
|
declare function getBalancesByAddressStream(address: string, opts?: BalanceStreamOptions): AsyncGenerator<WalletAddressBalanceWrapper[], void, void>;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
type SendRouteTransactionOptions = {
|
|
30
|
+
/**
|
|
31
|
+
* The caller has already run the plan's approval flow (checked allowances,
|
|
32
|
+
* sent any approves, waited for confirmation). Skips the internal
|
|
33
|
+
* ensureApprovals pass entirely — re-reading an allowance immediately
|
|
34
|
+
* after its approve confirms can return pre-block state from a different
|
|
35
|
+
* RPC node, which made the SDK prompt for the same approval twice
|
|
36
|
+
* (BVT-330). Exactly one path must own the approval decision per
|
|
37
|
+
* execution; this flag is how a caller claims that ownership.
|
|
38
|
+
*/
|
|
39
|
+
approvalsEnsured?: boolean;
|
|
40
|
+
};
|
|
41
|
+
declare function sendRouteTransaction(b: BuildRouteResult, fallbackChainId?: number | string, options?: SendRouteTransactionOptions): Promise<string>;
|
|
30
42
|
declare function runTopUp(params: {
|
|
31
43
|
fromChain?: string;
|
|
32
44
|
toChain?: string;
|
|
@@ -127,6 +139,7 @@ declare const Trustware: {
|
|
|
127
139
|
buildRoute: typeof buildRoute;
|
|
128
140
|
buildDepositAddress: typeof buildDepositAddress;
|
|
129
141
|
submitReceipt: typeof submitReceipt;
|
|
142
|
+
submitStepReceipt: typeof submitStepReceipt;
|
|
130
143
|
getStatus: typeof getStatus;
|
|
131
144
|
pollStatus: typeof pollStatus;
|
|
132
145
|
getBalances: typeof getBalances;
|