@stellar/stellar-sdk 16.0.0-rc.1 → 16.0.0

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 (128) hide show
  1. package/README.md +22 -28
  2. package/dist/stellar-sdk-axios.js +245 -232
  3. package/dist/stellar-sdk-axios.js.map +1 -1
  4. package/dist/stellar-sdk-axios.min.js +1 -1
  5. package/dist/stellar-sdk-axios.min.js.map +1 -1
  6. package/dist/stellar-sdk.js +49 -36
  7. package/dist/stellar-sdk.js.map +1 -1
  8. package/dist/stellar-sdk.min.js +2 -2
  9. package/dist/stellar-sdk.min.js.map +1 -1
  10. package/lib/axios/cjs/base/auth.js +11 -11
  11. package/lib/axios/cjs/base/auth.js.map +1 -1
  12. package/lib/axios/cjs/base/keypair.js +1 -1
  13. package/lib/axios/cjs/base/keypair.js.map +1 -1
  14. package/lib/axios/cjs/base/transaction_builder.js +13 -1
  15. package/lib/axios/cjs/base/transaction_builder.js.map +1 -1
  16. package/lib/axios/cjs/bindings/config.js +1 -1
  17. package/lib/axios/cjs/bindings/config.js.map +1 -1
  18. package/lib/axios/cjs/bindings/wasm_fetcher.js +1 -1
  19. package/lib/axios/cjs/bindings/wasm_fetcher.js.map +1 -1
  20. package/lib/axios/cjs/contract/client.js.map +1 -1
  21. package/lib/axios/cjs/contract/spec.js.map +1 -1
  22. package/lib/axios/cjs/contract/types.js.map +1 -1
  23. package/lib/axios/cjs/contract/utils.js.map +1 -1
  24. package/lib/axios/cjs/contract/wasm_spec_parser.js +1 -1
  25. package/lib/axios/cjs/contract/wasm_spec_parser.js.map +1 -1
  26. package/lib/axios/cjs/horizon/call_builder.js.map +1 -1
  27. package/lib/axios/cjs/horizon/horizon_api.js.map +1 -1
  28. package/lib/axios/cjs/horizon/horizon_axios_client.js +1 -1
  29. package/lib/axios/cjs/horizon/horizon_axios_client.js.map +1 -1
  30. package/lib/axios/cjs/http-client/fetch-client.js +1 -1
  31. package/lib/axios/cjs/http-client/fetch-client.js.map +1 -1
  32. package/lib/axios/cjs/http-client/types.js.map +1 -1
  33. package/lib/axios/cjs/rpc/axios.js +1 -1
  34. package/lib/axios/cjs/rpc/axios.js.map +1 -1
  35. package/lib/axios/cjs/rpc/jsonrpc.js.map +1 -1
  36. package/lib/axios/cjs/rpc/server.js +2 -2
  37. package/lib/axios/cjs/rpc/server.js.map +1 -1
  38. package/lib/axios/cjs/webauth/challenge_transaction.js.map +1 -1
  39. package/lib/axios/esm/base/auth.d.ts +19 -7
  40. package/lib/axios/esm/base/auth.js +11 -11
  41. package/lib/axios/esm/base/auth.js.map +1 -1
  42. package/lib/axios/esm/base/keypair.js +1 -1
  43. package/lib/axios/esm/base/keypair.js.map +1 -1
  44. package/lib/axios/esm/base/transaction_builder.js +13 -1
  45. package/lib/axios/esm/base/transaction_builder.js.map +1 -1
  46. package/lib/axios/esm/bindings/config.js +1 -1
  47. package/lib/axios/esm/bindings/config.js.map +1 -1
  48. package/lib/axios/esm/bindings/wasm_fetcher.js +1 -1
  49. package/lib/axios/esm/bindings/wasm_fetcher.js.map +1 -1
  50. package/lib/axios/esm/contract/client.js.map +1 -1
  51. package/lib/axios/esm/contract/spec.js.map +1 -1
  52. package/lib/axios/esm/contract/types.js.map +1 -1
  53. package/lib/axios/esm/contract/utils.js.map +1 -1
  54. package/lib/axios/esm/contract/wasm_spec_parser.js +1 -1
  55. package/lib/axios/esm/contract/wasm_spec_parser.js.map +1 -1
  56. package/lib/axios/esm/horizon/call_builder.js.map +1 -1
  57. package/lib/axios/esm/horizon/horizon_api.js.map +1 -1
  58. package/lib/axios/esm/horizon/horizon_axios_client.js +1 -1
  59. package/lib/axios/esm/horizon/horizon_axios_client.js.map +1 -1
  60. package/lib/axios/esm/http-client/fetch-client.js +1 -1
  61. package/lib/axios/esm/http-client/fetch-client.js.map +1 -1
  62. package/lib/axios/esm/http-client/types.js.map +1 -1
  63. package/lib/axios/esm/rpc/axios.js +1 -1
  64. package/lib/axios/esm/rpc/axios.js.map +1 -1
  65. package/lib/axios/esm/rpc/jsonrpc.js.map +1 -1
  66. package/lib/axios/esm/rpc/server.js +2 -2
  67. package/lib/axios/esm/rpc/server.js.map +1 -1
  68. package/lib/axios/esm/webauth/challenge_transaction.js.map +1 -1
  69. package/lib/cjs/base/auth.js +11 -11
  70. package/lib/cjs/base/auth.js.map +1 -1
  71. package/lib/cjs/base/keypair.js +1 -1
  72. package/lib/cjs/base/keypair.js.map +1 -1
  73. package/lib/cjs/base/transaction_builder.js +13 -1
  74. package/lib/cjs/base/transaction_builder.js.map +1 -1
  75. package/lib/cjs/bindings/config.js +1 -1
  76. package/lib/cjs/bindings/config.js.map +1 -1
  77. package/lib/cjs/bindings/wasm_fetcher.js +1 -1
  78. package/lib/cjs/bindings/wasm_fetcher.js.map +1 -1
  79. package/lib/cjs/contract/client.js.map +1 -1
  80. package/lib/cjs/contract/spec.js.map +1 -1
  81. package/lib/cjs/contract/types.js.map +1 -1
  82. package/lib/cjs/contract/utils.js.map +1 -1
  83. package/lib/cjs/contract/wasm_spec_parser.js +1 -1
  84. package/lib/cjs/contract/wasm_spec_parser.js.map +1 -1
  85. package/lib/cjs/horizon/call_builder.js.map +1 -1
  86. package/lib/cjs/horizon/horizon_api.js.map +1 -1
  87. package/lib/cjs/horizon/horizon_axios_client.js +1 -1
  88. package/lib/cjs/horizon/horizon_axios_client.js.map +1 -1
  89. package/lib/cjs/http-client/fetch-client.js +1 -1
  90. package/lib/cjs/http-client/fetch-client.js.map +1 -1
  91. package/lib/cjs/http-client/types.js.map +1 -1
  92. package/lib/cjs/rpc/axios.js +1 -1
  93. package/lib/cjs/rpc/axios.js.map +1 -1
  94. package/lib/cjs/rpc/jsonrpc.js.map +1 -1
  95. package/lib/cjs/rpc/server.js +2 -2
  96. package/lib/cjs/rpc/server.js.map +1 -1
  97. package/lib/cjs/webauth/challenge_transaction.js.map +1 -1
  98. package/lib/esm/base/auth.d.ts +19 -7
  99. package/lib/esm/base/auth.js +11 -11
  100. package/lib/esm/base/auth.js.map +1 -1
  101. package/lib/esm/base/keypair.js +1 -1
  102. package/lib/esm/base/keypair.js.map +1 -1
  103. package/lib/esm/base/transaction_builder.js +13 -1
  104. package/lib/esm/base/transaction_builder.js.map +1 -1
  105. package/lib/esm/bindings/config.js +1 -1
  106. package/lib/esm/bindings/config.js.map +1 -1
  107. package/lib/esm/bindings/wasm_fetcher.js +1 -1
  108. package/lib/esm/bindings/wasm_fetcher.js.map +1 -1
  109. package/lib/esm/contract/client.js.map +1 -1
  110. package/lib/esm/contract/spec.js.map +1 -1
  111. package/lib/esm/contract/types.js.map +1 -1
  112. package/lib/esm/contract/utils.js.map +1 -1
  113. package/lib/esm/contract/wasm_spec_parser.js +1 -1
  114. package/lib/esm/contract/wasm_spec_parser.js.map +1 -1
  115. package/lib/esm/horizon/call_builder.js.map +1 -1
  116. package/lib/esm/horizon/horizon_api.js.map +1 -1
  117. package/lib/esm/horizon/horizon_axios_client.js +1 -1
  118. package/lib/esm/horizon/horizon_axios_client.js.map +1 -1
  119. package/lib/esm/http-client/fetch-client.js +1 -1
  120. package/lib/esm/http-client/fetch-client.js.map +1 -1
  121. package/lib/esm/http-client/types.js.map +1 -1
  122. package/lib/esm/rpc/axios.js +1 -1
  123. package/lib/esm/rpc/axios.js.map +1 -1
  124. package/lib/esm/rpc/jsonrpc.js.map +1 -1
  125. package/lib/esm/rpc/server.js +2 -2
  126. package/lib/esm/rpc/server.js.map +1 -1
  127. package/lib/esm/webauth/challenge_transaction.js.map +1 -1
  128. package/package.json +2 -5
