@wirexapp/wpay-baas-sdk 0.1.7 → 0.1.8
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/README.md +32 -2
- package/dist/{chunk-Y7TGKAUA.js → chunk-D2YHFKQI.js} +3 -3
- package/dist/{chunk-Y7TGKAUA.js.map → chunk-D2YHFKQI.js.map} +1 -1
- package/dist/{chunk-BN5Q2YHP.js → chunk-ITBPDXHK.js} +132 -13
- package/dist/chunk-ITBPDXHK.js.map +1 -0
- package/dist/{chunk-C4OR7ZVY.js → chunk-YXNNTBO5.js} +3 -2
- package/dist/chunk-YXNNTBO5.js.map +1 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +1 -1
- package/dist/{types-_VJ4UPM4.d.ts → crypto.module-BsI4pLhf.d.ts} +70 -52
- package/dist/{index-DETvmzdr.d.ts → index-3P-X9tLg.d.ts} +2 -2
- package/dist/index.d.ts +7 -7
- package/dist/index.js +6 -6
- package/dist/modules/api/index.d.ts +3 -3
- package/dist/modules/api/index.js +2 -2
- package/dist/modules/crypto/index.d.ts +32 -10
- package/dist/modules/crypto/index.js +3 -3
- package/dist/{types-IKGr4nyf.d.ts → types-_RME4STd.d.ts} +1 -1
- package/dist/{withdrawal.api-DsvQPbRN.d.ts → withdrawal.api-CmRHIoyc.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-BN5Q2YHP.js.map +0 -1
- package/dist/chunk-C4OR7ZVY.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AuthService, WithdrawalApi } from './chunk-
|
|
2
|
-
import { ContractError, ConfigurationError } from './chunk-
|
|
1
|
+
import { AuthService, WithdrawalApi } from './chunk-D2YHFKQI.js';
|
|
2
|
+
import { ContractError, ConfigurationError } from './chunk-YXNNTBO5.js';
|
|
3
3
|
import { toPermissionValidator } from '@zerodev/permissions';
|
|
4
4
|
import { toSudoPolicy } from '@zerodev/permissions/policies';
|
|
5
5
|
import { toECDSASigner } from '@zerodev/permissions/signers';
|
|
@@ -3572,6 +3572,25 @@ var BaseAccountAbstractionService = class {
|
|
|
3572
3572
|
]);
|
|
3573
3573
|
return await this.walletService.sendUserOperationsAndWaitReceipt(calls, smartWalletClient);
|
|
3574
3574
|
}
|
|
3575
|
+
// Batch-ready variants of the installs above: they return the calls instead of
|
|
3576
|
+
// sending them, so onboarding can install the executor, switch the root validator
|
|
3577
|
+
// and register the account in a single UserOp.
|
|
3578
|
+
async getExecutorInstallCall() {
|
|
3579
|
+
const smartWalletClient = await this.walletService.getSmartWalletClientWithoutPolicy();
|
|
3580
|
+
return {
|
|
3581
|
+
to: smartWalletClient.account.address,
|
|
3582
|
+
value: BigInt(0),
|
|
3583
|
+
data: await this.getExecutorCallData()
|
|
3584
|
+
};
|
|
3585
|
+
}
|
|
3586
|
+
async getPolicyInstallCall() {
|
|
3587
|
+
const smartWalletClient = await this.walletService.getSmartWalletClientWithoutPolicy();
|
|
3588
|
+
return {
|
|
3589
|
+
to: smartWalletClient.account.address,
|
|
3590
|
+
value: BigInt(0),
|
|
3591
|
+
data: await this.getPolicyCallData()
|
|
3592
|
+
};
|
|
3593
|
+
}
|
|
3575
3594
|
async createExecutionDelayValidator() {
|
|
3576
3595
|
const executionDelayPolicyContract = this.contracts.executionDelayPolicy;
|
|
3577
3596
|
const rootPolicy = toSudoPolicy({ policyAddress: executionDelayPolicyContract });
|
|
@@ -3705,6 +3724,15 @@ var BaseAccountContractService = class {
|
|
|
3705
3724
|
}
|
|
3706
3725
|
return receipt;
|
|
3707
3726
|
}
|
|
3727
|
+
// Batch-ready variant of registerInAccounts: returns the call so onboarding can
|
|
3728
|
+
// register the account in the same UserOp that installs the executor and policy.
|
|
3729
|
+
async getAccountRegistrationCall() {
|
|
3730
|
+
return {
|
|
3731
|
+
to: this.contracts.accounts,
|
|
3732
|
+
value: BigInt(0),
|
|
3733
|
+
data: await this.getCallData()
|
|
3734
|
+
};
|
|
3735
|
+
}
|
|
3708
3736
|
async getCorporateCallData() {
|
|
3709
3737
|
return encodeFunctionData({
|
|
3710
3738
|
abi: corporateAccountsAbi,
|
|
@@ -3769,7 +3797,8 @@ var BaseCryptoService = class {
|
|
|
3769
3797
|
const nonce = await this.getCustomNonceToFinishRequest(callData);
|
|
3770
3798
|
const userOpReceipt = await this.walletService.sendUserOperationsWithNonceAndWaitReceipt(
|
|
3771
3799
|
callData,
|
|
3772
|
-
nonce
|
|
3800
|
+
nonce,
|
|
3801
|
+
{ applyUnwrapGasFloor: true }
|
|
3773
3802
|
);
|
|
3774
3803
|
if (!userOpReceipt.success) {
|
|
3775
3804
|
throw new Error(
|
|
@@ -3819,7 +3848,8 @@ var BaseCryptoService = class {
|
|
|
3819
3848
|
const nonce = await this.getCustomNonceToFinishRequest(encodedExecutionCalls);
|
|
3820
3849
|
const userOpReceipt = await this.walletService.sendUserOperationsWithNonceAndWaitReceipt(
|
|
3821
3850
|
encodedExecutionCalls,
|
|
3822
|
-
nonce
|
|
3851
|
+
nonce,
|
|
3852
|
+
{ applyUnwrapGasFloor: true }
|
|
3823
3853
|
);
|
|
3824
3854
|
if (!userOpReceipt.success) {
|
|
3825
3855
|
throw new Error(
|
|
@@ -3929,7 +3959,11 @@ var BaseCryptoService = class {
|
|
|
3929
3959
|
unwrapCallData,
|
|
3930
3960
|
erc20TransferCallDetails
|
|
3931
3961
|
]);
|
|
3932
|
-
const userOpReceipt = await this.walletService.sendUserOperationsAndWaitReceipt(
|
|
3962
|
+
const userOpReceipt = await this.walletService.sendUserOperationsAndWaitReceipt(
|
|
3963
|
+
encodedExecutionCalls,
|
|
3964
|
+
void 0,
|
|
3965
|
+
{ applyUnwrapGasFloor: true }
|
|
3966
|
+
);
|
|
3933
3967
|
if (!userOpReceipt.success) {
|
|
3934
3968
|
throw new Error(
|
|
3935
3969
|
`ERC20 Unwrap Transfer UserOperation failed: userOpHash=${userOpReceipt.userOpHash}, tx=${userOpReceipt.receipt.transactionHash}, reason=${userOpReceipt.reason ?? "unknown (likely out of gas)"}`
|
|
@@ -4043,6 +4077,47 @@ var BaseCryptoService = class {
|
|
|
4043
4077
|
};
|
|
4044
4078
|
}
|
|
4045
4079
|
};
|
|
4080
|
+
|
|
4081
|
+
// src/modules/crypto/chains/base/onboarding.service.ts
|
|
4082
|
+
var BaseOnboardingService = class {
|
|
4083
|
+
constructor(config) {
|
|
4084
|
+
this.walletService = config.walletService;
|
|
4085
|
+
this.accountAbstractionService = config.accountAbstractionService;
|
|
4086
|
+
this.accountContractService = config.accountContractService;
|
|
4087
|
+
this.logger = config.logger;
|
|
4088
|
+
}
|
|
4089
|
+
/**
|
|
4090
|
+
* Executor install + root validator switch + Accounts registration in one UserOp,
|
|
4091
|
+
* signed by the pre-policy (ECDSA sudo) client. Replaces the three-signature
|
|
4092
|
+
* sequence signInExecutor → signInPolicy → registerInAccounts for wallets that
|
|
4093
|
+
* have neither the executor nor the policy installed yet.
|
|
4094
|
+
*/
|
|
4095
|
+
async allInOneStepOnboarding() {
|
|
4096
|
+
const smartWalletClient = await this.walletService.getSmartWalletClientWithoutPolicy();
|
|
4097
|
+
const executorCall = await this.accountAbstractionService.getExecutorInstallCall();
|
|
4098
|
+
const policyCall = await this.accountAbstractionService.getPolicyInstallCall();
|
|
4099
|
+
const accountCall = await this.accountContractService.getAccountRegistrationCall();
|
|
4100
|
+
const callData = await smartWalletClient.account.encodeCalls([
|
|
4101
|
+
executorCall,
|
|
4102
|
+
policyCall,
|
|
4103
|
+
accountCall
|
|
4104
|
+
]);
|
|
4105
|
+
const userOpReceipt = await this.walletService.sendUserOperationsAndWaitReceipt(
|
|
4106
|
+
callData,
|
|
4107
|
+
smartWalletClient
|
|
4108
|
+
);
|
|
4109
|
+
if (!userOpReceipt?.success) {
|
|
4110
|
+
throw new Error(
|
|
4111
|
+
`Onboarding UserOperation failed: userOpHash=${userOpReceipt?.userOpHash}, tx=${userOpReceipt?.receipt?.transactionHash}, reason=${userOpReceipt?.reason ?? "unknown (likely out of gas)"}`
|
|
4112
|
+
);
|
|
4113
|
+
}
|
|
4114
|
+
this.logger?.info("All-in-one onboarding completed", {
|
|
4115
|
+
txHash: userOpReceipt.receipt.transactionHash
|
|
4116
|
+
});
|
|
4117
|
+
return userOpReceipt;
|
|
4118
|
+
}
|
|
4119
|
+
};
|
|
4120
|
+
var UNWRAP_CALL_GAS_FLOOR = 1300000n;
|
|
4046
4121
|
var BaseWalletService = class {
|
|
4047
4122
|
constructor(config) {
|
|
4048
4123
|
this.bundlerTransport = config.bundlerTransport;
|
|
@@ -4112,7 +4187,7 @@ var BaseWalletService = class {
|
|
|
4112
4187
|
throw new Error("Smart wallet client is not available.");
|
|
4113
4188
|
}
|
|
4114
4189
|
try {
|
|
4115
|
-
const trxHash = await
|
|
4190
|
+
const trxHash = await this.sendUserOperation(smartWalletClient, callData, void 0, config);
|
|
4116
4191
|
const result = await smartWalletClient.waitForUserOperationReceipt({
|
|
4117
4192
|
hash: trxHash,
|
|
4118
4193
|
timeout: 30 * 1e3
|
|
@@ -4129,14 +4204,36 @@ var BaseWalletService = class {
|
|
|
4129
4204
|
throw error;
|
|
4130
4205
|
}
|
|
4131
4206
|
}
|
|
4132
|
-
async sendUserOperationsWithNonceAndWaitReceipt(callData, nonce) {
|
|
4207
|
+
async sendUserOperationsWithNonceAndWaitReceipt(callData, nonce, config) {
|
|
4133
4208
|
const smartWalletClient = await this.getSmartWalletClient();
|
|
4134
|
-
const trxHash = await
|
|
4209
|
+
const trxHash = await this.sendUserOperation(smartWalletClient, callData, nonce, config);
|
|
4135
4210
|
return await smartWalletClient.waitForUserOperationReceipt({
|
|
4136
4211
|
hash: trxHash,
|
|
4137
4212
|
timeout: 30 * 1e3
|
|
4138
4213
|
});
|
|
4139
4214
|
}
|
|
4215
|
+
async sendUserOperation(smartWalletClient, callData, nonce, config) {
|
|
4216
|
+
const request = nonce === void 0 ? { callData } : { callData, nonce };
|
|
4217
|
+
if (!config?.applyUnwrapGasFloor) {
|
|
4218
|
+
return await smartWalletClient.sendUserOperation(request);
|
|
4219
|
+
}
|
|
4220
|
+
const fees = await smartWalletClient.getUserOperationGasPrice();
|
|
4221
|
+
const estimate = await smartWalletClient.estimateUserOperationGas({
|
|
4222
|
+
...request,
|
|
4223
|
+
maxFeePerGas: fees.maxFeePerGas,
|
|
4224
|
+
maxPriorityFeePerGas: fees.maxPriorityFeePerGas
|
|
4225
|
+
});
|
|
4226
|
+
const estimated = estimate?.callGasLimit;
|
|
4227
|
+
const callGasLimit = typeof estimated === "bigint" && estimated > UNWRAP_CALL_GAS_FLOOR ? estimated : UNWRAP_CALL_GAS_FLOOR;
|
|
4228
|
+
this.logger?.debug(
|
|
4229
|
+
`Unwrap callGasLimit floor: estimated=${estimated ?? "n/a"} submitted=${callGasLimit}`
|
|
4230
|
+
);
|
|
4231
|
+
return await smartWalletClient.sendUserOperation({
|
|
4232
|
+
...estimate,
|
|
4233
|
+
...request,
|
|
4234
|
+
callGasLimit
|
|
4235
|
+
});
|
|
4236
|
+
}
|
|
4140
4237
|
invalidateLocalCache() {
|
|
4141
4238
|
this.smartWalletClient = void 0;
|
|
4142
4239
|
this.smartAddress = void 0;
|
|
@@ -4164,8 +4261,12 @@ var BaseWalletService = class {
|
|
|
4164
4261
|
chain: this.chain,
|
|
4165
4262
|
bundlerTransport: this.bundlerTransport,
|
|
4166
4263
|
paymaster: {
|
|
4167
|
-
getPaymasterData: (userOperation) => {
|
|
4168
|
-
|
|
4264
|
+
getPaymasterData: async (userOperation) => {
|
|
4265
|
+
const sponsored = await this.kernelPaymasterClient.sponsorUserOperation({ userOperation });
|
|
4266
|
+
this.logger?.debug(
|
|
4267
|
+
`Paymaster gas: requested=${userOperation.callGasLimit ?? "n/a"} sponsored=${sponsored?.callGasLimit ?? "n/a"}`
|
|
4268
|
+
);
|
|
4269
|
+
return sponsored;
|
|
4169
4270
|
}
|
|
4170
4271
|
}
|
|
4171
4272
|
});
|
|
@@ -4543,6 +4644,14 @@ var baseFactory = {
|
|
|
4543
4644
|
logger: config.logger,
|
|
4544
4645
|
contracts: config.contracts
|
|
4545
4646
|
});
|
|
4647
|
+
},
|
|
4648
|
+
createOnboardingService(config, walletService, accountAbstractionService, accountContractService) {
|
|
4649
|
+
return new BaseOnboardingService({
|
|
4650
|
+
walletService,
|
|
4651
|
+
accountAbstractionService,
|
|
4652
|
+
accountContractService,
|
|
4653
|
+
logger: config.logger
|
|
4654
|
+
});
|
|
4546
4655
|
}
|
|
4547
4656
|
};
|
|
4548
4657
|
chainRegistry.register(8453, baseFactory);
|
|
@@ -4829,6 +4938,10 @@ var CryptoModule = class {
|
|
|
4829
4938
|
this.ensureInitialized();
|
|
4830
4939
|
return this._accountContractService;
|
|
4831
4940
|
}
|
|
4941
|
+
get onboarding() {
|
|
4942
|
+
this.ensureInitialized();
|
|
4943
|
+
return this._onboardingService;
|
|
4944
|
+
}
|
|
4832
4945
|
get smartDepositAddress() {
|
|
4833
4946
|
this.ensureInitialized();
|
|
4834
4947
|
if (!this._smartDepositService) {
|
|
@@ -4927,6 +5040,12 @@ var CryptoModule = class {
|
|
|
4927
5040
|
serviceConfig,
|
|
4928
5041
|
this._walletService
|
|
4929
5042
|
);
|
|
5043
|
+
this._onboardingService = factory.createOnboardingService(
|
|
5044
|
+
serviceConfig,
|
|
5045
|
+
this._walletService,
|
|
5046
|
+
this._accountAbstraction,
|
|
5047
|
+
this._accountContractService
|
|
5048
|
+
);
|
|
4930
5049
|
if (config.rhinoApiKey) {
|
|
4931
5050
|
this._smartDepositService = new SmartDepositAddressesService({
|
|
4932
5051
|
walletService: this._walletService,
|
|
@@ -4940,6 +5059,6 @@ var CryptoModule = class {
|
|
|
4940
5059
|
}
|
|
4941
5060
|
};
|
|
4942
5061
|
|
|
4943
|
-
export { BaseAccountAbstractionService, BaseAccountContractService, BaseCryptoService, BaseWalletService, BaseYieldService, ContractRegistryService, CryptoModule, chainRegistry };
|
|
4944
|
-
//# sourceMappingURL=chunk-
|
|
4945
|
-
//# sourceMappingURL=chunk-
|
|
5062
|
+
export { BaseAccountAbstractionService, BaseAccountContractService, BaseCryptoService, BaseOnboardingService, BaseWalletService, BaseYieldService, ContractRegistryService, CryptoModule, chainRegistry };
|
|
5063
|
+
//# sourceMappingURL=chunk-ITBPDXHK.js.map
|
|
5064
|
+
//# sourceMappingURL=chunk-ITBPDXHK.js.map
|