@unicitylabs/sphere-sdk 0.14.9 → 0.14.11-dev.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.
Files changed (35) hide show
  1. package/dist/connect/index.cjs +1 -1
  2. package/dist/connect/index.cjs.map +1 -1
  3. package/dist/connect/index.js +1 -1
  4. package/dist/connect/index.js.map +1 -1
  5. package/dist/core/index.cjs +156 -22
  6. package/dist/core/index.cjs.map +1 -1
  7. package/dist/core/index.d.cts +2 -0
  8. package/dist/core/index.d.ts +2 -0
  9. package/dist/core/index.js +156 -22
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/impl/browser/connect/index.cjs +1 -1
  12. package/dist/impl/browser/connect/index.cjs.map +1 -1
  13. package/dist/impl/browser/connect/index.js +1 -1
  14. package/dist/impl/browser/connect/index.js.map +1 -1
  15. package/dist/impl/wallet-api-v2/index.cjs +4 -0
  16. package/dist/impl/wallet-api-v2/index.cjs.map +1 -1
  17. package/dist/impl/wallet-api-v2/index.js +4 -0
  18. package/dist/impl/wallet-api-v2/index.js.map +1 -1
  19. package/dist/index.cjs +156 -22
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +2 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.js +156 -22
  24. package/dist/index.js.map +1 -1
  25. package/dist/modules/payments-v2/index.cjs +143 -16
  26. package/dist/modules/payments-v2/index.cjs.map +1 -1
  27. package/dist/modules/payments-v2/index.d.cts +6 -2
  28. package/dist/modules/payments-v2/index.d.ts +6 -2
  29. package/dist/modules/payments-v2/index.js +143 -16
  30. package/dist/modules/payments-v2/index.js.map +1 -1
  31. package/dist/token-engine/index.cjs +17 -6
  32. package/dist/token-engine/index.cjs.map +1 -1
  33. package/dist/token-engine/index.js +17 -6
  34. package/dist/token-engine/index.js.map +1 -1
  35. package/package.json +2 -2
@@ -23,6 +23,10 @@ import { StateMask } from "@unicitylabs/state-transition-sdk/lib/transaction/Sta
23
23
  import { MintJustificationVerifierService } from "@unicitylabs/state-transition-sdk/lib/transaction/verification/MintJustificationVerifierService.js";
24
24
  import { TokenIssuanceVerifierService } from "@unicitylabs/state-transition-sdk/lib/transaction/verification/TokenIssuanceVerifierService.js";
25
25
  import { VerificationContext } from "@unicitylabs/state-transition-sdk/lib/transaction/verification/VerificationContext.js";
26
+ import { UnicityCertificateVerifier } from "@unicitylabs/state-transition-sdk/lib/api/bft/verification/UnicityCertificateVerifier.js";
27
+ import { UnicitySealQuorumSignaturesVerificationRule } from "@unicitylabs/state-transition-sdk/lib/api/bft/verification/rule/UnicitySealQuorumSignaturesVerificationRule.js";
28
+ import { VerifiedSealCache } from "@unicitylabs/state-transition-sdk/lib/api/bft/verification/VerifiedSealCache.js";
29
+ import { Secp256k1SignatureVerifier } from "@unicitylabs/state-transition-sdk/lib/crypto/secp256k1/Secp256k1SignatureVerifier.js";
26
30
  import { WorkerTokenVerifier } from "@unicitylabs/state-transition-sdk/lib/transaction/verification/worker/WorkerTokenVerifier.js";
27
31
  import { EncodedPredicate } from "@unicitylabs/state-transition-sdk/lib/predicate/EncodedPredicate.js";
28
32
  import { SignaturePredicate } from "@unicitylabs/state-transition-sdk/lib/predicate/builtin/SignaturePredicate.js";
