shogun-core 6.2.3 → 6.3.0

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 (233) hide show
  1. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js +93 -341
  2. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js.map +1 -1
  3. package/dist/browser/shogun-core.js +138850 -146638
  4. package/dist/browser/shogun-core.js.map +1 -1
  5. package/dist/{core.js → src/core.js} +167 -107
  6. package/dist/src/crypto/asymmetric.js +168 -0
  7. package/dist/src/crypto/double-ratchet.js +908 -0
  8. package/dist/src/crypto/file-encryption.js +352 -0
  9. package/dist/src/crypto/hashing.js +160 -0
  10. package/dist/src/crypto/index.js +18 -0
  11. package/dist/{crypto → src/crypto}/mls-codec.js +24 -34
  12. package/dist/src/crypto/mls.js +734 -0
  13. package/dist/src/crypto/pgp.js +619 -0
  14. package/dist/{crypto → src/crypto}/random-generation.js +125 -103
  15. package/dist/src/crypto/sframe.js +466 -0
  16. package/dist/src/crypto/signal-protocol.js +943 -0
  17. package/dist/src/crypto/symmetric.js +165 -0
  18. package/dist/src/crypto/utils.js +220 -0
  19. package/dist/src/examples/auth-test.js +535 -0
  20. package/dist/src/examples/crypto-identity-example.js +294 -0
  21. package/dist/src/examples/crypto-working-test.js +149 -0
  22. package/dist/src/examples/double-ratchet-test.js +240 -0
  23. package/dist/src/examples/mls-3-member-test.js +183 -0
  24. package/dist/src/examples/mls-multi-member.js +439 -0
  25. package/dist/src/examples/mls-sframe-test.js +491 -0
  26. package/dist/src/examples/mls-simple-test.js +122 -0
  27. package/dist/src/examples/pgp-example.js +354 -0
  28. package/dist/src/examples/random-generation-test.js +191 -0
  29. package/dist/src/examples/shogun-core-example.js +204 -0
  30. package/dist/src/examples/signal-protocol-test.js +82 -0
  31. package/dist/src/examples/zkproof-credentials-example.js +357 -0
  32. package/dist/src/examples/zkproof-example.js +357 -0
  33. package/dist/src/gundb/crypto.js +420 -0
  34. package/dist/src/gundb/db.js +728 -0
  35. package/dist/src/gundb/derive.js +327 -0
  36. package/dist/src/gundb/errors.js +115 -0
  37. package/dist/src/gundb/gun-es.js +8 -0
  38. package/dist/src/gundb/index.js +5 -0
  39. package/dist/{gundb → src/gundb}/rxjs.js +147 -111
  40. package/dist/{gundb → src/gundb}/types.js +1 -2
  41. package/dist/src/index.js +19 -0
  42. package/dist/src/interfaces/events.js +57 -0
  43. package/dist/{interfaces → src/interfaces}/shogun.js +4 -7
  44. package/dist/src/managers/AuthManager.js +301 -0
  45. package/dist/src/managers/CoreInitializer.js +304 -0
  46. package/dist/src/managers/CryptoIdentityManager.js +230 -0
  47. package/dist/{managers → src/managers}/EventManager.js +19 -21
  48. package/dist/{managers → src/managers}/PluginManager.js +123 -89
  49. package/dist/src/plugins/base.js +90 -0
  50. package/dist/src/plugins/index.js +17 -0
  51. package/dist/src/plugins/nostr/index.js +4 -0
  52. package/dist/src/plugins/nostr/nostrConnector.js +539 -0
  53. package/dist/src/plugins/nostr/nostrConnectorPlugin.js +663 -0
  54. package/dist/src/plugins/nostr/nostrSigner.js +414 -0
  55. package/dist/src/plugins/smartwallet/index.js +2 -0
  56. package/dist/src/plugins/smartwallet/smartWalletPlugin.js +824 -0
  57. package/dist/src/plugins/web3/index.js +4 -0
  58. package/dist/src/plugins/web3/types.js +1 -0
  59. package/dist/src/plugins/web3/web3Connector.js +738 -0
  60. package/dist/src/plugins/web3/web3ConnectorPlugin.js +639 -0
  61. package/dist/src/plugins/web3/web3Signer.js +432 -0
  62. package/dist/src/plugins/webauthn/index.js +3 -0
  63. package/dist/{plugins → src/plugins}/webauthn/types.js +2 -5
  64. package/dist/src/plugins/webauthn/webauthn.js +647 -0
  65. package/dist/src/plugins/webauthn/webauthnPlugin.js +689 -0
  66. package/dist/src/plugins/webauthn/webauthnSigner.js +419 -0
  67. package/dist/{plugins → src/plugins}/zkproof/index.js +3 -10
  68. package/dist/src/plugins/zkproof/types.js +1 -0
  69. package/dist/src/plugins/zkproof/zkCredentials.js +287 -0
  70. package/dist/src/plugins/zkproof/zkProofConnector.js +267 -0
  71. package/dist/src/plugins/zkproof/zkProofPlugin.js +405 -0
  72. package/dist/src/storage/storage.js +189 -0
  73. package/dist/src/utils/errorHandler.js +339 -0
  74. package/dist/{utils → src/utils}/eventEmitter.js +26 -26
  75. package/dist/{utils → src/utils}/seedPhrase.js +23 -32
  76. package/dist/{utils → src/utils}/validation.js +14 -21
  77. package/dist/tsconfig.tsbuildinfo +1 -0
  78. package/dist/types/{crypto → src/crypto}/double-ratchet.d.ts +1 -1
  79. package/dist/types/{crypto → src/crypto}/signal-protocol.d.ts +25 -0
  80. package/dist/types/{crypto → src/crypto}/types.d.ts +3 -1
  81. package/dist/types/src/examples/crypto-working-test.d.ts +1 -0
  82. package/dist/types/src/examples/double-ratchet-test.d.ts +1 -0
  83. package/dist/types/src/examples/mls-sframe-test.d.ts +1 -0
  84. package/dist/types/src/examples/random-generation-test.d.ts +1 -0
  85. package/dist/types/src/examples/signal-protocol-test.d.ts +1 -0
  86. package/dist/types/{gundb → src/gundb}/db.d.ts +14 -1
  87. package/dist/types/src/gundb/gun-es.d.ts +8 -0
  88. package/dist/types/src/gundb/min.d.ts +3 -0
  89. package/dist/types/{index.d.ts → src/index.d.ts} +1 -0
  90. package/package.json +14 -11
  91. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js +0 -1651
  92. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js.map +0 -1
  93. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js +0 -1608
  94. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js.map +0 -1
  95. package/dist/crypto/asymmetric.js +0 -99
  96. package/dist/crypto/double-ratchet.js +0 -370
  97. package/dist/crypto/file-encryption.js +0 -213
  98. package/dist/crypto/hashing.js +0 -87
  99. package/dist/crypto/index.js +0 -34
  100. package/dist/crypto/mls.js +0 -569
  101. package/dist/crypto/pgp.js +0 -390
  102. package/dist/crypto/sframe.js +0 -352
  103. package/dist/crypto/signal-protocol.js +0 -456
  104. package/dist/crypto/symmetric.js +0 -91
  105. package/dist/crypto/types.js +0 -2
  106. package/dist/crypto/utils.js +0 -140
  107. package/dist/examples/auth-test.js +0 -453
  108. package/dist/examples/crypto-identity-example.js +0 -196
  109. package/dist/examples/crypto-working-test.js +0 -83
  110. package/dist/examples/double-ratchet-test.js +0 -155
  111. package/dist/examples/mls-3-member-test.js +0 -97
  112. package/dist/examples/mls-multi-member.js +0 -153
  113. package/dist/examples/mls-sframe-test.js +0 -307
  114. package/dist/examples/mls-simple-test.js +0 -58
  115. package/dist/examples/pgp-example.js +0 -200
  116. package/dist/examples/random-generation-test.js +0 -151
  117. package/dist/examples/shogun-core-example.js +0 -150
  118. package/dist/examples/signal-protocol-test.js +0 -38
  119. package/dist/examples/zkproof-credentials-example.js +0 -217
  120. package/dist/examples/zkproof-example.js +0 -242
  121. package/dist/gundb/crypto.js +0 -306
  122. package/dist/gundb/db.js +0 -485
  123. package/dist/gundb/derive.js +0 -232
  124. package/dist/gundb/errors.js +0 -76
  125. package/dist/gundb/gun-es.js +0 -12
  126. package/dist/gundb/index.js +0 -21
  127. package/dist/gundb/min.js +0 -10
  128. package/dist/index.esm.js +0 -22
  129. package/dist/index.js +0 -47
  130. package/dist/interfaces/common.js +0 -2
  131. package/dist/interfaces/events.js +0 -40
  132. package/dist/interfaces/plugin.js +0 -2
  133. package/dist/managers/AuthManager.js +0 -226
  134. package/dist/managers/CoreInitializer.js +0 -250
  135. package/dist/managers/CryptoIdentityManager.js +0 -138
  136. package/dist/plugins/base.js +0 -50
  137. package/dist/plugins/index.js +0 -32
  138. package/dist/plugins/nostr/index.js +0 -20
  139. package/dist/plugins/nostr/nostrConnector.js +0 -419
  140. package/dist/plugins/nostr/nostrConnectorPlugin.js +0 -453
  141. package/dist/plugins/nostr/nostrSigner.js +0 -319
  142. package/dist/plugins/nostr/types.js +0 -2
  143. package/dist/plugins/smartwallet/index.js +0 -18
  144. package/dist/plugins/smartwallet/smartWalletPlugin.js +0 -511
  145. package/dist/plugins/smartwallet/types.js +0 -2
  146. package/dist/plugins/web3/index.js +0 -20
  147. package/dist/plugins/web3/types.js +0 -2
  148. package/dist/plugins/web3/web3Connector.js +0 -533
  149. package/dist/plugins/web3/web3ConnectorPlugin.js +0 -455
  150. package/dist/plugins/web3/web3Signer.js +0 -314
  151. package/dist/plugins/webauthn/index.js +0 -19
  152. package/dist/plugins/webauthn/webauthn.js +0 -496
  153. package/dist/plugins/webauthn/webauthnPlugin.js +0 -490
  154. package/dist/plugins/webauthn/webauthnSigner.js +0 -310
  155. package/dist/plugins/zkproof/types.js +0 -2
  156. package/dist/plugins/zkproof/zkCredentials.js +0 -216
  157. package/dist/plugins/zkproof/zkProofConnector.js +0 -198
  158. package/dist/plugins/zkproof/zkProofPlugin.js +0 -272
  159. package/dist/storage/storage.js +0 -145
  160. package/dist/types/gundb/gun-es.d.ts +0 -8
  161. package/dist/utils/errorHandler.js +0 -246
  162. /package/dist/{types/examples/crypto-working-test.d.ts → src/crypto/types.js} +0 -0
  163. /package/dist/{types/gundb/min.d.ts → src/gundb/min.js} +0 -0
  164. /package/dist/{types/examples/double-ratchet-test.d.ts → src/interfaces/common.js} +0 -0
  165. /package/dist/{types/examples/mls-sframe-test.d.ts → src/interfaces/plugin.js} +0 -0
  166. /package/dist/{types/examples/random-generation-test.d.ts → src/plugins/nostr/types.js} +0 -0
  167. /package/dist/{types/examples/signal-protocol-test.d.ts → src/plugins/smartwallet/types.js} +0 -0
  168. /package/dist/types/{core.d.ts → src/core.d.ts} +0 -0
  169. /package/dist/types/{crypto → src/crypto}/asymmetric.d.ts +0 -0
  170. /package/dist/types/{crypto → src/crypto}/file-encryption.d.ts +0 -0
  171. /package/dist/types/{crypto → src/crypto}/hashing.d.ts +0 -0
  172. /package/dist/types/{crypto → src/crypto}/index.d.ts +0 -0
  173. /package/dist/types/{crypto → src/crypto}/mls-codec.d.ts +0 -0
  174. /package/dist/types/{crypto → src/crypto}/mls.d.ts +0 -0
  175. /package/dist/types/{crypto → src/crypto}/pgp.d.ts +0 -0
  176. /package/dist/types/{crypto → src/crypto}/random-generation.d.ts +0 -0
  177. /package/dist/types/{crypto → src/crypto}/sframe.d.ts +0 -0
  178. /package/dist/types/{crypto → src/crypto}/symmetric.d.ts +0 -0
  179. /package/dist/types/{crypto → src/crypto}/utils.d.ts +0 -0
  180. /package/dist/types/{examples → src/examples}/auth-test.d.ts +0 -0
  181. /package/dist/types/{examples → src/examples}/crypto-identity-example.d.ts +0 -0
  182. /package/dist/types/{examples → src/examples}/mls-3-member-test.d.ts +0 -0
  183. /package/dist/types/{examples → src/examples}/mls-multi-member.d.ts +0 -0
  184. /package/dist/types/{examples → src/examples}/mls-simple-test.d.ts +0 -0
  185. /package/dist/types/{examples → src/examples}/pgp-example.d.ts +0 -0
  186. /package/dist/types/{examples → src/examples}/shogun-core-example.d.ts +0 -0
  187. /package/dist/types/{examples → src/examples}/zkproof-credentials-example.d.ts +0 -0
  188. /package/dist/types/{examples → src/examples}/zkproof-example.d.ts +0 -0
  189. /package/dist/types/{gundb → src/gundb}/crypto.d.ts +0 -0
  190. /package/dist/types/{gundb → src/gundb}/derive.d.ts +0 -0
  191. /package/dist/types/{gundb → src/gundb}/errors.d.ts +0 -0
  192. /package/dist/types/{gundb → src/gundb}/index.d.ts +0 -0
  193. /package/dist/types/{gundb → src/gundb}/rxjs.d.ts +0 -0
  194. /package/dist/types/{gundb → src/gundb}/types.d.ts +0 -0
  195. /package/dist/types/{interfaces → src/interfaces}/common.d.ts +0 -0
  196. /package/dist/types/{interfaces → src/interfaces}/events.d.ts +0 -0
  197. /package/dist/types/{interfaces → src/interfaces}/plugin.d.ts +0 -0
  198. /package/dist/types/{interfaces → src/interfaces}/shogun.d.ts +0 -0
  199. /package/dist/types/{managers → src/managers}/AuthManager.d.ts +0 -0
  200. /package/dist/types/{managers → src/managers}/CoreInitializer.d.ts +0 -0
  201. /package/dist/types/{managers → src/managers}/CryptoIdentityManager.d.ts +0 -0
  202. /package/dist/types/{managers → src/managers}/EventManager.d.ts +0 -0
  203. /package/dist/types/{managers → src/managers}/PluginManager.d.ts +0 -0
  204. /package/dist/types/{plugins → src/plugins}/base.d.ts +0 -0
  205. /package/dist/types/{plugins → src/plugins}/index.d.ts +0 -0
  206. /package/dist/types/{plugins → src/plugins}/nostr/index.d.ts +0 -0
  207. /package/dist/types/{plugins → src/plugins}/nostr/nostrConnector.d.ts +0 -0
  208. /package/dist/types/{plugins → src/plugins}/nostr/nostrConnectorPlugin.d.ts +0 -0
  209. /package/dist/types/{plugins → src/plugins}/nostr/nostrSigner.d.ts +0 -0
  210. /package/dist/types/{plugins → src/plugins}/nostr/types.d.ts +0 -0
  211. /package/dist/types/{plugins → src/plugins}/smartwallet/index.d.ts +0 -0
  212. /package/dist/types/{plugins → src/plugins}/smartwallet/smartWalletPlugin.d.ts +0 -0
  213. /package/dist/types/{plugins → src/plugins}/smartwallet/types.d.ts +0 -0
  214. /package/dist/types/{plugins → src/plugins}/web3/index.d.ts +0 -0
  215. /package/dist/types/{plugins → src/plugins}/web3/types.d.ts +0 -0
  216. /package/dist/types/{plugins → src/plugins}/web3/web3Connector.d.ts +0 -0
  217. /package/dist/types/{plugins → src/plugins}/web3/web3ConnectorPlugin.d.ts +0 -0
  218. /package/dist/types/{plugins → src/plugins}/web3/web3Signer.d.ts +0 -0
  219. /package/dist/types/{plugins → src/plugins}/webauthn/index.d.ts +0 -0
  220. /package/dist/types/{plugins → src/plugins}/webauthn/types.d.ts +0 -0
  221. /package/dist/types/{plugins → src/plugins}/webauthn/webauthn.d.ts +0 -0
  222. /package/dist/types/{plugins → src/plugins}/webauthn/webauthnPlugin.d.ts +0 -0
  223. /package/dist/types/{plugins → src/plugins}/webauthn/webauthnSigner.d.ts +0 -0
  224. /package/dist/types/{plugins → src/plugins}/zkproof/index.d.ts +0 -0
  225. /package/dist/types/{plugins → src/plugins}/zkproof/types.d.ts +0 -0
  226. /package/dist/types/{plugins → src/plugins}/zkproof/zkCredentials.d.ts +0 -0
  227. /package/dist/types/{plugins → src/plugins}/zkproof/zkProofConnector.d.ts +0 -0
  228. /package/dist/types/{plugins → src/plugins}/zkproof/zkProofPlugin.d.ts +0 -0
  229. /package/dist/types/{storage → src/storage}/storage.d.ts +0 -0
  230. /package/dist/types/{utils → src/utils}/errorHandler.d.ts +0 -0
  231. /package/dist/types/{utils → src/utils}/eventEmitter.d.ts +0 -0
  232. /package/dist/types/{utils → src/utils}/seedPhrase.d.ts +0 -0
  233. /package/dist/types/{utils → src/utils}/validation.d.ts +0 -0
