@brninpay/sdk 0.1.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 (95) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/LICENSE +203 -0
  3. package/README.md +5 -0
  4. package/dist/actor-client.d.ts +13 -0
  5. package/dist/actor-client.d.ts.map +1 -0
  6. package/dist/actor-client.js +44 -0
  7. package/dist/actor-client.js.map +1 -0
  8. package/dist/bundler/client.d.ts +20 -0
  9. package/dist/bundler/client.d.ts.map +1 -0
  10. package/dist/bundler/client.js +228 -0
  11. package/dist/bundler/client.js.map +1 -0
  12. package/dist/bundler/providers/alchemy.d.ts +3 -0
  13. package/dist/bundler/providers/alchemy.d.ts.map +1 -0
  14. package/dist/bundler/providers/alchemy.js +15 -0
  15. package/dist/bundler/providers/alchemy.js.map +1 -0
  16. package/dist/bundler/providers/pimlico.d.ts +3 -0
  17. package/dist/bundler/providers/pimlico.d.ts.map +1 -0
  18. package/dist/bundler/providers/pimlico.js +12 -0
  19. package/dist/bundler/providers/pimlico.js.map +1 -0
  20. package/dist/client.d.ts +24 -0
  21. package/dist/client.d.ts.map +1 -0
  22. package/dist/client.js +352 -0
  23. package/dist/client.js.map +1 -0
  24. package/dist/conversion.d.ts +3 -0
  25. package/dist/conversion.d.ts.map +1 -0
  26. package/dist/conversion.js +27 -0
  27. package/dist/conversion.js.map +1 -0
  28. package/dist/erc4337/builder.d.ts +15 -0
  29. package/dist/erc4337/builder.d.ts.map +1 -0
  30. package/dist/erc4337/builder.js +144 -0
  31. package/dist/erc4337/builder.js.map +1 -0
  32. package/dist/erc4337/providers/kernel.d.ts +23 -0
  33. package/dist/erc4337/providers/kernel.d.ts.map +1 -0
  34. package/dist/erc4337/providers/kernel.js +120 -0
  35. package/dist/erc4337/providers/kernel.js.map +1 -0
  36. package/dist/erc4337/providers/safe.d.ts +23 -0
  37. package/dist/erc4337/providers/safe.d.ts.map +1 -0
  38. package/dist/erc4337/providers/safe.js +117 -0
  39. package/dist/erc4337/providers/safe.js.map +1 -0
  40. package/dist/erc4337/providers/types.d.ts +88 -0
  41. package/dist/erc4337/providers/types.d.ts.map +1 -0
  42. package/dist/erc4337/providers/types.js +35 -0
  43. package/dist/erc4337/providers/types.js.map +1 -0
  44. package/dist/erc4337/smart-wallet.d.ts +16 -0
  45. package/dist/erc4337/smart-wallet.d.ts.map +1 -0
  46. package/dist/erc4337/smart-wallet.js +86 -0
  47. package/dist/erc4337/smart-wallet.js.map +1 -0
  48. package/dist/index.d.ts +16 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +15 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/modules/payment-intents.d.ts +99 -0
  53. package/dist/modules/payment-intents.d.ts.map +1 -0
  54. package/dist/modules/payment-intents.js +118 -0
  55. package/dist/modules/payment-intents.js.map +1 -0
  56. package/dist/modules/policies.d.ts +87 -0
  57. package/dist/modules/policies.d.ts.map +1 -0
  58. package/dist/modules/policies.js +61 -0
  59. package/dist/modules/policies.js.map +1 -0
  60. package/dist/paymaster/client.d.ts +11 -0
  61. package/dist/paymaster/client.d.ts.map +1 -0
  62. package/dist/paymaster/client.js +119 -0
  63. package/dist/paymaster/client.js.map +1 -0
  64. package/dist/runtimee.d.ts +4 -0
  65. package/dist/runtimee.d.ts.map +1 -0
  66. package/dist/runtimee.js +4 -0
  67. package/dist/runtimee.js.map +1 -0
  68. package/dist/types.d.ts +389 -0
  69. package/dist/types.d.ts.map +1 -0
  70. package/dist/types.js +2 -0
  71. package/dist/types.js.map +1 -0
  72. package/package.json +29 -0
  73. package/src/actor-client.ts +57 -0
  74. package/src/bundler/client.ts +306 -0
  75. package/src/bundler/providers/alchemy.ts +21 -0
  76. package/src/bundler/providers/pimlico.ts +17 -0
  77. package/src/client.ts +472 -0
  78. package/src/conversion.ts +25 -0
  79. package/src/erc4337/builder.ts +181 -0
  80. package/src/erc4337/providers/kernel.ts +136 -0
  81. package/src/erc4337/providers/safe.ts +133 -0
  82. package/src/erc4337/providers/types.ts +73 -0
  83. package/src/erc4337/smart-wallet.ts +115 -0
  84. package/src/index.ts +60 -0
  85. package/src/modules/payment-intents.ts +156 -0
  86. package/src/modules/policies.ts +79 -0
  87. package/src/paymaster/client.ts +155 -0
  88. package/src/runtimee.ts +3 -0
  89. package/src/types.ts +469 -0
  90. package/test/architecture/architecture-invariants.test.ts +61 -0
  91. package/test/client.test.ts +180 -0
  92. package/test/conversion.test.ts +42 -0
  93. package/test/runtimee.test.ts +30 -0
  94. package/tsconfig.json +9 -0
  95. package/vitest.config.ts +8 -0
