@msafe/sui3-sdk 0.0.2 → 0.0.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.js CHANGED
@@ -1135,6 +1135,7 @@ var PseudoBackend = class _PseudoBackend {
1135
1135
  rawData: tx.data,
1136
1136
  txType: tx.txType,
1137
1137
  txSubType: tx.txSubType,
1138
+ processed: tx.processed,
1138
1139
  status: tx.status,
1139
1140
  statusRemark: tx.statusRemark,
1140
1141
  creator: tx.creator,
@@ -1168,9 +1169,10 @@ var PseudoBackend = class _PseudoBackend {
1168
1169
  const intention = {
1169
1170
  msafeAddress: input.msafeAddress,
1170
1171
  sequenceNumber,
1172
+ processed: false,
1171
1173
  ...IntentionHelper.getTxType(input.intention),
1172
1174
  data: IntentionHelper.ser(input.intention),
1173
- status: "future",
1175
+ status: "NEW",
1174
1176
  creator: input.userAddress
1175
1177
  };
1176
1178
  await this.model.transactionIntention.save(intention);
@@ -1217,9 +1219,10 @@ var PseudoBackend = class _PseudoBackend {
1217
1219
  const intention = {
1218
1220
  msafeAddress: input.msafeAddress,
1219
1221
  sequenceNumber,
1222
+ processed: false,
1220
1223
  ...IntentionHelper.getTxType(input.intention),
1221
1224
  data: IntentionHelper.ser(input.intention),
1222
- status: "future",
1225
+ status: "SUCCESS",
1223
1226
  creator: input.userAddress
1224
1227
  };
1225
1228
  await this.model.transactionIntention.save(intention);
@@ -1390,10 +1393,6 @@ var PseudoBackend = class _PseudoBackend {
1390
1393
  async processExecutedTransaction(digest) {
1391
1394
  const historyTx = await this.model.historyTransaction.findOneBy({ digest });
1392
1395
  if (historyTx) {
1393
- const allHistories = await this.model.historyTransaction.findBy({
1394
- msafeAddress: historyTx.msafeAddress
1395
- });
1396
- console.log(allHistories);
1397
1396
  return;
1398
1397
  }
1399
1398
  const pendingTx = await this.model.pendingTransaction.findOneBy({ digest });
@@ -1402,7 +1401,7 @@ var PseudoBackend = class _PseudoBackend {
1402
1401
  }
1403
1402
  await this.model.transactionIntention.update(
1404
1403
  { msafeAddress: pendingTx.msafeAddress, sequenceNumber: pendingTx.sequenceNumber },
1405
- { status: "processed" }
1404
+ { processed: true }
1406
1405
  );
1407
1406
  const pendings = await this.model.pendingTransaction.findBy({
1408
1407
  msafeAddress: pendingTx.msafeAddress,
@@ -1470,6 +1469,15 @@ var PseudoBackend = class _PseudoBackend {
1470
1469
  creator: nextTx.creator
1471
1470
  };
1472
1471
  await this.model.pendingTransaction.save(newPending);
1472
+ await this.model.transactionIntention.update(
1473
+ {
1474
+ msafeAddress: input.msafeAddress,
1475
+ sequenceNumber: nextSequenceNumber
1476
+ },
1477
+ {
1478
+ status: "SUCCESS"
1479
+ }
1480
+ );
1473
1481
  } catch (e) {
1474
1482
  await this.model.transactionIntention.update(
1475
1483
  {
@@ -1477,7 +1485,7 @@ var PseudoBackend = class _PseudoBackend {
1477
1485
  sequenceNumber: nextSequenceNumber
1478
1486
  },
1479
1487
  {
1480
- status: "failed",
1488
+ status: "FAILED",
1481
1489
  statusRemark: e.toString()
1482
1490
  }
1483
1491
  );
@@ -1507,7 +1515,7 @@ var PseudoBackend = class _PseudoBackend {
1507
1515
  if (failedIntention === null) {
1508
1516
  throw new Error("Next intention not found");
1509
1517
  }
1510
- if (failedIntention.status !== "failed") {
1518
+ if (failedIntention.status !== "FAILED") {
1511
1519
  throw new Error("Next intention not failed");
1512
1520
  }
1513
1521
  const history = {
@@ -1521,6 +1529,10 @@ var PseudoBackend = class _PseudoBackend {
1521
1529
  status: "build-failed"
1522
1530
  };
1523
1531
  await this.model.historyTransaction.save(history);
1532
+ await this.model.transactionIntention.update(
1533
+ { msafeAddress: input.msafeAddress, sequenceNumber: nextSequenceNumber },
1534
+ { processed: true }
1535
+ );
1524
1536
  }
1525
1537
  async getUser(address) {
1526
1538
  return this.model.user.findOneBy({ address });
@@ -1539,6 +1551,11 @@ var MSafeEnv = /* @__PURE__ */ ((MSafeEnv3) => {
1539
1551
  MSafeEnv3["prod"] = "prod";
1540
1552
  return MSafeEnv3;
1541
1553
  })(MSafeEnv || {});
1554
+ var UNIT_DATABASE_CONFIG = {
1555
+ type: "sqlite",
1556
+ database: ":memory:",
1557
+ logging: false
1558
+ };
1542
1559
  var LOCAL_DATABASE_CONFIG = {
1543
1560
  type: "mysql",
1544
1561
  host: "127.0.0.1",
@@ -1566,7 +1583,7 @@ var ENV_CONFIGS = /* @__PURE__ */ new Map([
1566
1583
  suiClient: {
1567
1584
  url: TESTNET_RPC_URL
1568
1585
  },
1569
- backend: LOCAL_DATABASE_CONFIG
1586
+ backend: UNIT_DATABASE_CONFIG
1570
1587
  }
1571
1588
  ],
1572
1589
  [
@@ -1738,6 +1755,7 @@ export {
1738
1755
  SUI_COIN,
1739
1756
  SignatureVerifier,
1740
1757
  TESTNET_RPC_URL,
1758
+ UNIT_DATABASE_CONFIG,
1741
1759
  Uint8ArrayToHex,
1742
1760
  getAllCoins,
1743
1761
  getMSafeConfig,