ox 1.0.2 → 1.0.4

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 (64) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/tempo/EarnShares.d.ts +179 -0
  3. package/dist/tempo/EarnShares.d.ts.map +1 -0
  4. package/dist/tempo/EarnShares.js +160 -0
  5. package/dist/tempo/EarnShares.js.map +1 -0
  6. package/dist/tempo/KeyAuthorization.d.ts +22 -16
  7. package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
  8. package/dist/tempo/KeyAuthorization.js +31 -7
  9. package/dist/tempo/KeyAuthorization.js.map +1 -1
  10. package/dist/tempo/MultisigConfig.d.ts +8 -4
  11. package/dist/tempo/MultisigConfig.d.ts.map +1 -1
  12. package/dist/tempo/MultisigConfig.js +16 -4
  13. package/dist/tempo/MultisigConfig.js.map +1 -1
  14. package/dist/tempo/SignatureEnvelope.d.ts +31 -13
  15. package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
  16. package/dist/tempo/SignatureEnvelope.js +172 -55
  17. package/dist/tempo/SignatureEnvelope.js.map +1 -1
  18. package/dist/tempo/index.d.ts +22 -0
  19. package/dist/tempo/index.d.ts.map +1 -1
  20. package/dist/tempo/index.js +22 -0
  21. package/dist/tempo/index.js.map +1 -1
  22. package/dist/zod/tempo/AuthorizationTempo.d.ts +70 -60
  23. package/dist/zod/tempo/AuthorizationTempo.d.ts.map +1 -1
  24. package/dist/zod/tempo/KeyAuthorization.d.ts +0 -306
  25. package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
  26. package/dist/zod/tempo/KeyAuthorization.js +2 -2
  27. package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
  28. package/dist/zod/tempo/MultisigConfig.d.ts.map +1 -1
  29. package/dist/zod/tempo/MultisigConfig.js +5 -2
  30. package/dist/zod/tempo/MultisigConfig.js.map +1 -1
  31. package/dist/zod/tempo/RpcSchemaTempo.d.ts +28 -132
  32. package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
  33. package/dist/zod/tempo/SignatureEnvelope.d.ts +79 -18
  34. package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
  35. package/dist/zod/tempo/SignatureEnvelope.js +39 -11
  36. package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
  37. package/dist/zod/tempo/Transaction.d.ts +84 -396
  38. package/dist/zod/tempo/Transaction.d.ts.map +1 -1
  39. package/dist/zod/tempo/TransactionRequest.d.ts +42 -234
  40. package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
  41. package/dist/zod/tempo/TxEnvelopeTempo.d.ts +0 -108
  42. package/dist/zod/tempo/TxEnvelopeTempo.d.ts.map +1 -1
  43. package/package.json +6 -1
  44. package/src/tempo/EarnShares.test.ts +120 -0
  45. package/src/tempo/EarnShares.ts +235 -0
  46. package/src/tempo/KeyAuthorization.test-d.ts +62 -0
  47. package/src/tempo/KeyAuthorization.test.ts +53 -0
  48. package/src/tempo/KeyAuthorization.ts +69 -27
  49. package/src/tempo/MultisigConfig.test.ts +34 -2
  50. package/src/tempo/MultisigConfig.ts +18 -4
  51. package/src/tempo/SignatureEnvelope.test-d.ts +97 -0
  52. package/src/tempo/SignatureEnvelope.test.ts +247 -36
  53. package/src/tempo/SignatureEnvelope.ts +271 -85
  54. package/src/tempo/e2e.test.ts +0 -416
  55. package/src/tempo/index.ts +22 -0
  56. package/src/tempo/multisig.e2e.test.ts +582 -0
  57. package/src/version.ts +1 -1
  58. package/src/zod/tempo/KeyAuthorization.ts +2 -2
  59. package/src/zod/tempo/MultisigConfig.ts +13 -5
  60. package/src/zod/tempo/SignatureEnvelope.ts +81 -18
  61. package/src/zod/tempo/_test/KeyAuthorization.test.ts +25 -0
  62. package/src/zod/tempo/_test/MultisigConfig.test.ts +44 -0
  63. package/src/zod/tempo/_test/SignatureEnvelope.test-d.ts +9 -0
  64. package/src/zod/tempo/_test/SignatureEnvelope.test.ts +142 -6
@@ -189,24 +189,6 @@ export declare const TxEnvelopeTempo: z.ZodMiniObject<{
189
189
  s: z.ZodMiniTemplateLiteral<`0x${string}`>;
190
190
  }, z.core.$strip>;
191
191
  type: z.ZodMiniLiteral<"webAuthn">;
