@frontiertower/frontier-sdk 0.3.3 → 0.5.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/README.md +13 -0
- package/dist/index.d.mts +312 -10
- package/dist/index.d.ts +312 -10
- package/dist/index.js +235 -0
- package/dist/index.mjs +233 -0
- package/package.json +2 -5
package/README.md
CHANGED
|
@@ -51,6 +51,10 @@ Your app must declare required permissions in the Frontier app registry:
|
|
|
51
51
|
- `wallet:transferNative` - Transfer native currency (ETH)
|
|
52
52
|
- `wallet:transferFrontierDollar` - Transfer Frontier Dollars
|
|
53
53
|
- `wallet:executeCall` - Execute arbitrary contract calls
|
|
54
|
+
- `wallet:executeBatchCall` - Execute multiple contract calls atomically
|
|
55
|
+
- `wallet:getSupportedTokens` - Get list of supported tokens for swaps
|
|
56
|
+
- `wallet:swap` - Execute token swaps (same-chain or cross-chain)
|
|
57
|
+
- `wallet:quoteSwap` - Get quotes for token swaps
|
|
54
58
|
|
|
55
59
|
### Storage Permissions
|
|
56
60
|
- `storage:get` - Read from storage
|
|
@@ -65,6 +69,15 @@ Your app must declare required permissions in the Frontier app registry:
|
|
|
65
69
|
- `user:getReferralDetails` - Access detailed referral information
|
|
66
70
|
- `user:addUserContact` - Add user contact information
|
|
67
71
|
|
|
72
|
+
### Partnerships Permissions
|
|
73
|
+
- `partnerships:listSponsors` - List sponsors you manage (paginated)
|
|
74
|
+
- `partnerships:getSponsor` - Retrieve a Sponsor by ID
|
|
75
|
+
- `partnerships:createSponsorPass` - Create a SponsorPass
|
|
76
|
+
- `partnerships:listActiveSponsorPasses` - List active SponsorPasses (paginated)
|
|
77
|
+
- `partnerships:listAllSponsorPasses` - List all SponsorPasses (paginated)
|
|
78
|
+
- `partnerships:getSponsorPass` - Retrieve a SponsorPass by ID
|
|
79
|
+
- `partnerships:revokeSponsorPass` - Revoke a SponsorPass by ID
|
|
80
|
+
|
|
68
81
|
### Chain Permissions
|
|
69
82
|
- `chain:getCurrentNetwork` - Get current network name
|
|
70
83
|
- `chain:getAvailableNetworks` - Get list of available networks
|
package/dist/index.d.mts
CHANGED
|
@@ -54,6 +54,60 @@ interface ExecuteCall {
|
|
|
54
54
|
/** Calldata */
|
|
55
55
|
data: string;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Swap parameters for token swaps
|
|
59
|
+
*/
|
|
60
|
+
interface SwapParams {
|
|
61
|
+
/** Symbol of the token to swap from (e.g., 'USDC') */
|
|
62
|
+
sourceToken: string;
|
|
63
|
+
/** Symbol of the token to swap to (e.g., 'WETH') */
|
|
64
|
+
targetToken: string;
|
|
65
|
+
/** Network identifier for source chain (e.g., 'base') */
|
|
66
|
+
sourceNetwork: string;
|
|
67
|
+
/** Network identifier for target chain (e.g., 'ethereum') */
|
|
68
|
+
targetNetwork: string;
|
|
69
|
+
/** Amount to swap in human-readable format (e.g., '100.5') */
|
|
70
|
+
amount: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Swap result status
|
|
74
|
+
*/
|
|
75
|
+
declare enum SwapResultStatus {
|
|
76
|
+
COMPLETED = "COMPLETED",
|
|
77
|
+
SUBMITTED = "SUBMITTED"
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Result of a swap operation
|
|
81
|
+
*/
|
|
82
|
+
interface SwapResult {
|
|
83
|
+
/** Source chain configuration */
|
|
84
|
+
sourceChain: object;
|
|
85
|
+
/** Target chain configuration */
|
|
86
|
+
targetChain: object;
|
|
87
|
+
/** Source token configuration */
|
|
88
|
+
sourceToken: object;
|
|
89
|
+
/** Target token configuration */
|
|
90
|
+
targetToken: object;
|
|
91
|
+
/** Status of the swap */
|
|
92
|
+
status: SwapResultStatus;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Quote for a swap operation
|
|
96
|
+
*/
|
|
97
|
+
interface SwapQuote {
|
|
98
|
+
/** Source chain configuration */
|
|
99
|
+
sourceChain: object;
|
|
100
|
+
/** Target chain configuration */
|
|
101
|
+
targetChain: object;
|
|
102
|
+
/** Source token configuration */
|
|
103
|
+
sourceToken: object;
|
|
104
|
+
/** Target token configuration */
|
|
105
|
+
targetToken: object;
|
|
106
|
+
/** Expected output amount in human-readable format */
|
|
107
|
+
expectedAmountOut: string;
|
|
108
|
+
/** Minimum output amount in human-readable format */
|
|
109
|
+
minAmountOut: string;
|
|
110
|
+
}
|
|
57
111
|
/**
|
|
58
112
|
* Wallet access class for interacting with the user's wallet
|
|
59
113
|
*
|
|
@@ -256,6 +310,103 @@ declare class WalletAccess {
|
|
|
256
310
|
* ```
|
|
257
311
|
*/
|
|
258
312
|
transferFrontierDollar(to: string, amount: string, overrides?: GasOverrides): Promise<UserOperationReceipt>;
|
|
313
|
+
/**
|
|
314
|
+
* Execute multiple calls atomically with a single signature
|
|
315
|
+
*
|
|
316
|
+
* Executes multiple contract interactions in a single transaction.
|
|
317
|
+
* All calls are executed atomically - if one fails, all fail.
|
|
318
|
+
*
|
|
319
|
+
* @param calls - Array of execute call parameters
|
|
320
|
+
* @param overrides - Optional gas overrides
|
|
321
|
+
* @returns User operation receipt with transaction details
|
|
322
|
+
* @throws {Error} If any transaction fails
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```typescript
|
|
326
|
+
* import { encodeFunctionData } from 'viem';
|
|
327
|
+
*
|
|
328
|
+
* const receipt = await sdk.getWallet().executeBatchCall([
|
|
329
|
+
* {
|
|
330
|
+
* to: '0xToken1',
|
|
331
|
+
* value: 0n,
|
|
332
|
+
* data: encodeFunctionData({ abi: erc20Abi, functionName: 'approve', args: [...] })
|
|
333
|
+
* },
|
|
334
|
+
* {
|
|
335
|
+
* to: '0xProtocol',
|
|
336
|
+
* value: 0n,
|
|
337
|
+
* data: encodeFunctionData({ abi: protocolAbi, functionName: 'deposit', args: [...] })
|
|
338
|
+
* }
|
|
339
|
+
* ]);
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
executeBatchCall(calls: ExecuteCall[], overrides?: GasOverrides): Promise<UserOperationReceipt>;
|
|
343
|
+
/**
|
|
344
|
+
* Get list of supported token symbols for the current chain
|
|
345
|
+
*
|
|
346
|
+
* Returns an array of token symbols that are supported for swaps
|
|
347
|
+
* and other operations on the current network.
|
|
348
|
+
*
|
|
349
|
+
* @returns Array of token symbols (e.g., ['FTD', 'USDC', 'WETH'])
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* ```typescript
|
|
353
|
+
* const tokens = await sdk.getWallet().getSupportedTokens();
|
|
354
|
+
* console.log('Supported tokens:', tokens); // ['FTD', 'USDC', 'WETH']
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
getSupportedTokens(): Promise<string[]>;
|
|
358
|
+
/**
|
|
359
|
+
* Execute a token swap
|
|
360
|
+
*
|
|
361
|
+
* @param sourceToken - Symbol of the token to swap from (e.g., 'USDC')
|
|
362
|
+
* @param targetToken - Symbol of the token to swap to (e.g., 'WETH')
|
|
363
|
+
* @param sourceNetwork - Network identifier for source chain (e.g., 'base')
|
|
364
|
+
* @param targetNetwork - Network identifier for target chain (e.g., 'ethereum')
|
|
365
|
+
* @param amount - Amount to swap in human-readable format (e.g., '100.5')
|
|
366
|
+
* @returns Swap result with status and transaction details
|
|
367
|
+
* @throws {Error} If swap fails or tokens/networks are not supported
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```typescript
|
|
371
|
+
* const result = await sdk.getWallet().swap(
|
|
372
|
+
* 'USDC',
|
|
373
|
+
* 'WETH',
|
|
374
|
+
* 'base',
|
|
375
|
+
* 'ethereum',
|
|
376
|
+
* '100.5'
|
|
377
|
+
* );
|
|
378
|
+
* console.log('Swap status:', result.status);
|
|
379
|
+
* ```
|
|
380
|
+
*/
|
|
381
|
+
swap(sourceToken: string, targetToken: string, sourceNetwork: string, targetNetwork: string, amount: string): Promise<SwapResult>;
|
|
382
|
+
/**
|
|
383
|
+
* Get a quote for a token swap without executing it
|
|
384
|
+
*
|
|
385
|
+
* Returns the expected output amount for a given swap.
|
|
386
|
+
* Useful for displaying swap previews to users before confirmation.
|
|
387
|
+
*
|
|
388
|
+
* @param sourceToken - Symbol of the token to swap from (e.g., 'USDC')
|
|
389
|
+
* @param targetToken - Symbol of the token to swap to (e.g., 'WETH')
|
|
390
|
+
* @param sourceNetwork - Network identifier for source chain (e.g., 'base')
|
|
391
|
+
* @param targetNetwork - Network identifier for target chain (e.g., 'ethereum')
|
|
392
|
+
* @param amount - Amount to swap in human-readable format (e.g., '100.5')
|
|
393
|
+
* @returns Quote with expected and minimum output amounts
|
|
394
|
+
* @throws {Error} If tokens/networks are not supported
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```typescript
|
|
398
|
+
* const quote = await sdk.getWallet().quoteSwap(
|
|
399
|
+
* 'USDC',
|
|
400
|
+
* 'WETH',
|
|
401
|
+
* 'base',
|
|
402
|
+
* 'ethereum',
|
|
403
|
+
* '100.5'
|
|
404
|
+
* );
|
|
405
|
+
* console.log('Expected output:', quote.expectedAmountOut);
|
|
406
|
+
* console.log('Minimum output:', quote.minAmountOut);
|
|
407
|
+
* ```
|
|
408
|
+
*/
|
|
409
|
+
quoteSwap(sourceToken: string, targetToken: string, sourceNetwork: string, targetNetwork: string, amount: string): Promise<SwapQuote>;
|
|
259
410
|
}
|
|
260
411
|
|
|
261
412
|
/**
|
|
@@ -497,16 +648,16 @@ interface ReferralOverview {
|
|
|
497
648
|
* Detailed referral information
|
|
498
649
|
*/
|
|
499
650
|
interface ReferralDetails {
|
|
500
|
-
/**
|
|
501
|
-
|
|
502
|
-
/**
|
|
651
|
+
/** Name of the referred user */
|
|
652
|
+
name: string;
|
|
653
|
+
/** Email of the referred user */
|
|
503
654
|
email: string;
|
|
504
|
-
/**
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
|
|
655
|
+
/** Date when the referral was made */
|
|
656
|
+
referralDate: string;
|
|
657
|
+
/** Reward information (if any) */
|
|
658
|
+
reward: string;
|
|
659
|
+
/** Status of the referral */
|
|
660
|
+
status: string;
|
|
510
661
|
}
|
|
511
662
|
/**
|
|
512
663
|
* Single contact entry
|
|
@@ -636,6 +787,152 @@ declare class UserAccess {
|
|
|
636
787
|
addUserContact(data: UserContactPayload): Promise<void>;
|
|
637
788
|
}
|
|
638
789
|
|
|
790
|
+
/**
|
|
791
|
+
* Sponsor passes API
|
|
792
|
+
*
|
|
793
|
+
* Sponsor pass creation and management
|
|
794
|
+
*/
|
|
795
|
+
type SponsorPassStatus = 'active' | 'revoked';
|
|
796
|
+
interface SponsorPass {
|
|
797
|
+
id: number;
|
|
798
|
+
sponsor: number;
|
|
799
|
+
sponsorName: string;
|
|
800
|
+
firstName: string;
|
|
801
|
+
lastName: string;
|
|
802
|
+
email: string;
|
|
803
|
+
status: SponsorPassStatus;
|
|
804
|
+
expiresAt: string | null;
|
|
805
|
+
createdAt: string;
|
|
806
|
+
updatedAt: string;
|
|
807
|
+
revokedAt: string | null;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Payload for creating a SponsorPass.
|
|
811
|
+
*/
|
|
812
|
+
interface CreateSponsorPassRequest {
|
|
813
|
+
sponsor: number;
|
|
814
|
+
firstName: string;
|
|
815
|
+
lastName: string;
|
|
816
|
+
email: string;
|
|
817
|
+
expiresAt?: string;
|
|
818
|
+
}
|
|
819
|
+
interface ListSponsorPassesParams {
|
|
820
|
+
limit?: number;
|
|
821
|
+
offset?: number;
|
|
822
|
+
}
|
|
823
|
+
interface ListAllSponsorPassesParams extends ListSponsorPassesParams {
|
|
824
|
+
includeRevoked?: boolean;
|
|
825
|
+
}
|
|
826
|
+
interface Sponsor {
|
|
827
|
+
id: number;
|
|
828
|
+
name: string;
|
|
829
|
+
dailyRate: string;
|
|
830
|
+
notes: string;
|
|
831
|
+
createdAt: string;
|
|
832
|
+
updatedAt: string;
|
|
833
|
+
}
|
|
834
|
+
interface ListSponsorsParams {
|
|
835
|
+
limit?: number;
|
|
836
|
+
offset?: number;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Partnerships access class for interacting with partnership-related features.
|
|
840
|
+
*
|
|
841
|
+
* This class provides methods to:
|
|
842
|
+
* - Create SponsorPasses
|
|
843
|
+
* - List active SponsorPasses
|
|
844
|
+
* - List all SponsorPasses (optionally including revoked)
|
|
845
|
+
* - Retrieve and revoke SponsorPasses
|
|
846
|
+
*/
|
|
847
|
+
declare class PartnershipsAccess {
|
|
848
|
+
private sdk;
|
|
849
|
+
constructor(sdk: FrontierSDK);
|
|
850
|
+
/**
|
|
851
|
+
* Create a SponsorPass
|
|
852
|
+
* Requires permission: `partnerships:createSponsorPass` or `partnerships:*`
|
|
853
|
+
*
|
|
854
|
+
* @param payload - SponsorPass creation payload
|
|
855
|
+
* @returns Created SponsorPass
|
|
856
|
+
*
|
|
857
|
+
* @example
|
|
858
|
+
* ```typescript
|
|
859
|
+
* const pass = await sdk.getPartnerships().createSponsorPass({
|
|
860
|
+
* sponsor: 123,
|
|
861
|
+
* firstName: 'Ada',
|
|
862
|
+
* lastName: 'Lovelace',
|
|
863
|
+
* email: 'ada@example.com',
|
|
864
|
+
* });
|
|
865
|
+
* console.log('Created SponsorPass:', pass.id);
|
|
866
|
+
* ```
|
|
867
|
+
*/
|
|
868
|
+
createSponsorPass(payload: CreateSponsorPassRequest): Promise<SponsorPass>;
|
|
869
|
+
/**
|
|
870
|
+
* List active SponsorPasses (paginated)
|
|
871
|
+
* Requires permission: `partnerships:listActiveSponsorPasses` or `partnerships:*`
|
|
872
|
+
*
|
|
873
|
+
* @param payload.limit - Maximum number of results to return
|
|
874
|
+
* @param payload.offset - Offset into the result set
|
|
875
|
+
* @returns Paginated response of active SponsorPasses
|
|
876
|
+
*
|
|
877
|
+
* @example
|
|
878
|
+
* ```typescript
|
|
879
|
+
* const active = await sdk.getPartnerships().listActiveSponsorPasses({ limit: 20, offset: 0 });
|
|
880
|
+
* console.log('Active count:', active.count);
|
|
881
|
+
* ```
|
|
882
|
+
*/
|
|
883
|
+
listActiveSponsorPasses(payload?: ListSponsorPassesParams): Promise<PaginatedResponse<SponsorPass>>;
|
|
884
|
+
/**
|
|
885
|
+
* List all SponsorPasses (paginated)
|
|
886
|
+
* Requires permission: `partnerships:listAllSponsorPasses` or `partnerships:*`
|
|
887
|
+
*
|
|
888
|
+
* @param payload.includeRevoked - When true, include revoked passes
|
|
889
|
+
* @returns Paginated response of SponsorPasses
|
|
890
|
+
*
|
|
891
|
+
* @example
|
|
892
|
+
* ```typescript
|
|
893
|
+
* const all = await sdk.getPartnerships().listAllSponsorPasses({ includeRevoked: true, limit: 50, offset: 0 });
|
|
894
|
+
* console.log('Total passes:', all.count);
|
|
895
|
+
* ```
|
|
896
|
+
*/
|
|
897
|
+
listAllSponsorPasses(payload?: ListAllSponsorPassesParams): Promise<PaginatedResponse<SponsorPass>>;
|
|
898
|
+
listSponsors(payload?: ListSponsorsParams): Promise<PaginatedResponse<Sponsor>>;
|
|
899
|
+
getSponsor(payload: {
|
|
900
|
+
id: number;
|
|
901
|
+
}): Promise<Sponsor>;
|
|
902
|
+
/**
|
|
903
|
+
* Retrieve a specific SponsorPass by ID
|
|
904
|
+
* Requires permission: `partnerships:getSponsorPass` or `partnerships:*`
|
|
905
|
+
*
|
|
906
|
+
* @param payload.id - SponsorPass ID
|
|
907
|
+
* @returns SponsorPass
|
|
908
|
+
*
|
|
909
|
+
* @example
|
|
910
|
+
* ```typescript
|
|
911
|
+
* const pass = await sdk.getPartnerships().getSponsorPass({ id: 123 });
|
|
912
|
+
* console.log('SponsorPass:', pass);
|
|
913
|
+
* ```
|
|
914
|
+
*/
|
|
915
|
+
getSponsorPass(payload: {
|
|
916
|
+
id: number;
|
|
917
|
+
}): Promise<SponsorPass>;
|
|
918
|
+
/**
|
|
919
|
+
* Revoke a SponsorPass by ID
|
|
920
|
+
* Requires permission: `partnerships:revokeSponsorPass` or `partnerships:*`
|
|
921
|
+
*
|
|
922
|
+
* Note: backend revokes (does not delete).
|
|
923
|
+
*
|
|
924
|
+
* @param payload.id - SponsorPass ID
|
|
925
|
+
*
|
|
926
|
+
* @example
|
|
927
|
+
* ```typescript
|
|
928
|
+
* await sdk.getPartnerships().revokeSponsorPass({ id: 123 });
|
|
929
|
+
* ```
|
|
930
|
+
*/
|
|
931
|
+
revokeSponsorPass(payload: {
|
|
932
|
+
id: number;
|
|
933
|
+
}): Promise<void>;
|
|
934
|
+
}
|
|
935
|
+
|
|
639
936
|
declare class FrontierSDK {
|
|
640
937
|
private requestId;
|
|
641
938
|
private pendingRequests;
|
|
@@ -643,6 +940,7 @@ declare class FrontierSDK {
|
|
|
643
940
|
private storage;
|
|
644
941
|
private chain;
|
|
645
942
|
private user;
|
|
943
|
+
private partnerships;
|
|
646
944
|
constructor();
|
|
647
945
|
private handleMessage;
|
|
648
946
|
/**
|
|
@@ -667,6 +965,10 @@ declare class FrontierSDK {
|
|
|
667
965
|
* Get user access instance
|
|
668
966
|
*/
|
|
669
967
|
getUser(): UserAccess;
|
|
968
|
+
/**
|
|
969
|
+
* Get partnerships access instance
|
|
970
|
+
*/
|
|
971
|
+
getPartnerships(): PartnershipsAccess;
|
|
670
972
|
/**
|
|
671
973
|
* Cleanup: Remove event listeners
|
|
672
974
|
* Call this when your app is being destroyed
|
|
@@ -686,4 +988,4 @@ interface SDKResponse {
|
|
|
686
988
|
error?: string;
|
|
687
989
|
}
|
|
688
990
|
|
|
689
|
-
export { ChainAccess, type ChainConfig, type ExecuteCall, FrontierSDK, type GasOverrides, type PaginatedResponse, type ReferralDetails, type ReferralOverview, type SDKRequest, type SDKResponse, type SmartAccount, StorageAccess, type User, UserAccess, type UserContact, type UserContactPayload, type UserOperationReceipt, type UserProfile, WalletAccess };
|
|
991
|
+
export { ChainAccess, type ChainConfig, type CreateSponsorPassRequest, type ExecuteCall, FrontierSDK, type GasOverrides, type ListSponsorsParams, type PaginatedResponse, PartnershipsAccess, type ReferralDetails, type ReferralOverview, type SDKRequest, type SDKResponse, type SmartAccount, type Sponsor, type SponsorPass, StorageAccess, type SwapParams, type SwapQuote, type SwapResult, SwapResultStatus, type User, UserAccess, type UserContact, type UserContactPayload, type UserOperationReceipt, type UserProfile, WalletAccess };
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,60 @@ interface ExecuteCall {
|
|
|
54
54
|
/** Calldata */
|
|
55
55
|
data: string;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Swap parameters for token swaps
|
|
59
|
+
*/
|
|
60
|
+
interface SwapParams {
|
|
61
|
+
/** Symbol of the token to swap from (e.g., 'USDC') */
|
|
62
|
+
sourceToken: string;
|
|
63
|
+
/** Symbol of the token to swap to (e.g., 'WETH') */
|
|
64
|
+
targetToken: string;
|
|
65
|
+
/** Network identifier for source chain (e.g., 'base') */
|
|
66
|
+
sourceNetwork: string;
|
|
67
|
+
/** Network identifier for target chain (e.g., 'ethereum') */
|
|
68
|
+
targetNetwork: string;
|
|
69
|
+
/** Amount to swap in human-readable format (e.g., '100.5') */
|
|
70
|
+
amount: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Swap result status
|
|
74
|
+
*/
|
|
75
|
+
declare enum SwapResultStatus {
|
|
76
|
+
COMPLETED = "COMPLETED",
|
|
77
|
+
SUBMITTED = "SUBMITTED"
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Result of a swap operation
|
|
81
|
+
*/
|
|
82
|
+
interface SwapResult {
|
|
83
|
+
/** Source chain configuration */
|
|
84
|
+
sourceChain: object;
|
|
85
|
+
/** Target chain configuration */
|
|
86
|
+
targetChain: object;
|
|
87
|
+
/** Source token configuration */
|
|
88
|
+
sourceToken: object;
|
|
89
|
+
/** Target token configuration */
|
|
90
|
+
targetToken: object;
|
|
91
|
+
/** Status of the swap */
|
|
92
|
+
status: SwapResultStatus;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Quote for a swap operation
|
|
96
|
+
*/
|
|
97
|
+
interface SwapQuote {
|
|
98
|
+
/** Source chain configuration */
|
|
99
|
+
sourceChain: object;
|
|
100
|
+
/** Target chain configuration */
|
|
101
|
+
targetChain: object;
|
|
102
|
+
/** Source token configuration */
|
|
103
|
+
sourceToken: object;
|
|
104
|
+
/** Target token configuration */
|
|
105
|
+
targetToken: object;
|
|
106
|
+
/** Expected output amount in human-readable format */
|
|
107
|
+
expectedAmountOut: string;
|
|
108
|
+
/** Minimum output amount in human-readable format */
|
|
109
|
+
minAmountOut: string;
|
|
110
|
+
}
|
|
57
111
|
/**
|
|
58
112
|
* Wallet access class for interacting with the user's wallet
|
|
59
113
|
*
|
|
@@ -256,6 +310,103 @@ declare class WalletAccess {
|
|
|
256
310
|
* ```
|
|
257
311
|
*/
|
|
258
312
|
transferFrontierDollar(to: string, amount: string, overrides?: GasOverrides): Promise<UserOperationReceipt>;
|
|
313
|
+
/**
|
|
314
|
+
* Execute multiple calls atomically with a single signature
|
|
315
|
+
*
|
|
316
|
+
* Executes multiple contract interactions in a single transaction.
|
|
317
|
+
* All calls are executed atomically - if one fails, all fail.
|
|
318
|
+
*
|
|
319
|
+
* @param calls - Array of execute call parameters
|
|
320
|
+
* @param overrides - Optional gas overrides
|
|
321
|
+
* @returns User operation receipt with transaction details
|
|
322
|
+
* @throws {Error} If any transaction fails
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```typescript
|
|
326
|
+
* import { encodeFunctionData } from 'viem';
|
|
327
|
+
*
|
|
328
|
+
* const receipt = await sdk.getWallet().executeBatchCall([
|
|
329
|
+
* {
|
|
330
|
+
* to: '0xToken1',
|
|
331
|
+
* value: 0n,
|
|
332
|
+
* data: encodeFunctionData({ abi: erc20Abi, functionName: 'approve', args: [...] })
|
|
333
|
+
* },
|
|
334
|
+
* {
|
|
335
|
+
* to: '0xProtocol',
|
|
336
|
+
* value: 0n,
|
|
337
|
+
* data: encodeFunctionData({ abi: protocolAbi, functionName: 'deposit', args: [...] })
|
|
338
|
+
* }
|
|
339
|
+
* ]);
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
executeBatchCall(calls: ExecuteCall[], overrides?: GasOverrides): Promise<UserOperationReceipt>;
|
|
343
|
+
/**
|
|
344
|
+
* Get list of supported token symbols for the current chain
|
|
345
|
+
*
|
|
346
|
+
* Returns an array of token symbols that are supported for swaps
|
|
347
|
+
* and other operations on the current network.
|
|
348
|
+
*
|
|
349
|
+
* @returns Array of token symbols (e.g., ['FTD', 'USDC', 'WETH'])
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* ```typescript
|
|
353
|
+
* const tokens = await sdk.getWallet().getSupportedTokens();
|
|
354
|
+
* console.log('Supported tokens:', tokens); // ['FTD', 'USDC', 'WETH']
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
getSupportedTokens(): Promise<string[]>;
|
|
358
|
+
/**
|
|
359
|
+
* Execute a token swap
|
|
360
|
+
*
|
|
361
|
+
* @param sourceToken - Symbol of the token to swap from (e.g., 'USDC')
|
|
362
|
+
* @param targetToken - Symbol of the token to swap to (e.g., 'WETH')
|
|
363
|
+
* @param sourceNetwork - Network identifier for source chain (e.g., 'base')
|
|
364
|
+
* @param targetNetwork - Network identifier for target chain (e.g., 'ethereum')
|
|
365
|
+
* @param amount - Amount to swap in human-readable format (e.g., '100.5')
|
|
366
|
+
* @returns Swap result with status and transaction details
|
|
367
|
+
* @throws {Error} If swap fails or tokens/networks are not supported
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```typescript
|
|
371
|
+
* const result = await sdk.getWallet().swap(
|
|
372
|
+
* 'USDC',
|
|
373
|
+
* 'WETH',
|
|
374
|
+
* 'base',
|
|
375
|
+
* 'ethereum',
|
|
376
|
+
* '100.5'
|
|
377
|
+
* );
|
|
378
|
+
* console.log('Swap status:', result.status);
|
|
379
|
+
* ```
|
|
380
|
+
*/
|
|
381
|
+
swap(sourceToken: string, targetToken: string, sourceNetwork: string, targetNetwork: string, amount: string): Promise<SwapResult>;
|
|
382
|
+
/**
|
|
383
|
+
* Get a quote for a token swap without executing it
|
|
384
|
+
*
|
|
385
|
+
* Returns the expected output amount for a given swap.
|
|
386
|
+
* Useful for displaying swap previews to users before confirmation.
|
|
387
|
+
*
|
|
388
|
+
* @param sourceToken - Symbol of the token to swap from (e.g., 'USDC')
|
|
389
|
+
* @param targetToken - Symbol of the token to swap to (e.g., 'WETH')
|
|
390
|
+
* @param sourceNetwork - Network identifier for source chain (e.g., 'base')
|
|
391
|
+
* @param targetNetwork - Network identifier for target chain (e.g., 'ethereum')
|
|
392
|
+
* @param amount - Amount to swap in human-readable format (e.g., '100.5')
|
|
393
|
+
* @returns Quote with expected and minimum output amounts
|
|
394
|
+
* @throws {Error} If tokens/networks are not supported
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```typescript
|
|
398
|
+
* const quote = await sdk.getWallet().quoteSwap(
|
|
399
|
+
* 'USDC',
|
|
400
|
+
* 'WETH',
|
|
401
|
+
* 'base',
|
|
402
|
+
* 'ethereum',
|
|
403
|
+
* '100.5'
|
|
404
|
+
* );
|
|
405
|
+
* console.log('Expected output:', quote.expectedAmountOut);
|
|
406
|
+
* console.log('Minimum output:', quote.minAmountOut);
|
|
407
|
+
* ```
|
|
408
|
+
*/
|
|
409
|
+
quoteSwap(sourceToken: string, targetToken: string, sourceNetwork: string, targetNetwork: string, amount: string): Promise<SwapQuote>;
|
|
259
410
|
}
|
|
260
411
|
|
|
261
412
|
/**
|
|
@@ -497,16 +648,16 @@ interface ReferralOverview {
|
|
|
497
648
|
* Detailed referral information
|
|
498
649
|
*/
|
|
499
650
|
interface ReferralDetails {
|
|
500
|
-
/**
|
|
501
|
-
|
|
502
|
-
/**
|
|
651
|
+
/** Name of the referred user */
|
|
652
|
+
name: string;
|
|
653
|
+
/** Email of the referred user */
|
|
503
654
|
email: string;
|
|
504
|
-
/**
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
|
|
655
|
+
/** Date when the referral was made */
|
|
656
|
+
referralDate: string;
|
|
657
|
+
/** Reward information (if any) */
|
|
658
|
+
reward: string;
|
|
659
|
+
/** Status of the referral */
|
|
660
|
+
status: string;
|
|
510
661
|
}
|
|
511
662
|
/**
|
|
512
663
|
* Single contact entry
|
|
@@ -636,6 +787,152 @@ declare class UserAccess {
|
|
|
636
787
|
addUserContact(data: UserContactPayload): Promise<void>;
|
|
637
788
|
}
|
|
638
789
|
|
|
790
|
+
/**
|
|
791
|
+
* Sponsor passes API
|
|
792
|
+
*
|
|
793
|
+
* Sponsor pass creation and management
|
|
794
|
+
*/
|
|
795
|
+
type SponsorPassStatus = 'active' | 'revoked';
|
|
796
|
+
interface SponsorPass {
|
|
797
|
+
id: number;
|
|
798
|
+
sponsor: number;
|
|
799
|
+
sponsorName: string;
|
|
800
|
+
firstName: string;
|
|
801
|
+
lastName: string;
|
|
802
|
+
email: string;
|
|
803
|
+
status: SponsorPassStatus;
|
|
804
|
+
expiresAt: string | null;
|
|
805
|
+
createdAt: string;
|
|
806
|
+
updatedAt: string;
|
|
807
|
+
revokedAt: string | null;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Payload for creating a SponsorPass.
|
|
811
|
+
*/
|
|
812
|
+
interface CreateSponsorPassRequest {
|
|
813
|
+
sponsor: number;
|
|
814
|
+
firstName: string;
|
|
815
|
+
lastName: string;
|
|
816
|
+
email: string;
|
|
817
|
+
expiresAt?: string;
|
|
818
|
+
}
|
|
819
|
+
interface ListSponsorPassesParams {
|
|
820
|
+
limit?: number;
|
|
821
|
+
offset?: number;
|
|
822
|
+
}
|
|
823
|
+
interface ListAllSponsorPassesParams extends ListSponsorPassesParams {
|
|
824
|
+
includeRevoked?: boolean;
|
|
825
|
+
}
|
|
826
|
+
interface Sponsor {
|
|
827
|
+
id: number;
|
|
828
|
+
name: string;
|
|
829
|
+
dailyRate: string;
|
|
830
|
+
notes: string;
|
|
831
|
+
createdAt: string;
|
|
832
|
+
updatedAt: string;
|
|
833
|
+
}
|
|
834
|
+
interface ListSponsorsParams {
|
|
835
|
+
limit?: number;
|
|
836
|
+
offset?: number;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Partnerships access class for interacting with partnership-related features.
|
|
840
|
+
*
|
|
841
|
+
* This class provides methods to:
|
|
842
|
+
* - Create SponsorPasses
|
|
843
|
+
* - List active SponsorPasses
|
|
844
|
+
* - List all SponsorPasses (optionally including revoked)
|
|
845
|
+
* - Retrieve and revoke SponsorPasses
|
|
846
|
+
*/
|
|
847
|
+
declare class PartnershipsAccess {
|
|
848
|
+
private sdk;
|
|
849
|
+
constructor(sdk: FrontierSDK);
|
|
850
|
+
/**
|
|
851
|
+
* Create a SponsorPass
|
|
852
|
+
* Requires permission: `partnerships:createSponsorPass` or `partnerships:*`
|
|
853
|
+
*
|
|
854
|
+
* @param payload - SponsorPass creation payload
|
|
855
|
+
* @returns Created SponsorPass
|
|
856
|
+
*
|
|
857
|
+
* @example
|
|
858
|
+
* ```typescript
|
|
859
|
+
* const pass = await sdk.getPartnerships().createSponsorPass({
|
|
860
|
+
* sponsor: 123,
|
|
861
|
+
* firstName: 'Ada',
|
|
862
|
+
* lastName: 'Lovelace',
|
|
863
|
+
* email: 'ada@example.com',
|
|
864
|
+
* });
|
|
865
|
+
* console.log('Created SponsorPass:', pass.id);
|
|
866
|
+
* ```
|
|
867
|
+
*/
|
|
868
|
+
createSponsorPass(payload: CreateSponsorPassRequest): Promise<SponsorPass>;
|
|
869
|
+
/**
|
|
870
|
+
* List active SponsorPasses (paginated)
|
|
871
|
+
* Requires permission: `partnerships:listActiveSponsorPasses` or `partnerships:*`
|
|
872
|
+
*
|
|
873
|
+
* @param payload.limit - Maximum number of results to return
|
|
874
|
+
* @param payload.offset - Offset into the result set
|
|
875
|
+
* @returns Paginated response of active SponsorPasses
|
|
876
|
+
*
|
|
877
|
+
* @example
|
|
878
|
+
* ```typescript
|
|
879
|
+
* const active = await sdk.getPartnerships().listActiveSponsorPasses({ limit: 20, offset: 0 });
|
|
880
|
+
* console.log('Active count:', active.count);
|
|
881
|
+
* ```
|
|
882
|
+
*/
|
|
883
|
+
listActiveSponsorPasses(payload?: ListSponsorPassesParams): Promise<PaginatedResponse<SponsorPass>>;
|
|
884
|
+
/**
|
|
885
|
+
* List all SponsorPasses (paginated)
|
|
886
|
+
* Requires permission: `partnerships:listAllSponsorPasses` or `partnerships:*`
|
|
887
|
+
*
|
|
888
|
+
* @param payload.includeRevoked - When true, include revoked passes
|
|
889
|
+
* @returns Paginated response of SponsorPasses
|
|
890
|
+
*
|
|
891
|
+
* @example
|
|
892
|
+
* ```typescript
|
|
893
|
+
* const all = await sdk.getPartnerships().listAllSponsorPasses({ includeRevoked: true, limit: 50, offset: 0 });
|
|
894
|
+
* console.log('Total passes:', all.count);
|
|
895
|
+
* ```
|
|
896
|
+
*/
|
|
897
|
+
listAllSponsorPasses(payload?: ListAllSponsorPassesParams): Promise<PaginatedResponse<SponsorPass>>;
|
|
898
|
+
listSponsors(payload?: ListSponsorsParams): Promise<PaginatedResponse<Sponsor>>;
|
|
899
|
+
getSponsor(payload: {
|
|
900
|
+
id: number;
|
|
901
|
+
}): Promise<Sponsor>;
|
|
902
|
+
/**
|
|
903
|
+
* Retrieve a specific SponsorPass by ID
|
|
904
|
+
* Requires permission: `partnerships:getSponsorPass` or `partnerships:*`
|
|
905
|
+
*
|
|
906
|
+
* @param payload.id - SponsorPass ID
|
|
907
|
+
* @returns SponsorPass
|
|
908
|
+
*
|
|
909
|
+
* @example
|
|
910
|
+
* ```typescript
|
|
911
|
+
* const pass = await sdk.getPartnerships().getSponsorPass({ id: 123 });
|
|
912
|
+
* console.log('SponsorPass:', pass);
|
|
913
|
+
* ```
|
|
914
|
+
*/
|
|
915
|
+
getSponsorPass(payload: {
|
|
916
|
+
id: number;
|
|
917
|
+
}): Promise<SponsorPass>;
|
|
918
|
+
/**
|
|
919
|
+
* Revoke a SponsorPass by ID
|
|
920
|
+
* Requires permission: `partnerships:revokeSponsorPass` or `partnerships:*`
|
|
921
|
+
*
|
|
922
|
+
* Note: backend revokes (does not delete).
|
|
923
|
+
*
|
|
924
|
+
* @param payload.id - SponsorPass ID
|
|
925
|
+
*
|
|
926
|
+
* @example
|
|
927
|
+
* ```typescript
|
|
928
|
+
* await sdk.getPartnerships().revokeSponsorPass({ id: 123 });
|
|
929
|
+
* ```
|
|
930
|
+
*/
|
|
931
|
+
revokeSponsorPass(payload: {
|
|
932
|
+
id: number;
|
|
933
|
+
}): Promise<void>;
|
|
934
|
+
}
|
|
935
|
+
|
|
639
936
|
declare class FrontierSDK {
|
|
640
937
|
private requestId;
|
|
641
938
|
private pendingRequests;
|
|
@@ -643,6 +940,7 @@ declare class FrontierSDK {
|
|
|
643
940
|
private storage;
|
|
644
941
|
private chain;
|
|
645
942
|
private user;
|
|
943
|
+
private partnerships;
|
|
646
944
|
constructor();
|
|
647
945
|
private handleMessage;
|
|
648
946
|
/**
|
|
@@ -667,6 +965,10 @@ declare class FrontierSDK {
|
|
|
667
965
|
* Get user access instance
|
|
668
966
|
*/
|
|
669
967
|
getUser(): UserAccess;
|
|
968
|
+
/**
|
|
969
|
+
* Get partnerships access instance
|
|
970
|
+
*/
|
|
971
|
+
getPartnerships(): PartnershipsAccess;
|
|
670
972
|
/**
|
|
671
973
|
* Cleanup: Remove event listeners
|
|
672
974
|
* Call this when your app is being destroyed
|
|
@@ -686,4 +988,4 @@ interface SDKResponse {
|
|
|
686
988
|
error?: string;
|
|
687
989
|
}
|
|
688
990
|
|
|
689
|
-
export { ChainAccess, type ChainConfig, type ExecuteCall, FrontierSDK, type GasOverrides, type PaginatedResponse, type ReferralDetails, type ReferralOverview, type SDKRequest, type SDKResponse, type SmartAccount, StorageAccess, type User, UserAccess, type UserContact, type UserContactPayload, type UserOperationReceipt, type UserProfile, WalletAccess };
|
|
991
|
+
export { ChainAccess, type ChainConfig, type CreateSponsorPassRequest, type ExecuteCall, FrontierSDK, type GasOverrides, type ListSponsorsParams, type PaginatedResponse, PartnershipsAccess, type ReferralDetails, type ReferralOverview, type SDKRequest, type SDKResponse, type SmartAccount, type Sponsor, type SponsorPass, StorageAccess, type SwapParams, type SwapQuote, type SwapResult, SwapResultStatus, type User, UserAccess, type UserContact, type UserContactPayload, type UserOperationReceipt, type UserProfile, WalletAccess };
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,9 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ChainAccess: () => ChainAccess,
|
|
24
24
|
FrontierSDK: () => FrontierSDK,
|
|
25
|
+
PartnershipsAccess: () => PartnershipsAccess,
|
|
25
26
|
StorageAccess: () => StorageAccess,
|
|
27
|
+
SwapResultStatus: () => SwapResultStatus,
|
|
26
28
|
UserAccess: () => UserAccess,
|
|
27
29
|
WalletAccess: () => WalletAccess,
|
|
28
30
|
createStandaloneHTML: () => createStandaloneHTML,
|
|
@@ -33,6 +35,11 @@ __export(index_exports, {
|
|
|
33
35
|
module.exports = __toCommonJS(index_exports);
|
|
34
36
|
|
|
35
37
|
// src/access/wallet.ts
|
|
38
|
+
var SwapResultStatus = /* @__PURE__ */ ((SwapResultStatus2) => {
|
|
39
|
+
SwapResultStatus2["COMPLETED"] = "COMPLETED";
|
|
40
|
+
SwapResultStatus2["SUBMITTED"] = "SUBMITTED";
|
|
41
|
+
return SwapResultStatus2;
|
|
42
|
+
})(SwapResultStatus || {});
|
|
36
43
|
var WalletAccess = class {
|
|
37
44
|
constructor(sdk) {
|
|
38
45
|
this.sdk = sdk;
|
|
@@ -263,6 +270,126 @@ var WalletAccess = class {
|
|
|
263
270
|
overrides
|
|
264
271
|
});
|
|
265
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* Execute multiple calls atomically with a single signature
|
|
275
|
+
*
|
|
276
|
+
* Executes multiple contract interactions in a single transaction.
|
|
277
|
+
* All calls are executed atomically - if one fails, all fail.
|
|
278
|
+
*
|
|
279
|
+
* @param calls - Array of execute call parameters
|
|
280
|
+
* @param overrides - Optional gas overrides
|
|
281
|
+
* @returns User operation receipt with transaction details
|
|
282
|
+
* @throws {Error} If any transaction fails
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```typescript
|
|
286
|
+
* import { encodeFunctionData } from 'viem';
|
|
287
|
+
*
|
|
288
|
+
* const receipt = await sdk.getWallet().executeBatchCall([
|
|
289
|
+
* {
|
|
290
|
+
* to: '0xToken1',
|
|
291
|
+
* value: 0n,
|
|
292
|
+
* data: encodeFunctionData({ abi: erc20Abi, functionName: 'approve', args: [...] })
|
|
293
|
+
* },
|
|
294
|
+
* {
|
|
295
|
+
* to: '0xProtocol',
|
|
296
|
+
* value: 0n,
|
|
297
|
+
* data: encodeFunctionData({ abi: protocolAbi, functionName: 'deposit', args: [...] })
|
|
298
|
+
* }
|
|
299
|
+
* ]);
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
async executeBatchCall(calls, overrides) {
|
|
303
|
+
return this.sdk.request("wallet:executeBatchCall", {
|
|
304
|
+
calls,
|
|
305
|
+
overrides
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Get list of supported token symbols for the current chain
|
|
310
|
+
*
|
|
311
|
+
* Returns an array of token symbols that are supported for swaps
|
|
312
|
+
* and other operations on the current network.
|
|
313
|
+
*
|
|
314
|
+
* @returns Array of token symbols (e.g., ['FTD', 'USDC', 'WETH'])
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```typescript
|
|
318
|
+
* const tokens = await sdk.getWallet().getSupportedTokens();
|
|
319
|
+
* console.log('Supported tokens:', tokens); // ['FTD', 'USDC', 'WETH']
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
async getSupportedTokens() {
|
|
323
|
+
return this.sdk.request("wallet:getSupportedTokens");
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Execute a token swap
|
|
327
|
+
*
|
|
328
|
+
* @param sourceToken - Symbol of the token to swap from (e.g., 'USDC')
|
|
329
|
+
* @param targetToken - Symbol of the token to swap to (e.g., 'WETH')
|
|
330
|
+
* @param sourceNetwork - Network identifier for source chain (e.g., 'base')
|
|
331
|
+
* @param targetNetwork - Network identifier for target chain (e.g., 'ethereum')
|
|
332
|
+
* @param amount - Amount to swap in human-readable format (e.g., '100.5')
|
|
333
|
+
* @returns Swap result with status and transaction details
|
|
334
|
+
* @throws {Error} If swap fails or tokens/networks are not supported
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```typescript
|
|
338
|
+
* const result = await sdk.getWallet().swap(
|
|
339
|
+
* 'USDC',
|
|
340
|
+
* 'WETH',
|
|
341
|
+
* 'base',
|
|
342
|
+
* 'ethereum',
|
|
343
|
+
* '100.5'
|
|
344
|
+
* );
|
|
345
|
+
* console.log('Swap status:', result.status);
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
async swap(sourceToken, targetToken, sourceNetwork, targetNetwork, amount) {
|
|
349
|
+
return this.sdk.request("wallet:swap", {
|
|
350
|
+
sourceToken,
|
|
351
|
+
targetToken,
|
|
352
|
+
sourceNetwork,
|
|
353
|
+
targetNetwork,
|
|
354
|
+
amount
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Get a quote for a token swap without executing it
|
|
359
|
+
*
|
|
360
|
+
* Returns the expected output amount for a given swap.
|
|
361
|
+
* Useful for displaying swap previews to users before confirmation.
|
|
362
|
+
*
|
|
363
|
+
* @param sourceToken - Symbol of the token to swap from (e.g., 'USDC')
|
|
364
|
+
* @param targetToken - Symbol of the token to swap to (e.g., 'WETH')
|
|
365
|
+
* @param sourceNetwork - Network identifier for source chain (e.g., 'base')
|
|
366
|
+
* @param targetNetwork - Network identifier for target chain (e.g., 'ethereum')
|
|
367
|
+
* @param amount - Amount to swap in human-readable format (e.g., '100.5')
|
|
368
|
+
* @returns Quote with expected and minimum output amounts
|
|
369
|
+
* @throws {Error} If tokens/networks are not supported
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* const quote = await sdk.getWallet().quoteSwap(
|
|
374
|
+
* 'USDC',
|
|
375
|
+
* 'WETH',
|
|
376
|
+
* 'base',
|
|
377
|
+
* 'ethereum',
|
|
378
|
+
* '100.5'
|
|
379
|
+
* );
|
|
380
|
+
* console.log('Expected output:', quote.expectedAmountOut);
|
|
381
|
+
* console.log('Minimum output:', quote.minAmountOut);
|
|
382
|
+
* ```
|
|
383
|
+
*/
|
|
384
|
+
async quoteSwap(sourceToken, targetToken, sourceNetwork, targetNetwork, amount) {
|
|
385
|
+
return this.sdk.request("wallet:quoteSwap", {
|
|
386
|
+
sourceToken,
|
|
387
|
+
targetToken,
|
|
388
|
+
sourceNetwork,
|
|
389
|
+
targetNetwork,
|
|
390
|
+
amount
|
|
391
|
+
});
|
|
392
|
+
}
|
|
266
393
|
};
|
|
267
394
|
|
|
268
395
|
// src/access/storage.ts
|
|
@@ -487,6 +614,105 @@ var UserAccess = class {
|
|
|
487
614
|
}
|
|
488
615
|
};
|
|
489
616
|
|
|
617
|
+
// src/access/partnerships.ts
|
|
618
|
+
var PartnershipsAccess = class {
|
|
619
|
+
constructor(sdk) {
|
|
620
|
+
this.sdk = sdk;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Create a SponsorPass
|
|
624
|
+
* Requires permission: `partnerships:createSponsorPass` or `partnerships:*`
|
|
625
|
+
*
|
|
626
|
+
* @param payload - SponsorPass creation payload
|
|
627
|
+
* @returns Created SponsorPass
|
|
628
|
+
*
|
|
629
|
+
* @example
|
|
630
|
+
* ```typescript
|
|
631
|
+
* const pass = await sdk.getPartnerships().createSponsorPass({
|
|
632
|
+
* sponsor: 123,
|
|
633
|
+
* firstName: 'Ada',
|
|
634
|
+
* lastName: 'Lovelace',
|
|
635
|
+
* email: 'ada@example.com',
|
|
636
|
+
* });
|
|
637
|
+
* console.log('Created SponsorPass:', pass.id);
|
|
638
|
+
* ```
|
|
639
|
+
*/
|
|
640
|
+
async createSponsorPass(payload) {
|
|
641
|
+
return this.sdk.request("partnerships:createSponsorPass", payload);
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* List active SponsorPasses (paginated)
|
|
645
|
+
* Requires permission: `partnerships:listActiveSponsorPasses` or `partnerships:*`
|
|
646
|
+
*
|
|
647
|
+
* @param payload.limit - Maximum number of results to return
|
|
648
|
+
* @param payload.offset - Offset into the result set
|
|
649
|
+
* @returns Paginated response of active SponsorPasses
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
* ```typescript
|
|
653
|
+
* const active = await sdk.getPartnerships().listActiveSponsorPasses({ limit: 20, offset: 0 });
|
|
654
|
+
* console.log('Active count:', active.count);
|
|
655
|
+
* ```
|
|
656
|
+
*/
|
|
657
|
+
async listActiveSponsorPasses(payload) {
|
|
658
|
+
return this.sdk.request("partnerships:listActiveSponsorPasses", payload);
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* List all SponsorPasses (paginated)
|
|
662
|
+
* Requires permission: `partnerships:listAllSponsorPasses` or `partnerships:*`
|
|
663
|
+
*
|
|
664
|
+
* @param payload.includeRevoked - When true, include revoked passes
|
|
665
|
+
* @returns Paginated response of SponsorPasses
|
|
666
|
+
*
|
|
667
|
+
* @example
|
|
668
|
+
* ```typescript
|
|
669
|
+
* const all = await sdk.getPartnerships().listAllSponsorPasses({ includeRevoked: true, limit: 50, offset: 0 });
|
|
670
|
+
* console.log('Total passes:', all.count);
|
|
671
|
+
* ```
|
|
672
|
+
*/
|
|
673
|
+
async listAllSponsorPasses(payload) {
|
|
674
|
+
return this.sdk.request("partnerships:listAllSponsorPasses", payload);
|
|
675
|
+
}
|
|
676
|
+
async listSponsors(payload) {
|
|
677
|
+
return this.sdk.request("partnerships:listSponsors", payload);
|
|
678
|
+
}
|
|
679
|
+
async getSponsor(payload) {
|
|
680
|
+
return this.sdk.request("partnerships:getSponsor", payload);
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Retrieve a specific SponsorPass by ID
|
|
684
|
+
* Requires permission: `partnerships:getSponsorPass` or `partnerships:*`
|
|
685
|
+
*
|
|
686
|
+
* @param payload.id - SponsorPass ID
|
|
687
|
+
* @returns SponsorPass
|
|
688
|
+
*
|
|
689
|
+
* @example
|
|
690
|
+
* ```typescript
|
|
691
|
+
* const pass = await sdk.getPartnerships().getSponsorPass({ id: 123 });
|
|
692
|
+
* console.log('SponsorPass:', pass);
|
|
693
|
+
* ```
|
|
694
|
+
*/
|
|
695
|
+
async getSponsorPass(payload) {
|
|
696
|
+
return this.sdk.request("partnerships:getSponsorPass", payload);
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Revoke a SponsorPass by ID
|
|
700
|
+
* Requires permission: `partnerships:revokeSponsorPass` or `partnerships:*`
|
|
701
|
+
*
|
|
702
|
+
* Note: backend revokes (does not delete).
|
|
703
|
+
*
|
|
704
|
+
* @param payload.id - SponsorPass ID
|
|
705
|
+
*
|
|
706
|
+
* @example
|
|
707
|
+
* ```typescript
|
|
708
|
+
* await sdk.getPartnerships().revokeSponsorPass({ id: 123 });
|
|
709
|
+
* ```
|
|
710
|
+
*/
|
|
711
|
+
async revokeSponsorPass(payload) {
|
|
712
|
+
return this.sdk.request("partnerships:revokeSponsorPass", payload);
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
|
|
490
716
|
// src/sdk.ts
|
|
491
717
|
var FrontierSDK = class {
|
|
492
718
|
constructor() {
|
|
@@ -509,6 +735,7 @@ var FrontierSDK = class {
|
|
|
509
735
|
this.storage = new StorageAccess(this);
|
|
510
736
|
this.chain = new ChainAccess(this);
|
|
511
737
|
this.user = new UserAccess(this);
|
|
738
|
+
this.partnerships = new PartnershipsAccess(this);
|
|
512
739
|
window.addEventListener("message", this.handleMessage);
|
|
513
740
|
this.notifyReady();
|
|
514
741
|
}
|
|
@@ -557,6 +784,12 @@ var FrontierSDK = class {
|
|
|
557
784
|
getUser() {
|
|
558
785
|
return this.user;
|
|
559
786
|
}
|
|
787
|
+
/**
|
|
788
|
+
* Get partnerships access instance
|
|
789
|
+
*/
|
|
790
|
+
getPartnerships() {
|
|
791
|
+
return this.partnerships;
|
|
792
|
+
}
|
|
560
793
|
/**
|
|
561
794
|
* Cleanup: Remove event listeners
|
|
562
795
|
* Call this when your app is being destroyed
|
|
@@ -779,7 +1012,9 @@ function createStandaloneHTML(appName = "Frontier App") {
|
|
|
779
1012
|
0 && (module.exports = {
|
|
780
1013
|
ChainAccess,
|
|
781
1014
|
FrontierSDK,
|
|
1015
|
+
PartnershipsAccess,
|
|
782
1016
|
StorageAccess,
|
|
1017
|
+
SwapResultStatus,
|
|
783
1018
|
UserAccess,
|
|
784
1019
|
WalletAccess,
|
|
785
1020
|
createStandaloneHTML,
|
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,11 @@ import {
|
|
|
6
6
|
} from "./chunk-7VB6TETG.mjs";
|
|
7
7
|
|
|
8
8
|
// src/access/wallet.ts
|
|
9
|
+
var SwapResultStatus = /* @__PURE__ */ ((SwapResultStatus2) => {
|
|
10
|
+
SwapResultStatus2["COMPLETED"] = "COMPLETED";
|
|
11
|
+
SwapResultStatus2["SUBMITTED"] = "SUBMITTED";
|
|
12
|
+
return SwapResultStatus2;
|
|
13
|
+
})(SwapResultStatus || {});
|
|
9
14
|
var WalletAccess = class {
|
|
10
15
|
constructor(sdk) {
|
|
11
16
|
this.sdk = sdk;
|
|
@@ -236,6 +241,126 @@ var WalletAccess = class {
|
|
|
236
241
|
overrides
|
|
237
242
|
});
|
|
238
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Execute multiple calls atomically with a single signature
|
|
246
|
+
*
|
|
247
|
+
* Executes multiple contract interactions in a single transaction.
|
|
248
|
+
* All calls are executed atomically - if one fails, all fail.
|
|
249
|
+
*
|
|
250
|
+
* @param calls - Array of execute call parameters
|
|
251
|
+
* @param overrides - Optional gas overrides
|
|
252
|
+
* @returns User operation receipt with transaction details
|
|
253
|
+
* @throws {Error} If any transaction fails
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* import { encodeFunctionData } from 'viem';
|
|
258
|
+
*
|
|
259
|
+
* const receipt = await sdk.getWallet().executeBatchCall([
|
|
260
|
+
* {
|
|
261
|
+
* to: '0xToken1',
|
|
262
|
+
* value: 0n,
|
|
263
|
+
* data: encodeFunctionData({ abi: erc20Abi, functionName: 'approve', args: [...] })
|
|
264
|
+
* },
|
|
265
|
+
* {
|
|
266
|
+
* to: '0xProtocol',
|
|
267
|
+
* value: 0n,
|
|
268
|
+
* data: encodeFunctionData({ abi: protocolAbi, functionName: 'deposit', args: [...] })
|
|
269
|
+
* }
|
|
270
|
+
* ]);
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
async executeBatchCall(calls, overrides) {
|
|
274
|
+
return this.sdk.request("wallet:executeBatchCall", {
|
|
275
|
+
calls,
|
|
276
|
+
overrides
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Get list of supported token symbols for the current chain
|
|
281
|
+
*
|
|
282
|
+
* Returns an array of token symbols that are supported for swaps
|
|
283
|
+
* and other operations on the current network.
|
|
284
|
+
*
|
|
285
|
+
* @returns Array of token symbols (e.g., ['FTD', 'USDC', 'WETH'])
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```typescript
|
|
289
|
+
* const tokens = await sdk.getWallet().getSupportedTokens();
|
|
290
|
+
* console.log('Supported tokens:', tokens); // ['FTD', 'USDC', 'WETH']
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
async getSupportedTokens() {
|
|
294
|
+
return this.sdk.request("wallet:getSupportedTokens");
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Execute a token swap
|
|
298
|
+
*
|
|
299
|
+
* @param sourceToken - Symbol of the token to swap from (e.g., 'USDC')
|
|
300
|
+
* @param targetToken - Symbol of the token to swap to (e.g., 'WETH')
|
|
301
|
+
* @param sourceNetwork - Network identifier for source chain (e.g., 'base')
|
|
302
|
+
* @param targetNetwork - Network identifier for target chain (e.g., 'ethereum')
|
|
303
|
+
* @param amount - Amount to swap in human-readable format (e.g., '100.5')
|
|
304
|
+
* @returns Swap result with status and transaction details
|
|
305
|
+
* @throws {Error} If swap fails or tokens/networks are not supported
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* const result = await sdk.getWallet().swap(
|
|
310
|
+
* 'USDC',
|
|
311
|
+
* 'WETH',
|
|
312
|
+
* 'base',
|
|
313
|
+
* 'ethereum',
|
|
314
|
+
* '100.5'
|
|
315
|
+
* );
|
|
316
|
+
* console.log('Swap status:', result.status);
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
async swap(sourceToken, targetToken, sourceNetwork, targetNetwork, amount) {
|
|
320
|
+
return this.sdk.request("wallet:swap", {
|
|
321
|
+
sourceToken,
|
|
322
|
+
targetToken,
|
|
323
|
+
sourceNetwork,
|
|
324
|
+
targetNetwork,
|
|
325
|
+
amount
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Get a quote for a token swap without executing it
|
|
330
|
+
*
|
|
331
|
+
* Returns the expected output amount for a given swap.
|
|
332
|
+
* Useful for displaying swap previews to users before confirmation.
|
|
333
|
+
*
|
|
334
|
+
* @param sourceToken - Symbol of the token to swap from (e.g., 'USDC')
|
|
335
|
+
* @param targetToken - Symbol of the token to swap to (e.g., 'WETH')
|
|
336
|
+
* @param sourceNetwork - Network identifier for source chain (e.g., 'base')
|
|
337
|
+
* @param targetNetwork - Network identifier for target chain (e.g., 'ethereum')
|
|
338
|
+
* @param amount - Amount to swap in human-readable format (e.g., '100.5')
|
|
339
|
+
* @returns Quote with expected and minimum output amounts
|
|
340
|
+
* @throws {Error} If tokens/networks are not supported
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```typescript
|
|
344
|
+
* const quote = await sdk.getWallet().quoteSwap(
|
|
345
|
+
* 'USDC',
|
|
346
|
+
* 'WETH',
|
|
347
|
+
* 'base',
|
|
348
|
+
* 'ethereum',
|
|
349
|
+
* '100.5'
|
|
350
|
+
* );
|
|
351
|
+
* console.log('Expected output:', quote.expectedAmountOut);
|
|
352
|
+
* console.log('Minimum output:', quote.minAmountOut);
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
async quoteSwap(sourceToken, targetToken, sourceNetwork, targetNetwork, amount) {
|
|
356
|
+
return this.sdk.request("wallet:quoteSwap", {
|
|
357
|
+
sourceToken,
|
|
358
|
+
targetToken,
|
|
359
|
+
sourceNetwork,
|
|
360
|
+
targetNetwork,
|
|
361
|
+
amount
|
|
362
|
+
});
|
|
363
|
+
}
|
|
239
364
|
};
|
|
240
365
|
|
|
241
366
|
// src/access/storage.ts
|
|
@@ -460,6 +585,105 @@ var UserAccess = class {
|
|
|
460
585
|
}
|
|
461
586
|
};
|
|
462
587
|
|
|
588
|
+
// src/access/partnerships.ts
|
|
589
|
+
var PartnershipsAccess = class {
|
|
590
|
+
constructor(sdk) {
|
|
591
|
+
this.sdk = sdk;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Create a SponsorPass
|
|
595
|
+
* Requires permission: `partnerships:createSponsorPass` or `partnerships:*`
|
|
596
|
+
*
|
|
597
|
+
* @param payload - SponsorPass creation payload
|
|
598
|
+
* @returns Created SponsorPass
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* ```typescript
|
|
602
|
+
* const pass = await sdk.getPartnerships().createSponsorPass({
|
|
603
|
+
* sponsor: 123,
|
|
604
|
+
* firstName: 'Ada',
|
|
605
|
+
* lastName: 'Lovelace',
|
|
606
|
+
* email: 'ada@example.com',
|
|
607
|
+
* });
|
|
608
|
+
* console.log('Created SponsorPass:', pass.id);
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
async createSponsorPass(payload) {
|
|
612
|
+
return this.sdk.request("partnerships:createSponsorPass", payload);
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* List active SponsorPasses (paginated)
|
|
616
|
+
* Requires permission: `partnerships:listActiveSponsorPasses` or `partnerships:*`
|
|
617
|
+
*
|
|
618
|
+
* @param payload.limit - Maximum number of results to return
|
|
619
|
+
* @param payload.offset - Offset into the result set
|
|
620
|
+
* @returns Paginated response of active SponsorPasses
|
|
621
|
+
*
|
|
622
|
+
* @example
|
|
623
|
+
* ```typescript
|
|
624
|
+
* const active = await sdk.getPartnerships().listActiveSponsorPasses({ limit: 20, offset: 0 });
|
|
625
|
+
* console.log('Active count:', active.count);
|
|
626
|
+
* ```
|
|
627
|
+
*/
|
|
628
|
+
async listActiveSponsorPasses(payload) {
|
|
629
|
+
return this.sdk.request("partnerships:listActiveSponsorPasses", payload);
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* List all SponsorPasses (paginated)
|
|
633
|
+
* Requires permission: `partnerships:listAllSponsorPasses` or `partnerships:*`
|
|
634
|
+
*
|
|
635
|
+
* @param payload.includeRevoked - When true, include revoked passes
|
|
636
|
+
* @returns Paginated response of SponsorPasses
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* ```typescript
|
|
640
|
+
* const all = await sdk.getPartnerships().listAllSponsorPasses({ includeRevoked: true, limit: 50, offset: 0 });
|
|
641
|
+
* console.log('Total passes:', all.count);
|
|
642
|
+
* ```
|
|
643
|
+
*/
|
|
644
|
+
async listAllSponsorPasses(payload) {
|
|
645
|
+
return this.sdk.request("partnerships:listAllSponsorPasses", payload);
|
|
646
|
+
}
|
|
647
|
+
async listSponsors(payload) {
|
|
648
|
+
return this.sdk.request("partnerships:listSponsors", payload);
|
|
649
|
+
}
|
|
650
|
+
async getSponsor(payload) {
|
|
651
|
+
return this.sdk.request("partnerships:getSponsor", payload);
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Retrieve a specific SponsorPass by ID
|
|
655
|
+
* Requires permission: `partnerships:getSponsorPass` or `partnerships:*`
|
|
656
|
+
*
|
|
657
|
+
* @param payload.id - SponsorPass ID
|
|
658
|
+
* @returns SponsorPass
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* ```typescript
|
|
662
|
+
* const pass = await sdk.getPartnerships().getSponsorPass({ id: 123 });
|
|
663
|
+
* console.log('SponsorPass:', pass);
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
666
|
+
async getSponsorPass(payload) {
|
|
667
|
+
return this.sdk.request("partnerships:getSponsorPass", payload);
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Revoke a SponsorPass by ID
|
|
671
|
+
* Requires permission: `partnerships:revokeSponsorPass` or `partnerships:*`
|
|
672
|
+
*
|
|
673
|
+
* Note: backend revokes (does not delete).
|
|
674
|
+
*
|
|
675
|
+
* @param payload.id - SponsorPass ID
|
|
676
|
+
*
|
|
677
|
+
* @example
|
|
678
|
+
* ```typescript
|
|
679
|
+
* await sdk.getPartnerships().revokeSponsorPass({ id: 123 });
|
|
680
|
+
* ```
|
|
681
|
+
*/
|
|
682
|
+
async revokeSponsorPass(payload) {
|
|
683
|
+
return this.sdk.request("partnerships:revokeSponsorPass", payload);
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
|
|
463
687
|
// src/sdk.ts
|
|
464
688
|
var FrontierSDK = class {
|
|
465
689
|
constructor() {
|
|
@@ -482,6 +706,7 @@ var FrontierSDK = class {
|
|
|
482
706
|
this.storage = new StorageAccess(this);
|
|
483
707
|
this.chain = new ChainAccess(this);
|
|
484
708
|
this.user = new UserAccess(this);
|
|
709
|
+
this.partnerships = new PartnershipsAccess(this);
|
|
485
710
|
window.addEventListener("message", this.handleMessage);
|
|
486
711
|
this.notifyReady();
|
|
487
712
|
}
|
|
@@ -530,6 +755,12 @@ var FrontierSDK = class {
|
|
|
530
755
|
getUser() {
|
|
531
756
|
return this.user;
|
|
532
757
|
}
|
|
758
|
+
/**
|
|
759
|
+
* Get partnerships access instance
|
|
760
|
+
*/
|
|
761
|
+
getPartnerships() {
|
|
762
|
+
return this.partnerships;
|
|
763
|
+
}
|
|
533
764
|
/**
|
|
534
765
|
* Cleanup: Remove event listeners
|
|
535
766
|
* Call this when your app is being destroyed
|
|
@@ -542,7 +773,9 @@ var FrontierSDK = class {
|
|
|
542
773
|
export {
|
|
543
774
|
ChainAccess,
|
|
544
775
|
FrontierSDK,
|
|
776
|
+
PartnershipsAccess,
|
|
545
777
|
StorageAccess,
|
|
778
|
+
SwapResultStatus,
|
|
546
779
|
UserAccess,
|
|
547
780
|
WalletAccess,
|
|
548
781
|
createStandaloneHTML,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontiertower/frontier-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "SDK for building apps on Frontier Wallet",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -47,8 +47,5 @@
|
|
|
47
47
|
"type": "git",
|
|
48
48
|
"url": "git+https://github.com/BerlinhouseLabs/frontier-sdk.git"
|
|
49
49
|
},
|
|
50
|
-
"readme": "README.md"
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"@frontiertower/frontier-sdk": "^0.3.0"
|
|
53
|
-
}
|
|
50
|
+
"readme": "README.md"
|
|
54
51
|
}
|