@charterlabs/rhinestone-sdk 0.3.0 → 0.3.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 (129) hide show
  1. package/README.md +31 -200
  2. package/dist/src/accounts/error.d.ts +8 -1
  3. package/dist/src/accounts/error.d.ts.map +1 -1
  4. package/dist/src/accounts/error.js +10 -1
  5. package/dist/src/accounts/index.d.ts +11 -10
  6. package/dist/src/accounts/index.d.ts.map +1 -1
  7. package/dist/src/accounts/index.js +79 -50
  8. package/dist/src/accounts/kernel.d.ts +3 -5
  9. package/dist/src/accounts/kernel.d.ts.map +1 -1
  10. package/dist/src/accounts/kernel.js +8 -17
  11. package/dist/src/accounts/kernel.test.js +10 -3
  12. package/dist/src/accounts/nexus.d.ts +3 -5
  13. package/dist/src/accounts/nexus.d.ts.map +1 -1
  14. package/dist/src/accounts/nexus.js +108 -57
  15. package/dist/src/accounts/nexus.test.js +10 -3
  16. package/dist/src/accounts/passport.d.ts +4 -7
  17. package/dist/src/accounts/passport.d.ts.map +1 -1
  18. package/dist/src/accounts/passport.js +0 -91
  19. package/dist/src/accounts/safe.d.ts +9 -4
  20. package/dist/src/accounts/safe.d.ts.map +1 -1
  21. package/dist/src/accounts/safe.js +108 -38
  22. package/dist/src/accounts/safe.test.js +10 -3
  23. package/dist/src/accounts/signing/common.d.ts +3 -3
  24. package/dist/src/accounts/signing/common.d.ts.map +1 -1
  25. package/dist/src/accounts/signing/common.js +29 -5
  26. package/dist/src/accounts/signing/message.js +2 -2
  27. package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
  28. package/dist/src/accounts/signing/typedData.js +3 -3
  29. package/dist/src/accounts/startale.d.ts +2 -4
  30. package/dist/src/accounts/startale.d.ts.map +1 -1
  31. package/dist/src/accounts/startale.js +0 -4
  32. package/dist/src/accounts/utils.d.ts.map +1 -1
  33. package/dist/src/accounts/utils.js +10 -3
  34. package/dist/src/accounts/walletClient.d.ts.map +1 -1
  35. package/dist/src/accounts/walletClient.js +6 -0
  36. package/dist/src/actions/compact.d.ts +4 -2
  37. package/dist/src/actions/compact.d.ts.map +1 -1
  38. package/dist/src/actions/compact.js +4 -1
  39. package/dist/src/actions/deployment.d.ts +19 -0
  40. package/dist/src/actions/deployment.d.ts.map +1 -0
  41. package/dist/src/actions/deployment.js +78 -0
  42. package/dist/src/actions/index.d.ts +3 -1
  43. package/dist/src/actions/index.d.ts.map +1 -1
  44. package/dist/src/actions/index.js +12 -0
  45. package/dist/src/actions/smart-sessions.d.ts +17 -8
  46. package/dist/src/actions/smart-sessions.d.ts.map +1 -1
  47. package/dist/src/actions/smart-sessions.js +40 -4
  48. package/dist/src/errors/index.d.ts +3 -3
  49. package/dist/src/errors/index.d.ts.map +1 -1
  50. package/dist/src/errors/index.js +3 -1
  51. package/dist/src/execution/compact.d.ts +15 -18
  52. package/dist/src/execution/compact.d.ts.map +1 -1
  53. package/dist/src/execution/compact.js +15 -17
  54. package/dist/src/execution/error.d.ts +2 -8
  55. package/dist/src/execution/error.d.ts.map +1 -1
  56. package/dist/src/execution/error.js +1 -10
  57. package/dist/src/execution/index.d.ts +6 -6
  58. package/dist/src/execution/index.d.ts.map +1 -1
  59. package/dist/src/execution/index.js +22 -28
  60. package/dist/src/execution/permit2.d.ts +12 -17
  61. package/dist/src/execution/permit2.d.ts.map +1 -1
  62. package/dist/src/execution/permit2.js +10 -16
  63. package/dist/src/execution/singleChainOps.d.ts +15 -3
  64. package/dist/src/execution/singleChainOps.d.ts.map +1 -1
  65. package/dist/src/execution/singleChainOps.js +17 -3
  66. package/dist/src/execution/utils.d.ts +36 -12
  67. package/dist/src/execution/utils.d.ts.map +1 -1
  68. package/dist/src/execution/utils.js +180 -133
  69. package/dist/src/index.d.ts +26 -8
  70. package/dist/src/index.d.ts.map +1 -1
  71. package/dist/src/index.js +49 -16
  72. package/dist/src/modules/abi/smart-session-emissary.d.ts +696 -0
  73. package/dist/src/modules/abi/smart-session-emissary.d.ts.map +1 -0
  74. package/dist/src/modules/abi/smart-session-emissary.js +565 -0
  75. package/dist/src/modules/chain-abstraction.d.ts +5 -0
  76. package/dist/src/modules/chain-abstraction.d.ts.map +1 -0
  77. package/dist/src/modules/chain-abstraction.js +7 -0
  78. package/dist/src/modules/common.d.ts +7 -1
  79. package/dist/src/modules/common.d.ts.map +1 -1
  80. package/dist/src/modules/index.d.ts +3 -9
  81. package/dist/src/modules/index.d.ts.map +1 -1
  82. package/dist/src/modules/index.js +11 -8
  83. package/dist/src/modules/index.test.js +3 -9
  84. package/dist/src/modules/legacy.d.ts +10 -0
  85. package/dist/src/modules/legacy.d.ts.map +1 -0
  86. package/dist/src/modules/legacy.js +65 -0
  87. package/dist/src/modules/validators/core.d.ts +2 -1
  88. package/dist/src/modules/validators/core.d.ts.map +1 -1
  89. package/dist/src/modules/validators/core.js +4 -1
  90. package/dist/src/modules/validators/index.d.ts +2 -2
  91. package/dist/src/modules/validators/index.d.ts.map +1 -1
  92. package/dist/src/modules/validators/index.js +1 -6
  93. package/dist/src/modules/validators/smart-sessions.d.ts +112 -23
  94. package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
  95. package/dist/src/modules/validators/smart-sessions.js +426 -301
  96. package/dist/src/orchestrator/client.d.ts +3 -4
  97. package/dist/src/orchestrator/client.d.ts.map +1 -1
  98. package/dist/src/orchestrator/client.js +49 -53
  99. package/dist/src/orchestrator/error.d.ts +11 -1
  100. package/dist/src/orchestrator/error.d.ts.map +1 -1
  101. package/dist/src/orchestrator/error.js +16 -1
  102. package/dist/src/orchestrator/index.d.ts +5 -5
  103. package/dist/src/orchestrator/index.d.ts.map +1 -1
  104. package/dist/src/orchestrator/index.js +3 -1
  105. package/dist/src/orchestrator/registry.d.ts +3 -2
  106. package/dist/src/orchestrator/registry.d.ts.map +1 -1
  107. package/dist/src/orchestrator/registry.js +15 -14
  108. package/dist/src/orchestrator/registry.test.js +18 -1
  109. package/dist/src/orchestrator/types.d.ts +33 -8
  110. package/dist/src/orchestrator/types.d.ts.map +1 -1
  111. package/dist/src/orchestrator/types.js +15 -1
  112. package/dist/src/types.d.ts +57 -28
  113. package/dist/src/types.d.ts.map +1 -1
  114. package/dist/src/utils/index.d.ts +14 -2
  115. package/dist/src/utils/index.d.ts.map +1 -1
  116. package/dist/src/utils/index.js +46 -4
  117. package/dist/test/utils/utils.d.ts +5 -0
  118. package/dist/test/utils/utils.d.ts.map +1 -0
  119. package/dist/test/utils/utils.js +20 -0
  120. package/package.json +33 -3
  121. package/dist/src/execution/smart-session.d.ts +0 -13
  122. package/dist/src/execution/smart-session.d.ts.map +0 -1
  123. package/dist/src/execution/smart-session.js +0 -178
  124. package/dist/src/modules/omni-account.d.ts +0 -8
  125. package/dist/src/modules/omni-account.d.ts.map +0 -1
  126. package/dist/src/modules/omni-account.js +0 -13
  127. package/dist/src/modules/validators/smart-sessions.test.d.ts +0 -2
  128. package/dist/src/modules/validators/smart-sessions.test.d.ts.map +0 -1
  129. package/dist/src/modules/validators/smart-sessions.test.js +0 -222