@@ -0,0 +1,824 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
+ return new (P || (P = Promise))(function (resolve, reject) {
30
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
34
+ });
35
+ };
36
+ var __generator = (this && this.__generator) || function (thisArg, body) {
37
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
38
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
39
+ function verb(n) { return function (v) { return step([n, v]); }; }
40
+ function step(op) {
41
+ if (f) throw new TypeError("Generator is already executing.");
42
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
43
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
44
+ if (y = 0, t) op = [op[0] & 2, t.value];
45
+ switch (op[0]) {
46
+ case 0: case 1: t = op; break;
47
+ case 4: _.label++; return { value: op[1], done: false };
48
+ case 5: _.label++; y = op[1]; op = [0]; continue;
49
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
50
+ default:
51
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
52
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
53
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
54
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
55
+ if (t[2]) _.ops.pop();
56
+ _.trys.pop(); continue;
57
+ }
58
+ op = body.call(thisArg, _);
59
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
60
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
61
+ }
62
+ };
63
+ var __read = (this && this.__read) || function (o, n) {
64
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
65
+ if (!m) return o;
66
+ var i = m.call(o), r, ar = [], e;
67
+ try {
68
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
69
+ }
70
+ catch (error) { e = { error: error }; }
71
+ finally {
72
+ try {
73
+ if (r && !r.done && (m = i["return"])) m.call(i);
74
+ }
75
+ finally { if (e) throw e.error; }
76
+ }
77
+ return ar;
78
+ };
79
+ import { BasePlugin } from "../base.js";
80
+ import { ethers } from "ethers";
81
+ // Smart Wallet ABIs
82
+ var SMART_WALLET_FACTORY_ABI = [
83
+ "function createWallet(address owner, uint256 requiredSignatures, uint256 requiredGuardians) external returns (address wallet)",
84
+ "function createWalletWithGuardians(address owner, address[] memory guardians, uint256 requiredSignatures, uint256 requiredGuardians) external returns (address wallet)",
85
+ "function getOwnerWallets(address owner) external view returns (address[] memory)",
86
+ "event WalletCreated(address indexed wallet, address indexed owner, uint256 indexed walletIndex)",
87
+ ];
88
+ var SMART_WALLET_ABI = [
89
+ // Signer management
90
+ "function addSigner(address signer) external",
91
+ "function removeSigner(address signer) external",
92
+ "function setRequiredSignatures(uint256 requiredSignatures) external",
93
+ "function signers(address) external view returns (bool)",
94
+ "function requiredSignatures() external view returns (uint256)",
95
+ "function owner() external view returns (address)",
96
+ // Guardian management
97
+ "function addGuardian(address guardian) external",
98
+ "function removeGuardian(address guardian) external",
99
+ "function setRequiredGuardians(uint256 requiredGuardians) external",
100
+ "function guardians(address) external view returns (bool)",
101
+ "function requiredGuardians() external view returns (uint256)",
102
+ // Execution
103
+ "function execute(address target, bytes calldata data, uint256 value) external returns (bool success, bytes memory returnData)",
104
+ "function executeBatch(address[] memory targets, bytes[] memory data, uint256[] memory values) external returns (bool[] memory results)",
105
+ // Multi-sig
106
+ "function proposeExecution(address target, bytes calldata data) external returns (uint256 proposalId)",
107
+ "function approveProposal(uint256 proposalId) external",
108
+ "function getProposal(uint256 proposalId) external view returns (address target, bytes memory data, address proposer, uint256 approvals, bool executed)",
109
+ "function hasApprovedProposal(uint256 proposalId, address signer) external view returns (bool)",
110
+ // Recovery
111
+ "function initiateRecovery(address newOwner) external",
112
+ "function approveRecovery() external",
113
+ "function executeRecovery() external",
114
+ "function getRecoveryRequest() external view returns (address newOwner, uint256 unlockTime, uint256 approvals)",
115
+ "function hasApprovedRecovery(address guardian) external view returns (bool)",
116
+ "event SignerAdded(address indexed signer)",
117
+ "event GuardianAdded(address indexed guardian)",
118
+ "event ExecutionExecuted(uint256 indexed proposalId, bool success)",
119
+ "event RecoveryExecuted(address indexed newOwner)",
120
+ ];
121
+ /**
122
+ * Smart Wallet Plugin for Shogun Core
123
+ * Provides integration with Smart Wallet contracts for account abstraction
124
+ */
125
+ var SmartWalletPlugin = /** @class */ (function (_super) {
126
+ __extends(SmartWalletPlugin, _super);
127
+ function SmartWalletPlugin(config) {
128
+ if (config === void 0) { config = {}; }
129
+ var _this = _super.call(this) || this;
130
+ _this.name = "smartwallet";
131
+ _this.version = "1.0.0";
132
+ _this.description = "Smart Wallet integration for Shogun Core with multi-sig and social recovery";
133
+ _this.factoryContract = null;
134
+ _this.signer = null;
135
+ _this.config = __assign({ enabled: true, defaultRequiredSignatures: 1, defaultRequiredGuardians: 2 }, config);
136
+ return _this;
137
+ }
138
+ /**
139
+ * Initialize the plugin
140
+ */
141
+ SmartWalletPlugin.prototype.initialize = function (core) {
142
+ _super.prototype.initialize.call(this, core);
143
+ if (!this.config.enabled) {
144
+ console.log("[SmartWallet] Plugin disabled");
145
+ return;
146
+ }
147
+ try {
148
+ // Initialize provider and signer
149
+ this.initProvider();
150
+ // Initialize factory contract if address is provided
151
+ if (this.config.factoryAddress) {
152
+ this.initFactoryContract();
153
+ }
154
+ console.log("[SmartWallet] Plugin initialized successfully");
155
+ }
156
+ catch (error) {
157
+ console.error("[SmartWallet] Initialization failed:", error.message);
158
+ }
159
+ };
160
+ /**
161
+ * Destroy the plugin and cleanup resources
162
+ */
163
+ SmartWalletPlugin.prototype.destroy = function () {
164
+ this.factoryContract = null;
165
+ this.signer = null;
166
+ _super.prototype.destroy.call(this);
167
+ console.log("[SmartWallet] Plugin destroyed");
168
+ };
169
+ /**
170
+ * Initialize provider and signer
171
+ */
172
+ SmartWalletPlugin.prototype.initProvider = function () {
173
+ if (typeof window !== "undefined" && window.ethereum) {
174
+ var provider = new ethers.BrowserProvider(window.ethereum);
175
+ // Try to get signer from config, otherwise request from browser
176
+ if (this.config.privateKey) {
177
+ this.signer = new ethers.Wallet(this.config.privateKey, provider);
178
+ }
179
+ else {
180
+ // Will be set when user connects wallet or provides private key
181
+ this.signer = null;
182
+ console.log("[SmartWallet] No private key provided. Use connectWallet() or setSigner() first.");
183
+ }
184
+ }
185
+ };
186
+ /**
187
+ * Set signer with private key or wallet instance
188
+ * This should be called after deriving the EOA from seed phrase
189
+ */
190
+ SmartWalletPlugin.prototype.setSigner = function (privateKeyOrAddress) {
191
+ return __awaiter(this, void 0, void 0, function () {
192
+ var provider;
193
+ var _a;
194
+ return __generator(this, function (_b) {
195
+ try {
196
+ if (!((_a = this.signer) === null || _a === void 0 ? void 0 : _a.provider)) {
197
+ provider = new ethers.BrowserProvider(window.ethereum);
198
+ this.signer = new ethers.Wallet(privateKeyOrAddress, provider);
199
+ }
200
+ else {
201
+ this.signer = new ethers.Wallet(privateKeyOrAddress, this.signer.provider);
202
+ }
203
+ console.log("[SmartWallet] Signer updated");
204
+ }
205
+ catch (error) {
206
+ console.error("[SmartWallet] Failed to set signer:", error.message);
207
+ throw error;
208
+ }
209
+ return [2 /*return*/];
210
+ });
211
+ });
212
+ };
213
+ /**
214
+ * Connect to MetaMask or other injected provider
215
+ */
216
+ SmartWalletPlugin.prototype.connectWallet = function () {
217
+ return __awaiter(this, void 0, void 0, function () {
218
+ var provider, _a, _b, _c, _d, error_1;
219
+ return __generator(this, function (_e) {
220
+ switch (_e.label) {
221
+ case 0:
222
+ _e.trys.push([0, 6, , 7]);
223
+ if (!(typeof window !== "undefined" && window.ethereum)) return [3 /*break*/, 4];
224
+ provider = new ethers.BrowserProvider(window.ethereum);
225
+ return [4 /*yield*/, provider.send("eth_requestAccounts", [])];
226
+ case 1:
227
+ _e.sent();
228
+ _a = this;
229
+ return [4 /*yield*/, provider.getSigner()];
230
+ case 2:
231
+ _a.signer = _e.sent();
232
+ _c = (_b = console).log;
233
+ _d = ["[SmartWallet] Connected to wallet:"];
234
+ return [4 /*yield*/, this.signer.getAddress()];
235
+ case 3:
236
+ _c.apply(_b, _d.concat([_e.sent()]));
237
+ return [3 /*break*/, 5];
238
+ case 4: throw new Error("No Ethereum provider found");
239
+ case 5: return [3 /*break*/, 7];
240
+ case 6:
241
+ error_1 = _e.sent();
242
+ console.error("[SmartWallet] Failed to connect wallet:", error_1.message);
243
+ throw error_1;
244
+ case 7: return [2 /*return*/];
245
+ }
246
+ });
247
+ });
248
+ };
249
+ /**
250
+ * Initialize factory contract
251
+ */
252
+ SmartWalletPlugin.prototype.initFactoryContract = function () {
253
+ if (!this.config.factoryAddress || !this.signer) {
254
+ console.warn("[SmartWallet] Factory address or signer not available");
255
+ return;
256
+ }
257
+ this.factoryContract = new ethers.Contract(this.config.factoryAddress, SMART_WALLET_FACTORY_ABI, this.signer);
258
+ };
259
+ /**
260
+ * Ensure signer is available
261
+ */
262
+ SmartWalletPlugin.prototype.assertSigner = function () {
263
+ if (!this.signer) {
264
+ throw new Error("Signer not available. Please connect a wallet.");
265
+ }
266
+ return this.signer;
267
+ };
268
+ /**
269
+ * Ensure factory is initialized
270
+ */
271
+ SmartWalletPlugin.prototype.assertFactory = function () {
272
+ if (!this.factoryContract) {
273
+ throw new Error("SmartWallet factory not initialized. Please deploy factory first.");
274
+ }
275
+ return this.factoryContract;
276
+ };
277
+ // ============================================ Wallet Creation ============================================
278
+ SmartWalletPlugin.prototype.createWallet = function (owner, requiredSignatures, requiredGuardians) {
279
+ return __awaiter(this, void 0, void 0, function () {
280
+ var factory, sig, reqSig, reqGuard, tx, receipt, event_1, walletAddress, error_2;
281
+ var _a, _b;
282
+ return __generator(this, function (_c) {
283
+ switch (_c.label) {
284
+ case 0:
285
+ _c.trys.push([0, 3, , 4]);
286
+ factory = this.assertFactory();
287
+ sig = this.assertSigner();
288
+ reqSig = (_a = requiredSignatures !== null && requiredSignatures !== void 0 ? requiredSignatures : this.config.defaultRequiredSignatures) !== null && _a !== void 0 ? _a : 1;
289
+ reqGuard = (_b = requiredGuardians !== null && requiredGuardians !== void 0 ? requiredGuardians : this.config.defaultRequiredGuardians) !== null && _b !== void 0 ? _b : 2;
290
+ return [4 /*yield*/, factory.createWallet(owner, reqSig, reqGuard)];
291
+ case 1:
292
+ tx = _c.sent();
293
+ return [4 /*yield*/, tx.wait()];
294
+ case 2:
295
+ receipt = _c.sent();
296
+ event_1 = receipt.logs.find(function (log) {
297
+ return log.topics[0] === ethers.id("WalletCreated(address,address,uint256)");
298
+ });
299
+ walletAddress = event_1
300
+ ? ethers.getAddress("0x" + event_1.topics[1].slice(-40))
301
+ : null;
302
+ return [2 /*return*/, {
303
+ success: true,
304
+ walletAddress: walletAddress || undefined,
305
+ transactionHash: receipt.hash,
306
+ }];
307
+ case 3:
308
+ error_2 = _c.sent();
309
+ return [2 /*return*/, {
310
+ success: false,
311
+ error: error_2.message,
312
+ }];
313
+ case 4: return [2 /*return*/];
314
+ }
315
+ });
316
+ });
317
+ };
318
+ SmartWalletPlugin.prototype.createWalletWithGuardians = function (owner, guardians, requiredSignatures, requiredGuardians) {
319
+ return __awaiter(this, void 0, void 0, function () {
320
+ var factory, reqSig, reqGuard, tx, receipt, event_2, walletAddress, error_3;
321
+ var _a, _b;
322
+ return __generator(this, function (_c) {
323
+ switch (_c.label) {
324
+ case 0:
325
+ _c.trys.push([0, 3, , 4]);
326
+ factory = this.assertFactory();
327
+ reqSig = (_a = requiredSignatures !== null && requiredSignatures !== void 0 ? requiredSignatures : this.config.defaultRequiredSignatures) !== null && _a !== void 0 ? _a : 1;
328
+ reqGuard = (_b = requiredGuardians !== null && requiredGuardians !== void 0 ? requiredGuardians : this.config.defaultRequiredGuardians) !== null && _b !== void 0 ? _b : 2;
329
+ return [4 /*yield*/, factory.createWalletWithGuardians(owner, guardians, reqSig, reqGuard)];
330
+ case 1:
331
+ tx = _c.sent();
332
+ return [4 /*yield*/, tx.wait()];
333
+ case 2:
334
+ receipt = _c.sent();
335
+ event_2 = receipt.logs.find(function (log) {
336
+ return log.topics[0] === ethers.id("WalletCreated(address,address,uint256)");
337
+ });
338
+ walletAddress = event_2
339
+ ? ethers.getAddress("0x" + event_2.topics[1].slice(-40))
340
+ : null;
341
+ return [2 /*return*/, {
342
+ success: true,
343
+ walletAddress: walletAddress || undefined,
344
+ transactionHash: receipt.hash,
345
+ }];
346
+ case 3:
347
+ error_3 = _c.sent();
348
+ return [2 /*return*/, {
349
+ success: false,
350
+ error: error_3.message,
351
+ }];
352
+ case 4: return [2 /*return*/];
353
+ }
354
+ });
355
+ });
356
+ };
357
+ // ============================================ Wallet Management ============================================
358
+ SmartWalletPlugin.prototype.getWalletInfo = function (walletAddress) {
359
+ return __awaiter(this, void 0, void 0, function () {
360
+ var walletContract, _a, owner, requiredSig, requiredGuard, currentSigner, isSigner, error_4;
361
+ return __generator(this, function (_b) {
362
+ switch (_b.label) {
363
+ case 0:
364
+ _b.trys.push([0, 3, , 4]);
365
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, this.assertSigner());
366
+ return [4 /*yield*/, Promise.all([
367
+ walletContract.owner(),
368
+ walletContract.requiredSignatures(),
369
+ walletContract.requiredGuardians(),
370
+ this.assertSigner().getAddress(),
371
+ ])];
372
+ case 1:
373
+ _a = __read.apply(void 0, [_b.sent(), 4]), owner = _a[0], requiredSig = _a[1], requiredGuard = _a[2], currentSigner = _a[3];
374
+ return [4 /*yield*/, walletContract.signers(currentSigner)];
375
+ case 2:
376
+ isSigner = _b.sent();
377
+ return [2 /*return*/, {
378
+ address: walletAddress,
379
+ owner: owner,
380
+ isSigner: isSigner,
381
+ requiredSignatures: Number(requiredSig),
382
+ requiredGuardians: Number(requiredGuard),
383
+ }];
384
+ case 3:
385
+ error_4 = _b.sent();
386
+ console.error("[SmartWallet] Error getting wallet info:", error_4);
387
+ return [2 /*return*/, null];
388
+ case 4: return [2 /*return*/];
389
+ }
390
+ });
391
+ });
392
+ };
393
+ SmartWalletPlugin.prototype.getOwnerWallets = function (ownerAddress) {
394
+ return __awaiter(this, void 0, void 0, function () {
395
+ var factory, wallets, error_5;
396
+ return __generator(this, function (_a) {
397
+ switch (_a.label) {
398
+ case 0:
399
+ _a.trys.push([0, 2, , 3]);
400
+ factory = this.assertFactory();
401
+ return [4 /*yield*/, factory.getOwnerWallets(ownerAddress)];
402
+ case 1:
403
+ wallets = _a.sent();
404
+ return [2 /*return*/, wallets];
405
+ case 2:
406
+ error_5 = _a.sent();
407
+ console.error("[SmartWallet] Error getting owner wallets:", error_5);
408
+ return [2 /*return*/, []];
409
+ case 3: return [2 /*return*/];
410
+ }
411
+ });
412
+ });
413
+ };
414
+ // ============================================ Signer Management ============================================
415
+ SmartWalletPlugin.prototype.addSigner = function (walletAddress, signer) {
416
+ return __awaiter(this, void 0, void 0, function () {
417
+ var walletContract, tx, receipt, error_6;
418
+ return __generator(this, function (_a) {
419
+ switch (_a.label) {
420
+ case 0:
421
+ _a.trys.push([0, 3, , 4]);
422
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, this.assertSigner());
423
+ return [4 /*yield*/, walletContract.addSigner(signer)];
424
+ case 1:
425
+ tx = _a.sent();
426
+ return [4 /*yield*/, tx.wait()];
427
+ case 2:
428
+ receipt = _a.sent();
429
+ return [2 /*return*/, {
430
+ success: true,
431
+ transactionHash: receipt.hash,
432
+ }];
433
+ case 3:
434
+ error_6 = _a.sent();
435
+ return [2 /*return*/, {
436
+ success: false,
437
+ error: error_6.message,
438
+ }];
439
+ case 4: return [2 /*return*/];
440
+ }
441
+ });
442
+ });
443
+ };
444
+ SmartWalletPlugin.prototype.removeSigner = function (walletAddress, signer) {
445
+ return __awaiter(this, void 0, void 0, function () {
446
+ var walletContract, tx, receipt, error_7;
447
+ return __generator(this, function (_a) {
448
+ switch (_a.label) {
449
+ case 0:
450
+ _a.trys.push([0, 3, , 4]);
451
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, this.assertSigner());
452
+ return [4 /*yield*/, walletContract.removeSigner(signer)];
453
+ case 1:
454
+ tx = _a.sent();
455
+ return [4 /*yield*/, tx.wait()];
456
+ case 2:
457
+ receipt = _a.sent();
458
+ return [2 /*return*/, {
459
+ success: true,
460
+ transactionHash: receipt.hash,
461
+ }];
462
+ case 3:
463
+ error_7 = _a.sent();
464
+ return [2 /*return*/, {
465
+ success: false,
466
+ error: error_7.message,
467
+ }];
468
+ case 4: return [2 /*return*/];
469
+ }
470
+ });
471
+ });
472
+ };
473
+ SmartWalletPlugin.prototype.setRequiredSignatures = function (walletAddress, required) {
474
+ return __awaiter(this, void 0, void 0, function () {
475
+ var walletContract, tx, receipt, error_8;
476
+ return __generator(this, function (_a) {
477
+ switch (_a.label) {
478
+ case 0:
479
+ _a.trys.push([0, 3, , 4]);
480
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, this.assertSigner());
481
+ return [4 /*yield*/, walletContract.setRequiredSignatures(required)];
482
+ case 1:
483
+ tx = _a.sent();
484
+ return [4 /*yield*/, tx.wait()];
485
+ case 2:
486
+ receipt = _a.sent();
487
+ return [2 /*return*/, {
488
+ success: true,
489
+ transactionHash: receipt.hash,
490
+ }];
491
+ case 3:
492
+ error_8 = _a.sent();
493
+ return [2 /*return*/, {
494
+ success: false,
495
+ error: error_8.message,
496
+ }];
497
+ case 4: return [2 /*return*/];
498
+ }
499
+ });
500
+ });
501
+ };
502
+ // ============================================ Guardian Management ============================================
503
+ SmartWalletPlugin.prototype.addGuardian = function (walletAddress, guardian) {
504
+ return __awaiter(this, void 0, void 0, function () {
505
+ var walletContract, tx, receipt, error_9;
506
+ return __generator(this, function (_a) {
507
+ switch (_a.label) {
508
+ case 0:
509
+ _a.trys.push([0, 3, , 4]);
510
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, this.assertSigner());
511
+ return [4 /*yield*/, walletContract.addGuardian(guardian)];
512
+ case 1:
513
+ tx = _a.sent();
514
+ return [4 /*yield*/, tx.wait()];
515
+ case 2:
516
+ receipt = _a.sent();
517
+ return [2 /*return*/, {
518
+ success: true,
519
+ transactionHash: receipt.hash,
520
+ }];
521
+ case 3:
522
+ error_9 = _a.sent();
523
+ return [2 /*return*/, {
524
+ success: false,
525
+ error: error_9.message,
526
+ }];
527
+ case 4: return [2 /*return*/];
528
+ }
529
+ });
530
+ });
531
+ };
532
+ SmartWalletPlugin.prototype.removeGuardian = function (walletAddress, guardian) {
533
+ return __awaiter(this, void 0, void 0, function () {
534
+ var walletContract, tx, receipt, error_10;
535
+ return __generator(this, function (_a) {
536
+ switch (_a.label) {
537
+ case 0:
538
+ _a.trys.push([0, 3, , 4]);
539
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, this.assertSigner());
540
+ return [4 /*yield*/, walletContract.removeGuardian(guardian)];
541
+ case 1:
542
+ tx = _a.sent();
543
+ return [4 /*yield*/, tx.wait()];
544
+ case 2:
545
+ receipt = _a.sent();
546
+ return [2 /*return*/, {
547
+ success: true,
548
+ transactionHash: receipt.hash,
549
+ }];
550
+ case 3:
551
+ error_10 = _a.sent();
552
+ return [2 /*return*/, {
553
+ success: false,
554
+ error: error_10.message,
555
+ }];
556
+ case 4: return [2 /*return*/];
557
+ }
558
+ });
559
+ });
560
+ };
561
+ // ============================================ Execution ============================================
562
+ SmartWalletPlugin.prototype.executeTransaction = function (walletAddress_1, target_1, data_1) {
563
+ return __awaiter(this, arguments, void 0, function (walletAddress, target, data, value) {
564
+ var walletContract, tx, receipt, error_11;
565
+ if (value === void 0) { value = "0"; }
566
+ return __generator(this, function (_a) {
567
+ switch (_a.label) {
568
+ case 0:
569
+ _a.trys.push([0, 3, , 4]);
570
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, this.assertSigner());
571
+ return [4 /*yield*/, walletContract.execute(target, data, value)];
572
+ case 1:
573
+ tx = _a.sent();
574
+ return [4 /*yield*/, tx.wait()];
575
+ case 2:
576
+ receipt = _a.sent();
577
+ return [2 /*return*/, {
578
+ success: true,
579
+ transactionHash: receipt.hash,
580
+ }];
581
+ case 3:
582
+ error_11 = _a.sent();
583
+ return [2 /*return*/, {
584
+ success: false,
585
+ error: error_11.message,
586
+ }];
587
+ case 4: return [2 /*return*/];
588
+ }
589
+ });
590
+ });
591
+ };
592
+ SmartWalletPlugin.prototype.executeBatch = function (walletAddress, targets, dataArray, values) {
593
+ return __awaiter(this, void 0, void 0, function () {
594
+ var walletContract, tx, receipt, error_12;
595
+ return __generator(this, function (_a) {
596
+ switch (_a.label) {
597
+ case 0:
598
+ _a.trys.push([0, 3, , 4]);
599
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, this.assertSigner());
600
+ return [4 /*yield*/, walletContract.executeBatch(targets, dataArray, values)];
601
+ case 1:
602
+ tx = _a.sent();
603
+ return [4 /*yield*/, tx.wait()];
604
+ case 2:
605
+ receipt = _a.sent();
606
+ return [2 /*return*/, {
607
+ success: true,
608
+ transactionHash: receipt.hash,
609
+ }];
610
+ case 3:
611
+ error_12 = _a.sent();
612
+ return [2 /*return*/, {
613
+ success: false,
614
+ error: error_12.message,
615
+ }];
616
+ case 4: return [2 /*return*/];
617
+ }
618
+ });
619
+ });
620
+ };
621
+ // ============================================ Multi-Sig ============================================
622
+ SmartWalletPlugin.prototype.proposeExecution = function (walletAddress, target, data) {
623
+ return __awaiter(this, void 0, void 0, function () {
624
+ var walletContract, tx, receipt, error_13;
625
+ return __generator(this, function (_a) {
626
+ switch (_a.label) {
627
+ case 0:
628
+ _a.trys.push([0, 3, , 4]);
629
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, this.assertSigner());
630
+ return [4 /*yield*/, walletContract.proposeExecution(target, data)];
631
+ case 1:
632
+ tx = _a.sent();
633
+ return [4 /*yield*/, tx.wait()];
634
+ case 2:
635
+ receipt = _a.sent();
636
+ return [2 /*return*/, {
637
+ success: true,
638
+ transactionHash: receipt.hash,
639
+ }];
640
+ case 3:
641
+ error_13 = _a.sent();
642
+ return [2 /*return*/, {
643
+ success: false,
644
+ error: error_13.message,
645
+ }];
646
+ case 4: return [2 /*return*/];
647
+ }
648
+ });
649
+ });
650
+ };
651
+ SmartWalletPlugin.prototype.approveProposal = function (walletAddress, proposalId) {
652
+ return __awaiter(this, void 0, void 0, function () {
653
+ var walletContract, tx, receipt, error_14;
654
+ return __generator(this, function (_a) {
655
+ switch (_a.label) {
656
+ case 0:
657
+ _a.trys.push([0, 3, , 4]);
658
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, this.assertSigner());
659
+ return [4 /*yield*/, walletContract.approveProposal(proposalId)];
660
+ case 1:
661
+ tx = _a.sent();
662
+ return [4 /*yield*/, tx.wait()];
663
+ case 2:
664
+ receipt = _a.sent();
665
+ return [2 /*return*/, {
666
+ success: true,
667
+ transactionHash: receipt.hash,
668
+ }];
669
+ case 3:
670
+ error_14 = _a.sent();
671
+ return [2 /*return*/, {
672
+ success: false,
673
+ error: error_14.message,
674
+ }];
675
+ case 4: return [2 /*return*/];
676
+ }
677
+ });
678
+ });
679
+ };
680
+ SmartWalletPlugin.prototype.getProposalInfo = function (walletAddress, proposalId) {
681
+ return __awaiter(this, void 0, void 0, function () {
682
+ var provider, walletContract, _a, target, data, proposer, approvals, executed, error_15;
683
+ return __generator(this, function (_b) {
684
+ switch (_b.label) {
685
+ case 0:
686
+ _b.trys.push([0, 2, , 3]);
687
+ provider = this.assertSigner().provider || ethers.getDefaultProvider();
688
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, provider);
689
+ return [4 /*yield*/, walletContract.getProposal(proposalId)];
690
+ case 1:
691
+ _a = __read.apply(void 0, [_b.sent(), 5]), target = _a[0], data = _a[1], proposer = _a[2], approvals = _a[3], executed = _a[4];
692
+ return [2 /*return*/, {
693
+ proposalId: proposalId,
694
+ target: target,
695
+ proposer: proposer,
696
+ approvals: Number(approvals),
697
+ executed: executed,
698
+ }];
699
+ case 2:
700
+ error_15 = _b.sent();
701
+ console.error("[SmartWallet] Error getting proposal info:", error_15);
702
+ return [2 /*return*/, null];
703
+ case 3: return [2 /*return*/];
704
+ }
705
+ });
706
+ });
707
+ };
708
+ // ============================================ Recovery ============================================
709
+ SmartWalletPlugin.prototype.initiateRecovery = function (walletAddress, newOwner) {
710
+ return __awaiter(this, void 0, void 0, function () {
711
+ var walletContract, tx, receipt, error_16;
712
+ return __generator(this, function (_a) {
713
+ switch (_a.label) {
714
+ case 0:
715
+ _a.trys.push([0, 3, , 4]);
716
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, this.assertSigner());
717
+ return [4 /*yield*/, walletContract.initiateRecovery(newOwner)];
718
+ case 1:
719
+ tx = _a.sent();
720
+ return [4 /*yield*/, tx.wait()];
721
+ case 2:
722
+ receipt = _a.sent();
723
+ return [2 /*return*/, {
724
+ success: true,
725
+ transactionHash: receipt.hash,
726
+ }];
727
+ case 3:
728
+ error_16 = _a.sent();
729
+ return [2 /*return*/, {
730
+ success: false,
731
+ error: error_16.message,
732
+ }];
733
+ case 4: return [2 /*return*/];
734
+ }
735
+ });
736
+ });
737
+ };
738
+ SmartWalletPlugin.prototype.approveRecovery = function (walletAddress) {
739
+ return __awaiter(this, void 0, void 0, function () {
740
+ var walletContract, tx, receipt, error_17;
741
+ return __generator(this, function (_a) {
742
+ switch (_a.label) {
743
+ case 0:
744
+ _a.trys.push([0, 3, , 4]);
745
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, this.assertSigner());
746
+ return [4 /*yield*/, walletContract.approveRecovery()];
747
+ case 1:
748
+ tx = _a.sent();
749
+ return [4 /*yield*/, tx.wait()];
750
+ case 2:
751
+ receipt = _a.sent();
752
+ return [2 /*return*/, {
753
+ success: true,
754
+ transactionHash: receipt.hash,
755
+ }];
756
+ case 3:
757
+ error_17 = _a.sent();
758
+ return [2 /*return*/, {
759
+ success: false,
760
+ error: error_17.message,
761
+ }];
762
+ case 4: return [2 /*return*/];
763
+ }
764
+ });
765
+ });
766
+ };
767
+ SmartWalletPlugin.prototype.executeRecovery = function (walletAddress) {
768
+ return __awaiter(this, void 0, void 0, function () {
769
+ var walletContract, tx, receipt, error_18;
770
+ return __generator(this, function (_a) {
771
+ switch (_a.label) {
772
+ case 0:
773
+ _a.trys.push([0, 3, , 4]);
774
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, this.assertSigner());
775
+ return [4 /*yield*/, walletContract.executeRecovery()];
776
+ case 1:
777
+ tx = _a.sent();
778
+ return [4 /*yield*/, tx.wait()];
779
+ case 2:
780
+ receipt = _a.sent();
781
+ return [2 /*return*/, {
782
+ success: true,
783
+ transactionHash: receipt.hash,
784
+ }];
785
+ case 3:
786
+ error_18 = _a.sent();
787
+ return [2 /*return*/, {
788
+ success: false,
789
+ error: error_18.message,
790
+ }];
791
+ case 4: return [2 /*return*/];
792
+ }
793
+ });
794
+ });
795
+ };
796
+ SmartWalletPlugin.prototype.getRecoveryRequest = function (walletAddress) {
797
+ return __awaiter(this, void 0, void 0, function () {
798
+ var provider, walletContract, _a, newOwner, unlockTime, approvals, error_19;
799
+ return __generator(this, function (_b) {
800
+ switch (_b.label) {
801
+ case 0:
802
+ _b.trys.push([0, 2, , 3]);
803
+ provider = this.assertSigner().provider || ethers.getDefaultProvider();
804
+ walletContract = new ethers.Contract(walletAddress, SMART_WALLET_ABI, provider);
805
+ return [4 /*yield*/, walletContract.getRecoveryRequest()];
806
+ case 1:
807
+ _a = __read.apply(void 0, [_b.sent(), 3]), newOwner = _a[0], unlockTime = _a[1], approvals = _a[2];
808
+ return [2 /*return*/, {
809
+ newOwner: newOwner,
810
+ unlockTime: Number(unlockTime),
811
+ approvals: Number(approvals),
812
+ }];
813
+ case 2:
814
+ error_19 = _b.sent();
815
+ console.error("[SmartWallet] Error getting recovery request:", error_19);
816
+ return [2 /*return*/, null];
817
+ case 3: return [2 /*return*/];
818
+ }
819
+ });
820
+ });
821
+ };
822
+ return SmartWalletPlugin;
823
+ }(BasePlugin));
824
+ export { SmartWalletPlugin };