192
- }, z.core.$strip>, z.ZodMiniObject<{
193
- inner: z.ZodMiniLazy<z.ZodMiniType<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown, z.core.$ZodTypeInternals<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown>>>;
194
- keyId: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
195
- type: z.ZodMiniLiteral<"keychain">;
196
- userAddress: z.ZodMiniTemplateLiteral<`0x${string}`>;
197
- version: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"v1">, z.ZodMiniLiteral<"v2">]>>;
198
- }, z.core.$strip>, z.ZodMiniObject<{
199
- account: z.ZodMiniTemplateLiteral<`0x${string}`>;
200
- init: z.ZodMiniOptional<z.ZodMiniObject<{
201
- salt: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
202
- threshold: z.ZodMiniNumber<number>;
203
- owners: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniObject<{
204
- owner: z.ZodMiniTemplateLiteral<`0x${string}`>;
205
- weight: z.ZodMiniNumber<number>;
206
- }, z.core.$strip>>>;
207
- }, z.core.$strip>>;
208
- signatures: z.ZodMiniLazy<z.ZodMiniType<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown, z.core.$ZodTypeInternals<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown>>>;
209
- type: z.ZodMiniLiteral<"multisig">;
210
192
  }, z.core.$strip>]>;
211
193
  type: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"secp256k1">, z.ZodMiniLiteral<"p256">, z.ZodMiniLiteral<"webAuthn">]>;
212
194
  witness: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
@@ -258,24 +240,6 @@ export declare const TxEnvelopeTempo: z.ZodMiniObject<{
258
240
  s: z.ZodMiniTemplateLiteral<`0x${string}`>;
259
241
  }, z.core.$strip>;
260
242
  type: z.ZodMiniLiteral<"webAuthn">;
261
- }, z.core.$strip>, z.ZodMiniObject<{
262
- inner: z.ZodMiniLazy<z.ZodMiniType<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown, z.core.$ZodTypeInternals<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown>>>;
263
- keyId: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
264
- type: z.ZodMiniLiteral<"keychain">;
265
- userAddress: z.ZodMiniTemplateLiteral<`0x${string}`>;
266
- version: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"v1">, z.ZodMiniLiteral<"v2">]>>;
267
- }, z.core.$strip>, z.ZodMiniObject<{
268
- account: z.ZodMiniTemplateLiteral<`0x${string}`>;
269
- init: z.ZodMiniOptional<z.ZodMiniObject<{
270
- salt: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
271
- threshold: z.ZodMiniNumber<number>;
272
- owners: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniObject<{
273
- owner: z.ZodMiniTemplateLiteral<`0x${string}`>;
274
- weight: z.ZodMiniNumber<number>;
275
- }, z.core.$strip>>>;
276
- }, z.core.$strip>>;
277
- signatures: z.ZodMiniLazy<z.ZodMiniType<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown, z.core.$ZodTypeInternals<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown>>>;
278
- type: z.ZodMiniLiteral<"multisig">;
279
243
  }, z.core.$strip>]>;
280
244
  type: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"secp256k1">, z.ZodMiniLiteral<"p256">, z.ZodMiniLiteral<"webAuthn">]>;
281
245
  witness: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
@@ -470,24 +434,6 @@ export declare const Signed: z.ZodMiniObject<{
470
434
  s: z.ZodMiniTemplateLiteral<`0x${string}`>;
471
435
  }, z.core.$strip>;
472
436
  type: z.ZodMiniLiteral<"webAuthn">;
473
- }, z.core.$strip>, z.ZodMiniObject<{
474
- inner: z.ZodMiniLazy<z.ZodMiniType<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown, z.core.$ZodTypeInternals<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown>>>;
475
- keyId: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
476
- type: z.ZodMiniLiteral<"keychain">;
477
- userAddress: z.ZodMiniTemplateLiteral<`0x${string}`>;
478
- version: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"v1">, z.ZodMiniLiteral<"v2">]>>;
479
- }, z.core.$strip>, z.ZodMiniObject<{
480
- account: z.ZodMiniTemplateLiteral<`0x${string}`>;
481
- init: z.ZodMiniOptional<z.ZodMiniObject<{
482
- salt: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
483
- threshold: z.ZodMiniNumber<number>;
484
- owners: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniObject<{
485
- owner: z.ZodMiniTemplateLiteral<`0x${string}`>;
486
- weight: z.ZodMiniNumber<number>;
487
- }, z.core.$strip>>>;
488
- }, z.core.$strip>>;
489
- signatures: z.ZodMiniLazy<z.ZodMiniType<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown, z.core.$ZodTypeInternals<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown>>>;
490
- type: z.ZodMiniLiteral<"multisig">;
491
437
  }, z.core.$strip>]>;