@@ -687,7 +687,7 @@
687
687
  reject(makeCanceledError(cancelToken.reason));
688
688
  });
689
689
  }
690
- let modifiedConfig = config;
690
+ const modifiedConfig = config;
691
691
  if (requestInterceptors.handlers.length > 0) {
692
692
  const chain = requestInterceptors.handlers.filter(
693
693
  (interceptor) => interceptor !== null
@@ -9279,6 +9279,9 @@
9279
9279
  // Reduce any little-endian byte string modulo the subgroup order; the `hash` name reflects the
9280
9280
  // common caller shape, not an input restriction.
9281
9281
  const modL_LE = (hash) => modN(bytesToNumberLE(hash)); // modulo L; but little-endian
9282
+ // Both sync and async SHA-512 slots are exported/configurable; use `callHash(...)` for both so
9283
+ // missing async overrides fail explicitly, then validate the returned digest type/length.
9284
+ const sha512a = (...m) => Promise.resolve(callHash('sha512Async')(concatBytes(...m))).then(checkDigest);
9282
9285
  const sha512s = (...m) => checkDigest(callHash('sha512')(concatBytes(...m)));
9283
9286
  // RFC8032 5.1.5. Split the 64-byte hashed seed into the clamped scalar half and nonce prefix.
9284
9287
  const hash2extK = (hashed) => {
@@ -9296,6 +9299,8 @@
9296
9299
  const pointBytes = point.toBytes(); // point serialized to Uint8Array
9297
9300
  return { head, prefix, scalar, point, pointBytes };
9298
9301
  };
9302
+ // RFC8032 5.1.5; getPublicKey async, sync. Hash priv key and extract point.
9303
+ const getExtendedPublicKeyAsync = (secretKey) => sha512a(abytes(secretKey, L)).then(hash2extK);
9299
9304
  const getExtendedPublicKey = (secretKey) => hash2extK(sha512s(abytes(secretKey, L)));
9300
9305
  /**
9301
9306
  * Creates a 32-byte Ed25519 public key from the RFC 8032 32-byte secret-key seed.
@@ -9467,28 +9472,24 @@
9467
9472
  return abytes(seed, L);
9468
9473
  };
9469
9474
  /**
9470
- * Generates a secret/public keypair.
9471
- * @param seed - Optional 32-byte Ed25519 secret-key seed, returned verbatim as `secretKey`.
9472
- * @returns Keypair with `secretKey` and `publicKey`.
9473
- * @throws If synchronous SHA-512 has not been configured in `hashes`. {@link Error}
9474
- * @throws On wrong argument types. {@link TypeError}
9475
- * @throws On wrong argument ranges or values. {@link RangeError}
9475
+ * Ed25519-specific key utilities.
9476
+ * `utils.getExtendedPublicKey*` expose secret-derived internals (`head`, `prefix`, `scalar`, and
9477
+ * point objects), not just public-key bytes.
9476
9478
  * @example
9477
- * Generate a new keypair through the synchronous API after wiring SHA-512.
9479
+ * Generate a new Ed25519 secret key and derive the matching public key.
9478
9480
  *
9479
9481
  * ```ts
9480
9482
  * import * as ed from '@noble/ed25519';
9481
- * import { sha512 } from '@noble/hashes/sha2.js';
9482
9483
  *
9483
- * ed.hashes.sha512 = sha512;
9484
- * const { secretKey, publicKey } = ed.keygen();
9484
+ * const secretKey = ed.utils.randomSecretKey();
9485
+ * const publicKey = await ed.getPublicKeyAsync(secretKey);
9485
9486
  * ```
9486
9487
  */
9487
- const keygen = (seed) => {
9488
- const secretKey = randomSecretKey(seed);
9489
- const publicKey = getPublicKey(secretKey);
9490
- return { secretKey, publicKey };
9491
- };
9488
+ const utils = /* @__PURE__ */ Object.freeze({
9489
+ getExtendedPublicKeyAsync: getExtendedPublicKeyAsync,
9490
+ getExtendedPublicKey: getExtendedPublicKey,
9491
+ randomSecretKey: randomSecretKey,
9492
+ });
9492
9493
  // ## Precomputes
9493
9494
  // --------------
9494
9495
  const W = 8; // W is window size
@@ -10666,7 +10667,7 @@
10666
10667
  * Create a random `Keypair` object.
10667
10668
  */
10668
10669
  static random() {
10669
- const { secretKey } = keygen();
10670
+ const secretKey = utils.randomSecretKey();
10670
10671
  return this.fromRawEd25519Seed(bufferExports.Buffer.from(secretKey));
10671
10672
  }
10672
10673
  /** Returns this public key as an xdr.AccountId. */
@@ -18360,7 +18361,19 @@
18360
18361
  "cannot clone a transaction with no operations: per-operation base fee cannot be determined"
18361
18362
  );
18362
18363
  }
