anymal-protocol 1.0.138 → 1.0.140
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +105 -49
- package/dist/index.mjs +71 -15
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -431,6 +431,7 @@ declare const ORG_FUNCTION = "executeCall";
|
|
|
431
431
|
declare function useCoinbaseCreateOrganizationWallet(): (orgPid: string, orgName: string, ownerAddress: string, orgContractAddress: `0x${string}`, evmAddress: `0x${string}`) => Promise<{
|
|
432
432
|
success: boolean;
|
|
433
433
|
message: string;
|
|
434
|
+
proxyAddress?: string;
|
|
434
435
|
status: string;
|
|
435
436
|
}>;
|
|
436
437
|
|
package/dist/index.d.ts
CHANGED
|
@@ -431,6 +431,7 @@ declare const ORG_FUNCTION = "executeCall";
|
|
|
431
431
|
declare function useCoinbaseCreateOrganizationWallet(): (orgPid: string, orgName: string, ownerAddress: string, orgContractAddress: `0x${string}`, evmAddress: `0x${string}`) => Promise<{
|
|
432
432
|
success: boolean;
|
|
433
433
|
message: string;
|
|
434
|
+
proxyAddress?: string;
|
|
434
435
|
status: string;
|
|
435
436
|
}>;
|
|
436
437
|
|
package/dist/index.js
CHANGED
|
@@ -3013,8 +3013,17 @@ function useCoinbaseMintAnymalNFT() {
|
|
|
3013
3013
|
|
|
3014
3014
|
// src/utils/coinbase/useCoinbaseCreateOrganizationWallet.ts
|
|
3015
3015
|
var import_react13 = require("react");
|
|
3016
|
+
var import_viem3 = require("viem");
|
|
3017
|
+
var import_chains2 = require("viem/chains");
|
|
3016
3018
|
function useCoinbaseCreateOrganizationWallet() {
|
|
3017
|
-
const { sendOperationFn, status } = useSendCoinbaseUserOperation();
|
|
3019
|
+
const { sendOperationFn, data, status } = useSendCoinbaseUserOperation();
|
|
3020
|
+
const publicClient = (0, import_react13.useMemo)(
|
|
3021
|
+
() => (0, import_viem3.createPublicClient)({
|
|
3022
|
+
chain: import_chains2.baseSepolia,
|
|
3023
|
+
transport: (0, import_viem3.http)()
|
|
3024
|
+
}),
|
|
3025
|
+
[]
|
|
3026
|
+
);
|
|
3018
3027
|
return (0, import_react13.useCallback)(
|
|
3019
3028
|
/**
|
|
3020
3029
|
* Creates a new organization on-chain.
|
|
@@ -3024,31 +3033,78 @@ function useCoinbaseCreateOrganizationWallet() {
|
|
|
3024
3033
|
* @param ownerAddress - The wallet address of the user who will be the default manager.
|
|
3025
3034
|
* @param orgContractAddress - The contract address of the organization beacon.
|
|
3026
3035
|
* @param evmAddress - The Coinbase smart account address of the admin.
|
|
3027
|
-
* @returns A promise with success status, message, and
|
|
3036
|
+
* @returns A promise with success status, message, and optional proxyAddress.
|
|
3028
3037
|
*/
|
|
3029
3038
|
async (orgPid, orgName, ownerAddress, orgContractAddress, evmAddress) => {
|
|
3030
3039
|
if (!orgPid || !orgName || !ownerAddress || !orgContractAddress || !evmAddress) {
|
|
3031
3040
|
return {
|
|
3032
3041
|
success: false,
|
|
3033
3042
|
message: "Missing required parameters for organization creation.",
|
|
3034
|
-
status: "error
|
|
3043
|
+
status: "error"
|
|
3044
|
+
};
|
|
3045
|
+
}
|
|
3046
|
+
try {
|
|
3047
|
+
const result = await sendOperationFn(
|
|
3048
|
+
evmAddress,
|
|
3049
|
+
orgContractAddress,
|
|
3050
|
+
ORGANIZATION_BEACON_ABI,
|
|
3051
|
+
"createOrganizationProxy",
|
|
3052
|
+
[ownerAddress, orgName, orgPid]
|
|
3053
|
+
);
|
|
3054
|
+
if (!result.success) {
|
|
3055
|
+
return { ...result, status: "error" };
|
|
3056
|
+
}
|
|
3057
|
+
let proxyAddress;
|
|
3058
|
+
try {
|
|
3059
|
+
const txHash = data?.receipts?.[0]?.transactionHash || data?.transactionHash;
|
|
3060
|
+
if (txHash) {
|
|
3061
|
+
const receipt = await publicClient.getTransactionReceipt({
|
|
3062
|
+
hash: txHash
|
|
3063
|
+
});
|
|
3064
|
+
for (const log of receipt.logs) {
|
|
3065
|
+
try {
|
|
3066
|
+
const decoded = (0, import_viem3.decodeEventLog)({
|
|
3067
|
+
abi: ORGANIZATION_BEACON_ABI,
|
|
3068
|
+
data: log.data,
|
|
3069
|
+
topics: log.topics
|
|
3070
|
+
});
|
|
3071
|
+
if (decoded.eventName === "NewOrganizationCreated") {
|
|
3072
|
+
proxyAddress = decoded.args.proxyAddress;
|
|
3073
|
+
break;
|
|
3074
|
+
}
|
|
3075
|
+
} catch {
|
|
3076
|
+
}
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
} catch (e) {
|
|
3080
|
+
console.error("Failed to get transaction receipt:", e);
|
|
3081
|
+
}
|
|
3082
|
+
if (!proxyAddress) {
|
|
3083
|
+
return {
|
|
3084
|
+
...result,
|
|
3085
|
+
status
|
|
3086
|
+
};
|
|
3087
|
+
}
|
|
3088
|
+
return {
|
|
3089
|
+
...result,
|
|
3090
|
+
proxyAddress,
|
|
3091
|
+
status
|
|
3092
|
+
};
|
|
3093
|
+
} catch (error) {
|
|
3094
|
+
console.error("Org wallet creation error", error);
|
|
3095
|
+
return {
|
|
3096
|
+
success: false,
|
|
3097
|
+
message: "Error",
|
|
3098
|
+
status: "error"
|
|
3035
3099
|
};
|
|
3036
3100
|
}
|
|
3037
|
-
const result = await sendOperationFn(
|
|
3038
|
-
evmAddress,
|
|
3039
|
-
orgContractAddress,
|
|
3040
|
-
ORGANIZATION_BEACON_ABI,
|
|
3041
|
-
"createOrganizationProxy",
|
|
3042
|
-
[ownerAddress, orgName, orgPid]
|
|
3043
|
-
);
|
|
3044
|
-
return { ...result, status };
|
|
3045
3101
|
},
|
|
3046
|
-
[sendOperationFn, status]
|
|
3102
|
+
[sendOperationFn, data, publicClient, status]
|
|
3047
3103
|
);
|
|
3048
3104
|
}
|
|
3049
3105
|
|
|
3050
3106
|
// src/utils/anymals/useMintAnymalNFT.ts
|
|
3051
|
-
var
|
|
3107
|
+
var import_viem5 = require("viem");
|
|
3052
3108
|
var import_react14 = require("react");
|
|
3053
3109
|
|
|
3054
3110
|
// src/helpers/GasEstimateHelper.tsx
|
|
@@ -3093,18 +3149,18 @@ async function applyBundlerGasEstimator(account, bundlerClient, options) {
|
|
|
3093
3149
|
}
|
|
3094
3150
|
|
|
3095
3151
|
// src/helpers/HumanRevert.tsx
|
|
3096
|
-
var
|
|
3152
|
+
var import_viem4 = require("viem");
|
|
3097
3153
|
function humanRevert(raw, shortMessage) {
|
|
3098
3154
|
if (!raw) return shortMessage ?? "Simulation reverted";
|
|
3099
3155
|
try {
|
|
3100
|
-
const { errorName, args } = (0,
|
|
3156
|
+
const { errorName, args } = (0, import_viem4.decodeErrorResult)({
|
|
3101
3157
|
abi: ERROR_ABI,
|
|
3102
3158
|
data: raw
|
|
3103
3159
|
});
|
|
3104
3160
|
return `${errorName}(${args.map(String).join(", ")})`;
|
|
3105
3161
|
} catch {
|
|
3106
3162
|
if (raw.startsWith("0x08c379a0") && raw.length >= 138) {
|
|
3107
|
-
return (0,
|
|
3163
|
+
return (0, import_viem4.hexToString)(`0x${raw.slice(138)}`);
|
|
3108
3164
|
}
|
|
3109
3165
|
return `${raw.slice(0, 10)}\u2026`;
|
|
3110
3166
|
}
|
|
@@ -3146,7 +3202,7 @@ function useMintAnymalNFT() {
|
|
|
3146
3202
|
"petastic-signup-campaign-1",
|
|
3147
3203
|
anymalTxId
|
|
3148
3204
|
];
|
|
3149
|
-
const callData = (0,
|
|
3205
|
+
const callData = (0, import_viem5.encodeFunctionData)({
|
|
3150
3206
|
abi: PET_NFT_ABI,
|
|
3151
3207
|
functionName,
|
|
3152
3208
|
args
|
|
@@ -3333,7 +3389,7 @@ function useUploadAnymalImage() {
|
|
|
3333
3389
|
var import_react17 = require("react");
|
|
3334
3390
|
|
|
3335
3391
|
// src/helpers/ProcessDirectPartialPayment.tsx
|
|
3336
|
-
var
|
|
3392
|
+
var import_viem6 = require("viem");
|
|
3337
3393
|
|
|
3338
3394
|
// src/helpers/SendUserOpWithRetries.tsx
|
|
3339
3395
|
async function sendUserOpWithRetries(bundlerClient, params, retries = 3, delay = 1e3) {
|
|
@@ -3393,7 +3449,7 @@ async function processDirectPartialPayment(marketplaceContract, smartAccount, bu
|
|
|
3393
3449
|
deadline,
|
|
3394
3450
|
backendSignature
|
|
3395
3451
|
];
|
|
3396
|
-
const partialPayCalldata = (0,
|
|
3452
|
+
const partialPayCalldata = (0, import_viem6.encodeFunctionData)({
|
|
3397
3453
|
abi: MARKETPLACE_ABI,
|
|
3398
3454
|
functionName,
|
|
3399
3455
|
args
|
|
@@ -3489,20 +3545,20 @@ function useProcessPartialKibblePayment() {
|
|
|
3489
3545
|
var import_react18 = require("react");
|
|
3490
3546
|
|
|
3491
3547
|
// src/helpers/ProcessDirectKibbleApproval.tsx
|
|
3492
|
-
var
|
|
3548
|
+
var import_viem7 = require("viem");
|
|
3493
3549
|
async function processDirectKibbleApproval(kibbleTokenAddress, spenderAddress, smartAccount, bundlerClient, approveAmount) {
|
|
3494
3550
|
try {
|
|
3495
3551
|
const functionName = "approve";
|
|
3496
3552
|
const args = [spenderAddress, approveAmount];
|
|
3497
|
-
const approveCalldata = (0,
|
|
3498
|
-
abi:
|
|
3553
|
+
const approveCalldata = (0, import_viem7.encodeFunctionData)({
|
|
3554
|
+
abi: import_viem7.erc20Abi,
|
|
3499
3555
|
functionName,
|
|
3500
3556
|
args
|
|
3501
3557
|
});
|
|
3502
3558
|
await simulateCall(
|
|
3503
3559
|
bundlerClient.client,
|
|
3504
3560
|
kibbleTokenAddress,
|
|
3505
|
-
|
|
3561
|
+
import_viem7.erc20Abi,
|
|
3506
3562
|
functionName,
|
|
3507
3563
|
args,
|
|
3508
3564
|
smartAccount.address
|
|
@@ -3559,7 +3615,7 @@ function useApproveKibbleToken() {
|
|
|
3559
3615
|
|
|
3560
3616
|
// src/utils/organization/useCreateOrganizationBase.ts
|
|
3561
3617
|
var import_react19 = require("react");
|
|
3562
|
-
var
|
|
3618
|
+
var import_viem8 = require("viem");
|
|
3563
3619
|
function useCreateOrganizationBase() {
|
|
3564
3620
|
return (0, import_react19.useCallback)(
|
|
3565
3621
|
/**
|
|
@@ -3583,7 +3639,7 @@ function useCreateOrganizationBase() {
|
|
|
3583
3639
|
try {
|
|
3584
3640
|
const functionName = "createOrganizationProxy";
|
|
3585
3641
|
const args = [ownerAddress, orgName, orgPid];
|
|
3586
|
-
const callData = (0,
|
|
3642
|
+
const callData = (0, import_viem8.encodeFunctionData)({
|
|
3587
3643
|
abi: ORGANIZATION_BEACON_ABI,
|
|
3588
3644
|
functionName,
|
|
3589
3645
|
args
|
|
@@ -3621,7 +3677,7 @@ function useCreateOrganizationBase() {
|
|
|
3621
3677
|
let proxyAddress;
|
|
3622
3678
|
for (const log of txReceipt.logs) {
|
|
3623
3679
|
try {
|
|
3624
|
-
const decoded = (0,
|
|
3680
|
+
const decoded = (0, import_viem8.decodeEventLog)({
|
|
3625
3681
|
abi: ORGANIZATION_BEACON_ABI,
|
|
3626
3682
|
data: log.data,
|
|
3627
3683
|
topics: log.topics
|
|
@@ -3660,10 +3716,10 @@ function useCreateOrganizationBase() {
|
|
|
3660
3716
|
var import_react20 = require("react");
|
|
3661
3717
|
|
|
3662
3718
|
// src/helpers/ProcessOrgKibbleApproval.tsx
|
|
3663
|
-
var
|
|
3719
|
+
var import_viem10 = require("viem");
|
|
3664
3720
|
|
|
3665
3721
|
// src/helpers/WaitForAllowance.tsx
|
|
3666
|
-
var
|
|
3722
|
+
var import_viem9 = require("viem");
|
|
3667
3723
|
async function waitForAllowance(publicClient, tokenAddress, ownerAddress, spenderAddress, expectedAmount) {
|
|
3668
3724
|
const MAX_RETRIES = 10;
|
|
3669
3725
|
const RETRY_INTERVAL = 2e3;
|
|
@@ -3672,7 +3728,7 @@ async function waitForAllowance(publicClient, tokenAddress, ownerAddress, spende
|
|
|
3672
3728
|
try {
|
|
3673
3729
|
const currentAllowance = await publicClient.readContract({
|
|
3674
3730
|
address: tokenAddress,
|
|
3675
|
-
abi:
|
|
3731
|
+
abi: import_viem9.erc20Abi,
|
|
3676
3732
|
functionName: "allowance",
|
|
3677
3733
|
args: [ownerAddress, spenderAddress]
|
|
3678
3734
|
});
|
|
@@ -3697,13 +3753,13 @@ async function processOrgKibbleApproval(orgContractAddress, kibbleTokenAddress,
|
|
|
3697
3753
|
if (approveAmount <= 0n) {
|
|
3698
3754
|
return { success: false, message: "Approval amount must be greater than zero." };
|
|
3699
3755
|
}
|
|
3700
|
-
const approveCalldata = (0,
|
|
3701
|
-
abi:
|
|
3756
|
+
const approveCalldata = (0, import_viem10.encodeFunctionData)({
|
|
3757
|
+
abi: import_viem10.erc20Abi,
|
|
3702
3758
|
functionName: "approve",
|
|
3703
3759
|
args: [partialPaymentModuleAddress, approveAmount]
|
|
3704
3760
|
});
|
|
3705
3761
|
const args = [kibbleTokenAddress, approveCalldata];
|
|
3706
|
-
const executeApproveCalldata = (0,
|
|
3762
|
+
const executeApproveCalldata = (0, import_viem10.encodeFunctionData)({
|
|
3707
3763
|
abi: ORGANIZATION_IMPL_ABI,
|
|
3708
3764
|
functionName: ORG_FUNCTION,
|
|
3709
3765
|
args
|
|
@@ -3790,10 +3846,10 @@ function useApproveOrgPartialPayment() {
|
|
|
3790
3846
|
var import_react21 = require("react");
|
|
3791
3847
|
|
|
3792
3848
|
// src/helpers/ProcessOrgPartialPayment.tsx
|
|
3793
|
-
var
|
|
3849
|
+
var import_viem11 = require("viem");
|
|
3794
3850
|
async function processOrgPartialPayment(orgContractAddress, partialPaymentModuleAddress, managerSmartAccount, bundlerClient, orderId, anymalNftId, pid, amountInTokens, maxTokenPayment, nonce, deadline, backendSignature) {
|
|
3795
3851
|
try {
|
|
3796
|
-
const partialPayCalldata = (0,
|
|
3852
|
+
const partialPayCalldata = (0, import_viem11.encodeFunctionData)({
|
|
3797
3853
|
abi: MARKETPLACE_ABI,
|
|
3798
3854
|
functionName: "partialPay",
|
|
3799
3855
|
args: [
|
|
@@ -3808,7 +3864,7 @@ async function processOrgPartialPayment(orgContractAddress, partialPaymentModule
|
|
|
3808
3864
|
]
|
|
3809
3865
|
});
|
|
3810
3866
|
const args = [partialPaymentModuleAddress, partialPayCalldata];
|
|
3811
|
-
const executePartialPayCalldata = (0,
|
|
3867
|
+
const executePartialPayCalldata = (0, import_viem11.encodeFunctionData)({
|
|
3812
3868
|
abi: ORGANIZATION_IMPL_ABI,
|
|
3813
3869
|
functionName: ORG_FUNCTION,
|
|
3814
3870
|
args
|
|
@@ -3924,7 +3980,7 @@ function useUpdateOrgWalletAddress() {
|
|
|
3924
3980
|
}
|
|
3925
3981
|
|
|
3926
3982
|
// src/utils/organization/useMintOrgAnymalNFT.ts
|
|
3927
|
-
var
|
|
3983
|
+
var import_viem12 = require("viem");
|
|
3928
3984
|
var import_react23 = require("react");
|
|
3929
3985
|
function useMintOrgAnymalNFT() {
|
|
3930
3986
|
return (0, import_react23.useCallback)(
|
|
@@ -3943,13 +3999,13 @@ function useMintOrgAnymalNFT() {
|
|
|
3943
3999
|
"petastic-signup-campaign-1",
|
|
3944
4000
|
anymalTxId
|
|
3945
4001
|
];
|
|
3946
|
-
const callData = (0,
|
|
4002
|
+
const callData = (0, import_viem12.encodeFunctionData)({
|
|
3947
4003
|
abi: PET_NFT_ABI,
|
|
3948
4004
|
functionName,
|
|
3949
4005
|
args
|
|
3950
4006
|
});
|
|
3951
4007
|
const executeArgs = [validationContractAddress, callData];
|
|
3952
|
-
const executeSubmitMetaCalldata = (0,
|
|
4008
|
+
const executeSubmitMetaCalldata = (0, import_viem12.encodeFunctionData)({
|
|
3953
4009
|
abi: ORGANIZATION_IMPL_ABI,
|
|
3954
4010
|
functionName: ORG_FUNCTION,
|
|
3955
4011
|
args: executeArgs
|
|
@@ -3982,10 +4038,10 @@ function useMintOrgAnymalNFT() {
|
|
|
3982
4038
|
|
|
3983
4039
|
// src/helpers/NonceHelper.tsx
|
|
3984
4040
|
var import_uuid = require("uuid");
|
|
3985
|
-
var
|
|
4041
|
+
var import_viem13 = require("viem");
|
|
3986
4042
|
var generateBytes32Nonce = () => {
|
|
3987
4043
|
const uuid3 = (0, import_uuid.v4)().replace(/-/g, "");
|
|
3988
|
-
return (0,
|
|
4044
|
+
return (0, import_viem13.padHex)(`0x${uuid3}`, { size: 32 });
|
|
3989
4045
|
};
|
|
3990
4046
|
|
|
3991
4047
|
// src/helpers/CryptoUtils.tsx
|
|
@@ -4441,16 +4497,16 @@ function useCreateOrganizationAppData() {
|
|
|
4441
4497
|
|
|
4442
4498
|
// src/utils/balance/useFetchBalance.ts
|
|
4443
4499
|
var import_react28 = require("react");
|
|
4444
|
-
var
|
|
4500
|
+
var import_viem14 = require("viem");
|
|
4445
4501
|
function useFetchBalance() {
|
|
4446
4502
|
return (0, import_react28.useCallback)(
|
|
4447
4503
|
async (publicClient, walletAddress, kibbleTokenAddress) => {
|
|
4448
4504
|
try {
|
|
4449
4505
|
const balance = await publicClient.readContract({
|
|
4450
|
-
address: (0,
|
|
4451
|
-
abi:
|
|
4506
|
+
address: (0, import_viem14.getAddress)(kibbleTokenAddress),
|
|
4507
|
+
abi: import_viem14.erc20Abi,
|
|
4452
4508
|
functionName: "balanceOf",
|
|
4453
|
-
args: [(0,
|
|
4509
|
+
args: [(0, import_viem14.getAddress)(walletAddress)]
|
|
4454
4510
|
});
|
|
4455
4511
|
return Number(balance);
|
|
4456
4512
|
} catch (error) {
|
|
@@ -4462,7 +4518,7 @@ function useFetchBalance() {
|
|
|
4462
4518
|
}
|
|
4463
4519
|
|
|
4464
4520
|
// src/utils/actions/useClaimActionReward.ts
|
|
4465
|
-
var
|
|
4521
|
+
var import_viem15 = require("viem");
|
|
4466
4522
|
var import_react29 = require("react");
|
|
4467
4523
|
function useClaimActionReward() {
|
|
4468
4524
|
return (0, import_react29.useCallback)(
|
|
@@ -4475,7 +4531,7 @@ function useClaimActionReward() {
|
|
|
4475
4531
|
}
|
|
4476
4532
|
const args = [actionId, claimIndex];
|
|
4477
4533
|
const functionName = "claimByIndex";
|
|
4478
|
-
const callData = (0,
|
|
4534
|
+
const callData = (0, import_viem15.encodeFunctionData)({
|
|
4479
4535
|
abi: REWARDABLE_ACTIONS_ABI,
|
|
4480
4536
|
functionName,
|
|
4481
4537
|
args
|
|
@@ -4511,7 +4567,7 @@ function useClaimActionReward() {
|
|
|
4511
4567
|
}
|
|
4512
4568
|
|
|
4513
4569
|
// src/utils/actions/useClaimOrgActionReward.ts
|
|
4514
|
-
var
|
|
4570
|
+
var import_viem16 = require("viem");
|
|
4515
4571
|
var import_react30 = require("react");
|
|
4516
4572
|
function useClaimOrgActionReward() {
|
|
4517
4573
|
return (0, import_react30.useCallback)(
|
|
@@ -4522,13 +4578,13 @@ function useClaimOrgActionReward() {
|
|
|
4522
4578
|
message: "Missing web3auth account info or contract address."
|
|
4523
4579
|
};
|
|
4524
4580
|
}
|
|
4525
|
-
const claimCallData = (0,
|
|
4581
|
+
const claimCallData = (0, import_viem16.encodeFunctionData)({
|
|
4526
4582
|
abi: REWARDABLE_ACTIONS_ABI,
|
|
4527
4583
|
functionName: "claimByIndex",
|
|
4528
4584
|
args: [actionId, claimIndex]
|
|
4529
4585
|
});
|
|
4530
4586
|
const args = [rewardableActionContractAddress, claimCallData];
|
|
4531
|
-
const executeClaimCalldata = (0,
|
|
4587
|
+
const executeClaimCalldata = (0, import_viem16.encodeFunctionData)({
|
|
4532
4588
|
abi: ORGANIZATION_IMPL_ABI,
|
|
4533
4589
|
functionName: ORG_FUNCTION,
|
|
4534
4590
|
args
|
package/dist/index.mjs
CHANGED
|
@@ -2933,9 +2933,18 @@ function useCoinbaseMintAnymalNFT() {
|
|
|
2933
2933
|
}
|
|
2934
2934
|
|
|
2935
2935
|
// src/utils/coinbase/useCoinbaseCreateOrganizationWallet.ts
|
|
2936
|
-
import { useCallback as useCallback13 } from "react";
|
|
2936
|
+
import { useCallback as useCallback13, useMemo as useMemo2 } from "react";
|
|
2937
|
+
import { createPublicClient as createPublicClient2, decodeEventLog, http as http2 } from "viem";
|
|
2938
|
+
import { baseSepolia as baseSepolia2 } from "viem/chains";
|
|
2937
2939
|
function useCoinbaseCreateOrganizationWallet() {
|
|
2938
|
-
const { sendOperationFn, status } = useSendCoinbaseUserOperation();
|
|
2940
|
+
const { sendOperationFn, data, status } = useSendCoinbaseUserOperation();
|
|
2941
|
+
const publicClient = useMemo2(
|
|
2942
|
+
() => createPublicClient2({
|
|
2943
|
+
chain: baseSepolia2,
|
|
2944
|
+
transport: http2()
|
|
2945
|
+
}),
|
|
2946
|
+
[]
|
|
2947
|
+
);
|
|
2939
2948
|
return useCallback13(
|
|
2940
2949
|
/**
|
|
2941
2950
|
* Creates a new organization on-chain.
|
|
@@ -2945,26 +2954,73 @@ function useCoinbaseCreateOrganizationWallet() {
|
|
|
2945
2954
|
* @param ownerAddress - The wallet address of the user who will be the default manager.
|
|
2946
2955
|
* @param orgContractAddress - The contract address of the organization beacon.
|
|
2947
2956
|
* @param evmAddress - The Coinbase smart account address of the admin.
|
|
2948
|
-
* @returns A promise with success status, message, and
|
|
2957
|
+
* @returns A promise with success status, message, and optional proxyAddress.
|
|
2949
2958
|
*/
|
|
2950
2959
|
async (orgPid, orgName, ownerAddress, orgContractAddress, evmAddress) => {
|
|
2951
2960
|
if (!orgPid || !orgName || !ownerAddress || !orgContractAddress || !evmAddress) {
|
|
2952
2961
|
return {
|
|
2953
2962
|
success: false,
|
|
2954
2963
|
message: "Missing required parameters for organization creation.",
|
|
2955
|
-
status: "error
|
|
2964
|
+
status: "error"
|
|
2965
|
+
};
|
|
2966
|
+
}
|
|
2967
|
+
try {
|
|
2968
|
+
const result = await sendOperationFn(
|
|
2969
|
+
evmAddress,
|
|
2970
|
+
orgContractAddress,
|
|
2971
|
+
ORGANIZATION_BEACON_ABI,
|
|
2972
|
+
"createOrganizationProxy",
|
|
2973
|
+
[ownerAddress, orgName, orgPid]
|
|
2974
|
+
);
|
|
2975
|
+
if (!result.success) {
|
|
2976
|
+
return { ...result, status: "error" };
|
|
2977
|
+
}
|
|
2978
|
+
let proxyAddress;
|
|
2979
|
+
try {
|
|
2980
|
+
const txHash = data?.receipts?.[0]?.transactionHash || data?.transactionHash;
|
|
2981
|
+
if (txHash) {
|
|
2982
|
+
const receipt = await publicClient.getTransactionReceipt({
|
|
2983
|
+
hash: txHash
|
|
2984
|
+
});
|
|
2985
|
+
for (const log of receipt.logs) {
|
|
2986
|
+
try {
|
|
2987
|
+
const decoded = decodeEventLog({
|
|
2988
|
+
abi: ORGANIZATION_BEACON_ABI,
|
|
2989
|
+
data: log.data,
|
|
2990
|
+
topics: log.topics
|
|
2991
|
+
});
|
|
2992
|
+
if (decoded.eventName === "NewOrganizationCreated") {
|
|
2993
|
+
proxyAddress = decoded.args.proxyAddress;
|
|
2994
|
+
break;
|
|
2995
|
+
}
|
|
2996
|
+
} catch {
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
} catch (e) {
|
|
3001
|
+
console.error("Failed to get transaction receipt:", e);
|
|
3002
|
+
}
|
|
3003
|
+
if (!proxyAddress) {
|
|
3004
|
+
return {
|
|
3005
|
+
...result,
|
|
3006
|
+
status
|
|
3007
|
+
};
|
|
3008
|
+
}
|
|
3009
|
+
return {
|
|
3010
|
+
...result,
|
|
3011
|
+
proxyAddress,
|
|
3012
|
+
status
|
|
3013
|
+
};
|
|
3014
|
+
} catch (error) {
|
|
3015
|
+
console.error("Org wallet creation error", error);
|
|
3016
|
+
return {
|
|
3017
|
+
success: false,
|
|
3018
|
+
message: "Error",
|
|
3019
|
+
status: "error"
|
|
2956
3020
|
};
|
|
2957
3021
|
}
|
|
2958
|
-
const result = await sendOperationFn(
|
|
2959
|
-
evmAddress,
|
|
2960
|
-
orgContractAddress,
|
|
2961
|
-
ORGANIZATION_BEACON_ABI,
|
|
2962
|
-
"createOrganizationProxy",
|
|
2963
|
-
[ownerAddress, orgName, orgPid]
|
|
2964
|
-
);
|
|
2965
|
-
return { ...result, status };
|
|
2966
3022
|
},
|
|
2967
|
-
[sendOperationFn, status]
|
|
3023
|
+
[sendOperationFn, data, publicClient, status]
|
|
2968
3024
|
);
|
|
2969
3025
|
}
|
|
2970
3026
|
|
|
@@ -3480,7 +3536,7 @@ function useApproveKibbleToken() {
|
|
|
3480
3536
|
|
|
3481
3537
|
// src/utils/organization/useCreateOrganizationBase.ts
|
|
3482
3538
|
import { useCallback as useCallback19 } from "react";
|
|
3483
|
-
import { decodeEventLog, encodeFunctionData as encodeFunctionData5 } from "viem";
|
|
3539
|
+
import { decodeEventLog as decodeEventLog2, encodeFunctionData as encodeFunctionData5 } from "viem";
|
|
3484
3540
|
function useCreateOrganizationBase() {
|
|
3485
3541
|
return useCallback19(
|
|
3486
3542
|
/**
|
|
@@ -3542,7 +3598,7 @@ function useCreateOrganizationBase() {
|
|
|
3542
3598
|
let proxyAddress;
|
|
3543
3599
|
for (const log of txReceipt.logs) {
|
|
3544
3600
|
try {
|
|
3545
|
-
const decoded =
|
|
3601
|
+
const decoded = decodeEventLog2({
|
|
3546
3602
|
abi: ORGANIZATION_BEACON_ABI,
|
|
3547
3603
|
data: log.data,
|
|
3548
3604
|
topics: log.topics
|
package/package.json
CHANGED