@aastar/sdk 0.20.4 → 0.20.6

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.
Files changed (92) hide show
  1. package/README.md +32 -24
  2. package/dist/BaseClient-BjbYP0cf.d.ts +88 -0
  3. package/dist/UserClient-AIIHB54I.js +6 -0
  4. package/dist/{UserClient-JMNNZT4P.js.map → UserClient-AIIHB54I.js.map} +1 -1
  5. package/dist/account.d.ts +48 -1
  6. package/dist/account.js +3 -3
  7. package/dist/admin.d.ts +62 -1
  8. package/dist/admin.js +3 -3
  9. package/dist/airaccount.d.ts +4 -2
  10. package/dist/airaccount.js +2 -4498
  11. package/dist/airaccount.js.map +1 -1
  12. package/dist/channel-CkRRbzT8.d.ts +77 -0
  13. package/dist/channel.d.ts +64 -1
  14. package/dist/channel.js +3 -3
  15. package/dist/{chunk-YSDWB6DO.js → chunk-4EZD7LPE.js} +30 -24
  16. package/dist/chunk-4EZD7LPE.js.map +1 -0
  17. package/dist/{chunk-TBDMSJVL.js → chunk-6QYXGMCR.js} +513 -322
  18. package/dist/chunk-6QYXGMCR.js.map +1 -0
  19. package/dist/{chunk-QNYP7RPI.js → chunk-7ARJ3OSU.js} +29 -21
  20. package/dist/chunk-7ARJ3OSU.js.map +1 -0
  21. package/dist/{chunk-KL6SCEIU.js → chunk-BN5WY5GM.js} +16 -14
  22. package/dist/chunk-BN5WY5GM.js.map +1 -0
  23. package/dist/{chunk-5TDDS3T5.js → chunk-FJ7XECC5.js} +4 -4
  24. package/dist/chunk-FJ7XECC5.js.map +1 -0
  25. package/dist/{chunk-4KRQXOTI.js → chunk-FUU7RIIA.js} +113 -102
  26. package/dist/chunk-FUU7RIIA.js.map +1 -0
  27. package/dist/{chunk-ZJLIKMCA.js → chunk-G3UJC4EL.js} +17 -8
  28. package/dist/chunk-G3UJC4EL.js.map +1 -0
  29. package/dist/{chunk-M5ORP2PM.js → chunk-KDH3UPKD.js} +10 -13
  30. package/dist/chunk-KDH3UPKD.js.map +1 -0
  31. package/dist/chunk-KISL64KW.js +4245 -0
  32. package/dist/chunk-KISL64KW.js.map +1 -0
  33. package/dist/{chunk-Y3KP7R2Y.js → chunk-LXWIPTPX.js} +5 -5
  34. package/dist/chunk-LXWIPTPX.js.map +1 -0
  35. package/dist/{chunk-NAPMVAVJ.js → chunk-MVEWJIPY.js} +124 -110
  36. package/dist/chunk-MVEWJIPY.js.map +1 -0
  37. package/dist/{chunk-LNICTATJ.js → chunk-PAABYXS6.js} +33 -40
  38. package/dist/chunk-PAABYXS6.js.map +1 -0
  39. package/dist/{chunk-O454V5ML.js → chunk-PKCHRXFR.js} +8 -12
  40. package/dist/chunk-PKCHRXFR.js.map +1 -0
  41. package/dist/{chunk-R2RATIK2.js → chunk-TENYCMJ3.js} +31 -31
  42. package/dist/chunk-TENYCMJ3.js.map +1 -0
  43. package/dist/{contract-addresses-VLAHHXOO.js → contract-addresses-N3TOL2WL.js} +3 -3
  44. package/dist/{contract-addresses-VLAHHXOO.js.map → contract-addresses-N3TOL2WL.js.map} +1 -1
  45. package/dist/core.d.ts +6930 -13
  46. package/dist/core.js +2 -2
  47. package/dist/dapp.d.ts +127 -1
  48. package/dist/dapp.js +12 -13
  49. package/dist/dapp.js.map +1 -1
  50. package/dist/doc-types-471vSmPO.d.ts +16 -0
  51. package/dist/enduser.d.ts +261 -1
  52. package/dist/enduser.js +4 -4
  53. package/dist/identity.d.ts +81 -1
  54. package/dist/identity.js +3 -3
  55. package/dist/index-B6SfEQxo.d.ts +47 -0
  56. package/dist/index.d.ts +55 -14
  57. package/dist/index.js +22 -22
  58. package/dist/index.js.map +1 -1
  59. package/dist/kms.d.ts +2986 -0
  60. package/dist/kms.js +5 -0
  61. package/dist/kms.js.map +1 -0
  62. package/dist/operator.d.ts +164 -1
  63. package/dist/operator.js +3 -3
  64. package/dist/paymaster.d.ts +312 -1
  65. package/dist/paymaster.js +3 -3
  66. package/dist/{index.node-GNYPFVZQ.js → src-L5SI5WNB.js} +4 -4
  67. package/dist/src-L5SI5WNB.js.map +1 -0
  68. package/dist/{dist-WMYQOYRO.js → src-X5MIV3EB.js} +5 -5
  69. package/dist/src-X5MIV3EB.js.map +1 -0
  70. package/dist/tier-router-DLiMxs0h.d.ts +321 -0
  71. package/dist/tokens.d.ts +64 -1
  72. package/dist/tokens.js +3 -3
  73. package/dist/x402.d.ts +373 -1
  74. package/dist/x402.js +3 -3
  75. package/package.json +19 -15
  76. package/LICENSE +0 -180
  77. package/dist/UserClient-JMNNZT4P.js +0 -6
  78. package/dist/chunk-4KRQXOTI.js.map +0 -1
  79. package/dist/chunk-5TDDS3T5.js.map +0 -1
  80. package/dist/chunk-KL6SCEIU.js.map +0 -1
  81. package/dist/chunk-LNICTATJ.js.map +0 -1
  82. package/dist/chunk-M5ORP2PM.js.map +0 -1
  83. package/dist/chunk-NAPMVAVJ.js.map +0 -1
  84. package/dist/chunk-O454V5ML.js.map +0 -1
  85. package/dist/chunk-QNYP7RPI.js.map +0 -1
  86. package/dist/chunk-R2RATIK2.js.map +0 -1
  87. package/dist/chunk-TBDMSJVL.js.map +0 -1
  88. package/dist/chunk-Y3KP7R2Y.js.map +0 -1
  89. package/dist/chunk-YSDWB6DO.js.map +0 -1
  90. package/dist/chunk-ZJLIKMCA.js.map +0 -1
  91. package/dist/dist-WMYQOYRO.js.map +0 -1
  92. package/dist/index.node-GNYPFVZQ.js.map +0 -1
