@dcentralab/d402-client 0.2.5 → 0.2.7
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 +35 -98
- package/dist/index.d.ts +35 -98
- package/dist/index.js +246 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +247 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
- package/LICENSE +0 -22
package/dist/index.d.mts
CHANGED
|
@@ -719,103 +719,6 @@ declare const EIP712_TYPES: {
|
|
|
719
719
|
}];
|
|
720
720
|
};
|
|
721
721
|
|
|
722
|
-
/**
|
|
723
|
-
* Contract configuration and utilities.
|
|
724
|
-
*
|
|
725
|
-
* Provides access to IATPWallet contract ABIs and deployed addresses.
|
|
726
|
-
* Contract data is bundled directly in the package for reliability.
|
|
727
|
-
*/
|
|
728
|
-
/**
|
|
729
|
-
* Supported contract names.
|
|
730
|
-
*/
|
|
731
|
-
declare enum ContractName {
|
|
732
|
-
IATP_WALLET = "IATPWallet",
|
|
733
|
-
IATP_WALLET_FACTORY = "IATPWalletFactory",
|
|
734
|
-
IATP_SETTLEMENT_LAYER = "IATPSettlementLayer",
|
|
735
|
-
ROLE_MANAGER = "RoleManager"
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* Supported networks for contract deployments.
|
|
739
|
-
*/
|
|
740
|
-
type SupportedContractNetwork = 'sepolia';
|
|
741
|
-
/**
|
|
742
|
-
* Get contract address for a given network.
|
|
743
|
-
*
|
|
744
|
-
* @param contractName - Name of the contract (use ContractName enum)
|
|
745
|
-
* @param network - Network name (default: "sepolia")
|
|
746
|
-
* @param useProxy - Use proxy address if true, implementation if false (default: true)
|
|
747
|
-
* @returns Contract address as hex string, or null if not found
|
|
748
|
-
*
|
|
749
|
-
* @example
|
|
750
|
-
* ```ts
|
|
751
|
-
* const factoryAddr = getContractAddress(ContractName.IATP_WALLET_FACTORY, 'sepolia')
|
|
752
|
-
* console.log(factoryAddr) // "0x15D83638E339a0f29283f6B93dC1bb90b8339078"
|
|
753
|
-
* ```
|
|
754
|
-
*/
|
|
755
|
-
declare function getContractAddress(contractName: string | ContractName, network?: SupportedContractNetwork, useProxy?: boolean): string | null;
|
|
756
|
-
/**
|
|
757
|
-
* Get contract ABI for a given network.
|
|
758
|
-
*
|
|
759
|
-
* @param contractName - Name of the contract (use ContractName enum)
|
|
760
|
-
* @param network - Network name (default: "sepolia")
|
|
761
|
-
* @returns Contract ABI as array of objects, or null if not found
|
|
762
|
-
*
|
|
763
|
-
* @example
|
|
764
|
-
* ```ts
|
|
765
|
-
* const factoryAbi = getContractAbi(ContractName.IATP_WALLET_FACTORY, 'sepolia')
|
|
766
|
-
* console.log(factoryAbi.length) // Number of ABI entries
|
|
767
|
-
* ```
|
|
768
|
-
*/
|
|
769
|
-
declare function getContractAbi(contractName: string | ContractName, network?: SupportedContractNetwork): any[] | null;
|
|
770
|
-
/**
|
|
771
|
-
* Get contract configuration (address and ABI) for a network.
|
|
772
|
-
*
|
|
773
|
-
* @param contractName - Name of the contract
|
|
774
|
-
* @param network - Network name (default: "sepolia")
|
|
775
|
-
* @returns Object with address and abi, or null if not found
|
|
776
|
-
*
|
|
777
|
-
* @example
|
|
778
|
-
* ```ts
|
|
779
|
-
* const config = getContractConfig(ContractName.IATP_WALLET_FACTORY, 'sepolia')
|
|
780
|
-
* if (config) {
|
|
781
|
-
* console.log(config.address)
|
|
782
|
-
* console.log(config.abi.length)
|
|
783
|
-
* }
|
|
784
|
-
* ```
|
|
785
|
-
*/
|
|
786
|
-
declare function getContractConfig(contractName: string | ContractName, network?: SupportedContractNetwork): {
|
|
787
|
-
address: string;
|
|
788
|
-
abi: any[];
|
|
789
|
-
} | null;
|
|
790
|
-
/**
|
|
791
|
-
* Get all contract addresses for a network.
|
|
792
|
-
*
|
|
793
|
-
* @param network - Network name
|
|
794
|
-
* @returns Object with all contract addresses for the network
|
|
795
|
-
*
|
|
796
|
-
* @example
|
|
797
|
-
* ```ts
|
|
798
|
-
* const addresses = getAllContractAddresses('sepolia')
|
|
799
|
-
* console.log(addresses.IATPWalletFactory)
|
|
800
|
-
* ```
|
|
801
|
-
*/
|
|
802
|
-
declare function getAllContractAddresses(network: SupportedContractNetwork): Record<string, string>;
|
|
803
|
-
/**
|
|
804
|
-
* Check if a contract is deployed on a network.
|
|
805
|
-
*
|
|
806
|
-
* @param contractName - Name of the contract
|
|
807
|
-
* @param network - Network name
|
|
808
|
-
* @returns True if contract exists on network
|
|
809
|
-
*
|
|
810
|
-
* @example
|
|
811
|
-
* ```ts
|
|
812
|
-
* if (isContractDeployed(ContractName.IATP_WALLET_FACTORY, 'sepolia')) {
|
|
813
|
-
* // Contract is available
|
|
814
|
-
* }
|
|
815
|
-
* ```
|
|
816
|
-
*/
|
|
817
|
-
declare function isContractDeployed(contractName: string | ContractName, network: SupportedContractNetwork): boolean;
|
|
818
|
-
|
|
819
722
|
/**
|
|
820
723
|
* IATPWallet creation and management
|
|
821
724
|
*
|
|
@@ -1027,5 +930,39 @@ declare function getUnlockedBalanceForProvider(params: {
|
|
|
1027
930
|
tokenAddress: Address;
|
|
1028
931
|
network?: 'sepolia';
|
|
1029
932
|
}): Promise<bigint>;
|
|
933
|
+
/**
|
|
934
|
+
* Withdraw all available epochs for a provider (utility agent).
|
|
935
|
+
*
|
|
936
|
+
* This function calls the settlement layer's withdrawAllAvailableEpochs function,
|
|
937
|
+
* which releases and withdraws funds from all available epochs for the given token.
|
|
938
|
+
* Only the provider themselves can call this function.
|
|
939
|
+
*
|
|
940
|
+
* @param params - Transaction parameters
|
|
941
|
+
* @param params.walletClient - Viem WalletClient (from wagmi useWalletClient)
|
|
942
|
+
* @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
|
|
943
|
+
* @param params.tokenAddress - Token contract address to withdraw
|
|
944
|
+
* @param params.network - Network (default: "sepolia")
|
|
945
|
+
* @returns Transaction hash
|
|
946
|
+
*
|
|
947
|
+
* @example
|
|
948
|
+
* ```ts
|
|
949
|
+
* import { withdrawAllAvailableEpochs } from '@dcentralab/d402-client'
|
|
950
|
+
*
|
|
951
|
+
* const hash = await withdrawAllAvailableEpochs({
|
|
952
|
+
* walletClient,
|
|
953
|
+
* publicClient,
|
|
954
|
+
* tokenAddress: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238', // USDC
|
|
955
|
+
* network: 'sepolia'
|
|
956
|
+
* })
|
|
957
|
+
*
|
|
958
|
+
* console.log('Withdrawal transaction:', hash)
|
|
959
|
+
* ```
|
|
960
|
+
*/
|
|
961
|
+
declare function withdrawAllAvailableEpochs(params: {
|
|
962
|
+
walletClient: WalletClient;
|
|
963
|
+
publicClient: PublicClient;
|
|
964
|
+
tokenAddress: Address;
|
|
965
|
+
network?: 'sepolia';
|
|
966
|
+
}): Promise<Hash>;
|
|
1030
967
|
|
|
1031
|
-
export { CHAIN_IDS,
|
|
968
|
+
export { CHAIN_IDS, 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 SupportedNetwork, TOKEN_ADDRESSES, UnsupportedNetworkError, UnsupportedSchemeError, type WalletCreationResult, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, findMatchingPaymentRequirement, formatMoney, generateNonce, getAvailableBalance, getChainId, getCurrentTimestamp, getLockedBalanceForProvider, getUnlockedBalanceForProvider, getUsdcAddress, getWalletsByOwner, isValidAddress, normalizeAddress, parseMoney, parsePaymentRequirement, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc, withdrawAllAvailableEpochs };
|
package/dist/index.d.ts
CHANGED
|
@@ -719,103 +719,6 @@ declare const EIP712_TYPES: {
|
|
|
719
719
|
}];
|
|
720
720
|
};
|
|
721
721
|
|
|
722
|
-
/**
|
|
723
|
-
* Contract configuration and utilities.
|
|
724
|
-
*
|
|
725
|
-
* Provides access to IATPWallet contract ABIs and deployed addresses.
|
|
726
|
-
* Contract data is bundled directly in the package for reliability.
|
|
727
|
-
*/
|
|
728
|
-
/**
|
|
729
|
-
* Supported contract names.
|
|
730
|
-
*/
|
|
731
|
-
declare enum ContractName {
|
|
732
|
-
IATP_WALLET = "IATPWallet",
|
|
733
|
-
IATP_WALLET_FACTORY = "IATPWalletFactory",
|
|
734
|
-
IATP_SETTLEMENT_LAYER = "IATPSettlementLayer",
|
|
735
|
-
ROLE_MANAGER = "RoleManager"
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* Supported networks for contract deployments.
|
|
739
|
-
*/
|
|
740
|
-
type SupportedContractNetwork = 'sepolia';
|
|
741
|
-
/**
|
|
742
|
-
* Get contract address for a given network.
|
|
743
|
-
*
|
|
744
|
-
* @param contractName - Name of the contract (use ContractName enum)
|
|
745
|
-
* @param network - Network name (default: "sepolia")
|
|
746
|
-
* @param useProxy - Use proxy address if true, implementation if false (default: true)
|
|
747
|
-
* @returns Contract address as hex string, or null if not found
|
|
748
|
-
*
|
|
749
|
-
* @example
|
|
750
|
-
* ```ts
|
|
751
|
-
* const factoryAddr = getContractAddress(ContractName.IATP_WALLET_FACTORY, 'sepolia')
|
|
752
|
-
* console.log(factoryAddr) // "0x15D83638E339a0f29283f6B93dC1bb90b8339078"
|
|
753
|
-
* ```
|
|
754
|
-
*/
|
|
755
|
-
declare function getContractAddress(contractName: string | ContractName, network?: SupportedContractNetwork, useProxy?: boolean): string | null;
|
|
756
|
-
/**
|
|
757
|
-
* Get contract ABI for a given network.
|
|
758
|
-
*
|
|
759
|
-
* @param contractName - Name of the contract (use ContractName enum)
|
|
760
|
-
* @param network - Network name (default: "sepolia")
|
|
761
|
-
* @returns Contract ABI as array of objects, or null if not found
|
|
762
|
-
*
|
|
763
|
-
* @example
|
|
764
|
-
* ```ts
|
|
765
|
-
* const factoryAbi = getContractAbi(ContractName.IATP_WALLET_FACTORY, 'sepolia')
|
|
766
|
-
* console.log(factoryAbi.length) // Number of ABI entries
|
|
767
|
-
* ```
|
|
768
|
-
*/
|
|
769
|
-
declare function getContractAbi(contractName: string | ContractName, network?: SupportedContractNetwork): any[] | null;
|
|
770
|
-
/**
|
|
771
|
-
* Get contract configuration (address and ABI) for a network.
|
|
772
|
-
*
|
|
773
|
-
* @param contractName - Name of the contract
|
|
774
|
-
* @param network - Network name (default: "sepolia")
|
|
775
|
-
* @returns Object with address and abi, or null if not found
|
|
776
|
-
*
|
|
777
|
-
* @example
|
|
778
|
-
* ```ts
|
|
779
|
-
* const config = getContractConfig(ContractName.IATP_WALLET_FACTORY, 'sepolia')
|
|
780
|
-
* if (config) {
|
|
781
|
-
* console.log(config.address)
|
|
782
|
-
* console.log(config.abi.length)
|
|
783
|
-
* }
|
|
784
|
-
* ```
|
|
785
|
-
*/
|
|
786
|
-
declare function getContractConfig(contractName: string | ContractName, network?: SupportedContractNetwork): {
|
|
787
|
-
address: string;
|
|
788
|
-
abi: any[];
|
|
789
|
-
} | null;
|
|
790
|
-
/**
|
|
791
|
-
* Get all contract addresses for a network.
|
|
792
|
-
*
|
|
793
|
-
* @param network - Network name
|
|
794
|
-
* @returns Object with all contract addresses for the network
|
|
795
|
-
*
|
|
796
|
-
* @example
|
|
797
|
-
* ```ts
|
|
798
|
-
* const addresses = getAllContractAddresses('sepolia')
|
|
799
|
-
* console.log(addresses.IATPWalletFactory)
|
|
800
|
-
* ```
|
|
801
|
-
*/
|
|
802
|
-
declare function getAllContractAddresses(network: SupportedContractNetwork): Record<string, string>;
|
|
803
|
-
/**
|
|
804
|
-
* Check if a contract is deployed on a network.
|
|
805
|
-
*
|
|
806
|
-
* @param contractName - Name of the contract
|
|
807
|
-
* @param network - Network name
|
|
808
|
-
* @returns True if contract exists on network
|
|
809
|
-
*
|
|
810
|
-
* @example
|
|
811
|
-
* ```ts
|
|
812
|
-
* if (isContractDeployed(ContractName.IATP_WALLET_FACTORY, 'sepolia')) {
|
|
813
|
-
* // Contract is available
|
|
814
|
-
* }
|
|
815
|
-
* ```
|
|
816
|
-
*/
|
|
817
|
-
declare function isContractDeployed(contractName: string | ContractName, network: SupportedContractNetwork): boolean;
|
|
818
|
-
|
|
819
722
|
/**
|
|
820
723
|
* IATPWallet creation and management
|
|
821
724
|
*
|
|
@@ -1027,5 +930,39 @@ declare function getUnlockedBalanceForProvider(params: {
|
|
|
1027
930
|
tokenAddress: Address;
|
|
1028
931
|
network?: 'sepolia';
|
|
1029
932
|
}): Promise<bigint>;
|
|
933
|
+
/**
|
|
934
|
+
* Withdraw all available epochs for a provider (utility agent).
|
|
935
|
+
*
|
|
936
|
+
* This function calls the settlement layer's withdrawAllAvailableEpochs function,
|
|
937
|
+
* which releases and withdraws funds from all available epochs for the given token.
|
|
938
|
+
* Only the provider themselves can call this function.
|
|
939
|
+
*
|
|
940
|
+
* @param params - Transaction parameters
|
|
941
|
+
* @param params.walletClient - Viem WalletClient (from wagmi useWalletClient)
|
|
942
|
+
* @param params.publicClient - Viem PublicClient (from wagmi usePublicClient)
|
|
943
|
+
* @param params.tokenAddress - Token contract address to withdraw
|
|
944
|
+
* @param params.network - Network (default: "sepolia")
|
|
945
|
+
* @returns Transaction hash
|
|
946
|
+
*
|
|
947
|
+
* @example
|
|
948
|
+
* ```ts
|
|
949
|
+
* import { withdrawAllAvailableEpochs } from '@dcentralab/d402-client'
|
|
950
|
+
*
|
|
951
|
+
* const hash = await withdrawAllAvailableEpochs({
|
|
952
|
+
* walletClient,
|
|
953
|
+
* publicClient,
|
|
954
|
+
* tokenAddress: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238', // USDC
|
|
955
|
+
* network: 'sepolia'
|
|
956
|
+
* })
|
|
957
|
+
*
|
|
958
|
+
* console.log('Withdrawal transaction:', hash)
|
|
959
|
+
* ```
|
|
960
|
+
*/
|
|
961
|
+
declare function withdrawAllAvailableEpochs(params: {
|
|
962
|
+
walletClient: WalletClient;
|
|
963
|
+
publicClient: PublicClient;
|
|
964
|
+
tokenAddress: Address;
|
|
965
|
+
network?: 'sepolia';
|
|
966
|
+
}): Promise<Hash>;
|
|
1030
967
|
|
|
1031
|
-
export { CHAIN_IDS,
|
|
968
|
+
export { CHAIN_IDS, 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 SupportedNetwork, TOKEN_ADDRESSES, UnsupportedNetworkError, UnsupportedSchemeError, type WalletCreationResult, createIATPWallet, createPaymentSelector, decodePayment, decodePaymentResponse, encodePayment, findMatchingPaymentRequirement, formatMoney, generateNonce, getAvailableBalance, getChainId, getCurrentTimestamp, getLockedBalanceForProvider, getUnlockedBalanceForProvider, getUsdcAddress, getWalletsByOwner, isValidAddress, normalizeAddress, parseMoney, parsePaymentRequirement, selectPaymentRequirement, signD402Payment, sortPaymentRequirements, usdToUsdc, withdrawAllAvailableEpochs };
|
package/dist/index.js
CHANGED
|
@@ -726,6 +726,25 @@ var sepolia_default = {
|
|
|
726
726
|
name: "ClientInitialized",
|
|
727
727
|
type: "event"
|
|
728
728
|
},
|
|
729
|
+
{
|
|
730
|
+
anonymous: false,
|
|
731
|
+
inputs: [
|
|
732
|
+
{
|
|
733
|
+
indexed: false,
|
|
734
|
+
internalType: "string",
|
|
735
|
+
name: "oldDescription",
|
|
736
|
+
type: "string"
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
indexed: false,
|
|
740
|
+
internalType: "string",
|
|
741
|
+
name: "newDescription",
|
|
742
|
+
type: "string"
|
|
743
|
+
}
|
|
744
|
+
],
|
|
745
|
+
name: "DescriptionUpdated",
|
|
746
|
+
type: "event"
|
|
747
|
+
},
|
|
729
748
|
{
|
|
730
749
|
anonymous: false,
|
|
731
750
|
inputs: [],
|
|
@@ -795,6 +814,25 @@ var sepolia_default = {
|
|
|
795
814
|
name: "Initialized",
|
|
796
815
|
type: "event"
|
|
797
816
|
},
|
|
817
|
+
{
|
|
818
|
+
anonymous: false,
|
|
819
|
+
inputs: [
|
|
820
|
+
{
|
|
821
|
+
indexed: false,
|
|
822
|
+
internalType: "string",
|
|
823
|
+
name: "oldName",
|
|
824
|
+
type: "string"
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
indexed: false,
|
|
828
|
+
internalType: "string",
|
|
829
|
+
name: "newName",
|
|
830
|
+
type: "string"
|
|
831
|
+
}
|
|
832
|
+
],
|
|
833
|
+
name: "NameUpdated",
|
|
834
|
+
type: "event"
|
|
835
|
+
},
|
|
798
836
|
{
|
|
799
837
|
anonymous: false,
|
|
800
838
|
inputs: [
|
|
@@ -840,6 +878,25 @@ var sepolia_default = {
|
|
|
840
878
|
name: "Upgraded",
|
|
841
879
|
type: "event"
|
|
842
880
|
},
|
|
881
|
+
{
|
|
882
|
+
anonymous: false,
|
|
883
|
+
inputs: [
|
|
884
|
+
{
|
|
885
|
+
indexed: true,
|
|
886
|
+
internalType: "enum IIATPWalletFactory.WalletType",
|
|
887
|
+
name: "oldWalletType",
|
|
888
|
+
type: "uint8"
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
indexed: true,
|
|
892
|
+
internalType: "enum IIATPWalletFactory.WalletType",
|
|
893
|
+
name: "newWalletType",
|
|
894
|
+
type: "uint8"
|
|
895
|
+
}
|
|
896
|
+
],
|
|
897
|
+
name: "WalletTypeUpdated",
|
|
898
|
+
type: "event"
|
|
899
|
+
},
|
|
843
900
|
{
|
|
844
901
|
anonymous: false,
|
|
845
902
|
inputs: [
|
|
@@ -1024,6 +1081,19 @@ var sepolia_default = {
|
|
|
1024
1081
|
stateMutability: "nonpayable",
|
|
1025
1082
|
type: "function"
|
|
1026
1083
|
},
|
|
1084
|
+
{
|
|
1085
|
+
inputs: [],
|
|
1086
|
+
name: "description",
|
|
1087
|
+
outputs: [
|
|
1088
|
+
{
|
|
1089
|
+
internalType: "string",
|
|
1090
|
+
name: "",
|
|
1091
|
+
type: "string"
|
|
1092
|
+
}
|
|
1093
|
+
],
|
|
1094
|
+
stateMutability: "view",
|
|
1095
|
+
type: "function"
|
|
1096
|
+
},
|
|
1027
1097
|
{
|
|
1028
1098
|
inputs: [],
|
|
1029
1099
|
name: "eip712Domain",
|
|
@@ -1185,6 +1255,21 @@ var sepolia_default = {
|
|
|
1185
1255
|
internalType: "address",
|
|
1186
1256
|
name: "_settlementLayer",
|
|
1187
1257
|
type: "address"
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
internalType: "enum IIATPWalletFactory.WalletType",
|
|
1261
|
+
name: "_walletType",
|
|
1262
|
+
type: "uint8"
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
internalType: "string",
|
|
1266
|
+
name: "_name",
|
|
1267
|
+
type: "string"
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
internalType: "string",
|
|
1271
|
+
name: "_description",
|
|
1272
|
+
type: "string"
|
|
1188
1273
|
}
|
|
1189
1274
|
],
|
|
1190
1275
|
name: "initialize",
|
|
@@ -1255,6 +1340,19 @@ var sepolia_default = {
|
|
|
1255
1340
|
stateMutability: "view",
|
|
1256
1341
|
type: "function"
|
|
1257
1342
|
},
|
|
1343
|
+
{
|
|
1344
|
+
inputs: [],
|
|
1345
|
+
name: "name",
|
|
1346
|
+
outputs: [
|
|
1347
|
+
{
|
|
1348
|
+
internalType: "string",
|
|
1349
|
+
name: "",
|
|
1350
|
+
type: "string"
|
|
1351
|
+
}
|
|
1352
|
+
],
|
|
1353
|
+
stateMutability: "view",
|
|
1354
|
+
type: "function"
|
|
1355
|
+
},
|
|
1258
1356
|
{
|
|
1259
1357
|
inputs: [],
|
|
1260
1358
|
name: "operatorAddress",
|
|
@@ -1376,6 +1474,29 @@ var sepolia_default = {
|
|
|
1376
1474
|
stateMutability: "view",
|
|
1377
1475
|
type: "function"
|
|
1378
1476
|
},
|
|
1477
|
+
{
|
|
1478
|
+
inputs: [
|
|
1479
|
+
{
|
|
1480
|
+
internalType: "enum IIATPWalletFactory.WalletType",
|
|
1481
|
+
name: "_newWalletType",
|
|
1482
|
+
type: "uint8"
|
|
1483
|
+
},
|
|
1484
|
+
{
|
|
1485
|
+
internalType: "string",
|
|
1486
|
+
name: "_newName",
|
|
1487
|
+
type: "string"
|
|
1488
|
+
},
|
|
1489
|
+
{
|
|
1490
|
+
internalType: "string",
|
|
1491
|
+
name: "_newDescription",
|
|
1492
|
+
type: "string"
|
|
1493
|
+
}
|
|
1494
|
+
],
|
|
1495
|
+
name: "updateMetadata",
|
|
1496
|
+
outputs: [],
|
|
1497
|
+
stateMutability: "nonpayable",
|
|
1498
|
+
type: "function"
|
|
1499
|
+
},
|
|
1379
1500
|
{
|
|
1380
1501
|
inputs: [
|
|
1381
1502
|
{
|
|
@@ -1489,6 +1610,19 @@ var sepolia_default = {
|
|
|
1489
1610
|
stateMutability: "view",
|
|
1490
1611
|
type: "function"
|
|
1491
1612
|
},
|
|
1613
|
+
{
|
|
1614
|
+
inputs: [],
|
|
1615
|
+
name: "walletType",
|
|
1616
|
+
outputs: [
|
|
1617
|
+
{
|
|
1618
|
+
internalType: "enum IIATPWalletFactory.WalletType",
|
|
1619
|
+
name: "",
|
|
1620
|
+
type: "uint8"
|
|
1621
|
+
}
|
|
1622
|
+
],
|
|
1623
|
+
stateMutability: "view",
|
|
1624
|
+
type: "function"
|
|
1625
|
+
},
|
|
1492
1626
|
{
|
|
1493
1627
|
inputs: [
|
|
1494
1628
|
{
|
|
@@ -4343,6 +4477,64 @@ var sepolia_default = {
|
|
|
4343
4477
|
type: "address"
|
|
4344
4478
|
}
|
|
4345
4479
|
],
|
|
4480
|
+
name: "createClientWallet",
|
|
4481
|
+
outputs: [
|
|
4482
|
+
{
|
|
4483
|
+
internalType: "address",
|
|
4484
|
+
name: "wallet",
|
|
4485
|
+
type: "address"
|
|
4486
|
+
}
|
|
4487
|
+
],
|
|
4488
|
+
stateMutability: "nonpayable",
|
|
4489
|
+
type: "function"
|
|
4490
|
+
},
|
|
4491
|
+
{
|
|
4492
|
+
inputs: [
|
|
4493
|
+
{
|
|
4494
|
+
internalType: "address",
|
|
4495
|
+
name: "_owner",
|
|
4496
|
+
type: "address"
|
|
4497
|
+
},
|
|
4498
|
+
{
|
|
4499
|
+
internalType: "address",
|
|
4500
|
+
name: "_operatorAddress",
|
|
4501
|
+
type: "address"
|
|
4502
|
+
}
|
|
4503
|
+
],
|
|
4504
|
+
name: "createClientWalletFor",
|
|
4505
|
+
outputs: [
|
|
4506
|
+
{
|
|
4507
|
+
internalType: "address",
|
|
4508
|
+
name: "wallet",
|
|
4509
|
+
type: "address"
|
|
4510
|
+
}
|
|
4511
|
+
],
|
|
4512
|
+
stateMutability: "nonpayable",
|
|
4513
|
+
type: "function"
|
|
4514
|
+
},
|
|
4515
|
+
{
|
|
4516
|
+
inputs: [
|
|
4517
|
+
{
|
|
4518
|
+
internalType: "address",
|
|
4519
|
+
name: "_operatorAddress",
|
|
4520
|
+
type: "address"
|
|
4521
|
+
},
|
|
4522
|
+
{
|
|
4523
|
+
internalType: "enum IIATPWalletFactory.WalletType",
|
|
4524
|
+
name: "_walletType",
|
|
4525
|
+
type: "uint8"
|
|
4526
|
+
},
|
|
4527
|
+
{
|
|
4528
|
+
internalType: "string",
|
|
4529
|
+
name: "_name",
|
|
4530
|
+
type: "string"
|
|
4531
|
+
},
|
|
4532
|
+
{
|
|
4533
|
+
internalType: "string",
|
|
4534
|
+
name: "_description",
|
|
4535
|
+
type: "string"
|
|
4536
|
+
}
|
|
4537
|
+
],
|
|
4346
4538
|
name: "createWallet",
|
|
4347
4539
|
outputs: [
|
|
4348
4540
|
{
|
|
@@ -4365,6 +4557,21 @@ var sepolia_default = {
|
|
|
4365
4557
|
internalType: "address",
|
|
4366
4558
|
name: "_operatorAddress",
|
|
4367
4559
|
type: "address"
|
|
4560
|
+
},
|
|
4561
|
+
{
|
|
4562
|
+
internalType: "enum IIATPWalletFactory.WalletType",
|
|
4563
|
+
name: "_walletType",
|
|
4564
|
+
type: "uint8"
|
|
4565
|
+
},
|
|
4566
|
+
{
|
|
4567
|
+
internalType: "string",
|
|
4568
|
+
name: "_name",
|
|
4569
|
+
type: "string"
|
|
4570
|
+
},
|
|
4571
|
+
{
|
|
4572
|
+
internalType: "string",
|
|
4573
|
+
name: "_description",
|
|
4574
|
+
type: "string"
|
|
4368
4575
|
}
|
|
4369
4576
|
],
|
|
4370
4577
|
name: "createWalletFor",
|
|
@@ -4801,21 +5008,14 @@ var implementations_default = {
|
|
|
4801
5008
|
sepolia: {
|
|
4802
5009
|
Congress: "0x94Fc9eddBd1779542b78eb92F0569762603876e2",
|
|
4803
5010
|
TraiaCongressMembersRegistry: "0x3B685403b195f16D103b42FCf56F848A278d6049",
|
|
4804
|
-
IATPWalletImplementation: "
|
|
5011
|
+
IATPWalletImplementation: "0x4f9f0E1cD21f7122417A2A13b03c1BE84b7CB37E",
|
|
4805
5012
|
RoleManagerImplementation: "0x585AD85FCFBec3B1503E50b46407bF65d4006560",
|
|
4806
5013
|
IATPSettlementLayerImplementation: "0x0fDd39d323EE3538c800d4A13730eecE3F0bA975",
|
|
4807
|
-
IATPWalletFactoryImplementation: "
|
|
5014
|
+
IATPWalletFactoryImplementation: "0x4AC08c53C7ce1244a458D49A4101C3DC664e2D37"
|
|
4808
5015
|
}
|
|
4809
5016
|
};
|
|
4810
5017
|
|
|
4811
5018
|
// src/contracts.ts
|
|
4812
|
-
var ContractName = /* @__PURE__ */ ((ContractName2) => {
|
|
4813
|
-
ContractName2["IATP_WALLET"] = "IATPWallet";
|
|
4814
|
-
ContractName2["IATP_WALLET_FACTORY"] = "IATPWalletFactory";
|
|
4815
|
-
ContractName2["IATP_SETTLEMENT_LAYER"] = "IATPSettlementLayer";
|
|
4816
|
-
ContractName2["ROLE_MANAGER"] = "RoleManager";
|
|
4817
|
-
return ContractName2;
|
|
4818
|
-
})(ContractName || {});
|
|
4819
5019
|
var ABIS = {
|
|
4820
5020
|
sepolia: sepolia_default.sepolia || {}
|
|
4821
5021
|
};
|
|
@@ -4844,14 +5044,6 @@ function getContractConfig(contractName, network = "sepolia") {
|
|
|
4844
5044
|
}
|
|
4845
5045
|
return { address, abi };
|
|
4846
5046
|
}
|
|
4847
|
-
function getAllContractAddresses(network) {
|
|
4848
|
-
return PROXY_ADDRESSES[network] || {};
|
|
4849
|
-
}
|
|
4850
|
-
function isContractDeployed(contractName, network) {
|
|
4851
|
-
const address = getContractAddress(contractName, network);
|
|
4852
|
-
const abi = getContractAbi(contractName, network);
|
|
4853
|
-
return address !== null && abi !== null;
|
|
4854
|
-
}
|
|
4855
5047
|
|
|
4856
5048
|
// src/wallet.ts
|
|
4857
5049
|
async function createIATPWallet(params) {
|
|
@@ -4881,7 +5073,7 @@ async function createIATPWallet(params) {
|
|
|
4881
5073
|
address: factoryConfig.address,
|
|
4882
5074
|
abi: factoryConfig.abi,
|
|
4883
5075
|
functionName: "createWallet",
|
|
4884
|
-
args: [operatorAddress]
|
|
5076
|
+
args: [operatorAddress, 0, "", ""]
|
|
4885
5077
|
});
|
|
4886
5078
|
const hash = await walletClient.writeContract(request);
|
|
4887
5079
|
const receipt = await publicClient.waitForTransactionReceipt({
|
|
@@ -5231,8 +5423,6 @@ init_encoder();
|
|
|
5231
5423
|
init_utils();
|
|
5232
5424
|
init_errors();
|
|
5233
5425
|
init_constants();
|
|
5234
|
-
|
|
5235
|
-
// src/settlement.ts
|
|
5236
5426
|
async function getLockedBalanceForProvider(params) {
|
|
5237
5427
|
const { publicClient, providerAddress, tokenAddress, network = "sepolia" } = params;
|
|
5238
5428
|
const settlementConfig = getContractConfig("IATPSettlementLayer" /* IATP_SETTLEMENT_LAYER */, network);
|
|
@@ -5261,8 +5451,42 @@ async function getUnlockedBalanceForProvider(params) {
|
|
|
5261
5451
|
});
|
|
5262
5452
|
return balance;
|
|
5263
5453
|
}
|
|
5454
|
+
async function withdrawAllAvailableEpochs(params) {
|
|
5455
|
+
const { walletClient, publicClient, tokenAddress, network = "sepolia" } = params;
|
|
5456
|
+
if (!walletClient?.account) {
|
|
5457
|
+
throw new Error("Wallet account not found. Please connect your wallet.");
|
|
5458
|
+
}
|
|
5459
|
+
const account = walletClient.account;
|
|
5460
|
+
const settlementConfig = getContractConfig("IATPSettlementLayer" /* IATP_SETTLEMENT_LAYER */, network);
|
|
5461
|
+
if (!settlementConfig) {
|
|
5462
|
+
throw new Error(`IATPSettlementLayer contract not found for network: ${network}`);
|
|
5463
|
+
}
|
|
5464
|
+
const data = viem.encodeFunctionData({
|
|
5465
|
+
abi: settlementConfig.abi,
|
|
5466
|
+
functionName: "withdrawAllAvailableEpochs",
|
|
5467
|
+
args: [tokenAddress]
|
|
5468
|
+
});
|
|
5469
|
+
const estimatedGas = await publicClient.estimateGas({
|
|
5470
|
+
account: account.address,
|
|
5471
|
+
to: settlementConfig.address,
|
|
5472
|
+
data
|
|
5473
|
+
});
|
|
5474
|
+
const gasLimit = estimatedGas + estimatedGas * BigInt(20) / BigInt(100);
|
|
5475
|
+
const { request } = await publicClient.simulateContract({
|
|
5476
|
+
account,
|
|
5477
|
+
address: settlementConfig.address,
|
|
5478
|
+
abi: settlementConfig.abi,
|
|
5479
|
+
functionName: "withdrawAllAvailableEpochs",
|
|
5480
|
+
args: [tokenAddress]
|
|
5481
|
+
});
|
|
5482
|
+
const hash = await walletClient.writeContract({
|
|
5483
|
+
...request,
|
|
5484
|
+
gas: gasLimit
|
|
5485
|
+
});
|
|
5486
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
5487
|
+
return hash;
|
|
5488
|
+
}
|
|
5264
5489
|
|
|
5265
|
-
exports.ContractName = ContractName;
|
|
5266
5490
|
exports.D402Client = D402Client;
|
|
5267
5491
|
exports.createIATPWallet = createIATPWallet;
|
|
5268
5492
|
exports.createPaymentSelector = createPaymentSelector;
|
|
@@ -5272,18 +5496,13 @@ exports.encodePayment = encodePayment;
|
|
|
5272
5496
|
exports.findMatchingPaymentRequirement = findMatchingPaymentRequirement;
|
|
5273
5497
|
exports.formatMoney = formatMoney;
|
|
5274
5498
|
exports.generateNonce = generateNonce;
|
|
5275
|
-
exports.getAllContractAddresses = getAllContractAddresses;
|
|
5276
5499
|
exports.getAvailableBalance = getAvailableBalance;
|
|
5277
5500
|
exports.getChainId = getChainId;
|
|
5278
|
-
exports.getContractAbi = getContractAbi;
|
|
5279
|
-
exports.getContractAddress = getContractAddress;
|
|
5280
|
-
exports.getContractConfig = getContractConfig;
|
|
5281
5501
|
exports.getCurrentTimestamp = getCurrentTimestamp;
|
|
5282
5502
|
exports.getLockedBalanceForProvider = getLockedBalanceForProvider;
|
|
5283
5503
|
exports.getUnlockedBalanceForProvider = getUnlockedBalanceForProvider;
|
|
5284
5504
|
exports.getUsdcAddress = getUsdcAddress;
|
|
5285
5505
|
exports.getWalletsByOwner = getWalletsByOwner;
|
|
5286
|
-
exports.isContractDeployed = isContractDeployed;
|
|
5287
5506
|
exports.isValidAddress = isValidAddress;
|
|
5288
5507
|
exports.normalizeAddress = normalizeAddress;
|
|
5289
5508
|
exports.parseMoney = parseMoney;
|
|
@@ -5292,5 +5511,6 @@ exports.selectPaymentRequirement = selectPaymentRequirement;
|
|
|
5292
5511
|
exports.signD402Payment = signD402Payment;
|
|
5293
5512
|
exports.sortPaymentRequirements = sortPaymentRequirements;
|
|
5294
5513
|
exports.usdToUsdc = usdToUsdc;
|
|
5514
|
+
exports.withdrawAllAvailableEpochs = withdrawAllAvailableEpochs;
|
|
5295
5515
|
//# sourceMappingURL=index.js.map
|
|
5296
5516
|
//# sourceMappingURL=index.js.map
|