@unconfirmed/sui-effect 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 (115) hide show
  1. package/AGENTS.md +209 -0
  2. package/LICENSE +21 -0
  3. package/LLMS.md +6707 -0
  4. package/README.md +300 -0
  5. package/dist/domain/bcs.d.ts +101 -0
  6. package/dist/domain/bcs.d.ts.map +1 -0
  7. package/dist/domain/bcs.js +183 -0
  8. package/dist/domain/bcs.js.map +1 -0
  9. package/dist/domain/errors.d.ts +595 -0
  10. package/dist/domain/errors.d.ts.map +1 -0
  11. package/dist/domain/errors.js +476 -0
  12. package/dist/domain/errors.js.map +1 -0
  13. package/dist/domain/executed.d.ts +325 -0
  14. package/dist/domain/executed.d.ts.map +1 -0
  15. package/dist/domain/executed.js +253 -0
  16. package/dist/domain/executed.js.map +1 -0
  17. package/dist/domain/journal-entry.d.ts +468 -0
  18. package/dist/domain/journal-entry.d.ts.map +1 -0
  19. package/dist/domain/journal-entry.js +63 -0
  20. package/dist/domain/journal-entry.js.map +1 -0
  21. package/dist/domain/schemas.d.ts +950 -0
  22. package/dist/domain/schemas.d.ts.map +1 -0
  23. package/dist/domain/schemas.js +571 -0
  24. package/dist/domain/schemas.js.map +1 -0
  25. package/dist/domain/sui-schema.d.ts +12 -0
  26. package/dist/domain/sui-schema.d.ts.map +1 -0
  27. package/dist/domain/sui-schema.js +12 -0
  28. package/dist/domain/sui-schema.js.map +1 -0
  29. package/dist/extension.d.ts +7 -0
  30. package/dist/extension.d.ts.map +1 -0
  31. package/dist/extension.js +7 -0
  32. package/dist/extension.js.map +1 -0
  33. package/dist/index.d.ts +31 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +31 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/internal.d.ts +18 -0
  38. package/dist/internal.d.ts.map +1 -0
  39. package/dist/internal.js +18 -0
  40. package/dist/internal.js.map +1 -0
  41. package/dist/journal.d.ts +51 -0
  42. package/dist/journal.d.ts.map +1 -0
  43. package/dist/journal.js +18 -0
  44. package/dist/journal.js.map +1 -0
  45. package/dist/script.d.ts +7 -0
  46. package/dist/script.d.ts.map +1 -0
  47. package/dist/script.js +7 -0
  48. package/dist/script.js.map +1 -0
  49. package/dist/services/Journal.d.ts +76 -0
  50. package/dist/services/Journal.d.ts.map +1 -0
  51. package/dist/services/Journal.js +70 -0
  52. package/dist/services/Journal.js.map +1 -0
  53. package/dist/services/JournalKeyValueStore.d.ts +73 -0
  54. package/dist/services/JournalKeyValueStore.d.ts.map +1 -0
  55. package/dist/services/JournalKeyValueStore.js +155 -0
  56. package/dist/services/JournalKeyValueStore.js.map +1 -0
  57. package/dist/services/Script.d.ts +210 -0
  58. package/dist/services/Script.d.ts.map +1 -0
  59. package/dist/services/Script.js +441 -0
  60. package/dist/services/Script.js.map +1 -0
  61. package/dist/services/Signer.d.ts +132 -0
  62. package/dist/services/Signer.d.ts.map +1 -0
  63. package/dist/services/Signer.js +158 -0
  64. package/dist/services/Signer.js.map +1 -0
  65. package/dist/services/SubmitConfig.d.ts +175 -0
  66. package/dist/services/SubmitConfig.d.ts.map +1 -0
  67. package/dist/services/SubmitConfig.js +52 -0
  68. package/dist/services/SubmitConfig.js.map +1 -0
  69. package/dist/services/Sui.d.ts +295 -0
  70. package/dist/services/Sui.d.ts.map +1 -0
  71. package/dist/services/Sui.js +414 -0
  72. package/dist/services/Sui.js.map +1 -0
  73. package/dist/services/SuiCore.d.ts +227 -0
  74. package/dist/services/SuiCore.d.ts.map +1 -0
  75. package/dist/services/SuiCore.js +400 -0
  76. package/dist/services/SuiCore.js.map +1 -0
  77. package/dist/services/SuiCoreFake.d.ts +278 -0
  78. package/dist/services/SuiCoreFake.d.ts.map +1 -0
  79. package/dist/services/SuiCoreFake.js +1003 -0
  80. package/dist/services/SuiCoreFake.js.map +1 -0
  81. package/dist/services/SuiExtension.d.ts +208 -0
  82. package/dist/services/SuiExtension.d.ts.map +1 -0
  83. package/dist/services/SuiExtension.js +355 -0
  84. package/dist/services/SuiExtension.js.map +1 -0
  85. package/dist/services/SuiGraphQL.d.ts +98 -0
  86. package/dist/services/SuiGraphQL.d.ts.map +1 -0
  87. package/dist/services/SuiGraphQL.js +118 -0
  88. package/dist/services/SuiGraphQL.js.map +1 -0
  89. package/dist/services/Tx.d.ts +687 -0
  90. package/dist/services/Tx.d.ts.map +1 -0
  91. package/dist/services/Tx.js +1224 -0
  92. package/dist/services/Tx.js.map +1 -0
  93. package/dist/testing.d.ts +88 -0
  94. package/dist/testing.d.ts.map +1 -0
  95. package/dist/testing.js +163 -0
  96. package/dist/testing.js.map +1 -0
  97. package/dist/tx.d.ts +24 -0
  98. package/dist/tx.d.ts.map +1 -0
  99. package/dist/tx.js +24 -0
  100. package/dist/tx.js.map +1 -0
  101. package/docs/extensions.md +1685 -0
  102. package/examples/extension-template/README.md +170 -0
  103. package/examples/extension-template/package.json +44 -0
  104. package/examples/extension-template/scripts/check-package.ts +147 -0
  105. package/examples/extension-template/src/Escrow.ts +445 -0
  106. package/examples/extension-template/src/Platform.ts +136 -0
  107. package/examples/extension-template/src/errors.ts +61 -0
  108. package/examples/extension-template/src/extension.ts +63 -0
  109. package/examples/extension-template/src/index.ts +34 -0
  110. package/examples/extension-template/src/schema.ts +158 -0
  111. package/examples/extension-template/src/upstream.ts +66 -0
  112. package/examples/extension-template/test/escrow.test.ts +559 -0
  113. package/examples/extension-template/tsconfig.build.json +26 -0
  114. package/examples/extension-template/tsconfig.json +35 -0
  115. package/package.json +87 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Script.js","sourceRoot":"","sources":["../../src/services/Script.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEnG,OAAO,EAAE,QAAQ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M,IAAI,IAAI,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC;oBAAE,KAAK,CAAC,IAAI,CAAC,CAAA;YAChE,CAAC;iBAAM,IAAI,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3C,KAAK,CAAC,aAAa,CAAC,CAAA;YACtB,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;YACjC,CAAC;QACH,CAAC;QACD,yEAAyE;QACzE,2EAA2E;QAC3E,wEAAwE;QACxE,kEAAkE;QAClE,UAAU,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,CAAA;QAC1C,KAAK,MAAM,IAAI,IAAI,eAAe,CAAC,UAAU,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,CAAA;IAC7D,CAAC;IACD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAA;IAC9D,IAAI,CAAC,IAAI,CAAC,CAAA;IACV,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * `Signer`: a credential as a value, never a service.
