anymal-protocol 1.0.117 → 1.0.119
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/{chunk-F72KTNHS.mjs → chunk-OBXCSRGF.mjs} +109 -1
- package/dist/cli/index.mjs +2 -36
- package/dist/index.d.mts +59 -11
- package/dist/index.d.ts +59 -11
- package/dist/index.js +487 -160
- package/dist/index.mjs +368 -151
- package/package.json +1 -1
- package/dist/chunk-43I5M7QS.mjs +0 -93
- package/dist/chunk-5UXBNDDZ.mjs +0 -93
- package/dist/chunk-DIGESQEI.mjs +0 -91
- package/dist/chunk-KEC6WLEL.mjs +0 -93
- package/dist/chunk-QHK3YPLJ.mjs +0 -93
package/dist/index.js
CHANGED
|
@@ -24,6 +24,8 @@ __export(index_exports, {
|
|
|
24
24
|
ActionSourceType: () => ActionSourceType,
|
|
25
25
|
ActionStatus: () => ActionStatus,
|
|
26
26
|
ActionType: () => ActionType,
|
|
27
|
+
FIREBASE_WEB_API_KEYS: () => FIREBASE_WEB_API_KEYS,
|
|
28
|
+
FIREBASE_WEB_AUTH_API_ENDPOINTS: () => FIREBASE_WEB_AUTH_API_ENDPOINTS,
|
|
27
29
|
MarketplacePaymentType: () => MarketplacePaymentType,
|
|
28
30
|
NETWORK_HOSTS: () => NETWORK_HOSTS,
|
|
29
31
|
Network: () => Network,
|
|
@@ -31,12 +33,20 @@ __export(index_exports, {
|
|
|
31
33
|
convertToActionRecord: () => convertToActionRecord,
|
|
32
34
|
convertToMultipleActionDefinitions: () => convertToMultipleActionDefinitions,
|
|
33
35
|
convertToMultipleActionRecords: () => convertToMultipleActionRecords,
|
|
36
|
+
createApp: () => createApp,
|
|
34
37
|
createAuthEnvelope: () => createAuthEnvelope,
|
|
35
38
|
fetchAnymals: () => fetchAnymals,
|
|
39
|
+
flattenFirestoreData: () => flattenFirestoreData,
|
|
36
40
|
generateAppSignature: () => generateAppSignature,
|
|
37
41
|
generateBytes32Nonce: () => generateBytes32Nonce,
|
|
38
42
|
generateJWT: () => generateJWT,
|
|
43
|
+
getFirebaseTokenForApp: () => getFirebaseTokenForApp,
|
|
39
44
|
loadExistingSecp256k1PrivateKey: () => loadExistingSecp256k1PrivateKey,
|
|
45
|
+
processDirectKibbleApproval: () => processDirectKibbleApproval,
|
|
46
|
+
processDirectPartialPayment: () => processDirectPartialPayment,
|
|
47
|
+
processOrgKibbleApproval: () => processOrgKibbleApproval,
|
|
48
|
+
processOrgPartialPayment: () => processOrgPartialPayment,
|
|
49
|
+
sendUserOpWithRetries: () => sendUserOpWithRetries,
|
|
40
50
|
serializePublicKeyCompressed: () => serializePublicKeyCompressed,
|
|
41
51
|
submitAction: () => submitAction,
|
|
42
52
|
useAddAnymalToDatabase: () => useAddAnymalToDatabase,
|
|
@@ -68,7 +78,9 @@ __export(index_exports, {
|
|
|
68
78
|
useUpdateUserPid: () => useUpdateUserPid,
|
|
69
79
|
useUploadAnymalImage: () => useUploadAnymalImage,
|
|
70
80
|
useVerifyAccount: () => useVerifyAccount,
|
|
71
|
-
useVerifyWeb3AuthSession: () => useVerifyWeb3AuthSession
|
|
81
|
+
useVerifyWeb3AuthSession: () => useVerifyWeb3AuthSession,
|
|
82
|
+
waitForAllowance: () => waitForAllowance,
|
|
83
|
+
waitForReceiptWithRetries: () => waitForReceiptWithRetries
|
|
72
84
|
});
|
|
73
85
|
module.exports = __toCommonJS(index_exports);
|
|
74
86
|
|
|
@@ -1274,35 +1286,36 @@ async function applyBundlerGasEstimator(account, bundlerClient, options) {
|
|
|
1274
1286
|
verificationGasMultiplier = 1.2,
|
|
1275
1287
|
preVerificationGasMultiplier = 2,
|
|
1276
1288
|
maxCallGasPercentOfBlock = 0.1,
|
|
1277
|
-
// 10% for now?
|
|
1278
1289
|
debug = true
|
|
1279
1290
|
} = options || {};
|
|
1280
1291
|
const publicClient = bundlerClient.client;
|
|
1281
1292
|
const blockGasLimit = (await publicClient.getBlock()).gasLimit;
|
|
1282
1293
|
const dynamicCallGasCap = blockGasLimit * BigInt(Math.floor(maxCallGasPercentOfBlock * 100)) / 100n;
|
|
1283
1294
|
account.userOperation = {
|
|
1295
|
+
...account.userOperation,
|
|
1284
1296
|
estimateGas: async (userOp) => {
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1297
|
+
try {
|
|
1298
|
+
const estimate = await bundlerClient.estimateUserOperationGas(userOp);
|
|
1299
|
+
const paddedCallGasLimit = estimate.callGasLimit * BigInt(Math.ceil(callGasMultiplier * 100)) / 100n;
|
|
1300
|
+
const cappedCallGasLimit = paddedCallGasLimit > dynamicCallGasCap ? dynamicCallGasCap : paddedCallGasLimit;
|
|
1301
|
+
const paddedVerificationGasLimit = estimate.verificationGasLimit * BigInt(Math.ceil(verificationGasMultiplier * 100)) / 100n;
|
|
1302
|
+
const paddedPreVerificationGas = estimate.preVerificationGas * BigInt(Math.ceil(preVerificationGasMultiplier * 100)) / 100n;
|
|
1303
|
+
if (debug) {
|
|
1304
|
+
console.log("\u2705 Gas Estimation Success:");
|
|
1305
|
+
console.log(" callGasLimit (capped):", cappedCallGasLimit.toString());
|
|
1306
|
+
console.log(" verificationGasLimit:", paddedVerificationGasLimit.toString());
|
|
1307
|
+
console.log(" preVerificationGas:", paddedPreVerificationGas.toString());
|
|
1308
|
+
}
|
|
1309
|
+
return {
|
|
1310
|
+
...estimate,
|
|
1311
|
+
callGasLimit: cappedCallGasLimit,
|
|
1312
|
+
verificationGasLimit: paddedVerificationGasLimit,
|
|
1313
|
+
preVerificationGas: paddedPreVerificationGas
|
|
1314
|
+
};
|
|
1315
|
+
} catch (error) {
|
|
1316
|
+
console.error("\u274C Gas estimation failed!", error);
|
|
1317
|
+
throw error;
|
|
1299
1318
|
}
|
|
1300
|
-
return {
|
|
1301
|
-
...estimate,
|
|
1302
|
-
callGasLimit: cappedCallGasLimit,
|
|
1303
|
-
verificationGasLimit: paddedVerificationGasLimit,
|
|
1304
|
-
preVerificationGas: paddedPreVerificationGas
|
|
1305
|
-
};
|
|
1306
1319
|
}
|
|
1307
1320
|
};
|
|
1308
1321
|
}
|
|
@@ -1328,7 +1341,7 @@ function useMintAnymalNFT() {
|
|
|
1328
1341
|
anymalTxId
|
|
1329
1342
|
]
|
|
1330
1343
|
});
|
|
1331
|
-
applyBundlerGasEstimator(smartAccount, bundlerClient);
|
|
1344
|
+
await applyBundlerGasEstimator(smartAccount, bundlerClient);
|
|
1332
1345
|
const userOpHash = await bundlerClient.sendUserOperation({
|
|
1333
1346
|
account: smartAccount,
|
|
1334
1347
|
calls: [
|
|
@@ -1722,8 +1735,104 @@ function useFetchAnymals() {
|
|
|
1722
1735
|
}
|
|
1723
1736
|
|
|
1724
1737
|
// src/utils/marketplace/useProcessPartialKibblePayment.ts
|
|
1725
|
-
var import_viem2 = require("viem");
|
|
1726
1738
|
var import_react17 = require("react");
|
|
1739
|
+
|
|
1740
|
+
// src/helpers/ProcessDirectPartialPayment.tsx
|
|
1741
|
+
var import_viem2 = require("viem");
|
|
1742
|
+
|
|
1743
|
+
// src/helpers/SendUserOpWithRetries.tsx
|
|
1744
|
+
async function sendUserOpWithRetries(bundlerClient, params, retries = 3, delay = 1e3) {
|
|
1745
|
+
let attempt = 0;
|
|
1746
|
+
let lastError;
|
|
1747
|
+
while (attempt < retries) {
|
|
1748
|
+
try {
|
|
1749
|
+
return await bundlerClient.sendUserOperation(params);
|
|
1750
|
+
} catch (err) {
|
|
1751
|
+
lastError = err;
|
|
1752
|
+
console.warn(`\u{1F6D1} sendUserOperation failed (attempt ${attempt + 1}):`, err);
|
|
1753
|
+
attempt++;
|
|
1754
|
+
if (attempt < retries) await new Promise((r) => setTimeout(r, delay));
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
throw new Error(`sendUserOperation failed after ${retries} attempts: ${lastError}`);
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
// src/helpers/WaitForReceiptWithRetries.tsx
|
|
1761
|
+
async function waitForReceiptWithRetries(bundlerClient, hash, retries = 3, delay = 2e3) {
|
|
1762
|
+
let attempt = 0;
|
|
1763
|
+
let lastError;
|
|
1764
|
+
while (attempt < retries) {
|
|
1765
|
+
try {
|
|
1766
|
+
const receipt = await bundlerClient.waitForUserOperationReceipt(
|
|
1767
|
+
{
|
|
1768
|
+
hash,
|
|
1769
|
+
timeout: 3e4,
|
|
1770
|
+
retryCount: 10
|
|
1771
|
+
}
|
|
1772
|
+
);
|
|
1773
|
+
if (!receipt.success) {
|
|
1774
|
+
throw new Error(`UserOperation reverted: ${receipt.reason || "unknown"}`);
|
|
1775
|
+
}
|
|
1776
|
+
return receipt;
|
|
1777
|
+
} catch (err) {
|
|
1778
|
+
lastError = err;
|
|
1779
|
+
console.warn(`\u{1F6D1} waitForUserOperationReceipt failed (attempt ${attempt + 1}):`, err);
|
|
1780
|
+
attempt++;
|
|
1781
|
+
if (attempt < retries) await new Promise((r) => setTimeout(r, delay));
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
throw new Error(`waitForUserOperationReceipt failed after ${retries} attempts: ${lastError}`);
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
// src/helpers/ProcessDirectPartialPayment.tsx
|
|
1788
|
+
async function processDirectPartialPayment(marketplaceContract, smartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) {
|
|
1789
|
+
try {
|
|
1790
|
+
const publicClient = bundlerClient.client;
|
|
1791
|
+
const allowance = await publicClient.readContract({
|
|
1792
|
+
abi: import_viem2.erc20Abi,
|
|
1793
|
+
address: marketplaceContract,
|
|
1794
|
+
functionName: "allowance",
|
|
1795
|
+
args: [smartAccount.address, marketplaceContract]
|
|
1796
|
+
});
|
|
1797
|
+
if (allowance < amountInTokens) {
|
|
1798
|
+
return { success: false, message: "Insufficient allowance for direct partial payment." };
|
|
1799
|
+
}
|
|
1800
|
+
const partialPayCalldata = (0, import_viem2.encodeFunctionData)({
|
|
1801
|
+
abi: MARKETPLACE_ABI,
|
|
1802
|
+
functionName: "partialPay",
|
|
1803
|
+
args: [
|
|
1804
|
+
orderId,
|
|
1805
|
+
anymalNftId,
|
|
1806
|
+
pid,
|
|
1807
|
+
amountInTokens,
|
|
1808
|
+
maxTokenPayment,
|
|
1809
|
+
nonce,
|
|
1810
|
+
deadline,
|
|
1811
|
+
backendSignature
|
|
1812
|
+
]
|
|
1813
|
+
});
|
|
1814
|
+
await applyBundlerGasEstimator(smartAccount, bundlerClient);
|
|
1815
|
+
const userOpHash = await sendUserOpWithRetries(bundlerClient, {
|
|
1816
|
+
account: smartAccount,
|
|
1817
|
+
calls: [{ to: marketplaceContract, data: partialPayCalldata }],
|
|
1818
|
+
paymaster: true
|
|
1819
|
+
});
|
|
1820
|
+
await waitForReceiptWithRetries(bundlerClient, userOpHash);
|
|
1821
|
+
return {
|
|
1822
|
+
success: true,
|
|
1823
|
+
message: "Direct partial payment UserOperation executed successfully.",
|
|
1824
|
+
opHash: userOpHash
|
|
1825
|
+
};
|
|
1826
|
+
} catch (error) {
|
|
1827
|
+
const errorMessage = error instanceof Error ? error.cause?.message || error.message : "An unknown error occurred.";
|
|
1828
|
+
return {
|
|
1829
|
+
success: false,
|
|
1830
|
+
message: `Error during direct payment processing: ${errorMessage}`
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
// src/utils/marketplace/useProcessPartialKibblePayment.ts
|
|
1727
1836
|
function useProcessPartialKibblePayment() {
|
|
1728
1837
|
return (0, import_react17.useCallback)(
|
|
1729
1838
|
async (pid, nftId, orderId, dbAuthToken, marketplaceContract, smartAccount, bundlerClient, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
@@ -1751,31 +1860,25 @@ function useProcessPartialKibblePayment() {
|
|
|
1751
1860
|
backendSignature
|
|
1752
1861
|
// bytes
|
|
1753
1862
|
];
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
}
|
|
1771
|
-
const receipt = await bundlerClient.waitForUserOperationReceipt({
|
|
1772
|
-
hash: userOpHash,
|
|
1773
|
-
timeout: 3e4,
|
|
1774
|
-
retryCount: 10
|
|
1775
|
-
});
|
|
1776
|
-
return { success: true, message: receipt.userOpHash };
|
|
1863
|
+
const result = await processDirectPartialPayment(
|
|
1864
|
+
marketplaceContract,
|
|
1865
|
+
smartAccount,
|
|
1866
|
+
bundlerClient,
|
|
1867
|
+
orderId,
|
|
1868
|
+
nftId,
|
|
1869
|
+
pid,
|
|
1870
|
+
amountInTokens,
|
|
1871
|
+
maxTokenPayment,
|
|
1872
|
+
nonce,
|
|
1873
|
+
deadline,
|
|
1874
|
+
backendSignature
|
|
1875
|
+
);
|
|
1876
|
+
return {
|
|
1877
|
+
success: result.success,
|
|
1878
|
+
message: result.message
|
|
1879
|
+
};
|
|
1777
1880
|
} catch (error) {
|
|
1778
|
-
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
|
|
1881
|
+
const errorMessage = error instanceof Error ? error.cause?.message || error.message : "An unknown error occurred.";
|
|
1779
1882
|
return {
|
|
1780
1883
|
success: false,
|
|
1781
1884
|
message: `Error processing payment: ${errorMessage}`
|
|
@@ -1787,41 +1890,53 @@ function useProcessPartialKibblePayment() {
|
|
|
1787
1890
|
}
|
|
1788
1891
|
|
|
1789
1892
|
// src/utils/marketplace/useApproveKibbleToken.ts
|
|
1790
|
-
var import_viem3 = require("viem");
|
|
1791
1893
|
var import_react18 = require("react");
|
|
1894
|
+
|
|
1895
|
+
// src/helpers/ProcessDirectKibbleApproval.tsx
|
|
1896
|
+
var import_viem3 = require("viem");
|
|
1897
|
+
async function processDirectKibbleApproval(kibbleTokenAddress, spenderAddress, smartAccount, bundlerClient, approveAmount) {
|
|
1898
|
+
try {
|
|
1899
|
+
const approveCalldata = (0, import_viem3.encodeFunctionData)({
|
|
1900
|
+
abi: import_viem3.erc20Abi,
|
|
1901
|
+
functionName: "approve",
|
|
1902
|
+
args: [spenderAddress, approveAmount]
|
|
1903
|
+
});
|
|
1904
|
+
await applyBundlerGasEstimator(smartAccount, bundlerClient);
|
|
1905
|
+
const userOpHash = await sendUserOpWithRetries(bundlerClient, {
|
|
1906
|
+
account: smartAccount,
|
|
1907
|
+
calls: [{ to: kibbleTokenAddress, data: approveCalldata }],
|
|
1908
|
+
paymaster: true
|
|
1909
|
+
});
|
|
1910
|
+
await waitForReceiptWithRetries(bundlerClient, userOpHash);
|
|
1911
|
+
return {
|
|
1912
|
+
success: true,
|
|
1913
|
+
message: "Direct approval UserOperation executed successfully.",
|
|
1914
|
+
opHash: userOpHash
|
|
1915
|
+
};
|
|
1916
|
+
} catch (error) {
|
|
1917
|
+
const errorMessage = error instanceof Error ? error.cause?.message || error.message : "An unknown error occurred.";
|
|
1918
|
+
return {
|
|
1919
|
+
success: false,
|
|
1920
|
+
message: `Error during direct approval processing: ${errorMessage}`
|
|
1921
|
+
};
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
// src/utils/marketplace/useApproveKibbleToken.ts
|
|
1792
1926
|
function useApproveKibbleToken() {
|
|
1793
1927
|
return (0, import_react18.useCallback)(
|
|
1794
1928
|
async (kibbleTokenAddress, marketplaceContract, amount, smartAccount, bundlerClient) => {
|
|
1795
1929
|
try {
|
|
1796
|
-
const
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
// amount to approve
|
|
1804
|
-
]
|
|
1805
|
-
});
|
|
1806
|
-
applyBundlerGasEstimator(smartAccount, bundlerClient);
|
|
1807
|
-
const userOpHash = await bundlerClient.sendUserOperation({
|
|
1808
|
-
account: smartAccount,
|
|
1809
|
-
calls: [
|
|
1810
|
-
{
|
|
1811
|
-
to: kibbleTokenAddress,
|
|
1812
|
-
data: callData
|
|
1813
|
-
}
|
|
1814
|
-
],
|
|
1815
|
-
paymaster: true
|
|
1816
|
-
});
|
|
1817
|
-
await bundlerClient.waitForUserOperationReceipt({
|
|
1818
|
-
hash: userOpHash,
|
|
1819
|
-
timeout: 3e4,
|
|
1820
|
-
retryCount: 10
|
|
1821
|
-
});
|
|
1930
|
+
const result = await processDirectKibbleApproval(
|
|
1931
|
+
kibbleTokenAddress,
|
|
1932
|
+
marketplaceContract,
|
|
1933
|
+
smartAccount,
|
|
1934
|
+
bundlerClient,
|
|
1935
|
+
amount
|
|
1936
|
+
);
|
|
1822
1937
|
return {
|
|
1823
|
-
success:
|
|
1824
|
-
message:
|
|
1938
|
+
success: result.success,
|
|
1939
|
+
message: result.message
|
|
1825
1940
|
};
|
|
1826
1941
|
} catch (error) {
|
|
1827
1942
|
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
|
|
@@ -1864,7 +1979,7 @@ function useCreateOrganizationBase() {
|
|
|
1864
1979
|
functionName: "createOrganizationProxy",
|
|
1865
1980
|
args: [ownerAddress, orgName, orgPid]
|
|
1866
1981
|
});
|
|
1867
|
-
applyBundlerGasEstimator(adminSmartAccount, bundlerClient);
|
|
1982
|
+
await applyBundlerGasEstimator(adminSmartAccount, bundlerClient);
|
|
1868
1983
|
const userOpHash = await bundlerClient.sendUserOperation({
|
|
1869
1984
|
account: adminSmartAccount,
|
|
1870
1985
|
calls: [
|
|
@@ -1926,7 +2041,92 @@ function useCreateOrganizationBase() {
|
|
|
1926
2041
|
|
|
1927
2042
|
// src/utils/organization/useApproveOrgKibbleToken.ts
|
|
1928
2043
|
var import_react20 = require("react");
|
|
2044
|
+
|
|
2045
|
+
// src/helpers/ProcessOrgKibbleApproval.tsx
|
|
2046
|
+
var import_viem6 = require("viem");
|
|
2047
|
+
|
|
2048
|
+
// src/helpers/WaitForAllowance.tsx
|
|
1929
2049
|
var import_viem5 = require("viem");
|
|
2050
|
+
async function waitForAllowance(publicClient, tokenAddress, ownerAddress, spenderAddress, expectedAmount) {
|
|
2051
|
+
const MAX_RETRIES = 10;
|
|
2052
|
+
const RETRY_INTERVAL = 2e3;
|
|
2053
|
+
console.log(` MDEBUG: Polling for allowance of ${expectedAmount} for spender ${spenderAddress}...`);
|
|
2054
|
+
for (let i = 0; i < MAX_RETRIES; i++) {
|
|
2055
|
+
try {
|
|
2056
|
+
const currentAllowance = await publicClient.readContract({
|
|
2057
|
+
address: tokenAddress,
|
|
2058
|
+
abi: import_viem5.erc20Abi,
|
|
2059
|
+
functionName: "allowance",
|
|
2060
|
+
args: [ownerAddress, spenderAddress]
|
|
2061
|
+
});
|
|
2062
|
+
console.log(` MDEBUG: (Attempt ${i + 1}) Current allowance is ${currentAllowance.toString()}`);
|
|
2063
|
+
if (currentAllowance >= expectedAmount) {
|
|
2064
|
+
console.log(` MDEBUG: \u2705 Allowance confirmed on-chain. ${currentAllowance}`);
|
|
2065
|
+
return true;
|
|
2066
|
+
}
|
|
2067
|
+
} catch (error) {
|
|
2068
|
+
const errorMessage = error instanceof Error ? error.cause?.message || error.message : "An unknown error occurred waiting for allowance.";
|
|
2069
|
+
console.log(` MDEBUG: Error polling for allowance: ${errorMessage}`);
|
|
2070
|
+
}
|
|
2071
|
+
await new Promise((res) => setTimeout(res, RETRY_INTERVAL));
|
|
2072
|
+
}
|
|
2073
|
+
console.log(" MDEBUG: \u274C Timed out waiting for allowance confirmation.");
|
|
2074
|
+
return false;
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
// src/helpers/ProcessOrgKibbleApproval.tsx
|
|
2078
|
+
async function processOrgKibbleApproval(orgContractAddress, kibbleTokenAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, approveAmount) {
|
|
2079
|
+
try {
|
|
2080
|
+
if (approveAmount <= 0n) {
|
|
2081
|
+
return { success: false, message: "Approval amount must be greater than zero." };
|
|
2082
|
+
}
|
|
2083
|
+
const approveCalldata = (0, import_viem6.encodeFunctionData)({
|
|
2084
|
+
abi: import_viem6.erc20Abi,
|
|
2085
|
+
functionName: "approve",
|
|
2086
|
+
args: [partialPaymentModuleAddress, approveAmount]
|
|
2087
|
+
});
|
|
2088
|
+
const executeApproveCalldata = (0, import_viem6.encodeFunctionData)({
|
|
2089
|
+
abi: ORGANIZATION_IMPL_ABI,
|
|
2090
|
+
functionName: "executeCall",
|
|
2091
|
+
args: [kibbleTokenAddress, approveCalldata]
|
|
2092
|
+
});
|
|
2093
|
+
await applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
|
|
2094
|
+
const userOpApproveHash = await sendUserOpWithRetries(bundlerClient, {
|
|
2095
|
+
account: managerSmartAccount,
|
|
2096
|
+
calls: [{ to: orgContractAddress, data: executeApproveCalldata }],
|
|
2097
|
+
paymaster: true
|
|
2098
|
+
});
|
|
2099
|
+
await waitForReceiptWithRetries(bundlerClient, userOpApproveHash);
|
|
2100
|
+
const publicClient = bundlerClient.client;
|
|
2101
|
+
const allowanceConfirmed = await waitForAllowance(
|
|
2102
|
+
publicClient,
|
|
2103
|
+
kibbleTokenAddress,
|
|
2104
|
+
orgContractAddress,
|
|
2105
|
+
partialPaymentModuleAddress,
|
|
2106
|
+
approveAmount
|
|
2107
|
+
);
|
|
2108
|
+
if (!allowanceConfirmed) {
|
|
2109
|
+
console.error("\u274C Halting iteration because on-chain allowance could not be confirmed.");
|
|
2110
|
+
return {
|
|
2111
|
+
success: false,
|
|
2112
|
+
message: `Error waiting for allowance`
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2115
|
+
return {
|
|
2116
|
+
success: true,
|
|
2117
|
+
message: "Approval UserOperation executed successfully.",
|
|
2118
|
+
opHash: userOpApproveHash
|
|
2119
|
+
};
|
|
2120
|
+
} catch (error) {
|
|
2121
|
+
const errorMessage = error instanceof Error ? error.cause?.message || error.message : "An unknown error occurred.";
|
|
2122
|
+
return {
|
|
2123
|
+
success: false,
|
|
2124
|
+
message: `Error during approval processing: ${errorMessage}`
|
|
2125
|
+
};
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
// src/utils/organization/useApproveOrgKibbleToken.ts
|
|
1930
2130
|
function useApproveOrgPartialPayment() {
|
|
1931
2131
|
return (0, import_react20.useCallback)(
|
|
1932
2132
|
async (orgContractAddress, kibbleTokenAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, approveAmount) => {
|
|
@@ -1937,37 +2137,22 @@ function useApproveOrgPartialPayment() {
|
|
|
1937
2137
|
};
|
|
1938
2138
|
}
|
|
1939
2139
|
try {
|
|
1940
|
-
const
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
args: [kibbleTokenAddress, approveCalldata]
|
|
1949
|
-
});
|
|
1950
|
-
applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
|
|
1951
|
-
const userOpApproveHash = await bundlerClient.sendUserOperation({
|
|
1952
|
-
account: managerSmartAccount,
|
|
1953
|
-
calls: [
|
|
1954
|
-
{
|
|
1955
|
-
to: orgContractAddress,
|
|
1956
|
-
data: executeApproveCalldata
|
|
1957
|
-
}
|
|
1958
|
-
],
|
|
1959
|
-
paymaster: true
|
|
1960
|
-
});
|
|
1961
|
-
await bundlerClient.waitForUserOperationReceipt({
|
|
1962
|
-
hash: userOpApproveHash
|
|
1963
|
-
});
|
|
1964
|
-
return { success: true, message: "Approval processed successfully." };
|
|
1965
|
-
} catch (error) {
|
|
1966
|
-
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";
|
|
2140
|
+
const result = await processOrgKibbleApproval(
|
|
2141
|
+
orgContractAddress,
|
|
2142
|
+
kibbleTokenAddress,
|
|
2143
|
+
partialPaymentModuleAddress,
|
|
2144
|
+
managerSmartAccount,
|
|
2145
|
+
bundlerClient,
|
|
2146
|
+
approveAmount
|
|
2147
|
+
);
|
|
1967
2148
|
return {
|
|
1968
|
-
success:
|
|
1969
|
-
message:
|
|
2149
|
+
success: result.success,
|
|
2150
|
+
message: result.message
|
|
1970
2151
|
};
|
|
2152
|
+
} catch (error) {
|
|
2153
|
+
console.error(" MDEBUG: Uncaught error in `useApproveOrgPartialPayment` hook:", error);
|
|
2154
|
+
const message = error instanceof Error ? error.cause?.message || error.message : "An unknown error occurred.";
|
|
2155
|
+
return { success: false, message: `Approval failed: ${message}` };
|
|
1971
2156
|
}
|
|
1972
2157
|
},
|
|
1973
2158
|
[]
|
|
@@ -1976,7 +2161,52 @@ function useApproveOrgPartialPayment() {
|
|
|
1976
2161
|
|
|
1977
2162
|
// src/utils/organization/useProcessOrgPartialKibblePayment.ts
|
|
1978
2163
|
var import_react21 = require("react");
|
|
1979
|
-
|
|
2164
|
+
|
|
2165
|
+
// src/helpers/ProcessOrgPartialPayment.tsx
|
|
2166
|
+
var import_viem7 = require("viem");
|
|
2167
|
+
async function processOrgPartialPayment(orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) {
|
|
2168
|
+
try {
|
|
2169
|
+
const partialPayCalldata = (0, import_viem7.encodeFunctionData)({
|
|
2170
|
+
abi: MARKETPLACE_ABI,
|
|
2171
|
+
functionName: "partialPay",
|
|
2172
|
+
args: [
|
|
2173
|
+
orderId,
|
|
2174
|
+
anymalNftId,
|
|
2175
|
+
pid,
|
|
2176
|
+
amountInTokens,
|
|
2177
|
+
maxTokenPayment,
|
|
2178
|
+
nonce,
|
|
2179
|
+
deadline,
|
|
2180
|
+
backendSignature
|
|
2181
|
+
]
|
|
2182
|
+
});
|
|
2183
|
+
const executePartialPayCalldata = (0, import_viem7.encodeFunctionData)({
|
|
2184
|
+
abi: ORGANIZATION_IMPL_ABI,
|
|
2185
|
+
functionName: "executeCall",
|
|
2186
|
+
args: [partialPaymentModuleAddress, partialPayCalldata]
|
|
2187
|
+
});
|
|
2188
|
+
await applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
|
|
2189
|
+
const userOpHash = await sendUserOpWithRetries(bundlerClient, {
|
|
2190
|
+
account: managerSmartAccount,
|
|
2191
|
+
calls: [{ to: orgContractAddress, data: executePartialPayCalldata }],
|
|
2192
|
+
paymaster: true
|
|
2193
|
+
});
|
|
2194
|
+
await waitForReceiptWithRetries(bundlerClient, userOpHash);
|
|
2195
|
+
return {
|
|
2196
|
+
success: true,
|
|
2197
|
+
message: "Partial payment UserOperation executed successfully.",
|
|
2198
|
+
opHash: userOpHash
|
|
2199
|
+
};
|
|
2200
|
+
} catch (error) {
|
|
2201
|
+
const errorMessage = error instanceof Error ? error.cause?.message || error.message : "An unknown error occurred.";
|
|
2202
|
+
return {
|
|
2203
|
+
success: false,
|
|
2204
|
+
message: `Error during payment processing: ${errorMessage}`
|
|
2205
|
+
};
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2209
|
+
// src/utils/organization/useProcessOrgPartialKibblePayment.ts
|
|
1980
2210
|
function useProcessOrgPartialKibblePayment() {
|
|
1981
2211
|
return (0, import_react21.useCallback)(
|
|
1982
2212
|
async (orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) => {
|
|
@@ -1987,46 +2217,28 @@ function useProcessOrgPartialKibblePayment() {
|
|
|
1987
2217
|
};
|
|
1988
2218
|
}
|
|
1989
2219
|
try {
|
|
1990
|
-
const
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
const executePartialPayCalldata = (0, import_viem6.encodeFunctionData)({
|
|
2005
|
-
abi: ORGANIZATION_IMPL_ABI,
|
|
2006
|
-
functionName: "executeCall",
|
|
2007
|
-
args: [partialPaymentModuleAddress, partialPayCalldata]
|
|
2008
|
-
});
|
|
2009
|
-
applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
|
|
2010
|
-
const userOpPartialPayHash = await bundlerClient.sendUserOperation({
|
|
2011
|
-
account: managerSmartAccount,
|
|
2012
|
-
calls: [
|
|
2013
|
-
{
|
|
2014
|
-
to: orgContractAddress,
|
|
2015
|
-
data: executePartialPayCalldata
|
|
2016
|
-
}
|
|
2017
|
-
],
|
|
2018
|
-
paymaster: true
|
|
2019
|
-
});
|
|
2020
|
-
const receipt = await bundlerClient.waitForUserOperationReceipt({
|
|
2021
|
-
hash: userOpPartialPayHash
|
|
2022
|
-
});
|
|
2023
|
-
return { success: true, message: receipt.userOpHash };
|
|
2024
|
-
} catch (error) {
|
|
2025
|
-
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";
|
|
2220
|
+
const result = await processOrgPartialPayment(
|
|
2221
|
+
orgContractAddress,
|
|
2222
|
+
partialPaymentModuleAddress,
|
|
2223
|
+
managerSmartAccount,
|
|
2224
|
+
bundlerClient,
|
|
2225
|
+
orderId,
|
|
2226
|
+
anymalNftId,
|
|
2227
|
+
pid,
|
|
2228
|
+
amountInTokens,
|
|
2229
|
+
maxTokenPayment,
|
|
2230
|
+
nonce,
|
|
2231
|
+
deadline,
|
|
2232
|
+
backendSignature
|
|
2233
|
+
);
|
|
2026
2234
|
return {
|
|
2027
|
-
success:
|
|
2028
|
-
message:
|
|
2235
|
+
success: result.success,
|
|
2236
|
+
message: result.message
|
|
2029
2237
|
};
|
|
2238
|
+
} catch (error) {
|
|
2239
|
+
console.error(" MDEBUG: Uncaught error in `useProcessOrgPartialKibblePayment`:", error);
|
|
2240
|
+
const errorMessage = error instanceof Error ? error.cause?.message || error.message : "An unknown error occurred.";
|
|
2241
|
+
return { success: false, message: `Partial payment failed: ${errorMessage}` };
|
|
2030
2242
|
}
|
|
2031
2243
|
},
|
|
2032
2244
|
[]
|
|
@@ -2076,10 +2288,10 @@ function useUpdateOrgWalletAddress() {
|
|
|
2076
2288
|
|
|
2077
2289
|
// src/helpers/NonceHelper.tsx
|
|
2078
2290
|
var import_uuid = require("uuid");
|
|
2079
|
-
var
|
|
2291
|
+
var import_viem8 = require("viem");
|
|
2080
2292
|
var generateBytes32Nonce = () => {
|
|
2081
2293
|
const uuid3 = (0, import_uuid.v4)().replace(/-/g, "");
|
|
2082
|
-
return (0,
|
|
2294
|
+
return (0, import_viem8.padHex)(`0x${uuid3}`, { size: 32 });
|
|
2083
2295
|
};
|
|
2084
2296
|
|
|
2085
2297
|
// src/helpers/CryptoUtils.tsx
|
|
@@ -2098,6 +2310,14 @@ var AUTH_API_ENDPOINTS = {
|
|
|
2098
2310
|
["testnet" /* Testnet */]: "https://dev-auth-api.petastic.com",
|
|
2099
2311
|
["localnet" /* Localnet */]: "http://localhost:3005"
|
|
2100
2312
|
};
|
|
2313
|
+
var FIREBASE_WEB_API_KEYS = {
|
|
2314
|
+
["testnet" /* Testnet */]: "AIzaSyC7Q-uzAzNSx6-cj_-LyNkFCWzB6RsmYzI",
|
|
2315
|
+
["localnet" /* Localnet */]: "AIzaSyC7Q-uzAzNSx6-cj_-LyNkFCWzB6RsmYzI"
|
|
2316
|
+
};
|
|
2317
|
+
var FIREBASE_WEB_AUTH_API_ENDPOINTS = {
|
|
2318
|
+
["testnet" /* Testnet */]: "https://identitytoolkit.googleapis.com/v1/accounts",
|
|
2319
|
+
["localnet" /* Localnet */]: "http://localhost:9099/identitytoolkit.googleapis.com/v1/accounts"
|
|
2320
|
+
};
|
|
2101
2321
|
function loadExistingSecp256k1PrivateKey(hexKey) {
|
|
2102
2322
|
if (!hexKey) {
|
|
2103
2323
|
throw new Error("Private key hex must be provided");
|
|
@@ -2162,6 +2382,101 @@ async function generateAppSignature(privateKeyHex, clientId, redirectUri, state)
|
|
|
2162
2382
|
return Buffer.from(signatureDER).toString("hex");
|
|
2163
2383
|
}
|
|
2164
2384
|
|
|
2385
|
+
// src/helpers/AppHelpers.tsx
|
|
2386
|
+
async function createApp(privateKeyHex, name, metadataURI, ownerEmail, network = "testnet" /* Testnet */, options) {
|
|
2387
|
+
const { publicKey, token } = await createAuthEnvelope(
|
|
2388
|
+
privateKeyHex,
|
|
2389
|
+
network,
|
|
2390
|
+
options
|
|
2391
|
+
);
|
|
2392
|
+
const host = AUTH_API_ENDPOINTS[network];
|
|
2393
|
+
if (!host) {
|
|
2394
|
+
throw new Error(`Unsupported network: ${network}`);
|
|
2395
|
+
}
|
|
2396
|
+
const url = `${host}/create-app`;
|
|
2397
|
+
const response = await fetch(url, {
|
|
2398
|
+
method: "POST",
|
|
2399
|
+
headers: {
|
|
2400
|
+
"Content-Type": "application/json",
|
|
2401
|
+
Authorization: `Bearer ${token}`
|
|
2402
|
+
},
|
|
2403
|
+
body: JSON.stringify({
|
|
2404
|
+
name,
|
|
2405
|
+
publicKey,
|
|
2406
|
+
metadataURI,
|
|
2407
|
+
ownerEmail
|
|
2408
|
+
})
|
|
2409
|
+
});
|
|
2410
|
+
if (!response.ok) {
|
|
2411
|
+
const text = await response.text();
|
|
2412
|
+
throw new Error(`Error creating app (${response.status}): ${text}`);
|
|
2413
|
+
}
|
|
2414
|
+
return response.json();
|
|
2415
|
+
}
|
|
2416
|
+
async function getFirebaseTokenForApp(privateKeyHex, appId, network = "testnet" /* Testnet */) {
|
|
2417
|
+
const { token } = await createAuthEnvelope(privateKeyHex, network);
|
|
2418
|
+
const host = AUTH_API_ENDPOINTS[network];
|
|
2419
|
+
if (!host) {
|
|
2420
|
+
throw new Error(`Unsupported network: ${network}`);
|
|
2421
|
+
}
|
|
2422
|
+
const response = await fetch(`${host}/exchange-jwt-for-app-token`, {
|
|
2423
|
+
method: "POST",
|
|
2424
|
+
headers: {
|
|
2425
|
+
Authorization: `Bearer ${token}`
|
|
2426
|
+
},
|
|
2427
|
+
body: JSON.stringify({
|
|
2428
|
+
appId
|
|
2429
|
+
})
|
|
2430
|
+
});
|
|
2431
|
+
if (!response.ok) {
|
|
2432
|
+
const text = await response.text();
|
|
2433
|
+
throw new Error(`Failed to get Firebase token: ${response.status} ${text}`);
|
|
2434
|
+
}
|
|
2435
|
+
const { firebaseToken: customToken } = await response.json();
|
|
2436
|
+
const firebaseApiKey = FIREBASE_WEB_API_KEYS[network];
|
|
2437
|
+
if (!firebaseApiKey) {
|
|
2438
|
+
throw new Error("FIREBASE_WEB_API_KEY is not set");
|
|
2439
|
+
}
|
|
2440
|
+
const fbAuthEndpoint = FIREBASE_WEB_AUTH_API_ENDPOINTS[network];
|
|
2441
|
+
const firebaseResponse = await fetch(
|
|
2442
|
+
`${fbAuthEndpoint}:signInWithCustomToken?key=${firebaseApiKey}`,
|
|
2443
|
+
{
|
|
2444
|
+
method: "POST",
|
|
2445
|
+
headers: {
|
|
2446
|
+
"Content-Type": "application/json"
|
|
2447
|
+
},
|
|
2448
|
+
body: JSON.stringify({
|
|
2449
|
+
token: customToken,
|
|
2450
|
+
returnSecureToken: true
|
|
2451
|
+
})
|
|
2452
|
+
}
|
|
2453
|
+
);
|
|
2454
|
+
if (!firebaseResponse.ok) {
|
|
2455
|
+
const text = await firebaseResponse.text();
|
|
2456
|
+
throw new Error(`Firebase token exchange failed: ${firebaseResponse.status} ${text}`);
|
|
2457
|
+
}
|
|
2458
|
+
const { idToken } = await firebaseResponse.json();
|
|
2459
|
+
return { firebaseToken: idToken };
|
|
2460
|
+
}
|
|
2461
|
+
function flattenFirestoreData(fields) {
|
|
2462
|
+
const parseValue = (val) => {
|
|
2463
|
+
if (val === null || typeof val !== "object") return val;
|
|
2464
|
+
if ("stringValue" in val) return val.stringValue;
|
|
2465
|
+
if ("integerValue" in val) return parseInt(val.integerValue, 10);
|
|
2466
|
+
if ("doubleValue" in val) return parseFloat(val.doubleValue);
|
|
2467
|
+
if ("booleanValue" in val) return val.booleanValue;
|
|
2468
|
+
if ("timestampValue" in val) return val.timestampValue;
|
|
2469
|
+
if ("nullValue" in val) return null;
|
|
2470
|
+
if ("mapValue" in val) return flattenFirestoreData(val.mapValue.fields || {});
|
|
2471
|
+
if ("arrayValue" in val)
|
|
2472
|
+
return (val.arrayValue.values || []).map(parseValue);
|
|
2473
|
+
return val;
|
|
2474
|
+
};
|
|
2475
|
+
return Object.fromEntries(
|
|
2476
|
+
Object.entries(fields).map(([key, value]) => [key, parseValue(value)])
|
|
2477
|
+
);
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2165
2480
|
// src/helpers/ActionHelpers.tsx
|
|
2166
2481
|
async function submitAction(idToken, pid, sourceType, payload, endpointBaseUrl) {
|
|
2167
2482
|
const api = endpointBaseUrl + "/actions";
|
|
@@ -2432,16 +2747,16 @@ function useCreateOrganizationAppData() {
|
|
|
2432
2747
|
|
|
2433
2748
|
// src/utils/balance/useFetchBalance.ts
|
|
2434
2749
|
var import_react27 = require("react");
|
|
2435
|
-
var
|
|
2750
|
+
var import_viem9 = require("viem");
|
|
2436
2751
|
function useFetchBalance() {
|
|
2437
2752
|
return (0, import_react27.useCallback)(
|
|
2438
2753
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
2439
2754
|
try {
|
|
2440
2755
|
const balance = await publicClient.readContract({
|
|
2441
|
-
address: (0,
|
|
2442
|
-
abi:
|
|
2756
|
+
address: (0, import_viem9.getAddress)(kibbleTokenAddress),
|
|
2757
|
+
abi: import_viem9.erc20Abi,
|
|
2443
2758
|
functionName: "balanceOf",
|
|
2444
|
-
args: [(0,
|
|
2759
|
+
args: [(0, import_viem9.getAddress)(walletAddress)]
|
|
2445
2760
|
});
|
|
2446
2761
|
return Number(balance);
|
|
2447
2762
|
} catch (error) {
|
|
@@ -2453,7 +2768,7 @@ function useFetchBalance() {
|
|
|
2453
2768
|
}
|
|
2454
2769
|
|
|
2455
2770
|
// src/utils/actions/useClaimActionReward.ts
|
|
2456
|
-
var
|
|
2771
|
+
var import_viem10 = require("viem");
|
|
2457
2772
|
var import_react28 = require("react");
|
|
2458
2773
|
function useClaimActionReward() {
|
|
2459
2774
|
return (0, import_react28.useCallback)(
|
|
@@ -2464,12 +2779,12 @@ function useClaimActionReward() {
|
|
|
2464
2779
|
message: "Missing web3auth account info or contract address."
|
|
2465
2780
|
};
|
|
2466
2781
|
}
|
|
2467
|
-
const callData = (0,
|
|
2782
|
+
const callData = (0, import_viem10.encodeFunctionData)({
|
|
2468
2783
|
abi: REWARDABLE_ACTIONS_ABI,
|
|
2469
2784
|
functionName: "claimByIndex",
|
|
2470
2785
|
args: [actionId, claimIndex]
|
|
2471
2786
|
});
|
|
2472
|
-
applyBundlerGasEstimator(smartAccount, bundlerClient);
|
|
2787
|
+
await applyBundlerGasEstimator(smartAccount, bundlerClient);
|
|
2473
2788
|
const userOpHash = await bundlerClient.sendUserOperation({
|
|
2474
2789
|
account: smartAccount,
|
|
2475
2790
|
calls: [
|
|
@@ -2492,7 +2807,7 @@ function useClaimActionReward() {
|
|
|
2492
2807
|
}
|
|
2493
2808
|
|
|
2494
2809
|
// src/utils/actions/useClaimOrgActionReward.ts
|
|
2495
|
-
var
|
|
2810
|
+
var import_viem11 = require("viem");
|
|
2496
2811
|
var import_react29 = require("react");
|
|
2497
2812
|
function useClaimOrgActionReward() {
|
|
2498
2813
|
return (0, import_react29.useCallback)(
|
|
@@ -2503,17 +2818,17 @@ function useClaimOrgActionReward() {
|
|
|
2503
2818
|
message: "Missing web3auth account info or contract address."
|
|
2504
2819
|
};
|
|
2505
2820
|
}
|
|
2506
|
-
const claimCallData = (0,
|
|
2821
|
+
const claimCallData = (0, import_viem11.encodeFunctionData)({
|
|
2507
2822
|
abi: REWARDABLE_ACTIONS_ABI,
|
|
2508
2823
|
functionName: "claimByIndex",
|
|
2509
2824
|
args: [actionId, claimIndex]
|
|
2510
2825
|
});
|
|
2511
|
-
const executeClaimCalldata = (0,
|
|
2826
|
+
const executeClaimCalldata = (0, import_viem11.encodeFunctionData)({
|
|
2512
2827
|
abi: ORGANIZATION_IMPL_ABI,
|
|
2513
2828
|
functionName: "executeCall",
|
|
2514
2829
|
args: [rewardableActionContractAddress, claimCallData]
|
|
2515
2830
|
});
|
|
2516
|
-
applyBundlerGasEstimator(smartAccount, bundlerClient);
|
|
2831
|
+
await applyBundlerGasEstimator(smartAccount, bundlerClient);
|
|
2517
2832
|
const userOpHash = await bundlerClient.sendUserOperation({
|
|
2518
2833
|
account: smartAccount,
|
|
2519
2834
|
calls: [
|
|
@@ -2659,6 +2974,8 @@ function isMarketplacePurchaseAction(payload) {
|
|
|
2659
2974
|
ActionSourceType,
|
|
2660
2975
|
ActionStatus,
|
|
2661
2976
|
ActionType,
|
|
2977
|
+
FIREBASE_WEB_API_KEYS,
|
|
2978
|
+
FIREBASE_WEB_AUTH_API_ENDPOINTS,
|
|
2662
2979
|
MarketplacePaymentType,
|
|
2663
2980
|
NETWORK_HOSTS,
|
|
2664
2981
|
Network,
|
|
@@ -2666,12 +2983,20 @@ function isMarketplacePurchaseAction(payload) {
|
|
|
2666
2983
|
convertToActionRecord,
|
|
2667
2984
|
convertToMultipleActionDefinitions,
|
|
2668
2985
|
convertToMultipleActionRecords,
|
|
2986
|
+
createApp,
|
|
2669
2987
|
createAuthEnvelope,
|
|
2670
2988
|
fetchAnymals,
|
|
2989
|
+
flattenFirestoreData,
|
|
2671
2990
|
generateAppSignature,
|
|
2672
2991
|
generateBytes32Nonce,
|
|
2673
2992
|
generateJWT,
|
|
2993
|
+
getFirebaseTokenForApp,
|
|
2674
2994
|
loadExistingSecp256k1PrivateKey,
|
|
2995
|
+
processDirectKibbleApproval,
|
|
2996
|
+
processDirectPartialPayment,
|
|
2997
|
+
processOrgKibbleApproval,
|
|
2998
|
+
processOrgPartialPayment,
|
|
2999
|
+
sendUserOpWithRetries,
|
|
2675
3000
|
serializePublicKeyCompressed,
|
|
2676
3001
|
submitAction,
|
|
2677
3002
|
useAddAnymalToDatabase,
|
|
@@ -2703,5 +3028,7 @@ function isMarketplacePurchaseAction(payload) {
|
|
|
2703
3028
|
useUpdateUserPid,
|
|
2704
3029
|
useUploadAnymalImage,
|
|
2705
3030
|
useVerifyAccount,
|
|
2706
|
-
useVerifyWeb3AuthSession
|
|
3031
|
+
useVerifyWeb3AuthSession,
|
|
3032
|
+
waitForAllowance,
|
|
3033
|
+
waitForReceiptWithRetries
|
|
2707
3034
|
});
|