@@ -0,0 +1,77 @@
1
+ import { Address, Hex, Account, Hash, PublicClient, WalletClient } from 'viem';
2
+
3
+ type ChannelState = {
4
+ payer: Address;
5
+ payee: Address;
6
+ token: Address;
7
+ authorizedSigner: Address;
8
+ deposit: bigint;
9
+ settled: bigint;
10
+ closeRequestedAt: bigint;
11
+ finalized: boolean;
12
+ };
13
+ type ChannelActions = {
14
+ openChannel: (args: {
15
+ payee: Address;
16
+ token: Address;
17
+ deposit: bigint;
18
+ salt: Hex;
19
+ authorizedSigner: Address;
20
+ account?: Account | Address;
21
+ }) => Promise<Hash>;
22
+ settleChannel: (args: {
23
+ channelId: Hex;
24
+ cumulativeAmount: bigint;
25
+ signature: Hex;
26
+ account?: Account | Address;
27
+ }) => Promise<Hash>;
28
+ closeChannel: (args: {
29
+ channelId: Hex;
30
+ cumulativeAmount: bigint;
31
+ signature: Hex;
32
+ account?: Account | Address;
33
+ }) => Promise<Hash>;
34
+ topUpChannel: (args: {
35
+ channelId: Hex;
36
+ amount: bigint;
37
+ account?: Account | Address;
38
+ }) => Promise<Hash>;
39
+ requestCloseChannel: (args: {
40
+ channelId: Hex;
41
+ account?: Account | Address;
42
+ }) => Promise<Hash>;
43
+ withdrawChannel: (args: {
44
+ channelId: Hex;
45
+ account?: Account | Address;
46
+ }) => Promise<Hash>;
47
+ getChannel: (args: {
48
+ channelId: Hex;
49
+ }) => Promise<ChannelState>;
50
+ /**
51
+ * @deprecated The deployed MicroPaymentChannel ABI no longer exposes a `CLOSE_TIMEOUT`
52
+ * constant — it was replaced by the configurable {@link closeTimeout} getter plus the
53
+ * {@link MIN_CLOSE_TIMEOUT}/{@link MAX_CLOSE_TIMEOUT} bounds. This wrapper now delegates
54
+ * to the on-chain `closeTimeout()` getter so it no longer reverts; use {@link closeTimeout}.
55
+ */
56
+ CLOSE_TIMEOUT: () => Promise<bigint>;
57
+ /** Current configurable close-timeout (seconds, view). ABI: closeTimeout() -> uint64. */
58
+ closeTimeout: () => Promise<bigint>;
59
+ /** Set the configurable close-timeout window (owner-gated). ABI: setCloseTimeout(uint64 _timeout). */
60
+ setCloseTimeout: (args: {
61
+ timeout: bigint;
62
+ account?: Account | Address;
63
+ }) => Promise<Hash>;
64
+ /** Whether a given channelId has already been closed (view). ABI: closedChannels(bytes32) -> bool. */
65
+ closedChannels: (args: {
66
+ channelId: Hex;
67
+ }) => Promise<boolean>;
68
+ /** Upper bound for {@link setCloseTimeout} (view). ABI: MAX_CLOSE_TIMEOUT() -> uint64. */
69
+ MAX_CLOSE_TIMEOUT: () => Promise<bigint>;
70
+ /** Lower bound for {@link setCloseTimeout} (view). ABI: MIN_CLOSE_TIMEOUT() -> uint64. */
71
+ MIN_CLOSE_TIMEOUT: () => Promise<bigint>;
72
+ VOUCHER_TYPEHASH: () => Promise<Hex>;
73
+ version: () => Promise<string>;
74
+ };
75
+ declare const channelActions: (address: Address) => (client: PublicClient | WalletClient) => ChannelActions;
76
+
77
+ export { type ChannelState as C, type ChannelActions as a, channelActions as c };
package/dist/channel.d.ts CHANGED
@@ -1 +1,64 @@
1
- export * from '@aastar/channel';
1
+ import { Hex, PublicClient, WalletClient, Address, Hash } from 'viem';
2
+ import { C as ChannelState } from './channel-CkRRbzT8.js';
3
+
4
+ type VoucherParams = {
5
+ channelId: Hex;
6
+ cumulativeAmount: bigint;
7
+ };
8
+ type SignedVoucher = VoucherParams & {
9
+ signature: Hex;
10
+ };
11
+ type ChannelConfig = {
12
+ payee: `0x${string}`;
13
+ token: `0x${string}`;
14
+ deposit: bigint;
15
+ salt: Hex;
16
+ authorizedSigner: `0x${string}`;
17
+ };
18
+
19
+ type ChannelClientConfig = {
20
+ publicClient: PublicClient;
21
+ walletClient: WalletClient;
22
+ channelAddress: Address;
23
+ chainId: number;
24
+ };
25
+ declare class ChannelClient {
26
+ private readonly readActions;
27
+ private readonly writeActions;
28
+ private readonly config;
29
+ constructor(config: ChannelClientConfig);
30
+ openChannel(channelConfig: ChannelConfig): Promise<Hash>;
31
+ signVoucherOffline(channelId: Hex, cumulativeAmount: bigint): Promise<SignedVoucher>;
32
+ settleChannel(voucher: SignedVoucher): Promise<Hash>;
33
+ closeChannel(voucher: SignedVoucher): Promise<Hash>;
34
+ topUpChannel(channelId: Hex, amount: bigint): Promise<Hash>;
35
+ requestClose(channelId: Hex): Promise<Hash>;
36
+ withdraw(channelId: Hex): Promise<Hash>;
37
+ getChannelState(channelId: Hex): Promise<ChannelState>;
38
+ getCloseTimeout(): Promise<bigint>;
39
+ getVersion(): Promise<string>;
40
+ }
41
+
42
+ declare const VOUCHER_TYPES: {
43
+ readonly Voucher: readonly [{
44
+ readonly name: "channelId";
45
+ readonly type: "bytes32";
46
+ }, {
47
+ readonly name: "cumulativeAmount";
48
+ readonly type: "uint128";
49
+ }];
50
+ };
51
+ declare function getVoucherDomain(chainId: number, verifyingContract: Address): {
52
+ name: string;
53
+ version: string;
54
+ chainId: number;
55
+ verifyingContract: `0x${string}`;
56
+ };
57
+ declare function signVoucher(walletClient: WalletClient, params: {
58
+ channelId: Hex;
59
+ cumulativeAmount: bigint;
60
+ chainId: number;
61
+ verifyingContract: Address;
62
+ }): Promise<Hex>;
63
+
64
+ export { ChannelClient, type ChannelClientConfig, type ChannelConfig, ChannelState, type SignedVoucher, VOUCHER_TYPES, type VoucherParams, getVoucherDomain, signVoucher };
package/dist/channel.js CHANGED
@@ -1,6 +1,6 @@
1
- export { ChannelClient, VOUCHER_TYPES, getVoucherDomain, signVoucher } from './chunk-Y3KP7R2Y.js';
2
- import './chunk-TBDMSJVL.js';
3
- import './chunk-ZJLIKMCA.js';
1
+ export { ChannelClient, VOUCHER_TYPES, getVoucherDomain, signVoucher } from './chunk-LXWIPTPX.js';
2
+ import './chunk-6QYXGMCR.js';
3
+ import './chunk-G3UJC4EL.js';
4
4
  import './chunk-PZ5AY32C.js';
