@deserialize/multi-vm-wallet 1.3.2 → 1.3.3
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/.claude/settings.local.json +2 -1
- package/dist/constant.js +60 -16
- package/dist/constant.js.map +1 -1
- package/dist/evm/aa-service/index.d.ts +1 -1
- package/dist/evm/aa-service/index.js +1 -2
- package/dist/evm/aa-service/index.js.map +1 -1
- package/dist/evm/aa-service/lib/kernel-account.d.ts +1 -1
- package/dist/evm/aa-service/lib/kernel-account.js +22 -6
- package/dist/evm/aa-service/lib/kernel-account.js.map +1 -1
- package/dist/evm/aa-service/lib/session-keys.d.ts +14 -17
- package/dist/evm/aa-service/lib/session-keys.js +40 -58
- package/dist/evm/aa-service/lib/session-keys.js.map +1 -1
- package/dist/evm/aa-service/lib/type.d.ts +2 -1
- package/dist/evm/aa-service/lib/type.js.map +1 -1
- package/dist/evm/aa-service/services/account-abstraction.d.ts +3 -29
- package/dist/evm/aa-service/services/account-abstraction.js +3 -67
- package/dist/evm/aa-service/services/account-abstraction.js.map +1 -1
- package/dist/evm/aa-service/services/bundler.js +2 -1
- package/dist/evm/aa-service/services/bundler.js.map +1 -1
- package/dist/evm/evm.d.ts +161 -1
- package/dist/evm/evm.js +247 -0
- package/dist/evm/evm.js.map +1 -1
- package/dist/evm/smartWallet.d.ts +11 -43
- package/dist/evm/smartWallet.js +136 -116
- package/dist/evm/smartWallet.js.map +1 -1
- package/dist/evm/utils.js +0 -1
- package/dist/evm/utils.js.map +1 -1
- package/dist/privacy/artifact-manager.d.ts +117 -0
- package/dist/privacy/artifact-manager.js +251 -0
- package/dist/privacy/artifact-manager.js.map +1 -0
- package/dist/privacy/broadcaster-client.d.ts +166 -0
- package/dist/privacy/broadcaster-client.js +261 -0
- package/dist/privacy/broadcaster-client.js.map +1 -0
- package/dist/privacy/index.d.ts +34 -0
- package/dist/privacy/index.js +56 -0
- package/dist/privacy/index.js.map +1 -0
- package/dist/privacy/network-config.d.ts +57 -0
- package/dist/privacy/network-config.js +118 -0
- package/dist/privacy/network-config.js.map +1 -0
- package/dist/privacy/poi-helper.d.ts +161 -0
- package/dist/privacy/poi-helper.js +249 -0
- package/dist/privacy/poi-helper.js.map +1 -0
- package/dist/privacy/railgun-engine.d.ts +135 -0
- package/dist/privacy/railgun-engine.js +205 -0
- package/dist/privacy/railgun-engine.js.map +1 -0
- package/dist/privacy/railgun-privacy-wallet.d.ts +288 -0
- package/dist/privacy/railgun-privacy-wallet.js +539 -0
- package/dist/privacy/railgun-privacy-wallet.js.map +1 -0
- package/dist/privacy/types.d.ts +229 -0
- package/dist/privacy/types.js +26 -0
- package/dist/privacy/types.js.map +1 -0
- package/dist/savings/savings-manager.d.ts +126 -0
- package/dist/savings/savings-manager.js +234 -0
- package/dist/savings/savings-manager.js.map +1 -0
- package/dist/savings/smart-savings.d.ts +74 -0
- package/dist/savings/smart-savings.js +152 -0
- package/dist/savings/smart-savings.js.map +1 -0
- package/dist/savings/types.d.ts +125 -0
- package/dist/savings/types.js +9 -0
- package/dist/savings/types.js.map +1 -0
- package/dist/svm/svm.d.ts +16 -0
- package/dist/svm/svm.js +23 -0
- package/dist/svm/svm.js.map +1 -1
- package/dist/test.js +53 -15
- package/dist/test.js.map +1 -1
- package/dist/vm.d.ts +14 -0
- package/dist/vm.js.map +1 -1
- package/package.json +2 -1
- package/utils/constant.ts +63 -16
- package/utils/evm/aa-service/index.ts +0 -1
- package/utils/evm/aa-service/lib/kernel-account.ts +23 -8
- package/utils/evm/aa-service/lib/session-keys.ts +58 -60
- package/utils/evm/aa-service/lib/type.ts +2 -1
- package/utils/evm/aa-service/services/account-abstraction.ts +10 -76
- package/utils/evm/aa-service/services/bundler.ts +2 -1
- package/utils/evm/evm.ts +300 -0
- package/utils/evm/smartWallet.ts +118 -128
- package/utils/evm/utils.ts +1 -1
- package/utils/savings/savings-manager.ts +271 -0
- package/utils/savings/smart-savings.ts +184 -0
- package/utils/savings/types.ts +135 -0
- package/utils/svm/svm.ts +27 -0
- package/utils/test.ts +82 -18
- package/utils/vm.ts +10 -0
package/utils/test.ts
CHANGED
|
@@ -11,31 +11,30 @@ import { ChainWalletConfig } from "./types";
|
|
|
11
11
|
import { discoverNFTs, EVMChainWallet } from "./evm";
|
|
12
12
|
import { } from "./svm/transactionParsing";
|
|
13
13
|
import { getEVMTransactionHistory } from "./evm/transactionParsing";
|
|
14
|
-
import { createPublicClient, encodeFunctionData, Hex, http, parseAbi, parseUnits, PublicClient } from "viem";
|
|
14
|
+
import { createPublicClient, encodeFunctionData, Hex, http, parseAbi, parseUnits, PublicClient, zeroAddress } from "viem";
|
|
15
15
|
import { base, baseGoerli } from "viem/chains";
|
|
16
16
|
import { discoverTokens, fetchWalletNfts, getTokenInfo } from "./svm/utils";
|
|
17
|
-
import { JsonRpcProvider } from "ethers";
|
|
17
|
+
import { JsonRpcProvider, N } from "ethers";
|
|
18
18
|
|
|
19
19
|
import { } from "@solana/spl-token-metadata"
|
|
20
20
|
import { entryPoint07Address } from "viem/account-abstraction";
|
|
21
21
|
|
|
22
22
|
import { KERNEL_V3_3, KernelVersionToAddressesMap } from '@zerodev/sdk/constants';
|
|
23
|
+
import { deserializeSessionKey } from "./evm/aa-service";
|
|
24
|
+
import { toSpendingLimitHook } from "@zerodev/hooks"
|
|
23
25
|
// const mnemonic = GenerateNewMnemonic()
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
// console.log('mnemonic: ', mnemonic);
|
|
27
29
|
|
|
28
30
|
// const seed = VM.mnemonicToSeed(mnemonic)
|
|
29
|
-
const pKey = "
|
|
31
|
+
const pKey = ""
|
|
30
32
|
|
|
31
33
|
const testUserKeyPair = Keypair.fromSecretKey(base58.decode(pKey));
|
|
32
34
|
// const x = testUserKeyPair instanceof Keypair;
|
|
33
|
-
const evePrivateKey = "0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318"
|
|
34
|
-
const evmPrivateKey2 = "0x0123456789012345678901234567890123456789012345678901234567890123"
|
|
35
|
-
const ogPrivKey = "d2d3f7117aa9a4c6e5d4affedd8a5ea624ffd82b2a1de81509e5913709b1ea72"
|
|
36
35
|
|
|
37
|
-
const evmPrivKey = "
|
|
38
|
-
const evmPrivateKeyExposed = "
|
|
36
|
+
const evmPrivKey = ""
|
|
37
|
+
const evmPrivateKeyExposed = ""
|
|
39
38
|
// const vm = new SVMVM(seed)
|
|
40
39
|
|
|
41
40
|
|
|
@@ -59,7 +58,7 @@ const chainConfig: ChainWalletConfig = {
|
|
|
59
58
|
const evmChainConfig: ChainWalletConfig = {
|
|
60
59
|
chainId: 8453,
|
|
61
60
|
name: "Base",
|
|
62
|
-
// rpcUrl: "https://
|
|
61
|
+
// rpcUrl: "https://base-mainnet.g.alchemy.com/v2/TFdA4BilCnKIwaqtypk0d",
|
|
63
62
|
rpcUrl: base.rpcUrls.default.http[0],
|
|
64
63
|
explorerUrl: "https://explorer.ethereum.com",
|
|
65
64
|
nativeToken: { name: "Ethereum", symbol: "ETH", decimals: 18 },
|
|
@@ -102,20 +101,17 @@ const OgChainConfig: ChainWalletConfig = {
|
|
|
102
101
|
const wallet = new EVMChainWallet(evmChainConfig, evmPrivateKeyExposed, 0)
|
|
103
102
|
|
|
104
103
|
//IIFE
|
|
105
|
-
const walletA = new EVMChainWallet(evmChainConfig, evmPrivateKeyExposed, 0); //wallet that usdc to send
|
|
104
|
+
const walletA = new EVMChainWallet(evmChainConfig, evmPrivateKeyExposed, 0); //wallet that has usdc to send
|
|
106
105
|
const walletB = new EVMChainWallet(evmChainConfig, evmPrivKey, 0); // wallet that has gas
|
|
107
106
|
const SEPOLIA_USDC_ADDRESS = '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238' as Hex;
|
|
108
107
|
const BASE_USDC_ADDRESS = '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913' as Hex;
|
|
109
108
|
const bundlerUrl = `https://api.pimlico.io/v2/${evmChainConfig.chainId}/rpc?apikey=pim_3UEhbTpS98H1XFm8p9kRxg`;
|
|
110
109
|
|
|
111
110
|
const RECIPIENT = "0x7027F9C9a701adCbfCD55D16aD219501D4b9589A";
|
|
112
|
-
|
|
113
|
-
return
|
|
114
|
-
console.log("walletA address: ", walletA.address);
|
|
115
|
-
console.log("walletB address: ", walletB.address);
|
|
111
|
+
const testSessionKeys = async () => {
|
|
116
112
|
|
|
113
|
+
console.log("walletA address: ", walletA.address);
|
|
117
114
|
|
|
118
|
-
//GET TOKEN LOGO using @solana/spl-token-metadata
|
|
119
115
|
const walletANativeBalance = await walletA.getNativeBalance();
|
|
120
116
|
console.log('walletA native balance: ', walletANativeBalance);
|
|
121
117
|
|
|
@@ -125,6 +121,9 @@ const RECIPIENT = "0x7027F9C9a701adCbfCD55D16aD219501D4b9589A";
|
|
|
125
121
|
//wallet B USDC balance
|
|
126
122
|
const walletBUSDCBalance = await walletB.getTokenBalance(BASE_USDC_ADDRESS);
|
|
127
123
|
console.log('walletB USDC balance: ', walletBUSDCBalance);
|
|
124
|
+
console.log("walletB address: ", walletB.address);
|
|
125
|
+
|
|
126
|
+
|
|
128
127
|
|
|
129
128
|
//extend wallet A wallet to a smart wallet with AA support
|
|
130
129
|
const extendedWalletA = await walletA.extend({
|
|
@@ -134,17 +133,82 @@ const RECIPIENT = "0x7027F9C9a701adCbfCD55D16aD219501D4b9589A";
|
|
|
134
133
|
// console.log('extendedWalletA: ', extendedWalletA);
|
|
135
134
|
const initializedExtendedWalletA = await extendedWalletA.initialize()
|
|
136
135
|
|
|
137
|
-
|
|
136
|
+
|
|
137
|
+
//now we want to test session keys
|
|
138
|
+
const sessionKeys = await initializedExtendedWalletA.generateSessionKey()
|
|
139
|
+
console.log('sessionKeys: ', sessionKeys);
|
|
140
|
+
|
|
141
|
+
|
|
138
142
|
|
|
139
143
|
|
|
144
|
+
// return;
|
|
145
|
+
const usdcPermission = initializedExtendedWalletA.createUSDCPermission(
|
|
146
|
+
BASE_USDC_ADDRESS,
|
|
147
|
+
"1", // approve up to 100 USDC,
|
|
148
|
+
RECIPIENT
|
|
149
|
+
)
|
|
150
|
+
console.log('usdcPermission: ', usdcPermission);
|
|
151
|
+
const sessionKeyApproval = await initializedExtendedWalletA.approveSessionKey(
|
|
152
|
+
{
|
|
153
|
+
sessionKeyAddress: sessionKeys.address,
|
|
154
|
+
sessionKeyPrivateKey: sessionKeys.privateKey,
|
|
155
|
+
permissions: [usdcPermission],
|
|
156
|
+
// useSudoPolicy: true,
|
|
157
|
+
}
|
|
158
|
+
)
|
|
140
159
|
|
|
141
|
-
|
|
160
|
+
const data = encodeFunctionData({
|
|
161
|
+
abi: parseAbi([
|
|
162
|
+
'function transfer(address to, uint256 amount) public returns (bool)'
|
|
163
|
+
]),
|
|
164
|
+
functionName: 'transfer',
|
|
165
|
+
args: [RECIPIENT, parseUnits('0.01', 6)]
|
|
166
|
+
}) // transfer 10 USDC
|
|
167
|
+
console.log('sessionKeyApproval: ', sessionKeyApproval);
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
const sessionKeyAccount = await deserializeSessionKey({
|
|
172
|
+
approval: sessionKeyApproval,
|
|
173
|
+
sessionKeySigner: sessionKeys.signer,
|
|
174
|
+
chain: base
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
//send transaction using session key
|
|
178
|
+
|
|
179
|
+
const sessionAccount = {
|
|
180
|
+
account: sessionKeyAccount,
|
|
181
|
+
address: sessionKeyAccount.address,
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const hash = await initializedExtendedWalletA.sendTransaction(BASE_USDC_ADDRESS, 0n, data, {
|
|
185
|
+
sessionAccount: sessionAccount
|
|
186
|
+
})
|
|
187
|
+
console.log('hash: ', hash);
|
|
188
|
+
//get session key client
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const testModule = async () => {
|
|
196
|
+
const extendedWalletA = await walletA.extend({
|
|
197
|
+
bundlerUrl: bundlerUrl
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
const initializedExtendedWalletA = await extendedWalletA.initialize()
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
//this is where we will test installation of modules
|
|
205
|
+
}
|
|
142
206
|
|
|
143
207
|
|
|
144
208
|
|
|
145
209
|
// console.log('wallet: ', wallet);
|
|
146
210
|
// getTokenInfo(new PublicKey("9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump"), wallet.connection!).then(e => console.log('token info: ', e))
|
|
147
|
-
|
|
211
|
+
|
|
148
212
|
// wallet.getNativeBalance().then(e => console.log('native balance: ', e))
|
|
149
213
|
|
|
150
214
|
// const toBuy = new PublicKey("9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump")
|
package/utils/vm.ts
CHANGED
|
@@ -70,6 +70,16 @@ export abstract class VM<AddressType, PrivateKeyType, ConnectionType> {
|
|
|
70
70
|
abstract generatePrivateKey(index: number, mnemonic?: string, derivationPath?: string): { privateKey: PrivateKeyType, index: number };
|
|
71
71
|
abstract getTokenInfo(tokenAddress: AddressType, connection: ConnectionType): Promise<TokenInfo>
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Derive a savings account using BIP-44 account index
|
|
75
|
+
*
|
|
76
|
+
* Main wallet uses: m/44'/60'/0'/0/0 (account index 0)
|
|
77
|
+
* Savings accounts use: m/44'/60'/N'/0/0 (account index N)
|
|
78
|
+
*
|
|
79
|
+
* @param accountIndex - The BIP-44 account index (1 for first savings, 2 for second, etc.)
|
|
80
|
+
* @returns Object containing privateKey, address, and derivation path
|
|
81
|
+
*/
|
|
82
|
+
abstract deriveSavingsAccount(accountIndex: number): { privateKey: PrivateKeyType; address: AddressType; derivationPath: string };
|
|
73
83
|
|
|
74
84
|
// abstract validateAddress(address: AddressType): boolean;
|
|
75
85
|
// abstract getNativeBalance(address: AddressType, connection: ConnectionType): Promise<Balance>;
|