18363
- const unscaledFee = Math.floor(parseInt(tx.fee, 10) / tx.operations.length);
18364
+ let sorobanData;
18365
+ const envelope = tx.toEnvelope();
18366
+ if (envelope.switch() === types.EnvelopeType.envelopeTypeTx()) {
18367
+ sorobanData = envelope.v1().tx().ext().value() ?? void 0;
18368
+ }
18369
+ let totalFee = parseInt(tx.fee, 10);
18370
+ if (sorobanData) {
18371
+ const resourceFee = Number(sorobanData.resourceFee().toBigInt());
18372
+ if (totalFee - resourceFee > 0) {
18373
+ totalFee -= resourceFee;
18374
+ }
18375
+ }
18376
+ const unscaledFee = Math.floor(totalFee / tx.operations.length);
18364
18377
  const builderOpts = {
18365
18378
  fee: (unscaledFee || BASE_FEE).toString(),
18366
18379
  memo: tx.memo,
@@ -19282,7 +19295,8 @@
19282
19295
  validUntilLedgerSeq,
19283
19296
  invocation,
19284
19297
  networkPassphrase,
19285
- publicKey = ""
19298
+ publicKey = "",
19299
+ authV2 = false
19286
19300
  } = params;
19287
19301
  const kp = Keypair.random().rawPublicKey();