492
438
  type: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"secp256k1">, z.ZodMiniLiteral<"p256">, z.ZodMiniLiteral<"webAuthn">]>;
493
439
  witness: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
@@ -539,24 +485,6 @@ export declare const Signed: z.ZodMiniObject<{
539
485
  s: z.ZodMiniTemplateLiteral<`0x${string}`>;
540
486
  }, z.core.$strip>;
541
487
  type: z.ZodMiniLiteral<"webAuthn">;
542
- }, z.core.$strip>, z.ZodMiniObject<{
543
- inner: z.ZodMiniLazy<z.ZodMiniType<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown, z.core.$ZodTypeInternals<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown>>>;
544
- keyId: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
545
- type: z.ZodMiniLiteral<"keychain">;
546
- userAddress: z.ZodMiniTemplateLiteral<`0x${string}`>;
547
- version: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"v1">, z.ZodMiniLiteral<"v2">]>>;
548
- }, z.core.$strip>, z.ZodMiniObject<{
549
- account: z.ZodMiniTemplateLiteral<`0x${string}`>;
550
- init: z.ZodMiniOptional<z.ZodMiniObject<{
551
- salt: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
552
- threshold: z.ZodMiniNumber<number>;
553
- owners: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniObject<{
554
- owner: z.ZodMiniTemplateLiteral<`0x${string}`>;
555
- weight: z.ZodMiniNumber<number>;
556
- }, z.core.$strip>>>;
557
- }, z.core.$strip>>;
558
- signatures: z.ZodMiniLazy<z.ZodMiniType<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown, z.core.$ZodTypeInternals<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown>>>;
559
- type: z.ZodMiniLiteral<"multisig">;
560
488
  }, z.core.$strip>]>;
561
489
  type: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"secp256k1">, z.ZodMiniLiteral<"p256">, z.ZodMiniLiteral<"webAuthn">]>;
562
490
  witness: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
@@ -751,24 +679,6 @@ export declare const serialized: z.ZodMiniCodec<z.ZodMiniTemplateLiteral<`0x${st
751
679
  s: z.ZodMiniTemplateLiteral<`0x${string}`>;
752
680
  }, z.core.$strip>;
753
681
  type: z.ZodMiniLiteral<"webAuthn">;
754
- }, z.core.$strip>, z.ZodMiniObject<{
755
- inner: z.ZodMiniLazy<z.ZodMiniType<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown, z.core.$ZodTypeInternals<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown>>>;
756
- keyId: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
757
- type: z.ZodMiniLiteral<"keychain">;
758
- userAddress: z.ZodMiniTemplateLiteral<`0x${string}`>;
759
- version: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"v1">, z.ZodMiniLiteral<"v2">]>>;
760
- }, z.core.$strip>, z.ZodMiniObject<{
761
- account: z.ZodMiniTemplateLiteral<`0x${string}`>;
762
- init: z.ZodMiniOptional<z.ZodMiniObject<{
763
- salt: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
764
- threshold: z.ZodMiniNumber<number>;
765
- owners: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniObject<{
766
- owner: z.ZodMiniTemplateLiteral<`0x${string}`>;
767
- weight: z.ZodMiniNumber<number>;
768
- }, z.core.$strip>>>;
769
- }, z.core.$strip>>;
770
- signatures: z.ZodMiniLazy<z.ZodMiniType<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown, z.core.$ZodTypeInternals<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown>>>;
771
- type: z.ZodMiniLiteral<"multisig">;
772
682
  }, z.core.$strip>]>;
773
683
  type: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"secp256k1">, z.ZodMiniLiteral<"p256">, z.ZodMiniLiteral<"webAuthn">]>;
774
684
  witness: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
@@ -820,24 +730,6 @@ export declare const serialized: z.ZodMiniCodec<z.ZodMiniTemplateLiteral<`0x${st
820
730
  s: z.ZodMiniTemplateLiteral<`0x${string}`>;
821
731
  }, z.core.$strip>;
822
732
  type: z.ZodMiniLiteral<"webAuthn">;
