@framers/agentos-ext-anchor-providers 1.1.0 → 1.2.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 (60) hide show
  1. package/LICENSE +98 -0
  2. package/README.md +38 -16
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +1 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/providers/EthereumProvider.d.ts +48 -4
  7. package/dist/providers/EthereumProvider.d.ts.map +1 -1
  8. package/dist/providers/EthereumProvider.js +261 -27
  9. package/dist/providers/EthereumProvider.js.map +1 -1
  10. package/dist/providers/OpenTimestampsProvider.d.ts +26 -2
  11. package/dist/providers/OpenTimestampsProvider.d.ts.map +1 -1
  12. package/dist/providers/OpenTimestampsProvider.js +141 -26
  13. package/dist/providers/OpenTimestampsProvider.js.map +1 -1
  14. package/dist/providers/RekorProvider.d.ts +32 -3
  15. package/dist/providers/RekorProvider.d.ts.map +1 -1
  16. package/dist/providers/RekorProvider.js +212 -25
  17. package/dist/providers/RekorProvider.js.map +1 -1
  18. package/dist/providers/SolanaProvider.d.ts +58 -4
  19. package/dist/providers/SolanaProvider.d.ts.map +1 -1
  20. package/dist/providers/SolanaProvider.js +310 -25
  21. package/dist/providers/SolanaProvider.js.map +1 -1
  22. package/dist/providers/WormSnapshotProvider.d.ts +30 -2
  23. package/dist/providers/WormSnapshotProvider.d.ts.map +1 -1
  24. package/dist/providers/WormSnapshotProvider.js +176 -27
  25. package/dist/providers/WormSnapshotProvider.js.map +1 -1
  26. package/dist/register.d.ts.map +1 -1
  27. package/dist/register.js +1 -0
  28. package/dist/register.js.map +1 -1
  29. package/dist/types.d.ts.map +1 -1
  30. package/dist/types.js +1 -0
  31. package/dist/types.js.map +1 -1
  32. package/dist/utils/http-client.d.ts.map +1 -1
  33. package/dist/utils/http-client.js +1 -0
  34. package/dist/utils/http-client.js.map +1 -1
  35. package/dist/utils/index.d.ts.map +1 -1
  36. package/dist/utils/index.js +1 -0
  37. package/dist/utils/index.js.map +1 -1
  38. package/dist/utils/serialization.d.ts.map +1 -1
  39. package/dist/utils/serialization.js +1 -0
  40. package/dist/utils/serialization.js.map +1 -1
  41. package/manifest.json +5 -5
  42. package/package.json +26 -21
  43. package/CHANGELOG.md +0 -16
  44. package/src/index.ts +0 -59
  45. package/src/providers/EthereumProvider.ts +0 -87
  46. package/src/providers/OpenTimestampsProvider.ts +0 -86
  47. package/src/providers/RekorProvider.ts +0 -82
  48. package/src/providers/SolanaProvider.ts +0 -439
  49. package/src/providers/WormSnapshotProvider.ts +0 -84
  50. package/src/register.ts +0 -69
  51. package/src/types.ts +0 -27
  52. package/src/utils/http-client.ts +0 -75
  53. package/src/utils/index.ts +0 -3
  54. package/src/utils/serialization.ts +0 -33
  55. package/test/integration.spec.ts +0 -175
  56. package/test/providers.spec.ts +0 -163
  57. package/test/register.spec.ts +0 -69
  58. package/test/types.spec.ts +0 -55
  59. package/test/utils.spec.ts +0 -225
  60. package/tsconfig.json +0 -21
