@charterlabs/rhinestone-sdk 0.3.0 → 0.3.1

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 (123) hide show
  1. package/dist/src/accounts/error.d.ts +8 -1
  2. package/dist/src/accounts/error.d.ts.map +1 -1
  3. package/dist/src/accounts/error.js +10 -1
  4. package/dist/src/accounts/index.d.ts +9 -9
  5. package/dist/src/accounts/index.d.ts.map +1 -1
  6. package/dist/src/accounts/index.js +65 -44
  7. package/dist/src/accounts/kernel.d.ts +3 -5
  8. package/dist/src/accounts/kernel.d.ts.map +1 -1
  9. package/dist/src/accounts/kernel.js +8 -17
  10. package/dist/src/accounts/kernel.test.js +10 -3
  11. package/dist/src/accounts/nexus.d.ts +3 -5
  12. package/dist/src/accounts/nexus.d.ts.map +1 -1
  13. package/dist/src/accounts/nexus.js +108 -57
  14. package/dist/src/accounts/nexus.test.js +10 -3
  15. package/dist/src/accounts/passport.d.ts +4 -7
  16. package/dist/src/accounts/passport.d.ts.map +1 -1
  17. package/dist/src/accounts/passport.js +0 -91
  18. package/dist/src/accounts/safe.d.ts +9 -4
  19. package/dist/src/accounts/safe.d.ts.map +1 -1
  20. package/dist/src/accounts/safe.js +108 -38
  21. package/dist/src/accounts/safe.test.js +10 -3
  22. package/dist/src/accounts/signing/common.d.ts +3 -3
  23. package/dist/src/accounts/signing/common.d.ts.map +1 -1
  24. package/dist/src/accounts/signing/common.js +36 -3
  25. package/dist/src/accounts/signing/message.js +2 -2
  26. package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
  27. package/dist/src/accounts/signing/typedData.js +3 -3
  28. package/dist/src/accounts/startale.d.ts +2 -4
  29. package/dist/src/accounts/startale.d.ts.map +1 -1
  30. package/dist/src/accounts/startale.js +0 -4
  31. package/dist/src/accounts/utils.d.ts.map +1 -1
  32. package/dist/src/accounts/utils.js +10 -3
  33. package/dist/src/accounts/walletClient.d.ts.map +1 -1
  34. package/dist/src/accounts/walletClient.js +6 -0
  35. package/dist/src/actions/compact.d.ts +3 -2
  36. package/dist/src/actions/compact.d.ts.map +1 -1
  37. package/dist/src/actions/compact.js +1 -0
  38. package/dist/src/actions/deployment.d.ts +19 -0
  39. package/dist/src/actions/deployment.d.ts.map +1 -0
  40. package/dist/src/actions/deployment.js +78 -0
  41. package/dist/src/actions/index.d.ts +3 -1
  42. package/dist/src/actions/index.d.ts.map +1 -1
  43. package/dist/src/actions/index.js +12 -0
  44. package/dist/src/actions/smart-sessions.d.ts +7 -8
  45. package/dist/src/actions/smart-sessions.d.ts.map +1 -1
  46. package/dist/src/actions/smart-sessions.js +7 -4
  47. package/dist/src/errors/index.d.ts +2 -2
  48. package/dist/src/errors/index.d.ts.map +1 -1
  49. package/dist/src/errors/index.js +2 -1
  50. package/dist/src/execution/compact.d.ts +12 -17
  51. package/dist/src/execution/compact.d.ts.map +1 -1
  52. package/dist/src/execution/compact.js +10 -16
  53. package/dist/src/execution/error.d.ts +1 -8
  54. package/dist/src/execution/error.d.ts.map +1 -1
  55. package/dist/src/execution/error.js +1 -10
  56. package/dist/src/execution/index.d.ts +3 -3
  57. package/dist/src/execution/index.d.ts.map +1 -1
  58. package/dist/src/execution/index.js +10 -21
  59. package/dist/src/execution/permit2.d.ts +12 -17
  60. package/dist/src/execution/permit2.d.ts.map +1 -1
  61. package/dist/src/execution/permit2.js +10 -16
  62. package/dist/src/execution/singleChainOps.d.ts +15 -3
  63. package/dist/src/execution/singleChainOps.d.ts.map +1 -1
  64. package/dist/src/execution/singleChainOps.js +17 -3
  65. package/dist/src/execution/utils.d.ts +29 -7
  66. package/dist/src/execution/utils.d.ts.map +1 -1
  67. package/dist/src/execution/utils.js +103 -127
  68. package/dist/src/index.d.ts +22 -6
  69. package/dist/src/index.d.ts.map +1 -1
  70. package/dist/src/index.js +36 -5
  71. package/dist/src/modules/abi/smart-session-emissary.d.ts +696 -0
  72. package/dist/src/modules/abi/smart-session-emissary.d.ts.map +1 -0
  73. package/dist/src/modules/abi/smart-session-emissary.js +565 -0
  74. package/dist/src/modules/chain-abstraction.d.ts +5 -0
  75. package/dist/src/modules/chain-abstraction.d.ts.map +1 -0
  76. package/dist/src/modules/chain-abstraction.js +7 -0
  77. package/dist/src/modules/common.d.ts +7 -1
  78. package/dist/src/modules/common.d.ts.map +1 -1
  79. package/dist/src/modules/index.d.ts +3 -9
  80. package/dist/src/modules/index.d.ts.map +1 -1
  81. package/dist/src/modules/index.js +10 -8
  82. package/dist/src/modules/index.test.js +3 -9
  83. package/dist/src/modules/legacy.d.ts +10 -0
  84. package/dist/src/modules/legacy.d.ts.map +1 -0
  85. package/dist/src/modules/legacy.js +65 -0
  86. package/dist/src/modules/validators/core.d.ts.map +1 -1
  87. package/dist/src/modules/validators/core.js +2 -0
  88. package/dist/src/modules/validators/index.d.ts +2 -2
  89. package/dist/src/modules/validators/index.d.ts.map +1 -1
  90. package/dist/src/modules/validators/index.js +1 -6
  91. package/dist/src/modules/validators/smart-sessions.d.ts +105 -20
  92. package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
  93. package/dist/src/modules/validators/smart-sessions.js +199 -435
  94. package/dist/src/orchestrator/client.d.ts +7 -3
  95. package/dist/src/orchestrator/client.d.ts.map +1 -1
  96. package/dist/src/orchestrator/client.js +3 -13
  97. package/dist/src/orchestrator/index.d.ts +2 -2
  98. package/dist/src/orchestrator/index.d.ts.map +1 -1
  99. package/dist/src/orchestrator/index.js +2 -1
  100. package/dist/src/orchestrator/registry.d.ts +2 -1
  101. package/dist/src/orchestrator/registry.d.ts.map +1 -1
  102. package/dist/src/orchestrator/registry.js +12 -0
  103. package/dist/src/orchestrator/registry.test.js +13 -0
  104. package/dist/src/orchestrator/types.d.ts +8 -5
  105. package/dist/src/orchestrator/types.d.ts.map +1 -1
  106. package/dist/src/types.d.ts +31 -21
  107. package/dist/src/types.d.ts.map +1 -1
  108. package/dist/src/utils/index.d.ts +14 -2
  109. package/dist/src/utils/index.d.ts.map +1 -1
  110. package/dist/src/utils/index.js +46 -4
  111. package/dist/test/utils/utils.d.ts +5 -0
  112. package/dist/test/utils/utils.d.ts.map +1 -0
  113. package/dist/test/utils/utils.js +20 -0
  114. package/package.json +32 -2
  115. package/dist/src/execution/smart-session.d.ts +0 -13
  116. package/dist/src/execution/smart-session.d.ts.map +0 -1
  117. package/dist/src/execution/smart-session.js +0 -178
  118. package/dist/src/modules/omni-account.d.ts +0 -8
  119. package/dist/src/modules/omni-account.d.ts.map +0 -1
  120. package/dist/src/modules/omni-account.js +0 -13
  121. package/dist/src/modules/validators/smart-sessions.test.d.ts +0 -2
  122. package/dist/src/modules/validators/smart-sessions.test.d.ts.map +0 -1
  123. package/dist/src/modules/validators/smart-sessions.test.js +0 -222
