@dcentralab/d402-client 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Account } from 'viem/accounts';
2
- import { Hash } from 'viem';
2
+ import { Hash, Address } from 'viem';
3
3
 
4
4
  /**
5
5
  * Type definitions for D402 payment protocol
@@ -855,5 +855,36 @@ declare function createIATPWallet(params: {
855
855
  rpcUrl?: string;
856
856
  operatorPrivateKey?: `0x${string}`;
857
857
  }): Promise<WalletCreationResult>;
858
+ /**
859
+ * Get all IATPWallet addresses owned by a user.
860
+ *
861
+ * Queries the IATPWalletFactory contract to retrieve all wallets
862
+ * where the specified address is the owner.
863
+ *
864
+ * @param params - Query parameters
865
+ * @param params.ownerAddress - Owner's address to query
866
+ * @param params.network - Network to query (default: "sepolia")
867
+ * @param params.rpcUrl - Custom RPC URL (optional)
868
+ * @returns Array of IATPWallet contract addresses
869
+ *
870
+ * @example
871
+ * ```ts
872
+ * import { getWalletsByOwner } from '@dcentralab/d402-client'
873
+ *
874
+ * // Get user's wallets
875
+ * const wallets = await getWalletsByOwner({
876
+ * ownerAddress: '0xUserAddress...',
877
+ * network: 'sepolia'
878
+ * })
879
+ *
880
+ * console.log(`User has ${wallets.length} wallets`)
881
+ * wallets.forEach(addr => console.log('Wallet:', addr))
882
+ * ```
883
+ */
884
+ declare function getWalletsByOwner(params: {
885
+ ownerAddress: Address;
886
+ network?: 'sepolia' | 'localhost';
887
+ rpcUrl?: string;
888
+ }): Promise<Address[]>;
858
889
 
859
- export { CHAIN_IDS, ContractName, D402Client, type D402ClientConfig, type D402Config, DEFAULT_VALIDITY_WINDOW_SECONDS, type EIP712Domain, EIP712_TYPES, Invalid402ResponseError, MissingRequestConfigError, NETWORKS, PaymentAlreadyAttemptedError, PaymentAmountExceededError, type PaymentAuthorization, PaymentError, type PaymentRequirement, type PaymentSelector, type PaymentSelectorOptions, PaymentVerificationError, type SignedPayment, type SupportedContractNetwork, type SupportedNetwork, TOKEN_ADDRESSES, UnsupportedNetworkError, UnsupportedSchemeError, type WalletCreationResult, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, findMatchingPaymentRequirement, formatMoney, generateNonce, getAllContractAddresses, getChainId, getContractAbi, getContractAddress, getContractConfig, getCurrentTimestamp, getUsdcAddress, isContractDeployed, isValidAddress, normalizeAddress, parseMoney, parsePaymentRequirement, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc };
890
+ export { CHAIN_IDS, ContractName, D402Client, type D402ClientConfig, type D402Config, DEFAULT_VALIDITY_WINDOW_SECONDS, type EIP712Domain, EIP712_TYPES, Invalid402ResponseError, MissingRequestConfigError, NETWORKS, PaymentAlreadyAttemptedError, PaymentAmountExceededError, type PaymentAuthorization, PaymentError, type PaymentRequirement, type PaymentSelector, type PaymentSelectorOptions, PaymentVerificationError, type SignedPayment, type SupportedContractNetwork, type SupportedNetwork, TOKEN_ADDRESSES, UnsupportedNetworkError, UnsupportedSchemeError, type WalletCreationResult, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, findMatchingPaymentRequirement, formatMoney, generateNonce, getAllContractAddresses, getChainId, getContractAbi, getContractAddress, getContractConfig, getCurrentTimestamp, getUsdcAddress, getWalletsByOwner, isContractDeployed, isValidAddress, normalizeAddress, parseMoney, parsePaymentRequirement, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Account } from 'viem/accounts';
2
- import { Hash } from 'viem';
2
+ import { Hash, Address } from 'viem';
3
3
 