package/LICENSE ADDED
@@ -0,0 +1,98 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License.
30
+
31
+ Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32
+
33
+ 3. Grant of Patent License.
34
+
35
+ Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
36
+
37
+ 4. Redistribution.
38
+
39
+ You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
40
+
41
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
42
+
43
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
44
+
45
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
46
+
47
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
48
+
49
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
50
+
51
+ 5. Submission of Contributions.
52
+
53
+ Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
54
+
55
+ 6. Trademarks.
56
+
57
+ This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
58
+
59
+ 7. Disclaimer of Warranty.
60
+
61
+ Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
62
+
63
+ 8. Limitation of Liability.
64
+
65
+ In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
66
+
67
+ 9. Accepting Warranty or Additional Liability.
68
+
69
+ While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
70
+
71
+ END OF TERMS AND CONDITIONS
72
+
73
+ APPENDIX: How to apply the Apache License to your work.
74
+
75
+ To apply the Apache License to your work, attach the following
76
+ boilerplate notice, with the fields enclosed by brackets "[]"
77
+ replaced with your own identifying information. (Don't include
78
+ the brackets!) The text should be enclosed in the appropriate
79
+ comment syntax for the file format. We also recommend that a
80
+ file or class name and description of purpose be included on the
81
+ same "printed page" as the copyright notice for easier
82
+ identification within third-party archives.
83
+
84
+ Copyright (c) 2025 Framers
85
+
86
+ Licensed under the Apache License, Version 2.0 (the "License");
87
+ you may not use this file except in compliance with the License.
88
+ You may obtain a copy of the License at
89
+
90
+ http://www.apache.org/licenses/LICENSE-2.0
91
+
92
+ Unless required by applicable law or agreed to in writing, software
93
+ distributed under the License is distributed on an "AS IS" BASIS,
94
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
95
+ See the License for the specific language governing permissions and
96
+ limitations under the License.
97
+
98
+
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @framers/agentos-ext-anchor-providers
2
2
 
