@pollar/core 0.9.0-rc.2 → 0.9.0-rc.3
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/dist/index.d.mts +169 -7
- package/dist/index.d.ts +169 -7
- package/dist/index.js +70 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -7
- package/dist/index.mjs.map +1 -1
- package/dist/index.rn.d.mts +1 -1
- package/dist/index.rn.d.ts +1 -1
- package/dist/index.rn.js +70 -7
- package/dist/index.rn.js.map +1 -1
- package/dist/index.rn.mjs +70 -7
- package/dist/index.rn.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.rn.mjs
CHANGED
|
@@ -1107,7 +1107,7 @@ function defaultStorage(options = {}) {
|
|
|
1107
1107
|
}
|
|
1108
1108
|
|
|
1109
1109
|
// src/version.ts
|
|
1110
|
-
var POLLAR_CORE_VERSION = "0.9.0-rc.
|
|
1110
|
+
var POLLAR_CORE_VERSION = "0.9.0-rc.3" ;
|
|
1111
1111
|
|
|
1112
1112
|
// src/visibility/noop.ts
|
|
1113
1113
|
function createNoopVisibilityProvider() {
|
|
@@ -1828,7 +1828,7 @@ async function loginOAuth(provider, deps) {
|
|
|
1828
1828
|
}
|
|
1829
1829
|
|
|
1830
1830
|
// src/client/auth/passkeyFlow.ts
|
|
1831
|
-
async function
|
|
1831
|
+
async function smartWalletFlow(deps, mode) {
|
|
1832
1832
|
const { api, signal, setAuthState, passkey } = deps;
|
|
1833
1833
|
if (!passkey) {
|
|
1834
1834
|
setAuthState({
|
|
@@ -1851,7 +1851,7 @@ async function loginSmartWallet(deps) {
|
|
|
1851
1851
|
return failPasskey(setAuthState, "Failed to start passkey");
|
|
1852
1852
|
}
|
|
1853
1853
|
setAuthState({ step: "creating_passkey" });
|
|
1854
|
-
const ceremony = await passkey({ challenge });
|
|
1854
|
+
const ceremony = await passkey({ challenge, mode });
|
|
1855
1855
|
const response = ceremony.response;
|
|
1856
1856
|
if (ceremony.kind === "register") {
|
|
1857
1857
|
setAuthState({ step: "deploying_smart_account" });
|
|
@@ -2444,9 +2444,10 @@ var PollarClient = class {
|
|
|
2444
2444
|
loginWallet(type, this._flowDeps(controller.signal)).catch((err) => this._handleFlowError(err));
|
|
2445
2445
|
}
|
|
2446
2446
|
/**
|
|
2447
|
-
* "Smart Wallet" login: runs the passkey (WebAuthn) ceremony
|
|
2448
|
-
* user
|
|
2449
|
-
* ceremony to be configured (e.g. via
|
|
2447
|
+
* "Smart Wallet" login: runs the passkey (WebAuthn) `get()` ceremony for a
|
|
2448
|
+
* returning user and signs them in. Use {@link createSmartWallet} for a new
|
|
2449
|
+
* user. Requires the `passkey` ceremony to be configured (e.g. via
|
|
2450
|
+
* `@pollar/react`).
|
|
2450
2451
|
*/
|
|
2451
2452
|
loginSmartWallet() {
|
|
2452
2453
|
if (!isClientRuntime) {
|
|
@@ -2454,7 +2455,21 @@ var PollarClient = class {
|
|
|
2454
2455
|
return;
|
|
2455
2456
|
}
|
|
2456
2457
|
const controller = this._newController();
|
|
2457
|
-
|
|
2458
|
+
smartWalletFlow(this._flowDeps(controller.signal), "login").catch((err) => this._handleFlowError(err));
|
|
2459
|
+
}
|
|
2460
|
+
/**
|
|
2461
|
+
* "Smart Wallet" registration: runs the passkey (WebAuthn) `create()` ceremony
|
|
2462
|
+
* for a new user and deploys a sponsored smart-account C-address. Use
|
|
2463
|
+
* {@link loginSmartWallet} for a returning user. Requires the `passkey`
|
|
2464
|
+
* ceremony to be configured (e.g. via `@pollar/react`).
|
|
2465
|
+
*/
|
|
2466
|
+
createSmartWallet() {
|
|
2467
|
+
if (!isClientRuntime) {
|
|
2468
|
+
warnServerSide("createSmartWallet");
|
|
2469
|
+
return;
|
|
2470
|
+
}
|
|
2471
|
+
const controller = this._newController();
|
|
2472
|
+
smartWalletFlow(this._flowDeps(controller.signal), "register").catch((err) => this._handleFlowError(err));
|
|
2458
2473
|
}
|
|
2459
2474
|
// ─── Cancel ───────────────────────────────────────────────────────────────
|
|
2460
2475
|
cancelLogin() {
|
|
@@ -2694,6 +2709,54 @@ var PollarClient = class {
|
|
|
2694
2709
|
this._setEnabledAssetsState({ step: "error", message: "Failed to load assets" });
|
|
2695
2710
|
}
|
|
2696
2711
|
}
|
|
2712
|
+
/**
|
|
2713
|
+
* Establishes (omit `limit`) or removes (`limit: '0'`) a trustline for an asset.
|
|
2714
|
+
*
|
|
2715
|
+
* Routing mirrors how the platform pays for the reserve:
|
|
2716
|
+
* - **Sponsored custodial** (`opts.sponsored` true, internal wallet) → the
|
|
2717
|
+
* server orchestrates a sponsored `changeTrust`: the app's wallets cover the
|
|
2718
|
+
* 0.5 XLM reserve and the fee, so the user pays nothing. Pass the asset's
|
|
2719
|
+
* `sponsored` flag (from {@link refreshAssets}) straight through.
|
|
2720
|
+
* - **Self-paid** (external/adapter wallet, sponsorship disabled, or a custom
|
|
2721
|
+
* asset not configured in the app) → a plain `change_trust` transaction the
|
|
2722
|
+
* user's own wallet signs and pays for, via {@link runTx}.
|
|
2723
|
+
*
|
|
2724
|
+
* Does not refresh on its own — callers should `refreshAssets()` afterwards.
|
|
2725
|
+
*/
|
|
2726
|
+
async setTrustline(asset, opts) {
|
|
2727
|
+
const limit = opts?.limit;
|
|
2728
|
+
const walletType = this._session?.wallet?.type;
|
|
2729
|
+
if (!this._session?.wallet?.address) {
|
|
2730
|
+
return { status: "error", details: "No wallet connected" };
|
|
2731
|
+
}
|
|
2732
|
+
if (walletType === "smart") {
|
|
2733
|
+
return { status: "error", details: "Trustlines do not apply to smart wallets" };
|
|
2734
|
+
}
|
|
2735
|
+
if (opts?.sponsored && !this._walletAdapter && walletType === "internal") {
|
|
2736
|
+
try {
|
|
2737
|
+
const { data, error } = await this._api.POST("/wallet/assets/trustline", {
|
|
2738
|
+
body: { code: asset.code, issuer: asset.issuer, ...limit !== void 0 && { limit } }
|
|
2739
|
+
});
|
|
2740
|
+
if (!error && data?.success) {
|
|
2741
|
+
if (data.content) this._setEnabledAssetsState({ step: "loaded", data: data.content });
|
|
2742
|
+
return { status: "success" };
|
|
2743
|
+
}
|
|
2744
|
+
const details = error?.details ?? error?.code;
|
|
2745
|
+
return { status: "error", ...details && { details } };
|
|
2746
|
+
} catch (err) {
|
|
2747
|
+
const details = err instanceof Error ? err.message : void 0;
|
|
2748
|
+
return { status: "error", ...details && { details } };
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
return this.runTx("change_trust", {
|
|
2752
|
+
asset: {
|
|
2753
|
+
type: asset.code.length <= 4 ? "credit_alphanum4" : "credit_alphanum12",
|
|
2754
|
+
code: asset.code,
|
|
2755
|
+
issuer: asset.issuer
|
|
2756
|
+
},
|
|
2757
|
+
...limit !== void 0 && { limit }
|
|
2758
|
+
});
|
|
2759
|
+
}
|
|
2697
2760
|
// ─── Transactions ─────────────────────────────────────────────────────────
|
|
2698
2761
|
/**
|
|
2699
2762
|
* Builds an unsigned XDR. Drives `_setTransactionState` for modal-style UIs
|