@flop-labs/sdk 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -0
- package/README.md +152 -101
- package/dist/a2a/agent-card.d.ts +51 -1
- package/dist/a2a/agent-card.d.ts.map +1 -1
- package/dist/a2a/agent-card.js +20 -0
- package/dist/a2a/agent-card.js.map +1 -1
- package/dist/a2a/index.d.ts +1 -1
- package/dist/a2a/index.d.ts.map +1 -1
- package/dist/a2a/index.js +1 -1
- package/dist/a2a/index.js.map +1 -1
- package/dist/a2a-cjs/agent-card.js +22 -0
- package/dist/a2a-cjs/agent-card.js.map +1 -1
- package/dist/a2a-cjs/index.js +3 -1
- package/dist/a2a-cjs/index.js.map +1 -1
- package/dist/agent/task-delegation.d.ts +1 -1
- package/dist/agent/task-delegation.d.ts.map +1 -1
- package/dist/agent/task-delegation.js +17 -48
- package/dist/agent/task-delegation.js.map +1 -1
- package/dist/agent-wallet.d.ts.map +1 -1
- package/dist/agent-wallet.js +1 -18
- package/dist/agent-wallet.js.map +1 -1
- package/dist/bundle/index.esm.js +1 -1
- package/dist/bundle/index.esm.js.map +1 -1
- package/dist/bundle/index.umd.cjs +1 -1
- package/dist/bundle/index.umd.cjs.map +1 -1
- package/dist/chain-text.d.ts +3 -0
- package/dist/chain-text.d.ts.map +1 -0
- package/dist/chain-text.js +27 -0
- package/dist/chain-text.js.map +1 -0
- package/dist/client.d.ts +16 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +75 -68
- package/dist/client.js.map +1 -1
- package/dist/compute-channel/agent-driver.d.ts.map +1 -1
- package/dist/compute-channel/agent-driver.js +3 -16
- package/dist/compute-channel/agent-driver.js.map +1 -1
- package/dist/compute-channel/direct-session-chain.d.ts.map +1 -1
- package/dist/compute-channel/direct-session-chain.js +63 -37
- package/dist/compute-channel/direct-session-chain.js.map +1 -1
- package/dist/compute-channel/direct-session.d.ts +1 -1
- package/dist/compute-channel/direct-session.d.ts.map +1 -1
- package/dist/compute-channel/direct-session.js +39 -6
- package/dist/compute-channel/direct-session.js.map +1 -1
- package/dist/compute-channel/fcu-admission.d.ts +37 -0
- package/dist/compute-channel/fcu-admission.d.ts.map +1 -0
- package/dist/compute-channel/fcu-admission.js +53 -0
- package/dist/compute-channel/fcu-admission.js.map +1 -0
- package/dist/compute-channel/fcu-agent.d.ts +27 -0
- package/dist/compute-channel/fcu-agent.d.ts.map +1 -0
- package/dist/compute-channel/fcu-agent.js +35 -0
- package/dist/compute-channel/fcu-agent.js.map +1 -0
- package/dist/compute-channel/fcu-policy.d.ts +67 -0
- package/dist/compute-channel/fcu-policy.d.ts.map +1 -0
- package/dist/compute-channel/fcu-policy.js +121 -0
- package/dist/compute-channel/fcu-policy.js.map +1 -0
- package/dist/compute-channel/fcu-profile.d.ts +56 -0
- package/dist/compute-channel/fcu-profile.d.ts.map +1 -0
- package/dist/compute-channel/fcu-profile.js +100 -0
- package/dist/compute-channel/fcu-profile.js.map +1 -0
- package/dist/compute-channel/fcu-serving.d.ts +146 -0
- package/dist/compute-channel/fcu-serving.d.ts.map +1 -0
- package/dist/compute-channel/fcu-serving.js +350 -0
- package/dist/compute-channel/fcu-serving.js.map +1 -0
- package/dist/compute-channel/fcu-sla.d.ts +88 -0
- package/dist/compute-channel/fcu-sla.d.ts.map +1 -0
- package/dist/compute-channel/fcu-sla.js +154 -0
- package/dist/compute-channel/fcu-sla.js.map +1 -0
- package/dist/compute-channel/fcu-store-node.d.ts +10 -0
- package/dist/compute-channel/fcu-store-node.d.ts.map +1 -0
- package/dist/compute-channel/fcu-store-node.js +98 -0
- package/dist/compute-channel/fcu-store-node.js.map +1 -0
- package/dist/compute-channel/fcu-timing.d.ts +34 -0
- package/dist/compute-channel/fcu-timing.d.ts.map +1 -0
- package/dist/compute-channel/fcu-timing.js +79 -0
- package/dist/compute-channel/fcu-timing.js.map +1 -0
- package/dist/compute-channel/flop-submitter.d.ts +1 -1
- package/dist/compute-channel/flop-submitter.d.ts.map +1 -1
- package/dist/compute-channel/flop-submitter.js +10 -20
- package/dist/compute-channel/flop-submitter.js.map +1 -1
- package/dist/compute-channel/index.d.ts +8 -0
- package/dist/compute-channel/index.d.ts.map +1 -1
- package/dist/compute-channel/index.js +8 -0
- package/dist/compute-channel/index.js.map +1 -1
- package/dist/compute-channel/peer-info.d.ts +15 -0
- package/dist/compute-channel/peer-info.d.ts.map +1 -0
- package/dist/compute-channel/peer-info.js +33 -0
- package/dist/compute-channel/peer-info.js.map +1 -0
- package/dist/compute-channel/transport-http.d.ts +10 -4
- package/dist/compute-channel/transport-http.d.ts.map +1 -1
- package/dist/compute-channel/transport-http.js +54 -18
- package/dist/compute-channel/transport-http.js.map +1 -1
- package/dist/connect.d.ts +4 -0
- package/dist/connect.d.ts.map +1 -0
- package/dist/connect.js +24 -0
- package/dist/connect.js.map +1 -0
- package/dist/coordination.d.ts.map +1 -1
- package/dist/coordination.js +5 -3
- package/dist/coordination.js.map +1 -1
- package/dist/discovery/discovery-service.d.ts.map +1 -1
- package/dist/discovery/discovery-service.js +19 -28
- package/dist/discovery/discovery-service.js.map +1 -1
- package/dist/faucet.d.ts +7 -2
- package/dist/faucet.d.ts.map +1 -1
- package/dist/faucet.js +39 -51
- package/dist/faucet.js.map +1 -1
- package/dist/htlc-appraisal.d.ts +4 -0
- package/dist/htlc-appraisal.d.ts.map +1 -0
- package/dist/htlc-appraisal.js +25 -0
- package/dist/htlc-appraisal.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/inference-purchase.d.ts +40 -0
- package/dist/inference-purchase.d.ts.map +1 -0
- package/dist/inference-purchase.js +43 -0
- package/dist/inference-purchase.js.map +1 -0
- package/dist/miner-admission.d.ts +124 -0
- package/dist/miner-admission.d.ts.map +1 -0
- package/dist/miner-admission.js +259 -0
- package/dist/miner-admission.js.map +1 -0
- package/dist/model-loader/registry.d.ts.map +1 -1
- package/dist/model-loader/registry.js +2 -8
- package/dist/model-loader/registry.js.map +1 -1
- package/dist/runtime-compatibility.d.ts +1 -1
- package/dist/runtime-compatibility.d.ts.map +1 -1
- package/dist/runtime-compatibility.js +5 -2
- package/dist/runtime-compatibility.js.map +1 -1
- package/dist/submit-tx.d.ts +1 -1
- package/dist/submit-tx.d.ts.map +1 -1
- package/dist/submit-tx.js +5 -13
- package/dist/submit-tx.js.map +1 -1
- package/dist/watch-transaction.d.ts +26 -0
- package/dist/watch-transaction.d.ts.map +1 -0
- package/dist/watch-transaction.js +91 -0
- package/dist/watch-transaction.js.map +1 -0
- package/dist/x402.d.ts +3 -1
- package/dist/x402.d.ts.map +1 -1
- package/dist/x402.js +16 -4
- package/dist/x402.js.map +1 -1
- package/package.json +10 -3
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { type VerifiedModelIdentity } from "./compute-channel/transcript.js";
|
|
2
|
+
export declare const MINER_ENDPOINT_DOMAIN = "flop-miner-endpoint-v1";
|
|
3
|
+
export declare const MODEL_IDENTITY_DOMAIN = "flop-model-identity-v1";
|
|
4
|
+
/** Longest endpoint an ad may name, in bytes (the canonical form is ASCII). */
|
|
5
|
+
export declare const MAX_ENDPOINT_BYTES = 256;
|
|
6
|
+
/** The worker republishes its ad this often, as it does its ghost key. */
|
|
7
|
+
export declare const ENDPOINT_AD_REPUBLISH_MS: number;
|
|
8
|
+
/**
|
|
9
|
+
* `blake2_256(MODEL_IDENTITY_DOMAIN ‖ identity)`, the identity encoded field by field as
|
|
10
|
+
* `turnEvidenceHash` encodes it: u32le-prefixed strings, raw 32-byte hashes, precision as one byte.
|
|
11
|
+
*/
|
|
12
|
+
export declare function modelIdentityHash(identity: VerifiedModelIdentity): Uint8Array;
|
|
13
|
+
/**
|
|
14
|
+
* `https://`, a host and an optional port other than 443, nothing else: one spelling per endpoint,
|
|
15
|
+
* so the signed bytes are the URL a writer dials. The host is a lowercase DNS name or, since a URL
|
|
16
|
+
* parser reads any host ending in a number or `0x…` as IPv4 (`0x08080808` is 8.8.8.8), a
|
|
17
|
+
* dotted-decimal IPv4 address with no leading zeros. Whether it resolves to a public address is
|
|
18
|
+
* the admission writer's check, not the codec's.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isCanonicalEndpoint(endpoint: string): boolean;
|
|
21
|
+
/** The fields of an endpoint ad. */
|
|
22
|
+
export interface EndpointAdFields {
|
|
23
|
+
genesisHash: Uint8Array;
|
|
24
|
+
account: Uint8Array;
|
|
25
|
+
enclaveKey: Uint8Array;
|
|
26
|
+
endpoint: string;
|
|
27
|
+
modelIdentityHash: Uint8Array;
|
|
28
|
+
issuedAtMs: number;
|
|
29
|
+
}
|
|
30
|
+
/** The ad as the mailbox takes and returns it: hex is lowercase without `0x`, the only spelling. */
|
|
31
|
+
export interface MinerEndpointAd {
|
|
32
|
+
account_id: string;
|
|
33
|
+
genesis_hash: string;
|
|
34
|
+
enclave_key: string;
|
|
35
|
+
endpoint: string;
|
|
36
|
+
model_identity_hash: string;
|
|
37
|
+
issued_at_ms: number;
|
|
38
|
+
signature: string;
|
|
39
|
+
}
|
|
40
|
+
/** The bytes the miner account signs. */
|
|
41
|
+
export declare function minerEndpointMessage(fields: EndpointAdFields): Uint8Array;
|
|
42
|
+
/** The miner account's sr25519 pair; a polkadot-js KeyringPair satisfies it. */
|
|
43
|
+
export interface AccountSigner {
|
|
44
|
+
publicKey: Uint8Array;
|
|
45
|
+
sign(message: Uint8Array): Uint8Array;
|
|
46
|
+
}
|
|
47
|
+
export declare function signMinerEndpointAd(signer: AccountSigner, fields: Omit<EndpointAdFields, "account">): MinerEndpointAd;
|
|
48
|
+
/**
|
|
49
|
+
* The ad's fields if its account signed them for `genesisHash`, else `undefined`. The sr25519
|
|
50
|
+
* verifier is WASM: await `cryptoWaitReady()` (compute-channel `ready()`) first.
|
|
51
|
+
*/
|
|
52
|
+
export declare function verifyMinerEndpointAd(ad: MinerEndpointAd, genesisHash: Uint8Array): EndpointAdFields | undefined;
|
|
53
|
+
export declare const SESSION_INFO_DOMAIN = "flop-session-info-v1";
|
|
54
|
+
/** Largest info-proof response a verifier reads, in bytes. */
|
|
55
|
+
export declare const MAX_INFO_PROOF_BYTES: number;
|
|
56
|
+
/** A model identity as JSON: hashes are lowercase hex without `0x`. */
|
|
57
|
+
export interface ModelIdentityWire {
|
|
58
|
+
requested_slug: string;
|
|
59
|
+
registry_model: string;
|
|
60
|
+
registry_version: string;
|
|
61
|
+
model_hash: string;
|
|
62
|
+
precision: number;
|
|
63
|
+
decode_policy_hash: string;
|
|
64
|
+
measured_root: string;
|
|
65
|
+
backend_model_name: string;
|
|
66
|
+
}
|
|
67
|
+
export declare function modelIdentityToWire(identity: VerifiedModelIdentity): ModelIdentityWire;
|
|
68
|
+
/** What a session server states in its proof. `image` fields are empty for an unstamped build. */
|
|
69
|
+
export interface SessionInfo {
|
|
70
|
+
genesisHash: Uint8Array;
|
|
71
|
+
account: Uint8Array;
|
|
72
|
+
enclaveKey: Uint8Array;
|
|
73
|
+
modelIdentity: VerifiedModelIdentity;
|
|
74
|
+
ready: boolean;
|
|
75
|
+
image: {
|
|
76
|
+
version: string;
|
|
77
|
+
revision: string;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** The proof as the session server returns it. */
|
|
81
|
+
export interface SessionInfoProof {
|
|
82
|
+
genesis_hash: string;
|
|
83
|
+
account_id: string;
|
|
84
|
+
enclave_key: string;
|
|
85
|
+
model_identity: ModelIdentityWire;
|
|
86
|
+
ready: boolean;
|
|
87
|
+
image: {
|
|
88
|
+
version: string;
|
|
89
|
+
revision: string;
|
|
90
|
+
};
|
|
91
|
+
signature: string;
|
|
92
|
+
}
|
|
93
|
+
/** The bytes the session key signs for `challenge`. */
|
|
94
|
+
export declare function sessionInfoMessage(challenge: Uint8Array, info: SessionInfo): Uint8Array;
|
|
95
|
+
/** Answer `challenge` with `info`, signed by the session key `enclave`. */
|
|
96
|
+
export declare function signSessionInfo(enclave: AccountSigner, challenge: Uint8Array, info: Omit<SessionInfo, "enclaveKey">): SessionInfoProof;
|
|
97
|
+
/** What a verifier expects of a proof: its own challenge and the ad it is checking. */
|
|
98
|
+
export interface InfoProofExpectation {
|
|
99
|
+
challenge: Uint8Array;
|
|
100
|
+
genesisHash: Uint8Array;
|
|
101
|
+
account: Uint8Array;
|
|
102
|
+
enclaveKey: Uint8Array;
|
|
103
|
+
modelIdentityHash: Uint8Array;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The served identity and build if `proof` answers `expected.challenge` for exactly the expected
|
|
107
|
+
* chain, account, session key and model, says it is ready, and the session key signed it; else
|
|
108
|
+
* `undefined`. Await `cryptoWaitReady()` first.
|
|
109
|
+
*/
|
|
110
|
+
export declare function verifySessionInfoProof(proof: unknown, expected: InfoProofExpectation): {
|
|
111
|
+
modelIdentity: VerifiedModelIdentity;
|
|
112
|
+
image: {
|
|
113
|
+
version: string;
|
|
114
|
+
revision: string;
|
|
115
|
+
};
|
|
116
|
+
} | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* POST `challenge` to `<endpoint>/session/info-proof` and return the parsed response. No redirect
|
|
119
|
+
* is followed (it would carry the request elsewhere), the response is capped at
|
|
120
|
+
* {@link MAX_INFO_PROOF_BYTES} and the whole exchange at 10 s; any of those, or a non-200, throws.
|
|
121
|
+
* The caller verifies the result and decides where `fetchImpl` may connect.
|
|
122
|
+
*/
|
|
123
|
+
export declare function fetchSessionInfoProof(endpoint: string, challenge: Uint8Array, fetchImpl?: typeof fetch): Promise<unknown>;
|
|
124
|
+
//# sourceMappingURL=miner-admission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"miner-admission.d.ts","sourceRoot":"","sources":["../src/miner-admission.ts"],"names":[],"mappings":"AAcA,OAAO,EAA4B,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAEvG,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAC9D,eAAO,MA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AC7B,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,GACpC,gBAAgB,CAWlB;AAED,uFAAuF;AACvF,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,UAAU,CAAC;IACtB,WAAW,EAAE,UAAU,CAAC;IACxB,OAAO,EAAE,UAAU,CAAC;IACpB,UAAU,EAAE,UAAU,CAAC;IACvB,iBAAiB,EAAE,UAAU,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,oBAAoB,GAC7B;IAAE,aAAa,EAAE,qBAAqB,CAAC;IAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAAG,SAAS,CA6BpG;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,UAAU,EACrB,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC,OAAO,CAAC,CA2BlB"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Miner admission without the tailnet (D3 (A) in docs/design/miner-without-tailnet.md).
|
|
3
|
+
*
|
|
4
|
+
* A miner publishes where its session server answers as an endpoint ad to the public mailbox
|
|
5
|
+
* (`POST /miner-endpoint`), signed by its account (sr25519, polkadot-js `pair.sign`) over
|
|
6
|
+
*
|
|
7
|
+
* "flop-miner-endpoint-v1" ‖ genesis (32) ‖ account (32) ‖ enclave_key (32)
|
|
8
|
+
* ‖ u32le(len) ‖ endpoint ‖ model_identity_hash (32) ‖ u64le(issued_at_ms)
|
|
9
|
+
*
|
|
10
|
+
* The mailbox (tee-bridge/miner-quote-server/src/endpoint_ads.rs) and the faucet's admission
|
|
11
|
+
* writer verify it. test-vectors/compute-channel/miner-endpoint-v1.json pins every copy.
|
|
12
|
+
*/
|
|
13
|
+
import { hexToU8a, u8aConcat, u8aToHex } from "@polkadot/util";
|
|
14
|
+
import { sr25519Verify } from "@polkadot/util-crypto";
|
|
15
|
+
import { blake2_256, u32le, u64le } from "./compute-channel/transcript.js";
|
|
16
|
+
export const MINER_ENDPOINT_DOMAIN = "flop-miner-endpoint-v1";
|
|
17
|
+
export const MODEL_IDENTITY_DOMAIN = "flop-model-identity-v1";
|
|
18
|
+
/** Longest endpoint an ad may name, in bytes (the canonical form is ASCII). */
|
|
19
|
+
export const MAX_ENDPOINT_BYTES = 256;
|
|
20
|
+
/** The worker republishes its ad this often, as it does its ghost key. */
|
|
21
|
+
export const ENDPOINT_AD_REPUBLISH_MS = 5 * 60_000;
|
|
22
|
+
const text = new TextEncoder();
|
|
23
|
+
function lengthPrefixed(value) {
|
|
24
|
+
return u8aConcat(u32le(value.length), value);
|
|
25
|
+
}
|
|
26
|
+
function hash32(value, label) {
|
|
27
|
+
if (value.length !== 32)
|
|
28
|
+
throw new RangeError(`${label} must be 32 bytes`);
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `blake2_256(MODEL_IDENTITY_DOMAIN ‖ identity)`, the identity encoded field by field as
|
|
33
|
+
* `turnEvidenceHash` encodes it: u32le-prefixed strings, raw 32-byte hashes, precision as one byte.
|
|
34
|
+
*/
|
|
35
|
+
export function modelIdentityHash(identity) {
|
|
36
|
+
if (!Number.isInteger(identity.precision) || identity.precision < 0 || identity.precision > 255) {
|
|
37
|
+
throw new RangeError("model precision must fit u8");
|
|
38
|
+
}
|
|
39
|
+
return blake2_256(u8aConcat(text.encode(MODEL_IDENTITY_DOMAIN), lengthPrefixed(text.encode(identity.requestedSlug)), lengthPrefixed(text.encode(identity.registryModel)), lengthPrefixed(text.encode(identity.registryVersion)), hash32(identity.modelHash, "modelHash"), new Uint8Array([identity.precision]), hash32(identity.decodePolicyHash, "decodePolicyHash"), hash32(identity.measuredRoot, "measuredRoot"), lengthPrefixed(text.encode(identity.backendModelName))));
|
|
40
|
+
}
|
|
41
|
+
const DNS_LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
42
|
+
const OCTET = /^(?:0|[1-9][0-9]{0,2})$/;
|
|
43
|
+
/**
|
|
44
|
+
* `https://`, a host and an optional port other than 443, nothing else: one spelling per endpoint,
|
|
45
|
+
* so the signed bytes are the URL a writer dials. The host is a lowercase DNS name or, since a URL
|
|
46
|
+
* parser reads any host ending in a number or `0x…` as IPv4 (`0x08080808` is 8.8.8.8), a
|
|
47
|
+
* dotted-decimal IPv4 address with no leading zeros. Whether it resolves to a public address is
|
|
48
|
+
* the admission writer's check, not the codec's.
|
|
49
|
+
*/
|
|
50
|
+
export function isCanonicalEndpoint(endpoint) {
|
|
51
|
+
if (endpoint.length > MAX_ENDPOINT_BYTES || !endpoint.startsWith("https://"))
|
|
52
|
+
return false;
|
|
53
|
+
const authority = endpoint.slice("https://".length);
|
|
54
|
+
const colon = authority.indexOf(":");
|
|
55
|
+
const host = colon === -1 ? authority : authority.slice(0, colon);
|
|
56
|
+
if (colon !== -1) {
|
|
57
|
+
const port = authority.slice(colon + 1);
|
|
58
|
+
if (!/^[1-9][0-9]{0,4}$/.test(port) || Number(port) > 65_535 || port === "443")
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
if (host.length === 0 || host.length > 253)
|
|
62
|
+
return false;
|
|
63
|
+
const labels = host.split(".");
|
|
64
|
+
const last = labels[labels.length - 1];
|
|
65
|
+
if (/^[0-9]+$/.test(last) || /^0x[0-9a-f]*$/.test(last)) {
|
|
66
|
+
return labels.length === 4 && labels.every(octet => OCTET.test(octet) && Number(octet) <= 255);
|
|
67
|
+
}
|
|
68
|
+
return labels.every(label => DNS_LABEL.test(label));
|
|
69
|
+
}
|
|
70
|
+
/** The bytes the miner account signs. */
|
|
71
|
+
export function minerEndpointMessage(fields) {
|
|
72
|
+
if (!isCanonicalEndpoint(fields.endpoint))
|
|
73
|
+
throw new RangeError("endpoint is not a canonical https URL");
|
|
74
|
+
if (!Number.isSafeInteger(fields.issuedAtMs) || fields.issuedAtMs < 0) {
|
|
75
|
+
throw new RangeError("issuedAtMs must be a non-negative safe integer");
|
|
76
|
+
}
|
|
77
|
+
return u8aConcat(text.encode(MINER_ENDPOINT_DOMAIN), hash32(fields.genesisHash, "genesisHash"), hash32(fields.account, "account"), hash32(fields.enclaveKey, "enclaveKey"), lengthPrefixed(text.encode(fields.endpoint)), hash32(fields.modelIdentityHash, "modelIdentityHash"), u64le(BigInt(fields.issuedAtMs)));
|
|
78
|
+
}
|
|
79
|
+
const bare = (bytes) => u8aToHex(bytes).slice(2);
|
|
80
|
+
export function signMinerEndpointAd(signer, fields) {
|
|
81
|
+
const signed = { ...fields, account: signer.publicKey };
|
|
82
|
+
return {
|
|
83
|
+
account_id: bare(signed.account),
|
|
84
|
+
genesis_hash: bare(signed.genesisHash),
|
|
85
|
+
enclave_key: bare(signed.enclaveKey),
|
|
86
|
+
endpoint: signed.endpoint,
|
|
87
|
+
model_identity_hash: bare(signed.modelIdentityHash),
|
|
88
|
+
issued_at_ms: signed.issuedAtMs,
|
|
89
|
+
signature: bare(signer.sign(minerEndpointMessage(signed))),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Lowercase hex without `0x`, exactly `bytes` long; any other spelling is refused, as the mailbox does. */
|
|
93
|
+
function hexField(value, bytes) {
|
|
94
|
+
if (typeof value !== "string" || value.length !== bytes * 2 || !/^[0-9a-f]*$/.test(value))
|
|
95
|
+
return undefined;
|
|
96
|
+
return hexToU8a(`0x${value}`);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The ad's fields if its account signed them for `genesisHash`, else `undefined`. The sr25519
|
|
100
|
+
* verifier is WASM: await `cryptoWaitReady()` (compute-channel `ready()`) first.
|
|
101
|
+
*/
|
|
102
|
+
export function verifyMinerEndpointAd(ad, genesisHash) {
|
|
103
|
+
const fields = {
|
|
104
|
+
genesisHash: hexField(ad.genesis_hash, 32),
|
|
105
|
+
account: hexField(ad.account_id, 32),
|
|
106
|
+
enclaveKey: hexField(ad.enclave_key, 32),
|
|
107
|
+
modelIdentityHash: hexField(ad.model_identity_hash, 32),
|
|
108
|
+
};
|
|
109
|
+
const signature = hexField(ad.signature, 64);
|
|
110
|
+
if (!fields.genesisHash || !fields.account || !fields.enclaveKey || !fields.modelIdentityHash || !signature
|
|
111
|
+
|| typeof ad.endpoint !== "string" || !isCanonicalEndpoint(ad.endpoint)
|
|
112
|
+
|| !Number.isSafeInteger(ad.issued_at_ms) || ad.issued_at_ms < 0
|
|
113
|
+
|| bare(fields.genesisHash) !== bare(hash32(genesisHash, "genesisHash")))
|
|
114
|
+
return undefined;
|
|
115
|
+
const decoded = {
|
|
116
|
+
genesisHash: fields.genesisHash, account: fields.account, enclaveKey: fields.enclaveKey,
|
|
117
|
+
endpoint: ad.endpoint, modelIdentityHash: fields.modelIdentityHash, issuedAtMs: ad.issued_at_ms,
|
|
118
|
+
};
|
|
119
|
+
try {
|
|
120
|
+
return sr25519Verify(minerEndpointMessage(decoded), signature, decoded.account) ? decoded : undefined;
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
// A key or signature that is not a valid point throws rather than failing to verify.
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/*
|
|
128
|
+
* Pre-funding info proof (#3432; D3 (A) step 2). The admission writer, and later the gateway, POST
|
|
129
|
+
* a fresh 32-byte challenge to `<endpoint>/session/info-proof`; the session server answers with
|
|
130
|
+
* what it serves and whether it is ready, signed by its session (enclave) key over
|
|
131
|
+
*
|
|
132
|
+
* "flop-session-info-v1" ‖ challenge (32) ‖ genesis (32) ‖ account (32) ‖ enclave_key (32)
|
|
133
|
+
* ‖ model_identity_hash (32) ‖ ready (u8) ‖ u32le(len) ‖ version ‖ u32le(len) ‖ revision
|
|
134
|
+
*
|
|
135
|
+
* test-vectors/compute-channel/session-info-proof-v1.json pins it.
|
|
136
|
+
*/
|
|
137
|
+
export const SESSION_INFO_DOMAIN = "flop-session-info-v1";
|
|
138
|
+
/** Largest info-proof response a verifier reads, in bytes. */
|
|
139
|
+
export const MAX_INFO_PROOF_BYTES = 16 * 1024;
|
|
140
|
+
const INFO_PROOF_TIMEOUT_MS = 10_000;
|
|
141
|
+
export function modelIdentityToWire(identity) {
|
|
142
|
+
return {
|
|
143
|
+
requested_slug: identity.requestedSlug,
|
|
144
|
+
registry_model: identity.registryModel,
|
|
145
|
+
registry_version: identity.registryVersion,
|
|
146
|
+
model_hash: bare(identity.modelHash),
|
|
147
|
+
precision: identity.precision,
|
|
148
|
+
decode_policy_hash: bare(identity.decodePolicyHash),
|
|
149
|
+
measured_root: bare(identity.measuredRoot),
|
|
150
|
+
backend_model_name: identity.backendModelName,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function modelIdentityFromWire(value) {
|
|
154
|
+
const wire = value;
|
|
155
|
+
if (!wire || typeof wire !== "object")
|
|
156
|
+
return undefined;
|
|
157
|
+
const modelHash = hexField(wire.model_hash, 32);
|
|
158
|
+
const decodePolicyHash = hexField(wire.decode_policy_hash, 32);
|
|
159
|
+
const measuredRoot = hexField(wire.measured_root, 32);
|
|
160
|
+
const strings = [wire.requested_slug, wire.registry_model, wire.registry_version, wire.backend_model_name];
|
|
161
|
+
if (!modelHash || !decodePolicyHash || !measuredRoot || !strings.every(item => typeof item === "string")
|
|
162
|
+
|| !Number.isInteger(wire.precision) || wire.precision < 0 || wire.precision > 255)
|
|
163
|
+
return undefined;
|
|
164
|
+
return {
|
|
165
|
+
requestedSlug: wire.requested_slug, registryModel: wire.registry_model, registryVersion: wire.registry_version,
|
|
166
|
+
modelHash, precision: wire.precision, decodePolicyHash, measuredRoot, backendModelName: wire.backend_model_name,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/** The bytes the session key signs for `challenge`. */
|
|
170
|
+
export function sessionInfoMessage(challenge, info) {
|
|
171
|
+
return u8aConcat(text.encode(SESSION_INFO_DOMAIN), hash32(challenge, "challenge"), hash32(info.genesisHash, "genesisHash"), hash32(info.account, "account"), hash32(info.enclaveKey, "enclaveKey"), modelIdentityHash(info.modelIdentity), new Uint8Array([info.ready ? 1 : 0]), lengthPrefixed(text.encode(info.image.version)), lengthPrefixed(text.encode(info.image.revision)));
|
|
172
|
+
}
|
|
173
|
+
/** Answer `challenge` with `info`, signed by the session key `enclave`. */
|
|
174
|
+
export function signSessionInfo(enclave, challenge, info) {
|
|
175
|
+
const signed = { ...info, enclaveKey: enclave.publicKey };
|
|
176
|
+
return {
|
|
177
|
+
genesis_hash: bare(signed.genesisHash),
|
|
178
|
+
account_id: bare(signed.account),
|
|
179
|
+
enclave_key: bare(signed.enclaveKey),
|
|
180
|
+
model_identity: modelIdentityToWire(signed.modelIdentity),
|
|
181
|
+
ready: signed.ready,
|
|
182
|
+
image: { ...signed.image },
|
|
183
|
+
signature: bare(enclave.sign(sessionInfoMessage(challenge, signed))),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The served identity and build if `proof` answers `expected.challenge` for exactly the expected
|
|
188
|
+
* chain, account, session key and model, says it is ready, and the session key signed it; else
|
|
189
|
+
* `undefined`. Await `cryptoWaitReady()` first.
|
|
190
|
+
*/
|
|
191
|
+
export function verifySessionInfoProof(proof, expected) {
|
|
192
|
+
const p = proof;
|
|
193
|
+
if (!p || typeof p !== "object")
|
|
194
|
+
return undefined;
|
|
195
|
+
const genesisHash = hexField(p.genesis_hash, 32);
|
|
196
|
+
const account = hexField(p.account_id, 32);
|
|
197
|
+
const enclaveKey = hexField(p.enclave_key, 32);
|
|
198
|
+
const signature = hexField(p.signature, 64);
|
|
199
|
+
const modelIdentity = modelIdentityFromWire(p.model_identity);
|
|
200
|
+
const image = p.image;
|
|
201
|
+
if (!genesisHash || !account || !enclaveKey || !signature || !modelIdentity
|
|
202
|
+
|| p.ready !== true || !image || typeof image.version !== "string" || typeof image.revision !== "string") {
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
const same = (a, b) => bare(a) === bare(b);
|
|
206
|
+
if (!same(genesisHash, expected.genesisHash) || !same(account, expected.account)
|
|
207
|
+
|| !same(enclaveKey, expected.enclaveKey) || !same(modelIdentityHash(modelIdentity), expected.modelIdentityHash)) {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
const info = {
|
|
211
|
+
genesisHash, account, enclaveKey, modelIdentity, ready: true,
|
|
212
|
+
image: { version: image.version, revision: image.revision },
|
|
213
|
+
};
|
|
214
|
+
try {
|
|
215
|
+
return sr25519Verify(sessionInfoMessage(expected.challenge, info), signature, enclaveKey)
|
|
216
|
+
? { modelIdentity, image: info.image }
|
|
217
|
+
: undefined;
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* POST `challenge` to `<endpoint>/session/info-proof` and return the parsed response. No redirect
|
|
225
|
+
* is followed (it would carry the request elsewhere), the response is capped at
|
|
226
|
+
* {@link MAX_INFO_PROOF_BYTES} and the whole exchange at 10 s; any of those, or a non-200, throws.
|
|
227
|
+
* The caller verifies the result and decides where `fetchImpl` may connect.
|
|
228
|
+
*/
|
|
229
|
+
export async function fetchSessionInfoProof(endpoint, challenge, fetchImpl = fetch) {
|
|
230
|
+
const res = await fetchImpl(`${endpoint}/session/info-proof`, {
|
|
231
|
+
method: "POST",
|
|
232
|
+
redirect: "error",
|
|
233
|
+
signal: AbortSignal.timeout(INFO_PROOF_TIMEOUT_MS),
|
|
234
|
+
headers: { "content-type": "application/json" },
|
|
235
|
+
body: JSON.stringify({ challenge: bare(hash32(challenge, "challenge")) }),
|
|
236
|
+
});
|
|
237
|
+
if (res.status !== 200) {
|
|
238
|
+
await res.body?.cancel();
|
|
239
|
+
throw new Error(`info proof refused: HTTP ${res.status}`);
|
|
240
|
+
}
|
|
241
|
+
const reader = res.body?.getReader();
|
|
242
|
+
if (!reader)
|
|
243
|
+
throw new Error("info proof has no body");
|
|
244
|
+
const chunks = [];
|
|
245
|
+
let size = 0;
|
|
246
|
+
for (;;) {
|
|
247
|
+
const { done, value } = await reader.read();
|
|
248
|
+
if (done)
|
|
249
|
+
break;
|
|
250
|
+
size += value.length;
|
|
251
|
+
if (size > MAX_INFO_PROOF_BYTES) {
|
|
252
|
+
await reader.cancel();
|
|
253
|
+
throw new Error(`info proof larger than ${MAX_INFO_PROOF_BYTES} bytes`);
|
|
254
|
+
}
|
|
255
|
+
chunks.push(value);
|
|
256
|
+
}
|
|
257
|
+
return JSON.parse(new TextDecoder().decode(u8aConcat(...chunks)));
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=miner-admission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"miner-admission.js","sourceRoot":"","sources":["../src/miner-admission.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAA8B,MAAM,iCAAiC,CAAC;AAEvG,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAC9D,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAC9D,+EAA+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AACtC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,MAAM,CAAC;AAEnD,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC;AAE/B,SAAS,cAAc,CAAC,KAAiB;IACvC,OAAO,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,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e,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/model-loader/registry.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAc9D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAyBlE;AAED,kGAAkG;AAClG,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,EAAE,CAG9D;AAED,yFAAyF;AACzF,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,EAC9B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUxB;AAED,gGAAgG;AAChG,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAmBhH"}
|
|
@@ -10,16 +10,10 @@
|
|
|
10
10
|
* operator-configured mirrors). The pure `decodeModelSource` decoders are exported so
|
|
11
11
|
* they can be unit-tested without live chain metadata.
|
|
12
12
|
*/
|
|
13
|
+
import { chainText } from "../chain-text.js";
|
|
13
14
|
/** Normalise a polkadot.js Vec<u8>/hex/utf8 value to a UTF-8 string. */
|
|
14
15
|
function bytesToUtf8(x) {
|
|
15
|
-
|
|
16
|
-
return x.startsWith("0x") ? Buffer.from(x.slice(2), "hex").toString("utf8") : x;
|
|
17
|
-
}
|
|
18
|
-
if (x instanceof Uint8Array)
|
|
19
|
-
return Buffer.from(x).toString("utf8");
|
|
20
|
-
if (Array.isArray(x))
|
|
21
|
-
return Buffer.from(x).toString("utf8");
|
|
22
|
-
return String(x);
|
|
16
|
+
return chainText(x);
|
|
23
17
|
}
|
|
24
18
|
function fieldOf(raw, ...names) {
|
|
25
19
|
for (const n of names) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/model-loader/registry.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,6CAA6C;AAC7C;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/model-loader/registry.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,6CAA6C;AAC7C;;;;;;;;;GASG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,wEAAwE;AACxE,SAAS,WAAW,CAAC,CAAU;IAC7B,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,OAAO,CAAC,GAAW,EAAE,GAAG,KAAe;IAC9C,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAK,GAA+B,CAAC,CAAC,CAAC,KAAK,SAAS;YAAE,OAAQ,GAA+B,CAAC,CAAC,CAAC,CAAC;IAChH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC5C,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACjD,MAAM,CAAC,GAAG,GAA8B,CAAC;IACzC,IAAI,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,SAAS,EAAE,CAAC;QAC/C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAC3E,CAAC;IACD,IAAI,OAAO,CAAC,CAAC,EAAE,a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IAAI,CACV,oBAAoB,SAAS,sDAAsD;YACjF,sCAAsC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAC3F,CAAC;QACF,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -2,7 +2,7 @@ export declare const SUPPORTED_SPEC_VERSIONS: readonly number[];
|
|
|
2
2
|
/** Compatibility envelope only; admission requires membership in SUPPORTED_SPEC_VERSIONS. */
|
|
3
3
|
export declare const SUPPORTED_SPEC_VERSION_RANGE: Readonly<{
|
|
4
4
|
min: 1013000;
|
|
5
|
-
max:
|
|
5
|
+
max: 1014014;
|
|
6
6
|
}>;
|
|
7
7
|
export declare function assertSupportedSpecVersion(specVersion: unknown): void;
|
|
8
8
|
//# sourceMappingURL=runtime-compatibility.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-compatibility.d.ts","sourceRoot":"","sources":["../src/runtime-compatibility.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-compatibility.d.ts","sourceRoot":"","sources":["../src/runtime-compatibility.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAAyL,CAAC;AAE/O,6FAA6F;AAC7F,eAAO,MAAM,4BAA4B;;;EAAoD,CAAC;AAE9F,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAQrE"}
|
|
@@ -7,10 +7,13 @@ import { FlopError } from "./errors.js";
|
|
|
7
7
|
// 1014007, integer quantity/duration forward terms and transaction version 2 (#3311).
|
|
8
8
|
// 1014008, staged fractional ownership and post-transfer holder counts (#3312).
|
|
9
9
|
// 1014009, atomic whole-listing native-FLOP resale (#3313).
|
|
10
|
+
// 1014014, per-identity reservation base raised to 400 (D-0540, #3744); wire bytes unchanged.
|
|
11
|
+
// 1014013, additive native profile/qualification registry and validated-inherent UTC clock.
|
|
12
|
+
// 1014012, primary-admission pause candidate with unchanged receipt/offer wire bytes.
|
|
10
13
|
// 1014011, funding-time economic snapshots and the v5 empty-state gate (#3132).
|
|
11
|
-
export const SUPPORTED_SPEC_VERSIONS = Object.freeze([1_013_000, 1_014_000, 1_014_001, 1_014_002, 1_014_003, 1_014_004, 1_014_005, 1_014_007, 1_014_008, 1_014_009, 1_014_010, 1_014_011]);
|
|
14
|
+
export const SUPPORTED_SPEC_VERSIONS = Object.freeze([1_013_000, 1_014_000, 1_014_001, 1_014_002, 1_014_003, 1_014_004, 1_014_005, 1_014_007, 1_014_008, 1_014_009, 1_014_010, 1_014_011, 1_014_012, 1_014_013, 1_014_014]);
|
|
12
15
|
/** Compatibility envelope only; admission requires membership in SUPPORTED_SPEC_VERSIONS. */
|
|
13
|
-
export const SUPPORTED_SPEC_VERSION_RANGE = Object.freeze({ min: 1_013_000, max:
|
|
16
|
+
export const SUPPORTED_SPEC_VERSION_RANGE = Object.freeze({ min: 1_013_000, max: 1_014_014 });
|
|
14
17
|
export function assertSupportedSpecVersion(specVersion) {
|
|
15
18
|
if (typeof specVersion !== "number" || !Number.isInteger(specVersion)
|
|
16
19
|
|| !SUPPORTED_SPEC_VERSIONS.includes(specVersion)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-compatibility.js","sourceRoot":"","sources":["../src/runtime-compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,kFAAkF;AAClF,qFAAqF;AACrF,qDAAqD;AACrD,iFAAiF;AACjF,4EAA4E;AAC5E,sFAAsF;AACtF,gFAAgF;AAChF,4DAA4D;AAC5D,gFAAgF;AAChF,MAAM,CAAC,MAAM,uBAAuB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime-compatibility.js","sourceRoot":"","sources":["../src/runtime-compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,kFAAkF;AAClF,qFAAqF;AACrF,qDAAqD;AACrD,iFAAiF;AACjF,4EAA4E;AAC5E,sFAAsF;AACtF,gFAAgF;AAChF,4DAA4D;AAC5D,8FAA8F;AAC9F,4FAA4F;AAC5F,sFAAsF;AACtF,gFAAgF;AAChF,MAAM,CAAC,MAAM,uBAAuB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;AAE/O,6FAA6F;AAC7F,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;AAE9F,MAAM,UAAU,0BAA0B,CAAC,WAAoB;IAC7D,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC;WAChE,CAAC,uBAAuB,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,SAAS,CACjB,oCAAoC,MAAM,CAAC,WAAW,CAAC,iCAAiC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,gEAAgE,EAC1L,sBAAsB,CACvB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/submit-tx.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TransactionSigner } from "./transaction-signer.js";
|
|
2
2
|
/**
|
|
3
3
|
* True when an extrinsic's events include a session circuit-breaker trip. The
|
|
4
4
|
* tripping spend dispatches successfully so its latch persists, but the
|
package/dist/submit-tx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit-tx.d.ts","sourceRoot":"","sources":["../src/submit-tx.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"submit-tx.d.ts","sourceRoot":"","sources":["../src/submit-tx.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAGjE;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,EAAE,GAAG,SAAS,GAAG,OAAO,CAMjF;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAIlF"}
|
package/dist/submit-tx.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2026 FLOP Network
|
|
2
2
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
3
3
|
import { CircuitBreakerTrippedError } from "./errors.js";
|
|
4
|
-
import {
|
|
4
|
+
import { watchTransaction } from "./watch-transaction.js";
|
|
5
5
|
/**
|
|
6
6
|
* True when an extrinsic's events include a session circuit-breaker trip. The
|
|
7
7
|
* tripping spend dispatches successfully so its latch persists, but the
|
|
@@ -17,17 +17,9 @@ export function trippedCircuitBreaker(events) {
|
|
|
17
17
|
* trip. Shared by the staking clients.
|
|
18
18
|
*/
|
|
19
19
|
export async function submitTx(tx, signer) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
else if (status.isInBlock || status.isFinalized) {
|
|
25
|
-
if (trippedCircuitBreaker(events))
|
|
26
|
-
reject(new CircuitBreakerTrippedError(txHash.toHex()));
|
|
27
|
-
else
|
|
28
|
-
resolve(txHash.toHex());
|
|
29
|
-
}
|
|
30
|
-
}).catch(reject);
|
|
31
|
-
});
|
|
20
|
+
const { txHash, events } = await watchTransaction(tx, signer);
|
|
21
|
+
if (trippedCircuitBreaker(events))
|
|
22
|
+
throw new CircuitBreakerTrippedError(txHash.toHex());
|
|
23
|
+
return txHash.toHex();
|
|
32
24
|
}
|
|
33
25
|
//# sourceMappingURL=submit-tx.js.map
|
package/dist/submit-tx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit-tx.js","sourceRoot":"","sources":["../src/submit-tx.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,6CAA6C;AAE7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"submit-tx.js","sourceRoot":"","sources":["../src/submit-tx.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,6CAA6C;AAE7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAkC;IACtE,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,CACxB,CAAC,EAAE,KAAK,EAAO,EAAE,EAAE,CACjB,KAAK,EAAE,MAAM,KAAK,uBAAuB;QACzC,CAAC,KAAK,CAAC,OAAO,KAAK,iBAAiB,IAAI,KAAK,CAAC,OAAO,KAAK,aAAa,CAAC,CAC3E,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,EAAO,EAAE,MAAyB;IAC/D,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,gBAAgB,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC9D,IAAI,qBAAqB,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,0BAA0B,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type TransactionSigner } from "./transaction-signer.js";
|
|
2
|
+
/** The exact submitted call failed in a finalized block; its intent must still fail. */
|
|
3
|
+
export declare class FinalizedTransactionError extends Error {
|
|
4
|
+
readonly txHash: string;
|
|
5
|
+
readonly blockHash: string;
|
|
6
|
+
readonly signerAddress: string;
|
|
7
|
+
readonly callHash: string;
|
|
8
|
+
readonly code = "TRANSACTION_FINALIZED_FAILED";
|
|
9
|
+
readonly outcome = "finalized_failed";
|
|
10
|
+
constructor(message: string, txHash: string, blockHash: string, signerAddress: string, callHash: string);
|
|
11
|
+
}
|
|
12
|
+
/** A watch ending is not proof that the transaction failed or never landed. */
|
|
13
|
+
export declare class TransactionUnconfirmedError extends Error {
|
|
14
|
+
readonly txHash: string | undefined;
|
|
15
|
+
readonly status: string;
|
|
16
|
+
readonly code = "TRANSACTION_UNCONFIRMED";
|
|
17
|
+
readonly outcome = "unconfirmed";
|
|
18
|
+
constructor(txHash: string | undefined, status: string, cause?: unknown);
|
|
19
|
+
}
|
|
20
|
+
/** Shared bounded watcher; cleans up even if the callback precedes the unsubscribe handle. */
|
|
21
|
+
export declare function watchTransaction(tx: any, signer: TransactionSigner, options?: {
|
|
22
|
+
waitForFinality?: boolean;
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
api?: any;
|
|
25
|
+
}): Promise<any>;
|
|
26
|
+
//# sourceMappingURL=watch-transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch-transaction.d.ts","sourceRoot":"","sources":["../src/watch-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAExG,wFAAwF;AACxF,qBA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