@trustware/sdk-staging 1.1.12-staging.4 → 1.1.12-staging.6
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 +100 -16
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/smart-account.cjs +1 -1
- package/dist/smart-account.mjs +1 -1
- package/dist/wallet.cjs +1 -1
- package/dist/wallet.mjs +1 -1
- package/dist/widget.cjs +1 -1
- package/dist/widget.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,20 +39,32 @@ The current widget flow is:
|
|
|
39
39
|
|
|
40
40
|
## Installation
|
|
41
41
|
|
|
42
|
-
Supports React `18.2+` and `19`.
|
|
43
|
-
|
|
44
42
|
```bash
|
|
45
43
|
npm install @trustware/sdk
|
|
46
44
|
# or
|
|
47
45
|
pnpm add @trustware/sdk
|
|
48
46
|
```
|
|
49
47
|
|
|
48
|
+
Supports React `18.2+` and `19`.
|
|
49
|
+
|
|
50
50
|
## Main Exports
|
|
51
51
|
|
|
52
52
|
- `TrustwareProvider`
|
|
53
|
+
- `useTrustware`
|
|
53
54
|
- `TrustwareWidget`
|
|
54
55
|
- `Trustware`
|
|
55
|
-
- `
|
|
56
|
+
- `TrustwareError`
|
|
57
|
+
- `RateLimitError`
|
|
58
|
+
- `assertValidPostHook`
|
|
59
|
+
- `walletManager`
|
|
60
|
+
- `useWalletDetection`
|
|
61
|
+
- `useWalletInfo`
|
|
62
|
+
- `connectDetectedWallet`
|
|
63
|
+
- `WagmiBridge`
|
|
64
|
+
- `useWagmi`
|
|
65
|
+
- `useEIP1193`
|
|
66
|
+
- `WALLETS`
|
|
67
|
+
- `./identity`, `./validation/address`, `./types`, `./constants`
|
|
56
68
|
|
|
57
69
|
## Quick Start
|
|
58
70
|
|
|
@@ -102,6 +114,7 @@ type TrustwareConfigOptions = {
|
|
|
102
114
|
toChain: string;
|
|
103
115
|
toToken: string;
|
|
104
116
|
fromToken?: string;
|
|
117
|
+
fromChain?: string;
|
|
105
118
|
fromAddress?: string;
|
|
106
119
|
toAddress?: string;
|
|
107
120
|
defaultSlippage?: number;
|
|
@@ -156,10 +169,14 @@ type TrustwareConfigOptions = {
|
|
|
156
169
|
- `routes.toChain`: destination chain key or chain id string.
|
|
157
170
|
- `routes.toToken`: destination token address or registry token identifier.
|
|
158
171
|
- `routes.fromToken`: optional source token preference.
|
|
172
|
+
- `routes.fromChain`: optional source chain preference.
|
|
159
173
|
- `routes.fromAddress`: optional source wallet override.
|
|
160
174
|
- `routes.toAddress`: optional destination address override.
|
|
161
175
|
- `routes.defaultSlippage`: optional slippage percentage. Defaults to `1`.
|
|
162
176
|
|
|
177
|
+
Chain and token fields are strings, including numeric chain ids — `"8453"`, not
|
|
178
|
+
`8453`.
|
|
179
|
+
|
|
163
180
|
### Route Options
|
|
164
181
|
|
|
165
182
|
- `routes.options.routeRefreshMs`: auto-refresh cadence for route previews.
|
|
@@ -169,14 +186,15 @@ type TrustwareConfigOptions = {
|
|
|
169
186
|
|
|
170
187
|
### Other Config Groups
|
|
171
188
|
|
|
172
|
-
- `autoDetectProvider`: enables Trustware-managed wallet discovery.
|
|
189
|
+
- `autoDetectProvider`: enables Trustware-managed wallet discovery. Defaults to
|
|
190
|
+
`false` — set it to `true` if you are not attaching a wallet yourself.
|
|
173
191
|
- `theme`: widget color mode — `"light" | "dark" | "system"` (default
|
|
174
192
|
`"system"`). Switch it at runtime with `Trustware.setTheme("dark")`.
|
|
175
193
|
- `messages`: top-level copy overrides.
|
|
176
|
-
- `retry`:
|
|
194
|
+
- `retry`: rate-limit observability callbacks — see [Rate Limiting](#rate-limiting).
|
|
177
195
|
- `walletConnect`: WalletConnect overrides.
|
|
178
196
|
- `features`: feature rollout controls, including swap-mode token selection constraints.
|
|
179
|
-
- `onError`, `onSuccess`, `onEvent`: lifecycle callbacks.
|
|
197
|
+
- `onError`, `onSuccess`, `onEvent`: lifecycle callbacks — see [Events](#events).
|
|
180
198
|
|
|
181
199
|
## Widget Usage Patterns
|
|
182
200
|
|
|
@@ -204,7 +222,7 @@ Use this mode when:
|
|
|
204
222
|
|
|
205
223
|
### 2. Widget With a Host-Managed Wallet
|
|
206
224
|
|
|
207
|
-
Use this when your app already controls wallet connection through Wagmi
|
|
225
|
+
Use this when your app already controls wallet connection through Wagmi or another adapter.
|
|
208
226
|
|
|
209
227
|
```tsx
|
|
210
228
|
import { useMemo } from "react";
|
|
@@ -250,11 +268,9 @@ Use this mode when:
|
|
|
250
268
|
|
|
251
269
|
```tsx
|
|
252
270
|
import { useRef } from "react";
|
|
253
|
-
import {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
type TrustwareWidgetRef,
|
|
257
|
-
} from "@trustware/sdk";
|
|
271
|
+
import { TrustwareProvider, TrustwareWidget } from "@trustware/sdk";
|
|
272
|
+
// The widget's prop and ref types live on the widget entry, not the root barrel.
|
|
273
|
+
import type { TrustwareWidgetRef } from "@trustware/sdk/react";
|
|
258
274
|
|
|
259
275
|
export function ControlledWidget() {
|
|
260
276
|
const widgetRef = useRef<TrustwareWidgetRef>(null);
|
|
@@ -277,12 +293,17 @@ export function ControlledWidget() {
|
|
|
277
293
|
|
|
278
294
|
Current widget props:
|
|
279
295
|
|
|
280
|
-
- `theme?: "light" | "dark" | "system"`
|
|
296
|
+
- `theme?: "light" | "dark" | "system"` — initial mode only; `Trustware.setTheme()` drives it afterwards
|
|
281
297
|
- `initialStep?: "home" | "select-token" | "crypto-pay" | "processing" | "success" | "error"`
|
|
282
|
-
- `defaultOpen?: boolean`
|
|
298
|
+
- `defaultOpen?: boolean` — defaults to `true`, which is what you want for inline usage
|
|
299
|
+
- `style?: React.CSSProperties` — merged onto the widget shell
|
|
283
300
|
- `onOpen?: () => void`
|
|
284
301
|
- `onClose?: () => void`
|
|
285
|
-
- `showThemeToggle?: boolean`
|
|
302
|
+
- `showThemeToggle?: boolean` — defaults to `true`
|
|
303
|
+
|
|
304
|
+
And the ref (`TrustwareWidgetRef`): `open()`, `close()`, `isOpen()`. `close()`
|
|
305
|
+
asks for confirmation first if a transaction is in flight, so it is safe to wire
|
|
306
|
+
straight to a dismiss button.
|
|
286
307
|
|
|
287
308
|
### 4. Headless Core API
|
|
288
309
|
|
|
@@ -355,10 +376,73 @@ Trustware.setDestinationAddress("0xDestination...");
|
|
|
355
376
|
|
|
356
377
|
## Headless / Core Notes
|
|
357
378
|
|
|
379
|
+
`Trustware` is a plain object, not a class or an event emitter — there is no
|
|
380
|
+
`Trustware.on()`. Events reach you through `config.onEvent`.
|
|
381
|
+
|
|
382
|
+
**Lifecycle and config**
|
|
383
|
+
|
|
384
|
+
- `Trustware.init(config)` loads the config and validates the API key once.
|
|
358
385
|
- `Trustware.getConfig()` returns the resolved config.
|
|
359
|
-
- `Trustware.
|
|
386
|
+
- `Trustware.setTheme(mode)` / `getTheme()` switch the widget's color mode at runtime.
|
|
387
|
+
- `Trustware.setDestinationAddress/Chain/Token()` update the route defaults in place.
|
|
388
|
+
|
|
389
|
+
**Wallets**
|
|
390
|
+
|
|
360
391
|
- `Trustware.useWallet(wallet)` attaches a wallet imperatively.
|
|
392
|
+
- `Trustware.getWallet()` and `Trustware.getAddress()` expose the active wallet.
|
|
361
393
|
- `Trustware.autoDetect()` can still be used if you want SDK-managed discovery outside the widget.
|
|
394
|
+
- `Trustware.getIdentity()` / `resolveAddressForChain()` / `addIdentityAddress()` handle
|
|
395
|
+
multi-chain identities, so an EVM address and a Solana address can belong to one user.
|
|
396
|
+
|
|
397
|
+
**Routes, status and balances**
|
|
398
|
+
|
|
399
|
+
- `buildRoute`, `buildDepositAddress` — build a route, or an address to deposit into.
|
|
400
|
+
- `submitReceipt`, `submitStepReceipt`, `sendRouteTransaction`, `runTopUp` — execution.
|
|
401
|
+
- `getStatus`, `pollStatus` — read a transaction through to a terminal state.
|
|
402
|
+
- `getBalances`, `getBalancesByAddress`, `getBalancesByAddressStream`.
|
|
403
|
+
- `useChains`, `useTokens` — React hooks over the chain and token registries.
|
|
404
|
+
- `validateAddressForChain`, `validateRouteAddresses` — check addresses before you spend a request.
|
|
405
|
+
|
|
406
|
+
There is no `getQuote`: the estimate is part of the route, on
|
|
407
|
+
`route.route?.estimate` and `route.finalExchangeRate`.
|
|
408
|
+
|
|
409
|
+
### Provider Context
|
|
410
|
+
|
|
411
|
+
`useTrustware()` returns `{ status, errors, core, emitError, emitSuccess,
|
|
412
|
+
emitEvent, revalidate }`. `status` is `"idle" | "initializing" | "ready" |
|
|
413
|
+
"error"` — gate anything that calls the API on `"ready"`. `core` is the same
|
|
414
|
+
`Trustware` facade, handed to you so you don't have to import it separately, and
|
|
415
|
+
`revalidate()` re-runs init after a failure (an API key arriving late, for
|
|
416
|
+
instance).
|
|
417
|
+
|
|
418
|
+
## Smart Accounts
|
|
419
|
+
|
|
420
|
+
For ERC-4337 flows, `@trustware/sdk/smart-account` sends a route as a user
|
|
421
|
+
operation rather than a wallet transaction:
|
|
422
|
+
|
|
423
|
+
```ts
|
|
424
|
+
import {
|
|
425
|
+
createTrustwareSmartAccountClient,
|
|
426
|
+
sendRouteAsUserOperation,
|
|
427
|
+
} from "@trustware/sdk/smart-account";
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
It is a separate entry point on purpose — 65 KB gzipped, and nothing pulls it in
|
|
431
|
+
unless you import it.
|
|
432
|
+
|
|
433
|
+
## Events
|
|
434
|
+
|
|
435
|
+
`config.onEvent` receives a discriminated `TrustwareEvent`:
|
|
436
|
+
|
|
437
|
+
- `error`
|
|
438
|
+
- `transaction_started`
|
|
439
|
+
- `transaction_success`
|
|
440
|
+
- `wallet_connected`
|
|
441
|
+
- `token_page_loaded`
|
|
442
|
+
- `token_page_error`
|
|
443
|
+
- `balance_stream_chunk`
|
|
444
|
+
- `balance_stream_fallback`
|
|
445
|
+
- `swap_route_changed`
|
|
362
446
|
|
|
363
447
|
## Rate Limiting
|
|
364
448
|
|
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.12-staging.
|
|
33
|
+
var SDK_VERSION = "1.1.12-staging.6";
|
|
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
package/dist/core.cjs
CHANGED
|
@@ -83,7 +83,7 @@ var init_constants = __esm({
|
|
|
83
83
|
"src/constants.ts"() {
|
|
84
84
|
"use strict";
|
|
85
85
|
SDK_NAME = "@trustware/sdk";
|
|
86
|
-
SDK_VERSION = "1.1.12-staging.
|
|
86
|
+
SDK_VERSION = "1.1.12-staging.6";
|
|
87
87
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
88
88
|
API_PREFIX = "/api";
|
|
89
89
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
package/dist/core.mjs
CHANGED
|
@@ -61,7 +61,7 @@ var init_constants = __esm({
|
|
|
61
61
|
"src/constants.ts"() {
|
|
62
62
|
"use strict";
|
|
63
63
|
SDK_NAME = "@trustware/sdk";
|
|
64
|
-
SDK_VERSION = "1.1.12-staging.
|
|
64
|
+
SDK_VERSION = "1.1.12-staging.6";
|
|
65
65
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
66
66
|
API_PREFIX = "/api";
|
|
67
67
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
package/dist/index.cjs
CHANGED
|
@@ -514,7 +514,7 @@ var init_constants = __esm({
|
|
|
514
514
|
"src/constants.ts"() {
|
|
515
515
|
"use strict";
|
|
516
516
|
SDK_NAME = "@trustware/sdk";
|
|
517
|
-
SDK_VERSION = "1.1.12-staging.
|
|
517
|
+
SDK_VERSION = "1.1.12-staging.6";
|
|
518
518
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
519
519
|
GTM_ID = "GTM-TZDGNCXB";
|
|
520
520
|
API_PREFIX = "/api";
|
package/dist/index.mjs
CHANGED
|
@@ -492,7 +492,7 @@ var init_constants = __esm({
|
|
|
492
492
|
"src/constants.ts"() {
|
|
493
493
|
"use strict";
|
|
494
494
|
SDK_NAME = "@trustware/sdk";
|
|
495
|
-
SDK_VERSION = "1.1.12-staging.
|
|
495
|
+
SDK_VERSION = "1.1.12-staging.6";
|
|
496
496
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
497
497
|
GTM_ID = "GTM-TZDGNCXB";
|
|
498
498
|
API_PREFIX = "/api";
|
package/dist/smart-account.cjs
CHANGED
|
@@ -12265,7 +12265,7 @@ var init_constants = __esm({
|
|
|
12265
12265
|
"src/constants.ts"() {
|
|
12266
12266
|
"use strict";
|
|
12267
12267
|
SDK_NAME = "@trustware/sdk";
|
|
12268
|
-
SDK_VERSION = "1.1.12-staging.
|
|
12268
|
+
SDK_VERSION = "1.1.12-staging.6";
|
|
12269
12269
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
12270
12270
|
API_PREFIX = "/api";
|
|
12271
12271
|
}
|
package/dist/smart-account.mjs
CHANGED
|
@@ -12241,7 +12241,7 @@ var init_constants = __esm({
|
|
|
12241
12241
|
"src/constants.ts"() {
|
|
12242
12242
|
"use strict";
|
|
12243
12243
|
SDK_NAME = "@trustware/sdk";
|
|
12244
|
-
SDK_VERSION = "1.1.12-staging.
|
|
12244
|
+
SDK_VERSION = "1.1.12-staging.6";
|
|
12245
12245
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
12246
12246
|
API_PREFIX = "/api";
|
|
12247
12247
|
}
|
package/dist/wallet.cjs
CHANGED
|
@@ -264,7 +264,7 @@ var init_constants = __esm({
|
|
|
264
264
|
"src/constants.ts"() {
|
|
265
265
|
"use strict";
|
|
266
266
|
SDK_NAME = "@trustware/sdk";
|
|
267
|
-
SDK_VERSION = "1.1.12-staging.
|
|
267
|
+
SDK_VERSION = "1.1.12-staging.6";
|
|
268
268
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
269
269
|
API_PREFIX = "/api";
|
|
270
270
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
package/dist/wallet.mjs
CHANGED
|
@@ -238,7 +238,7 @@ var init_constants = __esm({
|
|
|
238
238
|
"src/constants.ts"() {
|
|
239
239
|
"use strict";
|
|
240
240
|
SDK_NAME = "@trustware/sdk";
|
|
241
|
-
SDK_VERSION = "1.1.12-staging.
|
|
241
|
+
SDK_VERSION = "1.1.12-staging.6";
|
|
242
242
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
243
243
|
API_PREFIX = "/api";
|
|
244
244
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
package/dist/widget.cjs
CHANGED
|
@@ -593,7 +593,7 @@ var init_constants = __esm({
|
|
|
593
593
|
"src/constants.ts"() {
|
|
594
594
|
"use strict";
|
|
595
595
|
SDK_NAME = "@trustware/sdk";
|
|
596
|
-
SDK_VERSION = "1.1.12-staging.
|
|
596
|
+
SDK_VERSION = "1.1.12-staging.6";
|
|
597
597
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
598
598
|
GTM_ID = "GTM-TZDGNCXB";
|
|
599
599
|
API_PREFIX = "/api";
|
package/dist/widget.mjs
CHANGED
|
@@ -571,7 +571,7 @@ var init_constants = __esm({
|
|
|
571
571
|
"src/constants.ts"() {
|
|
572
572
|
"use strict";
|
|
573
573
|
SDK_NAME = "@trustware/sdk";
|
|
574
|
-
SDK_VERSION = "1.1.12-staging.
|
|
574
|
+
SDK_VERSION = "1.1.12-staging.6";
|
|
575
575
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
576
576
|
GTM_ID = "GTM-TZDGNCXB";
|
|
577
577
|
API_PREFIX = "/api";
|
package/package.json
CHANGED