anymal-protocol 1.0.45 → 1.0.47
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 +46 -1
- package/dist/index.d.ts +46 -1
- package/dist/index.js +491 -15
- package/dist/index.mjs +483 -11
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BundlerClient } from 'viem/account-abstraction';
|
|
2
|
+
|
|
1
3
|
declare function useVerifyAccount(): (pid: string, campaignId: string, dbAuthToken: string, bundlerClient: any, smartAccount: any, accountRewardsContractAddress: `0x${string}`) => Promise<{
|
|
2
4
|
success: boolean;
|
|
3
5
|
message: string;
|
|
@@ -90,6 +92,49 @@ declare function useApproveKibbleToken(): (kibbleTokenAddress: string, marketpla
|
|
|
90
92
|
message: string;
|
|
91
93
|
}>;
|
|
92
94
|
|
|
95
|
+
/**
|
|
96
|
+
* React hook to create a new organization on-chain via the Organization beacon contract.
|
|
97
|
+
*
|
|
98
|
+
* This method can only be called by an admin of the Anymal Organization Beacon contract
|
|
99
|
+
*
|
|
100
|
+
* @returns {Function} - Async function to create the organization.
|
|
101
|
+
*
|
|
102
|
+
*
|
|
103
|
+
* @returns {Promise<{ success: boolean; message: string; proxyAddress?: string; }>} - Success status and message.
|
|
104
|
+
*/
|
|
105
|
+
declare function useCreateOrganizationBase(): (orgPid: string, orgName: string, ownerAddress: string, orgContractAddress: string, adminSmartAccount: any, bundlerClient: any) => Promise<{
|
|
106
|
+
success: boolean;
|
|
107
|
+
message: string;
|
|
108
|
+
proxyAddress?: string;
|
|
109
|
+
}>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* React hook to approve the PartialPaymentModule to spend tokens on behalf of the organization.
|
|
113
|
+
*
|
|
114
|
+
* The hook instructs the organization's contract (via executeCall) to execute an ERC20 approve call.
|
|
115
|
+
*
|
|
116
|
+
* @returns {Function} - Async function to process the approval.
|
|
117
|
+
*/
|
|
118
|
+
declare function useApproveOrgPartialPayment(): (orgContractAddress: string, kibbleTokenAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, approveAmount: bigint) => Promise<{
|
|
119
|
+
success: boolean;
|
|
120
|
+
message: string;
|
|
121
|
+
}>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* React hook to process a partial KIBBLE payment via the Organization contract.
|
|
125
|
+
*
|
|
126
|
+
* The hook instructs the organization's contract (via executeCall)
|
|
127
|
+
* to execute the partialPay call on the PartialPaymentModule.
|
|
128
|
+
*
|
|
129
|
+
* @returns {Function} - Async function to process the partial payment.
|
|
130
|
+
*/
|
|
131
|
+
declare function useProcessOrgPartialKibblePayment(): (orgContractAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, orderId: string, anymalNftId: string, pid: string, amountInTokens: bigint, maxTokenPayment: bigint, nonce: string, deadline: number, backendSignature: string) => Promise<{
|
|
132
|
+
success: boolean;
|
|
133
|
+
message: string;
|
|
134
|
+
}>;
|
|
135
|
+
|
|
136
|
+
declare function useUpdateOrgWalletAddress(): (dbAuthToken: string, docID: string, baseWalletAddress: string, endpoint: string) => Promise<void>;
|
|
137
|
+
|
|
93
138
|
declare const generateBytes32Nonce: () => `0x${string}`;
|
|
94
139
|
|
|
95
140
|
declare function useCreateUserAppData(): (appId: string, pid: string, dbAuthToken: string, endpoint: string) => Promise<{
|
|
@@ -99,4 +144,4 @@ declare function useCreateUserAppData(): (appId: string, pid: string, dbAuthToke
|
|
|
99
144
|
|
|
100
145
|
declare function useFetchBalance(): (publicClient: any, walletAddress: string, kibbleTokenAddress: string) => Promise<number | undefined>;
|
|
101
146
|
|
|
102
|
-
export { type AnymalNftMetadataInputData, type CreateAnymalInputData, generateBytes32Nonce, useAddAnymalToDatabase, useApproveKibbleToken, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessPartialKibblePayment, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
|
|
147
|
+
export { type AnymalNftMetadataInputData, type CreateAnymalInputData, generateBytes32Nonce, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BundlerClient } from 'viem/account-abstraction';
|
|
2
|
+
|
|
1
3
|
declare function useVerifyAccount(): (pid: string, campaignId: string, dbAuthToken: string, bundlerClient: any, smartAccount: any, accountRewardsContractAddress: `0x${string}`) => Promise<{
|
|
2
4
|
success: boolean;
|
|
3
5
|
message: string;
|
|
@@ -90,6 +92,49 @@ declare function useApproveKibbleToken(): (kibbleTokenAddress: string, marketpla
|
|
|
90
92
|
message: string;
|
|
91
93
|
}>;
|
|
92
94
|
|
|
95
|
+
/**
|
|
96
|
+
* React hook to create a new organization on-chain via the Organization beacon contract.
|
|
97
|
+
*
|
|
98
|
+
* This method can only be called by an admin of the Anymal Organization Beacon contract
|
|
99
|
+
*
|
|
100
|
+
* @returns {Function} - Async function to create the organization.
|
|
101
|
+
*
|
|
102
|
+
*
|
|
103
|
+
* @returns {Promise<{ success: boolean; message: string; proxyAddress?: string; }>} - Success status and message.
|
|
104
|
+
*/
|
|
105
|
+
declare function useCreateOrganizationBase(): (orgPid: string, orgName: string, ownerAddress: string, orgContractAddress: string, adminSmartAccount: any, bundlerClient: any) => Promise<{
|
|
106
|
+
success: boolean;
|
|
107
|
+
message: string;
|
|
108
|
+
proxyAddress?: string;
|
|
109
|
+
}>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* React hook to approve the PartialPaymentModule to spend tokens on behalf of the organization.
|
|
113
|
+
*
|
|
114
|
+
* The hook instructs the organization's contract (via executeCall) to execute an ERC20 approve call.
|
|
115
|
+
*
|
|
116
|
+
* @returns {Function} - Async function to process the approval.
|
|
117
|
+
*/
|
|
118
|
+
declare function useApproveOrgPartialPayment(): (orgContractAddress: string, kibbleTokenAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, approveAmount: bigint) => Promise<{
|
|
119
|
+
success: boolean;
|
|
120
|
+
message: string;
|
|
121
|
+
}>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* React hook to process a partial KIBBLE payment via the Organization contract.
|
|
125
|
+
*
|
|
126
|
+
* The hook instructs the organization's contract (via executeCall)
|
|
127
|
+
* to execute the partialPay call on the PartialPaymentModule.
|
|
128
|
+
*
|
|
129
|
+
* @returns {Function} - Async function to process the partial payment.
|
|
130
|
+
*/
|
|
131
|
+
declare function useProcessOrgPartialKibblePayment(): (orgContractAddress: string, partialPaymentModuleAddress: string, managerSmartAccount: any, bundlerClient: BundlerClient, orderId: string, anymalNftId: string, pid: string, amountInTokens: bigint, maxTokenPayment: bigint, nonce: string, deadline: number, backendSignature: string) => Promise<{
|
|
132
|
+
success: boolean;
|
|
133
|
+
message: string;
|
|
134
|
+
}>;
|
|
135
|
+
|
|
136
|
+
declare function useUpdateOrgWalletAddress(): (dbAuthToken: string, docID: string, baseWalletAddress: string, endpoint: string) => Promise<void>;
|
|
137
|
+
|
|
93
138
|
declare const generateBytes32Nonce: () => `0x${string}`;
|
|
94
139
|
|
|
95
140
|
declare function useCreateUserAppData(): (appId: string, pid: string, dbAuthToken: string, endpoint: string) => Promise<{
|
|
@@ -99,4 +144,4 @@ declare function useCreateUserAppData(): (appId: string, pid: string, dbAuthToke
|
|
|
99
144
|
|
|
100
145
|
declare function useFetchBalance(): (publicClient: any, walletAddress: string, kibbleTokenAddress: string) => Promise<number | undefined>;
|
|
101
146
|
|
|
102
|
-
export { type AnymalNftMetadataInputData, type CreateAnymalInputData, generateBytes32Nonce, useAddAnymalToDatabase, useApproveKibbleToken, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessPartialKibblePayment, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
|
|
147
|
+
export { type AnymalNftMetadataInputData, type CreateAnymalInputData, generateBytes32Nonce, useAddAnymalToDatabase, useApproveKibbleToken, useApproveOrgPartialPayment, useCreateOrganizationBase, useCreateUserAppData, useCreateWeb3Account, useDeleteAnymalFromDatabase, useFetchBalance, useFetchNotifications, useFetchUserData, useMintAnymalNFT, useProcessOrgPartialKibblePayment, useProcessPartialKibblePayment, useSaveAnymalMetadata, useUpdateAnymalWithNFT, useUpdateOrgWalletAddress, useUpdateUserAsVerified, useUpdateUserEmail, useUpdateUserName, useUpdateUserPid, useUploadAnymalImage, useVerifyAccount, useVerifyWeb3AuthSession };
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,8 @@ __export(index_exports, {
|
|
|
23
23
|
generateBytes32Nonce: () => generateBytes32Nonce,
|
|
24
24
|
useAddAnymalToDatabase: () => useAddAnymalToDatabase,
|
|
25
25
|
useApproveKibbleToken: () => useApproveKibbleToken,
|
|
26
|
+
useApproveOrgPartialPayment: () => useApproveOrgPartialPayment,
|
|
27
|
+
useCreateOrganizationBase: () => useCreateOrganizationBase,
|
|
26
28
|
useCreateUserAppData: () => useCreateUserAppData,
|
|
27
29
|
useCreateWeb3Account: () => useCreateWeb3Account,
|
|
28
30
|
useDeleteAnymalFromDatabase: () => useDeleteAnymalFromDatabase,
|
|
@@ -30,9 +32,11 @@ __export(index_exports, {
|
|
|
30
32
|
useFetchNotifications: () => useFetchNotifications,
|
|
31
33
|
useFetchUserData: () => useFetchUserData,
|
|
32
34
|
useMintAnymalNFT: () => useMintAnymalNFT,
|
|
35
|
+
useProcessOrgPartialKibblePayment: () => useProcessOrgPartialKibblePayment,
|
|
33
36
|
useProcessPartialKibblePayment: () => useProcessPartialKibblePayment,
|
|
34
37
|
useSaveAnymalMetadata: () => useSaveAnymalMetadata,
|
|
35
38
|
useUpdateAnymalWithNFT: () => useUpdateAnymalWithNFT,
|
|
39
|
+
useUpdateOrgWalletAddress: () => useUpdateOrgWalletAddress,
|
|
36
40
|
useUpdateUserAsVerified: () => useUpdateUserAsVerified,
|
|
37
41
|
useUpdateUserEmail: () => useUpdateUserEmail,
|
|
38
42
|
useUpdateUserName: () => useUpdateUserName,
|
|
@@ -66,6 +70,245 @@ var VERIFY_ACCOUNT_ABI = [
|
|
|
66
70
|
}
|
|
67
71
|
];
|
|
68
72
|
var MARKETPLACE_ABI = [{ "inputs": [{ "internalType": "address", "name": "target", "type": "address" }], "name": "AddressEmptyCode", "type": "error" }, { "inputs": [], "name": "ECDSAInvalidSignature", "type": "error" }, { "inputs": [{ "internalType": "uint256", "name": "length", "type": "uint256" }], "name": "ECDSAInvalidSignatureLength", "type": "error" }, { "inputs": [{ "internalType": "bytes32", "name": "s", "type": "bytes32" }], "name": "ECDSAInvalidSignatureS", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "implementation", "type": "address" }], "name": "ERC1967InvalidImplementation", "type": "error" }, { "inputs": [], "name": "ERC1967NonPayable", "type": "error" }, { "inputs": [], "name": "FailedCall", "type": "error" }, { "inputs": [], "name": "InvalidInitialization", "type": "error" }, { "inputs": [], "name": "NotInitializing", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }], "name": "OwnableInvalidOwner", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "OwnableUnauthorizedAccount", "type": "error" }, { "inputs": [], "name": "UUPSUnauthorizedCallContext", "type": "error" }, { "inputs": [{ "internalType": "bytes32", "name": "slot", "type": "bytes32" }], "name": "UUPSUnsupportedProxiableUUID", "type": "error" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint64", "name": "version", "type": "uint64" }], "name": "Initialized", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }], "name": "OwnershipTransferred", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "string", "name": "orderId", "type": "string" }, { "indexed": true, "internalType": "address", "name": "payer", "type": "address" }, { "indexed": true, "internalType": "string", "name": "pid", "type": "string" }, { "indexed": false, "internalType": "string", "name": "anymalNftId", "type": "string" }, { "indexed": false, "internalType": "uint256", "name": "amountInTokens", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "timestamp", "type": "uint256" }], "name": "PartialPaymentMade", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "string", "name": "orderId", "type": "string" }, { "indexed": true, "internalType": "address", "name": "payer", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amountInTokens", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "timestamp", "type": "uint256" }], "name": "PaymentMade", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "string", "name": "orderId", "type": "string" }, { "indexed": true, "internalType": "address", "name": "payer", "type": "address" }, { "indexed": true, "internalType": "string", "name": "pid", "type": "string" }, { "indexed": false, "internalType": "uint256", "name": "refundedAmount", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "timestamp", "type": "uint256" }], "name": "RefundProcessed", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "bool", "name": "enabled", "type": "bool" }], "name": "SignatureCheckToggled", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "implementation", "type": "address" }], "name": "Upgraded", "type": "event" }, { "inputs": [], "name": "UPGRADE_INTERFACE_VERSION", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "authorizer", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_initialOwner", "type": "address" }, { "internalType": "address", "name": "_authorizer", "type": "address" }, { "internalType": "address", "name": "_kibbleToken", "type": "address" }], "name": "initialize", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "kibbleToken", "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }, { "internalType": "address", "name": "", "type": "address" }], "name": "paidAmounts", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "string", "name": "orderId", "type": "string" }, { "internalType": "string", "name": "anymalNftId", "type": "string" }, { "internalType": "string", "name": "pid", "type": "string" }, { "internalType": "uint256", "name": "amountInTokens", "type": "uint256" }, { "internalType": "uint256", "name": "maxTokenPayment", "type": "uint256" }, { "internalType": "bytes32", "name": "nonce", "type": "bytes32" }, { "internalType": "uint256", "name": "deadline", "type": "uint256" }, { "internalType": "bytes", "name": "backendSignature", "type": "bytes" }], "name": "partialPay", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "proxiableUUID", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "string", "name": "orderId", "type": "string" }, { "internalType": "address", "name": "payer", "type": "address" }, { "internalType": "string", "name": "pid", "type": "string" }], "name": "refund", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_authorizer", "type": "address" }], "name": "setAuthorizer", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bool", "name": "enabled", "type": "bool" }], "name": "setSignatureCheckEnabled", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "signatureCheckEnabled", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newImplementation", "type": "address" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "name": "upgradeToAndCall", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "name": "usedNonces", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "withdrawKibble", "outputs": [], "stateMutability": "nonpayable", "type": "function" }];
|
|
73
|
+
var ORGANIZATION_ABI = [
|
|
74
|
+
{
|
|
75
|
+
"inputs": [
|
|
76
|
+
{
|
|
77
|
+
"internalType": "address",
|
|
78
|
+
"name": "_initialImplementation",
|
|
79
|
+
"type": "address"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"internalType": "address",
|
|
83
|
+
"name": "_initialOwner",
|
|
84
|
+
"type": "address"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"internalType": "address",
|
|
88
|
+
"name": "_anymalNFTProxy",
|
|
89
|
+
"type": "address"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"stateMutability": "nonpayable",
|
|
93
|
+
"type": "constructor"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"inputs": [
|
|
97
|
+
{
|
|
98
|
+
"internalType": "address",
|
|
99
|
+
"name": "implementation",
|
|
100
|
+
"type": "address"
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"name": "BeaconInvalidImplementation",
|
|
104
|
+
"type": "error"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"inputs": [
|
|
108
|
+
{
|
|
109
|
+
"internalType": "address",
|
|
110
|
+
"name": "owner",
|
|
111
|
+
"type": "address"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"name": "OwnableInvalidOwner",
|
|
115
|
+
"type": "error"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"inputs": [
|
|
119
|
+
{
|
|
120
|
+
"internalType": "address",
|
|
121
|
+
"name": "account",
|
|
122
|
+
"type": "address"
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"name": "OwnableUnauthorizedAccount",
|
|
126
|
+
"type": "error"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"anonymous": false,
|
|
130
|
+
"inputs": [
|
|
131
|
+
{
|
|
132
|
+
"indexed": true,
|
|
133
|
+
"internalType": "string",
|
|
134
|
+
"name": "pid",
|
|
135
|
+
"type": "string"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"indexed": true,
|
|
139
|
+
"internalType": "string",
|
|
140
|
+
"name": "name",
|
|
141
|
+
"type": "string"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"indexed": false,
|
|
145
|
+
"internalType": "address",
|
|
146
|
+
"name": "proxyAddress",
|
|
147
|
+
"type": "address"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"indexed": false,
|
|
151
|
+
"internalType": "address",
|
|
152
|
+
"name": "networkAdmin",
|
|
153
|
+
"type": "address"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"indexed": false,
|
|
157
|
+
"internalType": "address",
|
|
158
|
+
"name": "userAdmin",
|
|
159
|
+
"type": "address"
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
"name": "NewOrganizationCreated",
|
|
163
|
+
"type": "event"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"anonymous": false,
|
|
167
|
+
"inputs": [
|
|
168
|
+
{
|
|
169
|
+
"indexed": true,
|
|
170
|
+
"internalType": "address",
|
|
171
|
+
"name": "previousOwner",
|
|
172
|
+
"type": "address"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"indexed": true,
|
|
176
|
+
"internalType": "address",
|
|
177
|
+
"name": "newOwner",
|
|
178
|
+
"type": "address"
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
"name": "OwnershipTransferred",
|
|
182
|
+
"type": "event"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"anonymous": false,
|
|
186
|
+
"inputs": [
|
|
187
|
+
{
|
|
188
|
+
"indexed": true,
|
|
189
|
+
"internalType": "address",
|
|
190
|
+
"name": "implementation",
|
|
191
|
+
"type": "address"
|
|
192
|
+
}
|
|
193
|
+
],
|
|
194
|
+
"name": "Upgraded",
|
|
195
|
+
"type": "event"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"inputs": [],
|
|
199
|
+
"name": "anymalNFTProxy",
|
|
200
|
+
"outputs": [
|
|
201
|
+
{
|
|
202
|
+
"internalType": "address",
|
|
203
|
+
"name": "",
|
|
204
|
+
"type": "address"
|
|
205
|
+
}
|
|
206
|
+
],
|
|
207
|
+
"stateMutability": "view",
|
|
208
|
+
"type": "function"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"inputs": [
|
|
212
|
+
{
|
|
213
|
+
"internalType": "address",
|
|
214
|
+
"name": "_userAdmin",
|
|
215
|
+
"type": "address"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"internalType": "string",
|
|
219
|
+
"name": "_orgName",
|
|
220
|
+
"type": "string"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"internalType": "string",
|
|
224
|
+
"name": "_orgPid",
|
|
225
|
+
"type": "string"
|
|
226
|
+
}
|
|
227
|
+
],
|
|
228
|
+
"name": "createOrganizationProxy",
|
|
229
|
+
"outputs": [
|
|
230
|
+
{
|
|
231
|
+
"internalType": "address",
|
|
232
|
+
"name": "proxyAddress",
|
|
233
|
+
"type": "address"
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
"stateMutability": "nonpayable",
|
|
237
|
+
"type": "function"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"inputs": [],
|
|
241
|
+
"name": "implementation",
|
|
242
|
+
"outputs": [
|
|
243
|
+
{
|
|
244
|
+
"internalType": "address",
|
|
245
|
+
"name": "",
|
|
246
|
+
"type": "address"
|
|
247
|
+
}
|
|
248
|
+
],
|
|
249
|
+
"stateMutability": "view",
|
|
250
|
+
"type": "function"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"inputs": [],
|
|
254
|
+
"name": "owner",
|
|
255
|
+
"outputs": [
|
|
256
|
+
{
|
|
257
|
+
"internalType": "address",
|
|
258
|
+
"name": "",
|
|
259
|
+
"type": "address"
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
"stateMutability": "view",
|
|
263
|
+
"type": "function"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"inputs": [],
|
|
267
|
+
"name": "renounceOwnership",
|
|
268
|
+
"outputs": [],
|
|
269
|
+
"stateMutability": "nonpayable",
|
|
270
|
+
"type": "function"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"inputs": [
|
|
274
|
+
{
|
|
275
|
+
"internalType": "address",
|
|
276
|
+
"name": "newOwner",
|
|
277
|
+
"type": "address"
|
|
278
|
+
}
|
|
279
|
+
],
|
|
280
|
+
"name": "transferOwnership",
|
|
281
|
+
"outputs": [],
|
|
282
|
+
"stateMutability": "nonpayable",
|
|
283
|
+
"type": "function"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"inputs": [
|
|
287
|
+
{
|
|
288
|
+
"internalType": "address",
|
|
289
|
+
"name": "newImplementation",
|
|
290
|
+
"type": "address"
|
|
291
|
+
}
|
|
292
|
+
],
|
|
293
|
+
"name": "upgradeBeaconTo",
|
|
294
|
+
"outputs": [],
|
|
295
|
+
"stateMutability": "nonpayable",
|
|
296
|
+
"type": "function"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"inputs": [
|
|
300
|
+
{
|
|
301
|
+
"internalType": "address",
|
|
302
|
+
"name": "newImplementation",
|
|
303
|
+
"type": "address"
|
|
304
|
+
}
|
|
305
|
+
],
|
|
306
|
+
"name": "upgradeTo",
|
|
307
|
+
"outputs": [],
|
|
308
|
+
"stateMutability": "nonpayable",
|
|
309
|
+
"type": "function"
|
|
310
|
+
}
|
|
311
|
+
];
|
|
69
312
|
|
|
70
313
|
// src/utils/account/useVerifyAccount.ts
|
|
71
314
|
function useVerifyAccount() {
|
|
@@ -211,7 +454,7 @@ function useUpdateUserEmail() {
|
|
|
211
454
|
}
|
|
212
455
|
`;
|
|
213
456
|
const variables = {
|
|
214
|
-
|
|
457
|
+
docID: [docID],
|
|
215
458
|
input: {
|
|
216
459
|
email
|
|
217
460
|
}
|
|
@@ -252,7 +495,7 @@ function useUpdateUserPid() {
|
|
|
252
495
|
}
|
|
253
496
|
`;
|
|
254
497
|
const variables = {
|
|
255
|
-
|
|
498
|
+
docID: [docID],
|
|
256
499
|
input: {
|
|
257
500
|
pid
|
|
258
501
|
}
|
|
@@ -294,7 +537,7 @@ function useUpdateUserAsVerified() {
|
|
|
294
537
|
}
|
|
295
538
|
`;
|
|
296
539
|
const variables = {
|
|
297
|
-
|
|
540
|
+
docID: [docID],
|
|
298
541
|
input: {
|
|
299
542
|
isVerified: true
|
|
300
543
|
}
|
|
@@ -337,7 +580,7 @@ function useUpdateUserName() {
|
|
|
337
580
|
}
|
|
338
581
|
`;
|
|
339
582
|
const variables = {
|
|
340
|
-
|
|
583
|
+
docID: [docID],
|
|
341
584
|
input: {
|
|
342
585
|
name
|
|
343
586
|
}
|
|
@@ -570,7 +813,7 @@ function useDeleteAnymalFromDatabase() {
|
|
|
570
813
|
},
|
|
571
814
|
body: JSON.stringify({
|
|
572
815
|
query: mutation,
|
|
573
|
-
variables: {
|
|
816
|
+
variables: { docID: [anymalDocID] }
|
|
574
817
|
})
|
|
575
818
|
});
|
|
576
819
|
if (!response.ok)
|
|
@@ -898,19 +1141,248 @@ function useApproveKibbleToken() {
|
|
|
898
1141
|
);
|
|
899
1142
|
}
|
|
900
1143
|
|
|
1144
|
+
// src/utils/organization/useCreateOrganizationBase.ts
|
|
1145
|
+
var import_react18 = require("react");
|
|
1146
|
+
var import_viem5 = require("viem");
|
|
1147
|
+
function useCreateOrganizationBase() {
|
|
1148
|
+
return (0, import_react18.useCallback)(
|
|
1149
|
+
/**
|
|
1150
|
+
* Creates a new organization on-chain.
|
|
1151
|
+
*
|
|
1152
|
+
* @param orgPid - The PID of the organization as registered in DefraDB.
|
|
1153
|
+
* @param orgName - The name of the organization as registered in DefraDB.
|
|
1154
|
+
* @param ownerAddress - The wallet address of the user who will be the default manager.
|
|
1155
|
+
* @param orgContractAddress - The contract address of the organization beacon.
|
|
1156
|
+
* @param adminSmartAccount - The smart account of the Anymal network administrator approving this org.
|
|
1157
|
+
* @param bundlerClient - The viem BundlerClient instance used for sending the user operation.
|
|
1158
|
+
* @returns A promise with success status and message.
|
|
1159
|
+
*/
|
|
1160
|
+
async (orgPid, orgName, ownerAddress, orgContractAddress, adminSmartAccount, bundlerClient) => {
|
|
1161
|
+
if (!orgPid || !orgName || !orgContractAddress || !bundlerClient || !adminSmartAccount || !ownerAddress) {
|
|
1162
|
+
return {
|
|
1163
|
+
success: false,
|
|
1164
|
+
message: "Missing required parameters for organization creation."
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
try {
|
|
1168
|
+
const callData = (0, import_viem5.encodeFunctionData)({
|
|
1169
|
+
abi: ORGANIZATION_ABI,
|
|
1170
|
+
functionName: "createOrganizationProxy",
|
|
1171
|
+
args: [ownerAddress, orgName, orgPid]
|
|
1172
|
+
});
|
|
1173
|
+
const userOpHash = await bundlerClient.sendUserOperation({
|
|
1174
|
+
account: adminSmartAccount,
|
|
1175
|
+
calls: [
|
|
1176
|
+
{
|
|
1177
|
+
to: orgContractAddress,
|
|
1178
|
+
data: callData
|
|
1179
|
+
}
|
|
1180
|
+
],
|
|
1181
|
+
maxPriorityFeePerGas: (0, import_viem5.parseGwei)("0.001"),
|
|
1182
|
+
// Low priority fee
|
|
1183
|
+
maxFeePerGas: (0, import_viem5.parseGwei)("0.025")
|
|
1184
|
+
// Max fee cap
|
|
1185
|
+
});
|
|
1186
|
+
const txReceipt = await bundlerClient.waitForUserOperationReceipt({
|
|
1187
|
+
hash: userOpHash
|
|
1188
|
+
});
|
|
1189
|
+
if (!txReceipt.success) {
|
|
1190
|
+
return {
|
|
1191
|
+
message: txReceipt.reason || "Unable to register organization.",
|
|
1192
|
+
success: false
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
let proxyAddress;
|
|
1196
|
+
for (const log of txReceipt.logs) {
|
|
1197
|
+
try {
|
|
1198
|
+
const decoded = (0, import_viem5.decodeEventLog)({
|
|
1199
|
+
abi: ORGANIZATION_ABI,
|
|
1200
|
+
data: log.data,
|
|
1201
|
+
topics: log.topics
|
|
1202
|
+
});
|
|
1203
|
+
if (decoded.eventName === "NewOrganizationCreated") {
|
|
1204
|
+
proxyAddress = decoded.args.proxyAddress;
|
|
1205
|
+
break;
|
|
1206
|
+
}
|
|
1207
|
+
} catch {
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
if (!proxyAddress) {
|
|
1211
|
+
return {
|
|
1212
|
+
success: true,
|
|
1213
|
+
message: "Organization registered successfully, but proxy address not found in logs."
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
return {
|
|
1217
|
+
success: true,
|
|
1218
|
+
message: "Organization registered successfully.",
|
|
1219
|
+
proxyAddress
|
|
1220
|
+
};
|
|
1221
|
+
} catch (error) {
|
|
1222
|
+
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";
|
|
1223
|
+
return {
|
|
1224
|
+
success: false,
|
|
1225
|
+
message: `Error processing organization: ${errorMessage}`
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
},
|
|
1229
|
+
[]
|
|
1230
|
+
);
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
// src/utils/organization/useApproveOrgKibbleToken.ts
|
|
1234
|
+
var import_react19 = require("react");
|
|
1235
|
+
var import_viem6 = require("viem");
|
|
1236
|
+
function useApproveOrgPartialPayment() {
|
|
1237
|
+
return (0, import_react19.useCallback)(
|
|
1238
|
+
async (orgContractAddress, kibbleTokenAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, approveAmount) => {
|
|
1239
|
+
if (!orgContractAddress || !kibbleTokenAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !approveAmount) {
|
|
1240
|
+
return {
|
|
1241
|
+
success: false,
|
|
1242
|
+
message: "Missing required parameters for approval."
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
try {
|
|
1246
|
+
const approveCalldata = (0, import_viem6.encodeFunctionData)({
|
|
1247
|
+
abi: import_viem6.erc20Abi,
|
|
1248
|
+
functionName: "approve",
|
|
1249
|
+
args: [partialPaymentModuleAddress, approveAmount]
|
|
1250
|
+
});
|
|
1251
|
+
const executeApproveCalldata = (0, import_viem6.encodeFunctionData)({
|
|
1252
|
+
abi: ORGANIZATION_ABI,
|
|
1253
|
+
functionName: "executeCall",
|
|
1254
|
+
args: [kibbleTokenAddress, approveCalldata]
|
|
1255
|
+
});
|
|
1256
|
+
const userOpApproveHash = await bundlerClient.sendUserOperation({
|
|
1257
|
+
account: managerSmartAccount,
|
|
1258
|
+
calls: [
|
|
1259
|
+
{
|
|
1260
|
+
to: orgContractAddress,
|
|
1261
|
+
data: executeApproveCalldata
|
|
1262
|
+
}
|
|
1263
|
+
],
|
|
1264
|
+
maxPriorityFeePerGas: (0, import_viem6.parseGwei)("0.001")
|
|
1265
|
+
// maxFeePerGas: parseGwei("0.01"),
|
|
1266
|
+
});
|
|
1267
|
+
await bundlerClient.waitForUserOperationReceipt({ hash: userOpApproveHash });
|
|
1268
|
+
return { success: true, message: "Approval processed successfully." };
|
|
1269
|
+
} catch (error) {
|
|
1270
|
+
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";
|
|
1271
|
+
return { success: false, message: `Error processing approval: ${errorMessage}` };
|
|
1272
|
+
}
|
|
1273
|
+
},
|
|
1274
|
+
[]
|
|
1275
|
+
);
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// src/utils/organization/useProcessOrgPartialKibblePayment.ts
|
|
1279
|
+
var import_react20 = require("react");
|
|
1280
|
+
var import_viem7 = require("viem");
|
|
1281
|
+
function useProcessOrgPartialKibblePayment() {
|
|
1282
|
+
return (0, import_react20.useCallback)(
|
|
1283
|
+
async (orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
1284
|
+
if (!orgContractAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !orderId || !pid || !nonce || !backendSignature) {
|
|
1285
|
+
return {
|
|
1286
|
+
success: false,
|
|
1287
|
+
message: "Missing required parameters for partial payment."
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
try {
|
|
1291
|
+
const partialPayCalldata = (0, import_viem7.encodeFunctionData)({
|
|
1292
|
+
abi: MARKETPLACE_ABI,
|
|
1293
|
+
functionName: "partialPay",
|
|
1294
|
+
args: [
|
|
1295
|
+
orderId,
|
|
1296
|
+
anymalNftId,
|
|
1297
|
+
pid,
|
|
1298
|
+
amountInTokens,
|
|
1299
|
+
maxTokenPayment,
|
|
1300
|
+
nonce,
|
|
1301
|
+
deadline,
|
|
1302
|
+
backendSignature
|
|
1303
|
+
]
|
|
1304
|
+
});
|
|
1305
|
+
const executePartialPayCalldata = (0, import_viem7.encodeFunctionData)({
|
|
1306
|
+
abi: ORGANIZATION_ABI,
|
|
1307
|
+
functionName: "executeCall",
|
|
1308
|
+
args: [partialPaymentModuleAddress, partialPayCalldata]
|
|
1309
|
+
});
|
|
1310
|
+
const userOpPartialPayHash = await bundlerClient.sendUserOperation({
|
|
1311
|
+
account: managerSmartAccount,
|
|
1312
|
+
calls: [
|
|
1313
|
+
{
|
|
1314
|
+
to: orgContractAddress,
|
|
1315
|
+
data: executePartialPayCalldata
|
|
1316
|
+
}
|
|
1317
|
+
],
|
|
1318
|
+
maxPriorityFeePerGas: (0, import_viem7.parseGwei)("0.001")
|
|
1319
|
+
// maxFeePerGas: parseGwei("0.01"),
|
|
1320
|
+
});
|
|
1321
|
+
await bundlerClient.waitForUserOperationReceipt({ hash: userOpPartialPayHash });
|
|
1322
|
+
return { success: true, message: "Partial payment processed successfully." };
|
|
1323
|
+
} catch (error) {
|
|
1324
|
+
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";
|
|
1325
|
+
return { success: false, message: `Error processing partial payment: ${errorMessage}` };
|
|
1326
|
+
}
|
|
1327
|
+
},
|
|
1328
|
+
[]
|
|
1329
|
+
);
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
// src/utils/organization/useUpdateOrgWalletAddress.ts
|
|
1333
|
+
var import_react21 = require("react");
|
|
1334
|
+
function useUpdateOrgWalletAddress() {
|
|
1335
|
+
return (0, import_react21.useCallback)(
|
|
1336
|
+
async (dbAuthToken, docID, baseWalletAddress, endpoint) => {
|
|
1337
|
+
try {
|
|
1338
|
+
const mutation = `
|
|
1339
|
+
mutation Update_AnymalOrganization($docID: [ID], $input: AnymalOrganizationMutationInputArg) {
|
|
1340
|
+
update_AnymalOrganization(docID: $docID, input: $input) {
|
|
1341
|
+
baseWalletAddress
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
`;
|
|
1345
|
+
const variables = {
|
|
1346
|
+
docID: [docID],
|
|
1347
|
+
input: {
|
|
1348
|
+
baseWalletAddress
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1351
|
+
const response = await fetch(endpoint, {
|
|
1352
|
+
method: "POST",
|
|
1353
|
+
headers: {
|
|
1354
|
+
"Content-Type": "application/json",
|
|
1355
|
+
Authorization: `Bearer ${dbAuthToken}`
|
|
1356
|
+
},
|
|
1357
|
+
body: JSON.stringify({
|
|
1358
|
+
query: mutation,
|
|
1359
|
+
variables
|
|
1360
|
+
})
|
|
1361
|
+
});
|
|
1362
|
+
if (!response.ok) {
|
|
1363
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
1364
|
+
}
|
|
1365
|
+
} catch (error) {
|
|
1366
|
+
console.error("Error updating baseWalletAddress:", error);
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
[]
|
|
1370
|
+
);
|
|
1371
|
+
}
|
|
1372
|
+
|
|
901
1373
|
// src/helpers/NonceHelper.tsx
|
|
902
1374
|
var import_uuid = require("uuid");
|
|
903
|
-
var
|
|
1375
|
+
var import_viem8 = require("viem");
|
|
904
1376
|
var generateBytes32Nonce = () => {
|
|
905
1377
|
const uuid2 = (0, import_uuid.v4)().replace(/-/g, "");
|
|
906
|
-
return (0,
|
|
1378
|
+
return (0, import_viem8.padHex)(`0x${uuid2}`, { size: 32 });
|
|
907
1379
|
};
|
|
908
1380
|
|
|
909
1381
|
// src/utils/application/useCreateUserAppData.ts
|
|
910
|
-
var
|
|
1382
|
+
var import_react22 = require("react");
|
|
911
1383
|
var import_uuid2 = require("uuid");
|
|
912
1384
|
function useCreateUserAppData() {
|
|
913
|
-
return (0,
|
|
1385
|
+
return (0, import_react22.useCallback)(
|
|
914
1386
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
915
1387
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
916
1388
|
const appValues = {
|
|
@@ -963,17 +1435,17 @@ function useCreateUserAppData() {
|
|
|
963
1435
|
}
|
|
964
1436
|
|
|
965
1437
|
// src/utils/balance/useFetchBalance.ts
|
|
966
|
-
var
|
|
967
|
-
var
|
|
1438
|
+
var import_react23 = require("react");
|
|
1439
|
+
var import_viem9 = require("viem");
|
|
968
1440
|
function useFetchBalance() {
|
|
969
|
-
return (0,
|
|
1441
|
+
return (0, import_react23.useCallback)(
|
|
970
1442
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
971
1443
|
try {
|
|
972
1444
|
const balance = await publicClient.readContract({
|
|
973
|
-
address: (0,
|
|
974
|
-
abi:
|
|
1445
|
+
address: (0, import_viem9.getAddress)(kibbleTokenAddress),
|
|
1446
|
+
abi: import_viem9.erc20Abi,
|
|
975
1447
|
functionName: "balanceOf",
|
|
976
|
-
args: [(0,
|
|
1448
|
+
args: [(0, import_viem9.getAddress)(walletAddress)]
|
|
977
1449
|
});
|
|
978
1450
|
return Number(balance);
|
|
979
1451
|
} catch (error) {
|
|
@@ -988,6 +1460,8 @@ function useFetchBalance() {
|
|
|
988
1460
|
generateBytes32Nonce,
|
|
989
1461
|
useAddAnymalToDatabase,
|
|
990
1462
|
useApproveKibbleToken,
|
|
1463
|
+
useApproveOrgPartialPayment,
|
|
1464
|
+
useCreateOrganizationBase,
|
|
991
1465
|
useCreateUserAppData,
|
|
992
1466
|
useCreateWeb3Account,
|
|
993
1467
|
useDeleteAnymalFromDatabase,
|
|
@@ -995,9 +1469,11 @@ function useFetchBalance() {
|
|
|
995
1469
|
useFetchNotifications,
|
|
996
1470
|
useFetchUserData,
|
|
997
1471
|
useMintAnymalNFT,
|
|
1472
|
+
useProcessOrgPartialKibblePayment,
|
|
998
1473
|
useProcessPartialKibblePayment,
|
|
999
1474
|
useSaveAnymalMetadata,
|
|
1000
1475
|
useUpdateAnymalWithNFT,
|
|
1476
|
+
useUpdateOrgWalletAddress,
|
|
1001
1477
|
useUpdateUserAsVerified,
|
|
1002
1478
|
useUpdateUserEmail,
|
|
1003
1479
|
useUpdateUserName,
|
package/dist/index.mjs
CHANGED
|
@@ -21,6 +21,245 @@ var VERIFY_ACCOUNT_ABI = [
|
|
|
21
21
|
}
|
|
22
22
|
];
|
|
23
23
|
var MARKETPLACE_ABI = [{ "inputs": [{ "internalType": "address", "name": "target", "type": "address" }], "name": "AddressEmptyCode", "type": "error" }, { "inputs": [], "name": "ECDSAInvalidSignature", "type": "error" }, { "inputs": [{ "internalType": "uint256", "name": "length", "type": "uint256" }], "name": "ECDSAInvalidSignatureLength", "type": "error" }, { "inputs": [{ "internalType": "bytes32", "name": "s", "type": "bytes32" }], "name": "ECDSAInvalidSignatureS", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "implementation", "type": "address" }], "name": "ERC1967InvalidImplementation", "type": "error" }, { "inputs": [], "name": "ERC1967NonPayable", "type": "error" }, { "inputs": [], "name": "FailedCall", "type": "error" }, { "inputs": [], "name": "InvalidInitialization", "type": "error" }, { "inputs": [], "name": "NotInitializing", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }], "name": "OwnableInvalidOwner", "type": "error" }, { "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "OwnableUnauthorizedAccount", "type": "error" }, { "inputs": [], "name": "UUPSUnauthorizedCallContext", "type": "error" }, { "inputs": [{ "internalType": "bytes32", "name": "slot", "type": "bytes32" }], "name": "UUPSUnsupportedProxiableUUID", "type": "error" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint64", "name": "version", "type": "uint64" }], "name": "Initialized", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }], "name": "OwnershipTransferred", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "string", "name": "orderId", "type": "string" }, { "indexed": true, "internalType": "address", "name": "payer", "type": "address" }, { "indexed": true, "internalType": "string", "name": "pid", "type": "string" }, { "indexed": false, "internalType": "string", "name": "anymalNftId", "type": "string" }, { "indexed": false, "internalType": "uint256", "name": "amountInTokens", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "timestamp", "type": "uint256" }], "name": "PartialPaymentMade", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "string", "name": "orderId", "type": "string" }, { "indexed": true, "internalType": "address", "name": "payer", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amountInTokens", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "timestamp", "type": "uint256" }], "name": "PaymentMade", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "string", "name": "orderId", "type": "string" }, { "indexed": true, "internalType": "address", "name": "payer", "type": "address" }, { "indexed": true, "internalType": "string", "name": "pid", "type": "string" }, { "indexed": false, "internalType": "uint256", "name": "refundedAmount", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "timestamp", "type": "uint256" }], "name": "RefundProcessed", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "bool", "name": "enabled", "type": "bool" }], "name": "SignatureCheckToggled", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "implementation", "type": "address" }], "name": "Upgraded", "type": "event" }, { "inputs": [], "name": "UPGRADE_INTERFACE_VERSION", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "authorizer", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_initialOwner", "type": "address" }, { "internalType": "address", "name": "_authorizer", "type": "address" }, { "internalType": "address", "name": "_kibbleToken", "type": "address" }], "name": "initialize", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "kibbleToken", "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }, { "internalType": "address", "name": "", "type": "address" }], "name": "paidAmounts", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "string", "name": "orderId", "type": "string" }, { "internalType": "string", "name": "anymalNftId", "type": "string" }, { "internalType": "string", "name": "pid", "type": "string" }, { "internalType": "uint256", "name": "amountInTokens", "type": "uint256" }, { "internalType": "uint256", "name": "maxTokenPayment", "type": "uint256" }, { "internalType": "bytes32", "name": "nonce", "type": "bytes32" }, { "internalType": "uint256", "name": "deadline", "type": "uint256" }, { "internalType": "bytes", "name": "backendSignature", "type": "bytes" }], "name": "partialPay", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "proxiableUUID", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "string", "name": "orderId", "type": "string" }, { "internalType": "address", "name": "payer", "type": "address" }, { "internalType": "string", "name": "pid", "type": "string" }], "name": "refund", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_authorizer", "type": "address" }], "name": "setAuthorizer", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bool", "name": "enabled", "type": "bool" }], "name": "setSignatureCheckEnabled", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "signatureCheckEnabled", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newImplementation", "type": "address" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "name": "upgradeToAndCall", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "name": "usedNonces", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "withdrawKibble", "outputs": [], "stateMutability": "nonpayable", "type": "function" }];
|
|
24
|
+
var ORGANIZATION_ABI = [
|
|
25
|
+
{
|
|
26
|
+
"inputs": [
|
|
27
|
+
{
|
|
28
|
+
"internalType": "address",
|
|
29
|
+
"name": "_initialImplementation",
|
|
30
|
+
"type": "address"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"internalType": "address",
|
|
34
|
+
"name": "_initialOwner",
|
|
35
|
+
"type": "address"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"internalType": "address",
|
|
39
|
+
"name": "_anymalNFTProxy",
|
|
40
|
+
"type": "address"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"stateMutability": "nonpayable",
|
|
44
|
+
"type": "constructor"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"inputs": [
|
|
48
|
+
{
|
|
49
|
+
"internalType": "address",
|
|
50
|
+
"name": "implementation",
|
|
51
|
+
"type": "address"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"name": "BeaconInvalidImplementation",
|
|
55
|
+
"type": "error"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"inputs": [
|
|
59
|
+
{
|
|
60
|
+
"internalType": "address",
|
|
61
|
+
"name": "owner",
|
|
62
|
+
"type": "address"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"name": "OwnableInvalidOwner",
|
|
66
|
+
"type": "error"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"inputs": [
|
|
70
|
+
{
|
|
71
|
+
"internalType": "address",
|
|
72
|
+
"name": "account",
|
|
73
|
+
"type": "address"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"name": "OwnableUnauthorizedAccount",
|
|
77
|
+
"type": "error"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"anonymous": false,
|
|
81
|
+
"inputs": [
|
|
82
|
+
{
|
|
83
|
+
"indexed": true,
|
|
84
|
+
"internalType": "string",
|
|
85
|
+
"name": "pid",
|
|
86
|
+
"type": "string"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"indexed": true,
|
|
90
|
+
"internalType": "string",
|
|
91
|
+
"name": "name",
|
|
92
|
+
"type": "string"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"indexed": false,
|
|
96
|
+
"internalType": "address",
|
|
97
|
+
"name": "proxyAddress",
|
|
98
|
+
"type": "address"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"indexed": false,
|
|
102
|
+
"internalType": "address",
|
|
103
|
+
"name": "networkAdmin",
|
|
104
|
+
"type": "address"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"indexed": false,
|
|
108
|
+
"internalType": "address",
|
|
109
|
+
"name": "userAdmin",
|
|
110
|
+
"type": "address"
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
"name": "NewOrganizationCreated",
|
|
114
|
+
"type": "event"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"anonymous": false,
|
|
118
|
+
"inputs": [
|
|
119
|
+
{
|
|
120
|
+
"indexed": true,
|
|
121
|
+
"internalType": "address",
|
|
122
|
+
"name": "previousOwner",
|
|
123
|
+
"type": "address"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"indexed": true,
|
|
127
|
+
"internalType": "address",
|
|
128
|
+
"name": "newOwner",
|
|
129
|
+
"type": "address"
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
"name": "OwnershipTransferred",
|
|
133
|
+
"type": "event"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"anonymous": false,
|
|
137
|
+
"inputs": [
|
|
138
|
+
{
|
|
139
|
+
"indexed": true,
|
|
140
|
+
"internalType": "address",
|
|
141
|
+
"name": "implementation",
|
|
142
|
+
"type": "address"
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
"name": "Upgraded",
|
|
146
|
+
"type": "event"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"inputs": [],
|
|
150
|
+
"name": "anymalNFTProxy",
|
|
151
|
+
"outputs": [
|
|
152
|
+
{
|
|
153
|
+
"internalType": "address",
|
|
154
|
+
"name": "",
|
|
155
|
+
"type": "address"
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"stateMutability": "view",
|
|
159
|
+
"type": "function"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"inputs": [
|
|
163
|
+
{
|
|
164
|
+
"internalType": "address",
|
|
165
|
+
"name": "_userAdmin",
|
|
166
|
+
"type": "address"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"internalType": "string",
|
|
170
|
+
"name": "_orgName",
|
|
171
|
+
"type": "string"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"internalType": "string",
|
|
175
|
+
"name": "_orgPid",
|
|
176
|
+
"type": "string"
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
"name": "createOrganizationProxy",
|
|
180
|
+
"outputs": [
|
|
181
|
+
{
|
|
182
|
+
"internalType": "address",
|
|
183
|
+
"name": "proxyAddress",
|
|
184
|
+
"type": "address"
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
"stateMutability": "nonpayable",
|
|
188
|
+
"type": "function"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"inputs": [],
|
|
192
|
+
"name": "implementation",
|
|
193
|
+
"outputs": [
|
|
194
|
+
{
|
|
195
|
+
"internalType": "address",
|
|
196
|
+
"name": "",
|
|
197
|
+
"type": "address"
|
|
198
|
+
}
|
|
199
|
+
],
|
|
200
|
+
"stateMutability": "view",
|
|
201
|
+
"type": "function"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"inputs": [],
|
|
205
|
+
"name": "owner",
|
|
206
|
+
"outputs": [
|
|
207
|
+
{
|
|
208
|
+
"internalType": "address",
|
|
209
|
+
"name": "",
|
|
210
|
+
"type": "address"
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
"stateMutability": "view",
|
|
214
|
+
"type": "function"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"inputs": [],
|
|
218
|
+
"name": "renounceOwnership",
|
|
219
|
+
"outputs": [],
|
|
220
|
+
"stateMutability": "nonpayable",
|
|
221
|
+
"type": "function"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"inputs": [
|
|
225
|
+
{
|
|
226
|
+
"internalType": "address",
|
|
227
|
+
"name": "newOwner",
|
|
228
|
+
"type": "address"
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
"name": "transferOwnership",
|
|
232
|
+
"outputs": [],
|
|
233
|
+
"stateMutability": "nonpayable",
|
|
234
|
+
"type": "function"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"inputs": [
|
|
238
|
+
{
|
|
239
|
+
"internalType": "address",
|
|
240
|
+
"name": "newImplementation",
|
|
241
|
+
"type": "address"
|
|
242
|
+
}
|
|
243
|
+
],
|
|
244
|
+
"name": "upgradeBeaconTo",
|
|
245
|
+
"outputs": [],
|
|
246
|
+
"stateMutability": "nonpayable",
|
|
247
|
+
"type": "function"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"inputs": [
|
|
251
|
+
{
|
|
252
|
+
"internalType": "address",
|
|
253
|
+
"name": "newImplementation",
|
|
254
|
+
"type": "address"
|
|
255
|
+
}
|
|
256
|
+
],
|
|
257
|
+
"name": "upgradeTo",
|
|
258
|
+
"outputs": [],
|
|
259
|
+
"stateMutability": "nonpayable",
|
|
260
|
+
"type": "function"
|
|
261
|
+
}
|
|
262
|
+
];
|
|
24
263
|
|
|
25
264
|
// src/utils/account/useVerifyAccount.ts
|
|
26
265
|
function useVerifyAccount() {
|
|
@@ -166,7 +405,7 @@ function useUpdateUserEmail() {
|
|
|
166
405
|
}
|
|
167
406
|
`;
|
|
168
407
|
const variables = {
|
|
169
|
-
|
|
408
|
+
docID: [docID],
|
|
170
409
|
input: {
|
|
171
410
|
email
|
|
172
411
|
}
|
|
@@ -207,7 +446,7 @@ function useUpdateUserPid() {
|
|
|
207
446
|
}
|
|
208
447
|
`;
|
|
209
448
|
const variables = {
|
|
210
|
-
|
|
449
|
+
docID: [docID],
|
|
211
450
|
input: {
|
|
212
451
|
pid
|
|
213
452
|
}
|
|
@@ -249,7 +488,7 @@ function useUpdateUserAsVerified() {
|
|
|
249
488
|
}
|
|
250
489
|
`;
|
|
251
490
|
const variables = {
|
|
252
|
-
|
|
491
|
+
docID: [docID],
|
|
253
492
|
input: {
|
|
254
493
|
isVerified: true
|
|
255
494
|
}
|
|
@@ -292,7 +531,7 @@ function useUpdateUserName() {
|
|
|
292
531
|
}
|
|
293
532
|
`;
|
|
294
533
|
const variables = {
|
|
295
|
-
|
|
534
|
+
docID: [docID],
|
|
296
535
|
input: {
|
|
297
536
|
name
|
|
298
537
|
}
|
|
@@ -525,7 +764,7 @@ function useDeleteAnymalFromDatabase() {
|
|
|
525
764
|
},
|
|
526
765
|
body: JSON.stringify({
|
|
527
766
|
query: mutation,
|
|
528
|
-
variables: {
|
|
767
|
+
variables: { docID: [anymalDocID] }
|
|
529
768
|
})
|
|
530
769
|
});
|
|
531
770
|
if (!response.ok)
|
|
@@ -853,6 +1092,235 @@ function useApproveKibbleToken() {
|
|
|
853
1092
|
);
|
|
854
1093
|
}
|
|
855
1094
|
|
|
1095
|
+
// src/utils/organization/useCreateOrganizationBase.ts
|
|
1096
|
+
import { useCallback as useCallback18 } from "react";
|
|
1097
|
+
import { decodeEventLog, encodeFunctionData as encodeFunctionData5, parseGwei as parseGwei5 } from "viem";
|
|
1098
|
+
function useCreateOrganizationBase() {
|
|
1099
|
+
return useCallback18(
|
|
1100
|
+
/**
|
|
1101
|
+
* Creates a new organization on-chain.
|
|
1102
|
+
*
|
|
1103
|
+
* @param orgPid - The PID of the organization as registered in DefraDB.
|
|
1104
|
+
* @param orgName - The name of the organization as registered in DefraDB.
|
|
1105
|
+
* @param ownerAddress - The wallet address of the user who will be the default manager.
|
|
1106
|
+
* @param orgContractAddress - The contract address of the organization beacon.
|
|
1107
|
+
* @param adminSmartAccount - The smart account of the Anymal network administrator approving this org.
|
|
1108
|
+
* @param bundlerClient - The viem BundlerClient instance used for sending the user operation.
|
|
1109
|
+
* @returns A promise with success status and message.
|
|
1110
|
+
*/
|
|
1111
|
+
async (orgPid, orgName, ownerAddress, orgContractAddress, adminSmartAccount, bundlerClient) => {
|
|
1112
|
+
if (!orgPid || !orgName || !orgContractAddress || !bundlerClient || !adminSmartAccount || !ownerAddress) {
|
|
1113
|
+
return {
|
|
1114
|
+
success: false,
|
|
1115
|
+
message: "Missing required parameters for organization creation."
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
try {
|
|
1119
|
+
const callData = encodeFunctionData5({
|
|
1120
|
+
abi: ORGANIZATION_ABI,
|
|
1121
|
+
functionName: "createOrganizationProxy",
|
|
1122
|
+
args: [ownerAddress, orgName, orgPid]
|
|
1123
|
+
});
|
|
1124
|
+
const userOpHash = await bundlerClient.sendUserOperation({
|
|
1125
|
+
account: adminSmartAccount,
|
|
1126
|
+
calls: [
|
|
1127
|
+
{
|
|
1128
|
+
to: orgContractAddress,
|
|
1129
|
+
data: callData
|
|
1130
|
+
}
|
|
1131
|
+
],
|
|
1132
|
+
maxPriorityFeePerGas: parseGwei5("0.001"),
|
|
1133
|
+
// Low priority fee
|
|
1134
|
+
maxFeePerGas: parseGwei5("0.025")
|
|
1135
|
+
// Max fee cap
|
|
1136
|
+
});
|
|
1137
|
+
const txReceipt = await bundlerClient.waitForUserOperationReceipt({
|
|
1138
|
+
hash: userOpHash
|
|
1139
|
+
});
|
|
1140
|
+
if (!txReceipt.success) {
|
|
1141
|
+
return {
|
|
1142
|
+
message: txReceipt.reason || "Unable to register organization.",
|
|
1143
|
+
success: false
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
let proxyAddress;
|
|
1147
|
+
for (const log of txReceipt.logs) {
|
|
1148
|
+
try {
|
|
1149
|
+
const decoded = decodeEventLog({
|
|
1150
|
+
abi: ORGANIZATION_ABI,
|
|
1151
|
+
data: log.data,
|
|
1152
|
+
topics: log.topics
|
|
1153
|
+
});
|
|
1154
|
+
if (decoded.eventName === "NewOrganizationCreated") {
|
|
1155
|
+
proxyAddress = decoded.args.proxyAddress;
|
|
1156
|
+
break;
|
|
1157
|
+
}
|
|
1158
|
+
} catch {
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
if (!proxyAddress) {
|
|
1162
|
+
return {
|
|
1163
|
+
success: true,
|
|
1164
|
+
message: "Organization registered successfully, but proxy address not found in logs."
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
return {
|
|
1168
|
+
success: true,
|
|
1169
|
+
message: "Organization registered successfully.",
|
|
1170
|
+
proxyAddress
|
|
1171
|
+
};
|
|
1172
|
+
} catch (error) {
|
|
1173
|
+
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";
|
|
1174
|
+
return {
|
|
1175
|
+
success: false,
|
|
1176
|
+
message: `Error processing organization: ${errorMessage}`
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
},
|
|
1180
|
+
[]
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
// src/utils/organization/useApproveOrgKibbleToken.ts
|
|
1185
|
+
import { useCallback as useCallback19 } from "react";
|
|
1186
|
+
import { encodeFunctionData as encodeFunctionData6, erc20Abi as erc20Abi2, parseGwei as parseGwei6 } from "viem";
|
|
1187
|
+
function useApproveOrgPartialPayment() {
|
|
1188
|
+
return useCallback19(
|
|
1189
|
+
async (orgContractAddress, kibbleTokenAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, approveAmount) => {
|
|
1190
|
+
if (!orgContractAddress || !kibbleTokenAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !approveAmount) {
|
|
1191
|
+
return {
|
|
1192
|
+
success: false,
|
|
1193
|
+
message: "Missing required parameters for approval."
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
try {
|
|
1197
|
+
const approveCalldata = encodeFunctionData6({
|
|
1198
|
+
abi: erc20Abi2,
|
|
1199
|
+
functionName: "approve",
|
|
1200
|
+
args: [partialPaymentModuleAddress, approveAmount]
|
|
1201
|
+
});
|
|
1202
|
+
const executeApproveCalldata = encodeFunctionData6({
|
|
1203
|
+
abi: ORGANIZATION_ABI,
|
|
1204
|
+
functionName: "executeCall",
|
|
1205
|
+
args: [kibbleTokenAddress, approveCalldata]
|
|
1206
|
+
});
|
|
1207
|
+
const userOpApproveHash = await bundlerClient.sendUserOperation({
|
|
1208
|
+
account: managerSmartAccount,
|
|
1209
|
+
calls: [
|
|
1210
|
+
{
|
|
1211
|
+
to: orgContractAddress,
|
|
1212
|
+
data: executeApproveCalldata
|
|
1213
|
+
}
|
|
1214
|
+
],
|
|
1215
|
+
maxPriorityFeePerGas: parseGwei6("0.001")
|
|
1216
|
+
// maxFeePerGas: parseGwei("0.01"),
|
|
1217
|
+
});
|
|
1218
|
+
await bundlerClient.waitForUserOperationReceipt({ hash: userOpApproveHash });
|
|
1219
|
+
return { success: true, message: "Approval processed successfully." };
|
|
1220
|
+
} catch (error) {
|
|
1221
|
+
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";
|
|
1222
|
+
return { success: false, message: `Error processing approval: ${errorMessage}` };
|
|
1223
|
+
}
|
|
1224
|
+
},
|
|
1225
|
+
[]
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// src/utils/organization/useProcessOrgPartialKibblePayment.ts
|
|
1230
|
+
import { useCallback as useCallback20 } from "react";
|
|
1231
|
+
import { encodeFunctionData as encodeFunctionData7, parseGwei as parseGwei7 } from "viem";
|
|
1232
|
+
function useProcessOrgPartialKibblePayment() {
|
|
1233
|
+
return useCallback20(
|
|
1234
|
+
async (orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
1235
|
+
if (!orgContractAddress || !partialPaymentModuleAddress || !managerSmartAccount || !bundlerClient || !orderId || !pid || !nonce || !backendSignature) {
|
|
1236
|
+
return {
|
|
1237
|
+
success: false,
|
|
1238
|
+
message: "Missing required parameters for partial payment."
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
try {
|
|
1242
|
+
const partialPayCalldata = encodeFunctionData7({
|
|
1243
|
+
abi: MARKETPLACE_ABI,
|
|
1244
|
+
functionName: "partialPay",
|
|
1245
|
+
args: [
|
|
1246
|
+
orderId,
|
|
1247
|
+
anymalNftId,
|
|
1248
|
+
pid,
|
|
1249
|
+
amountInTokens,
|
|
1250
|
+
maxTokenPayment,
|
|
1251
|
+
nonce,
|
|
1252
|
+
deadline,
|
|
1253
|
+
backendSignature
|
|
1254
|
+
]
|
|
1255
|
+
});
|
|
1256
|
+
const executePartialPayCalldata = encodeFunctionData7({
|
|
1257
|
+
abi: ORGANIZATION_ABI,
|
|
1258
|
+
functionName: "executeCall",
|
|
1259
|
+
args: [partialPaymentModuleAddress, partialPayCalldata]
|
|
1260
|
+
});
|
|
1261
|
+
const userOpPartialPayHash = await bundlerClient.sendUserOperation({
|
|
1262
|
+
account: managerSmartAccount,
|
|
1263
|
+
calls: [
|
|
1264
|
+
{
|
|
1265
|
+
to: orgContractAddress,
|
|
1266
|
+
data: executePartialPayCalldata
|
|
1267
|
+
}
|
|
1268
|
+
],
|
|
1269
|
+
maxPriorityFeePerGas: parseGwei7("0.001")
|
|
1270
|
+
// maxFeePerGas: parseGwei("0.01"),
|
|
1271
|
+
});
|
|
1272
|
+
await bundlerClient.waitForUserOperationReceipt({ hash: userOpPartialPayHash });
|
|
1273
|
+
return { success: true, message: "Partial payment processed successfully." };
|
|
1274
|
+
} catch (error) {
|
|
1275
|
+
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";
|
|
1276
|
+
return { success: false, message: `Error processing partial payment: ${errorMessage}` };
|
|
1277
|
+
}
|
|
1278
|
+
},
|
|
1279
|
+
[]
|
|
1280
|
+
);
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
// src/utils/organization/useUpdateOrgWalletAddress.ts
|
|
1284
|
+
import { useCallback as useCallback21 } from "react";
|
|
1285
|
+
function useUpdateOrgWalletAddress() {
|
|
1286
|
+
return useCallback21(
|
|
1287
|
+
async (dbAuthToken, docID, baseWalletAddress, endpoint) => {
|
|
1288
|
+
try {
|
|
1289
|
+
const mutation = `
|
|
1290
|
+
mutation Update_AnymalOrganization($docID: [ID], $input: AnymalOrganizationMutationInputArg) {
|
|
1291
|
+
update_AnymalOrganization(docID: $docID, input: $input) {
|
|
1292
|
+
baseWalletAddress
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
`;
|
|
1296
|
+
const variables = {
|
|
1297
|
+
docID: [docID],
|
|
1298
|
+
input: {
|
|
1299
|
+
baseWalletAddress
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
const response = await fetch(endpoint, {
|
|
1303
|
+
method: "POST",
|
|
1304
|
+
headers: {
|
|
1305
|
+
"Content-Type": "application/json",
|
|
1306
|
+
Authorization: `Bearer ${dbAuthToken}`
|
|
1307
|
+
},
|
|
1308
|
+
body: JSON.stringify({
|
|
1309
|
+
query: mutation,
|
|
1310
|
+
variables
|
|
1311
|
+
})
|
|
1312
|
+
});
|
|
1313
|
+
if (!response.ok) {
|
|
1314
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
1315
|
+
}
|
|
1316
|
+
} catch (error) {
|
|
1317
|
+
console.error("Error updating baseWalletAddress:", error);
|
|
1318
|
+
}
|
|
1319
|
+
},
|
|
1320
|
+
[]
|
|
1321
|
+
);
|
|
1322
|
+
}
|
|
1323
|
+
|
|
856
1324
|
// src/helpers/NonceHelper.tsx
|
|
857
1325
|
import { v4 as uuidv4 } from "uuid";
|
|
858
1326
|
import { padHex } from "viem";
|
|
@@ -862,10 +1330,10 @@ var generateBytes32Nonce = () => {
|
|
|
862
1330
|
};
|
|
863
1331
|
|
|
864
1332
|
// src/utils/application/useCreateUserAppData.ts
|
|
865
|
-
import { useCallback as
|
|
1333
|
+
import { useCallback as useCallback22 } from "react";
|
|
866
1334
|
import { v4 as uuid } from "uuid";
|
|
867
1335
|
function useCreateUserAppData() {
|
|
868
|
-
return
|
|
1336
|
+
return useCallback22(
|
|
869
1337
|
async (appId, pid, dbAuthToken, endpoint) => {
|
|
870
1338
|
if (!dbAuthToken || !pid || !dbAuthToken || !endpoint) return;
|
|
871
1339
|
const appValues = {
|
|
@@ -918,15 +1386,15 @@ function useCreateUserAppData() {
|
|
|
918
1386
|
}
|
|
919
1387
|
|
|
920
1388
|
// src/utils/balance/useFetchBalance.ts
|
|
921
|
-
import { useCallback as
|
|
922
|
-
import { erc20Abi as
|
|
1389
|
+
import { useCallback as useCallback23 } from "react";
|
|
1390
|
+
import { erc20Abi as erc20Abi3, getAddress } from "viem";
|
|
923
1391
|
function useFetchBalance() {
|
|
924
|
-
return
|
|
1392
|
+
return useCallback23(
|
|
925
1393
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
926
1394
|
try {
|
|
927
1395
|
const balance = await publicClient.readContract({
|
|
928
1396
|
address: getAddress(kibbleTokenAddress),
|
|
929
|
-
abi:
|
|
1397
|
+
abi: erc20Abi3,
|
|
930
1398
|
functionName: "balanceOf",
|
|
931
1399
|
args: [getAddress(walletAddress)]
|
|
932
1400
|
});
|
|
@@ -942,6 +1410,8 @@ export {
|
|
|
942
1410
|
generateBytes32Nonce,
|
|
943
1411
|
useAddAnymalToDatabase,
|
|
944
1412
|
useApproveKibbleToken,
|
|
1413
|
+
useApproveOrgPartialPayment,
|
|
1414
|
+
useCreateOrganizationBase,
|
|
945
1415
|
useCreateUserAppData,
|
|
946
1416
|
useCreateWeb3Account,
|
|
947
1417
|
useDeleteAnymalFromDatabase,
|
|
@@ -949,9 +1419,11 @@ export {
|
|
|
949
1419
|
useFetchNotifications,
|
|
950
1420
|
useFetchUserData,
|
|
951
1421
|
useMintAnymalNFT,
|
|
1422
|
+
useProcessOrgPartialKibblePayment,
|
|
952
1423
|
useProcessPartialKibblePayment,
|
|
953
1424
|
useSaveAnymalMetadata,
|
|
954
1425
|
useUpdateAnymalWithNFT,
|
|
1426
|
+
useUpdateOrgWalletAddress,
|
|
955
1427
|
useUpdateUserAsVerified,
|
|
956
1428
|
useUpdateUserEmail,
|
|
957
1429
|
useUpdateUserName,
|
package/package.json
CHANGED