@@ -354,6 +358,7 @@ async function awaitProofBounded(deps, transaction, signal) {
354
358
  deps.client,
355
359
  deps.trustBase,
356
360
  deps.predicateVerifier,
361
+ deps.unicityCertificateVerifier,
357
362
  transaction,
358
363
  signal,
359
364
  deps.intervalMs
@@ -993,7 +998,7 @@ async function burntTokenFromCheckpoint(deps, storedBytes, reDerivedBurnTx, sour
993
998
  }
994
999
  let burnCertified;
995
1000
  try {
996
- burnCertified = await reDerivedBurnTx.toCertifiedTransaction(deps.trustBase, deps.predicateVerifier, burnProof);
1001
+ burnCertified = await reDerivedBurnTx.toCertifiedTransaction(deps.trustBase, deps.predicateVerifier, deps.unicityCertificateVerifier, burnProof);
997
1002
  } catch (err) {
998
1003
  if (isTrustbaseFailure(err)) {
999
1004
  throw new CheckpointTrustbaseMismatchError(
@@ -1101,7 +1106,7 @@ var SphereTokenEngine = class {
1101
1106
  "AGGREGATOR_ERROR",
1102
1107
  options
1103
1108
  );
1104
- const certified = await mintTx.toCertifiedTransaction(this.deps.trustBase, this.deps.predicateVerifier, proof);
1109
+ const certified = await mintTx.toCertifiedTransaction(this.deps.trustBase, this.deps.predicateVerifier, this.deps.unicityCertificateVerifier, proof);
1105
1110
  const token = await Token.mint(certified, this.deps.verificationContext);
1106
1111
  return this.wrapToken(token);
1107
1112
  }
@@ -1118,7 +1123,7 @@ var SphereTokenEngine = class {
1118
1123
  "AGGREGATOR_ERROR",
1119
1124
  options
1120
1125
  );
1121
- const certified = await mintTx.toCertifiedTransaction(this.deps.trustBase, this.deps.predicateVerifier, proof);
1126
+ const certified = await mintTx.toCertifiedTransaction(this.deps.trustBase, this.deps.predicateVerifier, this.deps.unicityCertificateVerifier, proof);
1122
1127
  const token = await Token.mint(certified, this.deps.verificationContext);
1123
1128
  return this.wrapToken(token);
1124
1129
  }
@@ -1139,7 +1144,7 @@ var SphereTokenEngine = class {
1139
1144
  "TRANSFER_FAILED",
1140
1145
  options
1141
1146
  );
1142
- const certified = await transferTx.toCertifiedTransaction(this.deps.trustBase, this.deps.predicateVerifier, proof);
1147
+ const certified = await transferTx.toCertifiedTransaction(this.deps.trustBase, this.deps.predicateVerifier, this.deps.unicityCertificateVerifier, proof);
1143
1148
  const transferred = await params.token.sdkToken.transfer(certified, this.deps.verificationContext);
1144
1149
  return this.wrapToken(transferred);
1145
1150
  }
@@ -1226,7 +1231,7 @@ var SphereTokenEngine = class {
1226
1231
  const burnUnlock = await SignaturePredicateUnlockScript.create(burnTx, this.deps.signingService);
1227
1232
  const burnCert = await CertificationData.fromTransaction(burnTx, burnUnlock);
1228
1233
  const burnProof = await this.submitAndAwaitProof(burnCert, burnTx, "Split burn failed", "TRANSFER_FAILED", ctx.options);
1229
- const burnCertified = await burnTx.toCertifiedTransaction(this.deps.trustBase, this.deps.predicateVerifier, burnProof);
1234
+ const burnCertified = await burnTx.toCertifiedTransaction(this.deps.trustBase, this.deps.predicateVerifier, this.deps.unicityCertificateVerifier, burnProof);
1230
1235
  const burntToken = await ctx.params.token.sdkToken.transfer(burnCertified, this.deps.verificationContext);
1231
1236
  return { burntToken, burnProof };
1232
1237
  }
@@ -1265,7 +1270,7 @@ var SphereTokenEngine = class {
1265
1270
  );
1266
1271
  const certData = await CertificationData.fromMintTransaction(mintTx);
1267
1272
  const proof = await this.submitSplitMintLeg(certData, mintTx, options);
1268
- const certified = await mintTx.toCertifiedTransaction(this.deps.trustBase, this.deps.predicateVerifier, proof);
1273
+ const certified = await mintTx.toCertifiedTransaction(this.deps.trustBase, this.deps.predicateVerifier, this.deps.unicityCertificateVerifier, proof);
1269
1274
  const token = await Token.mint(certified, this.deps.verificationContext);
1270
1275
  return this.wrapToken(token);
1271
1276
  }
@@ -1408,6 +1413,7 @@ var SphereTokenEngine = class {
1408
1413
  client: this.deps.client,
1409
1414
  trustBase: this.deps.trustBase,
1410
1415
  predicateVerifier: this.deps.predicateVerifier,
1416
+ unicityCertificateVerifier: this.deps.unicityCertificateVerifier,
1411
1417
  intervalMs: this.deps.proofPollIntervalMs ?? DEFAULT_PROOF_POLL_INTERVAL_MS
1412
1418
  // #683
1413
1419
  },
@@ -1499,6 +1505,9 @@ async function createSphereTokenEngine(config) {
1499
1505
  }
1500
1506
  const trustBase = RootTrustBase.fromJSON(config.trustBaseJson);
1501
1507
  const predicateVerifier = PredicateVerifierService.create();
1508
+ const unicityCertificateVerifier = new UnicityCertificateVerifier(
1509
+ new UnicitySealQuorumSignaturesVerificationRule(new Secp256k1SignatureVerifier(), new VerifiedSealCache(256))
1510
+ );
1502
1511
  const mintJustificationVerifier = new MintJustificationVerifierService();
1503
1512
  mintJustificationVerifier.register(
1504
1513
  new SplitMintJustificationVerifier(decodeSpherePaymentData)
@@ -1507,10 +1516,12 @@ async function createSphereTokenEngine(config) {
1507
1516
  client: new StateTransitionClient(new AggregatorClient(config.aggregatorUrl, config.apiKey ?? null)),
1508
1517
  trustBase,
1509
1518
  predicateVerifier,
1519
+ unicityCertificateVerifier,
1510
1520
  mintJustificationVerifier,
1511
1521
  verificationContext: new VerificationContext(
1512
1522
  trustBase,
1513
1523
  predicateVerifier,
1524
+ unicityCertificateVerifier,
1514
1525
  mintJustificationVerifier,
1515
1526
  new TokenIssuanceVerifierService(false)
1516
1527
  ),