@piprail/sdk 2.7.0 → 2.8.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.
package/dist/index.d.cts CHANGED
@@ -4741,6 +4741,8 @@ declare function getDirectoryInfo(source: DiscoverySource): DirectoryInfo;
4741
4741
  declare function decorateOutcome(o: RegisterOutcome): RegisterOutcome;
4742
4742
  /** Normalize an index's network field to CAIP-2 when we recognise the slug;
4743
4743
  * pass a value that's already CAIP-2 (`namespace:reference`) through unchanged.
4744
+ * A legacy/superseded CAIP-2 id is mapped to its canonical replacement first
4745
+ * (so a colon-bearing legacy id like `ton:-239` still canonicalizes).
4744
4746
  * An unknown slug returns unchanged (no `:`), which the client treats as
4745
4747
  * "unresolved — don't hide it" rather than a confident mismatch. */
4746
4748
  declare function normalizeNetwork(network: string): string;
package/dist/index.d.ts CHANGED
@@ -4741,6 +4741,8 @@ declare function getDirectoryInfo(source: DiscoverySource): DirectoryInfo;
4741
4741
  declare function decorateOutcome(o: RegisterOutcome): RegisterOutcome;
4742
4742
  /** Normalize an index's network field to CAIP-2 when we recognise the slug;
4743
4743
  * pass a value that's already CAIP-2 (`namespace:reference`) through unchanged.
4744
+ * A legacy/superseded CAIP-2 id is mapped to its canonical replacement first
4745
+ * (so a colon-bearing legacy id like `ton:-239` still canonicalizes).
4744
4746
  * An unknown slug returns unchanged (no `:`), which the client treats as
4745
4747
  * "unresolved — don't hide it" rather than a confident mismatch. */
4746
4748
  declare function normalizeNetwork(network: string): string;
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  parseUnits,
25
25
  rejectForeignToken,
26
26
  toInsufficientFundsError
27
- } from "./chunk-7XK22JSQ.js";
27
+ } from "./chunk-W3HOMXOF.js";
28
28
 
29
29
  // src/drivers/registry.ts
30
30
  var byFamily = /* @__PURE__ */ new Map();
