kokio-sdk 0.0.2 → 0.0.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/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -14,6 +14,7 @@ export class Kokio {
|
|
|
14
14
|
viemWalletClient: WalletClient;
|
|
15
15
|
turnkeyClient: TurnkeyClient;
|
|
16
16
|
organizationId: string;
|
|
17
|
+
gasPolicyId: string;
|
|
17
18
|
|
|
18
19
|
constants: ConstantsSubPackage;
|
|
19
20
|
|
|
@@ -29,6 +30,7 @@ export class Kokio {
|
|
|
29
30
|
viemWalletClient: WalletClient,
|
|
30
31
|
turnkeyClient: TurnkeyClient,
|
|
31
32
|
organizationId: string,
|
|
33
|
+
gasPolicyId: string,
|
|
32
34
|
smartAccountClient?: SmartAccountClient,
|
|
33
35
|
deviceWalletAddress?: Address,
|
|
34
36
|
eSIMWalletAddress?: Address
|
|
@@ -36,10 +38,11 @@ export class Kokio {
|
|
|
36
38
|
this.viemWalletClient = viemWalletClient;
|
|
37
39
|
this.turnkeyClient = turnkeyClient;
|
|
38
40
|
this.organizationId = organizationId;
|
|
41
|
+
this.gasPolicyId = gasPolicyId;
|
|
39
42
|
|
|
40
43
|
this.constants = new ConstantsSubPackage(this.viemWalletClient);
|
|
41
44
|
|
|
42
|
-
this.smartAccount = new SmartAccountSubPackage(this.viemWalletClient, this.turnkeyClient, this.organizationId);
|
|
45
|
+
this.smartAccount = new SmartAccountSubPackage(this.viemWalletClient, this.turnkeyClient, this.organizationId, this.gasPolicyId);
|
|
43
46
|
this.deviceWalletFactory = smartAccountClient? new DeviceWalletFactorySubPackage(viemWalletClient, smartAccountClient): undefined;
|
|
44
47
|
this.eSIMWalletFactory = smartAccountClient? new ESIMWalletFactorySubPackage(viemWalletClient, smartAccountClient): undefined;
|
|
45
48
|
this.lazyWalletRegistry = smartAccountClient? new LazyWalletRegistrySubPackage(smartAccountClient): undefined;
|
|
@@ -9,11 +9,13 @@ export class SmartAccountSubPackage {
|
|
|
9
9
|
client;
|
|
10
10
|
turnkeyClient;
|
|
11
11
|
organizationId;
|
|
12
|
+
gasPolicyId;
|
|
12
13
|
|
|
13
|
-
constructor(client: WalletClient, turnkeyClient: TurnkeyClient, organiationId: string) {
|
|
14
|
+
constructor(client: WalletClient, turnkeyClient: TurnkeyClient, organiationId: string, gasPolicyId: string) {
|
|
14
15
|
this.client = client;
|
|
15
16
|
this.turnkeyClient = turnkeyClient;
|
|
16
17
|
this.organizationId = organiationId;
|
|
18
|
+
this.gasPolicyId = gasPolicyId;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
getSmartWallet (deviceUniqueIdentifier: string, deviceWalletOwnerKey: P256Key, salt: bigint, sender?: Address) {
|
|
@@ -21,6 +23,6 @@ export class SmartAccountSubPackage {
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
getSmartWalletClient (account: SmartContractAccount) {
|
|
24
|
-
return _getSmartWalletClient(this.client, account)
|
|
26
|
+
return _getSmartWalletClient(this.client, this.gasPolicyId, account)
|
|
25
27
|
}
|
|
26
28
|
}
|
|
@@ -26,6 +26,7 @@ import { _add0x, _concatUint8Arrays, _remove0x, _shouldRemoveLeadingZero } from
|
|
|
26
26
|
import { P256Key, WebAuthnSignature } from "../../types.js";
|
|
27
27
|
import { DeviceWallet, DeviceWalletFactory } from "../../abis/index.js";
|
|
28
28
|
import { _signMessageWithTurnkey, _signTypedDataWithTurnkey } from "../services/turnkeyClient.js";
|
|
29
|
+
import { alchemyGasManagerMiddleware } from "@account-kit/infra";
|
|
29
30
|
|
|
30
31
|
const _encodeExecute = async (tx: AccountOp) => {
|
|
31
32
|
|
|
@@ -227,7 +228,15 @@ const _signUserOperationHash = async (hash: Hex, turnkeyClient: TurnkeyClient, o
|
|
|
227
228
|
return _signMessage(message, turnkeyClient, organiationId, signWith);
|
|
228
229
|
}
|
|
229
230
|
|
|
230
|
-
export const _getSmartWallet = async (
|
|
231
|
+
export const _getSmartWallet = async (
|
|
232
|
+
client: WalletClient,
|
|
233
|
+
turnkeyClient: TurnkeyClient,
|
|
234
|
+
organiationId: string,
|
|
235
|
+
deviceUniqueIdentifier: string,
|
|
236
|
+
deviceWalletOwnerKey: P256Key,
|
|
237
|
+
salt: bigint,
|
|
238
|
+
sender?: Address
|
|
239
|
+
): Promise<SmartContractAccount> => {
|
|
231
240
|
|
|
232
241
|
const chainID = await client.getChainId();
|
|
233
242
|
const rpcURL = client.transport.url;
|
|
@@ -244,14 +253,14 @@ export const _getSmartWallet = async (client: WalletClient, turnkeyClient: Turnk
|
|
|
244
253
|
chain: values.chain,
|
|
245
254
|
|
|
246
255
|
// The EntryPointDef that your account is compatible with
|
|
247
|
-
|
|
256
|
+
entryPoint: getEntryPoint(values.chain, {version: "0.7.0"}),
|
|
248
257
|
|
|
249
258
|
getAccountInitCode: async (): Promise<Hex> => await _getAccountInitCode(client, deviceUniqueIdentifier, deviceWalletOwnerKey, salt),
|
|
250
259
|
|
|
251
260
|
// getAccountInitCodeHash: async (): Promise<BytesLike> => await getInitCodeHash(client, deviceUniqueIdentifier, deviceWalletOwnerKey),
|
|
252
261
|
|
|
253
262
|
// an invalid signature that doesn't cause your account to revert during validation
|
|
254
|
-
getDummySignature: async (): Promise<Hash> => "
|
|
263
|
+
getDummySignature: async (): Promise<Hash> => "0x",
|
|
255
264
|
|
|
256
265
|
// given a UO in the form of {target, data, value} should output the calldata for calling your contract's execution method
|
|
257
266
|
encodeExecute: async (uo): Promise<Hash> => _encodeExecute(uo),
|
|
@@ -272,7 +281,7 @@ export const _getSmartWallet = async (client: WalletClient, turnkeyClient: Turnk
|
|
|
272
281
|
});
|
|
273
282
|
}
|
|
274
283
|
|
|
275
|
-
export const _getSmartWalletClient = async (client: WalletClient, account: SmartContractAccount) => {
|
|
284
|
+
export const _getSmartWalletClient = async (client: WalletClient, gasPolicyId: string, account: SmartContractAccount) => {
|
|
276
285
|
|
|
277
286
|
const chainID = await client.getChainId();
|
|
278
287
|
const rpcURL = client.transport.url;
|
|
@@ -283,5 +292,6 @@ export const _getSmartWalletClient = async (client: WalletClient, account: Smart
|
|
|
283
292
|
account: account,
|
|
284
293
|
chain: values.chain,
|
|
285
294
|
transport: http(values.rpcURL),
|
|
295
|
+
...alchemyGasManagerMiddleware(gasPolicyId)
|
|
286
296
|
});
|
|
287
297
|
}
|
package/src/logic/constants.ts
CHANGED
|
@@ -44,7 +44,7 @@ export const sepoliaFactoryAddresses: Record<string, Address> = {
|
|
|
44
44
|
LAZY_WALLET_REGISTRY: '0x8a1E53b903efcc6b252CE4bD3b255202318505Ef',
|
|
45
45
|
REGISTRY: '0xCa447f5C75C57f6C59027304A5Fb5A09F0E005c9',
|
|
46
46
|
ENTRY_POINT: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',
|
|
47
|
-
SENDER_CREATOR: '
|
|
47
|
+
SENDER_CREATOR: '0xefc2c1444ebcc4db75e7613d20c6a62ff67a167c',
|
|
48
48
|
P256VERIFIER: '0xF04f3b3935aD461D17d4a8a78E7ea21d4a61AEb1'
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -73,8 +73,8 @@ export const optimismSepoliaFactoryAddresses: Record<string, Address> = {
|
|
|
73
73
|
ESIM_WALLET_FACTORY: '0xaD2Ba6248D0e6990a844C94ACE78F8775A68b631',
|
|
74
74
|
LAZY_WALLET_REGISTRY: '0x29b98C32D83604664fd0742b9112b0825a74849F',
|
|
75
75
|
REGISTRY: '0xaeB98F0f092fCb4a476ea3a5EB6A4B9E3D63A686',
|
|
76
|
-
ENTRY_POINT: '
|
|
77
|
-
SENDER_CREATOR: '
|
|
76
|
+
ENTRY_POINT: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',
|
|
77
|
+
SENDER_CREATOR: '0xefc2c1444ebcc4db75e7613d20c6a62ff67a167c',
|
|
78
78
|
P256VERIFIER: '0x5349aEA97Faa6D5d6D78A8847068300a4eC9D39E'
|
|
79
79
|
}
|
|
80
80
|
|