823
- }, z.core.$strip>, z.ZodMiniObject<{
824
- inner: z.ZodMiniLazy<z.ZodMiniType<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown, z.core.$ZodTypeInternals<import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>, unknown>>>;
825
- keyId: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
826
- type: z.ZodMiniLiteral<"keychain">;
827
- userAddress: z.ZodMiniTemplateLiteral<`0x${string}`>;
828
- version: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"v1">, z.ZodMiniLiteral<"v2">]>>;
829
- }, z.core.$strip>, z.ZodMiniObject<{
830
- account: z.ZodMiniTemplateLiteral<`0x${string}`>;
831
- init: z.ZodMiniOptional<z.ZodMiniObject<{
832
- salt: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
833
- threshold: z.ZodMiniNumber<number>;
834
- owners: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniObject<{
835
- owner: z.ZodMiniTemplateLiteral<`0x${string}`>;
836
- weight: z.ZodMiniNumber<number>;
837
- }, z.core.$strip>>>;
838
- }, z.core.$strip>>;
839
- signatures: z.ZodMiniLazy<z.ZodMiniType<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown, z.core.$ZodTypeInternals<readonly import("../../tempo/SignatureEnvelope.js").SignatureEnvelope<number>[], unknown>>>;
840
- type: z.ZodMiniLiteral<"multisig">;
841
733
  }, z.core.$strip>]>;
842
734
  type: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"secp256k1">, z.ZodMiniLiteral<"p256">, z.ZodMiniLiteral<"webAuthn">]>;
843
735
  witness: z.ZodMiniOptional<z.ZodMiniTemplateLiteral<`0x${string}`>>;