19288
19302
  const nonce = new types.Int64(bytesToInt64(kp));
@@ -19290,18 +19304,17 @@
19290
19304
  if (!pk) {
19291
19305
  throw new Error(`authorizeInvocation requires publicKey parameter`);
19292
19306
  }
19307
+ const addressCredentials = new types.SorobanAddressCredentials({
19308
+ address: new Address(pk).toScAddress(),
19309
+ nonce,
19310
+ signatureExpirationLedger: 0,
19311
+ // replaced
19312
+ signature: types.ScVal.scvVec([])
19313
+ // replaced
19314
+ });
19293
19315
  const entry = new types.SorobanAuthorizationEntry({
19294
19316
  rootInvocation: invocation,
19295
- credentials: types.SorobanCredentials.sorobanCredentialsAddressV2(
19296
- new types.SorobanAddressCredentials({
19297
- address: new Address(pk).toScAddress(),
19298
- nonce,
19299
- signatureExpirationLedger: 0,
19300
- // replaced
19301
- signature: types.ScVal.scvVec([])
19302
- // replaced
19303
- })
19304
- )
19317
+ credentials: authV2 ? types.SorobanCredentials.sorobanCredentialsAddressV2(addressCredentials) : types.SorobanCredentials.sorobanCredentialsAddress(addressCredentials)
19305
19318
  });