@@ -47,17 +47,20 @@ function getTypedData(element, nonce, expires) {
47
47
  { name: 'targetChain', type: 'uint256' },
48
48
  { name: 'fillExpiry', type: 'uint256' },
49
49
  ],
50
- Op: [
50
+ Ops: [
51
51
  { name: 'to', type: 'address' },
52
52
  { name: 'value', type: 'uint256' },
53
53
  { name: 'data', type: 'bytes' },
54
54
  ],
55
+ Op: [
56
+ { name: 'vt', type: 'bytes32' },
57
+ { name: 'ops', type: 'Ops[]' },
58
+ ],
55
59
  Mandate: [
56
60
  { name: 'target', type: 'Target' },
57
- { name: 'v', type: 'uint8' },
58
61
  { name: 'minGas', type: 'uint128' },
59
- { name: 'originOps', type: 'Op[]' },
60
- { name: 'destOps', type: 'Op[]' },
62
+ { name: 'originOps', type: 'Op' },
63
+ { name: 'destOps', type: 'Op' },
61
64
  { name: 'q', type: 'bytes32' },
62
65
  ],
63
66
  PermitBatchWitnessTransferFrom: [
@@ -84,18 +87,9 @@ function getTypedData(element, nonce, expires) {
84
87
  targetChain: BigInt(mandate.destinationChainId),
85
88
  fillExpiry: BigInt(mandate.fillDeadline),
86
89
  },
87
- v: mandate.v || 0,
88
- minGas: BigInt(mandate.minGas || '0'),
89
- originOps: mandate.preClaimOps.map((op) => ({
90
- to: op.to,
91
- value: BigInt(op.value),
92
- data: op.data,
93
- })),
94
- destOps: mandate.destinationOps.map((op) => ({
95
- to: op.to,
96
- value: BigInt(op.value),
97
- data: op.data,
98
- })),
90
+ minGas: BigInt(mandate.minGas),
91
+ originOps: mandate.preClaimOps,
92
+ destOps: mandate.destinationOps,
99
93
  q: (0, viem_1.keccak256)(mandate.qualifier.encodedVal),
100
94
  },
101
95
  },