package/dist/src/index.js CHANGED
@@ -1,24 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOrchestrator = exports.WEBAUTHN_VALIDATOR_ABI = exports.getCredentials = exports.getThreshold = exports.getCredentialInfo = exports.setThreshold = exports.removeCredential = exports.addCredential = exports.hasCredential = exports.hasCredentialById = exports.getCredentialIds = exports.generateCredentialId = exports.signPermit2Sequential = exports.signPermit2Batch = exports.getPermit2Address = exports.checkERC20AllowanceDirect = exports.deployStandaloneWithEoa = exports.getAllSupportedChainsAndTokens = exports.getTokenAddress = exports.getSupportedTokens = exports.wrapParaAccount = exports.walletClientToAccount = exports.RhinestoneSDK = void 0;
3
+ exports.getOrchestrator = exports.WEBAUTHN_VALIDATOR_ABI = exports.getCredentials = exports.getThreshold = exports.getCredentialInfo = exports.setThreshold = exports.removeCredential = exports.addCredential = exports.hasCredential = exports.hasCredentialById = exports.getCredentialIds = exports.generateCredentialId = exports.signPermit2Sequential = exports.signPermit2Batch = exports.getPermit2Address = exports.checkERC20AllowanceDirect = exports.deployStandaloneWithEoa = exports.getAllSupportedChainsAndTokens = exports.getTokenDecimals = exports.getTokenAddress = exports.getSupportedTokens = exports.wrapParaAccount = exports.walletClientToAccount = exports.deployAccountsForOwners = exports.RhinestoneSDK = void 0;
4
+ exports.createRhinestoneAccount = createRhinestoneAccount;
4
5
  const accounts_1 = require("./accounts");
