kokio-sdk 0.1.3 → 0.1.4
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/esm/config.js
CHANGED
|
@@ -13,7 +13,7 @@ export class Kokio {
|
|
|
13
13
|
organizationId;
|
|
14
14
|
pimlicoAPIKey;
|
|
15
15
|
gasPolicyId;
|
|
16
|
-
|
|
16
|
+
_constants;
|
|
17
17
|
smartAccount;
|
|
18
18
|
deviceWalletFactory;
|
|
19
19
|
eSIMWalletFactory;
|
|
@@ -28,7 +28,7 @@ export class Kokio {
|
|
|
28
28
|
this.organizationId = organizationId;
|
|
29
29
|
this.pimlicoAPIKey = pimlicoAPIKey;
|
|
30
30
|
this.gasPolicyId = gasPolicyId;
|
|
31
|
-
this.
|
|
31
|
+
this._constants = new ConstantsSubPackage(this.viemWalletClient, this.pimlicoAPIKey);
|
|
32
32
|
this.smartAccount = new SmartAccountSubPackage(this.viemWalletClient, this.credentialId, this.rpId, this.organizationId, this.pimlicoAPIKey, this.gasPolicyId);
|
|
33
33
|
this.deviceWalletFactory = smartAccountClient ? new DeviceWalletFactorySubPackage(viemWalletClient, smartAccountClient) : undefined;
|
|
34
34
|
this.eSIMWalletFactory = smartAccountClient ? new ESIMWalletFactorySubPackage(viemWalletClient, smartAccountClient) : undefined;
|
|
@@ -37,4 +37,16 @@ export class Kokio {
|
|
|
37
37
|
this.deviceWallet = deviceWalletAddress && smartAccountClient ? new DeviceWalletSubPackage(viemWalletClient, smartAccountClient, deviceWalletAddress) : undefined;
|
|
38
38
|
this.eSIMWallet = eSIMWalletAddress && smartAccountClient ? new ESIMWalletSubPackage(smartAccountClient, eSIMWalletAddress) : undefined;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Chain-specific constants (factory addresses, chain, RPC URLs, custom errors)
|
|
42
|
+
* for the wallet client's connected chain. Resolution is asynchronous because
|
|
43
|
+
* the chain id is read from the client, so this getter returns a promise:
|
|
44
|
+
*
|
|
45
|
+
* const { factoryAddresses } = await kokio.constants;
|
|
46
|
+
*
|
|
47
|
+
* The underlying value is memoized, so repeated awaits do not re-fetch.
|
|
48
|
+
*/
|
|
49
|
+
get constants() {
|
|
50
|
+
return this._constants.load();
|
|
51
|
+
}
|
|
40
52
|
}
|
|
@@ -1,15 +1,38 @@
|
|
|
1
1
|
import { _extractChainID, _getChainSpecificConstants } from "../logic/constants.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves chain-specific constants for the wallet client's connected chain.
|
|
4
|
+
*
|
|
5
|
+
* The chain id can only be read asynchronously from the client, so resolution
|
|
6
|
+
* is deferred to `load()` (memoized after the first call). Access the resolved
|
|
7
|
+
* values via `await kokio.constants` on the top-level SDK instance.
|
|
8
|
+
*/
|
|
2
9
|
export class ConstantsSubPackage {
|
|
3
|
-
|
|
4
|
-
|
|
10
|
+
client;
|
|
11
|
+
pimlicoAPIKey;
|
|
12
|
+
cache;
|
|
5
13
|
constructor(client, pimlicoAPIKey) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
this.client = client;
|
|
15
|
+
this.pimlicoAPIKey = pimlicoAPIKey;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolves and caches the chain-specific constants. Subsequent calls
|
|
19
|
+
* return the same promise, so the chain id is only fetched once.
|
|
20
|
+
*/
|
|
21
|
+
load() {
|
|
22
|
+
if (!this.cache) {
|
|
23
|
+
this.cache = (async () => {
|
|
24
|
+
const chainID = await _extractChainID(this.client);
|
|
25
|
+
const rpcURL = this.client.transport.url;
|
|
26
|
+
const values = _getChainSpecificConstants(chainID, rpcURL, this.pimlicoAPIKey);
|
|
27
|
+
return {
|
|
28
|
+
factoryAddresses: values.factoryAddresses,
|
|
29
|
+
chain: values.chain,
|
|
30
|
+
rpcURL: values.rpcURL,
|
|
31
|
+
pimlicoRpcURL: values.pimlicoRpcURL,
|
|
32
|
+
customErrors: values.customErrors,
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
}
|
|
36
|
+
return this.cache;
|
|
14
37
|
}
|
|
15
38
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { createSmartAccountClient, getEntryPoint, toSmartContractAccount, split } from "@aa-sdk/core";
|
|
1
|
+
import { createSmartAccountClient, getEntryPoint, toSmartContractAccount, split, erc7677Middleware } from "@aa-sdk/core";
|
|
2
2
|
import { http, encodeFunctionData, encodePacked, encodeAbiParameters, parseAbiParameters, getContract, concat, keccak256, getContractAddress, getAddress, hashMessage, stringToBytes, toHex, hexToBytes, bytesToHex } from "viem";
|
|
3
3
|
import { _getChainSpecificConstants, ZERO, SIGNATURE_VALIDITY_SECONDS } from "../constants.js";
|
|
4
4
|
import { _remove0x } from "../utils.js";
|
|
5
5
|
import { DeviceWallet, DeviceWalletFactory } from "../../abis/index.js";
|
|
6
|
-
import { alchemyGasManagerMiddleware } from "@account-kit/infra";
|
|
7
6
|
import { isoBase64URL } from "@simplewebauthn/server/helpers";
|
|
8
7
|
import { Passkey } from "react-native-passkey";
|
|
9
8
|
import { p256 } from "@noble/curves/nist.js";
|
|
@@ -294,6 +293,6 @@ export const _getSmartWalletClient = async (client, pimlicoAPIKey, gasPolicyId,
|
|
|
294
293
|
fallback: http(values.rpcURL),
|
|
295
294
|
}),
|
|
296
295
|
// transport: http(values.rpcURL),
|
|
297
|
-
...
|
|
296
|
+
...erc7677Middleware({ context: { policyId: gasPolicyId } })
|
|
298
297
|
});
|
|
299
298
|
};
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address, WalletClient } from "viem";
|
|
2
|
-
import {
|
|
2
|
+
import { KokioConstants } from "./interface/constantsClass.js";
|
|
3
3
|
import { SmartAccountSubPackage } from "./interface/smartAccountClass.js";
|
|
4
4
|
import { DeviceWalletFactorySubPackage } from "./interface/deviceWalletFactoryClass.js";
|
|
5
5
|
import { P256VerifierSubPackage } from "./interface/P256VerifierClass.js";
|
|
@@ -15,7 +15,7 @@ export declare class Kokio {
|
|
|
15
15
|
organizationId: string;
|
|
16
16
|
pimlicoAPIKey: string;
|
|
17
17
|
gasPolicyId: string;
|
|
18
|
-
|
|
18
|
+
private _constants;
|
|
19
19
|
smartAccount: SmartAccountSubPackage;
|
|
20
20
|
deviceWalletFactory?: DeviceWalletFactorySubPackage;
|
|
21
21
|
eSIMWalletFactory?: ESIMWalletFactorySubPackage;
|
|
@@ -24,4 +24,14 @@ export declare class Kokio {
|
|
|
24
24
|
eSIMWallet?: ESIMWalletSubPackage;
|
|
25
25
|
P256Verifier?: P256VerifierSubPackage;
|
|
26
26
|
constructor(viemWalletClient: WalletClient, credentialId: string, rpId: string, organizationId: string, pimlicoAPIKey: string, gasPolicyId: string, smartAccountClient?: SmartAccountClient, deviceWalletAddress?: Address, eSIMWalletAddress?: Address);
|
|
27
|
+
/**
|
|
28
|
+
* Chain-specific constants (factory addresses, chain, RPC URLs, custom errors)
|
|
29
|
+
* for the wallet client's connected chain. Resolution is asynchronous because
|
|
30
|
+
* the chain id is read from the client, so this getter returns a promise:
|
|
31
|
+
*
|
|
32
|
+
* const { factoryAddresses } = await kokio.constants;
|
|
33
|
+
*
|
|
34
|
+
* The underlying value is memoized, so repeated awaits do not re-fetch.
|
|
35
|
+
*/
|
|
36
|
+
get constants(): Promise<KokioConstants>;
|
|
27
37
|
}
|
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
import { WalletClient } from "viem";
|
|
2
|
-
import { mainnetFactoryAddresses, sepoliaFactoryAddresses, optimismMainnetFactoryAddresses, optimismSepoliaFactoryAddresses, arbitrumOneFactoryAddresses, arbitrumSepoliaFactoryAddresses, customErrors } from "../logic/constants.js";
|
|
3
|
-
export
|
|
4
|
-
factoryAddresses: typeof sepoliaFactoryAddresses | typeof mainnetFactoryAddresses | typeof optimismMainnetFactoryAddresses | typeof optimismSepoliaFactoryAddresses | typeof arbitrumOneFactoryAddresses | typeof arbitrumSepoliaFactoryAddresses;
|
|
2
|
+
import { mainnetFactoryAddresses, sepoliaFactoryAddresses, optimismMainnetFactoryAddresses, optimismSepoliaFactoryAddresses, baseMainnetFactoryAddresses, baseSepoliaFactoryAddresses, arbitrumOneFactoryAddresses, arbitrumSepoliaFactoryAddresses, customErrors, chainSpecifcConstants } from "../logic/constants.js";
|
|
3
|
+
export interface KokioConstants {
|
|
4
|
+
factoryAddresses: typeof sepoliaFactoryAddresses | typeof mainnetFactoryAddresses | typeof optimismMainnetFactoryAddresses | typeof optimismSepoliaFactoryAddresses | typeof baseMainnetFactoryAddresses | typeof baseSepoliaFactoryAddresses | typeof arbitrumOneFactoryAddresses | typeof arbitrumSepoliaFactoryAddresses;
|
|
5
|
+
chain: chainSpecifcConstants["chain"];
|
|
6
|
+
rpcURL: string;
|
|
7
|
+
pimlicoRpcURL: string;
|
|
5
8
|
customErrors: typeof customErrors;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolves chain-specific constants for the wallet client's connected chain.
|
|
12
|
+
*
|
|
13
|
+
* The chain id can only be read asynchronously from the client, so resolution
|
|
14
|
+
* is deferred to `load()` (memoized after the first call). Access the resolved
|
|
15
|
+
* values via `await kokio.constants` on the top-level SDK instance.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ConstantsSubPackage {
|
|
18
|
+
private client;
|
|
19
|
+
private pimlicoAPIKey;
|
|
20
|
+
private cache?;
|
|
6
21
|
constructor(client: WalletClient, pimlicoAPIKey: string);
|
|
22
|
+
/**
|
|
23
|
+
* Resolves and caches the chain-specific constants. Subsequent calls
|
|
24
|
+
* return the same promise, so the chain id is only fetched once.
|
|
25
|
+
*/
|
|
26
|
+
load(): Promise<KokioConstants>;
|
|
7
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kokio-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/esm/config.js",
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"types": "./dist/types/types-export.d.ts",
|
|
18
18
|
"import": "./dist/esm/types.js"
|
|
19
19
|
},
|
|
20
|
+
"./abis": {
|
|
21
|
+
"types": "./dist/types/abis/index.d.ts",
|
|
22
|
+
"import": "./dist/esm/abis/index.js",
|
|
23
|
+
"default": "./dist/esm/abis/index.js"
|
|
24
|
+
},
|
|
20
25
|
"./package.json": "./package.json"
|
|
21
26
|
},
|
|
22
27
|
"scripts": {
|
|
@@ -40,7 +45,6 @@
|
|
|
40
45
|
},
|
|
41
46
|
"dependencies": {
|
|
42
47
|
"@aa-sdk/core": "4.88.4",
|
|
43
|
-
"@account-kit/infra": "4.88.4",
|
|
44
48
|
"@noble/curves": "2.2.0",
|
|
45
49
|
"@peculiar/asn1-ecc": "2.8.0",
|
|
46
50
|
"@peculiar/asn1-schema": "2.8.0",
|