@@ -1,5 +1,5 @@
1
- import type { Address } from 'viem';
2
- import type { Execution, IntentOpElement } from '../orchestrator/types';
1
+ import { type Address } from 'viem';
2
+ import type { IntentOpElement } from '../orchestrator/types';
3
3
  declare function getTypedData(account: Address, intentExecutorAddress: Address, element: IntentOpElement, nonce: bigint): {
4
4
  domain: {
5
5
  name: string;
@@ -16,12 +16,24 @@ declare function getTypedData(account: Address, intentExecutorAddress: Address,
16
16
  name: string;
17
17
  type: string;
18
18
  }[];
19
+ GasRefund: {
20
+ name: string;
21
+ type: string;
22
+ }[];
23
+ Ops: {
24
+ name: string;
25
+ type: string;
26
+ }[];
19
27
  };
20
28
  primaryType: "SingleChainOps";
21
29
  message: {
22
30
  account: `0x${string}`;
23
31
  nonce: bigint;
24
- ops: Execution[];
32
+ op: import("../orchestrator/types").Op;
33
+ gasRefund: {
34
+ token: "0x0000000000000000000000000000000000000000";
35
+ exchangeRate: bigint;
36
+ };
25
37
  };
26
38
  };
27
39
  export { getTypedData };
@@ -1 +1 @@
1
- {"version":3,"file":"singleChainOps.d.ts","sourceRoot":"","sources":["../../../execution/singleChainOps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvE,iBAAS,YAAY,CACnB,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,OAAO,EAC9B,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;EA8Bd;AACD,OAAO,EAAE,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"singleChainOps.d.ts","sourceRoot":"","sources":["../../../execution/singleChainOps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAe,MAAM,MAAM,CAAA;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,iBAAS,YAAY,CACnB,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,OAAO,EAC9B,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0Cd;AACD,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTypedData = getTypedData;
4
+ const viem_1 = require("viem");
4
5
  function getTypedData(account, intentExecutorAddress, element, nonce) {
5
- const ops = element.mandate.destinationOps;
6
6
  return {
7
7
  domain: {
8
8
  name: 'IntentExecutor',
@@ -14,9 +14,18 @@ function getTypedData(account, intentExecutorAddress, element, nonce) {
14
14
  SingleChainOps: [
15
15
  { name: 'account', type: 'address' },
16
16
  { name: 'nonce', type: 'uint256' },
17
- { name: 'ops', type: 'Op[]' },
17
+ { name: 'op', type: 'Op' },
18
+ { name: 'gasRefund', type: 'GasRefund' },
18
19
  ],
19
20
  Op: [
21
+ { name: 'vt', type: 'bytes32' },
22
+ { name: 'ops', type: 'Ops[]' },
23
+ ],
24
+ GasRefund: [
25
+ { name: 'token', type: 'address' },
26
+ { name: 'exchangeRate', type: 'uint256' },
27
+ ],
28
+ Ops: [
20
29
  { name: 'to', type: 'address' },
21
30
  { name: 'value', type: 'uint256' },
22
31
  { name: 'data', type: 'bytes' },
@@ -26,7 +35,12 @@ function getTypedData(account, intentExecutorAddress, element, nonce) {
26
35
  message: {
27
36
  account,
28
37
  nonce,
29
- ops,
38
+ op: element.mandate.destinationOps,
39
+ // todo
40
+ gasRefund: {
41
+ token: viem_1.zeroAddress,
42
+ exchangeRate: 0n,
43
+ },
30
44
  },
31
45
  };
32
46
  }
@@ -1,8 +1,8 @@
1
- import { type Address, type Chain, type HashTypedDataParameters, type Hex, type PublicClient, type SignableMessage, type SignedAuthorization, type SignedAuthorizationList, type TypedData } from 'viem';
1
+ import { type Address, type Chain, type HashTypedDataParameters, type Hex, type PublicClient, type SignableMessage, type SignedAuthorization, type SignedAuthorizationList, type TypedData, type TypedDataDefinition } from 'viem';
2
2
  import { type UserOperation } from 'viem/account-abstraction';
3
3
  import { type IntentOp, type IntentRoute } from '../orchestrator';
4
4
  import type { SettlementLayer } from '../orchestrator/types';
5
- import type { Call, CalldataInput, CallInput, RhinestoneAccountConfig, RhinestoneConfig, SignerSet, SourceAssetInput, TokenRequest, TokenSymbol, Transaction, UserOperationTransaction } from '../types';
5
+ import type { Call, CalldataInput, CallInput, RhinestoneAccountConfig, RhinestoneConfig, SignerSet, SourceAssetInput, Sponsorship, TokenRequest, TokenSymbol, Transaction, UserOperationTransaction } from '../types';
6
6
  interface UserOperationResult {
7
7
  type: 'userop';
8
8
  hash: Hex;
@@ -33,6 +33,10 @@ interface SignedUserOperationData extends PreparedUserOperationData {
33
33
  declare function prepareTransaction(config: RhinestoneConfig, transaction: Transaction): Promise<PreparedTransactionData>;
34
34
  declare function prepareUserOperation(config: RhinestoneConfig, transaction: UserOperationTransaction): Promise<PreparedUserOperationData>;
35
35
  declare function resolveCallInputs(inputs: CallInput[] | undefined, config: RhinestoneConfig, chain: Chain, accountAddress: Address): Promise<CalldataInput[]>;
36
+ declare function getTransactionMessages(config: RhinestoneConfig, preparedTransaction: PreparedTransactionData): {
37
+ origin: TypedDataDefinition[];
38
+ destination: TypedDataDefinition;
39
+ };
36
40
  declare function signTransaction(config: RhinestoneConfig, preparedTransaction: PreparedTransactionData): Promise<SignedTransactionData>;
37
41
  declare function signUserOperation(config: RhinestoneConfig, preparedUserOperation: PreparedUserOperationData): Promise<SignedUserOperationData>;
38
42
  declare function signAuthorizations(config: RhinestoneConfig, preparedTransaction: PreparedTransactionData): Promise<SignedAuthorization[]>;
@@ -41,21 +45,39 @@ declare function signTypedData<typedData extends TypedData | Record<string, unkn
41
45
  declare function signAuthorizationsInternal(config: RhinestoneConfig, data: IntentRoute | UserOperation): Promise<SignedAuthorization[]>;
42
46
  declare function submitTransaction(config: RhinestoneConfig, signedTransaction: SignedTransactionData, authorizations: SignedAuthorizationList, dryRun?: boolean): Promise<TransactionResult>;
43
47
  declare function submitUserOperation(config: RhinestoneConfig, signedUserOperation: SignedUserOperationData): Promise<UserOperationResult>;
44
- declare function getTokenRequests(sourceChains: Chain[], targetChain: Chain, initialTokenRequests: TokenRequest[] | undefined, settlementLayers: SettlementLayer[] | undefined): TokenRequest[];
45
- declare function prepareTransactionAsIntent(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain: Chain, callInputs: CalldataInput[], gasLimit: bigint | undefined, tokenRequests: TokenRequest[], recipientInput: RhinestoneAccountConfig | Address | undefined, accountAddress: Address, isSponsored: boolean, eip7702InitSignature: Hex | undefined, settlementLayers: SettlementLayer[] | undefined, sourceAssets: SourceAssetInput | undefined, feeAsset: Address | TokenSymbol | undefined, lockFunds: boolean | undefined, account: {
48
+ declare function getTokenRequests(sourceChains: Chain[] | undefined, targetChain: Chain, initialTokenRequests: TokenRequest[] | undefined, settlementLayers: SettlementLayer[] | undefined): TokenRequest[];
49
+ declare function getIntentAccount(config: RhinestoneConfig, eip7702InitSignature: Hex | undefined, account: {
50
+ setupOps?: {
51
+ to: Address;
52
+ data: Hex;
53
+ }[];
54
+ } | undefined): {
55
+ address: `0x${string}`;
56
+ accountType: "ERC7579" | "EOA";
57
+ setupOps: {
58
+ to: Address;
59
+ data: Hex;
60
+ }[];
61
+ delegations: {
62
+ 0: {
63
+ contract: `0x${string}`;
64
+ };
65
+ } | undefined;
66
+ };
67
+ declare function prepareTransactionAsIntent(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain: Chain, callInputs: CalldataInput[], gasLimit: bigint | undefined, tokenRequests: TokenRequest[], recipientInput: RhinestoneAccountConfig | Address | undefined, sponsored: Sponsorship | undefined, eip7702InitSignature: Hex | undefined, settlementLayers: SettlementLayer[] | undefined, sourceAssets: SourceAssetInput | undefined, feeAsset: Address | TokenSymbol | undefined, lockFunds: boolean | undefined, account: {
46
68
  setupOps?: {
47
69
  to: Address;
48
70
  data: Hex;
49
71
  }[];
50
72
  } | undefined): Promise<IntentRoute>;
51
- declare function signIntent(config: RhinestoneConfig, targetChain: Chain, intentOp: IntentOp, signers?: SignerSet): Promise<{
52
- originSignatures: any[];
73
+ declare function signIntent(config: RhinestoneConfig, intentOp: IntentOp, signers?: SignerSet): Promise<{
74
+ originSignatures: `0x${string}`[];
53
75
  destinationSignature: `0x${string}`;
54
76
  }>;
55
77
  declare function getOrchestratorByChain(chainId: number, apiKey: string | undefined, orchestratorUrl?: string): import("../orchestrator").Orchestrator;
56
78
  declare function submitIntentInternal(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain: Chain, intentOp: IntentOp, originSignatures: Hex[], destinationSignature: Hex, authorizations: SignedAuthorizationList, dryRun: boolean): Promise<TransactionResult>;
57
79
  declare function getValidatorAccount(config: RhinestoneConfig, signers: SignerSet | undefined, publicClient: PublicClient, chain: Chain): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">> | null | undefined>;
58
80
  declare function parseCalls(calls: CalldataInput[], chainId: number): Call[];
59
- export { prepareTransaction, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, };
81
+ export { prepareTransaction, getTransactionMessages, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, getIntentAccount, };
60
82
  export type { IntentRoute, TransactionResult, PreparedTransactionData, PreparedUserOperationData, SignedTransactionData, SignedUserOperationData, UserOperationResult, };
61
83
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAKV,KAAK,uBAAuB,EAC5B,KAAK,GAAG,EAIR,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EAIf,MAAM,MAAM,CAAA;AACb,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;AAkCjC,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,WAAW,EAEjB,MAAM,iBAAiB,CAAA;AAWxB,OAAO,KAAK,EAGV,eAAe,EAGhB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAEV,IAAI,EACJ,aAAa,EACb,SAAS,EACT,uBAAuB,EACvB,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,wBAAwB,EACzB,MAAM,UAAU,CAAA;AAMjB,UAAU,mBAAmB;IAC3B,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,GAAG,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,iBAAiB;IACzB,IAAI,EAAE,QAAQ,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,UAAU,uBAAuB;IAC/B,WAAW,EAAE,WAAW,CAAA;IACxB,WAAW,EA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oBb;AAkDD,iBAAS,UAAU,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,CAMnE;AAqGD,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,CAAA;AACD,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.prepareTransaction = prepareTransaction;
4
+ exports.getTransactionMessages = getTransactionMessages;
4
5
  exports.signTransaction = signTransaction;
5
6
  exports.signAuthorizations = signAuthorizations;
6
7
  exports.signAuthorizationsInternal = signAuthorizationsInternal;
@@ -18,6 +19,7 @@ exports.getValidatorAccount = getValidatorAccount;
18
19
  exports.parseCalls = parseCalls;
19
20
  exports.getTokenRequests = getTokenRequests;
20
21
  exports.resolveCallInputs = resolveCallInputs;
22
+ exports.getIntentAccount = getIntentAccount;
21
23
  const viem_1 = require("viem");
22
24
  const account_abstraction_1 = require("viem/account-abstraction");
23
25
  const erc7739_1 = require("viem/experimental/erc7739");
@@ -36,11 +38,11 @@ const singleChainOps_1 = require("./singleChainOps");
36
38
  async function prepareTransaction(config, transaction) {
37
39
  const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account, recipient, } = getTransactionParams(transaction);
38
40
  const accountAddress = (0, accounts_1.getAddress)(config);
39
- const isUserOpSigner = signers?.type === 'guardians' || signers?.type === 'session';
41
+ const isUserOpSigner = signers?.type === 'guardians';
40
42
  if (isUserOpSigner) {
41
43
  throw new error_1.SignerNotSupportedError();
42
44
  }
43
- const intentRoute = await prepareTransactionAsIntent(config, sourceChains, targetChain, await resolveCallInputs(transaction.calls, config, targetChain, accountAddress), transaction.gasLimit, tokenRequests, recipient, accountAddress, sponsored ?? false, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account);
45
+ const intentRoute = await prepareTransactionAsIntent(config, sourceChains, targetChain, await resolveCallInputs(transaction.calls, config, targetChain, accountAddress), transaction.gasLimit, tokenRequests, recipient, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account);
44
46
  return {
45
47
  intentRoute,
46
48
  transaction,
@@ -78,10 +80,13 @@ async function resolveCallInputs(inputs, config, chain, accountAddress) {
78
80
  }
79
81
  return resolved;
80
82
  }
83
+ function getTransactionMessages(config, preparedTransaction) {
84
+ return getIntentMessages(config, preparedTransaction.intentRoute.intentOp);
85
+ }
81
86
  async function signTransaction(config, preparedTransaction) {
82
- const { targetChain, signers } = getTransactionParams(preparedTransaction.transaction);
87
+ const { signers } = getTransactionParams(preparedTransaction.transaction);
83
88
  const intentRoute = preparedTransaction.intentRoute;
84
- const { originSignatures, destinationSignature } = await signIntent(config, targetChain, intentRoute.intentOp, signers);
89
+ const { originSignatures, destinationSignature } = await signIntent(config, intentRoute.intentOp, signers);
85
90
  return {
86
91
  intentRoute,
87
92
  transaction: preparedTransaction.transaction,
@@ -126,7 +131,7 @@ async function signTypedData(config, parameters, chain, signers) {
126
131
  }
127
132
  const ownerValidator = (0, validators_1.getOwnerValidator)(config);
128
133
  const isRoot = validator.address === ownerValidator.address;
129
- if (signers?.type === 'session') {
134
+ if (signers?.type === 'experimental_session') {
130
135
  return await signTypedDataWithSession(config, chain, {
131
136
  address: validator.address,
132
137
  isRoot,
@@ -264,7 +269,9 @@ function getTokenRequests(sourceChains, targetChain, initialTokenRequests, settl
264
269
  amount: 1n,
265
270
  };
266
271
  const isSameChain = (settlementLayers?.length === 1 && settlementLayers[0] === 'SAME_CHAIN') ||
267
- (sourceChains.length === 1 && sourceChains[0].id === targetChain.id);
272
+ (sourceChains &&
273
+ sourceChains.length === 1 &&
274
+ sourceChains[0].id === targetChain.id);
268
275
  const tokenRequests = !initialTokenRequests || initialTokenRequests.length === 0
269
276
  ? isSameChain
270
277
  ? []
@@ -298,23 +305,28 @@ async function prepareTransactionAsUserOp(config, chain, callInputs, signers, ga
298
305
  }),
299
306
  };
300
307
  }
301
- async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, recipientInput, accountAddress, isSponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account) {
302
- if (config.account?.type === 'eoa') {
303
- if (callInputs.length > 0) {
304
- throw new error_1.CallsNotSupportedError();
305
- }
308
+ function getAccountType(accountConfig) {
309
+ if (accountConfig?.type === 'eoa') {
310
+ return 'EOA';
311
+ }
312
+ else {
313
+ return 'ERC7579';
306
314
  }
315
+ }
316
+ function getIntentAccount(config, eip7702InitSignature, account) {
317
+ const accountAddress = (0, accounts_1.getAddress)(config);
318
+ const accountType = getAccountType(config.account);
319
+ const { setupOps, delegations } = getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature);
320
+ return {
321
+ address: accountAddress,
322
+ accountType: accountType,
323
+ setupOps: account?.setupOps ?? setupOps,
324
+ delegations,
325
+ };
326
+ }
327
+ async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, recipientInput, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account) {
307
328
  const calls = parseCalls(callInputs, targetChain.id);
308
329
  const accountAccessList = createAccountAccessList(sourceChains, sourceAssets);
309
- const { setupOps, delegations } = getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature);
310
- function getAccountType(accountConfig) {
311
- if (accountConfig?.type === 'eoa') {
312
- return 'EOA';
313
- }
314
- else {
315
- return 'ERC7579';
316
- }
317
- }
318
330
  function getRecipient(recipient) {
319
331
  if (typeof recipient === 'string') {
320
332
  // Passed as an address, assume it's an EOA
@@ -325,27 +337,12 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
325
337
  delegations: undefined,
326
338
  };
327
339
  }
328
- const recipientAddress = recipient ? (0, accounts_1.getAddress)(recipient) : undefined;
329
- const recipientAccountType = recipient
330
- ? getAccountType(recipient.account)
331
- : undefined;
332
- const { setupOps: recipientSetupOps, delegations: recipientDelegations } = recipient && recipientAddress
333
- ? getSetupOperationsAndDelegations(recipient, recipientAddress, eip7702InitSignature)
334
- : {
335
- setupOps: [],
336
- delegations: {},
337
- };
338
- if (!recipientAddress || !recipientAccountType) {
340
+ if (!recipient) {
339
341
  return undefined;
340
342
  }
341
- return {
342
- address: recipientAddress,
343
- accountType: recipientAccountType,
344
- setupOps: recipientSetupOps,
345
- delegations: recipientDelegations,
346
- };
343
+ return getIntentAccount(recipient, eip7702InitSignature, account);
347
344
  }
348
- const accountType = getAccountType(config.account);
345
+ const intentAccount = getIntentAccount(config, eip7702InitSignature, account);
349
346
  const recipient = getRecipient(recipientInput);
350
347
  const metaIntent = {
351
348
  destinationChainId: targetChain.id,
@@ -354,27 +351,26 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
354
351
  amount: tokenRequest.amount,
355
352
  })),
356
353
  recipient,
357
- account: {
358
- address: accountAddress,
359
- accountType: accountType,
360
- setupOps: account?.setupOps ?? setupOps,
361
- delegations,
362
- },
363
- destinationExecutions: calls.map((call) => ({
364
- to: call.to,
365
- value: call.value.toString(),
366
- data: call.data,
367
- })),
354
+ account: intentAccount,
355
+ destinationExecutions: calls,
368
356
  destinationGasUnits: gasLimit,
369
357
  accountAccessList,
370
358
  options: {
371
359
  topupCompact: lockFunds ?? false,
372
360
  feeToken: feeAsset,
373
- sponsorSettings: {
374
- gasSponsored: isSponsored,
375
- bridgeFeesSponsored: isSponsored,
376
- swapFeesSponsored: isSponsored,
377
- },
361
+ sponsorSettings: sponsored
362
+ ? typeof sponsored === 'object'
363
+ ? {
364
+ gasSponsored: sponsored.gas,
365
+ bridgeFeesSponsored: sponsored.bridging,
366
+ swapFeesSponsored: sponsored.swaps,
367
+ }
368
+ : {
369
+ gasSponsored: sponsored,
370
+ bridgeFeesSponsored: sponsored,
371
+ swapFeesSponsored: sponsored,
372
+ }
373
+ : undefined,
378
374
  settlementLayers,
379
375
  },
380
376
  };
@@ -382,27 +378,21 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
382
378
  const intentRoute = await orchestrator.getIntentRoute(metaIntent);
383
379
  return intentRoute;
384
380
  }
385
- async function signIntent(config, targetChain, intentOp, signers) {
381
+ async function signIntent(config, intentOp, signers) {
382
+ const { origin } = getIntentMessages(config, intentOp);
386
383
  if (config.account?.type === 'eoa') {
384
+ const eoa = config.eoa;
385
+ if (!eoa) {
386
+ throw new accounts_1.EoaAccountMustHaveAccountError();
387
+ }
387
388
  const originSignatures = [];
388
- for (const element of intentOp.elements) {
389
- let digest;
390
- if (config.eoa?.signTypedData) {
391
- const typedData = (0, permit2_1.getTypedData)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
392
- originSignatures.push(await config.eoa.signTypedData(typedData));
393
- }
394
- else if (config.eoa?.sign) {
395
- digest = (0, compact_1.getPermit2Digest)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
396
- originSignatures.push(await config.eoa.sign({ hash: digest }));
397
- }
398
- else if (config.eoa?.signMessage) {
399
- digest = (0, compact_1.getPermit2Digest)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
400
- originSignatures.push(await config.eoa.signMessage({
401
- message: { raw: digest },
402
- }));
389
+ for (const typedData of origin) {
390
+ if (eoa.signTypedData) {
391
+ const signature = await eoa.signTypedData(typedData);
392
+ originSignatures.push(signature);
403
393
  }
404
394
  else {
405
- throw new accounts_1.EoaSigningMethodNotConfiguredError('signTypedData, sign, or signMessage');
395
+ throw new accounts_1.EoaSigningMethodNotConfiguredError('signTypedData');
406
396
  }
407
397
  }
408
398
  const destinationSignature = originSignatures.at(-1);
@@ -417,36 +407,10 @@ async function signIntent(config, targetChain, intentOp, signers) {
417
407
  }
418
408
  const ownerValidator = (0, validators_1.getOwnerValidator)(config);
419
409
  const isRoot = validator.address === ownerValidator.address;
420
- const signatures = await getIntentSignature(config, intentOp, signers, targetChain, validator, isRoot);
421
- return {
422
- originSignatures: signatures.originSignatures,
423
- destinationSignature: signatures.destinationSignature,
424
- };
425
- }
426
- async function getIntentSignature(config, intentOp, signers, targetChain, validator, isRoot) {
427
- const withPermit2 = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext?.fundingMethod === 'PERMIT2');
428
- const withIntentExecutorOps = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext.settlementLayer ===
429
- 'INTENT_EXECUTOR');
430
- if (withIntentExecutorOps) {
431
- const signature = await getSingleChainOpsSignature(config, intentOp, signers, targetChain, validator, isRoot);
432
- return signature;
433
- }
434
- if (withPermit2) {
435
- return await getPermit2Signatures(config, intentOp, signers, targetChain, validator, isRoot);
436
- }
437
- const signature = await getCompactSignature(config, intentOp, signers, targetChain, validator, isRoot);
438
- return {
439
- originSignatures: Array(intentOp.elements.length).fill(signature),
440
- destinationSignature: signature,
441
- };
442
- }
443
- async function getSingleChainOpsSignature(config, intentOp, signers, targetChain, validator, isRoot) {
444
- const address = (0, accounts_1.getAddress)(config);
445
- const intentExecutor = (0, modules_1.getIntentExecutor)(config);
446
410
  const originSignatures = [];
447
- for (const element of intentOp.elements) {
448
- const typedData = (0, singleChainOps_1.getTypedData)(address, intentExecutor.address, element, BigInt(intentOp.nonce));
449
- const signature = await signIntentTypedData(config, signers, targetChain, validator, isRoot, typedData);
411
+ for (const typedData of origin) {
412
+ const chain = (0, registry_1.getChainById)(typedData.domain?.chainId);
413
+ const signature = await signIntentTypedData(config, signers, validator, isRoot, typedData, chain);
450
414
  originSignatures.push(signature);
451
415
  }
452
416
  const destinationSignature = originSignatures.at(-1);
@@ -455,32 +419,42 @@ async function getSingleChainOpsSignature(config, intentOp, signers, targetChain
455
419
  destinationSignature,
456
420
  };
457
421
  }
458
- async function getPermit2Signatures(config, intentOp, signers, targetChain, validator, isRoot) {
459
- const originSignatures = [];
422
+ function getIntentMessages(config, intentOp) {
423
+ const address = (0, accounts_1.getAddress)(config);
424
+ const intentExecutor = (0, modules_1.getIntentExecutor)(config);
425
+ const withPermit2 = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext.fundingMethod === 'PERMIT2');
426
+ const withIntentExecutorOps = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext.settlementLayer ===
427
+ 'INTENT_EXECUTOR');
428
+ const origin = [];
460
429
  for (const element of intentOp.elements) {
461
- const typedData = (0, permit2_1.getTypedData)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
462
- const signature = await signIntentTypedData(config, signers, targetChain, validator, isRoot, typedData);
463
- originSignatures.push(signature);
430
+ if (withIntentExecutorOps) {
431
+ const typedData = (0, singleChainOps_1.getTypedData)(address, intentExecutor.address, element, BigInt(intentOp.nonce));
432
+ origin.push(typedData);
433
+ }
434
+ else if (withPermit2) {
435
+ const typedData = (0, permit2_1.getTypedData)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
436
+ origin.push(typedData);
437
+ }
438
+ else {
439
+ const typedData = (0, compact_1.getCompactTypedData)(intentOp);
440
+ origin.push(typedData);
441
+ }
464
442
  }
465
- const destinationSignature = originSignatures.at(-1);
443
+ const destination = origin.at(-1);
466
444
  return {
467
- originSignatures,
468
- destinationSignature,
445
+ origin,
446
+ destination,
469
447
  };
470
448
  }
471
- async function getCompactSignature(config, intentOp, signers, targetChain, validator, isRoot) {
472
- const typedData = (0, compact_1.getCompactTypedData)(intentOp);
473
- return await signIntentTypedData(config, signers, targetChain, validator, isRoot, typedData);
474
- }
475
- async function signIntentTypedData(config, signers, targetChain, validator, isRoot, parameters) {
449
+ async function signIntentTypedData(config, signers, validator, isRoot, parameters, chain) {
476
450
  if ((0, core_1.supportsEip712)(validator)) {
477
- return await (0, accounts_1.getTypedDataPackedSignature)(config, signers, targetChain, {
451
+ return await (0, accounts_1.getTypedDataPackedSignature)(config, signers, chain, {
478
452
  address: validator.address,
479
453
  isRoot,
480
454
  }, parameters);
481
455
  }
482
456
  const hash = (0, viem_1.hashTypedData)(parameters);
483
- return await (0, accounts_1.getPackedSignature)(config, signers, targetChain, {
457
+ return await (0, accounts_1.getPackedSignature)(config, signers, chain, {
484
458
  address: validator.address,
485
459
  isRoot,
486
460
  }, hash);
@@ -588,16 +562,13 @@ async function getValidatorAccount(config, signers, publicClient, chain) {
588
562
  if (withOwner) {
589
563
  return (0, accounts_1.getSmartAccount)(config, publicClient, chain);
590
564
  }
591
- const withSession = signers.type === 'session' ? signers : null;
592
565
  const withGuardians = signers.type === 'guardians' ? signers : null;
593
- return withSession
594
- ? await (0, accounts_1.getSmartSessionSmartAccount)(config, publicClient, chain, withSession.session, withSession.enableData || null)
595
- : withGuardians
596
- ? await (0, accounts_1.getGuardianSmartAccount)(config, publicClient, chain, {
597
- type: 'ecdsa',
598
- accounts: withGuardians.guardians,
599
- })
600
- : null;
566
+ return withGuardians
567
+ ? await (0, accounts_1.getGuardianSmartAccount)(config, publicClient, chain, {
568
+ type: 'ecdsa',
569
+ accounts: withGuardians.guardians,
570
+ })
571
+ : null;
601
572
  }
602
573
  function getValidator(config, signers) {
603
574
  if (!signers) {
@@ -624,7 +595,7 @@ function getValidator(config, signers) {
624
595
  }
625
596
  }
626
597
  // Smart sessions
627
- const withSession = signers.type === 'session' ? signers.session : null;
598
+ const withSession = signers.type === 'experimental_session' ? signers.session : null;
628
599
  if (withSession) {
629
600
  return (0, validators_1.getSmartSessionValidator)(config);
630
601
  }
@@ -685,12 +656,17 @@ function getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSig
685
656
  };
686
657
  }
687
658
  else if (initCode) {
659
+ const to = 'factory' in initCode ? initCode.factory : undefined;
660
+ const data = 'factory' in initCode ? initCode.factoryData : undefined;
661
+ if (!to || !data) {
662
+ throw new accounts_1.FactoryArgsNotAvailableError();
663
+ }
688
664
  // Contract account with init code
689
665
  return {
690
666
  setupOps: [
691
667
  {
692
- to: initCode.factory,
693
- data: initCode.factoryData,
668
+ to,
669
+ data,
694
670
  },
695
671
  ],
696
672
  };