@pollar/core 0.4.0 → 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/dist/index.d.mts CHANGED
@@ -234,7 +234,7 @@ interface paths {
234
234
  patch?: never;
235
235
  trace?: never;
236
236
  };
237
- "/tx/submit": {
237
+ "/tx/sign-and-send": {
238
238
  parameters: {
239
239
  query?: never;
240
240
  header?: never;
@@ -247,7 +247,7 @@ interface paths {
247
247
  * Submit signed transaction
248
248
  * @description Submits a signed transaction envelope to the Stellar network.
249
249
  */
250
- post: operations["postTxSubmit"];
250
+ post: operations["postTxSignAndSend"];
251
251
  delete?: never;
252
252
  options?: never;
253
253
  head?: never;
@@ -1084,7 +1084,7 @@ interface operations {
1084
1084
  content: {
1085
1085
  "application/json": {
1086
1086
  /** @enum {string} */
1087
- network: "testnet" | "mainnet";
1087
+ network: "testnet" | "public";
1088
1088
  publicKey: string;
1089
1089
  /** @constant */
1090
1090
  operation: "payment";
@@ -1125,7 +1125,7 @@ interface operations {
1125
1125
  content: {
1126
1126
  "application/json": {
1127
1127
  /** @constant */
1128
- code: "SDK_TX_BUILD";
1128
+ code: "SDK_TX_BUILT";
1129
1129
  /** @constant */
1130
1130
  success: true;
1131
1131
  content: {
@@ -1168,7 +1168,7 @@ interface operations {
1168
1168
  };
1169
1169
  };
1170
1170
  };
1171
- /** @description Horizon error */
1171
+ /** @description Transaction build error */
1172
1172
  502: {
1173
1173
  headers: {
1174
1174
  [name: string]: unknown;
@@ -1183,14 +1183,22 @@ interface operations {
1183
1183
  };
1184
1184
  };
1185
1185
  };
1186
- postTxSubmit: {
1186
+ postTxSignAndSend: {
1187
1187
  parameters: {
1188
1188
  query?: never;
1189
1189
  header?: never;
1190
1190
  path?: never;
1191
1191
  cookie?: never;
1192
1192
  };
1193
- requestBody?: never;
1193
+ requestBody?: {
1194
+ content: {
1195
+ "application/json": {
1196
+ /** @enum {string} */
1197
+ network: "testnet" | "public";
1198
+ signedXdr: string;
1199
+ };
1200
+ };
1201
+ };
1194
1202
  responses: {
1195
1203
  /** @description Submit result (PENDING | SUCCESS | FAILED) */
1196
1204
  200: {
@@ -1244,7 +1252,7 @@ interface operations {
1244
1252
  getTxStatus: {
1245
1253
  parameters: {
1246
1254
  query: {
1247
- network: "testnet" | "mainnet";
1255
+ network: "testnet" | "public";
1248
1256
  hash: string;
1249
1257
  };
1250
1258
  header?: never;
@@ -1316,6 +1324,7 @@ declare const StateStatus: {
1316
1324
  };
1317
1325
  type StateStatus = (typeof StateStatus)[keyof typeof StateStatus];
1318
1326
  declare const PollarStateVar: {
1327
+ readonly NETWORK: "network";
1319
1328
  readonly AUTHENTICATION: "authentication";
1320
1329
  readonly TRANSACTION: "transaction";
1321
1330
  };
@@ -1363,12 +1372,13 @@ declare const STATE_VAR_CODES: {
1363
1372
  readonly BUILD_TRANSACTION_START: "BUILD_TRANSACTION_START";
1364
1373
  readonly BUILD_TRANSACTION_SUCCESS: "BUILD_TRANSACTION_SUCCESS";
1365
1374
  readonly BUILD_TRANSACTION_ERROR: "BUILD_TRANSACTION_ERROR";
1366
- readonly SIGN_TRANSACTION_START: "SIGN_TRANSACTION_START";
1367
- readonly SIGN_TRANSACTION_SUCCESS: "SIGN_TRANSACTION_SUCCESS";
1368
- readonly SIGN_TRANSACTION_ERROR: "SIGN_TRANSACTION_ERROR";
1369
- readonly SEND_TRANSACTION_START: "SEND_TRANSACTION_START";
1370
- readonly SEND_TRANSACTION_SUCCESS: "SEND_TRANSACTION_SUCCESS";
1371
- readonly SEND_TRANSACTION_ERROR: "SEND_TRANSACTION_ERROR";
1375
+ readonly SIGN_SEND_TRANSACTION_START: "SIGN_SEND_TRANSACTION_START";
1376
+ readonly SIGN_SEND_TRANSACTION_SUCCESS: "SIGN_SEND_TRANSACTION_SUCCESS";
1377
+ readonly SIGN_SEND_TRANSACTION_ERROR: "SIGN_SEND_TRANSACTION_ERROR";
1378
+ };
1379
+ readonly network: {
1380
+ readonly NONE: "NONE";
1381
+ readonly NETWORK_UPDATED: "NETWORK_UPDATED";
1372
1382
  };
1373
1383
  };
1374
1384
 
@@ -1433,19 +1443,10 @@ interface PollarClientConfig {
1433
1443
  baseUrl?: string;
1434
1444
  apiKey: string;
1435
1445
  }
1436
- type SubmitTxResult = {
1437
- success: true;
1438
- hash: string;
1439
- status: 'PENDING' | 'SUCCESS' | 'FAILED';
1440
- resultCode?: string;
1441
- message?: string;
1442
- } | {
1443
- success: false;
1444
- error: string;
1445
- };
1446
- type TxBuildResponse = paths['/tx/build']['post']['responses'][200]['content']['application/json'];
1447
1446
  type TxBuildBody = NonNullable<paths['/tx/build']['post']['requestBody']>['content']['application/json'];
1448
- type TxBuildResponseError = paths['/tx/build']['post']['responses'][400 | 401 | 502]['content']['application/json'];
1447
+ type TxBuildResponse = paths['/tx/build']['post']['responses'][200]['content']['application/json'];
1448
+ type TxSignAndSendBody = NonNullable<paths['/tx/sign-and-send']['post']['requestBody']>['content']['application/json'];
1449
+ type TxSignSendResponse = paths['/tx/sign-and-send']['post']['responses'][200]['content']['application/json'];
1449
1450
  type PollarLoginOptions = {
1450
1451
  provider: 'google';
1451
1452
  } | {
@@ -1457,11 +1458,13 @@ type PollarLoginOptions = {
1457
1458
  provider: 'wallet';
1458
1459
  type: WalletType;
1459
1460
  };
1461
+ type NetworkCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.NETWORK];
1462
+ type StateNetworkCodes = NetworkCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.NETWORK]];
1460
1463
  type AuthenticationCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.AUTHENTICATION];
1461
1464
  type StateAuthenticationCodes = AuthenticationCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.AUTHENTICATION]];
1462
1465
  type TransactionCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.TRANSACTION];
1463
1466
  type StateTransactionCodes = TransactionCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.TRANSACTION]];
1464
- type StateVarCodes = StateAuthenticationCodes | StateTransactionCodes;
1467
+ type StateVarCodes = StateNetworkCodes | StateAuthenticationCodes | StateTransactionCodes;
1465
1468
  interface PollarStateEntry {
1466
1469
  var: PollarStateVar;
1467
1470
  code: StateVarCodes;
@@ -1531,8 +1534,9 @@ declare class PollarClient {
1531
1534
  };
1532
1535
  onStateChange(cb: (state: PollarStateEntry) => void): () => void;
1533
1536
  verifyEmailCode(clientSessionId: string, code: string): Promise<void>;
1537
+ getNetwork(): "testnet" | "public";
1534
1538
  buildTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<void>;
1535
- submitTx(signedXdr: string): Promise<SubmitTxResult>;
1539
+ submitTx(signedXdr: string): Promise<void>;
1536
1540
  logout(): void;
1537
1541
  private _readStore;
1538
1542
  private _storeSession;
@@ -1565,4 +1569,4 @@ declare class StellarClient {
1565
1569
  getBalances(publicKey: string): Promise<GetBalancesResult>;
1566
1570
  }
1567
1571
 
1568
- export { AlbedoAdapter, type ConnectWalletResponse, FreighterAdapter, type GetBalancesResult, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, type PollarLoginOptions, type PollarState, type PollarStateEntry, PollarStateVar, STATE_VAR_CODES, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StateAuthenticationCodes, StateStatus, type StateTransactionCodes, type StateVarCodes, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, type SubmitTxResult, type TxBuildBody, type TxBuildResponse, type TxBuildResponseError, type WalletAdapter, WalletType, isValidSession, type paths as pollarPaths };
1572
+ export { AlbedoAdapter, type ConnectWalletResponse, FreighterAdapter, type GetBalancesResult, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, type PollarLoginOptions, type PollarState, type PollarStateEntry, PollarStateVar, STATE_VAR_CODES, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StateAuthenticationCodes, type StateNetworkCodes, StateStatus, type StateTransactionCodes, type StateVarCodes, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, type TxBuildBody, type TxBuildResponse, type TxSignAndSendBody, type TxSignSendResponse, type WalletAdapter, WalletType, isValidSession, type paths as pollarPaths };
package/dist/index.d.ts CHANGED
@@ -234,7 +234,7 @@ interface paths {
234
234
  patch?: never;
235
235
  trace?: never;
236
236
  };
237
- "/tx/submit": {
237
+ "/tx/sign-and-send": {
238
238
  parameters: {
239
239
  query?: never;
240
240
  header?: never;
@@ -247,7 +247,7 @@ interface paths {
247
247
  * Submit signed transaction
248
248
  * @description Submits a signed transaction envelope to the Stellar network.
249
249
  */
250
- post: operations["postTxSubmit"];
250
+ post: operations["postTxSignAndSend"];
251
251
  delete?: never;
252
252
  options?: never;
253
253
  head?: never;
@@ -1084,7 +1084,7 @@ interface operations {
1084
1084
  content: {
1085
1085
  "application/json": {
1086
1086
  /** @enum {string} */
1087
- network: "testnet" | "mainnet";
1087
+ network: "testnet" | "public";
1088
1088
  publicKey: string;
1089
1089
  /** @constant */
1090
1090
  operation: "payment";
@@ -1125,7 +1125,7 @@ interface operations {
1125
1125
  content: {
1126
1126
  "application/json": {
1127
1127
  /** @constant */
1128
- code: "SDK_TX_BUILD";
1128
+ code: "SDK_TX_BUILT";
1129
1129
  /** @constant */
1130
1130
  success: true;
1131
1131
  content: {
@@ -1168,7 +1168,7 @@ interface operations {
1168
1168
  };
1169
1169
  };
1170
1170
  };
1171
- /** @description Horizon error */
1171
+ /** @description Transaction build error */
1172
1172
  502: {
1173
1173
  headers: {
1174
1174
  [name: string]: unknown;
@@ -1183,14 +1183,22 @@ interface operations {
1183
1183
  };
1184
1184
  };
1185
1185
  };
1186
- postTxSubmit: {
1186
+ postTxSignAndSend: {
1187
1187
  parameters: {
1188
1188
  query?: never;
1189
1189
  header?: never;
1190
1190
  path?: never;
1191
1191
  cookie?: never;
1192
1192
  };
1193
- requestBody?: never;
1193
+ requestBody?: {
1194
+ content: {
1195
+ "application/json": {
1196
+ /** @enum {string} */
1197
+ network: "testnet" | "public";
1198
+ signedXdr: string;
1199
+ };
1200
+ };
1201
+ };
1194
1202
  responses: {
1195
1203
  /** @description Submit result (PENDING | SUCCESS | FAILED) */
1196
1204
  200: {
@@ -1244,7 +1252,7 @@ interface operations {
1244
1252
  getTxStatus: {
1245
1253
  parameters: {
1246
1254
  query: {
1247
- network: "testnet" | "mainnet";
1255
+ network: "testnet" | "public";
1248
1256
  hash: string;
1249
1257
  };
1250
1258
  header?: never;
@@ -1316,6 +1324,7 @@ declare const StateStatus: {
1316
1324
  };
1317
1325
  type StateStatus = (typeof StateStatus)[keyof typeof StateStatus];
1318
1326
  declare const PollarStateVar: {
1327
+ readonly NETWORK: "network";
1319
1328
  readonly AUTHENTICATION: "authentication";
1320
1329
  readonly TRANSACTION: "transaction";
1321
1330
  };
@@ -1363,12 +1372,13 @@ declare const STATE_VAR_CODES: {
1363
1372
  readonly BUILD_TRANSACTION_START: "BUILD_TRANSACTION_START";
1364
1373
  readonly BUILD_TRANSACTION_SUCCESS: "BUILD_TRANSACTION_SUCCESS";
1365
1374
  readonly BUILD_TRANSACTION_ERROR: "BUILD_TRANSACTION_ERROR";
1366
- readonly SIGN_TRANSACTION_START: "SIGN_TRANSACTION_START";
1367
- readonly SIGN_TRANSACTION_SUCCESS: "SIGN_TRANSACTION_SUCCESS";
1368
- readonly SIGN_TRANSACTION_ERROR: "SIGN_TRANSACTION_ERROR";
1369
- readonly SEND_TRANSACTION_START: "SEND_TRANSACTION_START";
1370
- readonly SEND_TRANSACTION_SUCCESS: "SEND_TRANSACTION_SUCCESS";
1371
- readonly SEND_TRANSACTION_ERROR: "SEND_TRANSACTION_ERROR";
1375
+ readonly SIGN_SEND_TRANSACTION_START: "SIGN_SEND_TRANSACTION_START";
1376
+ readonly SIGN_SEND_TRANSACTION_SUCCESS: "SIGN_SEND_TRANSACTION_SUCCESS";
1377
+ readonly SIGN_SEND_TRANSACTION_ERROR: "SIGN_SEND_TRANSACTION_ERROR";
1378
+ };
1379
+ readonly network: {
1380
+ readonly NONE: "NONE";
1381
+ readonly NETWORK_UPDATED: "NETWORK_UPDATED";
1372
1382
  };
1373
1383
  };
1374
1384
 
@@ -1433,19 +1443,10 @@ interface PollarClientConfig {
1433
1443
  baseUrl?: string;
1434
1444
  apiKey: string;
1435
1445
  }
1436
- type SubmitTxResult = {
1437
- success: true;
1438
- hash: string;
1439
- status: 'PENDING' | 'SUCCESS' | 'FAILED';
1440
- resultCode?: string;
1441
- message?: string;
1442
- } | {
1443
- success: false;
1444
- error: string;
1445
- };
1446
- type TxBuildResponse = paths['/tx/build']['post']['responses'][200]['content']['application/json'];
1447
1446
  type TxBuildBody = NonNullable<paths['/tx/build']['post']['requestBody']>['content']['application/json'];
1448
- type TxBuildResponseError = paths['/tx/build']['post']['responses'][400 | 401 | 502]['content']['application/json'];
1447
+ type TxBuildResponse = paths['/tx/build']['post']['responses'][200]['content']['application/json'];
1448
+ type TxSignAndSendBody = NonNullable<paths['/tx/sign-and-send']['post']['requestBody']>['content']['application/json'];
1449
+ type TxSignSendResponse = paths['/tx/sign-and-send']['post']['responses'][200]['content']['application/json'];
1449
1450
  type PollarLoginOptions = {
1450
1451
  provider: 'google';
1451
1452
  } | {
@@ -1457,11 +1458,13 @@ type PollarLoginOptions = {
1457
1458
  provider: 'wallet';
1458
1459
  type: WalletType;
1459
1460
  };
1461
+ type NetworkCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.NETWORK];
1462
+ type StateNetworkCodes = NetworkCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.NETWORK]];
1460
1463
  type AuthenticationCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.AUTHENTICATION];
1461
1464
  type StateAuthenticationCodes = AuthenticationCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.AUTHENTICATION]];
1462
1465
  type TransactionCodes = (typeof STATE_VAR_CODES)[typeof PollarStateVar.TRANSACTION];
1463
1466
  type StateTransactionCodes = TransactionCodes[keyof (typeof STATE_VAR_CODES)[typeof PollarStateVar.TRANSACTION]];
1464
- type StateVarCodes = StateAuthenticationCodes | StateTransactionCodes;
1467
+ type StateVarCodes = StateNetworkCodes | StateAuthenticationCodes | StateTransactionCodes;
1465
1468
  interface PollarStateEntry {
1466
1469
  var: PollarStateVar;
1467
1470
  code: StateVarCodes;
@@ -1531,8 +1534,9 @@ declare class PollarClient {
1531
1534
  };
1532
1535
  onStateChange(cb: (state: PollarStateEntry) => void): () => void;
1533
1536
  verifyEmailCode(clientSessionId: string, code: string): Promise<void>;
1537
+ getNetwork(): "testnet" | "public";
1534
1538
  buildTx(operation: TxBuildBody['operation'], params: TxBuildBody['params'], options?: TxBuildBody['options']): Promise<void>;
1535
- submitTx(signedXdr: string): Promise<SubmitTxResult>;
1539
+ submitTx(signedXdr: string): Promise<void>;
1536
1540
  logout(): void;
1537
1541
  private _readStore;
1538
1542
  private _storeSession;
@@ -1565,4 +1569,4 @@ declare class StellarClient {
1565
1569
  getBalances(publicKey: string): Promise<GetBalancesResult>;
1566
1570
  }
1567
1571
 
1568
- export { AlbedoAdapter, type ConnectWalletResponse, FreighterAdapter, type GetBalancesResult, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, type PollarLoginOptions, type PollarState, type PollarStateEntry, PollarStateVar, STATE_VAR_CODES, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StateAuthenticationCodes, StateStatus, type StateTransactionCodes, type StateVarCodes, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, type SubmitTxResult, type TxBuildBody, type TxBuildResponse, type TxBuildResponseError, type WalletAdapter, WalletType, isValidSession, type paths as pollarPaths };
1572
+ export { AlbedoAdapter, type ConnectWalletResponse, FreighterAdapter, type GetBalancesResult, type PollarApiClient, type PollarApplicationConfigContent, type PollarApplicationConfigResponse, PollarClient, type PollarClientConfig, type PollarLoginOptions, type PollarState, type PollarStateEntry, PollarStateVar, STATE_VAR_CODES, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StateAuthenticationCodes, type StateNetworkCodes, StateStatus, type StateTransactionCodes, type StateVarCodes, type StellarBalance, StellarClient, type StellarClientConfig, type StellarNetwork, type TxBuildBody, type TxBuildResponse, type TxSignAndSendBody, type TxSignSendResponse, type WalletAdapter, WalletType, isValidSession, type paths as pollarPaths };
package/dist/index.js CHANGED
@@ -660,6 +660,7 @@ var StateStatus = {
660
660
  ERROR: "ERROR"
661
661
  };
662
662
  var PollarStateVar = {
663
+ NETWORK: "network",
663
664
  AUTHENTICATION: "authentication",
664
665
  TRANSACTION: "transaction"
665
666
  };
@@ -706,12 +707,13 @@ var STATE_VAR_CODES = {
706
707
  BUILD_TRANSACTION_START: "BUILD_TRANSACTION_START",
707
708
  BUILD_TRANSACTION_SUCCESS: "BUILD_TRANSACTION_SUCCESS",
708
709
  BUILD_TRANSACTION_ERROR: "BUILD_TRANSACTION_ERROR",
709
- SIGN_TRANSACTION_START: "SIGN_TRANSACTION_START",
710
- SIGN_TRANSACTION_SUCCESS: "SIGN_TRANSACTION_SUCCESS",
711
- SIGN_TRANSACTION_ERROR: "SIGN_TRANSACTION_ERROR",
712
- SEND_TRANSACTION_START: "SEND_TRANSACTION_START",
713
- SEND_TRANSACTION_SUCCESS: "SEND_TRANSACTION_SUCCESS",
714
- SEND_TRANSACTION_ERROR: "SEND_TRANSACTION_ERROR"
710
+ SIGN_SEND_TRANSACTION_START: "SIGN_SEND_TRANSACTION_START",
711
+ SIGN_SEND_TRANSACTION_SUCCESS: "SIGN_SEND_TRANSACTION_SUCCESS",
712
+ SIGN_SEND_TRANSACTION_ERROR: "SIGN_SEND_TRANSACTION_ERROR"
713
+ },
714
+ network: {
715
+ NONE: "NONE",
716
+ NETWORK_UPDATED: "NETWORK_UPDATED"
715
717
  }
716
718
  };
717
719
 
@@ -1263,6 +1265,7 @@ var PollarClient = class {
1263
1265
  this._session = null;
1264
1266
  this._stateListeners = /* @__PURE__ */ new Set();
1265
1267
  this._state = {
1268
+ network: [],
1266
1269
  authentication: [],
1267
1270
  transaction: []
1268
1271
  };
@@ -1290,6 +1293,9 @@ var PollarClient = class {
1290
1293
  this._readStore();
1291
1294
  }
1292
1295
  });
1296
+ this._emitState("network", STATE_VAR_CODES.network.NETWORK_UPDATED, "info", StateStatus.SUCCESS, {
1297
+ network: "testnet"
1298
+ });
1293
1299
  }
1294
1300
  isAuthenticated() {
1295
1301
  return !!this._session?.wallet?.publicKey;
@@ -1369,13 +1375,16 @@ var PollarClient = class {
1369
1375
  );
1370
1376
  }
1371
1377
  }
1378
+ getNetwork() {
1379
+ return this._state.network.at(-1)?.data?.network === "public" ? "public" : "testnet";
1380
+ }
1372
1381
  async buildTx(operation, params, options) {
1373
1382
  if (!this._session?.wallet?.publicKey) {
1374
1383
  this._emitState("transaction", STATE_VAR_CODES.transaction.BUILD_TRANSACTION_ERROR_NO_WALLET, "error", StateStatus.ERROR);
1375
1384
  return;
1376
1385
  }
1377
1386
  const body = {
1378
- network: "testnet",
1387
+ network: this.getNetwork(),
1379
1388
  publicKey: this._session?.wallet?.publicKey,
1380
1389
  operation,
1381
1390
  params,
@@ -1384,7 +1393,6 @@ var PollarClient = class {
1384
1393
  try {
1385
1394
  this._emitState("transaction", STATE_VAR_CODES.transaction.BUILD_TRANSACTION_START, "info", StateStatus.LOADING);
1386
1395
  const response = await this._api.POST("/tx/build", { body });
1387
- console.log({ response });
1388
1396
  if (!emitResponse(
1389
1397
  PollarStateVar.TRANSACTION,
1390
1398
  response,
@@ -1403,19 +1411,28 @@ var PollarClient = class {
1403
1411
  }
1404
1412
  }
1405
1413
  async submitTx(signedXdr) {
1414
+ const body = {
1415
+ network: this.getNetwork(),
1416
+ signedXdr
1417
+ };
1406
1418
  try {
1407
- console.info("[PollarClient] Submitting signed transaction");
1408
- const { data, error } = await this._api.POST("/tx/submit", { body: { signedXdr } });
1409
- if (error || !data?.success) {
1410
- const msg = error?.message ?? data?.error ?? "Failed to submit transaction";
1411
- console.warn("[PollarClient] submitTx error \u2014", msg);
1412
- return { success: false, error: msg };
1419
+ this._emitState("transaction", STATE_VAR_CODES.transaction.SIGN_SEND_TRANSACTION_START, "info", StateStatus.LOADING);
1420
+ const response = await this._api.POST("/tx/sign-and-send", { body });
1421
+ if (!emitResponse(
1422
+ PollarStateVar.TRANSACTION,
1423
+ response,
1424
+ { code: STATE_VAR_CODES.transaction.SIGN_SEND_TRANSACTION_SUCCESS, status: StateStatus.SUCCESS },
1425
+ STATE_VAR_CODES.transaction.SIGN_SEND_TRANSACTION_ERROR,
1426
+ this._emitState.bind(this)
1427
+ )) {
1428
+ return;
1413
1429
  }
1414
- return { success: true, ...data.content };
1415
- } catch (err) {
1416
- const msg = err instanceof Error ? err.message : "Network error";
1417
- console.warn("[PollarClient] submitTx network error \u2014", msg);
1418
- return { success: false, error: msg };
1430
+ } catch (error) {
1431
+ this._emitState("transaction", STATE_VAR_CODES.transaction.SIGN_SEND_TRANSACTION_ERROR, "error", StateStatus.ERROR, {
1432
+ body,
1433
+ error
1434
+ });
1435
+ return;
1419
1436
  }
1420
1437
  }
1421
1438
  logout() {
@@ -1459,6 +1476,7 @@ var PollarClient = class {
1459
1476
  this._session = null;
1460
1477
  removeStorage();
1461
1478
  this._state = {
1479
+ network: [],
1462
1480
  authentication: [],
1463
1481
  transaction: []
1464
1482
  };