4
4
  /**
5
5
  * Type definitions for D402 payment protocol
@@ -855,5 +855,36 @@ declare function createIATPWallet(params: {
855
855
  rpcUrl?: string;
856
856
  operatorPrivateKey?: `0x${string}`;
857
857
  }): Promise<WalletCreationResult>;
858
+ /**
859
+ * Get all IATPWallet addresses owned by a user.
860
+ *
861
+ * Queries the IATPWalletFactory contract to retrieve all wallets
862
+ * where the specified address is the owner.
863
+ *
864
+ * @param params - Query parameters
865
+ * @param params.ownerAddress - Owner's address to query
866
+ * @param params.network - Network to query (default: "sepolia")
867
+ * @param params.rpcUrl - Custom RPC URL (optional)
868
+ * @returns Array of IATPWallet contract addresses
869
+ *
870
+ * @example
871
+ * ```ts
872
+ * import { getWalletsByOwner } from '@dcentralab/d402-client'
873
+ *
874
+ * // Get user's wallets
875
+ * const wallets = await getWalletsByOwner({
876
+ * ownerAddress: '0xUserAddress...',
877
+ * network: 'sepolia'
878
+ * })
879
+ *
880
+ * console.log(`User has ${wallets.length} wallets`)
881
+ * wallets.forEach(addr => console.log('Wallet:', addr))
882
+ * ```
883
+ */
884
+ declare function getWalletsByOwner(params: {
885
+ ownerAddress: Address;
886
+ network?: 'sepolia' | 'localhost';
887
+ rpcUrl?: string;
888
+ }): Promise<Address[]>;
858
889
 
859
- export { CHAIN_IDS, ContractName, D402Client, type D402ClientConfig, type D402Config, DEFAULT_VALIDITY_WINDOW_SECONDS, type EIP712Domain, EIP712_TYPES, Invalid402ResponseError, MissingRequestConfigError, NETWORKS, PaymentAlreadyAttemptedError, PaymentAmountExceededError, type PaymentAuthorization, PaymentError, type PaymentRequirement, type PaymentSelector, type PaymentSelectorOptions, PaymentVerificationError, type SignedPayment, type SupportedContractNetwork, type SupportedNetwork, TOKEN_ADDRESSES, UnsupportedNetworkError, UnsupportedSchemeError, type WalletCreationResult, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, findMatchingPaymentRequirement, formatMoney, generateNonce, getAllContractAddresses, getChainId, getContractAbi, getContractAddress, getContractConfig, getCurrentTimestamp, getUsdcAddress, isContractDeployed, isValidAddress, normalizeAddress, parseMoney, parsePaymentRequirement, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc };
890
+ export { CHAIN_IDS, ContractName, D402Client, type D402ClientConfig, type D402Config, DEFAULT_VALIDITY_WINDOW_SECONDS, type EIP712Domain, EIP712_TYPES, Invalid402ResponseError, MissingRequestConfigError, NETWORKS, PaymentAlreadyAttemptedError, PaymentAmountExceededError, type PaymentAuthorization, PaymentError, type PaymentRequirement, type PaymentSelector, type PaymentSelectorOptions, PaymentVerificationError, type SignedPayment, type SupportedContractNetwork, type SupportedNetwork, TOKEN_ADDRESSES, UnsupportedNetworkError, UnsupportedSchemeError, type WalletCreationResult, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, findMatchingPaymentRequirement, formatMoney, generateNonce, getAllContractAddresses, getChainId, getContractAbi, getContractAddress, getContractConfig, getCurrentTimestamp, getUsdcAddress, getWalletsByOwner, isContractDeployed, isValidAddress, normalizeAddress, parseMoney, parsePaymentRequirement, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc };
package/dist/index.js CHANGED
@@ -8995,6 +8995,26 @@ async function createIATPWallet(params) {
8995
8995
  chainId: chain.id
8996
8996
  };
8997
8997
  }
8998
+ async function getWalletsByOwner(params) {
8999
+ const { ownerAddress, network = "sepolia", rpcUrl } = params;
9000
+ const factoryConfig = getContractConfig("IATPWalletFactory" /* IATP_WALLET_FACTORY */, network);
9001
+ if (!factoryConfig) {
9002
+ throw new Error(`IATPWalletFactory not found for network: ${network}`);
9003
+ }
9004
+ const chain = network === "sepolia" ? chains.sepolia : chains.localhost;
9005
+ const transport = viem.http(rpcUrl);
9006
+ const publicClient = viem.createPublicClient({
9007
+ chain,
9008
+ transport
9009
+ });
9010
+ const wallets = await publicClient.readContract({
9011
+ address: factoryConfig.address,
9012
+ abi: factoryConfig.abi,
9013
+ functionName: "getWalletsByOwner",
9014
+ args: [ownerAddress]
9015
+ });
9016
+ return wallets;
9017
+ }
8998
9018
 
8999
9019
  exports.ContractName = ContractName;
9000
9020
  exports.D402Client = D402Client;
@@ -9013,6 +9033,7 @@ exports.getContractAddress = getContractAddress;
9013
9033
  exports.getContractConfig = getContractConfig;
9014
9034
  exports.getCurrentTimestamp = getCurrentTimestamp;
9015
9035
  exports.getUsdcAddress = getUsdcAddress;
9036
+ exports.getWalletsByOwner = getWalletsByOwner;
9016
9037
  exports.isContractDeployed = isContractDeployed;
9017
9038
  exports.isValidAddress = isValidAddress;
9018
9039
  exports.normalizeAddress = normalizeAddress;