5
5
  //# sourceMappingURL=channel.js.map
6
6
  //# sourceMappingURL=channel.js.map
@@ -1,4 +1,4 @@
1
- import { SimpleAccountFactoryABI } from './chunk-TBDMSJVL.js';
1
+ import { SimpleAccountFactoryABI } from './chunk-6QYXGMCR.js';
2
2
  import { http, createWalletClient, encodeAbiParameters, keccak256, encodeFunctionData, concatHex } from 'viem';
3
3
  import { privateKeyToAccount } from 'viem/accounts';
4
4
 
@@ -24,26 +24,32 @@ function packUserOpLimits(high, low) {
24
24
  return `0x${(high << 128n | low).toString(16).padStart(64, "0")}`;
25
25
  }
26
26
  function getUserOpHash(op, ep, chainId) {
27
- const packed = encodeAbiParameters([
28
- { type: "address" },
29
- { type: "uint256" },
30
- { type: "bytes32" },
31
- { type: "bytes32" },
32
- { type: "bytes32" },
33
- { type: "uint256" },
34
- { type: "bytes32" },
35
- { type: "bytes32" }
36
- ], [
37
- op.sender,
38
- BigInt(op.nonce),
39
- keccak256(op.initCode && op.initCode !== "0x" ? op.initCode : "0x"),
40
- keccak256(op.callData),
41
- op.accountGasLimits,
42
- BigInt(op.preVerificationGas),
43
- op.gasFees,
44
- keccak256(op.paymasterAndData)
45
- ]);
46
- const enc = encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "uint256" }], [keccak256(packed), ep, BigInt(chainId)]);
27
+ const packed = encodeAbiParameters(
28
+ [
29
+ { type: "address" },
30
+ { type: "uint256" },
31
+ { type: "bytes32" },
32
+ { type: "bytes32" },
33
+ { type: "bytes32" },
34
+ { type: "uint256" },
35
+ { type: "bytes32" },
36
+ { type: "bytes32" }
37
+ ],
38
+ [
39
+ op.sender,
40
+ BigInt(op.nonce),
41
+ keccak256(op.initCode && op.initCode !== "0x" ? op.initCode : "0x"),
42
+ keccak256(op.callData),
43
+ op.accountGasLimits,
44
+ BigInt(op.preVerificationGas),
45
+ op.gasFees,
46
+ keccak256(op.paymasterAndData)
47
+ ]
48
+ );
49
+ const enc = encodeAbiParameters(
50
+ [{ type: "bytes32" }, { type: "address" }, { type: "uint256" }],
51
+ [keccak256(packed), ep, BigInt(chainId)]
52
+ );
47
53
  return keccak256(enc);
