@medialane/sdk 0.167.0 → 0.168.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.
@@ -1,7 +1,7 @@
1
- import { bC as ResolvedConfig, aZ as CreatePopCollectionParams, bJ as TxResult, aK as ClaimConditions, aV as CreateDropParams, b2 as CreateTicketParams, bn as MintTicketsParams, aX as CreateMembershipParams, bm as MintMembershipsParams, b0 as CreateSponsorshipOfferParams, bz as ProposeSponsorshipParams, k as ApiClient, bk as MedialaneConfig, bl as MedialaneErrorCode, bs as OrderDetails, R as ResolvedFeeConfig, I as ApiFundingIntent, H as ApiFundingInstructions, L as ApiFundingSubmit, N as ApiIntentCreated, bP as SealedOwner, bQ as ReceiptProviderLike, bR as WalletExecutor, bS as ExecutedTransaction, bT as PasskeyOwner, bU as CreatedOwner } from '../errors-GcSzVvZL.cjs';
2
- export { bV as InvalidRecoveryKeyError, bW as OwnerSigner, bv as PasskeyCancelledError, bX as PasskeyConfig, bw as PasskeyUnsupportedError, bx as PasskeyUnsupportedReason, bY as RecoveryKey, bL as UserFacingError, bZ as createPasskeyOwner, b_ as encodeRecoveryKey, b$ as parseRecoveryKey } from '../errors-GcSzVvZL.cjs';
1
+ import { bS as ResolvedConfig, b5 as CreatePopCollectionParams, bZ as TxResult, aK as ClaimConditions, aZ as CreateDropParams, bc as CreateTicketParams, bC as MintTicketsParams, b1 as CreateMembershipParams, bB as MintMembershipsParams, b9 as CreateSponsorshipOfferParams, bP as ProposeSponsorshipParams, k as ApiClient, bz as MedialaneConfig, bA as MedialaneErrorCode, bH as OrderDetails, R as ResolvedFeeConfig, I as ApiFundingIntent, H as ApiFundingInstructions, L as ApiFundingSubmit, N as ApiIntentCreated, c4 as SealedOwner, c5 as ReceiptProviderLike, c6 as WalletExecutor, c7 as ExecutedTransaction, c8 as PasskeyOwner, bh as CreateWalletManageIntentParams, c9 as CreatedOwner } from '../errors-CwqwX-vA.cjs';
2
+ export { ca as InvalidRecoveryKeyError, cb as OwnerSigner, bK as PasskeyCancelledError, cc as PasskeyConfig, bL as PasskeyUnsupportedError, bM as PasskeyUnsupportedReason, cd as RecoveryKey, b$ as UserFacingError, ce as createPasskeyOwner, cf as encodeRecoveryKey, cg as parseRecoveryKey } from '../errors-CwqwX-vA.cjs';
3
3
  import { AccountInterface, ProviderInterface, Call, TypedData, constants, BigNumberish, DeployAccountContractPayload, Account } from 'starknet';
4
- import { V as VenueAdapter, O as OrderRef, A as AdapterTxResult, R as RegisterOrderParams, j as VenueSigner } from '../types-PPshMWr7.cjs';
4
+ import { V as VenueAdapter, O as OrderRef, A as AdapterTxResult, R as RegisterOrderParams, j as VenueSigner } from '../types-C-y68Ut2.cjs';
5
5
  import 'zod';
6
6
 
