@charterlabs/rhinestone-sdk 0.1.0 → 0.1.2

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 (194) hide show
  1. package/README.md +74 -181
  2. package/dist/src/accounts/error.d.ts +69 -0
  3. package/dist/src/accounts/error.d.ts.map +1 -0
  4. package/dist/src/accounts/error.js +109 -0
  5. package/dist/{accounts → src/accounts}/index.d.ts +14 -21
  6. package/dist/src/accounts/index.d.ts.map +1 -0
  7. package/dist/src/accounts/index.js +469 -0
  8. package/dist/src/accounts/index.test.d.ts +2 -0
  9. package/dist/src/accounts/index.test.d.ts.map +1 -0
  10. package/dist/src/accounts/index.test.js +36 -0
  11. package/dist/{accounts → src/accounts}/kernel.d.ts +7 -9
  12. package/dist/src/accounts/kernel.d.ts.map +1 -0
  13. package/dist/{accounts → src/accounts}/kernel.js +0 -8
  14. package/dist/src/accounts/kernel.test.d.ts +2 -0
  15. package/dist/src/accounts/kernel.test.d.ts.map +1 -0
  16. package/dist/src/accounts/kernel.test.js +105 -0
  17. package/dist/{accounts → src/accounts}/nexus.d.ts +14 -13
  18. package/dist/src/accounts/nexus.d.ts.map +1 -0
  19. package/dist/{accounts → src/accounts}/nexus.js +92 -88
  20. package/dist/src/accounts/nexus.test.d.ts +2 -0
  21. package/dist/src/accounts/nexus.test.d.ts.map +1 -0
  22. package/dist/src/accounts/nexus.test.js +87 -0
  23. package/dist/{accounts → src/accounts}/safe.d.ts +4 -6
  24. package/dist/src/accounts/safe.d.ts.map +1 -0
  25. package/dist/{accounts → src/accounts}/safe.js +20 -29
  26. package/dist/src/accounts/safe.test.d.ts +2 -0
  27. package/dist/src/accounts/safe.test.d.ts.map +1 -0
  28. package/dist/src/accounts/safe.test.js +87 -0
  29. package/dist/src/accounts/startale.d.ts +20 -0
  30. package/dist/src/accounts/startale.d.ts.map +1 -0
  31. package/dist/src/accounts/startale.js +100 -0
  32. package/dist/src/accounts/startale.test.d.ts +2 -0
  33. package/dist/src/accounts/startale.test.d.ts.map +1 -0
  34. package/dist/src/accounts/startale.test.js +99 -0
  35. package/dist/{accounts → src/accounts}/utils.d.ts +4 -3
  36. package/dist/src/accounts/utils.d.ts.map +1 -0
  37. package/dist/{accounts → src/accounts}/utils.js +44 -0
  38. package/dist/src/accounts/utils.test.d.ts +2 -0
  39. package/dist/src/accounts/utils.test.d.ts.map +1 -0
  40. package/dist/src/accounts/utils.test.js +49 -0
  41. package/dist/src/actions/index.d.ts +39 -0
  42. package/dist/src/actions/index.d.ts.map +1 -0
  43. package/dist/{actions → src/actions}/index.js +108 -15
  44. package/dist/src/actions/index.test.d.ts +2 -0
  45. package/dist/src/actions/index.test.d.ts.map +1 -0
  46. package/dist/src/actions/index.test.js +302 -0
  47. package/dist/{actions → src/actions}/smart-session.d.ts +2 -2
  48. package/dist/src/actions/smart-session.d.ts.map +1 -0
  49. package/dist/src/execution/compact.d.ts +8 -0
  50. package/dist/src/execution/compact.d.ts.map +1 -0
  51. package/dist/src/execution/compact.js +105 -0
  52. package/dist/src/execution/error.d.ts +54 -0
  53. package/dist/src/execution/error.d.ts.map +1 -0
  54. package/dist/src/execution/error.js +78 -0
  55. package/dist/{execution → src/execution}/index.d.ts +7 -6
  56. package/dist/src/execution/index.d.ts.map +1 -0
  57. package/dist/src/execution/index.js +150 -0
  58. package/dist/src/execution/smart-session.d.ts +15 -0
  59. package/dist/src/execution/smart-session.d.ts.map +1 -0
  60. package/dist/{execution → src/execution}/smart-session.js +16 -77
  61. package/dist/src/execution/smart-session.test.d.ts +2 -0
  62. package/dist/src/execution/smart-session.test.d.ts.map +1 -0
  63. package/dist/src/execution/smart-session.test.js +34 -0
  64. package/dist/src/execution/utils.d.ts +45 -0
  65. package/dist/src/execution/utils.d.ts.map +1 -0
  66. package/dist/src/execution/utils.js +433 -0
  67. package/dist/src/index.d.ts +41 -0
  68. package/dist/src/index.d.ts.map +1 -0
  69. package/dist/src/index.js +154 -0
  70. package/dist/src/modules/abi/smart-sessions.d.ts.map +1 -0
  71. package/dist/src/modules/common.d.ts.map +1 -0
  72. package/dist/{modules → src/modules}/index.d.ts +3 -11
  73. package/dist/src/modules/index.d.ts.map +1 -0
  74. package/dist/{modules → src/modules}/index.js +3 -45
  75. package/dist/src/modules/index.test.d.ts +2 -0
  76. package/dist/src/modules/index.test.d.ts.map +1 -0
  77. package/dist/src/modules/index.test.js +107 -0
  78. package/dist/src/modules/omni-account.d.ts +7 -0
  79. package/dist/src/modules/omni-account.d.ts.map +1 -0
  80. package/dist/src/modules/omni-account.js +11 -0
  81. package/dist/src/modules/read.d.ts +9 -0
  82. package/dist/src/modules/read.d.ts.map +1 -0
  83. package/dist/{modules → src/modules}/read.js +6 -37
  84. package/dist/{modules → src/modules}/validators/core.d.ts +6 -7
  85. package/dist/src/modules/validators/core.d.ts.map +1 -0
  86. package/dist/{modules → src/modules}/validators/core.js +83 -8
  87. package/dist/src/modules/validators/core.test.d.ts +2 -0
  88. package/dist/src/modules/validators/core.test.d.ts.map +1 -0
  89. package/dist/src/modules/validators/core.test.js +108 -0
  90. package/dist/src/modules/validators/index.d.ts +4 -0
  91. package/dist/src/modules/validators/index.d.ts.map +1 -0
  92. package/dist/{modules → src/modules}/validators/index.js +1 -3
  93. package/dist/{modules → src/modules}/validators/smart-sessions.d.ts +4 -15
  94. package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -0
  95. package/dist/{modules → src/modules}/validators/smart-sessions.js +7 -61
  96. package/dist/src/modules/validators/smart-sessions.test.d.ts +2 -0
  97. package/dist/src/modules/validators/smart-sessions.test.d.ts.map +1 -0
  98. package/dist/src/modules/validators/smart-sessions.test.js +226 -0
  99. package/dist/src/orchestrator/client.d.ts +21 -0
  100. package/dist/src/orchestrator/client.d.ts.map +1 -0
  101. package/dist/src/orchestrator/client.js +284 -0
  102. package/dist/src/orchestrator/consts.d.ts +5 -0
  103. package/dist/src/orchestrator/consts.d.ts.map +1 -0
  104. package/dist/src/orchestrator/consts.js +9 -0
  105. package/dist/src/orchestrator/error.d.ts +96 -0
  106. package/dist/src/orchestrator/error.d.ts.map +1 -0
  107. package/dist/src/orchestrator/error.js +132 -0
  108. package/dist/src/orchestrator/index.d.ts +11 -0
  109. package/dist/src/orchestrator/index.d.ts.map +1 -0
  110. package/dist/src/orchestrator/index.js +42 -0
  111. package/dist/src/orchestrator/registry.d.ts +39 -0
  112. package/dist/src/orchestrator/registry.d.ts.map +1 -0
  113. package/dist/src/orchestrator/registry.js +121 -0
  114. package/dist/src/orchestrator/registry.json +365 -0
  115. package/dist/src/orchestrator/registry.test.d.ts +2 -0
  116. package/dist/src/orchestrator/registry.test.d.ts.map +1 -0
  117. package/dist/src/orchestrator/registry.test.js +137 -0
  118. package/dist/src/orchestrator/types.d.ts +275 -0
  119. package/dist/src/orchestrator/types.d.ts.map +1 -0
  120. package/dist/src/orchestrator/types.js +19 -0
  121. package/dist/src/orchestrator/utils.d.ts +5 -0
  122. package/dist/src/orchestrator/utils.d.ts.map +1 -0
  123. package/dist/src/orchestrator/utils.js +126 -0
  124. package/dist/{types.d.ts → src/types.d.ts} +42 -21
  125. package/dist/src/types.d.ts.map +1 -0
  126. package/dist/test/consts.d.ts +10 -0
  127. package/dist/test/consts.d.ts.map +1 -0
  128. package/dist/test/consts.js +22 -0
  129. package/package.json +11 -20
  130. package/dist/accounts/index.d.ts.map +0 -1
  131. package/dist/accounts/index.js +0 -419
  132. package/dist/accounts/kernel.d.ts.map +0 -1
  133. package/dist/accounts/nexus.d.ts.map +0 -1
  134. package/dist/accounts/safe.d.ts.map +0 -1
  135. package/dist/accounts/utils.d.ts.map +0 -1
  136. package/dist/actions/index.d.ts +0 -29
  137. package/dist/actions/index.d.ts.map +0 -1
  138. package/dist/actions/registry.d.ts +0 -7
  139. package/dist/actions/registry.d.ts.map +0 -1
  140. package/dist/actions/registry.js +0 -7
  141. package/dist/actions/smart-session.d.ts.map +0 -1
  142. package/dist/execution/index.d.ts.map +0 -1
  143. package/dist/execution/index.js +0 -149
  144. package/dist/execution/smart-session.d.ts +0 -23
  145. package/dist/execution/smart-session.d.ts.map +0 -1
  146. package/dist/execution/utils.d.ts +0 -68
  147. package/dist/execution/utils.d.ts.map +0 -1
  148. package/dist/execution/utils.js +0 -482
  149. package/dist/index.d.ts +0 -38
  150. package/dist/index.d.ts.map +0 -1
  151. package/dist/index.js +0 -119
  152. package/dist/modules/abi/smart-sessions.d.ts.map +0 -1
  153. package/dist/modules/common.d.ts.map +0 -1
  154. package/dist/modules/index.d.ts.map +0 -1
  155. package/dist/modules/omni-account.d.ts +0 -9
  156. package/dist/modules/omni-account.d.ts.map +0 -1
  157. package/dist/modules/omni-account.js +0 -15
  158. package/dist/modules/read.d.ts +0 -10
  159. package/dist/modules/read.d.ts.map +0 -1
  160. package/dist/modules/registry.d.ts +0 -9
  161. package/dist/modules/registry.d.ts.map +0 -1
  162. package/dist/modules/registry.js +0 -60
  163. package/dist/modules/validators/core.d.ts.map +0 -1
  164. package/dist/modules/validators/index.d.ts +0 -4
  165. package/dist/modules/validators/index.d.ts.map +0 -1
  166. package/dist/modules/validators/smart-sessions.d.ts.map +0 -1
  167. package/dist/orchestrator/client.d.ts +0 -29
  168. package/dist/orchestrator/client.d.ts.map +0 -1
  169. package/dist/orchestrator/client.js +0 -250
  170. package/dist/orchestrator/consts.d.ts +0 -5
  171. package/dist/orchestrator/consts.d.ts.map +0 -1
  172. package/dist/orchestrator/consts.js +0 -9
  173. package/dist/orchestrator/error.d.ts +0 -18
  174. package/dist/orchestrator/error.d.ts.map +0 -1
  175. package/dist/orchestrator/error.js +0 -33
  176. package/dist/orchestrator/index.d.ts +0 -11
  177. package/dist/orchestrator/index.d.ts.map +0 -1
  178. package/dist/orchestrator/index.js +0 -40
  179. package/dist/orchestrator/registry.d.ts +0 -20
  180. package/dist/orchestrator/registry.d.ts.map +0 -1
  181. package/dist/orchestrator/registry.js +0 -444
  182. package/dist/orchestrator/types.d.ts +0 -242
  183. package/dist/orchestrator/types.d.ts.map +0 -1
  184. package/dist/orchestrator/types.js +0 -19
  185. package/dist/orchestrator/utils.d.ts +0 -29
  186. package/dist/orchestrator/utils.d.ts.map +0 -1
  187. package/dist/orchestrator/utils.js +0 -319
  188. package/dist/types.d.ts.map +0 -1
  189. /package/dist/{actions → src/actions}/smart-session.js +0 -0
  190. /package/dist/{modules → src/modules}/abi/smart-sessions.d.ts +0 -0
  191. /package/dist/{modules → src/modules}/abi/smart-sessions.js +0 -0
  192. /package/dist/{modules → src/modules}/common.d.ts +0 -0
  193. /package/dist/{modules → src/modules}/common.js +0 -0
  194. /package/dist/{types.js → src/types.js} +0 -0
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BUNDLE_STATUS_UNKNOWN = exports.BUNDLE_STATUS_PRECONFIRMED = exports.BUNDLE_STATUS_FILLED = exports.BUNDLE_STATUS_COMPLETED = exports.BUNDLE_STATUS_PARTIALLY_COMPLETED = exports.BUNDLE_STATUS_EXPIRED = exports.BUNDLE_STATUS_FAILED = exports.BUNDLE_STATUS_PENDING = void 0;
4
- const BUNDLE_STATUS_PENDING = 'PENDING';
5
- exports.BUNDLE_STATUS_PENDING = BUNDLE_STATUS_PENDING;
6
- const BUNDLE_STATUS_FAILED = 'FAILED';
7
- exports.BUNDLE_STATUS_FAILED = BUNDLE_STATUS_FAILED;
8
- const BUNDLE_STATUS_EXPIRED = 'EXPIRED';
9
- exports.BUNDLE_STATUS_EXPIRED = BUNDLE_STATUS_EXPIRED;
10
- const BUNDLE_STATUS_PARTIALLY_COMPLETED = 'PARTIALLY_COMPLETED';
11
- exports.BUNDLE_STATUS_PARTIALLY_COMPLETED = BUNDLE_STATUS_PARTIALLY_COMPLETED;
12
- const BUNDLE_STATUS_COMPLETED = 'COMPLETED';
13
- exports.BUNDLE_STATUS_COMPLETED = BUNDLE_STATUS_COMPLETED;
14
- const BUNDLE_STATUS_FILLED = 'FILLED';
15
- exports.BUNDLE_STATUS_FILLED = BUNDLE_STATUS_FILLED;
16
- const BUNDLE_STATUS_PRECONFIRMED = 'PRECONFIRMED';
17
- exports.BUNDLE_STATUS_PRECONFIRMED = BUNDLE_STATUS_PRECONFIRMED;
18
- const BUNDLE_STATUS_UNKNOWN = 'UNKNOWN';
19
- exports.BUNDLE_STATUS_UNKNOWN = BUNDLE_STATUS_UNKNOWN;
@@ -1,29 +0,0 @@
1
- import { type Hex } from 'viem';
2
- import type { UserOperation } from 'viem/account-abstraction';
3
- import { type BundleEvent, type Execution, type InsufficientBalanceResult, type MultiChainCompact, type OrderCost, type OrderCostResult, type UserChainBalances } from './types';
4
- declare enum BundleStatusEnum {
5
- PENDING = "PENDING",
6
- EXPIRED = "EXPIRED",
7
- PARTIALLY_COMPLETED = "PARTIALLY_COMPLETED",
8
- PRECONFIRMED = "PRECONFIRMED",
9
- COMPLETED = "COMPLETED",
10
- FILLED = "FILLED",
11
- FAILED = "FAILED",
12
- UNKNOWN = "UNKNOWN"
13
- }
14
- declare function getEmptyUserOp(): UserOperation<'0.7'>;
15
- declare function getOrderBundleHash(orderBundle: MultiChainCompact): Hex;
16
- declare function convertBigIntFields(obj: any): any;
17
- declare function parseCompactResponse(response: any): MultiChainCompact;
18
- declare function parseUseChainBalances(response: any): UserChainBalances;
19
- declare function parseOrderCost(response: any): OrderCost;
20
- declare function parseInsufficientBalanceResult(response: any): InsufficientBalanceResult;
21
- declare function parseOrderCostResult(response: any): OrderCostResult;
22
- declare function parsePendingBundleEvent(response: any): BundleEvent;
23
- declare function hashMultichainCompactWithoutDomainSeparator(multiChainCompact: MultiChainCompact): Hex;
24
- declare function applyInjectedExecutions(orderPath: {
25
- orderBundle: MultiChainCompact;
26
- injectedExecutions: Execution[];
27
- }): MultiChainCompact;
28
- export { BundleStatusEnum, getEmptyUserOp, getOrderBundleHash, convertBigIntFields, parseCompactResponse, parsePendingBundleEvent, hashMultichainCompactWithoutDomainSeparator, parseUseChainBalances, parseOrderCost, parseInsufficientBalanceResult, parseOrderCostResult, applyInjectedExec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GACnC,GAAG,CAmBL;AAyGD,iBAAS,uBAAuB,CAAC,SAAS,EAAE;IAC1C,WAAW,EAAE,iBAAiB,CAAA;IAC9B,kBAAkB,EAAE,SAAS,EAAE,CAAA;CAChC,GAAG,iBAAiB,CAQpB;AAED,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,2CAA2C,EAC3C,qBAAqB,EACrB,cAAc,EACd,8BAA8B,EAC9B,oBAAoB,EACpB,uBAAuB,GACxB,CAAA"}
@@ -1,319 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BundleStatusEnum = void 0;
4
- exports.getEmptyUserOp = getEmptyUserOp;
5
- exports.getOrderBundleHash = getOrderBundleHash;
6
- exports.convertBigIntFields = convertBigIntFields;
7
- exports.parseCompactResponse = parseCompactResponse;
8
- exports.parsePendingBundleEvent = parsePendingBundleEvent;
9
- exports.hashMultichainCompactWithoutDomainSeparator = hashMultichainCompactWithoutDomainSeparator;
10
- exports.parseUseChainBalances = parseUseChainBalances;
11
- exports.parseOrderCost = parseOrderCost;
12
- exports.parseInsufficientBalanceResult = parseInsufficientBalanceResult;
13
- exports.parseOrderCostResult = parseOrderCostResult;
14
- exports.applyInjectedExecutions = applyInjectedExecutions;
15
- const viem_1 = require("viem");
16
- const modules_1 = require("../modules");
17
- const types_1 = require("./types");
18
- const MULTICHAIN_COMPACT_TYPEHASH = '0xee54591377b86e048be6b2fbd8913598a6270aed3415776321279495bf4efae5';
19
- const SEGMENT_TYPEHASH = '0x54ada5b33a7390e2883c985295cfa2dcd9bb46515ad10cbdfc22a7c73f9807db';
20
- const WITNESS_TYPEHASH = '0x78e29a727cef567e7d6dddf5bf7eedf0c84af60d4a57512c586c787aae731629';
21
- const EXECUTION_TYPEHASH = '0xa222cbaaad3b88446c3ca031429dafb24afdbda10c5dbd9882c294762857141a';
22
- var BundleStatusEnum;
23
- (function (BundleStatusEnum) {
24
- BundleStatusEnum["PENDING"] = "PENDING";
25
- BundleStatusEnum["EXPIRED"] = "EXPIRED";
26
- BundleStatusEnum["PARTIALLY_COMPLETED"] = "PARTIALLY_COMPLETED";
27
- BundleStatusEnum["PRECONFIRMED"] = "PRECONFIRMED";
28
- BundleStatusEnum["COMPLETED"] = "COMPLETED";
29
- BundleStatusEnum["FILLED"] = "FILLED";
30
- BundleStatusEnum["FAILED"] = "FAILED";
31
- BundleStatusEnum["UNKNOWN"] = "UNKNOWN";
32
- })(BundleStatusEnum || (exports.BundleStatusEnum = BundleStatusEnum = {}));
33
- function getEmptyUserOp() {
34
- return {
35
- sender: viem_1.zeroAddress,
36
- nonce: 0n,
37
- callData: '0x',
38
- preVerificationGas: 0n,
39
- maxFeePerGas: 0n,
40
- maxPriorityFeePerGas: 0n,
41
- verificationGasLimit: 0n,
42
- callGasLimit: 0n,
43
- signature: '0x',
44
- };
45
- }
46
- function getOrderBundleHash(orderBundle) {
47
- const notarizedChainId = Number(orderBundle.segments[0].chainId);
48
- return hashMultiChainCompactWithDomainSeparator(orderBundle, getCompactDomainSeparator(notarizedChainId, modules_1.HOOK_ADDRESS));
49
- }
50
- function convertBigIntFields(obj) {
51
- if (obj === null || obj === undefined) {
52
- return obj;
53
- }
54
- if (typeof obj === 'bigint') {
55
- return obj.toString();
56
- }
57
- if (Array.isArray(obj)) {
58
- return obj.map(convertBigIntFields);
59
- }
60
- if (typeof obj === 'object') {
61
- const result = {};
62
- for (const key in obj) {
63
- if (Object.hasOwn(obj, key)) {
64
- result[key] = convertBigIntFields(obj[key]);
65
- }
66
- }
67
- return result;
68
- }
69
- return obj;
70
- }
71
- function parseCompactResponse(response) {
72
- return {
73
- sponsor: response.sponsor,
74
- nonce: BigInt(response.nonce),
75
- expires: BigInt(response.expires),
76
- segments: response.segments.map((segment) => {
77
- return {
78
- arbiter: segment.arbiter,
79
- chainId: BigInt(segment.chainId),
80
- idsAndAmounts: segment.idsAndAmounts.map((idsAndAmount) => {
81
- return [BigInt(idsAndAmount[0]), BigInt(idsAndAmount[1])];
82
- }),
83
- witness: {
84
- recipient: segment.witness.recipient,
85
- tokenOut: segment.witness.tokenOut.map((tokenOut) => {
86
- return [BigInt(tokenOut[0]), BigInt(tokenOut[1])];
87
- }),
88
- depositId: BigInt(segment.witness.depositId),
89
- targetChain: BigInt(segment.witness.targetChain),
90
- fillDeadline: segment.witness.fillDeadline,
91
- execs: segment.witness.execs.map((exec) => {
92
- return {
93
- to: exec.to,
94
- value: BigInt(exec.value),
95
- data: exec.data,
96
- };
97
- }),
98
- userOpHash: segment.witness.userOpHash,
99
- maxFeeBps: segment.witness.maxFeeBps,
100
- },
101
- };
102
- }),
103
- tokenPrices: response.tokenPrices,
104
- gasPrices: response.gasPrices,
105
- opGasParams: response.opGasParams,
106
- };
107
- }
108
- function parseUseChainBalances(response) {
109
- const result = {};
110
- for (const chainIdStr in response) {
111
- const chainId = Number(chainIdStr);
112
- const chainData = response[chainIdStr];
113
- result[chainId] = {};
114
- for (const tokenAddress in chainData) {
115
- const balanceStr = chainData[tokenAddress]?.balance;
116
- result[chainId][tokenAddress] = BigInt(balanceStr);
117
- }
118
- }
119
- return result;
120
- }
121
- function parseOrderCost(response) {
122
- const tokensSpent = {};
123
- for (const chainIdStr in response.tokensSpent) {
124
- const chainId = Number(chainIdStr);
125
- tokensSpent[chainId] = {};
126
- const chainTokens = response.tokensSpent[chainIdStr];
127
- for (const tokenAddress in chainTokens) {
128
- const balanceStr = chainTokens[tokenAddress];
129
- if (typeof balanceStr !== 'string') {
130
- throw new Error(`Expected string balance for token ${tokenAddress} on chain ${chainId}`);
131
- }
132
- tokensSpent[chainId][tokenAddress] = BigInt(balanceStr);
133
- }
134
- }
135
- const tokensReceived = response.tokensReceived.map((entry) => {
136
- return {
137
- tokenAddress: entry.tokenAddress,
138
- hasFulfilled: entry.hasFulfilled,
139
- amountSpent: BigInt(entry.amountSpent),
140
- targetAmount: BigInt(entry.targetAmount),
141
- fee: BigInt(entry.fee),
142
- };
143
- });
144
- return {
145
- hasFulfilledAll: true,
146
- tokensSpent,
147
- tokensReceived,
148
- };
149
- }
150
- function parseInsufficientBalanceResult(response) {
151
- if (!Array.isArray(response.tokenShortfall)) {
152
- throw new Error('Expected tokenShortfall to be an array');
153
- }
154
- const tokenShortfall = response.tokenShortfall.map((entry) => {
155
- return {
156
- tokenAddress: entry.tokenAddress,
157
- targetAmount: BigInt(entry.targetAmount),
158
- amountSpent: BigInt(entry.amountSpent),
159
- fee: BigInt(entry.fee),
160
- tokenSymbol: entry.tokenSymbol,
161
- tokenDecimals: entry.tokenDecimals,
162
- };
163
- });
164
- const result = {
165
- hasFulfilledAll: false,
166
- tokenShortfall,
167
- totalTokenShortfallInUSD: BigInt(response.totalTokenShortfallInUSD),
168
- };
169
- return result;
170
- }
171
- function parseOrderCostResult(response) {
172
- if (typeof response.hasFulfilledAll !== 'boolean') {
173
- throw new Error('Missing or invalid hasFulfilledAll field');
174
- }
175
- if (response.hasFulfilledAll) {
176
- return parseOrderCost(response);
177
- }
178
- else {
179
- return parseInsufficientBalanceResult(response);
180
- }
181
- }
182
- function parsePendingBundleEvent(response) {
183
- return {
184
- type: response.type,
185
- bundleId: BigInt(response.bundleId),
186
- targetFillPayload: {
187
- to: response.targetFillPayload.to,
188
- data: response.targetFillPayload.data,
189
- value: BigInt(response.targetFillPayload.value),
190
- chainId: response.targetFillPayload.chainId,
191
- },
192
- acrossDepositEvents: response.acrossDepositEvents.map((event) => {
193
- return {
194
- message: event.message,
195
- depositId: BigInt(event.depositId),
196
- depositor: event.depositor,
197
- recipient: event.recipient,
198
- inputToken: event.inputToken,
199
- inputAmount: BigInt(event.inputAmount),
200
- outputToken: event.outputToken,
201
- fillDeadline: event.fillDeadline,
202
- outputAmount: BigInt(event.outputAmount),
203
- quoteTimestamp: event.quoteTimestamp,
204
- exclusiveRelayer: event.exclusiveRelayer,
205
- destinationChainId: event.destinationChainId,
206
- originClaimPayload: {
207
- to: event.originClaimPayload.to,
208
- data: event.originClaimPayload.data,
209
- value: BigInt(event.originClaimPayload.value),
210
- chainId: event.originClaimPayload.chainId,
211
- },
212
- exclusivityDeadline: event.exclusivityDeadline,
213
- };
214
- }),
215
- };
216
- }
217
- function hashMultiChainCompactWithDomainSeparator(multiChainCompact, domainSeparator) {
218
- return (0, viem_1.keccak256)((0, viem_1.encodePacked)(['string', 'bytes32', 'bytes32'], [
219
- '\x19\x01',
220
- domainSeparator,
221
- hashMultichainCompactWithoutDomainSeparator(multiChainCompact),
222
- ]));
223
- }
224
- function hashMultichainCompactWithoutDomainSeparator(multiChainCompact) {
225
- return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
226
- { name: 'typehash', type: 'bytes32' },
227
- { name: 'sponsor', type: 'address' },
228
- { name: 'nonce', type: 'uint256' },
229
- { name: 'expires', type: 'uint256' },
230
- { name: 'segments', type: 'bytes32' },
231
- ], [
232
- MULTICHAIN_COMPACT_TYPEHASH,
233
- multiChainCompact.sponsor,
234
- multiChainCompact.nonce,
235
- multiChainCompact.expires,
236
- hashSegments([...multiChainCompact.segments]),
237
- ]));
238
- }
239
- function hashSegments(segment) {
240
- return (0, viem_1.keccak256)((0, viem_1.encodePacked)(['bytes32[]'], [segment.map(hashSegment)]));
241
- }
242
- function hashSegment(segment) {
243
- return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
244
- { name: 'typehash', type: 'bytes32' },
245
- { name: 'arbiter', type: 'address' },
246
- { name: 'chainId', type: 'uint256' },
247
- { name: 'idsAndAmounts', type: 'bytes32' },
248
- { name: 'witness', type: 'bytes32' },
249
- ], [
250
- SEGMENT_TYPEHASH,
251
- segment.arbiter,
252
- segment.chainId,
253
- hashIdsAndAmounts(segment.idsAndAmounts),
254
- hashWitness(segment.witness),
255
- ]));
256
- }
257
- function hashWitness(witness) {
258
- return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
259
- { name: 'typehash', type: 'bytes32' },
260
- { name: 'recipient', type: 'address' },
261
- { name: 'tokenOut', type: 'bytes32' },
262
- { name: 'depositId', type: 'uint256' },
263
- { name: 'targetChain', type: 'uint256' },
264
- { name: 'fillDeadline', type: 'uint32' },
265
- { name: 'execs', type: 'bytes32' }, // Assuming XchainExec[] is complex
266
- { name: 'userOpHash', type: 'bytes32' },
267
- { name: 'maxFeeBps', type: 'uint32' },
268
- ], [
269
- WITNESS_TYPEHASH,
270
- witness.recipient,
271
- hashIdsAndAmounts(witness.tokenOut),
272
- witness.depositId,
273
- witness.targetChain,
274
- witness.fillDeadline,
275
- hashExecutionArray(witness.execs),
276
- witness.userOpHash,
277
- witness.maxFeeBps,
278
- ]));
279
- }
280
- function getCompactDomainSeparator(chainId, verifyingContract) {
281
- return (0, viem_1.domainSeparator)({
282
- domain: getCompactDomain(chainId, verifyingContract),
283
- });
284
- }
285
- function getCompactDomain(chainId, verifyingContract) {
286
- return {
287
- name: 'The Compact',
288
- version: '0',
289
- chainId: chainId,
290
- verifyingContract: verifyingContract,
291
- };
292
- }
293
- function hashIdsAndAmounts(idsAndAmounts) {
294
- return (0, viem_1.keccak256)((0, viem_1.encodePacked)(['uint256[2][]'], [idsAndAmounts]));
295
- }
296
- function hashExecutionArray(executionArray) {
297
- const hashes = executionArray.map(hashExecution);
298
- return (0, viem_1.keccak256)((0, viem_1.encodePacked)(['bytes32[]'], [hashes]));
299
- }
300
- function hashExecution(execution) {
301
- return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
302
- { name: 'typehash', type: 'bytes32' },
303
- { name: 'target', type: 'address' },
304
- { name: 'value', type: 'uint256' },
305
- { name: 'callData', type: 'bytes32' },
306
- ], [
307
- EXECUTION_TYPEHASH,
308
- execution.to,
309
- execution.value,
310
- (0, viem_1.keccak256)(execution.data),
311
- ]));
312
- }
313
- function applyInjectedExecutions(orderPath) {
314
- if (orderPath.injectedExecutions.length > 0) {
315
- orderPath.orderBundle.segments[0].witness.execs =
316
- orderPath.injectedExecutions.concat(orderPath.orderBundle.segments[0].witness.execs);
317
- }
318
- return orderPath.orderBundle;
319
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAEvE,KAAK,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;AAE9C,UAAU,qBAAqB;IAC7B,IAAI,EAAE,WAAW,CAAA;CAClB;AAED,UAAU,sBAAsB;IAC9B,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,eAAe,CAAA;IACxB,aAAa,EAAE,GAAG,EAAE,CAAA;CACrB;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,SAAS,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,SAAS,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf;AAED,KAAK,QAAQ,GAAG,sBAAsB,GAAG,uBAAuB,CAAA;AAEhE,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,UAAU,qBAAqB;IAC7B,IAAI,EAAE,kBAAkB,CAAA;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,KAAK,EAAE,CAAC,8BAA8B,EAAE,GAAG,8BAA8B,EAAE,CAAC,CAAA;CAC7E;AAED,UAAU,8BAA8B;IACtC,SAAS,EAAE,mCAAmC,CAAA;IAC9C,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,CAAC,EA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KAAK,EAAE,IAAI,EAAE,CAAA;IACb,aAAa,EAAE,YAAY,EAAE,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,SAAS,CAAA;CACpB;AAED,UAAU,oBAAqB,SAAQ,eAAe;IACpD,KAAK,EAAE,KAAK,CAAA;CACb;AAED,UAAU,qBAAsB,SAAQ,eAAe;IACrD,WAAW,CAAC,EAAE,KAAK,CAAA;IACnB,WAAW,EAAE,KAAK,CAAA;CACnB;AAED,KAAK,WAAW,GAAG,oBAAoB,GAAG,qBAAqB,CAAA;AAE/D,YAAY,EACV,WAAW,EACX,uBAAuB,EACvB,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,WAAW,EACX,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,sBAAsB,EACtB,uBAAuB,EACvB,SAAS,EACT,OAAO,EACP,QAAQ,EACR,MAAM,EACN,mCAAmC,GACpC,CAAA"}
File without changes
File without changes
File without changes
File without changes