19306
19319
  return authorizeEntry(entry, signer, validUntilLedgerSeq, networkPassphrase);
19307
19320
  }
@@ -20876,7 +20889,7 @@ ${value}`, dataLines++;
20876
20889
  return doc && typeof doc == "object" && "baseURI" in doc && typeof doc.baseURI == "string" ? doc.baseURI : void 0;
20877
20890
  }
20878
20891
 
20879
- const version$1 = "16.0.0-rc.1";
20892
+ const version$1 = "16.0.0";
20880
20893
  const SERVER_TIME_MAP = {};
20881
20894
  function toSeconds(ms) {
20882
20895
  return Math.floor(ms / 1e3);
@@ -22803,7 +22816,7 @@ ${value}`, dataLines++;
22803
22816
  Api2.isSimulationRaw = isSimulationRaw;
22804
22817
  })(Api || (Api = {}));
22805
22818
 
22806
- const version = "16.0.0-rc.1";
22819
+ const version = "16.0.0";
22807
22820
  function createHttpClient(headers) {
22808
22821
  return createFetchClient({
22809
22822
  headers: {
@@ -23293,8 +23306,8 @@ ${value}`, dataLines++;
23293
23306
  async getClaimableBalance(id) {
23294
23307
  let balanceId;
23295
23308
  if (StrKey.isValidClaimableBalance(id)) {
23296
- let buffer = StrKey.decodeClaimableBalance(id);
23297
- let v = bufferExports.Buffer.concat([
23309
+ const buffer = StrKey.decodeClaimableBalance(id);
23310
+ const v = bufferExports.Buffer.concat([
23298
23311
  bufferExports.Buffer.from("\0\0\0"),
23299
23312
  buffer.subarray(0, 1)
23300
23313
  ]);
@@ -25381,7 +25394,7 @@ ${JSON.stringify(sentTransaction)}`
25381
25394
 
25382
25395
  function specFromWasm(wasm) {
25383
25396
  const customData = parseWasmCustomSections(wasm);
25384
- let xdrSections = customData.get("contractspecv0");
25397
+ const xdrSections = customData.get("contractspecv0");
25385
25398
  if (!xdrSections || xdrSections.length === 0) {
25386
25399
  throw new Error("Could not obtain contract spec from wasm");
25387
25400
  }
@@ -26953,7 +26966,7 @@ ${indent} */
26953
26966
  build: "tsc"
26954
26967
  },
26955
26968
  dependencies: {
26956
- "@stellar/stellar-sdk": `^${"16.0.0-rc.1"}`,
26969
+ "@stellar/stellar-sdk": `^${"16.0.0"}`,
26957
26970
  buffer: "6.0.3"
26958
26971
  },
26959
26972
  devDependencies: {
@@ -27429,7 +27442,7 @@ export class Client extends ContractClient {
27429
27442
  return { type: "stellar-asset-contract" };
27430
27443
  }
27431
27444
  const wasmHash = instance.executable().wasmHash();
27432
- let wasmBytes = await getRemoteWasmFromHash(server, wasmHash);
27445
+ const wasmBytes = await getRemoteWasmFromHash(server, wasmHash);
27433
27446
  return { type: "wasm", wasmBytes };
27434
27447
  } catch (error) {
27435
27448
  if (error instanceof WasmFetchError) {