3
+ *
4
+ * One process may legitimately hold two credentials at once (a sponsor signs
5
+ * as itself and verifies the sender's signature), and `R = Signer` cannot say
6
+ * which one a function meant. So a signer is always an explicit parameter, and
7
+ * nothing here ever exposes secret material: a `Signer` is an address, a
8
+ * scheme, and two functions that return signatures.
9
+ *
10
+ * @since 0.1.0
11
+ */
12
+ import type { Keypair, Signer as SdkSigner } from "@mysten/sui/cryptography";
13
+ import { Config, Effect } from "effect";
14
+ import { SigningError } from "../domain/errors.ts";
15
+ import { Signature, SuiAddress } from "../domain/schemas.ts";
16
+ /** The signature schemes a {@link Signer} built by this module can carry. */
17
+ export type SignatureScheme = "ED25519" | "Secp256k1" | "Secp256r1" | "MultiSig" | "ZkLogin" | "Passkey";
18
+ /**
19
+ * A credential: who it signs as, how, and the two things it can sign.
20
+ *
21
+ * Both members fail with `SigningError` and nothing else: a signer that has to
22
+ * reach a KMS or a wallet wraps its own transport failure in the `cause`, so a
23
+ * caller's error union does not grow a branch per credential kind.
24
+ */
25
+ export interface Signer {
26
+ /** The Sui address this signer signs as. */
27
+ readonly address: SuiAddress;
28
+ /** The signature scheme of the credential. */
29
+ readonly scheme: SignatureScheme;
30
+ /**
31
+ * Signs transaction bytes with the `TransactionData` intent.
32
+ *
33
+ * Fails with: `SigningError`.
34
+ */
35
+ readonly signTransaction: (bytes: Uint8Array) => Effect.Effect<Signature, SigningError>;
36
+ /**
37
+ * Signs a personal message with the `PersonalMessage` intent.
38
+ *
39
+ * Fails with: `SigningError`.
40
+ */
41
+ readonly signPersonalMessage: (bytes: Uint8Array) => Effect.Effect<Signature, SigningError>;
42
+ }
43
+ /**
44
+ * Wraps any `@mysten/sui/cryptography` `Signer`.
45
+ *
46
+ * The SDK's `Signer` is the base class every credential extends: `Keypair` and
47
+ * its three schemes, but also a Ledger signer, a wallet adapter's signer, a KMS
48
+ * signer — anything that can `toSuiAddress`, `getKeyScheme`, `signTransaction`
49
+ * and `signPersonalMessage`. Nothing here needs the secret, so nothing here
50
+ * needs a keypair, and the `Signer` this returns exposes no secret material
51
+ * either.
52
+ *
53
+ * For a credential that is not an SDK `Signer` at all — a remote service, a
54
+ * hardware device behind your own protocol — use {@link remote}, which takes
55
+ * Effects and the address to sign as.
56
+ *
57
+ * Never fails: a bad address or signature surfaces as a `SigningError` from the
58
+ * member that produced it, not from construction.
59
+ */
60
+ export declare const fromSdkSigner: (keypair: SdkSigner) => Signer;
61
+ /**
62
+ * {@link fromSdkSigner} under the name the spec gave it when a keypair was the
63
+ * only thing it took. A `Keypair` **is** an SDK `Signer`, so this is a thin
64
+ * alias kept for callers who hold one. Never fails.
65
+ */
66
+ export declare const fromKeypair: (keypair: Keypair) => Signer;
67
+ /**
68
+ * Reads a Bech32 `suiprivkey1…` secret key from configuration and builds the
69
+ * signer for whichever of the three schemes its flag names.
70
+ *
71
+ * The key is read with `Config.redacted`, and the decoded bytes never leave
72
+ * this function. Neither does anything derived from them: the failure carries
73
+ * one fixed sentence and no `cause`, because the decoder's own message quotes
74
+ * the input it rejected.
75
+ *
76
+ * Fails with: `ConfigError` when the variable is missing, is not a Bech32 Sui
77
+ * private key, or names a scheme that has no keypair class (`MultiSig`,
78
+ * `ZkLogin`, `Passkey` — use {@link remote} for those).
79
+ */
80
+ export declare const fromConfig: (name?: string) => Effect.Effect<Signer, Config.ConfigError>;
81
+ /**
82
+ * A fresh Ed25519 credential that exists only for this process. For tests,
83
+ * localnet and throwaway addresses.
84
+ *
85
+ * This is the one place sui-effect does not take randomness from Effect's
86
+ * `Random`: key generation must come from a cryptographically secure source,
87
+ * and `Random` is a seeded, test-controllable PRNG whose whole purpose is to be
88
+ * reproducible. `new Ed25519Keypair()` uses the SDK's CSPRNG (`@noble/curves`
89
+ * over `crypto.getRandomValues`). A `TestClock`-style deterministic key would
90
+ * be a security bug, not a convenience.
91
+ *
92
+ * Never fails.
93
+ */
94
+ export declare const ephemeral: Effect.Effect<Signer>;
95
+ /**
96
+ * What {@link remote} needs to know about a credential it does not hold.
97
+ *
98
+ * `address` is not optional and is not derived: a remote signer **must report
99
+ * the address it signs as**. `Tx.sign` and `Tx.cosign` compare it with the
100
+ * transaction's sender and gas owner and refuse a mismatch, which is the only
101
+ * thing standing between a misconfigured KMS key and an `INVALID_ARGUMENT`
102
+ * rejection that `Tx.submit` can only report as `SubmissionUnknown`.
103
+ */
104
+ export interface RemoteSigner {
105
+ readonly address: SuiAddress;
106
+ readonly scheme: SignatureScheme;
107
+ readonly signTransaction: (bytes: Uint8Array) => Effect.Effect<string, SigningError>;
108
+ readonly signPersonalMessage?: (bytes: Uint8Array) => Effect.Effect<string, SigningError>;
109
+ }
110
+ /**
111
+ * Builds a signer around something that signs elsewhere: a KMS, a wallet, a
112
+ * hardware device, another process.
113
+ *
114
+ * The returned signer decodes whatever the remote produced, so a malformed
115
+ * signature is a `SigningError` rather than a surprise at execution. When
116
+ * `signPersonalMessage` is not given, asking for one fails with `SigningError`
117
+ * instead of pretending. Never fails.
118
+ */
119
+ export declare const remote: (signer: RemoteSigner) => Signer;
120
+ /**
121
+ * The constructors, namespaced the way the spec spells them:
122
+ * `Signer.fromSdkSigner`, `Signer.fromKeypair`, `Signer.fromConfig`,
123
+ * `Signer.ephemeral`, `Signer.remote`. The type `Signer` is the interface above.
124
+ */
125
+ export declare const Signer: {
126
+ readonly fromSdkSigner: (keypair: SdkSigner) => Signer;
127
+ readonly fromKeypair: (keypair: Keypair) => Signer;
128
+ readonly fromConfig: (name?: string) => Effect.Effect<Signer, Config.ConfigError>;
129
+ readonly ephemeral: Effect.Effect<Signer, never, never>;
130
+ readonly remote: (signer: RemoteSigner) => Signer;
131
+ };
132
+ //# sourceMappingURL=Signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Signer.d.ts","sourceRoot":"","sources":["../../src/services/Signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAK5E,OAAO,EAAE,MAAM,EAAkB,MAAM,EAAoB,MAAM,QAAQ,CAAA;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAE5D,6EAA6E;AAC7E,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAA;AAExG;;;;;;GAMG;AACH,MAAM,WAAW,MAAM;IACrB,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;IAC5B,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA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D,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC;;8BAgEb,YAAY,KAAG,MAAM;CA0B1C,CAAA"}
@@ -0,0 +1,158 @@
1
+ import { decodeSuiPrivateKey } from "@mysten/sui/cryptography";
2
+ import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
3
+ import { Secp256k1Keypair } from "@mysten/sui/keypairs/secp256k1";
4
+ import { Secp256r1Keypair } from "@mysten/sui/keypairs/secp256r1";
5
+ import { Config, ConfigProvider, Effect, Redacted, Schema } from "effect";
6
+ import { SigningError } from "../domain/errors.js";
7
+ import { Signature, SuiAddress } from "../domain/schemas.js";
8
+ const decodeSignature = Schema.decodeUnknownEffect(Signature);
9
+ const signatureOf = (signature) => decodeSignature(signature).pipe(Effect.mapError((issue) => new SigningError({ cause: `the signer returned a signature this version cannot read: ${issue.message}` })));
10
+ /**
11
+ * Wraps any `@mysten/sui/cryptography` `Signer`.
12
+ *
13
+ * The SDK's `Signer` is the base class every credential extends: `Keypair` and
14
+ * its three schemes, but also a Ledger signer, a wallet adapter's signer, a KMS
15
+ * signer — anything that can `toSuiAddress`, `getKeyScheme`, `signTransaction`
16
+ * and `signPersonalMessage`. Nothing here needs the secret, so nothing here
17
+ * needs a keypair, and the `Signer` this returns exposes no secret material
18
+ * either.
19
+ *
20
+ * For a credential that is not an SDK `Signer` at all — a remote service, a
21
+ * hardware device behind your own protocol — use {@link remote}, which takes
22
+ * Effects and the address to sign as.
23
+ *
24
+ * Never fails: a bad address or signature surfaces as a `SigningError` from the
25
+ * member that produced it, not from construction.
26
+ */
27
+ export const fromSdkSigner = (keypair) => {
28
+ const address = keypair.toSuiAddress();
29
+ return {
30
+ // `toSuiAddress` returns the normalized form the SDK derived from the
31
+ // public key, so this never throws; the members still decode what the
32
+ // keypair hands back.
33
+ address: SuiAddress.make(address),
34
+ scheme: keypair.getKeyScheme(),
35
+ signTransaction: Effect.fn("Signer.signTransaction")(function* (bytes) {
36
+ const result = yield* Effect.tryPromise({
37
+ try: () => keypair.signTransaction(bytes),
38
+ catch: (cause) => new SigningError({ cause })
39
+ });
40
+ return yield* signatureOf(result.signature);
41
+ }),
42
+ signPersonalMessage: Effect.fn("Signer.signPersonalMessage")(function* (bytes) {
43
+ const result = yield* Effect.tryPromise({
44
+ try: () => keypair.signPersonalMessage(bytes),
45
+ catch: (cause) => new SigningError({ cause })
46
+ });
47
+ return yield* signatureOf(result.signature);
48
+ })
49
+ };
50
+ };
51
+ /**
52
+ * {@link fromSdkSigner} under the name the spec gave it when a keypair was the
53
+ * only thing it took. A `Keypair` **is** an SDK `Signer`, so this is a thin
54
+ * alias kept for callers who hold one. Never fails.
55
+ */
56
+ export const fromKeypair = (keypair) => fromSdkSigner(keypair);
57
+ /** Builds the keypair class the scheme flag of a Bech32 secret key names. */
58
+ const keypairOf = (parsed) => {
59
+ switch (parsed.scheme) {
60
+ case "ED25519":
61
+ return Ed25519Keypair.fromSecretKey(parsed.secretKey);
62
+ case "Secp256k1":
63
+ return Secp256k1Keypair.fromSecretKey(parsed.secretKey);
64
+ case "Secp256r1":
65
+ return Secp256r1Keypair.fromSecretKey(parsed.secretKey);
66
+ default:
67
+ return undefined;
68
+ }
69
+ };
70
+ /**
71
+ * The only text a failure of {@link fromConfig} ever carries.
72
+ *
73
+ * It is fixed, and neither the key nor the thrown message is in it. The Bech32
74
+ * decoder reports a bad checksum as `Invalid checksum in suiprivkey1…` with the
75
+ * **whole input**, so a one-character typo in a live key would otherwise print
76
+ * a recoverable secret on stderr the moment `Script.run` describes the failure.
77
+ * There is nothing a caller can do with the decoder's wording that this
78
+ * sentence does not already tell them, so it is dropped rather than redacted:
79
+ * a `cause` on the error would serialize through `SuiError.toJson` too.
80
+ */
81
+ const KEY_ERROR = "is not a Bech32 Sui private key (scheme or checksum), " +
82
+ "or names a scheme with no keypair class (MultiSig, ZkLogin, Passkey — use Signer.remote for those)";
83
+ /**
84
+ * Reads a Bech32 `suiprivkey1…` secret key from configuration and builds the
85
+ * signer for whichever of the three schemes its flag names.
86
+ *
87
+ * The key is read with `Config.redacted`, and the decoded bytes never leave
88
+ * this function. Neither does anything derived from them: the failure carries
89
+ * one fixed sentence and no `cause`, because the decoder's own message quotes
90
+ * the input it rejected.
91
+ *
92
+ * Fails with: `ConfigError` when the variable is missing, is not a Bech32 Sui
93
+ * private key, or names a scheme that has no keypair class (`MultiSig`,
94
+ * `ZkLogin`, `Passkey` — use {@link remote} for those).
95
+ */
96
+ export const fromConfig = (name = "SUI_PRIVATE_KEY") => Config.redacted(name).pipe(Effect.flatMap((redacted) => Effect.try({
97
+ try: () => {
98
+ const parsed = decodeSuiPrivateKey(Redacted.value(redacted));
99
+ const keypair = keypairOf(parsed);
100
+ if (keypair === undefined) {
101
+ throw new Error("unsupported key scheme");
102
+ }
103
+ return fromKeypair(keypair);
104
+ },
105
+ // No `cause`: it would carry the decoder's message, and the decoder's
106
+ // message carries the key.
107
+ catch: () => new Config.ConfigError(new ConfigProvider.SourceError({ message: `${name} ${KEY_ERROR}` }))
108
+ })));
109
+ /**
110
+ * A fresh Ed25519 credential that exists only for this process. For tests,
111
+ * localnet and throwaway addresses.
112
+ *
113
+ * This is the one place sui-effect does not take randomness from Effect's
114
+ * `Random`: key generation must come from a cryptographically secure source,
115
+ * and `Random` is a seeded, test-controllable PRNG whose whole purpose is to be
116
+ * reproducible. `new Ed25519Keypair()` uses the SDK's CSPRNG (`@noble/curves`
117
+ * over `crypto.getRandomValues`). A `TestClock`-style deterministic key would
118
+ * be a security bug, not a convenience.
119
+ *
120
+ * Never fails.
121
+ */
122
+ export const ephemeral = Effect.sync(() => fromKeypair(new Ed25519Keypair()));
123
+ /**
124
+ * Builds a signer around something that signs elsewhere: a KMS, a wallet, a
125
+ * hardware device, another process.
126
+ *
127
+ * The returned signer decodes whatever the remote produced, so a malformed
128
+ * signature is a `SigningError` rather than a surprise at execution. When
129
+ * `signPersonalMessage` is not given, asking for one fails with `SigningError`
130
+ * instead of pretending. Never fails.
131
+ */
132
+ export const remote = (signer) => ({
133
+ address: signer.address,
134
+ scheme: signer.scheme,
135
+ signTransaction: Effect.fn("Signer.remote.signTransaction")(function* (bytes) {
136
+ return yield* signatureOf(yield* signer.signTransaction(bytes));
137
+ }),
138
+ signPersonalMessage: Effect.fn("Signer.remote.signPersonalMessage")(function* (bytes) {
139
+ const sign = signer.signPersonalMessage;
140
+ if (sign === undefined) {
141
+ return yield* new SigningError({ cause: "this remote signer cannot sign personal messages" });
142
+ }
143
+ return yield* signatureOf(yield* sign(bytes));
144
+ })
145
+ });
146
+ /**
147
+ * The constructors, namespaced the way the spec spells them:
148
+ * `Signer.fromSdkSigner`, `Signer.fromKeypair`, `Signer.fromConfig`,
149
+ * `Signer.ephemeral`, `Signer.remote`. The type `Signer` is the interface above.
150
+ */
151
+ export const Signer = {
152
+ fromSdkSigner,
153
+ fromKeypair,
154
+ fromConfig,
155
+ ephemeral,
156
+ remote
157
+ };
158
+ //# sourceMappingURL=Signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Signer.js","sourceRoot":"","sources":["../../src/services/Signer.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AA+B5D,MAAM,eAAe,GAAG,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAA;AAE7D,MAAM,WAAW,GAAG,CAAC,SAAiB,E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I,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/C,CAAC,CAAC;CACH,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,aAAa;IACb,WAAW;IACX,UAAU;IACV,SAAS;IACT,MAAM;CACE,CAAA"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * `SubmitConfig`: the knobs of the transaction lifecycle, as a
3
+ * `Context.Reference` so every default is in force with no setup and any of
4
+ * them can be overridden for one fiber.
5
+ *
6
+ * @since 0.1.0
7
+ */
8
+ import { Context, Duration, Schedule } from "effect";
9
+ import type { Effect } from "effect";
10
+ import type { PolicyDenied } from "../domain/errors.ts";
11
+ import type { Mist, Simulation } from "../domain/schemas.ts";
12
+ /** How `Tx.build` sets an expiration when the recipe left one unset. */
13
+ export type ExpirationPolicy = "validDuring" | "epoch" | "none";
14
+ /**
15
+ * Whether `Tx.reconcile` is allowed to conclude that an expiration window
16
+ * closed on a transaction the node does not know.
17
+ *
18
+ * `"epochThenMiss"` is the default and the only rule that produces
19
+ * `NotApplied { evidence: "expired" }`: the epoch (or timestamp) bound must be
20
+ * observed as passed, then `getTransaction` must miss, then — after
21
+ * `SubmitConfig.reconcileRecheck` — both must hold again. A single observation
22
+ * proves nothing, because a transaction can execute between the lookup and the
23
+ * expiry check, and a node behind a load balancer can serve an epoch from one
24
+ * replica and a transaction index from another.
25
+ *
26
+ * `"never"` disables the rule outright, so an expiration window is never
27
+ * evidence and an unknown transaction stays `SubmissionUnknown`. That is the
28
+ * setting for a deployment behind a mixed-node load balancer, where even the
29
+ * repeated observation can be answered by two different nodes.
30
+ *
31
+ * **Residual risk, even on `"epochThenMiss"`:** a node whose transaction index
32
+ * lags its epoch view can report the new epoch and miss a transaction it has in
33
+ * fact executed, twice in a row. The recheck delay makes that unlikely, not
34
+ * impossible; a deployment that cannot tolerate it sets `"never"` and settles
35
+ * unknown submissions by hand.
36
+ */
37
+ export type ExpiryEvidencePolicy = "epochThenMiss" | "never";
38
+ /** Every decision `Tx.build`, `Tx.submit` and `Tx.reconcile` read from context. */
39
+ export interface SubmitConfigService {
40
+ /**
41
+ * The expiration `Tx.build` sets when the recipe set none.
42
+ *
43
+ * `"validDuring"` bounds the transaction to the current epoch and the next,
44
+ * and names the chain: it is the only one that both satisfies the validator
45
+ * rule (a transaction must have address-owned inputs *or* an expiration of at
46
+ * most two epochs) and stops bytes signed for one chain from landing on
47
+ * another. It costs one `getCurrentSystemState` read per build.
48
+ * `"epoch"` costs the same read and carries no chain guard. `"none"` leaves
49
+ * the transaction valid forever, which makes
50
+ * `NotApplied { evidence: "expired" }` unreachable.
51
+ */
52
+ readonly expiration: ExpirationPolicy;
53
+ /**
54
+ * An **additional** wall-clock bound on a `"validDuring"` expiration, as
55
+ * `maxTimestamp`.
56
+ *
57
+ * Unset by default, because no Sui network accepts one yet: a devnet node on
58
+ * protocol 100 refuses any transaction carrying a timestamp bound with
59
+ * `Feature is not supported: Timestamp-based transaction expiration is not
60
+ * yet supported`, whether or not epochs are set alongside it. Setting this
61
+ * produces bytes the current protocol rejects at build time; it is here so
62
+ * that a network which does support them needs no new API, and so that
63
+ * `Tx.reconcile`'s wall-clock expiry rule has something to read.
64
+ */
65
+ readonly validFor?: Duration.Duration;
66
+ /**
67
+ * The largest gas budget `Tx.build` will accept. The budget itself is chosen
68
+ * by the node's simulation during build; this is the ceiling above which
69
+ * building fails with `BuildError` rather than signing an expensive mistake.
70
+ */
71
+ readonly maxGasBudget: Mist;
72
+ /**
73
+ * An extra simulate before signing, and the place spend limits and target
74
+ * policies plug in. It fails with `PolicyDenied` and nothing else, so
75
+ * `Tx.run` stays typed.
76
+ */
77
+ readonly preflight?: (simulation: Simulation) => Effect.Effect<void, PolicyDenied>;
78
+ /** Whether `Tx.run` holds the sender lock from build through submit. */
79
+ readonly lockSender: boolean;
80
+ /**
81
+ * How `Tx.submit` re-sends the identical bytes after a retryable transport
82
+ * failure or a timeout. It never rebuilds, so a retry can only ever land the
83
+ * transaction the caller already signed.
84
+ */
85
+ readonly resubmit: Schedule.Schedule<unknown>;
86
+ /** How many times `Tx.submit` sends the bytes in total, the first try included. */
87
+ readonly resubmitAttempts: number;
88
+ /**
89
+ * How long one `executeTransaction` may take before `Tx.submit` treats it as
90
+ * a retryable transport failure. A timeout is the case `Tx.submit` exists
91
+ * for: the bytes may well have reached the network.
92
+ */
93
+ readonly executeTimeout: Duration.Duration;
94
+ /**
95
+ * How far `chainTime` must pass a transaction's recorded `maxTimestamp`
96
+ * before `Tx.reconcile` is willing to call it `NotApplied`. It covers the
97
+ * skew between the node's clock, the Clock object and the validators.
98
+ *
99
+ * It applies to the wall-clock rule only. The epoch rule needs no margin:
100
+ * an epoch is a consensus fact, not a reading of a clock, so once the
101
+ * current epoch is past a transaction's `maxEpoch` it is simply over.
102
+ */
103
+ readonly expiryMargin: Duration.Duration;
104
+ /**
105
+ * Whether a closed expiration window may be evidence at all, and under which
106
+ * rule. See {@link ExpiryEvidencePolicy}. Defaults to `"epochThenMiss"`.
107
+ */
108
+ readonly expiryEvidence: ExpiryEvidencePolicy;
109
+ /**
110
+ * How long `Tx.reconcile` waits between the first observation of a closed
111
+ * expiration window and the second one it needs before it will answer
112
+ * `NotApplied { evidence: "expired" }`.
113
+ *
114
+ * It is a `Clock` sleep, so a test drives it with `TestClock` and a test that
115
+ * does not care sets it to zero.
116
+ */
117
+ readonly reconcileRecheck: Duration.Duration;
118
+ /**
119
+ * Whether `Tx.submit` waits for a successful execution to become visible to
120
+ * reads before it returns and releases the sender lock. Defaults to `true`.
121
+ */
122
+ readonly awaitVisibility: boolean;
123
+ /**
124
+ * How long that wait may take. A wait that times out or fails **never**
125
+ * changes the outcome: the transaction executed, and `Tx.submit` returns the
126
+ * `Executed` it already has after logging the failure.
127
+ */
128
+ readonly visibilityTimeout: Duration.Duration;
129
+ /**
130
+ * The nonce `Tx.build` stamps on a default `ValidDuring` expiration, which is
131
+ * what makes two otherwise identical transactions from one address in one
132
+ * epoch different bytes with different digests.
133
+ *
134
+ * The default draws a `u32` from Effect's `Random`, which is process-local
135
+ * and does not survive a restart: independent 32-bit draws collide with
136
+ * probability about 1.16% after ten thousand such transactions. **A collision
137
+ * is not a second execution.** Identical bytes have one digest and one
138
+ * journal key, so the second build is the same transaction as the first; the
139
+ * failure mode is a transaction that cannot be sent again because the first
140
+ * one already occupied its digest, not a duplicated intent.
141
+ *
142
+ * Supply a monotonic allocator when that matters — a counter in the same
143
+ * store the journal uses, an id service, anything that survives a restart:
144
+ * `nonce: Effect.map(counter.next, (n) => n % 4_294_967_296)`. The value must
145
+ * be an integer in `[0, 2^32)`; anything else fails the build with
146
+ * `BuildError`. A journal-backed allocator is deferred (DESIGN §15).
147
+ */
148
+ readonly nonce: Effect.Effect<number>;
149
+ }
150
+ /** The spec's defaults, in force whenever nothing overrides them. */
151
+ export declare const defaults: SubmitConfigService;
152
+ /**
153
+ * The lifecycle settings.
154
+ *
155
+ * Because this is a `Context.Reference` and not a service, it never appears in
156
+ * an `R`: a one-shot script gets the defaults with no wiring, and an
157
+ * application overrides what it cares about with
158
+ * `Effect.provideService(effect, SubmitConfig, { ...SubmitConfig.defaults, validFor: "30 seconds" })`.
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * import { Effect } from "effect"
163
+ * import { SubmitConfig } from "@unconfirmed/sui-effect/tx"
164
+ *
165
+ * const strict = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
166
+ * Effect.provideService(effect, SubmitConfig, {
167
+ * ...SubmitConfig.defaults,
168
+ * maxGasBudget: 100_000_000n as typeof SubmitConfig.defaults.maxGasBudget
169
+ * })
170
+ * ```
171
+ */
172
+ export declare const SubmitConfig: Context.Reference<SubmitConfigService> & {
173
+ defaults: SubmitConfigService;
174
+ };
175
+ //# sourceMappingURL=SubmitConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubmitConfig.d.ts","sourceRoot":"","sources":["../../src/services/SubmitConfig.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;A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E,oBAAoB,CAAA;IAC7C;;;;;;;OAOG;IACH,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,CAAA;IAC5C;;;OAGG;IACH,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;IACjC;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,QAAQ,CAAA;IAC7C;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;CACtC;AAED,qEAAqE;AACrE,eAAO,MAAM,QAAQ,EAAE,mBAiBtB,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY;;CAKxB,CAAA"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * `SubmitConfig`: the knobs of the transaction lifecycle, as a
3
+ * `Context.Reference` so every default is in force with no setup and any of
4
+ * them can be overridden for one fiber.
5
+ *
6
+ * @since 0.1.0
7
+ */
8
+ import { Context, Duration, Random, Schedule } from "effect";
9
+ import { U32_MAX } from "../domain/schemas.js";
10
+ /** The spec's defaults, in force whenever nothing overrides them. */
11
+ export const defaults = {
12
+ expiration: "validDuring",
13
+ // The protocol's own maximum gas budget (50 SUI). Lower it to cap spend.
14
+ maxGasBudget: 50000000000n,
15
+ lockSender: true,
16
+ resubmit: Schedule.min([
17
+ Schedule.exponential("250 millis"),
18
+ Schedule.spaced("30 seconds")
19
+ ]).pipe(Schedule.jittered),
20
+ resubmitAttempts: 5,
21
+ executeTimeout: Duration.seconds(60),
22
+ expiryMargin: Duration.seconds(30),
23
+ expiryEvidence: "epochThenMiss",
24
+ reconcileRecheck: Duration.seconds(2),
25
+ awaitVisibility: true,
26
+ visibilityTimeout: Duration.seconds(15),
27
+ nonce: Random.nextIntBetween(0, U32_MAX)
28
+ };
29
+ /**
30
+ * The lifecycle settings.
31
+ *
32
+ * Because this is a `Context.Reference` and not a service, it never appears in
33
+ * an `R`: a one-shot script gets the defaults with no wiring, and an
34
+ * application overrides what it cares about with
35
+ * `Effect.provideService(effect, SubmitConfig, { ...SubmitConfig.defaults, validFor: "30 seconds" })`.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { Effect } from "effect"
40
+ * import { SubmitConfig } from "@unconfirmed/sui-effect/tx"
41
+ *
42
+ * const strict = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
43
+ * Effect.provideService(effect, SubmitConfig, {
44
+ * ...SubmitConfig.defaults,
45
+ * maxGasBudget: 100_000_000n as typeof SubmitConfig.defaults.maxGasBudget
46
+ * })
47
+ * ```
48
+ */
49
+ export const SubmitConfig = Object.assign(Context.Reference("@unconfirmed/sui-effect/SubmitConfig", {
50
+ defaultValue: () => defaults
51
+ }), { defaults });
52
+ //# sourceMappingURL=SubmitConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubmitConfig.js","sourceRoot":"","sources":["../../src/services/SubmitConfig.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAI5D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AA+I9C,qEAAqE;AACrE,MAAM,CAAC,MAAM,QAAQ,GAAwB;IAC3C,UAAU,EAAE,aAAa;IACzB,yEAAyE;IACzE,YAAY,EAAE,YAAuB;IACrC,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC;QACrB,QAAQ,CAAC,WAAW,CAAC,YAAY,CAAC;QAClC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC;KAC9B,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC1B,gBAAgB,EAAE,CAAC;IACnB,cAAc,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;IACpC,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,EA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