@@ -1 +1 @@
1
- {"version":3,"file":"TxEnvelopeTempo.d.ts","sourceRoot":"","sources":["../../../src/zod/tempo/TxEnvelopeTempo.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAY7B,8CAA8C;AAC9C,eAAO,MAAM,IAAI,2BAAqB,CAAA;AAEtC,qCAAqC;AACrC,eAAO,MAAM,IAAI;;;;iBAIf,CAAA;AAqBF,yCAAyC;AACzC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAG1B,CAAA;AAEF,gDAAgD;AAChD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGjB,CAAA;AAEF,yFAAyF;AACzF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBASrB,CAAA"}
1
+ {"version":3,"file":"TxEnvelopeTempo.d.ts","sourceRoot":"","sources":["../../../src/zod/tempo/TxEnvelopeTempo.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAY7B,8CAA8C;AAC9C,eAAO,MAAM,IAAI,2BAAqB,CAAA;AAEtC,qCAAqC;AACrC,eAAO,MAAM,IAAI;;;;iBAIf,CAAA;AAqBF,yCAAyC;AACzC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAG1B,CAAA;AAEF,gDAAgD;AAChD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGjB,CAAA;AAEF,yFAAyF;AACzF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBASrB,CAAA"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "ox",
3
3
  "description": "Ethereum Standard Library",
4
4
  "type": "module",
5
- "version": "1.0.2",
5
+ "version": "1.0.4",
6
6
  "main": "./dist/index.js",
7
7
  "sideEffects": false,
8
8
  "license": "MIT",
@@ -520,6 +520,11 @@
520
520
  "types": "./dist/tempo/Channel.d.ts",
521
521
  "default": "./dist/tempo/Channel.js"
522
522
  },
523
+ "./tempo/EarnShares": {
524
+ "src": "./src/tempo/EarnShares.ts",
525
+ "types": "./dist/tempo/EarnShares.d.ts",
526
+ "default": "./dist/tempo/EarnShares.js"
527
+ },
523
528
  "./tempo/KeyAuthorization": {
524
529
  "src": "./src/tempo/KeyAuthorization.ts",
525
530
  "types": "./dist/tempo/KeyAuthorization.d.ts",
@@ -0,0 +1,120 @@
1
+ import { EarnShares } from 'ox/tempo'
2
+ import { describe, expect, test } from 'vite-plus/test'
3
+
4
+ const anchor = { engineShares: 3n, shareSupply: 2n } as const
5
+
6
+ describe('toAmount', () => {
7
+ test('default', () => {
8
+ expect(EarnShares.toAmount(anchor, 7n)).toBe(4n)
9
+ })
10
+
11
+ test('behavior: rounds down', () => {
12
+ expect(EarnShares.toAmount({ engineShares: 3n, shareSupply: 1n }, 2n)).toBe(
13
+ 0n,
14
+ )
15
+ })
16
+ })
17
+
18
+ describe('toAmountUp', () => {
19
+ test('default', () => {
20
+ expect(EarnShares.toAmountUp(anchor, 7n)).toBe(5n)
21
+ })
22
+
23
+ test('behavior: exact conversions do not round up', () => {
24
+ expect(EarnShares.toAmountUp(anchor, 3n)).toBe(2n)
25
+ })
26
+ })
27
+
28
+ describe('toVenueAmount', () => {
29
+ test('default', () => {
30
+ expect(EarnShares.toVenueAmount(anchor, 7n)).toBe(10n)
31
+ })
32
+
33
+ test('behavior: identity at the initial 1:1 anchor', () => {
34
+ expect(
35
+ EarnShares.toVenueAmount({ engineShares: 1n, shareSupply: 1n }, 12_345n),
36
+ ).toBe(12_345n)
37
+ })
38
+ })
39
+
40
+ describe('feeShares', () => {
41
+ test('default', () => {
42
+ expect(
43
+ EarnShares.feeShares({
44
+ activeAssets: 1_100n,
45
+ shareSupply: 1_000n,
46
+ totalFeeAssets: 100n,
47
+ }),
48
+ ).toBe(100n)
49
+ })
50
+
51
+ test('behavior: zero fee mints nothing', () => {
52
+ expect(
53
+ EarnShares.feeShares({
54
+ activeAssets: 1_100n,
55
+ shareSupply: 1_000n,
56
+ totalFeeAssets: 0n,
57
+ }),
58
+ ).toBe(0n)
59
+ })
60
+
61
+ test('behavior: fee at or above active assets mints nothing', () => {
62
+ expect(
63
+ EarnShares.feeShares({
64
+ activeAssets: 100n,
65
+ shareSupply: 1_000n,
66
+ totalFeeAssets: 100n,
67
+ }),
68
+ ).toBe(0n)
69
+ })
70
+
71
+ test('behavior: rounds down', () => {
72
+ expect(
73
+ EarnShares.feeShares({
74
+ activeAssets: 1_000n,
75
+ shareSupply: 999n,
76
+ totalFeeAssets: 100n,
77
+ }),
78
+ ).toBe(111n)
79
+ })
80
+ })
81
+
82
+ describe('minimumOutput', () => {
83
+ test('default', () => {
84
+ expect(EarnShares.minimumOutput(1_000_000n, 50)).toBe(995_000n)
85
+ })
86
+
87
+ test('behavior: zero slippage returns the expected output', () => {
88
+ expect(EarnShares.minimumOutput(1_000_000n, 0)).toBe(1_000_000n)
89
+ })
90
+
91
+ test('behavior: floors to 1n', () => {
92
+ expect(EarnShares.minimumOutput(1n, 9_999)).toBe(1n)
93
+ })
94
+
95
+ test('error: non-positive expected output', () => {
96
+ expect(() =>
97
+ EarnShares.minimumOutput(0n, 50),
98
+ ).toThrowErrorMatchingInlineSnapshot(
99
+ `[EarnShares.InvalidExpectedOutputError: Expected output \`0\` must be greater than zero.]`,
100
+ )
101
+ })
102
+
103
+ test('error: out-of-range slippage', () => {
104
+ expect(() => EarnShares.minimumOutput(1_000_000n, 10_000))
105
+ .toThrowErrorMatchingInlineSnapshot(`
106
+ [EarnShares.InvalidSlippageError: Slippage tolerance \`10000\` is invalid.
107
+
108
+ Slippage must be a whole number from 0 through 9999 basis points.]
109
+ `)
110
+ })
111
+
112
+ test('error: non-integer slippage', () => {
113
+ expect(() => EarnShares.minimumOutput(1_000_000n, 0.5))
114
+ .toThrowErrorMatchingInlineSnapshot(`
115
+ [EarnShares.InvalidSlippageError: Slippage tolerance \`0.5\` is invalid.
116
+
117
+ Slippage must be a whole number from 0 through 9999 basis points.]
118
+ `)
119
+ })
120
+ })
@@ -0,0 +1,235 @@
1
+ import * as Errors from '../core/Errors.js'
2
+
3
+ /** Basis-point denominator used by slippage bounds. */
4
+ export const basisPointScale = 10_000
5
+
6
+ /**
7
+ * Tempo Earn `VaultAdapter` conversion anchor.
8
+ *
9
+ * The adapter prices vault shares against venue shares through this pair:
10
+ * `engineShares` venue shares are worth `shareSupply` vault shares. It is initialised
11
+ * 1:1 and restated on `contribute` and `migrateEngine`.
12
+ *
13
+ * These conversions are raw and fee-blind; they ignore pending fee dilution
14
+ * and are unsuitable for user-facing value (use the adapter's `previewRedeem`).
15
+ */
16
+ export type Anchor = {
17
+ /** Venue shares held by the engine at the anchor point. */
18
+ engineShares: bigint
19
+ /** Vault share supply at the anchor point. */
20
+ shareSupply: bigint
21
+ }
22
+
23
+ /**
24
+ * Converts venue shares to a vault share amount at the anchor rate, rounding down.
25
+ *
26
+ * Mirrors `VaultAdapter.sharesToTokens`.
27
+ *
28
+ * @example
29
+ * ```ts twoslash
30
+ * import { EarnShares } from 'ox/tempo'
31
+ *
32
+ * const shareAmount = EarnShares.toAmount(
33
+ * { engineShares: 3n, shareSupply: 2n },
34
+ * 7n
35
+ * )
36
+ * // @log: 4n
37
+ * ```
38
+ *
39
+ * @param anchor - The conversion anchor.
40
+ * @param venueShareAmount - Venue share amount, base units.
41
+ * @returns Vault share amount, rounded down.
42
+ */
43
+ export function toAmount(anchor: Anchor, venueShareAmount: bigint): bigint {
44
+ return (venueShareAmount * anchor.shareSupply) / anchor.engineShares
45
+ }
46
+
47
+ export declare namespace toAmount {
48
+ type ErrorType = Errors.GlobalErrorType
49
+ }
50
+
51
+ /**
52
+ * Converts venue shares to a vault share amount at the anchor rate, rounding up.
53
+ *
54
+ * Mirrors the adapter's ceiling conversion used by exact-asset exits.
55
+ *
56
+ * @example
57
+ * ```ts twoslash
58
+ * import { EarnShares } from 'ox/tempo'
59
+ *
60
+ * const shareAmount = EarnShares.toAmountUp(
61
+ * { engineShares: 3n, shareSupply: 2n },
62
+ * 7n
63
+ * )
64
+ * // @log: 5n
65
+ * ```
66
+ *
67
+ * @param anchor - The conversion anchor.
68
+ * @param venueShareAmount - Venue share amount, base units.
69
+ * @returns Vault share amount, rounded up.
70
+ */
71
+ export function toAmountUp(anchor: Anchor, venueShareAmount: bigint): bigint {
72
+ const { engineShares, shareSupply } = anchor
73
+ return (venueShareAmount * shareSupply + engineShares - 1n) / engineShares
74
+ }
75
+
76
+ export declare namespace toAmountUp {
77
+ type ErrorType = Errors.GlobalErrorType
78
+ }
79
+
80
+ /**
81
+ * Converts a vault share amount to venue shares at the anchor rate, rounding down.
82
+ *
83
+ * Mirrors `VaultAdapter.tokensToShares`.
84
+ *
85
+ * @example
86
+ * ```ts twoslash
87
+ * import { EarnShares } from 'ox/tempo'
88
+ *
89
+ * const venueShareAmount = EarnShares.toVenueAmount(
90
+ * { engineShares: 3n, shareSupply: 2n },
91
+ * 7n
92
+ * )
93
+ * // @log: 10n
94
+ * ```
95
+ *
96
+ * @param anchor - The conversion anchor.
97
+ * @param shareAmount - Vault share amount, base units.
98
+ * @returns Venue share amount, rounded down.
99
+ */
100
+ export function toVenueAmount(anchor: Anchor, shareAmount: bigint): bigint {
101
+ return (shareAmount * anchor.engineShares) / anchor.shareSupply
102
+ }
103
+
104
+ export declare namespace toVenueAmount {
105
+ type ErrorType = Errors.GlobalErrorType
106
+ }
107
+
108
+ /**
109
+ * Computes the dilution-correct vault shares minted for an asset-denominated fee.
110
+ *
111
+ * Mirrors `FeeMath`:
112
+ * `feeShares = floor(fee * shareSupply / (activeAssets - fee))`, zero when the
113
+ * fee is zero or not smaller than the active assets. Minting this amount to the
114
+ * fee ledger prices the fee at post-mint value per share.
115
+ *
116
+ * @example
117
+ * ```ts twoslash
118
+ * import { EarnShares } from 'ox/tempo'
119
+ *
120
+ * const shares = EarnShares.feeShares({
121
+ * activeAssets: 1_100n,
122
+ * shareSupply: 1_000n,
123
+ * totalFeeAssets: 100n
124
+ * })
125
+ * // @log: 100n
126
+ * ```
127
+ *
128
+ * @param options - Fee accrual inputs.
129
+ * @returns Vault shares to mint for the fee, rounded down.
130
+ */
131
+ export function feeShares(options: feeShares.Options): bigint {
132
+ const { activeAssets, shareSupply, totalFeeAssets } = options
133
+ if (totalFeeAssets === 0n || totalFeeAssets >= activeAssets) return 0n
134
+ return (totalFeeAssets * shareSupply) / (activeAssets - totalFeeAssets)
135
+ }
136
+
137
+ export declare namespace feeShares {
138
+ export type Options = {
139
+ /** Assets backing the active (non-queued) supply, base units. */
140
+ activeAssets: bigint
141
+ /** Active vault share supply, base units. */
142
+ shareSupply: bigint
143
+ /** Total fee liability in asset units. */
144
+ totalFeeAssets: bigint
145
+ }
146
+ export type ErrorType = Errors.GlobalErrorType
147
+ }
148
+
149
+ /**
150
+ * Lowers an expected output by a basis-point slippage tolerance, flooring to `1n`.
151
+ *
152
+ * Suitable for lower bounds such as a deposit's minimum shares or a redeem's
153
+ * minimum assets; not for upper bounds such as an exact withdrawal's maximum
154
+ * shares.
155
+ *
156
+ * @example
157
+ * ```ts twoslash
158
+ * import { EarnShares } from 'ox/tempo'
159
+ *
160
+ * const minimumShares = EarnShares.minimumOutput(
161
+ * 1_000_000n,
162
+ * 50
163
+ * )
164
+ * // @log: 995_000n
165
+ * ```
166
+ *
167
+ * @param expectedAmount - Expected output in base units.
168
+ * @param slippageBps - Allowed slippage in basis points from `0` through `9_999`.
169
+ * @returns The minimum accepted output, floored to `1n`.
170
+ * @throws `InvalidExpectedOutputError` when `expectedAmount` is not positive.
171
+ * @throws `InvalidSlippageError` when `slippageBps` is outside its valid range.
172
+ */
173
+ export function minimumOutput(
174
+ expectedAmount: bigint,
175
+ slippageBps: number,
176
+ ): bigint {
177
+ if (expectedAmount <= 0n)
178
+ throw new InvalidExpectedOutputError({ expectedAmount })
179
+ if (
180
+ !Number.isInteger(slippageBps) ||
181
+ slippageBps < 0 ||
182
+ slippageBps >= basisPointScale
183
+ )
184
+ throw new InvalidSlippageError({ slippageBps })
185
+ const scale = BigInt(basisPointScale)
186
+ const bounded = (expectedAmount * (scale - BigInt(slippageBps))) / scale
187
+ return bounded === 0n ? 1n : bounded
188
+ }
189
+
190
+ export declare namespace minimumOutput {
191
+ type ErrorType =
192
+ | InvalidExpectedOutputError
193
+ | InvalidSlippageError
194
+ | Errors.GlobalErrorType
195
+ }
196
+
197
+ /**
198
+ * Error thrown when an expected output is not positive.
199
+ */
200
+ export class InvalidExpectedOutputError extends Errors.BaseError {
201
+ override readonly name = 'EarnShares.InvalidExpectedOutputError'
202
+
203
+ constructor(options: InvalidExpectedOutputError.Options) {
204
+ super(
205
+ `Expected output \`${options.expectedAmount}\` must be greater than zero.`,
206
+ )
207
+ }
208
+ }
209
+
210
+ export declare namespace InvalidExpectedOutputError {
211
+ export type Options = {
212
+ expectedAmount: bigint
213
+ }
214
+ }
215
+
216
+ /**
217
+ * Error thrown when a slippage tolerance is not an integer from `0` through `9_999`.
218
+ */
219
+ export class InvalidSlippageError extends Errors.BaseError {
220
+ override readonly name = 'EarnShares.InvalidSlippageError'
221
+
222
+ constructor(options: InvalidSlippageError.Options) {
223
+ super(`Slippage tolerance \`${options.slippageBps}\` is invalid.`, {
224
+ metaMessages: [
225
+ `Slippage must be a whole number from 0 through ${basisPointScale - 1} basis points.`,
226
+ ],
227
+ })
228
+ }
229
+ }
230
+
231
+ export declare namespace InvalidSlippageError {
232
+ export type Options = {
233
+ slippageBps: number
234
+ }
235
+ }
@@ -0,0 +1,62 @@
1
+ import { expectTypeOf, test } from 'vp/test'
2
+ import * as KeyAuthorization from './KeyAuthorization.js'
3
+ import * as SignatureEnvelope from './SignatureEnvelope.js'
4
+
5
+ const authorization = {
6
+ address: '0x1111111111111111111111111111111111111111',
7
+ chainId: 1n,
8
+ type: 'secp256k1',
9
+ } as const satisfies KeyAuthorization.Input
10
+
11
+ const signature = {
12
+ signature: {
13
+ r: '0x01',
14
+ s: '0x02',
15
+ yParity: 0,
16
+ },
17
+ type: 'secp256k1',
18
+ } as const satisfies SignatureEnvelope.Secp256k1
19
+
20
+ const multisig = {
21
+ account: '0x2222222222222222222222222222222222222222',
22
+ signatures: [signature],
23
+ type: 'multisig',
24
+ } as const satisfies SignatureEnvelope.Multisig
25
+
26
+ test('accepts primitive signatures', () => {
27
+ const signed = KeyAuthorization.from(authorization, { signature })
28
+
29
+ expectTypeOf(signed.signature).toMatchTypeOf<
30
+ KeyAuthorization.Signed['signature']
31
+ >()
32
+ })
33
+
34
+ test('rejects multisig signatures', () => {
35
+ KeyAuthorization.from(authorization, {
36
+ // @ts-expect-error Key authorizations accept only primitive signatures.
37
+ signature: multisig,
38
+ })
39
+
40
+ const multisigRpc = {
41
+ account: multisig.account,
42
+ signatures: [
43
+ {
44
+ r: '0x01',
45
+ s: '0x02',
46
+ type: 'secp256k1',
47
+ yParity: '0x0',
48
+ },
49
+ ],
50
+ } as const satisfies SignatureEnvelope.MultisigRpc
51
+
52
+ const rpc: KeyAuthorization.Rpc = {
53
+ chainId: '0x1',
54
+ expiry: null,
55
+ keyId: authorization.address,
56
+ keyType: authorization.type,
57
+ // @ts-expect-error Key authorizations accept only primitive RPC signatures.
58
+ signature: multisigRpc,
59
+ }
60
+
61
+ expectTypeOf(rpc).toEqualTypeOf<KeyAuthorization.Rpc>()
62
+ })
@@ -53,6 +53,12 @@ const signature_webauthn = SignatureEnvelope.from({
53
53
  },
54
54
  })
55
55
 
56
+ const signature_multisig = SignatureEnvelope.from({
57
+ account: address,
58
+ signatures: [SignatureEnvelope.from(signature_secp256k1)],
59
+ type: 'multisig',
60
+ })
61
+
56
62
  describe('from', () => {
57
63
  test('default', () => {
58
64
  const authorization = KeyAuthorization.from({
@@ -416,9 +422,56 @@ describe('from', () => {
416
422
  }
417
423
  `)
418
424
  })
425
+
426
+ test('rejects a multisig signature', () => {
427
+ const authorization = KeyAuthorization.from({
428
+ address,
429
+ chainId: 1n,
430
+ type: 'secp256k1',
431
+ })
432
+
433
+ expect(() =>
434
+ KeyAuthorization.from(authorization, {
435
+ signature: signature_multisig as never,
436
+ }),
437
+ ).toThrowErrorMatchingInlineSnapshot(
438
+ `[KeyAuthorization.InvalidSignatureTypeError: Signature type \`multisig\` is invalid for key authorizations; expected \`secp256k1\`, \`p256\`, or \`webAuthn\`.]`,
439
+ )
440
+
441
+ expect(() =>
442
+ KeyAuthorization.from(authorization, {
443
+ signature: SignatureEnvelope.serialize(signature_multisig),
444
+ }),
445
+ ).toThrowErrorMatchingInlineSnapshot(
446
+ `[KeyAuthorization.InvalidSignatureTypeError: Signature type \`multisig\` is invalid for key authorizations; expected \`secp256k1\`, \`p256\`, or \`webAuthn\`.]`,
447
+ )
448
+
449
+ expect(() =>
450
+ KeyAuthorization.from({
451
+ ...authorization,
452
+ signature: signature_multisig,
453
+ } as never),
454
+ ).toThrowErrorMatchingInlineSnapshot(
455
+ `[KeyAuthorization.InvalidSignatureTypeError: Signature type \`multisig\` is invalid for key authorizations; expected \`secp256k1\`, \`p256\`, or \`webAuthn\`.]`,
456
+ )
457
+ })
419
458
  })
420
459
 
421
460
  describe('fromRpc', () => {
461
+ test('rejects a multisig signature', () => {
462
+ expect(() =>
463
+ KeyAuthorization.fromRpc({
464
+ chainId: '0x1',
465
+ expiry: null,
466
+ keyId: address,
467
+ keyType: 'secp256k1',
468
+ signature: SignatureEnvelope.toRpc(signature_multisig),
469
+ } as never),
470
+ ).toThrowErrorMatchingInlineSnapshot(
471
+ `[KeyAuthorization.InvalidSignatureTypeError: Signature type \`multisig\` is invalid for key authorizations; expected \`secp256k1\`, \`p256\`, or \`webAuthn\`.]`,
472
+ )
473
+ })
474
+
422
475
  test('secp256k1', () => {
423
476
  const authorization = KeyAuthorization.fromRpc({
424
477
  chainId: '0x1',