5
6
  Object.defineProperty(exports, "deployStandaloneWithEoa", { enumerable: true, get: function () { return accounts_1.deployStandaloneWithEoa; } });
6
7
  const walletClient_1 = require("./accounts/walletClient");
7
8
  Object.defineProperty(exports, "walletClientToAccount", { enumerable: true, get: function () { return walletClient_1.walletClientToAccount; } });
8
9
  Object.defineProperty(exports, "wrapParaAccount", { enumerable: true, get: function () { return walletClient_1.wrapParaAccount; } });
10
+ const deployment_1 = require("./actions/deployment");
11
+ Object.defineProperty(exports, "deployAccountsForOwners", { enumerable: true, get: function () { return deployment_1.deployAccountsForOwners; } });
9
12
  const execution_1 = require("./execution");
10
13
  const permit2_1 = require("./execution/permit2");
11
14
  Object.defineProperty(exports, "checkERC20AllowanceDirect", { enumerable: true, get: function () { return permit2_1.checkERC20AllowanceDirect; } });
12
15
  Object.defineProperty(exports, "getPermit2Address", { enumerable: true, get: function () { return permit2_1.getPermit2Address; } });
13
16
  Object.defineProperty(exports, "signPermit2Batch", { enumerable: true, get: function () { return permit2_1.signPermit2Batch; } });
14
17
  Object.defineProperty(exports, "signPermit2Sequential", { enumerable: true, get: function () { return permit2_1.signPermit2Sequential; } });
15
- const smart_session_1 = require("./execution/smart-session");
16
18
  const utils_1 = require("./execution/utils");
17
19
  const modules_1 = require("./modules");
20
+ const smart_sessions_1 = require("./modules/validators/smart-sessions");
18
21
  const orchestrator_1 = require("./orchestrator");
19
22
  Object.defineProperty(exports, "getAllSupportedChainsAndTokens", { enumerable: true, get: function () { return orchestrator_1.getAllSupportedChainsAndTokens; } });
20
23
  Object.defineProperty(exports, "getSupportedTokens", { enumerable: true, get: function () { return orchestrator_1.getSupportedTokens; } });
21
24
  Object.defineProperty(exports, "getTokenAddress", { enumerable: true, get: function () { return orchestrator_1.getTokenAddress; } });