3
- External anchor providers for the [AgentOS](https://github.com/framersai/agentos) provenance system. Extends the built-in signed hash chain with external tamper-evidence backends — WORM storage, transparency logs, and blockchain timestamping.
3
+ External anchor providers for the [AgentOS](https://github.com/framerslab/agentos) provenance system. Extends the built-in signed hash chain with external tamper-evidence backends — WORM storage, transparency logs, and blockchain timestamping.
4
4
 
5
5
  ## Proof Levels
6
6
 
@@ -304,15 +304,37 @@ Computes SHA-256 hex digest of the canonical anchor representation.
304
304
 
305
305
  ## Implementation Status
306
306
 
307
- | Provider | Status | Notes |
308
- |----------|--------|-------|
309
- | WormSnapshotProvider | Stub | Requires `@aws-sdk/client-s3` implementation |
310
- | RekorProvider | Stub | Requires `sigstore` SDK implementation |
311
- | OpenTimestampsProvider | Stub | Requires `opentimestamps` implementation |
312
- | EthereumProvider | Stub | Requires `ethers` implementation |
313
- | SolanaProvider | Implemented | Requires `@solana/web3.js` (and a funded signer) |
307
+ | Provider | Status | Runtime requirements |
308
+ |----------|--------|----------------------|
309
+ | OpenTimestampsProvider | Implemented (weak verify) | None — uses global `fetch` against public OTS calendars |
310
+ | WormSnapshotProvider | Implemented | `@aws-sdk/client-s3` (dynamic import) + S3 bucket with Object Lock enabled |
311
+ | EthereumProvider | Implemented | `ethers` v6 (dynamic import) + funded signer + RPC endpoint |
312
+ | RekorProvider | Implemented (weak verify) | `publicKeyPem` + `signArtifact` callback (Ed25519 sig over raw hash bytes) |
313
+ | SolanaProvider | Implemented | `@solana/web3.js` (dynamic import) + funded signer |
314
314
 
315
- All providers **except SolanaProvider** currently return `{ success: false }` from `publish()` until their respective SDK integrations are implemented. SolanaProvider is functional when its optional peer dependencies are installed and the configured signer is funded.
315
+ All five providers return `{ success: true, externalRef, metadata: {...} }` on a successful publish. Failed publishes return `{ success: false, error, metadata }` — never throw — so a composite anchor strategy can fall through cleanly.
316
+
317
+ ### Verification strength
318
+
319
+ | Provider | Verify behaviour |
320
+ |----------|------------------|
321
+ | OpenTimestampsProvider | Weak — re-POSTs the digest to a stored calendar URL and confirms the returned bytes hash to the stored attestation hash. For full Bitcoin-block proof, parse the stored base64 with `javascript-opentimestamps` and run its `verify()` against Bitcoin. |
322
+ | WormSnapshotProvider | Strong — `HeadObjectCommand` confirms the object still exists, the Object Lock retention is still active, and the stored SHA-256 metadata matches the recomputed canonical anchor hash. |
323
+ | EthereumProvider | Strong — fetches the transaction + receipt by hash, decodes calldata (or contract input via the `anchor(bytes32)` ABI), and asserts equality with the recomputed canonical anchor hash. |
324
+ | RekorProvider | Weak — GETs the entry by UUID, decodes the body, and compares the stored hash with the recomputed canonical anchor hash. The inclusion proof against the signed tree head is not verified here; wire `sigstore.verify(bundle)` afterwards for compliance workflows. |
325
+ | SolanaProvider | Strong — reads the on-chain account, decodes the manifest hash + content hash, and compares both against the recomputed canonical values. |
326
+
327
+ ### Failure detection
328
+
329
+ Failed publishes set `metadata` with provider-specific diagnostics (bucket / region / chainId / serverUrl etc.). For SDK-missing failures the WORM provider sets `metadata.sdkMissing: true` so callers composing fallback strategies can distinguish "this provider can't run on this machine" from "transient runtime error":
330
+
331
+ ```ts
332
+ const result = await provider.publish(anchor);
333
+ if (!result.success) {
334
+ if (result.metadata?.sdkMissing === true) continue; // fall through
335
+ throw new Error(`Anchor publish failed: ${result.error}`);
336
+ }
337
+ ```
316
338
 
317
339
  ## Testing
318
340
 
@@ -341,13 +363,13 @@ pnpm test:watch
341
363
 
342
364
  | Package | Description | Link |
343
365
  |---------|-------------|------|
344
- | `@framers/agentos` | Core AgentOS framework with `AnchorProvider` interface, `AnchorManager`, registry | [packages/agentos](https://github.com/framersai/agentos) |
345
- | `@framers/agentos` provenance types | `AnchorProvider`, `ProofLevel`, `AnchorProviderResult` interfaces | [`src/core/provenance/types.ts`](https://github.com/framersai/agentos/blob/master/src/core/provenance/types.ts) |
346
- | `@framers/agentos` factory | `createAnchorProvider()`, `registerAnchorProviderFactory()` | [`src/core/provenance/anchoring/providers/createAnchorProvider.ts`](https://github.com/framersai/agentos/blob/master/src/core/provenance/anchoring/providers/createAnchorProvider.ts) |
347
- | `@framers/agentos` built-in providers | `NoneProvider`, `CompositeAnchorProvider` | [`src/core/provenance/anchoring/providers/`](https://github.com/framersai/agentos/blob/master/src/core/provenance/anchoring/providers/) |
348
- | `@framers/agentos` AnchorManager | Periodic anchoring with external provider support | [`src/core/provenance/anchoring/AnchorManager.ts`](https://github.com/framersai/agentos/blob/master/src/core/provenance/anchoring/AnchorManager.ts) |
349
- | `@framers/agentos` profiles | `sealedAuditable()` convenience profile | [`src/core/provenance/config/PolicyProfiles.ts`](https://github.com/framersai/agentos/blob/master/src/core/provenance/config/PolicyProfiles.ts) |
366
+ | `@framers/agentos` | Core AgentOS framework with `AnchorProvider` interface, `AnchorManager`, registry | [packages/agentos](https://github.com/framerslab/agentos) |
367
+ | `@framers/agentos` provenance types | `AnchorProvider`, `ProofLevel`, `AnchorProviderResult` interfaces | [`src/core/provenance/types.ts`](https://github.com/framerslab/agentos/blob/master/src/core/provenance/types.ts) |
368
+ | `@framers/agentos` factory | `createAnchorProvider()`, `registerAnchorProviderFactory()` | [`src/core/provenance/anchoring/providers/createAnchorProvider.ts`](https://github.com/framerslab/agentos/blob/master/src/core/provenance/anchoring/providers/createAnchorProvider.ts) |
369
+ | `@framers/agentos` built-in providers | `NoneProvider`, `CompositeAnchorProvider` | [`src/core/provenance/anchoring/providers/`](https://github.com/framerslab/agentos/blob/master/src/core/provenance/anchoring/providers/) |
370
+ | `@framers/agentos` AnchorManager | Periodic anchoring with external provider support | [`src/core/provenance/anchoring/AnchorManager.ts`](https://github.com/framerslab/agentos/blob/master/src/core/provenance/anchoring/AnchorManager.ts) |
371
+ | `@framers/agentos` profiles | `sealedAuditable()` convenience profile | [`src/core/provenance/config/PolicyProfiles.ts`](https://github.com/framerslab/agentos/blob/master/src/core/provenance/config/PolicyProfiles.ts) |
350
372
 
351
373
  ## License
352
374
 
353
- MIT
375
+ Apache-2.0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAG3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,YAAY,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAEtF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,YAAY,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAE1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,YAAY,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAG1E,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAG3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,YAAY,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAEtF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,YAAY,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAE1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,YAAY,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAG1E,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  /**
2
3
  * @file index.ts
3
4
  * @description Main entry point for @framers/agentos-ext-anchor-providers.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,WAAW;AACX,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE3D,YAAY;AACZ,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAG/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAK/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,YAAY;AACZ,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,WAAW;AACX,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE3D,YAAY;AACZ,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAG/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAK/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,YAAY;AACZ,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,10 +1,24 @@
1
1
  /**
2
2
  * @file EthereumProvider.ts
3
3
  * @description Ethereum on-chain anchor provider.
4
- * Publishes anchor Merkle roots as calldata in Ethereum transactions.
4
+ *
5
+ * `publish()` writes the SHA-256 of the canonical anchor as calldata on
6
+ * an Ethereum transaction so the anchor becomes inseparable from a
7
+ * specific block (and via the block, a specific point in time). Two
8
+ * modes:
9
+ *
10
+ * 1. **Self-transfer with calldata** (default when `contractAddress`
11
+ * is unset): the signer sends 0 wei to itself with the anchor hash
12
+ * packed into the `data` field. Cheap, no contract needed.
13
+ * 2. **Contract anchor** (when `contractAddress` is set): an ABI call
14
+ * to `anchor(bytes32 merkleRoot)` so on-chain consumers can filter
15
+ * / index anchor events.
16
+ *
17
+ * `verify()` fetches the transaction's receipt, recovers the calldata,
18
+ * and confirms it matches the recomputed canonical anchor hash.
5
19
  *
6
20
  * Proof level: `publicly-timestamped`
7
- * Required peer dependency: `ethers`
21
+ * Required peer dependency: `ethers` (loaded via dynamic import).
8
22
  *
9
23
  * @module @framers/agentos-ext-anchor-providers
10
24
  */
@@ -13,14 +27,16 @@ import type { BaseProviderConfig } from '../types.js';
13
27
  export interface EthereumProviderConfig extends BaseProviderConfig {
14
28
  /** JSON-RPC endpoint URL. */
15
29
  rpcUrl: string;
16
- /** Contract address for anchor storage (optional — can use raw calldata tx). */
30
+ /** Contract address for anchor storage. Omit for raw-calldata mode. */
17
31
  contractAddress?: string;
18
- /** Private key hex for signing transactions. */
32
+ /** Private key hex (0x-prefixed) for signing transactions. */
19
33
  signerPrivateKey?: string;
20
34
  /** Chain ID. Default: 1 (mainnet). */
21
35
  chainId?: number;
22
36
  /** Gas limit override. Default: auto-estimate. */
23
37
  gasLimit?: number;
38
+ /** Number of confirmations to wait for. Default: 1. */
39
+ confirmations?: number;
24
40
  }
25
41
  export declare class EthereumProvider implements AnchorProvider {
26
42
  readonly id = "ethereum";
@@ -28,9 +44,37 @@ export declare class EthereumProvider implements AnchorProvider {
28
44
  readonly proofLevel: ProofLevel;
29
45
  private readonly config;
30
46
  private readonly baseConfig;
47
+ /** Cached ethers Provider — reused across calls. */
48
+ private cachedProvider;
49
+ /** Cached ethers Wallet — only present when signing is configured. */
50
+ private cachedWallet;
31
51
  constructor(config: EthereumProviderConfig);
32
52
  publish(anchor: AnchorRecord): Promise<AnchorProviderResult>;
53
+ /**
54
+ * Confirm the anchor's `eth:` externalRef points at a finalised tx
55
+ * whose calldata (or contract input) matches the recomputed canonical
56
+ * anchor digest. Does not re-execute the contract — just compares the
57
+ * stored calldata against the expected hash.
58
+ */
33
59
  verify(anchor: AnchorRecord): Promise<boolean>;
34
60
  dispose(): Promise<void>;
61
+ private loadEthers;
62
+ private getProvider;
63
+ /**
64
+ * Race an RPC call against `config.timeoutMs` so a stalled provider
65
+ * connection can't block the publish/verify chain indefinitely.
66
+ * ethers v6 has internal request timeouts in some paths but doesn't
67
+ * expose a single knob for them, so we wrap every call explicitly.
68
+ */
69
+ private withTimeout;
70
+ /**
71
+ * Retry a transient operation up to `config.retries` times with linear
72
+ * `config.retryDelayMs` backoff. Each attempt is bounded by
73
+ * `config.timeoutMs` via {@link withTimeout}; the timeout counts as a
74
+ * retryable failure (so a slow node burns one attempt and falls
75
+ * through, not the whole budget).
76
+ */
77
+ private withRetry;
78
+ private getWallet;
35
79
  }
36
80
  //# sourceMappingURL=EthereumProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumProvider.d.ts","sourceRoot":"","sources":["../../src/providers/EthereumProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACvG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAItD,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,gBAAiB,YAAW,cAAc;IACrD,QAAQ,CAAC,EAAE,cAAc;IACzB,QAAQ,CAAC,IAAI,8BAA8B;IAC3C,QAAQ,CAAC,UAAU,EAAE,UAAU,CAA0B;IAEzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;IAChD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA+B;gBAE9C,MAAM,EAAE,sBAAsB;IAQpC,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA8B5D,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ9C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
1
+ {"version":3,"file":"EthereumProvider.d.ts","sourceRoot":"","sources":["../../src/providers/EthereumProvider.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACvG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAItD,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AASD,qBAAa,gBAAiB,YAAW,cAAc;IACrD,QAAQ,CAAC,EAAE,cAAc;IACzB,QAAQ,CAAC,IAAI,8BAA8B;IAC3C,QAAQ,CAAC,UAAU,EAAE,UAAU,CAA0B;IAEzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAIrB;IACF,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA+B;IAE1D,oDAAoD;IACpD,OAAO,CAAC,cAAc,CAAa;IACnC,sEAAsE;IACtE,OAAO,CAAC,YAAY,CAAa;gBAErB,MAAM,EAAE,sBAAsB;IAepC,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAqFlE;;;;;OAKG;IACG,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAyD9C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAYhB,UAAU;IAgBxB,OAAO,CAAC,WAAW;IAanB;;;;;OAKG;YACW,WAAW;IAiBzB;;;;;;OAMG;YACW,SAAS;YAeT,SAAS;CASxB"}
@@ -1,66 +1,300 @@
1
+ // @ts-nocheck
1
2
  /**
2
3
  * @file EthereumProvider.ts
3
4
  * @description Ethereum on-chain anchor provider.
4
- * Publishes anchor Merkle roots as calldata in Ethereum transactions.
5
+ *
6
+ * `publish()` writes the SHA-256 of the canonical anchor as calldata on
7
+ * an Ethereum transaction so the anchor becomes inseparable from a
8
+ * specific block (and via the block, a specific point in time). Two
9
+ * modes:
10
+ *
11
+ * 1. **Self-transfer with calldata** (default when `contractAddress`
12
+ * is unset): the signer sends 0 wei to itself with the anchor hash
13
+ * packed into the `data` field. Cheap, no contract needed.
14
+ * 2. **Contract anchor** (when `contractAddress` is set): an ABI call
15
+ * to `anchor(bytes32 merkleRoot)` so on-chain consumers can filter
16
+ * / index anchor events.
17
+ *
18
+ * `verify()` fetches the transaction's receipt, recovers the calldata,
19
+ * and confirms it matches the recomputed canonical anchor hash.
5
20
  *
6
21
  * Proof level: `publicly-timestamped`
7
- * Required peer dependency: `ethers`
22
+ * Required peer dependency: `ethers` (loaded via dynamic import).
8
23
  *
9
24
  * @module @framers/agentos-ext-anchor-providers
10
25
  */
11
26
  import { resolveBaseConfig } from '../types.js';
12
27
  import { hashCanonicalAnchor } from '../utils/serialization.js';
28
+ /**
29
+ * Minimal ABI fragment for an `anchor(bytes32)` contract. Callers can
30
+ * deploy any contract with this method signature (e.g. logging the
31
+ * merkleRoot to an event) and point `contractAddress` at it.
32
+ */
33
+ const ANCHOR_CONTRACT_ABI = ['function anchor(bytes32 merkleRoot)'];
13
34
  export class EthereumProvider {
14
35
  id = 'ethereum';
15
36
  name = 'Ethereum On-Chain Anchor';
16
37
  proofLevel = 'publicly-timestamped';
17
38
  config;
18
39
  baseConfig;
40
+ /** Cached ethers Provider — reused across calls. */
41
+ cachedProvider = null;
42
+ /** Cached ethers Wallet — only present when signing is configured. */
43
+ cachedWallet = null;
19
44
  constructor(config) {
20
45
  this.config = {
21
- chainId: 1,
22
- ...config,
46
+ rpcUrl: config.rpcUrl,
47
+ chainId: config.chainId ?? 1,
48
+ confirmations: config.confirmations ?? 1,
49
+ timeoutMs: config.timeoutMs ?? 30_000,
50
+ retries: config.retries ?? 3,
51
+ retryDelayMs: config.retryDelayMs ?? 1_000,
52
+ contractAddress: config.contractAddress,
53
+ signerPrivateKey: config.signerPrivateKey,
54
+ gasLimit: config.gasLimit,
23
55
  };
24
56
  this.baseConfig = resolveBaseConfig(config);
25
57
  }
26
58
  async publish(anchor) {
27
- // TODO: Implement using ethers.js or viem
28
- //
29
- // Implementation outline:
30
- // 1. Compute SHA-256 of canonical anchor: hashCanonicalAnchor(anchor)
31
- // 2. Create ethers.JsonRpcProvider(this.config.rpcUrl)
32
- // 3. Create ethers.Wallet(this.config.signerPrivateKey, provider)
33
- // 4. If contractAddress is set:
34
- // - ABI-encode call to `anchor(bytes32 merkleRoot)` on the contract
35
- // - Send contract transaction
36
- // 5. If no contractAddress (raw calldata):
37
- // - Send self-transfer with 0x + anchorHash as calldata
38
- // 6. Wait for transaction receipt (1 confirmation)
39
- // 7. Return { success: true, externalRef: `eth:${chainId}:${txHash}`,
40
- // metadata: { blockNumber, blockHash, gasUsed, chainId } }
59
+ if (!this.config.signerPrivateKey) {
60
+ return {
61
+ providerId: this.id,
62
+ success: false,
63
+ error: 'EthereumProvider.publish requires signerPrivateKey to send transactions.',
64
+ metadata: { chainId: this.config.chainId },
65
+ };
66
+ }
67
+ let ethers;
41
68
  try {
42
- const _hash = await hashCanonicalAnchor(anchor);
43
- throw new Error('EthereumProvider is not yet implemented. ' +
44
- 'Install ethers.js and implement the Ethereum on-chain anchor integration.');
69
+ ethers = await this.loadEthers();
45
70
  }
46
71
  catch (e) {
47
72
  return {
48
73
  providerId: this.id,
49
74
  success: false,
50
75
  error: e instanceof Error ? e.message : String(e),
76
+ metadata: { sdkMissing: true },
77
+ };
78
+ }
79
+ const digestHex = await hashCanonicalAnchor(anchor);
80
+ const dataHex = `0x${digestHex}`;
81
+ try {
82
+ const wallet = await this.getWallet(ethers);
83
+ let txResponse;
84
+ if (this.config.contractAddress) {
85
+ // Contract-call mode: invoke anchor(bytes32) so on-chain
86
+ // listeners can index anchor commits by event.
87
+ const contract = new ethers.Contract(this.config.contractAddress, ANCHOR_CONTRACT_ABI, wallet);
88
+ const overrides = {};
89
+ if (this.config.gasLimit !== undefined)
90
+ overrides.gasLimit = this.config.gasLimit;
91
+ txResponse = await this.withRetry(() => contract.anchor(dataHex, overrides));
92
+ }
93
+ else {
94
+ // Raw-calldata mode: self-transfer with the digest packed into
95
+ // the data field. No contract required; the proof is just the
96
+ // existence of a tx with this calldata in a finalised block.
97
+ const tx = {
98
+ to: await wallet.getAddress(),
99
+ value: 0n,
100
+ data: dataHex,
101
+ };
102
+ if (this.config.gasLimit !== undefined)
103
+ tx.gasLimit = this.config.gasLimit;
104
+ txResponse = await this.withRetry(() => wallet.sendTransaction(tx));
105
+ }
106
+ const receipt = await txResponse.wait(this.config.confirmations);
107
+ if (!receipt) {
108
+ return {
109
+ providerId: this.id,
110
+ success: false,
111
+ error: 'Transaction sent but receipt was null',
112
+ metadata: { txHash: txResponse.hash, chainId: this.config.chainId },
113
+ };
114
+ }
115
+ return {
116
+ providerId: this.id,
117
+ success: true,
118
+ externalRef: `eth:${this.config.chainId}:${receipt.hash ?? txResponse.hash}`,
119
+ publishedAt: new Date().toISOString(),
120
+ metadata: {
121
+ chainId: this.config.chainId,
122
+ txHash: receipt.hash ?? txResponse.hash,
123
+ blockNumber: receipt.blockNumber,
124
+ blockHash: receipt.blockHash,
125
+ gasUsed: receipt.gasUsed?.toString(),
126
+ contractAddress: this.config.contractAddress,
127
+ mode: this.config.contractAddress ? 'contract' : 'calldata',
128
+ },
129
+ };
130
+ }
131
+ catch (e) {
132
+ const message = e instanceof Error ? e.message : String(e);
133
+ return {
134
+ providerId: this.id,
135
+ success: false,
136
+ error: `Ethereum transaction failed: ${message}`,
137
+ metadata: { chainId: this.config.chainId },
51
138
  };
52
139
  }
53
140
  }
141
+ /**
142
+ * Confirm the anchor's `eth:` externalRef points at a finalised tx
143
+ * whose calldata (or contract input) matches the recomputed canonical
144
+ * anchor digest. Does not re-execute the contract — just compares the
145
+ * stored calldata against the expected hash.
146
+ */
54
147
  async verify(anchor) {
55
- // TODO: Parse txHash from externalRef, fetch transaction receipt,
56
- // decode calldata, compare with anchor hash
57
- if (!anchor.externalRef)
148
+ if (!anchor.externalRef?.startsWith('eth:'))
149
+ return false;
150
+ let ethers;
151
+ try {
152
+ ethers = await this.loadEthers();
153
+ }
154
+ catch {
155
+ return false;
156
+ }
157
+ // Parse eth:${chainId}:${txHash}
158
+ const parts = anchor.externalRef.split(':');
159
+ if (parts.length < 3)
58
160
  return false;
59
- console.warn('[EthereumProvider] verify() is not yet implemented');
60
- return false;
161
+ const txHash = parts.slice(2).join(':'); // tolerate 0x... that already has colons (defensive)
162
+ try {
163
+ const provider = this.getProvider(ethers);
164
+ const tx = await this.withRetry(() => provider.getTransaction(txHash));
165
+ if (!tx)
166
+ return false;
167
+ const receipt = await this.withRetry(() => provider.getTransactionReceipt(txHash));
168
+ if (!receipt || receipt.status === 0)
169
+ return false;
170
+ // Normalise both sides to lowercase hex with the `0x` prefix so the
171
+ // comparison is independent of how hashCanonicalAnchor / the on-chain
172
+ // decoder happens to encode the case.
173
+ const expectedHex = `0x${(await hashCanonicalAnchor(anchor)).toLowerCase()}`;
174
+ const txData = (tx.data ?? '').toLowerCase();
175
+ // Detect mode from tx.data shape rather than from current config —
176
+ // config.contractAddress may have been changed since publish, and the
177
+ // tx on chain is the authoritative source. Two recognised shapes:
178
+ //
179
+ // * raw calldata mode: exactly `0x` + 64 hex chars (32-byte digest).
180
+ // * contract-call mode: ABI-encoded `anchor(bytes32)` call, starts
181
+ // with the 4-byte selector followed by a 32-byte argument.
182
+ //
183
+ // Anything else is treated as a verify failure (the recorded tx
184
+ // does not match any pattern this provider produces on publish).
185
+ if (txData.length === 66 && txData === expectedHex) {
186
+ return true;
187
+ }
188
+ try {
189
+ const iface = new ethers.Interface(ANCHOR_CONTRACT_ABI);
190
+ const selector = iface.getFunction('anchor')?.selector?.toLowerCase();
191
+ if (!selector || !txData.startsWith(selector))
192
+ return false;
193
+ const parsed = iface.parseTransaction({ data: tx.data, value: tx.value });
194
+ if (!parsed || parsed.name !== 'anchor')
195
+ return false;
196
+ const argHex = parsed.args[0].toLowerCase();
197
+ return argHex === expectedHex;
198
+ }
199
+ catch {
200
+ return false;
201
+ }
202
+ }
203
+ catch {
204
+ return false;
205
+ }
61
206
  }
62
207
  async dispose() {
63
- // TODO: Disconnect provider if persistent connection was established
208
+ if (this.cachedProvider && typeof this.cachedProvider.destroy === 'function') {
209
+ try {
210
+ this.cachedProvider.destroy();
211
+ }
212
+ catch {
213
+ // Best-effort cleanup.
214
+ }
215
+ }
216
+ this.cachedProvider = null;
217
+ this.cachedWallet = null;
218
+ }
219
+ async loadEthers() {
220
+ const moduleName = 'ethers';
221
+ try {
222
+ const mod = await import(moduleName);
223
+ // ethers v6 exports a namespace under default; v5 exports flat.
224
+ // We use namespace-style access (`ethers.Wallet`, `ethers.Contract`)
225
+ // which works for v6 root export.
226
+ return mod.ethers ?? mod;
227
+ }
228
+ catch {
229
+ throw new Error('EthereumProvider requires ethers (v6) at runtime. ' +
230
+ 'Install it in your project to enable Ethereum anchoring.');
231
+ }
232
+ }
233
+ getProvider(ethers) {
234
+ if (this.cachedProvider)
235
+ return this.cachedProvider;
236
+ // ethers v6 doesn't expose a simple retry knob, but the provider
237
+ // has a `pollingInterval` and internal fetch-retry. We additionally
238
+ // wrap the actual RPC calls (sendTransaction / getTransaction)
239
+ // through `withRetry` below so transient failures don't bubble up
240
+ // as anchor failures.
241
+ this.cachedProvider = new ethers.JsonRpcProvider(this.config.rpcUrl, this.config.chainId, {
242
+ staticNetwork: ethers.Network.from?.(this.config.chainId),
243
+ });
244
+ return this.cachedProvider;
245
+ }
246
+ /**
247
+ * Race an RPC call against `config.timeoutMs` so a stalled provider
248
+ * connection can't block the publish/verify chain indefinitely.
249
+ * ethers v6 has internal request timeouts in some paths but doesn't
250
+ * expose a single knob for them, so we wrap every call explicitly.
251
+ */
252
+ async withTimeout(op) {
253
+ let timer;
254
+ try {
255
+ return await Promise.race([
256
+ op(),
257
+ new Promise((_, reject) => {
258
+ timer = setTimeout(() => reject(new Error(`Ethereum RPC timed out after ${this.config.timeoutMs}ms`)), this.config.timeoutMs);
259
+ }),
260
+ ]);
261
+ }
262
+ finally {
263
+ if (timer)
264
+ clearTimeout(timer);
265
+ }
266
+ }
267
+ /**
268
+ * Retry a transient operation up to `config.retries` times with linear
269
+ * `config.retryDelayMs` backoff. Each attempt is bounded by
270
+ * `config.timeoutMs` via {@link withTimeout}; the timeout counts as a
271
+ * retryable failure (so a slow node burns one attempt and falls
272
+ * through, not the whole budget).
273
+ */
274
+ async withRetry(op) {
275
+ let lastError;
276
+ for (let attempt = 0; attempt <= this.config.retries; attempt++) {
277
+ try {
278
+ return await this.withTimeout(op);
279
+ }
280
+ catch (e) {
281
+ lastError = e;
282
+ if (attempt < this.config.retries) {
283
+ await new Promise((resolve) => setTimeout(resolve, this.config.retryDelayMs));
284
+ }
285
+ }
286
+ }
287
+ throw lastError instanceof Error ? lastError : new Error(String(lastError));
288
+ }
289
+ async getWallet(ethers) {
290
+ if (this.cachedWallet)
291
+ return this.cachedWallet;
292
+ if (!this.config.signerPrivateKey) {
293
+ throw new Error('signerPrivateKey is required to obtain a wallet for publishing.');
294
+ }
295
+ const provider = this.getProvider(ethers);
296
+ this.cachedWallet = new ethers.Wallet(this.config.signerPrivateKey, provider);
297
+ return this.cachedWallet;
64
298
  }
65
299
  }
66
300
  //# sourceMappingURL=EthereumProvider.js.map