gokite-aa-sdk 1.0.4 → 1.0.5
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.
|
@@ -2,13 +2,35 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ethers_1 = require("ethers");
|
|
4
4
|
const gokite_aa_sdk_1 = require("./gokite-aa-sdk");
|
|
5
|
+
const example_1 = require("./example");
|
|
6
|
+
// Contract addresses on kite_testnet
|
|
7
|
+
const ADDRESSES = {
|
|
8
|
+
SETTLEMENT_TOKEN: '0x0fF5393387ad2f9f691FD6Fd28e07E3969e27e63',
|
|
9
|
+
SETTLEMENT_CONTRACT: '0x8d9FaD78d5Ce247aA01C140798B9558fd64a63E3',
|
|
10
|
+
CLIENT_AGENT_VAULT_IMPL: '0xB5AAFCC6DD4DFc2B80fb8BCcf406E1a2Fd559e23',
|
|
11
|
+
SERVICE_REGISTRY: '0xF727EDE22C9e338a7d1d57B930dcEBbC6a66c008'
|
|
12
|
+
};
|
|
5
13
|
async function simpleExample() {
|
|
6
14
|
const sdk = new gokite_aa_sdk_1.GokiteAASDK('kite_testnet', 'https://rpc-testnet.gokite.ai', 'https://bundler-service.staging.gokite.ai/rpc/');
|
|
7
15
|
const signer = new ethers_1.ethers.Wallet(process.env.PRIVATE_KEY);
|
|
16
|
+
const aa = sdk.getAccountAddress(signer.address);
|
|
17
|
+
// Prepare initialization data
|
|
18
|
+
const initializeCallData = ethers_1.ethers.Interface.from([
|
|
19
|
+
'function initialize(address allowedToken, address owner)'
|
|
20
|
+
]).encodeFunctionData('initialize', [
|
|
21
|
+
ADDRESSES.SETTLEMENT_TOKEN,
|
|
22
|
+
aa
|
|
23
|
+
]);
|
|
24
|
+
// Create KitePass deployment bytecode
|
|
25
|
+
const proxyConstructorData = ethers_1.ethers.AbiCoder.defaultAbiCoder().encode(['address', 'address', 'bytes'], [ADDRESSES.CLIENT_AGENT_VAULT_IMPL, aa, initializeCallData]);
|
|
26
|
+
const transparentProxyBytecode = (0, example_1.getTransparentProxyBytecode)();
|
|
27
|
+
const fullInitCode = transparentProxyBytecode + proxyConstructorData.slice(2);
|
|
8
28
|
const request = {
|
|
9
|
-
target:
|
|
10
|
-
value:
|
|
11
|
-
callData:
|
|
29
|
+
target: aa,
|
|
30
|
+
value: 0n,
|
|
31
|
+
callData: ethers_1.ethers.Interface.from([
|
|
32
|
+
'function performCreate(uint256 value, bytes calldata initCode) returns (address)'
|
|
33
|
+
]).encodeFunctionData('performCreate', [0n, fullInitCode])
|
|
12
34
|
};
|
|
13
35
|
console.log('📊 Estimate transaction...');
|
|
14
36
|
const estimate = await sdk.estimateUserOperation(signer.address, request);
|
package/dist/gokite-aa-sdk.js
CHANGED
|
@@ -428,7 +428,13 @@ class GokiteAASDK {
|
|
|
428
428
|
gasEstimate.callGasLimit = gasEstimate.callGasLimit + 5000000n;
|
|
429
429
|
gasEstimate.verificationGasLimit = gasEstimate.verificationGasLimit + 1000000n;
|
|
430
430
|
gasEstimate.preVerificationGas = gasEstimate.preVerificationGas + 1000000n;
|
|
431
|
-
|
|
431
|
+
const maxFeePerGas = BigInt(10000000); // 0.001 gwei
|
|
432
|
+
const maxPriorityFeePerGas = BigInt(1); // 1 wei
|
|
433
|
+
userOp.gasFees = (0, utils_1.packAccountGasLimits)(maxPriorityFeePerGas, maxFeePerGas);
|
|
434
|
+
// Pack gas limits and fees (note: verificationGasLimit first, callGasLimit second)
|
|
435
|
+
userOp.accountGasLimits = (0, utils_1.packAccountGasLimits)(gasEstimate.verificationGasLimit, gasEstimate.callGasLimit);
|
|
436
|
+
userOp.preVerificationGas = gasEstimate.preVerificationGas;
|
|
437
|
+
userOp.gasFees = (0, utils_1.packAccountGasLimits)(gasEstimate.maxPriorityFeePerGas, gasEstimate.maxFeePerGas);
|
|
432
438
|
// Calculate total cost in KITE
|
|
433
439
|
const totalGas = gasEstimate.callGasLimit + gasEstimate.verificationGasLimit + gasEstimate.preVerificationGas;
|
|
434
440
|
const totalCostWei = totalGas * gasEstimate.maxFeePerGas;
|