@@ -1840,7 +1840,7 @@ var loaders = {
1840
1840
  solana: async () => {
1841
1841
  let mod;
1842
1842
  try {
1843
- mod = await import("./solana-3FMCWSEE.js");
1843
+ mod = await import("./solana-Z34OWXMO.js");
1844
1844
  } catch (cause) {
1845
1845
  throw new MissingDriverError(
1846
1846
  `Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
@@ -1852,7 +1852,7 @@ var loaders = {
1852
1852
  ton: async () => {
1853
1853
  let mod;
1854
1854
  try {
1855
- mod = await import("./ton-5ZPT5PSP.js");
1855
+ mod = await import("./ton-N7KSPSAR.js");
1856
1856
  } catch (cause) {
1857
1857
  throw new MissingDriverError(
1858
1858
  `TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
@@ -1864,7 +1864,7 @@ var loaders = {
1864
1864
  stellar: async () => {
1865
1865
  let mod;
1866
1866
  try {
1867
- mod = await import("./stellar-U5NCRIOJ.js");
1867
+ mod = await import("./stellar-PWC4LETJ.js");
1868
1868
  } catch (cause) {
1869
1869
  throw new MissingDriverError(
1870
1870
  `Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
@@ -1876,7 +1876,7 @@ var loaders = {
1876
1876
  xrpl: async () => {
1877
1877
  let mod;
1878
1878
  try {
1879
- mod = await import("./xrpl-2MZEOIFY.js");
1879
+ mod = await import("./xrpl-6B4IYRWI.js");
1880
1880
  } catch (cause) {
1881
1881
  throw new MissingDriverError(
1882
1882
  `XRPL selected, but its package isn't installed. Run: npm install xrpl`,
@@ -1888,7 +1888,7 @@ var loaders = {
1888
1888
  tron: async () => {
1889
1889
  let mod;
1890
1890
  try {
1891
- mod = await import("./tron-WYS4X2I5.js");
1891
+ mod = await import("./tron-WKDUQVZR.js");
1892
1892
  } catch (cause) {
1893
1893
  throw new MissingDriverError(
1894
1894
  `Tron selected, but its package isn't installed. Run: npm install tronweb`,
@@ -1900,7 +1900,7 @@ var loaders = {
1900
1900
  sui: async () => {
1901
1901
  let mod;
1902
1902
  try {
1903
- mod = await import("./sui-Y53M4GUM.js");
1903
+ mod = await import("./sui-VEOGHBYE.js");
1904
1904
  } catch (cause) {
1905
1905
  throw new MissingDriverError(
1906
1906
  `Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
@@ -1912,7 +1912,7 @@ var loaders = {
1912
1912
  near: async () => {
1913
1913
  let mod;
1914
1914
  try {
1915
- mod = await import("./near-OTPQD6BI.js");
1915
+ mod = await import("./near-QV4IOZNX.js");
1916
1916
  } catch (cause) {
1917
1917
  throw new MissingDriverError(
1918
1918
  `NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
@@ -1924,7 +1924,7 @@ var loaders = {
1924
1924
  aptos: async () => {
1925
1925
  let mod;
1926
1926
  try {
1927
- mod = await import("./aptos-QAAXIUY3.js");
1927
+ mod = await import("./aptos-WMPFEASY.js");
1928
1928
  } catch (cause) {
1929
1929
  throw new MissingDriverError(
1930
1930
  `Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
@@ -1936,7 +1936,7 @@ var loaders = {
1936
1936
  algorand: async () => {
1937
1937
  let mod;
1938
1938
  try {
1939
- mod = await import("./algorand-WB6PBJU4.js");
1939
+ mod = await import("./algorand-WJL6VRXW.js");
1940
1940
  } catch (cause) {
1941
1941
  throw new MissingDriverError(
1942
1942
  `Algorand selected, but its package isn't installed. Run: npm install algosdk`,
@@ -2027,7 +2027,7 @@ var SLUG_TO_CAIP2 = {
2027
2027
  bsc: "eip155:56",
2028
2028
  // non-EVM families — values mirror each driver's bound caip2 exactly
2029
2029
  solana: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
2030
- ton: "ton:-239",
2030
+ ton: "tvm:-239",
2031
2031
  tron: "tron:mainnet",
2032
2032
  near: "near:mainnet",
2033
2033
  sui: "sui:mainnet",
@@ -2036,7 +2036,12 @@ var SLUG_TO_CAIP2 = {
2036
2036
  stellar: "stellar:pubnet",
2037
2037
  xrpl: "xrpl:0"
2038
2038
  };
2039
+ var LEGACY_CAIP2_ALIAS = {
2040
+ "ton:-239": "tvm:-239"
2041
+ };
2039
2042
  function normalizeNetwork(network) {
2043
+ const legacy = LEGACY_CAIP2_ALIAS[network];
2044
+ if (legacy) return legacy;
2040
2045
  if (network.includes(":")) return network;
2041
2046
  return SLUG_TO_CAIP2[network.toLowerCase()] ?? network;
2042
2047
  }
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkJG6KRAW6cjs = require('./chunk-JG6KRAW6.cjs');
13
+ var _chunkVPENSVOIcjs = require('./chunk-VPENSVOI.cjs');
14
14
 
15
15
  // src/drivers/near/index.ts
16
16
  var _nearapijs = require('near-api-js');
@@ -61,18 +61,18 @@ async function payNear(params) {
61
61
  return res.hash;
62
62
  } catch (err) {
63
63
  if (isNearRegistrationError(err)) {
64
- throw new (0, _chunkJG6KRAW6cjs.RecipientNotReadyError)(
64
+ throw new (0, _chunkVPENSVOIcjs.RecipientNotReadyError)(
65
65
  `NEAR recipient ${accept.payTo} isn't registered on token ${accept.asset} (NEP-145 storage_deposit) \u2014 register it once (\u22480.00125 NEAR) before it can receive. (NEAR: not registered)`,
66
66
  { cause: err }
67
67
  );
68
68
  }
69
69
  if (isNearAffordability(err)) {
70
- throw new (0, _chunkJG6KRAW6cjs.InsufficientFundsError)(
70
+ throw new (0, _chunkVPENSVOIcjs.InsufficientFundsError)(
71
71
  err instanceof Error ? err.message : "Insufficient NEAR balance for the payment.",
72
72
  { cause: err }
73
73
  );
74
74
  }
75
- throw _nullishCoalesce(_chunkJG6KRAW6cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
75
+ throw _nullishCoalesce(_chunkVPENSVOIcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
76
76
  }
77
77
  }
78
78
  async function payNearNative(params) {
@@ -82,12 +82,12 @@ async function payNearNative(params) {
82
82
  return res.hash;
83
83
  } catch (err) {
84
84
  if (isNearAffordability(err)) {
85
- throw new (0, _chunkJG6KRAW6cjs.InsufficientFundsError)(
85
+ throw new (0, _chunkVPENSVOIcjs.InsufficientFundsError)(
86
86
  err instanceof Error ? err.message : "Insufficient NEAR balance for the payment.",
87
87
  { cause: err }
88
88
  );
89
89
  }
90
- throw _nullishCoalesce(_chunkJG6KRAW6cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
90
+ throw _nullishCoalesce(_chunkVPENSVOIcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
91
91
  }
92
92
  }
93
93
  function isNearRegistrationError(err) {
@@ -109,28 +109,28 @@ var NONCE_BLOCK_MULTIPLIER = 1000000n;
109
109
  async function payExactNear(input) {
110
110
  const { signer, senderId, blockHeight, accessKeyNonce, accept } = input;
111
111
  if (accept.asset === "native") {
112
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
112
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
113
113
  "NEAR exact is NEP-141-only (an ft_transfer); native NEAR is not exact-payable. Pay via onchain-proof."
114
114
  );
115
115
  }
116
116
  if (!isValidNearAccountId(accept.asset)) {
117
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(`NEAR exact: asset "${accept.asset}" must be a NEP-141 contract account id.`);
117
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(`NEAR exact: asset "${accept.asset}" must be a NEP-141 contract account id.`);
118
118
  }
119
119
  if (!isValidNearAccountId(accept.payTo)) {
120
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(`NEAR exact: payTo "${accept.payTo}" is not a valid NEAR account id.`);
120
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(`NEAR exact: payTo "${accept.payTo}" is not a valid NEAR account id.`);
121
121
  }
122
122
  if (!isValidNearAccountId(senderId)) {
123
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(`NEAR exact: sender "${senderId}" is not a valid NEAR account id.`);
123
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(`NEAR exact: sender "${senderId}" is not a valid NEAR account id.`);
124
124
  }
125
125
  const t = accept.maxTimeoutSeconds;
126
126
  if (!Number.isInteger(t) || t <= 0) {
127
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)("NEAR exact: maxTimeoutSeconds must be a positive integer.");
127
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)("NEAR exact: maxTimeoutSeconds must be a positive integer.");
128
128
  }
129
129
  const timeoutBlocks = BigInt(Math.max(1, Math.ceil(t / ESTIMATED_BLOCK_SECONDS)));
130
130
  const maxBlockHeight = blockHeight + timeoutBlocks;
131
131
  const nonce = accessKeyNonce + 1n;
132
132
  if (nonce >= blockHeight * NONCE_BLOCK_MULTIPLIER) {
133
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
133
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
134
134
  "NEAR exact: the access-key nonce is at the protocol ceiling for this block height; cannot build a delegate action."
135
135
  );
136
136
  }
@@ -259,7 +259,7 @@ async function verifyAndSettleExactNear(input) {
259
259
  if (/not enough|insufficient|exceeded the prepaid gas|NotEnoughBalance|doesn't have enough|is not registered/i.test(m)) {
260
260
  return fail("tx_reverted", `the ft_transfer would fail on chain: ${shorten(m)}.`);
261
261
  }
262
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
262
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
263
263
  `NEAR exact settle: the relayer could not submit the delegate (${shorten(m)}). The buyer's signed delegate is still valid \u2014 fund/fix the relayer and the buyer can re-present it.`,
264
264
  { cause: err }
265
265
  );
@@ -408,13 +408,13 @@ function txNotFound(hash) {
408
408
 
409
409
  function assertNearWallet(wallet, network) {
410
410
  if (typeof wallet !== "object" || wallet === null) {
411
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
411
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
412
412
  `chain ${network} is NEAR; wallet must be { accountId, key } (key = ed25519:\u2026).`
413
413
  );
414
414
  }
415
- _chunkJG6KRAW6cjs.assertNoLegacyWalletKey.call(void 0, wallet, "NEAR");
415
+ _chunkVPENSVOIcjs.assertNoLegacyWalletKey.call(void 0, wallet, "NEAR");
416
416
  if (!("accountId" in wallet) || !("key" in wallet)) {
417
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
417
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
418
418
  `chain ${network} is NEAR; wallet must be { accountId, key } (key = ed25519:\u2026).`
419
419
  );
420
420
  }
@@ -422,13 +422,13 @@ function assertNearWallet(wallet, network) {
422
422
  }
423
423
  function resolveNearWallet(config) {
424
424
  if (!config.accountId || !config.key) {
425
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)("NEAR wallet needs { accountId, key } (key = ed25519:\u2026).");
425
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)("NEAR wallet needs { accountId, key } (key = ed25519:\u2026).");
426
426
  }
427
427
  let signer;
428
428
  try {
429
429
  signer = _nearapijs.KeyPairSigner.fromSecretKey(config.key);
430
430
  } catch (cause) {
431
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)("NEAR wallet { key } is not a valid ed25519:\u2026 secret key.", {
431
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)("NEAR wallet { key } is not a valid ed25519:\u2026 secret key.", {
432
432
  cause
433
433
  });
434
434
  }
@@ -490,16 +490,16 @@ function makeNearNetwork(preset, rpcUrl) {
490
490
  const info = preset.tokens[token.toUpperCase()];
491
491
  if (!info) {
492
492
  const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
493
- throw new (0, _chunkJG6KRAW6cjs.UnknownTokenError)(
493
+ throw new (0, _chunkVPENSVOIcjs.UnknownTokenError)(
494
494
  `token "${token}" isn't built in for NEAR (known: ${known}). Pass { contractId, decimals } for a custom NEP-141.`
495
495
  );
496
496
  }
497
497
  return { asset: info.contractId, decimals: info.decimals, symbol: info.symbol };
498
498
  }
499
- _chunkJG6KRAW6cjs.rejectForeignToken.call(void 0, token, "near", network);
499
+ _chunkVPENSVOIcjs.rejectForeignToken.call(void 0, token, "near", network);
500
500
  const t = token;
501
501
  if (!t.contractId || typeof t.decimals !== "number") {
502
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
502
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
503
503
  `chain ${network} is NEAR; a custom token must be { contractId, decimals }.`
504
504
  );
505
505
  }
@@ -518,12 +518,12 @@ function makeNearNetwork(preset, rpcUrl) {
518
518
  },
519
519
  assertValidPayTo(payTo) {
520
520
  if (payTo.startsWith("0x")) {
521
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
521
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
522
522
  `chain ${network} is NEAR, but payTo "${payTo}" looks like an EVM/Sui 0x address.`
523
523
  );
524
524
  }
525
525
  if (!isValidNearAccountId(payTo)) {
526
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
526
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
527
527
  `chain ${network} is NEAR, but payTo "${payTo}" is not a valid NEAR account id.`
528
528
  );
529
529
  }
@@ -567,10 +567,10 @@ function makeNearNetwork(preset, rpcUrl) {
567
567
  if (tx && tx.success) return { height: "0" };
568
568
  } catch (e11) {
569
569
  }
570
- throw new (0, _chunkJG6KRAW6cjs.ConfirmationTimeoutError)(`NEAR tx ${hash} not confirmed in time.`);
570
+ throw new (0, _chunkVPENSVOIcjs.ConfirmationTimeoutError)(`NEAR tx ${hash} not confirmed in time.`);
571
571
  },
572
572
  async estimateCost() {
573
- return _chunkJG6KRAW6cjs.nativeCost.call(void 0, {
573
+ return _chunkVPENSVOIcjs.nativeCost.call(void 0, {
574
574
  symbol: "NEAR",
575
575
  decimals: NEAR_DECIMALS,
576
576
  fee: 1500000000000000000000n,
@@ -692,7 +692,7 @@ function makeNearNetwork(preset, rpcUrl) {
692
692
  try {
693
693
  relayerWallet = resolveNearWallet(relayer._native);
694
694
  } catch (err) {
695
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
695
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
696
696
  `NEAR exact settle: the relayer wallet is invalid (${err instanceof Error ? err.message : String(err)}).`,
697
697
  { cause: err }
698
698
  );
@@ -10,7 +10,7 @@ import {
10
10
  nativeCost,
11
11
  rejectForeignToken,
12
12
  toInsufficientFundsError
13
- } from "./chunk-7XK22JSQ.js";
13
+ } from "./chunk-W3HOMXOF.js";
14
14
 
15
15
  // src/drivers/near/index.ts
16
16
  import { JsonRpcProvider, Account, actions as actions2 } from "near-api-js";
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
 
11
- var _chunkJG6KRAW6cjs = require('./chunk-JG6KRAW6.cjs');
11
+ var _chunkVPENSVOIcjs = require('./chunk-VPENSVOI.cjs');
12
12
 
13
13
  // src/drivers/solana/index.ts
14
14
  var _web3js = require('@solana/web3.js');
@@ -221,6 +221,8 @@ function notFound(signature) {
221
221
  var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);
222
222
  var COMPUTE_UNIT_LIMIT = 2e4;
223
223
  var COMPUTE_UNIT_PRICE_MICROLAMPORTS = 1;
224
+ var MEMO_PROGRAM_ID = new (0, _web3js.PublicKey)("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");
225
+ var MAX_MEMO_BYTES = 256;
224
226
  var MAX_COMPUTE_UNIT_LIMIT = 300000n;
225
227
  var MAX_COMPUTE_UNIT_PRICE_MICROLAMPORTS = 100000n;
226
228
  var CB_SET_UNIT_LIMIT = 2;
@@ -231,18 +233,44 @@ function tokenProgramFor(accept) {
231
233
  function isEmptySig(sig) {
232
234
  return !sig || sig.every((b) => b === 0);
233
235
  }
236
+ function memoRandomNonce() {
237
+ const g = globalThis.crypto;
238
+ if (!_optionalChain([g, 'optionalAccess', _3 => _3.getRandomValues])) {
239
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
240
+ "this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); SVM exact needs a CSPRNG nonce."
241
+ );
242
+ }
243
+ const raw = new Uint8Array(16);
244
+ g.getRandomValues(raw);
245
+ return Buffer.from([...raw].map((b) => b.toString(16).padStart(2, "0")).join(""), "utf8");
246
+ }
247
+ function memoDataFor(accept) {
248
+ if (accept.extra.memo !== void 0) {
249
+ const bytes = Buffer.from(accept.extra.memo, "utf8");
250
+ if (bytes.length > MAX_MEMO_BYTES) {
251
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
252
+ `SVM exact: extra.memo is ${bytes.length} bytes; the scheme caps it at ${MAX_MEMO_BYTES}.`
253
+ );
254
+ }
255
+ return bytes;
256
+ }
257
+ return memoRandomNonce();
258
+ }
259
+ function memoInstruction(accept) {
260
+ return new (0, _web3js.TransactionInstruction)({ programId: MEMO_PROGRAM_ID, keys: [], data: memoDataFor(accept) });
261
+ }
234
262
  async function payExactSolana(input) {
235
263
  const { connection, keypair, accept } = input;
236
264
  if (accept.asset === "native") {
237
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
265
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
238
266
  "SVM exact is SPL-token only (TransferChecked); native SOL is not exact-payable. Pay via onchain-proof."
239
267
  );
240
268
  }
241
269
  if (!accept.extra.feePayer) {
242
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.feePayer (the merchant sponsor key).");
270
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.feePayer (the merchant sponsor key).");
243
271
  }
244
272
  if (accept.extra.decimals === void 0) {
245
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.decimals for the TransferChecked.");
273
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)("SVM exact rail must advertise extra.decimals for the TransferChecked.");
246
274
  }
247
275
  let feePayer;
248
276
  let mint;
@@ -252,12 +280,12 @@ async function payExactSolana(input) {
252
280
  mint = new (0, _web3js.PublicKey)(accept.asset);
253
281
  payTo = new (0, _web3js.PublicKey)(accept.payTo);
254
282
  } catch (err) {
255
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
283
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
256
284
  `SVM exact: bad feePayer/asset/payTo (${err instanceof Error ? err.message : String(err)}).`
257
285
  );
258
286
  }
259
287
  if (feePayer.equals(payTo)) {
260
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
288
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
261
289
  "SVM exact: the fee payer must differ from payTo \u2014 payTo appears in the transfer instruction, which the fee payer must not (a scheme MUST-rule). Use a separate relayer key for the gate."
262
290
  );
263
291
  }
@@ -271,10 +299,11 @@ async function payExactSolana(input) {
271
299
  destInfo = "unknown";
272
300
  }
273
301
  if (destInfo === null) {
274
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
302
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
275
303
  `SVM exact: the recipient's token account for ${mint.toBase58()} doesn't exist yet \u2014 the exact rail can't create it. Pay via onchain-proof (which creates it), or have ${payTo.toBase58()} create its associated token account first.`
276
304
  );
277
305
  }
306
+ const memoIx = memoInstruction(accept);
278
307
  const instructions = [
279
308
  _web3js.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
280
309
  _web3js.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: COMPUTE_UNIT_PRICE_MICROLAMPORTS }),
@@ -287,7 +316,9 @@ async function payExactSolana(input) {
287
316
  accept.extra.decimals,
288
317
  [],
289
318
  program
290
- )
319
+ ),
320
+ memoIx
321
+ // [3] SPL-Memo (scheme MUST); keeps the tx at 4 ix, inside Path-1's 3-to-7.
291
322
  ];
292
323
  const { blockhash } = await connection.getLatestBlockhash();
293
324
  const message = new (0, _web3js.TransactionMessage)({
@@ -299,11 +330,11 @@ async function payExactSolana(input) {
299
330
  tx.sign([keypair]);
300
331
  const buyerIndex = message.staticAccountKeys.findIndex((k) => k.equals(keypair.publicKey));
301
332
  if (buyerIndex < 1 || buyerIndex >= message.header.numRequiredSignatures) {
302
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)("SVM exact: could not locate the buyer signer slot.");
333
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)("SVM exact: could not locate the buyer signer slot.");
303
334
  }
304
335
  const buyerSig = tx.signatures[buyerIndex];
305
336
  if (!buyerSig || isEmptySig(buyerSig)) {
306
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)("SVM exact: the wallet did not produce a buyer signature.");
337
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)("SVM exact: the wallet did not produce a buyer signature.");
307
338
  }
308
339
  const transaction = Buffer.from(tx.serialize()).toString("base64");
309
340
  return {
@@ -330,15 +361,15 @@ async function verifyAndSettleExactSolana(input) {
330
361
  if (!accept.extra.feePayer) throw new Error("rail is missing extra.feePayer");
331
362
  railFeePayer = new (0, _web3js.PublicKey)(accept.extra.feePayer);
332
363
  } catch (err) {
333
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(`SVM exact: rail has a bad payTo/asset/feePayer (${err instanceof Error ? err.message : String(err)}).`);
364
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(`SVM exact: rail has a bad payTo/asset/feePayer (${err instanceof Error ? err.message : String(err)}).`);
334
365
  }
335
366
  if (!railFeePayer.equals(feePayerKeypair.publicKey)) {
336
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
367
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
337
368
  "SVM exact: the gate relayer key does not match the rail extra.feePayer \u2014 misconfigured rail."
338
369
  );
339
370
  }
340
371
  if (feePayerKeypair.publicKey.equals(payTo)) {
341
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)("SVM exact: the fee payer must differ from payTo \u2014 misconfigured rail.");
372
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)("SVM exact: the fee payer must differ from payTo \u2014 misconfigured rail.");
342
373
  }
343
374
  const program = tokenProgramFor(accept);
344
375
  let tx;
@@ -379,7 +410,7 @@ async function verifyAndSettleExactSolana(input) {
379
410
  return fail("signature_invalid", "The fee payer is invoked as a program.");
380
411
  }
381
412
  for (const i of ix.accountKeyIndexes) {
382
- if (_optionalChain([keys, 'access', _3 => _3.get, 'call', _4 => _4(i), 'optionalAccess', _5 => _5.equals, 'call', _6 => _6(feePayerKey)])) {
413
+ if (_optionalChain([keys, 'access', _4 => _4.get, 'call', _5 => _5(i), 'optionalAccess', _6 => _6.equals, 'call', _7 => _7(feePayerKey)])) {
383
414
  return fail("signature_invalid", "The fee payer appears in an instruction account list (would risk a fund drain).");
384
415
  }
385
416
  }
@@ -478,7 +509,7 @@ async function verifyAndSettleExactSolana(input) {
478
509
  } catch (err) {
479
510
  const msg = err instanceof Error ? err.message : String(err);
480
511
  if (/blockhash|block height|expired/i.test(msg)) return fail("payment_expired", `Settle broadcast rejected \u2014 blockhash expired: ${shorten(msg)}.`);
481
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
512
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
482
513
  `SVM exact settle: the merchant fee payer failed to broadcast (${shorten(msg)}). The buyer's signed transaction is still valid \u2014 fund/fix the fee payer and the buyer can re-present it.`,
483
514
  { cause: err }
484
515
  );
@@ -488,7 +519,7 @@ async function verifyAndSettleExactSolana(input) {
488
519
  return fail("tx_reverted", `Settle tx ${txid} reverted on-chain (a post-simulate race).`);
489
520
  }
490
521
  if (confirmed === "timeout") {
491
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
522
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
492
523
  `SVM exact settle: broadcast ${txid} but it did not confirm in time. It likely landed \u2014 re-verify by signature before re-presenting; do NOT re-pay.`
493
524
  );
494
525
  }
@@ -531,18 +562,18 @@ async function pollConfirmed(connection, signature) {
531
562
 
532
563
  function toKeypair(wallet, network) {
533
564
  if (typeof wallet !== "object" || wallet === null) {
534
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
565
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
535
566
  `chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
536
567
  );
537
568
  }
538
- _chunkJG6KRAW6cjs.assertNoLegacyWalletKey.call(void 0, wallet, "Solana");
569
+ _chunkVPENSVOIcjs.assertNoLegacyWalletKey.call(void 0, wallet, "Solana");
539
570
  if ("signer" in wallet) {
540
571
  return wallet.signer;
541
572
  }
542
573
  if ("key" in wallet) {
543
574
  const sk = wallet.key;
544
575
  if (typeof sk === "string" && sk.startsWith("0x")) {
545
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
576
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
546
577
  `chain ${network} is Solana, but the wallet { key } is a 0x\u2026 hex key \u2014 that's an EVM key. A Solana key is a base58 secret string (or a 64-byte Uint8Array).`
547
578
  );
548
579
  }
@@ -550,12 +581,12 @@ function toKeypair(wallet, network) {
550
581
  const bytes = typeof sk === "string" ? _bs582.default.decode(sk) : sk;
551
582
  return _web3js.Keypair.fromSecretKey(bytes);
552
583
  } catch (err) {
553
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
584
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
554
585
  `chain ${network} is Solana; the wallet { key } isn't a valid Solana secret (expected a base58 secret string or a 64-byte Uint8Array): ${err instanceof Error ? err.message : String(err)}.`
555
586
  );
556
587
  }
557
588
  }
558
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
589
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
559
590
  `chain ${network} is Solana; wallet must be { key } (base58 secret) or { signer }.`
560
591
  );
561
592
  }
@@ -584,15 +615,15 @@ function makeSolanaNetwork(preset, rpcUrl) {
584
615
  const info = preset.tokens[token.toUpperCase()];
585
616
  if (!info) {
586
617
  const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
587
- throw new (0, _chunkJG6KRAW6cjs.UnknownTokenError)(
618
+ throw new (0, _chunkVPENSVOIcjs.UnknownTokenError)(
588
619
  `token "${token}" isn't built in for Solana (known: ${known}). Pass { mint, decimals } instead, or use 'native'.`
589
620
  );
590
621
  }
591
622
  return { asset: info.mint, decimals: info.decimals, symbol: info.symbol };
592
623
  }
593
- _chunkJG6KRAW6cjs.rejectForeignToken.call(void 0, token, "solana", network);
624
+ _chunkVPENSVOIcjs.rejectForeignToken.call(void 0, token, "solana", network);
594
625
  if (!("mint" in token)) {
595
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
626
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
596
627
  `chain ${network} is Solana; a custom token must be { mint, decimals }.`
597
628
  );
598
629
  }
@@ -611,14 +642,14 @@ function makeSolanaNetwork(preset, rpcUrl) {
611
642
  },
612
643
  assertValidPayTo(payTo) {
613
644
  if (payTo.startsWith("0x")) {
614
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
645
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
615
646
  `chain ${network} is Solana, but payTo "${payTo}" looks like an EVM address.`
616
647
  );
617
648
  }
618
649
  try {
619
650
  new (0, _web3js.PublicKey)(payTo);
620
651
  } catch (e7) {
621
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
652
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
622
653
  `chain ${network} is Solana, but payTo "${payTo}" is not a base58 address.`
623
654
  );
624
655
  }
@@ -630,7 +661,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
630
661
  try {
631
662
  return await paySolana({ connection, keypair: wallet._native, accept });
632
663
  } catch (err) {
633
- throw _nullishCoalesce(_chunkJG6KRAW6cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
664
+ throw _nullishCoalesce(_chunkVPENSVOIcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
634
665
  }
635
666
  },
636
667
  async confirm(ref) {
@@ -641,19 +672,19 @@ function makeSolanaNetwork(preset, rpcUrl) {
641
672
  });
642
673
  info = value[0];
643
674
  } catch (err) {
644
- throw new (0, _chunkJG6KRAW6cjs.ConfirmationTimeoutError)(
675
+ throw new (0, _chunkVPENSVOIcjs.ConfirmationTimeoutError)(
645
676
  `Solana payment ${ref} could not be confirmed (RPC read failed).`,
646
677
  { cause: err }
647
678
  );
648
679
  }
649
680
  if (!info || info.err || info.confirmationStatus !== "confirmed" && info.confirmationStatus !== "finalized") {
650
- throw new (0, _chunkJG6KRAW6cjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
681
+ throw new (0, _chunkVPENSVOIcjs.ConfirmationTimeoutError)(`Solana payment ${ref} did not confirm in time.`);
651
682
  }
652
683
  return { height: String(info.slot) };
653
684
  },
654
685
  async estimateCost(accept) {
655
686
  if (accept.scheme === "exact") {
656
- return _chunkJG6KRAW6cjs.nativeCost.call(void 0, {
687
+ return _chunkVPENSVOIcjs.nativeCost.call(void 0, {
657
688
  symbol: "SOL",
658
689
  decimals: SOL_DECIMALS,
659
690
  fee: 0n,
@@ -663,7 +694,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
663
694
  }
664
695
  const base = 5000n;
665
696
  if (accept.asset === "native") {
666
- return _chunkJG6KRAW6cjs.nativeCost.call(void 0, {
697
+ return _chunkVPENSVOIcjs.nativeCost.call(void 0, {
667
698
  symbol: "SOL",
668
699
  decimals: SOL_DECIMALS,
669
700
  fee: base,
@@ -672,7 +703,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
672
703
  });
673
704
  }
674
705
  const ataRent = 2039280n;
675
- return _chunkJG6KRAW6cjs.nativeCost.call(void 0, {
706
+ return _chunkVPENSVOIcjs.nativeCost.call(void 0, {
676
707
  symbol: "SOL",
677
708
  decimals: SOL_DECIMALS,
678
709
  fee: base + ataRent,
@@ -740,7 +771,7 @@ function makeSolanaNetwork(preset, rpcUrl) {
740
771
  let tokenProgram = "spl-token";
741
772
  try {
742
773
  const info = await connection.getAccountInfo(new (0, _web3js.PublicKey)(asset));
743
- if (_optionalChain([info, 'optionalAccess', _7 => _7.owner, 'access', _8 => _8.equals, 'call', _9 => _9(_spltoken.TOKEN_2022_PROGRAM_ID)])) tokenProgram = "token-2022";
774
+ if (_optionalChain([info, 'optionalAccess', _8 => _8.owner, 'access', _9 => _9.equals, 'call', _10 => _10(_spltoken.TOKEN_2022_PROGRAM_ID)])) tokenProgram = "token-2022";
744
775
  } catch (e9) {
745
776
  }
746
777
  return { method: "svm", extra: { feePayer: fp, tokenProgram } };