@@ -0,0 +1,4 @@
1
+
2
+ > @brninpay/sdk@0.1.0 build /home/runner/work/brninpay/brninpay/packages/sdk
3
+ > tsc
4
+
package/LICENSE ADDED
@@ -0,0 +1,203 @@
1
+ Copyright 2026 Runtimee Authors
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same "printed page" as the copyright notice for easier
189
+ identification within third-party archives.
190
+
191
+ Copyright [yyyy] [name of copyright owner]
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @runtimee/sdk
2
+
3
+ Developer-facing API for Runtimee.
4
+
5
+ Create financial actors, define spending policies, and let autonomous systems spend USDC within constraints.
@@ -0,0 +1,13 @@
1
+ import type { ActorStatus, ActorSummary, ClientTransport, CreateActorParams, ExecutionReceipt, PayParams, PreviewPayParams } from './types.js';
2
+ export declare class ActorClient {
3
+ private readonly transport;
4
+ constructor(transport: ClientTransport);
5
+ create(params: CreateActorParams): Promise<ActorSummary>;
6
+ pay(actorId: string, params: PayParams): Promise<ExecutionReceipt>;
7
+ previewPay(actorId: string, params: PreviewPayParams): Promise<{
8
+ decision: string;
9
+ policyResults: unknown[];
10
+ }>;
11
+ status(actorId: string): Promise<ActorStatus>;
12
+ }
13
+ //# sourceMappingURL=actor-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor-client.d.ts","sourceRoot":"","sources":["../src/actor-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAA;AAEnB,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,eAAe;IAEjD,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IAQxD,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAalE,UAAU,CACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;IAYpD,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAMpD"}
@@ -0,0 +1,44 @@
1
+ import { parseUsdc } from './conversion.js';
2
+ export class ActorClient {
3
+ transport;
4
+ constructor(transport) {
5
+ this.transport = transport;
6
+ }
7
+ async create(params) {
8
+ return this.transport.request({
9
+ path: '/api/actors',
10
+ method: 'POST',
11
+ body: params,
12
+ });
13
+ }
14
+ async pay(actorId, params) {
15
+ return this.transport.request({
16
+ path: `/api/actors/${encodeURIComponent(actorId)}/pay`,
17
+ method: 'POST',
18
+ body: {
19
+ target: params.target,
20
+ amount: parseUsdc(params.amount).toString(),
21
+ purpose: params.purpose,
22
+ idempotencyKey: params.idempotencyKey,
23
+ },
24
+ });
25
+ }
26
+ async previewPay(actorId, params) {
27
+ return this.transport.request({
28
+ path: `/api/actors/${encodeURIComponent(actorId)}/preview-pay`,
29
+ method: 'POST',
30
+ body: {
31
+ target: params.target,
32
+ amount: parseUsdc(params.amount).toString(),
33
+ purpose: params.purpose,
34
+ },
35
+ });
36
+ }
37
+ async status(actorId) {
38
+ return this.transport.request({
39
+ path: `/api/actors/${encodeURIComponent(actorId)}`,
40
+ method: 'GET',
41
+ });
42
+ }
43
+ }
44
+ //# sourceMappingURL=actor-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor-client.js","sourceRoot":"","sources":["../src/actor-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAW3C,MAAM,OAAO,WAAW;IACO;IAA7B,YAA6B,SAA0B;QAA1B,cAAS,GAAT,SAAS,CAAiB;IAAG,CAAC;IAE3D,KAAK,CAAC,MAAM,CAAC,MAAyB;QACpC,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAe;YAC1C,IAAI,EAAE,aAAa;YACnB,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;SACb,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,OAAe,EAAE,MAAiB;QAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAmB;YAC9C,IAAI,EAAE,eAAe,kBAAkB,CAAC,OAAO,CAAC,MAAM;YACtD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;gBAC3C,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,cAAc,EAAE,MAAM,CAAC,cAAc;aACtC;SACF,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,UAAU,CACd,OAAe,EACf,MAAwB;QAExB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAiD;YAC5E,IAAI,EAAE,eAAe,kBAAkB,CAAC,OAAO,CAAC,cAAc;YAC9D,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;gBAC3C,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB;SACF,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAc;YACzC,IAAI,EAAE,eAAe,kBAAkB,CAAC,OAAO,CAAC,EAAE;YAClD,MAAM,EAAE,KAAK;SACd,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import type { BundlerClientConfig, GasEstimate, UserOperation, UserOperationByHash, UserOperationReceipt } from '../types.js';
2
+ export declare class BundlerClient {
3
+ private readonly config;
4
+ private readonly timeoutMs;
5
+ private readonly pollingIntervalMs;
6
+ private readonly maxRetries;
7
+ private readonly logger;
8
+ private readonly fetchImplementation;
9
+ constructor(config: BundlerClientConfig);
10
+ estimateUserOperationGas(userOperation: UserOperation): Promise<GasEstimate>;
11
+ sendUserOperation(userOperation: UserOperation): Promise<`0x${string}`>;
12
+ getUserOperationReceipt(hash: `0x${string}`, options?: {
13
+ pollingIntervalMs?: number;
14
+ timeoutMs?: number;
15
+ }): Promise<UserOperationReceipt>;
16
+ getUserOperationByHash(hash: `0x${string}`): Promise<UserOperationByHash>;
17
+ private requestWithFallback;
18
+ private requestWithProvider;
19
+ }
20
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/bundler/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EAEnB,WAAW,EAKX,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,aAAa,CAAA;AAiFpB,qBAAa,aAAa;IAOZ,OAAO,CAAC,QAAQ,CAAC,MAAM;IANnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAQ;IAC1C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;IAClC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAc;gBAErB,MAAM,EAAE,mBAAmB;IAQlD,wBAAwB,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC;IAqB5E,iBAAiB,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC;IAOvE,uBAAuB,CAC3B,IAAI,EAAE,KAAK,MAAM,EAAE,EACnB,OAAO,GAAE;QAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAC/D,OAAO,CAAC,oBAAoB,CAAC;IAqD1B,sBAAsB,CAAC,IAAI,EAAE,KAAK,MAAM,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAkBjE,mBAAmB;YA0BnB,mBAAmB;CAqElC"}
@@ -0,0 +1,228 @@
1
+ import { ExecutionError, GasEstimationError, NetworkError, ValidationError } from '@brninpay/core';
2
+ const defaultLogger = {
3
+ debug: () => undefined,
4
+ info: () => undefined,
5
+ warn: () => undefined,
6
+ error: () => undefined,
7
+ };
8
+ function sleep(ms) {
9
+ return new Promise((resolve) => setTimeout(resolve, ms));
10
+ }
11
+ function bigintToHex(value) {
12
+ return `0x${value.toString(16)}`;
13
+ }
14
+ function numberToHex(value) {
15
+ return bigintToHex(BigInt(value));
16
+ }
17
+ function hexToBigInt(value) {
18
+ if (value === undefined) {
19
+ return 0n;
20
+ }
21
+ if (typeof value === 'bigint') {
22
+ return value;
23
+ }
24
+ return BigInt(value);
25
+ }
26
+ function serializeUserOperation(userOperation) {
27
+ if (userOperation.version === 'v0.6') {
28
+ return {
29
+ sender: userOperation.sender,
30
+ nonce: bigintToHex(userOperation.nonce),
31
+ initCode: userOperation.initCode,
32
+ callData: userOperation.callData,
33
+ callGasLimit: bigintToHex(userOperation.callGasLimit),
34
+ verificationGasLimit: bigintToHex(userOperation.verificationGasLimit),
35
+ preVerificationGas: bigintToHex(userOperation.preVerificationGas),
36
+ maxFeePerGas: bigintToHex(userOperation.maxFeePerGas),
37
+ maxPriorityFeePerGas: bigintToHex(userOperation.maxPriorityFeePerGas),
38
+ paymasterAndData: userOperation.paymasterAndData,
39
+ signature: userOperation.signature,
40
+ };
41
+ }
42
+ return {
43
+ sender: userOperation.sender,
44
+ nonce: bigintToHex(userOperation.nonce),
45
+ factory: userOperation.factory,
46
+ factoryData: userOperation.factoryData,
47
+ callData: userOperation.callData,
48
+ callGasLimit: bigintToHex(userOperation.callGasLimit),
49
+ verificationGasLimit: bigintToHex(userOperation.verificationGasLimit),
50
+ preVerificationGas: bigintToHex(userOperation.preVerificationGas),
51
+ maxFeePerGas: bigintToHex(userOperation.maxFeePerGas),
52
+ maxPriorityFeePerGas: bigintToHex(userOperation.maxPriorityFeePerGas),
53
+ paymaster: userOperation.paymaster,
54
+ paymasterVerificationGasLimit: bigintToHex(userOperation.paymasterVerificationGasLimit),
55
+ paymasterPostOpGasLimit: bigintToHex(userOperation.paymasterPostOpGasLimit),
56
+ paymasterData: userOperation.paymasterData,
57
+ signature: userOperation.signature,
58
+ };
59
+ }
60
+ function mapJsonRpcError(error, method) {
61
+ if (method === 'eth_estimateUserOperationGas') {
62
+ return new GasEstimationError(error.message, error.data);
63
+ }
64
+ return new ExecutionError('bundler_rpc_error', error.message, {
65
+ method,
66
+ code: error.code,
67
+ data: error.data,
68
+ });
69
+ }
70
+ export class BundlerClient {
71
+ config;
72
+ timeoutMs;
73
+ pollingIntervalMs;
74
+ maxRetries;
75
+ logger;
76
+ fetchImplementation;
77
+ constructor(config) {
78
+ this.config = config;
79
+ this.timeoutMs = config.timeoutMs ?? 15_000;
80
+ this.pollingIntervalMs = config.pollingIntervalMs ?? 2_000;
81
+ this.maxRetries = config.maxRetries ?? 1;
82
+ this.logger = config.logger ?? defaultLogger;
83
+ this.fetchImplementation = config.fetchImplementation ?? fetch.bind(globalThis);
84
+ }
85
+ async estimateUserOperationGas(userOperation) {
86
+ const result = await this.requestWithFallback('eth_estimateUserOperationGas', [serializeUserOperation(userOperation), this.config.entryPointAddress]);
87
+ return {
88
+ callGasLimit: hexToBigInt(result.callGasLimit),
89
+ verificationGasLimit: hexToBigInt(result.verificationGasLimit),
90
+ preVerificationGas: hexToBigInt(result.preVerificationGas),
91
+ maxFeePerGas: userOperation.maxFeePerGas,
92
+ maxPriorityFeePerGas: userOperation.maxPriorityFeePerGas,
93
+ paymasterVerificationGasLimit: result.paymasterVerificationGasLimit
94
+ ? hexToBigInt(result.paymasterVerificationGasLimit)
95
+ : undefined,
96
+ paymasterPostOpGasLimit: result.paymasterPostOpGasLimit
97
+ ? hexToBigInt(result.paymasterPostOpGasLimit)
98
+ : undefined,
99
+ };
100
+ }
101
+ async sendUserOperation(userOperation) {
102
+ return this.requestWithFallback('eth_sendUserOperation', [
103
+ serializeUserOperation(userOperation),
104
+ this.config.entryPointAddress,
105
+ ]);
106
+ }
107
+ async getUserOperationReceipt(hash, options = {}) {
108
+ const startedAt = Date.now();
109
+ const pollingIntervalMs = options.pollingIntervalMs ?? this.pollingIntervalMs;
110
+ const timeoutMs = options.timeoutMs ?? 60_000;
111
+ while (true) {
112
+ const receipt = await this.requestWithFallback('eth_getUserOperationReceipt', [hash], {
113
+ allowNotFound: true,
114
+ });
115
+ if (receipt) {
116
+ return {
117
+ userOpHash: receipt.userOpHash,
118
+ sender: receipt.sender,
119
+ nonce: BigInt(receipt.nonce),
120
+ actualGasCost: BigInt(receipt.actualGasCost),
121
+ actualGasUsed: BigInt(receipt.actualGasUsed),
122
+ success: receipt.success,
123
+ entryPoint: receipt.entryPoint,
124
+ receipt: {
125
+ transactionHash: receipt.receipt.transactionHash,
126
+ blockHash: receipt.receipt.blockHash,
127
+ blockNumber: BigInt(receipt.receipt.blockNumber),
128
+ },
129
+ logs: receipt.logs,
130
+ };
131
+ }
132
+ if (Date.now() - startedAt >= timeoutMs) {
133
+ throw new ValidationError('Timed out while waiting for user operation receipt', {
134
+ hash,
135
+ timeoutMs,
136
+ });
137
+ }
138
+ await sleep(pollingIntervalMs);
139
+ }
140
+ }
141
+ async getUserOperationByHash(hash) {
142
+ const result = await this.requestWithFallback('eth_getUserOperationByHash', [hash]);
143
+ return {
144
+ blockHash: result.blockHash,
145
+ blockNumber: BigInt(result.blockNumber),
146
+ entryPoint: result.entryPoint,
147
+ transactionHash: result.transactionHash,
148
+ userOperation: result.userOperation,
149
+ };
150
+ }
151
+ async requestWithFallback(method, params, options = {}) {
152
+ const providers = [this.config.primary, this.config.secondary].filter((provider) => Boolean(provider));
153
+ let lastError;
154
+ for (const provider of providers) {
155
+ try {
156
+ return await this.requestWithProvider(provider, method, params, options);
157
+ }
158
+ catch (error) {
159
+ lastError = error instanceof Error ? error : new Error(String(error));
160
+ this.logger.warn('Bundler provider failed', {
161
+ provider: provider.name,
162
+ method,
163
+ error: lastError.message,
164
+ });
165
+ }
166
+ }
167
+ throw lastError ?? new ExecutionError('bundler_failure', `Bundler request ${method} failed`);
168
+ }
169
+ async requestWithProvider(provider, method, params, options) {
170
+ const body = JSON.stringify({
171
+ jsonrpc: '2.0',
172
+ id: Date.now(),
173
+ method,
174
+ params,
175
+ });
176
+ let attempt = 0;
177
+ while (true) {
178
+ attempt += 1;
179
+ const controller = new AbortController();
180
+ const timeoutId = setTimeout(() => controller.abort('Bundler request timed out'), this.timeoutMs);
181
+ try {
182
+ const response = await this.fetchImplementation(provider.url, {
183
+ method: 'POST',
184
+ headers: {
185
+ 'Content-Type': 'application/json',
186
+ ...(provider.headers ?? {}),
187
+ },
188
+ body,
189
+ signal: controller.signal,
190
+ });
191
+ if (!response.ok) {
192
+ throw new NetworkError(`Bundler HTTP ${response.status}: ${response.statusText}`, {
193
+ provider: provider.name,
194
+ method,
195
+ });
196
+ }
197
+ const payload = (await response.json());
198
+ if ('error' in payload) {
199
+ if (options.allowNotFound && payload.error.code === -32001) {
200
+ return null;
201
+ }
202
+ throw mapJsonRpcError(payload.error, method);
203
+ }
204
+ return payload.result;
205
+ }
206
+ catch (error) {
207
+ if (attempt > this.maxRetries + 1) {
208
+ throw error;
209
+ }
210
+ if (error instanceof Error && error.name === 'AbortError') {
211
+ throw new NetworkError('Bundler request timed out', {
212
+ provider: provider.name,
213
+ method,
214
+ });
215
+ }
216
+ if (error instanceof NetworkError) {
217
+ await sleep(250 * attempt);
218
+ continue;
219
+ }
220
+ throw error;
221
+ }
222
+ finally {
223
+ clearTimeout(timeoutId);
224
+ }
225
+ }
226
+ }
227
+ }
228
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/bundler/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAclG,MAAM,aAAa,GAAc;IAC/B,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS;IACtB,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS;IACrB,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS;IACrB,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS;CACvB,CAAA;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAA;AAClC,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;AACnC,CAAC;AAED,SAAS,WAAW,CAAC,KAAkC;IACrD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,CAAA;IACX,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,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f,IAAI,OAAO,GAAG,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;oBAClC,MAAM,KAAK,CAAA;gBACb,CAAC;gBAED,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBAC1D,MAAM,IAAI,YAAY,CAAC,2BAA2B,EAAE;wBAClD,QAAQ,EAAE,QAAQ,CAAC,IAAI;wBACvB,MAAM;qBACP,CAAC,CAAA;gBACJ,CAAC;gBAED,IAAI,KAAK,YAAY,YAAY,EAAE,CAAC;oBAClC,MAAM,KAAK,CAAC,GAAG,GAAG,OAAO,CAAC,CAAA;oBAC1B,SAAQ;gBACV,CAAC;gBAED,MAAM,KAAK,CAAA;YACb,CAAC;oBAAS,CAAC;gBACT,YAAY,CAAC,SAAS,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ import type { AlchemyBundlerProviderParams, BundlerProviderConfig } from '../../types.js';
2
+ export declare function createAlchemyBundlerProvider(params: AlchemyBundlerProviderParams): BundlerProviderConfig;
3
+ //# sourceMappingURL=alchemy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alchemy.d.ts","sourceRoot":"","sources":["../../../src/bundler/providers/alchemy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAEzF,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,4BAA4B,GACnC,qBAAqB,CAevB"}
@@ -0,0 +1,15 @@
1
+ import { ValidationError } from '@brninpay/core';
2
+ export function createAlchemyBundlerProvider(params) {
3
+ if (!params.apiKey.trim()) {
4
+ throw new ValidationError('Alchemy bundler provider requires a non-empty apiKey');
5
+ }
6
+ if (!params.url && !params.network?.trim()) {
7
+ throw new ValidationError('Alchemy bundler provider requires either a url or network');
8
+ }
9
+ return {
10
+ name: 'alchemy',
11
+ url: params.url ??
12
+ `https://${params.network}.g.alchemy.com/v2/${encodeURIComponent(params.apiKey)}`,
13
+ };
14
+ }
15
+ //# sourceMappingURL=alchemy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alchemy.js","sourceRoot":"","sources":["../../../src/bundler/providers/alchemy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGhD,MAAM,UAAU,4BAA4B,CAC1C,MAAoC;IAEpC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QAC1B,MAAM,IAAI,eAAe,CAAC,sDAAsD,CAAC,CAAA;IACnF,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;QAC3C,MAAM,IAAI,eAAe,CAAC,2DAA2D,CAAC,CAAA;IACxF,CAAC;IAED,OAAO;QACL,IAAI,EAAE,SAAS;QACf,GAAG,EACD,MAAM,CAAC,GAAG;YACV,WAAW,MAAM,CAAC,OAAO,qBAAqB,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;KACpF,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { BundlerProviderConfig, PimlicoBundlerProviderParams } from '../../types.js';
2
+ export declare function createPimlicoBundlerProvider(params: PimlicoBundlerProviderParams): BundlerProviderConfig;
3
+ //# sourceMappingURL=pimlico.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pimlico.d.ts","sourceRoot":"","sources":["../../../src/bundler/providers/pimlico.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAEzF,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,4BAA4B,GACnC,qBAAqB,CAWvB"}
@@ -0,0 +1,12 @@
1
+ import { ValidationError } from '@brninpay/core';
2
+ export function createPimlicoBundlerProvider(params) {
3
+ if (!params.apiKey.trim()) {
4
+ throw new ValidationError('Pimlico bundler provider requires a non-empty apiKey');
5
+ }
6
+ return {
7
+ name: 'pimlico',
8
+ url: params.url ??
9
+ `https://api.pimlico.io/v2/${params.chainId}/rpc?apikey=${encodeURIComponent(params.apiKey)}`,
10
+ };
11
+ }
12
+ //# sourceMappingURL=pimlico.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../../src/bundler/providers/pimlico.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGhD,MAAM,UAAU,4BAA4B,CAC1C,MAAoC;IAEpC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QAC1B,MAAM,IAAI,eAAe,CAAC,sDAAsD,CAAC,CAAA;IACnF,CAAC;IAED,OAAO;QACL,IAAI,EAAE,SAAS;QACf,GAAG,EACD,MAAM,CAAC,GAAG;YACV,6BAA6B,MAAM,CAAC,OAAO,eAAe,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;KAChG,CAAA;AACH,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { ActorClient } from './actor-client.js';
2
+ import { PaymentIntentClient } from './modules/payment-intents.js';
3
+ import { PolicyClient } from './modules/policies.js';
4
+ import type { ClientRequestOptions, ClientTransport, RequestInterceptor, ResponseInterceptor, RetryPolicy, RuntimeeConfig, SdkLogger } from './types.js';
5
+ export declare class BrninpayClient implements ClientTransport {
6
+ readonly actors: ActorClient;
7
+ readonly paymentIntents: PaymentIntentClient;
8
+ readonly policies: PolicyClient;
9
+ protected readonly fetchImplementation: typeof fetch;
10
+ protected readonly logger: SdkLogger;
11
+ protected readonly baseUrl: URL;
12
+ protected readonly apiKey: string;
13
+ protected readonly apiSecret?: string;
14
+ protected readonly timeoutMs: number;
15
+ protected readonly defaultHeaders: Record<string, string>;
16
+ protected readonly retryPolicy: RetryPolicy;
17
+ protected readonly requestInterceptors: RequestInterceptor[];
18
+ protected readonly responseInterceptors: ResponseInterceptor[];
19
+ constructor(config: RuntimeeConfig);
20
+ request<T>(options: ClientRequestOptions): Promise<T>;
21
+ private executeRequest;
22
+ private applyAuthentication;
23
+ }
24
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAEV,oBAAoB,EACpB,eAAe,EAEf,kBAAkB,EAElB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,SAAS,EACV,MAAM,YAAY,CAAA;AA2OnB,qBAAa,cAAe,YAAW,eAAe;IACpD,SAAgB,MAAM,EAAE,WAAW,CAAA;IACnC,SAAgB,cAAc,EAAE,mBAAmB,CAAA;IACnD,SAAgB,QAAQ,EAAE,YAAY,CAAA;IAEtC,SAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE,OAAO,KAAK,CAAA;IACpD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IACpC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAA;IAC/B,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACjC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IACrC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IACpC,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzD,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;IAC3C,SAAS,CAAC,QAAQ,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