25
+ Object.defineProperty(exports, "getTokenDecimals", { enumerable: true, get: function () { return orchestrator_1.getTokenDecimals; } });
22
26
  /**
23
27
  * Initialize a Rhinestone account
24
28
  * Note: accounts are deployed onchain only when the first transaction is sent.
@@ -57,6 +61,23 @@ async function createRhinestoneAccount(config) {
57
61
  function setup(chain) {
58
62
  return (0, accounts_1.setup)(config, chain);
59
63
  }
64
+ /**
65
+ * Get the account initialization data. Used for deploying the account onchain.
66
+ * @returns factory address and factory data
67
+ */
68
+ function getInitData() {
69
+ const initData = (0, accounts_1.getInitCode)(config);
70
+ if (!initData) {
71
+ throw new accounts_1.FactoryArgsNotAvailableError();
72
+ }
73
+ if (!('factory' in initData)) {
74
+ throw new accounts_1.FactoryArgsNotAvailableError();
75
+ }
76
+ return {
77
+ factory: initData.factory,
78
+ factoryData: initData.factoryData,
79
+ };
80
+ }
60
81
  /**
61
82
  * Prepare and sign the EIP-7702 account initialization data
62
83
  * @returns init data signature
@@ -75,6 +96,14 @@ async function createRhinestoneAccount(config) {
75
96
  function prepareTransaction(transaction) {
76
97
  return (0, utils_1.prepareTransaction)(config, transaction);
77
98
  }
99
+ /**
100
+ * Get the transaction typed data message to sign
101
+ * @param preparedTransaction Prepared transaction data
102
+ * @see {@link prepareTransaction} to prepare the transaction data for signing
103
+ */
104
+ function getTransactionMessages(preparedTransaction) {
105
+ return (0, utils_1.getTransactionMessages)(config, preparedTransaction);
106
+ }
78
107
  /**
79
108
  * Sign a transaction
80
109
  * @param preparedTransaction Prepared transaction data
@@ -185,16 +214,6 @@ async function createRhinestoneAccount(config) {
185
214
  function getPortfolio(onTestnets = false) {
186
215
  return (0, execution_1.getPortfolio)(config, onTestnets);
187
216
  }
188
- /**
189
- * Get the maximum spendable token amount on the target chain
190
- * @param chain Target chain
191
- * @param token Token address (on the target chain)
192
- * @param gasUnits Gas cost estimate for the transaction execution
193
- * @returns Maximum spendable amount in absolute units
194
- */
195
- function getMaxSpendableAmount(chain, token, gasUnits, sponsored = false) {
196
- return (0, execution_1.getMaxSpendableAmount)(config, chain, token, gasUnits, sponsored);
197
- }
198
217
  /**
199
218
  * Get account owners (ECDSA)
200
219
  * @param chain Chain to get the owners on
@@ -214,8 +233,16 @@ async function createRhinestoneAccount(config) {
214
233
  const account = getAddress();
215
234
  return (0, modules_1.getValidators)(accountType, account, chain, config.provider);
216
235
  }
217
- function getSessionDetails(sessions, sessionIndex, initialNonces, signature) {
218
- return (0, smart_session_1.getSessionDetails)(config, sessions, sessionIndex, initialNonces, signature);
236
+ function experimental_getSessionDetails(sessions) {
237
+ const account = getAddress();
238
+ return (0, modules_1.getSessionDetails)(account, sessions);
239
+ }
240
+ function experimental_isSessionEnabled(session) {
241
+ const account = getAddress();
242
+ return (0, smart_sessions_1.isSessionEnabled)(account, config.provider, session);
243
+ }
244
+ function experimental_signEnableSession(details) {
245
+ return (0, modules_1.signEnableSession)(config, details);
219
246
  }
220
247
  /**
221
248
  * Check ERC20 allowance for the account owner and token (using Permit2 as spender)
@@ -237,6 +264,7 @@ async function createRhinestoneAccount(config) {
237
264
  deployStandaloneWithEoa,
238
265
  signEip7702InitData,
239
266
  prepareTransaction,
267
+ getTransactionMessages,
240
268
  signTransaction,
241
269
  signAuthorizations,
242
270
  signMessage,
@@ -250,11 +278,13 @@ async function createRhinestoneAccount(config) {
250
278
  waitForExecution,
251
279
  getAddress,
252
280
  getPortfolio,
253
- getMaxSpendableAmount,
254
- getSessionDetails,
255
281
  getOwners,
256
282
  getValidators,
283
+ experimental_getSessionDetails,
284
+ experimental_isSessionEnabled,
285
+ experimental_signEnableSession,
257
286
  checkERC20Allowance,
287
+ getInitData,
258
288
  };
259
289
  }
260
290
  class RhinestoneSDK {
@@ -287,6 +317,9 @@ class RhinestoneSDK {
287
317
  getIntentStatus(intentId) {
288
318
  return (0, execution_1.getIntentStatus)(this.apiKey, this.endpointUrl, intentId);
289
319
  }
320
+ splitIntents(input) {
321
+ return (0, execution_1.splitIntents)(this.apiKey, this.endpointUrl, input);
322
+ }
290
323
  }
291
324
  exports.RhinestoneSDK = RhinestoneSDK;
292
325
  // WebAuthn Validator contract helpers (keep Charter API stable)