@unifold/core 0.1.25 → 0.1.26

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.mts CHANGED
@@ -374,6 +374,7 @@ interface PaymentNetwork {
374
374
  icon_urls: IconUrl[];
375
375
  }
376
376
  interface ProjectConfigResponse {
377
+ project_name?: string;
377
378
  asset_cdn_url: string;
378
379
  transfer_crypto: {
379
380
  networks: FeaturedToken[];
@@ -488,6 +489,48 @@ interface VerifyAddressResponse {
488
489
  * @returns Verification result with valid status and reason if invalid
489
490
  */
490
491
  declare function verifyRecipientAddress(request: VerifyAddressRequest, publishableKey?: string): Promise<VerifyAddressResponse>;
492
+ interface BuildSolanaTransactionRequest {
493
+ chain_id: string;
494
+ token_address: string;
495
+ source_address: string;
496
+ destination_address: string;
497
+ amount: string;
498
+ }
499
+ interface BuildSolanaTransactionResponse {
500
+ encoding: 'base64';
501
+ transaction: string;
502
+ }
503
+ /**
504
+ * Build a Solana transaction for transferring SOL or SPL tokens.
505
+ * Returns an unsigned VersionedTransaction that must be signed by the user's wallet.
506
+ *
507
+ * Features:
508
+ * - Native SOL transfers (use "native" as token_address)
509
+ * - SPL Token transfers (standard Token Program)
510
+ * - SPL Token-2022 transfers (Token Extensions)
511
+ * - Automatic ATA (Associated Token Account) creation with idempotency
512
+ *
513
+ * @param request - Transaction details including chain_id, token_address, source/destination addresses, and amount
514
+ * @param publishableKey - Optional publishable key, defaults to configured key
515
+ * @returns Unsigned transaction in base64 format that needs to be signed by the wallet
516
+ */
517
+ declare function buildSolanaTransaction(request: BuildSolanaTransactionRequest, publishableKey?: string): Promise<BuildSolanaTransactionResponse>;
518
+ interface SendSolanaTransactionRequest {
519
+ chain_id: string;
520
+ signed_transaction: string;
521
+ }
522
+ interface SendSolanaTransactionResponse {
523
+ signature: string;
524
+ }
525
+ /**
526
+ * Send a signed Solana transaction to the network.
527
+ * The transaction must have been previously built using buildSolanaTransaction() and signed by the user's wallet.
528
+ *
529
+ * @param request - Contains chain_id and the signed transaction in base64 format
530
+ * @param publishableKey - Optional publishable key, defaults to configured key
531
+ * @returns Transaction signature (hash) that can be used to track the transaction
532
+ */
533
+ declare function sendSolanaTransaction(request: SendSolanaTransactionRequest, publishableKey?: string): Promise<SendSolanaTransactionResponse>;
491
534
 
492
535
  /**
493
536
  * User IP information interface
@@ -583,4 +626,4 @@ declare const i18n: {
583
626
  };
584
627
  type I18nStrings = typeof i18n;
585
628
 
586
- export { type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type CreateDepositAddressRequest, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type I18nStrings, type IconUrl, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SupportedChain, type SupportedDepositTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, createDepositAddress, createOnrampSession, getAddressBalance, getAddressBalances, getApiBaseUrl, getChainName, getDefaultOnrampToken, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, pollDirectExecutions, queryExecutions, setApiConfig, useUserIp, verifyRecipientAddress };
629
+ export { type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type CreateDepositAddressRequest, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type I18nStrings, type IconUrl, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SupportedChain, type SupportedDepositTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, buildSolanaTransaction, createDepositAddress, createOnrampSession, getAddressBalance, getAddressBalances, getApiBaseUrl, getChainName, getDefaultOnrampToken, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, pollDirectExecutions, queryExecutions, sendSolanaTransaction, setApiConfig, useUserIp, verifyRecipientAddress };
package/dist/index.d.ts CHANGED
@@ -374,6 +374,7 @@ interface PaymentNetwork {
374
374
  icon_urls: IconUrl[];
375
375
  }
376
376
  interface ProjectConfigResponse {
377
+ project_name?: string;
377
378
  asset_cdn_url: string;
378
379
  transfer_crypto: {
379
380
  networks: FeaturedToken[];
@@ -488,6 +489,48 @@ interface VerifyAddressResponse {
488
489
  * @returns Verification result with valid status and reason if invalid
489
490
  */
490
491
  declare function verifyRecipientAddress(request: VerifyAddressRequest, publishableKey?: string): Promise<VerifyAddressResponse>;
492
+ interface BuildSolanaTransactionRequest {
493
+ chain_id: string;
494
+ token_address: string;
495
+ source_address: string;
496
+ destination_address: string;
497
+ amount: string;
498
+ }
499
+ interface BuildSolanaTransactionResponse {
500
+ encoding: 'base64';
501
+ transaction: string;
502
+ }
503
+ /**
504
+ * Build a Solana transaction for transferring SOL or SPL tokens.
505
+ * Returns an unsigned VersionedTransaction that must be signed by the user's wallet.
506
+ *
507
+ * Features:
508
+ * - Native SOL transfers (use "native" as token_address)
509
+ * - SPL Token transfers (standard Token Program)
510
+ * - SPL Token-2022 transfers (Token Extensions)
511
+ * - Automatic ATA (Associated Token Account) creation with idempotency
512
+ *
513
+ * @param request - Transaction details including chain_id, token_address, source/destination addresses, and amount
514
+ * @param publishableKey - Optional publishable key, defaults to configured key
515
+ * @returns Unsigned transaction in base64 format that needs to be signed by the wallet
516
+ */
517
+ declare function buildSolanaTransaction(request: BuildSolanaTransactionRequest, publishableKey?: string): Promise<BuildSolanaTransactionResponse>;
518
+ interface SendSolanaTransactionRequest {
519
+ chain_id: string;
520
+ signed_transaction: string;
521
+ }
522
+ interface SendSolanaTransactionResponse {
523
+ signature: string;
524
+ }
525
+ /**
526
+ * Send a signed Solana transaction to the network.
527
+ * The transaction must have been previously built using buildSolanaTransaction() and signed by the user's wallet.
528
+ *
529
+ * @param request - Contains chain_id and the signed transaction in base64 format
530
+ * @param publishableKey - Optional publishable key, defaults to configured key
531
+ * @returns Transaction signature (hash) that can be used to track the transaction
532
+ */
533
+ declare function sendSolanaTransaction(request: SendSolanaTransactionRequest, publishableKey?: string): Promise<SendSolanaTransactionResponse>;
491
534
 
492
535
  /**
493
536
  * User IP information interface
@@ -583,4 +626,4 @@ declare const i18n: {
583
626
  };
584
627
  type I18nStrings = typeof i18n;
585
628
 
586
- export { type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type CreateDepositAddressRequest, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type I18nStrings, type IconUrl, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SupportedChain, type SupportedDepositTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, createDepositAddress, createOnrampSession, getAddressBalance, getAddressBalances, getApiBaseUrl, getChainName, getDefaultOnrampToken, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, pollDirectExecutions, queryExecutions, setApiConfig, useUserIp, verifyRecipientAddress };
629
+ export { type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type CreateDepositAddressRequest, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type I18nStrings, type IconUrl, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SupportedChain, type SupportedDepositTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, buildSolanaTransaction, createDepositAddress, createOnrampSession, getAddressBalance, getAddressBalances, getApiBaseUrl, getChainName, getDefaultOnrampToken, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, pollDirectExecutions, queryExecutions, sendSolanaTransaction, setApiConfig, useUserIp, verifyRecipientAddress };
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  ExecutionStatus: () => ExecutionStatus,
24
24
  SOLANA_USDC_ADDRESS: () => SOLANA_USDC_ADDRESS,
25
+ buildSolanaTransaction: () => buildSolanaTransaction,
25
26
  createDepositAddress: () => createDepositAddress,
26
27
  createOnrampSession: () => createOnrampSession,
27
28
  getAddressBalance: () => getAddressBalance,
@@ -44,6 +45,7 @@ __export(index_exports, {
44
45
  i18n: () => i18n,
45
46
  pollDirectExecutions: () => pollDirectExecutions,
46
47
  queryExecutions: () => queryExecutions,
48
+ sendSolanaTransaction: () => sendSolanaTransaction,
47
49
  setApiConfig: () => setApiConfig,
48
50
  useUserIp: () => useUserIp,
49
51
  verifyRecipientAddress: () => verifyRecipientAddress
@@ -460,6 +462,46 @@ async function verifyRecipientAddress(request, publishableKey) {
460
462
  }
461
463
  return response.json();
462
464
  }
465
+ async function buildSolanaTransaction(request, publishableKey) {
466
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
467
+ validatePublishableKey(pk);
468
+ const response = await fetch(`${API_BASE_URL}/v1/public/transactions/solana/build`, {
469
+ method: "POST",
470
+ headers: {
471
+ accept: "application/json",
472
+ "x-publishable-key": pk,
473
+ "Content-Type": "application/json"
474
+ },
475
+ body: JSON.stringify(request)
476
+ });
477
+ if (!response.ok) {
478
+ const error = await response.json().catch(() => ({ message: response.statusText }));
479
+ throw new Error(
480
+ `Failed to build Solana transaction: ${error.message || response.statusText}`
481
+ );
482
+ }
483
+ return response.json();
484
+ }
485
+ async function sendSolanaTransaction(request, publishableKey) {
486
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
487
+ validatePublishableKey(pk);
488
+ const response = await fetch(`${API_BASE_URL}/v1/public/transactions/solana/send`, {
489
+ method: "POST",
490
+ headers: {
491
+ accept: "application/json",
492
+ "x-publishable-key": pk,
493
+ "Content-Type": "application/json"
494
+ },
495
+ body: JSON.stringify(request)
496
+ });
497
+ if (!response.ok) {
498
+ const error = await response.json().catch(() => ({ message: response.statusText }));
499
+ throw new Error(
500
+ `Failed to send Solana transaction: ${error.message || response.statusText}`
501
+ );
502
+ }
503
+ return response.json();
504
+ }
463
505
 
464
506
  // src/hooks/use-user-ip.ts
465
507
  var import_react_query = require("@tanstack/react-query");
@@ -568,6 +610,7 @@ var i18n = en_default;
568
610
  0 && (module.exports = {
569
611
  ExecutionStatus,
570
612
  SOLANA_USDC_ADDRESS,
613
+ buildSolanaTransaction,
571
614
  createDepositAddress,
572
615
  createOnrampSession,
573
616
  getAddressBalance,
@@ -590,6 +633,7 @@ var i18n = en_default;
590
633
  i18n,
591
634
  pollDirectExecutions,
592
635
  queryExecutions,
636
+ sendSolanaTransaction,
593
637
  setApiConfig,
594
638
  useUserIp,
595
639
  verifyRecipientAddress
package/dist/index.mjs CHANGED
@@ -408,6 +408,46 @@ async function verifyRecipientAddress(request, publishableKey) {
408
408
  }
409
409
  return response.json();
410
410
  }
411
+ async function buildSolanaTransaction(request, publishableKey) {
412
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
413
+ validatePublishableKey(pk);
414
+ const response = await fetch(`${API_BASE_URL}/v1/public/transactions/solana/build`, {
415
+ method: "POST",
416
+ headers: {
417
+ accept: "application/json",
418
+ "x-publishable-key": pk,
419
+ "Content-Type": "application/json"
420
+ },
421
+ body: JSON.stringify(request)
422
+ });
423
+ if (!response.ok) {
424
+ const error = await response.json().catch(() => ({ message: response.statusText }));
425
+ throw new Error(
426
+ `Failed to build Solana transaction: ${error.message || response.statusText}`
427
+ );
428
+ }
429
+ return response.json();
430
+ }
431
+ async function sendSolanaTransaction(request, publishableKey) {
432
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
433
+ validatePublishableKey(pk);
434
+ const response = await fetch(`${API_BASE_URL}/v1/public/transactions/solana/send`, {
435
+ method: "POST",
436
+ headers: {
437
+ accept: "application/json",
438
+ "x-publishable-key": pk,
439
+ "Content-Type": "application/json"
440
+ },
441
+ body: JSON.stringify(request)
442
+ });
443
+ if (!response.ok) {
444
+ const error = await response.json().catch(() => ({ message: response.statusText }));
445
+ throw new Error(
446
+ `Failed to send Solana transaction: ${error.message || response.statusText}`
447
+ );
448
+ }
449
+ return response.json();
450
+ }
411
451
 
412
452
  // src/hooks/use-user-ip.ts
413
453
  import { useQuery } from "@tanstack/react-query";
@@ -515,6 +555,7 @@ var i18n = en_default;
515
555
  export {
516
556
  ExecutionStatus,
517
557
  SOLANA_USDC_ADDRESS,
558
+ buildSolanaTransaction,
518
559
  createDepositAddress,
519
560
  createOnrampSession,
520
561
  getAddressBalance,
@@ -537,6 +578,7 @@ export {
537
578
  i18n,
538
579
  pollDirectExecutions,
539
580
  queryExecutions,
581
+ sendSolanaTransaction,
540
582
  setApiConfig,
541
583
  useUserIp,
542
584
  verifyRecipientAddress
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/core",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "Unifold Core SDK - Core types, API client, and business logic",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",