@dcentralab/d402-client 0.3.7 → 0.3.8
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 +54 -42
- package/dist/index.d.ts +54 -42
- package/dist/index.js +5024 -194
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5026 -197
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Account } from 'viem/accounts';
|
|
2
2
|
import { WalletClient, PublicClient, Hash, Address } from 'viem';
|
|
3
|
+
import { Chain } from 'viem/chains';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Type definitions for D402 payment protocol
|
|
@@ -590,6 +591,23 @@ declare function decodePaymentResponse(header: string): {
|
|
|
590
591
|
message?: string;
|
|
591
592
|
};
|
|
592
593
|
|
|
594
|
+
/**
|
|
595
|
+
* Core type definitions shared across the package
|
|
596
|
+
*/
|
|
597
|
+
/**
|
|
598
|
+
* Supported blockchain networks (where IATP contracts are deployed)
|
|
599
|
+
*/
|
|
600
|
+
type SupportedNetwork = 'sepolia' | 'arbitrum';
|
|
601
|
+
/**
|
|
602
|
+
* EIP-712 domain for signature verification
|
|
603
|
+
*/
|
|
604
|
+
interface EIP712Domain {
|
|
605
|
+
name: string;
|
|
606
|
+
version: string;
|
|
607
|
+
chainId: number;
|
|
608
|
+
verifyingContract: `0x${string}`;
|
|
609
|
+
}
|
|
610
|
+
|
|
593
611
|
/**
|
|
594
612
|
* Type definitions for wallet module
|
|
595
613
|
*/
|
|
@@ -640,7 +658,7 @@ interface WithdrawalRequest {
|
|
|
640
658
|
*
|
|
641
659
|
* @param params - Creation parameters
|
|
642
660
|
* @param params.ownerAccount - Owner's account (will own the wallet)
|
|
643
|
-
* @param params.network - Network to deploy on (default: "sepolia")
|
|
661
|
+
* @param params.network - Network to deploy on: "sepolia" | "arbitrum" (default: "sepolia")
|
|
644
662
|
* @param params.rpcUrl - Custom RPC URL (optional)
|
|
645
663
|
* @returns Wallet creation result with addresses and keys
|
|
646
664
|
*
|
|
@@ -662,7 +680,7 @@ interface WithdrawalRequest {
|
|
|
662
680
|
declare function createIATPWallet(params: {
|
|
663
681
|
ownerAccount: Account;
|
|
664
682
|
walletClient?: WalletClient;
|
|
665
|
-
network?:
|
|
683
|
+
network?: SupportedNetwork;
|
|
666
684
|
rpcUrl?: string;
|
|
667
685
|
}): Promise<WalletCreationResult>;
|
|
668
686
|
|
|
@@ -680,7 +698,7 @@ declare function createIATPWallet(params: {
|
|
|
680
698
|
* @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
|
|
681
699
|
* @param params.walletAddress - IATPWallet contract address
|
|
682
700
|
* @param params.tokenAddress - Token contract address (e.g., USDC)
|
|
683
|
-
* @param params.network - Network to query (default: "sepolia")
|
|
701
|
+
* @param params.network - Network to query: "sepolia" | "arbitrum" (default: "sepolia")
|
|
684
702
|
* @returns Available balance in token's base units (wei)
|
|
685
703
|
*
|
|
686
704
|
* @example
|
|
@@ -703,7 +721,7 @@ declare function getAvailableBalance(params: {
|
|
|
703
721
|
publicClient: PublicClient;
|
|
704
722
|
walletAddress: Address;
|
|
705
723
|
tokenAddress: Address;
|
|
706
|
-
network?:
|
|
724
|
+
network?: SupportedNetwork;
|
|
707
725
|
}): Promise<bigint>;
|
|
708
726
|
/**
|
|
709
727
|
* Get all IATPWallet addresses owned by a user.
|
|
@@ -715,7 +733,7 @@ declare function getAvailableBalance(params: {
|
|
|
715
733
|
*
|
|
716
734
|
* @param params - Query parameters
|
|
717
735
|
* @param params.ownerAddress - User's wallet address (from MetaMask)
|
|
718
|
-
* @param params.network - Network to query (default: "sepolia")
|
|
736
|
+
* @param params.network - Network to query: "sepolia" | "arbitrum" (default: "sepolia")
|
|
719
737
|
* @param params.rpcUrl - Custom RPC URL (optional)
|
|
720
738
|
* @returns Array of IATPWallet contract addresses (empty if user has no wallets)
|
|
721
739
|
*
|
|
@@ -741,7 +759,7 @@ declare function getAvailableBalance(params: {
|
|
|
741
759
|
*/
|
|
742
760
|
declare function getWalletsByOwner(params: {
|
|
743
761
|
ownerAddress: Address;
|
|
744
|
-
network?:
|
|
762
|
+
network?: SupportedNetwork;
|
|
745
763
|
rpcUrl?: string;
|
|
746
764
|
}): Promise<Address[]>;
|
|
747
765
|
|
|
@@ -759,7 +777,7 @@ declare function getWalletsByOwner(params: {
|
|
|
759
777
|
* @param params.publicClient - Viem PublicClient
|
|
760
778
|
* @param params.walletAddress - IATPWallet contract address
|
|
761
779
|
* @param params.tokenAddress - Token contract address
|
|
762
|
-
* @param params.network - Network
|
|
780
|
+
* @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
763
781
|
* @returns Withdrawal request details or null if no request exists
|
|
764
782
|
*
|
|
765
783
|
* @example
|
|
@@ -788,7 +806,7 @@ declare function getWithdrawalRequest(params: {
|
|
|
788
806
|
publicClient: PublicClient;
|
|
789
807
|
walletAddress: Address;
|
|
790
808
|
tokenAddress: Address;
|
|
791
|
-
network?:
|
|
809
|
+
network?: SupportedNetwork;
|
|
792
810
|
}): Promise<{
|
|
793
811
|
request: WithdrawalRequest;
|
|
794
812
|
unlockTime: bigint;
|
|
@@ -806,7 +824,7 @@ declare function getWithdrawalRequest(params: {
|
|
|
806
824
|
* @param params.tokenAddress - Token contract address
|
|
807
825
|
* @param params.amount - Amount in token's base units (wei)
|
|
808
826
|
* @param params.account - Account to sign transaction (operator)
|
|
809
|
-
* @param params.network - Network (default: "sepolia")
|
|
827
|
+
* @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
810
828
|
* @returns Transaction hash
|
|
811
829
|
*
|
|
812
830
|
* @example
|
|
@@ -831,7 +849,7 @@ declare function requestWithdrawal(params: {
|
|
|
831
849
|
tokenAddress: Address;
|
|
832
850
|
amount: bigint;
|
|
833
851
|
account: Account;
|
|
834
|
-
network?:
|
|
852
|
+
network?: SupportedNetwork;
|
|
835
853
|
}): Promise<Hash>;
|
|
836
854
|
/**
|
|
837
855
|
* Execute a withdrawal from an IATPWallet (after unlock period).
|
|
@@ -845,7 +863,7 @@ declare function requestWithdrawal(params: {
|
|
|
845
863
|
* @param params.walletAddress - IATPWallet contract address
|
|
846
864
|
* @param params.tokenAddress - Token contract address
|
|
847
865
|
* @param params.account - Account to sign transaction (operator)
|
|
848
|
-
* @param params.network - Network (default: "sepolia")
|
|
866
|
+
* @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
849
867
|
* @returns Transaction hash
|
|
850
868
|
*
|
|
851
869
|
* @example
|
|
@@ -867,7 +885,7 @@ declare function executeWithdrawal(params: {
|
|
|
867
885
|
walletAddress: Address;
|
|
868
886
|
tokenAddress: Address;
|
|
869
887
|
account: Account;
|
|
870
|
-
network?:
|
|
888
|
+
network?: SupportedNetwork;
|
|
871
889
|
}): Promise<Hash>;
|
|
872
890
|
|
|
873
891
|
/**
|
|
@@ -987,7 +1005,7 @@ declare function extractToolResult(response: ParsedMcpResponse): unknown;
|
|
|
987
1005
|
* @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
|
|
988
1006
|
* @param params.providerAddress - Provider (utility agent) IATPWallet address
|
|
989
1007
|
* @param params.tokenAddress - Token contract address
|
|
990
|
-
* @param params.network - Network (default: "sepolia")
|
|
1008
|
+
* @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
991
1009
|
* @returns Locked balance in base units (wei)
|
|
992
1010
|
*
|
|
993
1011
|
* @example
|
|
@@ -1008,7 +1026,7 @@ declare function getLockedBalanceForProvider(params: {
|
|
|
1008
1026
|
publicClient: PublicClient;
|
|
1009
1027
|
providerAddress: Address;
|
|
1010
1028
|
tokenAddress: Address;
|
|
1011
|
-
network?:
|
|
1029
|
+
network?: SupportedNetwork;
|
|
1012
1030
|
}): Promise<bigint>;
|
|
1013
1031
|
/**
|
|
1014
1032
|
* Get unlocked balance for a provider across released epochs.
|
|
@@ -1020,7 +1038,7 @@ declare function getLockedBalanceForProvider(params: {
|
|
|
1020
1038
|
* @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
|
|
1021
1039
|
* @param params.providerAddress - Provider (utility agent) IATPWallet address
|
|
1022
1040
|
* @param params.tokenAddress - Token contract address
|
|
1023
|
-
* @param params.network - Network (default: "sepolia")
|
|
1041
|
+
* @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
1024
1042
|
* @returns Unlocked balance in base units (wei)
|
|
1025
1043
|
*
|
|
1026
1044
|
* @example
|
|
@@ -1041,7 +1059,7 @@ declare function getUnlockedBalanceForProvider(params: {
|
|
|
1041
1059
|
publicClient: PublicClient;
|
|
1042
1060
|
providerAddress: Address;
|
|
1043
1061
|
tokenAddress: Address;
|
|
1044
|
-
network?:
|
|
1062
|
+
network?: SupportedNetwork;
|
|
1045
1063
|
}): Promise<bigint>;
|
|
1046
1064
|
|
|
1047
1065
|
/**
|
|
@@ -1061,7 +1079,7 @@ declare function getUnlockedBalanceForProvider(params: {
|
|
|
1061
1079
|
* @param params.walletClient - Viem WalletClient (from wagmi useWalletClient)
|
|
1062
1080
|
* @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
|
|
1063
1081
|
* @param params.tokenAddress - Token contract address to withdraw
|
|
1064
|
-
* @param params.network - Network (default: "sepolia")
|
|
1082
|
+
* @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
1065
1083
|
* @returns Transaction hash
|
|
1066
1084
|
*
|
|
1067
1085
|
* @example
|
|
@@ -1082,26 +1100,9 @@ declare function withdrawAllAvailableEpochs(params: {
|
|
|
1082
1100
|
walletClient: WalletClient;
|
|
1083
1101
|
publicClient: PublicClient;
|
|
1084
1102
|
tokenAddress: Address;
|
|
1085
|
-
network?:
|
|
1103
|
+
network?: SupportedNetwork;
|
|
1086
1104
|
}): Promise<Hash>;
|
|
1087
1105
|
|
|
1088
|
-
/**
|
|
1089
|
-
* Core type definitions shared across the package
|
|
1090
|
-
*/
|
|
1091
|
-
/**
|
|
1092
|
-
* Supported blockchain networks (where IATP contracts are deployed)
|
|
1093
|
-
*/
|
|
1094
|
-
type SupportedNetwork = 'sepolia';
|
|
1095
|
-
/**
|
|
1096
|
-
* EIP-712 domain for signature verification
|
|
1097
|
-
*/
|
|
1098
|
-
interface EIP712Domain {
|
|
1099
|
-
name: string;
|
|
1100
|
-
version: string;
|
|
1101
|
-
chainId: number;
|
|
1102
|
-
verifyingContract: `0x${string}`;
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
1106
|
/**
|
|
1106
1107
|
* Contract configuration and utilities.
|
|
1107
1108
|
*
|
|
@@ -1122,8 +1123,7 @@ declare enum ContractName {
|
|
|
1122
1123
|
* Get contract address for a given network.
|
|
1123
1124
|
*
|
|
1124
1125
|
* @param contractName - Name of the contract (use ContractName enum)
|
|
1125
|
-
* @param network - Network
|
|
1126
|
-
* @param useProxy - Use proxy address if true, implementation if false (default: true)
|
|
1126
|
+
* @param network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
1127
1127
|
* @returns Contract address as hex string, or null if not found
|
|
1128
1128
|
*
|
|
1129
1129
|
* @example
|
|
@@ -1132,12 +1132,12 @@ declare enum ContractName {
|
|
|
1132
1132
|
* console.log(factoryAddr) // "0x15D83638E339a0f29283f6B93dC1bb90b8339078"
|
|
1133
1133
|
* ```
|
|
1134
1134
|
*/
|
|
1135
|
-
declare function getContractAddress(contractName: string | ContractName, network?: SupportedNetwork
|
|
1135
|
+
declare function getContractAddress(contractName: string | ContractName, network?: SupportedNetwork): string | null;
|
|
1136
1136
|
/**
|
|
1137
1137
|
* Get contract ABI for a given network.
|
|
1138
1138
|
*
|
|
1139
1139
|
* @param contractName - Name of the contract (use ContractName enum)
|
|
1140
|
-
* @param network - Network
|
|
1140
|
+
* @param network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
1141
1141
|
* @returns Contract ABI as array of objects, or null if not found
|
|
1142
1142
|
*
|
|
1143
1143
|
* @example
|
|
@@ -1151,7 +1151,7 @@ declare function getContractAbi(contractName: string | ContractName, network?: S
|
|
|
1151
1151
|
* Get contract configuration (address and ABI) for a network.
|
|
1152
1152
|
*
|
|
1153
1153
|
* @param contractName - Name of the contract
|
|
1154
|
-
* @param network - Network
|
|
1154
|
+
* @param network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
1155
1155
|
* @returns Object with address and abi, or null if not found
|
|
1156
1156
|
*
|
|
1157
1157
|
* @example
|
|
@@ -1172,6 +1172,19 @@ declare function getContractConfig(contractName: string | ContractName, network?
|
|
|
1172
1172
|
* Utility functions for D402 payment processing
|
|
1173
1173
|
*/
|
|
1174
1174
|
|
|
1175
|
+
/**
|
|
1176
|
+
* Get viem Chain object for a supported network
|
|
1177
|
+
*
|
|
1178
|
+
* @param network - Network name
|
|
1179
|
+
* @returns viem Chain object
|
|
1180
|
+
*
|
|
1181
|
+
* @example
|
|
1182
|
+
* ```ts
|
|
1183
|
+
* const chain = getChain('arbitrum')
|
|
1184
|
+
* console.log(chain.id) // 42161
|
|
1185
|
+
* ```
|
|
1186
|
+
*/
|
|
1187
|
+
declare function getChain(network: SupportedNetwork): Chain;
|
|
1175
1188
|
/**
|
|
1176
1189
|
* Parse a money string or number into atomic units (wei)
|
|
1177
1190
|
*
|
|
@@ -1223,7 +1236,6 @@ declare function getUsdcAddress(network: SupportedNetwork): `0x${string}`;
|
|
|
1223
1236
|
* ```ts
|
|
1224
1237
|
* getChainId('sepolia') // Returns 11155111
|
|
1225
1238
|
* getChainId('11155111') // Returns 11155111 (passthrough)
|
|
1226
|
-
* getChainId('base') // Returns 8453 (for parsing 402 responses)
|
|
1227
1239
|
* ```
|
|
1228
1240
|
*/
|
|
1229
1241
|
declare function getChainId(network: string): number;
|
|
@@ -1324,4 +1336,4 @@ declare class UnsupportedNetworkError extends PaymentError {
|
|
|
1324
1336
|
constructor(network: string);
|
|
1325
1337
|
}
|
|
1326
1338
|
|
|
1327
|
-
export { ContractName, D402Client, type D402ClientConfig, type D402Response, type EIP712Domain, Invalid402ResponseError, type JsonRpcPayload, type McpToolResult, MissingRequestConfigError, type ParsedMcpResponse, PaymentAlreadyAttemptedError, PaymentAmountExceededError, type PaymentAuthorization, PaymentError, type PaymentRequirement, type PaymentSelector, type PaymentSelectorOptions, PaymentVerificationError, type SignedPayment, type SupportedNetwork, UnsupportedNetworkError, UnsupportedSchemeError, type WalletCreationResult, type WithdrawalRequest, buildMcpHeaders, buildToolCallPayload, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, executeWithdrawal, extractToolResult, findMatchingPaymentRequirement, formatMoney, generateNonce, getAvailableBalance, getChainId, getContractAbi, getContractAddress, getContractConfig, getCurrentTimestamp, getLockedBalanceForProvider, getUnlockedBalanceForProvider, getUsdcAddress, getWalletsByOwner, getWithdrawalRequest, initMcpSession, isValidAddress, normalizeAddress, parseAllPaymentRequirements, parseMcpResponse, parseMoney, parsePaymentRequirement, requestWithdrawal, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc, withdrawAllAvailableEpochs };
|
|
1339
|
+
export { ContractName, D402Client, type D402ClientConfig, type D402Response, type EIP712Domain, Invalid402ResponseError, type JsonRpcPayload, type McpToolResult, MissingRequestConfigError, type ParsedMcpResponse, PaymentAlreadyAttemptedError, PaymentAmountExceededError, type PaymentAuthorization, PaymentError, type PaymentRequirement, type PaymentSelector, type PaymentSelectorOptions, PaymentVerificationError, type SignedPayment, type SupportedNetwork, UnsupportedNetworkError, UnsupportedSchemeError, type WalletCreationResult, type WithdrawalRequest, buildMcpHeaders, buildToolCallPayload, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, executeWithdrawal, extractToolResult, findMatchingPaymentRequirement, formatMoney, generateNonce, getAvailableBalance, getChain, getChainId, getContractAbi, getContractAddress, getContractConfig, getCurrentTimestamp, getLockedBalanceForProvider, getUnlockedBalanceForProvider, getUsdcAddress, getWalletsByOwner, getWithdrawalRequest, initMcpSession, isValidAddress, normalizeAddress, parseAllPaymentRequirements, parseMcpResponse, parseMoney, parsePaymentRequirement, requestWithdrawal, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc, withdrawAllAvailableEpochs };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Account } from 'viem/accounts';
|
|
2
2
|
import { WalletClient, PublicClient, Hash, Address } from 'viem';
|
|
3
|
+
import { Chain } from 'viem/chains';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Type definitions for D402 payment protocol
|
|
@@ -590,6 +591,23 @@ declare function decodePaymentResponse(header: string): {
|
|
|
590
591
|
message?: string;
|
|
591
592
|
};
|
|
592
593
|
|
|
594
|
+
/**
|
|
595
|
+
* Core type definitions shared across the package
|
|
596
|
+
*/
|
|
597
|
+
/**
|
|
598
|
+
* Supported blockchain networks (where IATP contracts are deployed)
|
|
599
|
+
*/
|
|
600
|
+
type SupportedNetwork = 'sepolia' | 'arbitrum';
|
|
601
|
+
/**
|
|
602
|
+
* EIP-712 domain for signature verification
|
|
603
|
+
*/
|
|
604
|
+
interface EIP712Domain {
|
|
605
|
+
name: string;
|
|
606
|
+
version: string;
|
|
607
|
+
chainId: number;
|
|
608
|
+
verifyingContract: `0x${string}`;
|
|
609
|
+
}
|
|
610
|
+
|
|
593
611
|
/**
|
|
594
612
|
* Type definitions for wallet module
|
|
595
613
|
*/
|
|
@@ -640,7 +658,7 @@ interface WithdrawalRequest {
|
|
|
640
658
|
*
|
|
641
659
|
* @param params - Creation parameters
|
|
642
660
|
* @param params.ownerAccount - Owner's account (will own the wallet)
|
|
643
|
-
* @param params.network - Network to deploy on (default: "sepolia")
|
|
661
|
+
* @param params.network - Network to deploy on: "sepolia" | "arbitrum" (default: "sepolia")
|
|
644
662
|
* @param params.rpcUrl - Custom RPC URL (optional)
|
|
645
663
|
* @returns Wallet creation result with addresses and keys
|
|
646
664
|
*
|
|
@@ -662,7 +680,7 @@ interface WithdrawalRequest {
|
|
|
662
680
|
declare function createIATPWallet(params: {
|
|
663
681
|
ownerAccount: Account;
|
|
664
682
|
walletClient?: WalletClient;
|
|
665
|
-
network?:
|
|
683
|
+
network?: SupportedNetwork;
|
|
666
684
|
rpcUrl?: string;
|
|
667
685
|
}): Promise<WalletCreationResult>;
|
|
668
686
|
|
|
@@ -680,7 +698,7 @@ declare function createIATPWallet(params: {
|
|
|
680
698
|
* @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
|
|
681
699
|
* @param params.walletAddress - IATPWallet contract address
|
|
682
700
|
* @param params.tokenAddress - Token contract address (e.g., USDC)
|
|
683
|
-
* @param params.network - Network to query (default: "sepolia")
|
|
701
|
+
* @param params.network - Network to query: "sepolia" | "arbitrum" (default: "sepolia")
|
|
684
702
|
* @returns Available balance in token's base units (wei)
|
|
685
703
|
*
|
|
686
704
|
* @example
|
|
@@ -703,7 +721,7 @@ declare function getAvailableBalance(params: {
|
|
|
703
721
|
publicClient: PublicClient;
|
|
704
722
|
walletAddress: Address;
|
|
705
723
|
tokenAddress: Address;
|
|
706
|
-
network?:
|
|
724
|
+
network?: SupportedNetwork;
|
|
707
725
|
}): Promise<bigint>;
|
|
708
726
|
/**
|
|
709
727
|
* Get all IATPWallet addresses owned by a user.
|
|
@@ -715,7 +733,7 @@ declare function getAvailableBalance(params: {
|
|
|
715
733
|
*
|
|
716
734
|
* @param params - Query parameters
|
|
717
735
|
* @param params.ownerAddress - User's wallet address (from MetaMask)
|
|
718
|
-
* @param params.network - Network to query (default: "sepolia")
|
|
736
|
+
* @param params.network - Network to query: "sepolia" | "arbitrum" (default: "sepolia")
|
|
719
737
|
* @param params.rpcUrl - Custom RPC URL (optional)
|
|
720
738
|
* @returns Array of IATPWallet contract addresses (empty if user has no wallets)
|
|
721
739
|
*
|
|
@@ -741,7 +759,7 @@ declare function getAvailableBalance(params: {
|
|
|
741
759
|
*/
|
|
742
760
|
declare function getWalletsByOwner(params: {
|
|
743
761
|
ownerAddress: Address;
|
|
744
|
-
network?:
|
|
762
|
+
network?: SupportedNetwork;
|
|
745
763
|
rpcUrl?: string;
|
|
746
764
|
}): Promise<Address[]>;
|
|
747
765
|
|
|
@@ -759,7 +777,7 @@ declare function getWalletsByOwner(params: {
|
|
|
759
777
|
* @param params.publicClient - Viem PublicClient
|
|
760
778
|
* @param params.walletAddress - IATPWallet contract address
|
|
761
779
|
* @param params.tokenAddress - Token contract address
|
|
762
|
-
* @param params.network - Network
|
|
780
|
+
* @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
763
781
|
* @returns Withdrawal request details or null if no request exists
|
|
764
782
|
*
|
|
765
783
|
* @example
|
|
@@ -788,7 +806,7 @@ declare function getWithdrawalRequest(params: {
|
|
|
788
806
|
publicClient: PublicClient;
|
|
789
807
|
walletAddress: Address;
|
|
790
808
|
tokenAddress: Address;
|
|
791
|
-
network?:
|
|
809
|
+
network?: SupportedNetwork;
|
|
792
810
|
}): Promise<{
|
|
793
811
|
request: WithdrawalRequest;
|
|
794
812
|
unlockTime: bigint;
|
|
@@ -806,7 +824,7 @@ declare function getWithdrawalRequest(params: {
|
|
|
806
824
|
* @param params.tokenAddress - Token contract address
|
|
807
825
|
* @param params.amount - Amount in token's base units (wei)
|
|
808
826
|
* @param params.account - Account to sign transaction (operator)
|
|
809
|
-
* @param params.network - Network (default: "sepolia")
|
|
827
|
+
* @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
810
828
|
* @returns Transaction hash
|
|
811
829
|
*
|
|
812
830
|
* @example
|
|
@@ -831,7 +849,7 @@ declare function requestWithdrawal(params: {
|
|
|
831
849
|
tokenAddress: Address;
|
|
832
850
|
amount: bigint;
|
|
833
851
|
account: Account;
|
|
834
|
-
network?:
|
|
852
|
+
network?: SupportedNetwork;
|
|
835
853
|
}): Promise<Hash>;
|
|
836
854
|
/**
|
|
837
855
|
* Execute a withdrawal from an IATPWallet (after unlock period).
|
|
@@ -845,7 +863,7 @@ declare function requestWithdrawal(params: {
|
|
|
845
863
|
* @param params.walletAddress - IATPWallet contract address
|
|
846
864
|
* @param params.tokenAddress - Token contract address
|
|
847
865
|
* @param params.account - Account to sign transaction (operator)
|
|
848
|
-
* @param params.network - Network (default: "sepolia")
|
|
866
|
+
* @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
849
867
|
* @returns Transaction hash
|
|
850
868
|
*
|
|
851
869
|
* @example
|
|
@@ -867,7 +885,7 @@ declare function executeWithdrawal(params: {
|
|
|
867
885
|
walletAddress: Address;
|
|
868
886
|
tokenAddress: Address;
|
|
869
887
|
account: Account;
|
|
870
|
-
network?:
|
|
888
|
+
network?: SupportedNetwork;
|
|
871
889
|
}): Promise<Hash>;
|
|
872
890
|
|
|
873
891
|
/**
|
|
@@ -987,7 +1005,7 @@ declare function extractToolResult(response: ParsedMcpResponse): unknown;
|
|
|
987
1005
|
* @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
|
|
988
1006
|
* @param params.providerAddress - Provider (utility agent) IATPWallet address
|
|
989
1007
|
* @param params.tokenAddress - Token contract address
|
|
990
|
-
* @param params.network - Network (default: "sepolia")
|
|
1008
|
+
* @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
991
1009
|
* @returns Locked balance in base units (wei)
|
|
992
1010
|
*
|
|
993
1011
|
* @example
|
|
@@ -1008,7 +1026,7 @@ declare function getLockedBalanceForProvider(params: {
|
|
|
1008
1026
|
publicClient: PublicClient;
|
|
1009
1027
|
providerAddress: Address;
|
|
1010
1028
|
tokenAddress: Address;
|
|
1011
|
-
network?:
|
|
1029
|
+
network?: SupportedNetwork;
|
|
1012
1030
|
}): Promise<bigint>;
|
|
1013
1031
|
/**
|
|
1014
1032
|
* Get unlocked balance for a provider across released epochs.
|
|
@@ -1020,7 +1038,7 @@ declare function getLockedBalanceForProvider(params: {
|
|
|
1020
1038
|
* @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
|
|
1021
1039
|
* @param params.providerAddress - Provider (utility agent) IATPWallet address
|
|
1022
1040
|
* @param params.tokenAddress - Token contract address
|
|
1023
|
-
* @param params.network - Network (default: "sepolia")
|
|
1041
|
+
* @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
1024
1042
|
* @returns Unlocked balance in base units (wei)
|
|
1025
1043
|
*
|
|
1026
1044
|
* @example
|
|
@@ -1041,7 +1059,7 @@ declare function getUnlockedBalanceForProvider(params: {
|
|
|
1041
1059
|
publicClient: PublicClient;
|
|
1042
1060
|
providerAddress: Address;
|
|
1043
1061
|
tokenAddress: Address;
|
|
1044
|
-
network?:
|
|
1062
|
+
network?: SupportedNetwork;
|
|
1045
1063
|
}): Promise<bigint>;
|
|
1046
1064
|
|
|
1047
1065
|
/**
|
|
@@ -1061,7 +1079,7 @@ declare function getUnlockedBalanceForProvider(params: {
|
|
|
1061
1079
|
* @param params.walletClient - Viem WalletClient (from wagmi useWalletClient)
|
|
1062
1080
|
* @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
|
|
1063
1081
|
* @param params.tokenAddress - Token contract address to withdraw
|
|
1064
|
-
* @param params.network - Network (default: "sepolia")
|
|
1082
|
+
* @param params.network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
1065
1083
|
* @returns Transaction hash
|
|
1066
1084
|
*
|
|
1067
1085
|
* @example
|
|
@@ -1082,26 +1100,9 @@ declare function withdrawAllAvailableEpochs(params: {
|
|
|
1082
1100
|
walletClient: WalletClient;
|
|
1083
1101
|
publicClient: PublicClient;
|
|
1084
1102
|
tokenAddress: Address;
|
|
1085
|
-
network?:
|
|
1103
|
+
network?: SupportedNetwork;
|
|
1086
1104
|
}): Promise<Hash>;
|
|
1087
1105
|
|
|
1088
|
-
/**
|
|
1089
|
-
* Core type definitions shared across the package
|
|
1090
|
-
*/
|
|
1091
|
-
/**
|
|
1092
|
-
* Supported blockchain networks (where IATP contracts are deployed)
|
|
1093
|
-
*/
|
|
1094
|
-
type SupportedNetwork = 'sepolia';
|
|
1095
|
-
/**
|
|
1096
|
-
* EIP-712 domain for signature verification
|
|
1097
|
-
*/
|
|
1098
|
-
interface EIP712Domain {
|
|
1099
|
-
name: string;
|
|
1100
|
-
version: string;
|
|
1101
|
-
chainId: number;
|
|
1102
|
-
verifyingContract: `0x${string}`;
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
1106
|
/**
|
|
1106
1107
|
* Contract configuration and utilities.
|
|
1107
1108
|
*
|
|
@@ -1122,8 +1123,7 @@ declare enum ContractName {
|
|
|
1122
1123
|
* Get contract address for a given network.
|
|
1123
1124
|
*
|
|
1124
1125
|
* @param contractName - Name of the contract (use ContractName enum)
|
|
1125
|
-
* @param network - Network
|
|
1126
|
-
* @param useProxy - Use proxy address if true, implementation if false (default: true)
|
|
1126
|
+
* @param network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
1127
1127
|
* @returns Contract address as hex string, or null if not found
|
|
1128
1128
|
*
|
|
1129
1129
|
* @example
|
|
@@ -1132,12 +1132,12 @@ declare enum ContractName {
|
|
|
1132
1132
|
* console.log(factoryAddr) // "0x15D83638E339a0f29283f6B93dC1bb90b8339078"
|
|
1133
1133
|
* ```
|
|
1134
1134
|
*/
|
|
1135
|
-
declare function getContractAddress(contractName: string | ContractName, network?: SupportedNetwork
|
|
1135
|
+
declare function getContractAddress(contractName: string | ContractName, network?: SupportedNetwork): string | null;
|
|
1136
1136
|
/**
|
|
1137
1137
|
* Get contract ABI for a given network.
|
|
1138
1138
|
*
|
|
1139
1139
|
* @param contractName - Name of the contract (use ContractName enum)
|
|
1140
|
-
* @param network - Network
|
|
1140
|
+
* @param network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
1141
1141
|
* @returns Contract ABI as array of objects, or null if not found
|
|
1142
1142
|
*
|
|
1143
1143
|
* @example
|
|
@@ -1151,7 +1151,7 @@ declare function getContractAbi(contractName: string | ContractName, network?: S
|
|
|
1151
1151
|
* Get contract configuration (address and ABI) for a network.
|
|
1152
1152
|
*
|
|
1153
1153
|
* @param contractName - Name of the contract
|
|
1154
|
-
* @param network - Network
|
|
1154
|
+
* @param network - Network: "sepolia" | "arbitrum" (default: "sepolia")
|
|
1155
1155
|
* @returns Object with address and abi, or null if not found
|
|
1156
1156
|
*
|
|
1157
1157
|
* @example
|
|
@@ -1172,6 +1172,19 @@ declare function getContractConfig(contractName: string | ContractName, network?
|
|
|
1172
1172
|
* Utility functions for D402 payment processing
|
|
1173
1173
|
*/
|
|
1174
1174
|
|
|
1175
|
+
/**
|
|
1176
|
+
* Get viem Chain object for a supported network
|
|
1177
|
+
*
|
|
1178
|
+
* @param network - Network name
|
|
1179
|
+
* @returns viem Chain object
|
|
1180
|
+
*
|
|
1181
|
+
* @example
|
|
1182
|
+
* ```ts
|
|
1183
|
+
* const chain = getChain('arbitrum')
|
|
1184
|
+
* console.log(chain.id) // 42161
|
|
1185
|
+
* ```
|
|
1186
|
+
*/
|
|
1187
|
+
declare function getChain(network: SupportedNetwork): Chain;
|
|
1175
1188
|
/**
|
|
1176
1189
|
* Parse a money string or number into atomic units (wei)
|
|
1177
1190
|
*
|
|
@@ -1223,7 +1236,6 @@ declare function getUsdcAddress(network: SupportedNetwork): `0x${string}`;
|
|
|
1223
1236
|
* ```ts
|
|
1224
1237
|
* getChainId('sepolia') // Returns 11155111
|
|
1225
1238
|
* getChainId('11155111') // Returns 11155111 (passthrough)
|
|
1226
|
-
* getChainId('base') // Returns 8453 (for parsing 402 responses)
|
|
1227
1239
|
* ```
|
|
1228
1240
|
*/
|
|
1229
1241
|
declare function getChainId(network: string): number;
|
|
@@ -1324,4 +1336,4 @@ declare class UnsupportedNetworkError extends PaymentError {
|
|
|
1324
1336
|
constructor(network: string);
|
|
1325
1337
|
}
|
|
1326
1338
|
|
|
1327
|
-
export { ContractName, D402Client, type D402ClientConfig, type D402Response, type EIP712Domain, Invalid402ResponseError, type JsonRpcPayload, type McpToolResult, MissingRequestConfigError, type ParsedMcpResponse, PaymentAlreadyAttemptedError, PaymentAmountExceededError, type PaymentAuthorization, PaymentError, type PaymentRequirement, type PaymentSelector, type PaymentSelectorOptions, PaymentVerificationError, type SignedPayment, type SupportedNetwork, UnsupportedNetworkError, UnsupportedSchemeError, type WalletCreationResult, type WithdrawalRequest, buildMcpHeaders, buildToolCallPayload, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, executeWithdrawal, extractToolResult, findMatchingPaymentRequirement, formatMoney, generateNonce, getAvailableBalance, getChainId, getContractAbi, getContractAddress, getContractConfig, getCurrentTimestamp, getLockedBalanceForProvider, getUnlockedBalanceForProvider, getUsdcAddress, getWalletsByOwner, getWithdrawalRequest, initMcpSession, isValidAddress, normalizeAddress, parseAllPaymentRequirements, parseMcpResponse, parseMoney, parsePaymentRequirement, requestWithdrawal, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc, withdrawAllAvailableEpochs };
|
|
1339
|
+
export { ContractName, D402Client, type D402ClientConfig, type D402Response, type EIP712Domain, Invalid402ResponseError, type JsonRpcPayload, type McpToolResult, MissingRequestConfigError, type ParsedMcpResponse, PaymentAlreadyAttemptedError, PaymentAmountExceededError, type PaymentAuthorization, PaymentError, type PaymentRequirement, type PaymentSelector, type PaymentSelectorOptions, PaymentVerificationError, type SignedPayment, type SupportedNetwork, UnsupportedNetworkError, UnsupportedSchemeError, type WalletCreationResult, type WithdrawalRequest, buildMcpHeaders, buildToolCallPayload, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, executeWithdrawal, extractToolResult, findMatchingPaymentRequirement, formatMoney, generateNonce, getAvailableBalance, getChain, getChainId, getContractAbi, getContractAddress, getContractConfig, getCurrentTimestamp, getLockedBalanceForProvider, getUnlockedBalanceForProvider, getUsdcAddress, getWalletsByOwner, getWithdrawalRequest, initMcpSession, isValidAddress, normalizeAddress, parseAllPaymentRequirements, parseMcpResponse, parseMoney, parsePaymentRequirement, requestWithdrawal, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc, withdrawAllAvailableEpochs };
|