7
7
  declare class PopService {
@@ -8261,6 +8261,7 @@ interface TypedDataSigner {
8261
8261
  interface SponsoredExecuteConfig {
8262
8262
  proxyUrl: string;
8263
8263
  fetchImpl?: typeof fetch;
8264
+ headers?: Record<string, string>;
8264
8265
  }
8265
8266
  type SponsoredExecuteResult = {
8266
8267
  status: "sponsored";
@@ -8273,7 +8274,7 @@ declare class SponsoredCallRejectedError extends Error {
8273
8274
  }
8274
8275
  type SponsorshipFailureCode = "sponsor_unavailable" | "credits_exhausted" | "account_not_deployed" | "not_executable" | "invalid_request" | "not_authorized" | "rate_limited" | "may_have_broadcast";
8275
8276
  declare function allowsFallbackFunding(code: string | undefined, status: number, stage: "build" | "execute"): boolean;
8276
- declare function executeSponsored(config: SponsoredExecuteConfig, signer: TypedDataSigner, calls: Call[]): Promise<SponsoredExecuteResult>;
8277
+ declare function executeSponsored(config: SponsoredExecuteConfig, signer: TypedDataSigner, calls: Call[], intentIds?: string[]): Promise<SponsoredExecuteResult>;
8277
8278
 
8278
8279
  declare function encodeByteArray(str: string): string[];
8279
8280
 
@@ -8478,6 +8479,10 @@ interface MediaWalletConfig {
8478
8479
  backendUrl?: string;
8479
8480
  deployProxyUrl?: string;
8480
8481
  fetchImpl?: typeof fetch;
8482
+ walletIntents?: (params: CreateWalletManageIntentParams) => Promise<{
8483
+ id: string;
8484
+ calls: Call[];
8485
+ }>;
8481
8486
  }
8482
8487
  interface MediaWallet {
8483
8488
  store: OwnerStore;
@@ -8486,11 +8491,13 @@ interface MediaWallet {
8486
8491
  signerFor(sealed: SealedOwner): {
8487
8492
  address: string;
8488
8493
  signTypedData(data: TypedData): Promise<string[]>;
8489
- execute(calls: Call[]): Promise<{
8494
+ execute(calls: Call[], opts?: {
8495
+ intentIds?: string[];
8496
+ }): Promise<{
8490
8497
  txHash: string;
8491
8498
  }>;
8492
8499
  };
8493
- run(sealed: SealedOwner, calls: Call[], userAddress?: string): Promise<ExecutedTransaction>;
8500
+ run(sealed: SealedOwner, calls: Call[], userAddress?: string, intentIds?: string[]): Promise<ExecutedTransaction>;
8494
8501
  getGuardians(address: string): Promise<GuardianInfo[]>;
8495
8502
  getEscape(address: string): Promise<EscapeInfo>;
8496
8503
  getEscapeSecurityPeriod(address: string): Promise<number>;
@@ -1,7 +1,7 @@
1
- import { bC as ResolvedConfig, aZ as CreatePopCollectionParams, bJ as TxResult, aK as ClaimConditions, aV as CreateDropParams, b2 as CreateTicketParams, bn as MintTicketsParams, aX as CreateMembershipParams, bm as MintMembershipsParams, b0 as CreateSponsorshipOfferParams, bz as ProposeSponsorshipParams, k as ApiClient, bk as MedialaneConfig, bl as MedialaneErrorCode, bs as OrderDetails, R as ResolvedFeeConfig, I as ApiFundingIntent, H as ApiFundingInstructions, L as ApiFundingSubmit, N as ApiIntentCreated, bP as SealedOwner, bQ as ReceiptProviderLike, bR as WalletExecutor, bS as ExecutedTransaction, bT as PasskeyOwner, bU as CreatedOwner } from '../errors-DRiTDrwm.js';
2
- export { bV as InvalidRecoveryKeyError, bW as OwnerSigner, bv as PasskeyCancelledError, bX as PasskeyConfig, bw as PasskeyUnsupportedError, bx as PasskeyUnsupportedReason, bY as RecoveryKey, bL as UserFacingError, bZ as createPasskeyOwner, b_ as encodeRecoveryKey, b$ as parseRecoveryKey } from '../errors-DRiTDrwm.js';
1
+ import { bS as ResolvedConfig, b5 as CreatePopCollectionParams, bZ as TxResult, aK as ClaimConditions, aZ as CreateDropParams, bc as CreateTicketParams, bC as MintTicketsParams, b1 as CreateMembershipParams, bB as MintMembershipsParams, b9 as CreateSponsorshipOfferParams, bP as ProposeSponsorshipParams, k as ApiClient, bz as MedialaneConfig, bA as MedialaneErrorCode, bH as OrderDetails, R as ResolvedFeeConfig, I as ApiFundingIntent, H as ApiFundingInstructions, L as ApiFundingSubmit, N as ApiIntentCreated, c4 as SealedOwner, c5 as ReceiptProviderLike, c6 as WalletExecutor, c7 as ExecutedTransaction, c8 as PasskeyOwner, bh as CreateWalletManageIntentParams, c9 as CreatedOwner } from '../errors-CWbsAodQ.js';
2
+ export { ca as InvalidRecoveryKeyError, cb as OwnerSigner, bK as PasskeyCancelledError, cc as PasskeyConfig, bL as PasskeyUnsupportedError, bM as PasskeyUnsupportedReason, cd as RecoveryKey, b$ as UserFacingError, ce as createPasskeyOwner, cf as encodeRecoveryKey, cg as parseRecoveryKey } from '../errors-CWbsAodQ.js';
3
3
  import { AccountInterface, ProviderInterface, Call, TypedData, constants, BigNumberish, DeployAccountContractPayload, Account } from 'starknet';
4
- import { V as VenueAdapter, O as OrderRef, A as AdapterTxResult, R as RegisterOrderParams, j as VenueSigner } from '../types-PPshMWr7.js';
4
+ import { V as VenueAdapter, O as OrderRef, A as AdapterTxResult, R as RegisterOrderParams, j as VenueSigner } from '../types-C-y68Ut2.js';
5
5
  import 'zod';
6
6
 
7
7
  declare class PopService {
@@ -8261,6 +8261,7 @@ interface TypedDataSigner {
8261
8261
  interface SponsoredExecuteConfig {
8262
8262
  proxyUrl: string;
8263
8263
  fetchImpl?: typeof fetch;
8264
+ headers?: Record<string, string>;
8264
8265
  }
8265
8266
  type SponsoredExecuteResult = {
8266
8267
  status: "sponsored";
@@ -8273,7 +8274,7 @@ declare class SponsoredCallRejectedError extends Error {
8273
8274
  }
8274
8275
  type SponsorshipFailureCode = "sponsor_unavailable" | "credits_exhausted" | "account_not_deployed" | "not_executable" | "invalid_request" | "not_authorized" | "rate_limited" | "may_have_broadcast";
8275
8276
  declare function allowsFallbackFunding(code: string | undefined, status: number, stage: "build" | "execute"): boolean;
8276
- declare function executeSponsored(config: SponsoredExecuteConfig, signer: TypedDataSigner, calls: Call[]): Promise<SponsoredExecuteResult>;
8277
+ declare function executeSponsored(config: SponsoredExecuteConfig, signer: TypedDataSigner, calls: Call[], intentIds?: string[]): Promise<SponsoredExecuteResult>;
8277
8278
 
8278
8279
  declare function encodeByteArray(str: string): string[];
8279
8280
 
@@ -8478,6 +8479,10 @@ interface MediaWalletConfig {
8478
8479
  backendUrl?: string;
8479
8480
  deployProxyUrl?: string;
8480
8481
  fetchImpl?: typeof fetch;
8482
+ walletIntents?: (params: CreateWalletManageIntentParams) => Promise<{
8483
+ id: string;
8484
+ calls: Call[];
8485
+ }>;
8481
8486
  }
8482
8487
  interface MediaWallet {
8483
8488
  store: OwnerStore;
@@ -8486,11 +8491,13 @@ interface MediaWallet {
8486
8491
  signerFor(sealed: SealedOwner): {
8487
8492
  address: string;
8488
8493
  signTypedData(data: TypedData): Promise<string[]>;
8489
- execute(calls: Call[]): Promise<{
8494
+ execute(calls: Call[], opts?: {
8495
+ intentIds?: string[];
8496
+ }): Promise<{
8490
8497
  txHash: string;
8491
8498
  }>;
8492
8499
  };
8493
- run(sealed: SealedOwner, calls: Call[], userAddress?: string): Promise<ExecutedTransaction>;
8500
+ run(sealed: SealedOwner, calls: Call[], userAddress?: string, intentIds?: string[]): Promise<ExecutedTransaction>;
8494
8501
  getGuardians(address: string): Promise<GuardianInfo[]>;
8495
8502
  getEscape(address: string): Promise<EscapeInfo>;
8496
8503
  getEscapeSecurityPeriod(address: string): Promise<number>;
@@ -1,5 +1,5 @@
1
- import { normalizeAddress, collectionHref, resolveConfig, ApiClient, UserFacingError, getService, STARKNET_MEDIAWALLET_CLASS_HASH, computeAccountAddress, ownerConstructorCalldata, getTokenBySymbol, signWithPrivateKey, stringifyBigInts, SUPPORTED_TOKENS, starkKeyPairFromPrivateKey, createFailoverFetch } from '../chunk-USFXQO4T.js';
2
- export { InvalidStarkPrivateKeyError, PasskeyCancelledError, PasskeyUnsupportedError, UserFacingError, computeAccountAddress, createPasskeyOwner, deriveAesKey, generateStarkKeyPair, ownerConstructorCalldata, sealPrivateKey, signWithPrivateKey, starkKeyPairFromPrivateKey, unsealPrivateKey } from '../chunk-USFXQO4T.js';
1
+ import { normalizeAddress, collectionHref, resolveConfig, ApiClient, UserFacingError, getService, STARKNET_MEDIAWALLET_CLASS_HASH, computeAccountAddress, ownerConstructorCalldata, getTokenBySymbol, signWithPrivateKey, stringifyBigInts, SUPPORTED_TOKENS, starkKeyPairFromPrivateKey, createFailoverFetch } from '../chunk-3QGECZBS.js';
2
+ export { InvalidStarkPrivateKeyError, PasskeyCancelledError, PasskeyUnsupportedError, UserFacingError, computeAccountAddress, createPasskeyOwner, deriveAesKey, generateStarkKeyPair, ownerConstructorCalldata, sealPrivateKey, signWithPrivateKey, starkKeyPairFromPrivateKey, unsealPrivateKey } from '../chunk-3QGECZBS.js';
3
3
  import { getStarknetCoordinates, getCoordinates } from '../chunk-PBJLHXDB.js';
4
4
  import { hash, cairo, uint256, RpcProvider, CairoOption, CairoOptionVariant, num, ec, validateAndParseAddress, Account, typedData, stark, CallData, byteArray, Contract, TypedDataRevision, constants, shortString } from 'starknet';
5
5
  import { extract, expand } from '@noble/hashes/hkdf.js';
@@ -11317,7 +11317,7 @@ async function executeIntent(provider, signer, client, intent, opts = {}) {
11317
11317
  } else {
11318
11318
  calls = intent.calls;
11319
11319
  }
11320
- const { txHash } = await signer.execute(calls);
11320
+ const { txHash } = await signer.execute(calls, { intentIds: [intent.id] });
11321
11321
  const receipt = await assertTransactionSucceeded(provider, txHash);
11322
11322
  await Promise.all([
11323
11323
  syncTransactionBestEffort(client, txHash),
@@ -11330,7 +11330,7 @@ async function executeIntents(provider, signer, client, intents, opts = {}) {
11330
11330
  throw new Error("Expected prebuilt intents (requiresSignature=false)");
11331
11331
  }
11332
11332
  const calls = intents.flatMap((i) => i.calls);
11333
- const { txHash } = await signer.execute(calls);
11333
+ const { txHash } = await signer.execute(calls, { intentIds: intents.map((i) => i.id) });
11334
11334
  const receipt = await assertTransactionSucceeded(provider, txHash);
11335
11335
  await Promise.all([
11336
11336
  syncTransactionBestEffort(client, txHash),
@@ -11392,14 +11392,14 @@ async function failureOf(res, fallback) {
11392
11392
  const body = await res.json().catch(() => null);
11393
11393
  return { reason: body?.error || fallback, code: typeof body?.code === "string" ? body.code : void 0 };
11394
11394
  }
11395
- async function executeSponsored(config, signer, calls) {
11395
+ async function executeSponsored(config, signer, calls, intentIds) {
11396
11396
  const doFetch = config.fetchImpl ?? fetch;
11397
11397
  const base = config.proxyUrl.replace(/\/$/, "");
11398
- const headers = { "Content-Type": "application/json" };
11398
+ const headers = { "Content-Type": "application/json", ...config.headers };
11399
11399
  const buildRes = await doFetch(`${base}/build`, {
11400
11400
  method: "POST",
11401
11401
  headers,
11402
- body: JSON.stringify({ userAddress: signer.address, calls })
11402
+ body: JSON.stringify(intentIds ? { intentIds } : { userAddress: signer.address, calls })
11403
11403
  });
11404
11404
  if (!buildRes.ok) {
11405
11405
  const { reason, code } = await failureOf(buildRes, "We couldn't prepare this transaction.");
@@ -11411,7 +11411,7 @@ async function executeSponsored(config, signer, calls) {
11411
11411
  const executeRes = await doFetch(`${base}/execute`, {
11412
11412
  method: "POST",
11413
11413
  headers,
11414
- body: JSON.stringify({ userAddress: signer.address, typedData, signature, calls })
11414
+ body: JSON.stringify(intentIds ? { intentIds, typedData, signature } : { userAddress: signer.address, typedData, signature, calls })
11415
11415
  });
11416
11416
  if (!executeRes.ok) {
11417
11417
  const { reason, code } = await failureOf(executeRes, "We couldn't submit this transaction.");
@@ -11792,14 +11792,15 @@ function sponsoredExecutor(deps) {
11792
11792
  const fallback = deps.fallback ?? selfFundedExecutor(deps);
11793
11793
  return {
11794
11794
  async execute(input) {
11795
- const { userAddress, privateKeyHex, calls } = input;
11795
+ const { userAddress, privateKeyHex, calls, intentIds } = input;
11796
11796
  const result = await executeSponsored(
11797
11797
  { proxyUrl: deps.proxyUrl, fetchImpl: deps.fetchImpl },
11798
11798
  {
11799
11799
  address: userAddress,
11800
11800
  signTypedData: async (data) => signWithPrivateKey(privateKeyHex, typedData.getMessageHash(data, userAddress))
11801
11801
  },
11802
- calls
11802
+ calls,
11803
+ intentIds
11803
11804
  );
11804
11805
  if (result.status === "sponsored") return { transactionHash: result.transactionHash };
11805
11806
  const consented = await deps.consent.request({ address: userAddress, calls });
@@ -12013,14 +12014,25 @@ function createMediaWallet(config) {
12013
12014
  unlockCache.set(sealed.address, { promise, timer });
12014
12015
  return promise;
12015
12016
  };
12016
- const run = async (sealed, calls, userAddress) => {
12017
+ const run = async (sealed, calls, userAddress, intentIds) => {
12017
12018
  const privateKeyHex = await unlockOnce(sealed);
12018
12019
  return config.executor.execute({
12019
12020
  userAddress: userAddress ?? sealed.address,
12020
12021
  privateKeyHex,
12021
- calls
12022
+ calls,
12023
+ intentIds
12022
12024
  });
12023
12025
  };
12026
+ const walletIntents = config.walletIntents ?? (async (params) => {
12027
+ if (!config.backendUrl) throw new Error("This wallet has no backend url configured");
12028
+ const created = await new ApiClient(config.backendUrl).createWalletManageIntent(params);
12029
+ return created.data;
12030
+ });
12031
+ const manage = async (sealed, params) => {
12032
+ const intent = await walletIntents(params);
12033
+ const { transactionHash } = await run(sealed, intent.calls, params.owner, [intent.id]);
12034
+ return transactionHash;
12035
+ };
12024
12036
  return {
12025
12037
  store: config.store,
12026
12038
  passkey: config.passkey,
@@ -12032,8 +12044,8 @@ function createMediaWallet(config) {
12032
12044
  const privateKeyHex = await unlockOnce(sealed);
12033
12045
  return signWithPrivateKey(privateKeyHex, typedData.getMessageHash(data, sealed.address));
12034
12046
  },
12035
- execute: async (calls) => {
12036
- const { transactionHash } = await run(sealed, calls);
12047
+ execute: async (calls, opts) => {
12048
+ const { transactionHash } = await run(sealed, calls, void 0, opts?.intentIds);
12037
12049
  return { txHash: transactionHash };
12038
12050
  }
12039
12051
  };
@@ -12048,38 +12060,12 @@ function createMediaWallet(config) {
12048
12060
  const guid = BigInt(computeOwnerGuid(devicePubkey));
12049
12061
  return owners.some((owner) => BigInt(owner.guid) === guid);
12050
12062
  },
12051
- async setFirstGuardian(sealed, guardianPubkey) {
12052
- const { transactionHash } = await run(sealed, [buildSetFirstGuardianCall(sealed.address, guardianPubkey)]);
12053
- return transactionHash;
12054
- },
12055
- async triggerEscapeOwner(guardianSealed, targetAddress, newOwnerPubkey) {
12056
- const { transactionHash } = await run(
12057
- guardianSealed,
12058
- [buildTriggerEscapeOwnerCall(targetAddress, newOwnerPubkey)],
12059
- normalizeWalletAddress(targetAddress)
12060
- );
12061
- return transactionHash;
12062
- },
12063
- async completeEscapeOwner(guardianSealed, targetAddress) {
12064
- const { transactionHash } = await run(
12065
- guardianSealed,
12066
- [buildCompleteEscapeOwnerCall(targetAddress)],
12067
- normalizeWalletAddress(targetAddress)
12068
- );
12069
- return transactionHash;
12070
- },
12071
- async cancelEscape(sealed) {
12072
- const { transactionHash } = await run(sealed, [buildCancelEscapeCall(sealed.address)]);
12073
- return transactionHash;
12074
- },
12075
- async addDevice(sealed, devicePubkey) {
12076
- const { transactionHash } = await run(sealed, [buildAddOwnerCall(sealed.address, devicePubkey)]);
12077
- return transactionHash;
12078
- },
12079
- async removeDevice(sealed, ownerGuid) {
12080
- const { transactionHash } = await run(sealed, [buildRemoveOwnerByGuidCall(sealed.address, ownerGuid)]);
12081
- return transactionHash;
12082
- },
12063
+ setFirstGuardian: (sealed, guardianPubkey) => manage(sealed, { owner: sealed.address, action: "set_first_guardian", pubkey: guardianPubkey }),
12064
+ triggerEscapeOwner: (guardianSealed, targetAddress, newOwnerPubkey) => manage(guardianSealed, { owner: normalizeWalletAddress(targetAddress), action: "trigger_escape", newOwnerPubkey }),
12065
+ completeEscapeOwner: (guardianSealed, targetAddress) => manage(guardianSealed, { owner: normalizeWalletAddress(targetAddress), action: "complete_escape" }),
12066
+ cancelEscape: (sealed) => manage(sealed, { owner: sealed.address, action: "cancel_escape" }),
12067
+ addDevice: (sealed, devicePubkey) => manage(sealed, { owner: sealed.address, action: "add_owner", pubkey: devicePubkey }),
12068
+ removeDevice: (sealed, ownerGuid) => manage(sealed, { owner: sealed.address, action: "remove_owner", ownerGuid }),
12083
12069
  completeDeployment: (onStep, options) => deployments.run(onStep, options),
12084
12070
  isDeploying: () => deployments.isDeploying()
12085
12071
  };