48
54
  }
49
55
  var UserOpClient = class {
@@ -67,7 +73,7 @@ var UserOpClient = class {
67
73
  }
68
74
  };
69
75
 
70
- // ../account/dist/accounts/simple.js
76
+ // ../account/src/accounts/simple.ts
71
77
  async function toSimpleSmartAccount(parameters) {
72
78
  const { client, owner, factoryAddress, entryPoint, index = 0n, salt = 0n } = parameters;
73
79
  const factoryData = encodeFunctionData({
@@ -112,5 +118,5 @@ async function toSimpleSmartAccount(parameters) {
112
118
  }
113
119
 
114
120
  export { UserOpClient, createEOAWalletClient, getUserOpHash, packUserOpLimits, toSimpleSmartAccount };
115
- //# sourceMappingURL=chunk-YSDWB6DO.js.map
116
- //# sourceMappingURL=chunk-YSDWB6DO.js.map
121
+ //# sourceMappingURL=chunk-4EZD7LPE.js.map
122
+ //# sourceMappingURL=chunk-4EZD7LPE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../account/src/eoa.ts","../../account/src/index.ts","../../account/src/accounts/simple.ts"],"names":[],"mappings":";;;;AAQO,IAAM,wBAAwB,CACjC,UAAA,EACA,KAAA,EACA,SAAA,GAAuB,MAAK,KACV;AAClB,EAAA,MAAM,OAAA,GAAU,oBAAoB,UAAU,CAAA;AAC9C,EAAA,MAAM,SAAS,kBAAA,CAAmB;AAAA,IAC9B,OAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACH,CAAA;AAED,EAAA,OAAO,MAAA,CAAO,OAAO,MAAA,EAAQ;AAAA,IACzB,MAAM,gBAAgB,IAAA,EAAmD;AACrE,MAAA,OAAO,OAAO,eAAA,CAAgB;AAAA,QAC1B,GAAG,IAAA;AAAA,QACH,OAAA;AAAA,QACA;AAAA,OACH,CAAA;AAAA,IACL,CAAA;AAAA,IACA,UAAA,EAAY,MAAM,OAAA,CAAQ;AAAA,GAC7B,CAAA;AACL;ACtBO,SAAS,gBAAA,CAAiB,MAAc,GAAA,EAAkB;AAC7D,EAAA,OAAO,CAAA,EAAA,EAAA,CAAO,IAAA,IAAQ,IAAA,GAAQ,GAAA,EAAK,QAAA,CAAS,EAAE,CAAA,CAAE,QAAA,CAAS,EAAA,EAAI,GAAG,CAAC,CAAA,CAAA;AACrE;AAKO,SAAS,aAAA,CAAc,EAAA,EAAS,EAAA,EAAa,OAAA,EAAsB;AACtE,EAAA,MAAM,MAAA,GAAS,mBAAA;AAAA,IACX;AAAA,MACI,EAAE,MAAM,SAAA,EAAU;AAAA,MAAG,EAAE,MAAM,SAAA,EAAU;AAAA,MAAG,EAAE,MAAM,SAAA,EAAU;AAAA,MAAG,EAAE,MAAM,SAAA,EAAU;AAAA,MACjF,EAAE,MAAM,SAAA,E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AA,OAAO,KAAA,CAAM,cAAc,SAAS,CAAA;AAAA,IACxC,CAAA;AAAA,IAEA,MAAM,gBAAgB,WAAA,EAAgC;AAClD,MAAA,MAAM,IAAI,MAAM,uEAAuE,CAAA;AAAA,IAC3F,CAAA;AAAA,IAEA,MAAM,kBAAkB,MAAA,EAA2B;AAC/C,MAAA,MAAM,OAAA,GAAU,MAAA,CAAO,KAAA,EAAO,EAAA,IAAM,KAAA;AACpC,MAAA,MAAM,IAAA,GAAO,aAAA,CAAc,MAAA,EAAQ,UAAA,CAAW,SAAS,OAAO,CAAA;AAC9D,MAAA,OAAO,KAAA,CAAM,YAAY,EAAE,OAAA,EAAS,EAAE,GAAA,EAAK,IAAA,IAAQ,CAAA;AAAA,IACvD,CAAA;AAAA,IAEA,MAAM,WAAA,GAAc;AAChB,MAAA,OAAO,QAAA;AAAA,IACX,CAAA;AAAA,IAEA,MAAM,iBAAA,GAAoB;AACtB,MAAA,OAAO,8IAAA;AAAA,IACX;AAAA,GAEJ;AACJ","file":"chunk-4EZD7LPE.js","sourcesContent":["import { type WalletClient, type PublicClient, type Address, type Chain, type Transport, type Hash, type Hex, createWalletClient, http } from 'viem';\nimport { privateKeyToAccount } from 'viem/accounts';\n\nexport type EOAWalletClient = WalletClient & {\n sendTransaction: (args: { to: Address, value?: bigint, data?: Hex }) => Promise<Hash>;\n getAddress: () => Address;\n};\n\nexport const createEOAWalletClient = (\n privateKey: Hex, \n chain: Chain, \n transport: Transport = http()\n): EOAWalletClient => {\n const account = privateKeyToAccount(privateKey);\n const client = createWalletClient({\n account,\n chain,\n transport\n });\n\n return Object.assign(client, {\n async sendTransaction(args: { to: Address, value?: bigint, data?: Hex }) {\n return client.sendTransaction({\n ...args,\n account,\n chain\n });\n },\n getAddress: () => account.address\n }) as EOAWalletClient;\n};\n","import { type Hex, type Address, encodeAbiParameters, keccak256 } from 'viem';\n\nexport * from './eoa.js';\nexport * from './accounts/simple.js';\n\n/**\n * Common Pack Logic for v0.7 UserOperations\n */\nexport function packUserOpLimits(high: bigint, low: bigint): Hex {\n return `0x${((high << 128n) | low).toString(16).padStart(64, '0')}` as Hex;\n}\n\n/**\n * Local implementation of EntryPoint v0.7 getUserOpHash\n */\nexport function getUserOpHash(op: any, ep: Address, chainId: number): Hex {\n const packed = encodeAbiParameters(\n [\n { type: 'address' }, { type: 'uint256' }, { type: 'bytes32' }, { type: 'bytes32' },\n { type: 'bytes32' }, { type: 'uint256' }, { type: 'bytes32' }, { type: 'bytes32' }\n ],\n [\n op.sender, BigInt(op.nonce), \n keccak256(op.initCode && op.initCode !== \"0x\" ? op.initCode : '0x'), \n keccak256(op.callData),\n op.accountGasLimits, BigInt(op.preVerificationGas), op.gasFees,\n keccak256(op.paymasterAndData)\n ]\n );\n const enc = encodeAbiParameters(\n [{ type: 'bytes32' }, { type: 'address' }, { type: 'uint256' }],\n [keccak256(packed), ep, BigInt(chainId)]\n );\n return keccak256(enc);\n}\n\n/**\n * UserOperation Client for handling high-level flows\n */\nexport class UserOpClient {\n static async estimateGas(bundler: any, op: any, entryPoint: Address) {\n return bundler.request({\n method: 'eth_estimateUserOperationGas',\n params: [op, entryPoint]\n });\n }\n\n static async sendUserOp(bundler: any, op: any, entryPoint: Address) {\n return bundler.request({\n method: 'eth_sendUserOperation',\n params: [op, entryPoint]\n });\n }\n\n static async getReceipt(bundler: any, hash: Hex) {\n return bundler.request({\n method: 'eth_getUserOperationReceipt',\n params: [hash]\n });\n }\n}\n","import { \n type Address, \n type Hex, \n type LocalAccount, \n type SignableMessage, \n type TypedDataDefinition,\n type Hash,\n concatHex, \n encodeFunctionData, \n keccak256,\n} from 'viem';\nimport { SimpleAccountFactoryABI, type PublicClient } from '@aastar/core';\nimport { getUserOpHash } from '../index.js';\n\nexport type SimpleSmartAccount = LocalAccount & {\n signUserOperation: (userOp: any) => Promise<Hex>;\n getInitCode: () => Promise<Hex>;\n getDummySignature: () => Promise<Hex>;\n entryPoint: Address;\n};\n\nexport async function toSimpleSmartAccount(parameters: {\n client: any;\n owner: LocalAccount;\n factoryAddress: Address;\n entryPoint: { address: Address; version: '0.6' | '0.7' };\n salt?: bigint;\n index?: bigint;\n}): Promise<SimpleSmartAccount> {\n const { client, owner, factoryAddress, entryPoint, index = 0n, salt = 0n } = parameters;\n \n // Calculate initCode\n const factoryData = encodeFunctionData({\n abi: SimpleAccountFactoryABI,\n functionName: 'createAccount',\n args: [owner.address, salt]\n });\n const initCode = concatHex([factoryAddress, factoryData]);\n\n // Calculate counterfactual address\n const address = await client.readContract({\n address: factoryAddress,\n abi: SimpleAccountFactoryABI,\n functionName: 'getAddress',\n args: [owner.address, salt]\n });\n\n return {\n address,\n publicKey: owner.address,\n source: 'custom', \n type: 'local',\n entryPoint: entryPoint.address,\n \n async signMessage({ message }: { message: SignableMessage }): Promise<Hex> {\n // validating signature for smart account usually involves EIP-1271, \n // but here we just sign with owner for SimpleAccount which validates owner sig\n return owner.signMessage({ message });\n },\n\n async signTypedData(typedData: TypedDataDefinition): Promise<Hex> {\n return owner.signTypedData(typedData);\n },\n\n async signTransaction(transaction: any): Promise<Hex> {\n throw new Error('Smart Accounts cannot sign transactions directly. Use UserOperations.');\n },\n \n async signUserOperation(userOp: any): Promise<Hex> {\n const chainId = client.chain?.id || 31337; // Default to local anvil if not found\n const hash = getUserOpHash(userOp, entryPoint.address, chainId);\n return owner.signMessage({ message: { raw: hash } });\n },\n \n async getInitCode() {\n return initCode;\n },\n\n async getDummySignature() {\n return '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';\n }\n\n } as any as SimpleSmartAccount;\n}\n"]}