@heyanon-arp/sdk 0.0.15 → 0.0.23
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/dist/assets.d.ts +25 -1
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/post-commit.d.ts +34 -0
- package/dist/escrow/config-status.d.ts +38 -0
- package/dist/escrow/index.d.ts +2 -1
- package/dist/escrow/lock-account.d.ts +54 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +192 -2
- package/dist/index.mjs +161 -3
- package/dist/settlement/index.d.ts +1 -1
- package/dist/settlement/program-ids.d.ts +12 -0
- package/dist/types/agent.d.ts +80 -0
- package/dist/types/body.d.ts +29 -0
- package/dist/types/cli-auth.d.ts +41 -0
- package/dist/types/delegation.d.ts +21 -0
- package/dist/types/discovery.d.ts +87 -0
- package/dist/types/envelope.d.ts +7 -0
- package/dist/types/event.d.ts +20 -0
- package/dist/types/inbox.d.ts +33 -0
- package/dist/types/index.d.ts +14 -6
- package/dist/types/read-model.d.ts +160 -0
- package/dist/types/relationship.d.ts +11 -0
- package/dist/types/work-log.d.ts +8 -0
- package/package.json +1 -1
package/dist/assets.d.ts
CHANGED
|
@@ -113,10 +113,34 @@ export declare function isWhitelistedAssetId(assetId: string, cluster?: SolanaCl
|
|
|
113
113
|
* asset_reference = [-.%a-zA-Z0-9]{1,128}
|
|
114
114
|
*/
|
|
115
115
|
export declare const CAIP19_REGEX: RegExp;
|
|
116
|
+
/**
|
|
117
|
+
* `AssetIdentifier.decimals` bounds — base-unit exponent, inclusive
|
|
118
|
+
* [0, 18]. 18 is the max any whitelisted asset uses and matches the
|
|
119
|
+
* decimal-amount fraction cap below. NOT the SPL u8 mint-decimals
|
|
120
|
+
* range (0–255) — that's a distinct on-chain concept the CLI keeps
|
|
121
|
+
* local to base-unit conversion.
|
|
122
|
+
*/
|
|
123
|
+
export declare const ASSET_DECIMALS_MIN = 0;
|
|
124
|
+
export declare const ASSET_DECIMALS_MAX = 18;
|
|
125
|
+
/** `AssetIdentifier.symbol` length bounds (inclusive) when present. */
|
|
126
|
+
export declare const ASSET_SYMBOL_MIN_LEN = 1;
|
|
127
|
+
export declare const ASSET_SYMBOL_MAX_LEN = 16;
|
|
128
|
+
/**
|
|
129
|
+
* Canonical decimal-as-string AMOUNT shape: unsigned, ≥1 integer
|
|
130
|
+
* digit, optional fraction, bounded 30 integer / 18 fraction digits so
|
|
131
|
+
* BigInt scaling stays cheap and a hostile kilobyte-long "amount" is
|
|
132
|
+
* rejected up front (18 == {@link ASSET_DECIMALS_MAX}). The protocol's
|
|
133
|
+
* amount fields (delegation.offer amount, accept-prefs min/max) are
|
|
134
|
+
* decimal strings — server + CLI both validate against THIS regex so
|
|
135
|
+
* they can never disagree on what a valid amount looks like.
|
|
136
|
+
*/
|
|
137
|
+
export declare const DECIMAL_AMOUNT_REGEX: RegExp;
|
|
138
|
+
export declare function isDecimalAmountString(v: unknown): v is string;
|
|
116
139
|
/**
|
|
117
140
|
* Type guard for `AssetIdentifier`. Validates structural shape +
|
|
118
141
|
* CAIP-19 conformance of `asset_id` + decimals range. Symbol is
|
|
119
|
-
* optional but if present must be
|
|
142
|
+
* optional but if present must be {@link ASSET_SYMBOL_MIN_LEN}–
|
|
143
|
+
* {@link ASSET_SYMBOL_MAX_LEN} chars.
|
|
120
144
|
*/
|
|
121
145
|
export declare function isAssetIdentifier(value: unknown): value is AssetIdentifier;
|
|
122
146
|
/**
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ARP error codes that fire AFTER the server has committed the envelope
|
|
3
|
+
* event row to the hash chain (so the sender_sequence is consumed) but
|
|
4
|
+
* BEFORE the body handler materialises any read-model state.
|
|
5
|
+
*
|
|
6
|
+
* This is a single shared contract with two consumers:
|
|
7
|
+
* - the CLI advances `lastSenderSequence` on these (otherwise the next
|
|
8
|
+
* envelope reuses the consumed sequence and trips ENV_SEQUENCE_BACKWARDS);
|
|
9
|
+
* - the server marks the just-committed event `readModelStatus='rejected'`
|
|
10
|
+
* (otherwise `events --success-only` / the webhook reconciler would
|
|
11
|
+
* treat a rejected action as a materialised one).
|
|
12
|
+
*
|
|
13
|
+
* Previously this list lived in FOUR hand-maintained copies — three CLI
|
|
14
|
+
* sets (delegation/work/receipt) + the server's
|
|
15
|
+
* `PRE_MATERIALIZATION_REJECTION_CODES` — which had already drifted
|
|
16
|
+
* (the server was missing `RECEIPT_INVALID_STATE`). It is now owned here.
|
|
17
|
+
*/
|
|
18
|
+
export declare const POST_COMMIT_ERROR_CODES: readonly ["DELEGATION_ALREADY_EXISTS", "DELEGATION_INVALID_STATE", "DELEGATION_NOT_FOUND", "DELEGATION_RELATIONSHIP_MISMATCH", "DELEGATION_ACCEPTER_IS_OFFERER", "DELEGATION_DECLINER_IS_OFFERER", "DELEGATION_CANCELER_NOT_OFFERER", "DELEGATION_ASSET_NOT_ALLOWED", "DELEGATION_PRICING_MISMATCH", "DELEGATION_CAPACITY_EXCEEDED", "DELEGATION_PENDING_LOCK", "DELEGATION_FUNDER_NOT_OFFERER", "DELEGATION_ALREADY_FUNDED", "WORK_DELEGATION_NOT_FOUND", "WORK_DELEGATION_NOT_ACTIVE", "WORK_RELATIONSHIP_MISMATCH", "WORK_REQUESTER_NOT_OFFERER", "WORK_REQUEST_ALREADY_EXISTS", "WORK_REQUEST_NOT_FOUND", "WORK_RESPONDER_IS_CALLER", "WORK_INVALID_STATE", "RECEIPT_ALREADY_EXISTS", "RECEIPT_DELEGATION_NOT_FOUND", "RECEIPT_DELEGATION_NOT_ACTIVE", "RECEIPT_RELATIONSHIP_MISMATCH", "RECEIPT_ISSUER_IS_CALLER", "RECEIPT_NOT_FOUND", "RECEIPT_INVALID_STATE", "RECEIPT_RESPONSE_HASH_NOT_FOUND", "RECEIPT_REQUEST_HASH_NOT_FOUND", "RECEIPT_DELIVERABLE_HASH_MISMATCH"];
|
|
19
|
+
export type PostCommitErrorCode = (typeof POST_COMMIT_ERROR_CODES)[number];
|
|
20
|
+
/**
|
|
21
|
+
* Code-FAMILY prefixes that are always post-commit, enumerated rather
|
|
22
|
+
* than listed member-by-member because they grow over time:
|
|
23
|
+
* - `ESC_LOCK_*` — on-chain lock-validator cross-check rejections fire
|
|
24
|
+
* after the delegation/fund event is committed, before materialisation.
|
|
25
|
+
* - `SDK_*` — SDK-layer throws (canonical-encode / signature / id) that
|
|
26
|
+
* the server's internal-exception filter stamps with an `SDK_` code.
|
|
27
|
+
* These only appear in the FINAL wire code a CLIENT sees, so they
|
|
28
|
+
* matter to the CLI. Server-side classification runs in the message
|
|
29
|
+
* handler BEFORE that code is assigned, so the prefix is simply never
|
|
30
|
+
* matched there — harmless to share the same predicate.
|
|
31
|
+
*/
|
|
32
|
+
export declare const POST_COMMIT_ERROR_CODE_PREFIXES: readonly ["ESC_LOCK_", "SDK_"];
|
|
33
|
+
/** True if `code` is a post-commit error code (explicit member OR prefix family). */
|
|
34
|
+
export declare function isPostCommitErrorCode(code: string): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live on-chain escrow Config PDA snapshot — the shape the server's
|
|
3
|
+
* `GET /v1/escrow/config` returns and the CLI consumes. Single source
|
|
4
|
+
* of truth for the read-model contract: the server's config-reader
|
|
5
|
+
* service annotates its `readConfig()` return with this, and the CLI's
|
|
6
|
+
* `getEscrowConfig` types its response with it, so the two cannot drift.
|
|
7
|
+
*
|
|
8
|
+
* Framework-agnostic plain interface (no decorators) — the server reads
|
|
9
|
+
* it from a service, not a NestJS DTO class, so there is nothing to
|
|
10
|
+
* decorate; lamport amounts are decimal STRINGS (u64-safe), windows +
|
|
11
|
+
* fee_bps are numbers.
|
|
12
|
+
*/
|
|
13
|
+
export interface EscrowConfigStatus {
|
|
14
|
+
/** Config.fee_enabled bit. */
|
|
15
|
+
feeEnabled: boolean;
|
|
16
|
+
/** fee_bps as a number (u16). 0 when disabled or explicitly zero. */
|
|
17
|
+
feeBps: number;
|
|
18
|
+
/** base58 fee_recipient. The all-zero address sentinel means "no recipient configured". */
|
|
19
|
+
feeRecipient: string;
|
|
20
|
+
/** base58 treasury (receives the treasury share of dispute stakes). */
|
|
21
|
+
treasury: string;
|
|
22
|
+
/** Lamports the WORKER must stake at accept_lock. */
|
|
23
|
+
workerStakeLamports: string;
|
|
24
|
+
/** Lamports the operator collects per resolve_dispute. */
|
|
25
|
+
operatorDisputeFeeLamports: string;
|
|
26
|
+
/** Seconds the worker has to submit_work after accept_lock. */
|
|
27
|
+
workWindowSecs: number;
|
|
28
|
+
/** Seconds the buyer has to approve/dispute after submit_work. */
|
|
29
|
+
reviewWindowSecs: number;
|
|
30
|
+
/** Seconds the operator has to resolve after open_dispute. */
|
|
31
|
+
disputeWindowSecs: number;
|
|
32
|
+
/** Whether the contract is paused. */
|
|
33
|
+
paused: boolean;
|
|
34
|
+
/** The admin pubkey. */
|
|
35
|
+
admin: string;
|
|
36
|
+
/** The on-chain program id. */
|
|
37
|
+
programId: string;
|
|
38
|
+
}
|
package/dist/escrow/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { deriveLockId, delegationIdToBytes16, bytes16ToDelegationId } from './lock-id';
|
|
2
2
|
export { deriveDelegationConditionHash, type DelegationTermsSubset, type DelegationTermsInput } from './condition-hash';
|
|
3
3
|
export { parseCaip19SolanaAssetId, type ParsedSolanaAssetId } from './caip19';
|
|
4
|
+
export type { EscrowConfigStatus } from './config-status';
|
|
4
5
|
export { buildCreateLockIxData, computeCreateLockDiscriminator, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, type CreateLockArgs, } from './create-lock';
|
|
5
6
|
export { ESCROW_PDA_SEEDS, NO_ARG_LIFECYCLE_INSTRUCTIONS, type NoArgLifecycleInstruction, instructionDiscriminator, buildLifecycleIxData, buildResolveDisputeIxData, type ResolveDisputeArgs, } from './lifecycle-instructions';
|
|
6
|
-
export { LOCK_ACCOUNT_SIZE, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, NATIVE_SOL_MINT_BASE58, type LockStateName, type DecodedLockAccount, decodeLockAccount, computeLockAccountDiscriminator, } from './lock-account';
|
|
7
|
+
export { LOCK_ACCOUNT_SIZE, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, LockStates, LockTerminalStates, ESCROW_RELEASE_METHODS, EscrowReleaseMethods, NATIVE_SOL_MINT_BASE58, type LockStateName, type LockTerminalState, type EscrowReleaseMethodName, isEscrowReleaseMethod, type DecodedLockAccount, decodeLockAccount, computeLockAccountDiscriminator, } from './lock-account';
|
|
@@ -8,7 +8,60 @@ export declare const LOCK_ACCOUNT_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
|
8
8
|
export declare const LOCK_STATE_NAMES: readonly ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
|
|
9
9
|
export type LockStateName = (typeof LOCK_STATE_NAMES)[number];
|
|
10
10
|
/** Terminal lock states — no further on-chain transition exists. */
|
|
11
|
-
export declare const LOCK_TERMINAL_STATES: readonly
|
|
11
|
+
export declare const LOCK_TERMINAL_STATES: readonly ["canceled", "paid", "revoked", "dispute_resolved", "dispute_closed"];
|
|
12
|
+
/**
|
|
13
|
+
* The terminal subset of {@link LockStateName}. A receipt's
|
|
14
|
+
* `release_status` IS the on-chain lock's terminal state, so the
|
|
15
|
+
* server `ReceiptReleaseStatus` enum and the CLI `releaseStatus` DTO
|
|
16
|
+
* field both source this type instead of re-listing the literals.
|
|
17
|
+
*/
|
|
18
|
+
export type LockTerminalState = (typeof LOCK_TERMINAL_STATES)[number];
|
|
19
|
+
/**
|
|
20
|
+
* Named-member accessor for the terminal lock states (the subset that a
|
|
21
|
+
* receipt's `release_status` / a delegation's `releaseStatus` can hold).
|
|
22
|
+
* The server's `ReceiptReleaseStatus` enum and any `releaseStatus`
|
|
23
|
+
* field source these instead of re-listing the literals. Vocab-tested
|
|
24
|
+
* against {@link LOCK_TERMINAL_STATES}.
|
|
25
|
+
*/
|
|
26
|
+
export declare const LockTerminalStates: {
|
|
27
|
+
readonly CANCELED: "canceled";
|
|
28
|
+
readonly PAID: "paid";
|
|
29
|
+
readonly REVOKED: "revoked";
|
|
30
|
+
readonly DISPUTE_RESOLVED: "dispute_resolved";
|
|
31
|
+
readonly DISPUTE_CLOSED: "dispute_closed";
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* On-chain `WorkPaymentClaimed.claim_type` → how a paid lock was
|
|
35
|
+
* released. Discriminant order = u8 value (0 = buyer_approved,
|
|
36
|
+
* 1 = review_timeout). The server's `EscrowReleaseMethod` enum and the
|
|
37
|
+
* CLI claim `role` both source these values.
|
|
38
|
+
*/
|
|
39
|
+
export declare const ESCROW_RELEASE_METHODS: readonly ["buyer_approved", "review_timeout"];
|
|
40
|
+
export type EscrowReleaseMethodName = (typeof ESCROW_RELEASE_METHODS)[number];
|
|
41
|
+
export declare function isEscrowReleaseMethod(v: unknown): v is EscrowReleaseMethodName;
|
|
42
|
+
/**
|
|
43
|
+
* Named-member accessor for the on-chain lock FSM — lets consumers
|
|
44
|
+
* write `state === LockStates.SUBMITTED` / `case LockStates.PAID:`
|
|
45
|
+
* instead of bare strings. Values are the wire/decoder strings (== the
|
|
46
|
+
* {@link LockStateName} union), so they stay assignable everywhere with
|
|
47
|
+
* no casts. Parity with {@link LOCK_STATE_NAMES} is vocab-tested.
|
|
48
|
+
*/
|
|
49
|
+
export declare const LockStates: {
|
|
50
|
+
readonly CREATED: "created";
|
|
51
|
+
readonly CANCELED: "canceled";
|
|
52
|
+
readonly IN_PROGRESS: "in_progress";
|
|
53
|
+
readonly SUBMITTED: "submitted";
|
|
54
|
+
readonly PAID: "paid";
|
|
55
|
+
readonly REVOKED: "revoked";
|
|
56
|
+
readonly DISPUTING: "disputing";
|
|
57
|
+
readonly DISPUTE_RESOLVED: "dispute_resolved";
|
|
58
|
+
readonly DISPUTE_CLOSED: "dispute_closed";
|
|
59
|
+
};
|
|
60
|
+
/** Named-member accessor for {@link EscrowReleaseMethodName} (vocab-tested). */
|
|
61
|
+
export declare const EscrowReleaseMethods: {
|
|
62
|
+
readonly BUYER_APPROVED: "buyer_approved";
|
|
63
|
+
readonly REVIEW_TIMEOUT: "review_timeout";
|
|
64
|
+
};
|
|
12
65
|
/** The contract's native-SOL sentinel mint, base58 form of [0u8;32]. */
|
|
13
66
|
export declare const NATIVE_SOL_MINT_BASE58 = "11111111111111111111111111111111";
|
|
14
67
|
export interface DecodedLockAccount {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -312,6 +312,7 @@ var SPL_TOKEN_PROGRAM_ID_BASE58 = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
|
312
312
|
var TOKEN_2022_PROGRAM_ID_BASE58 = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
313
313
|
var ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
314
314
|
var SYSTEM_PROGRAM_ID_BASE58 = "11111111111111111111111111111111";
|
|
315
|
+
var ESCROW_PROGRAM_ID_BASE58 = "DckBAFZcE1AZWgVsz5ipnwSUy2wWeK5eBPBoyJgKVPzb";
|
|
315
316
|
|
|
316
317
|
// src/settlement/token-program.ts
|
|
317
318
|
function detectTokenProgramFromOwner(mintAccountOwnerBase58) {
|
|
@@ -427,6 +428,7 @@ function isSha256Hex(v) {
|
|
|
427
428
|
}
|
|
428
429
|
var ED25519_SIG_PREFIX = "ed25519:";
|
|
429
430
|
var PROTOCOL_VERSIONS = ["arp/0.1"];
|
|
431
|
+
var CURRENT_PROTOCOL_VERSION = PROTOCOL_VERSIONS[PROTOCOL_VERSIONS.length - 1];
|
|
430
432
|
|
|
431
433
|
// src/types/body.ts
|
|
432
434
|
var DECLINE_REASONS = ["missing_brief", "rate_too_low", "out_of_scope", "policy", "expired_proposal", "capacity", "unspecified", "other"];
|
|
@@ -437,18 +439,43 @@ var HANDSHAKE_DECISIONS = ["accept", "decline"];
|
|
|
437
439
|
function isHandshakeDecision(v) {
|
|
438
440
|
return typeof v === "string" && HANDSHAKE_DECISIONS.includes(v);
|
|
439
441
|
}
|
|
442
|
+
var HandshakeDecisions = {
|
|
443
|
+
ACCEPT: "accept",
|
|
444
|
+
DECLINE: "decline"
|
|
445
|
+
};
|
|
440
446
|
var DELEGATION_ACTIONS = ["offer", "accept", "decline", "cancel", "fund"];
|
|
441
447
|
function isDelegationAction(v) {
|
|
442
448
|
return typeof v === "string" && DELEGATION_ACTIONS.includes(v);
|
|
443
449
|
}
|
|
450
|
+
var DelegationActions = {
|
|
451
|
+
OFFER: "offer",
|
|
452
|
+
ACCEPT: "accept",
|
|
453
|
+
DECLINE: "decline",
|
|
454
|
+
CANCEL: "cancel",
|
|
455
|
+
FUND: "fund"
|
|
456
|
+
};
|
|
444
457
|
var RECEIPT_VERDICTS = ["accepted", "accepted_with_notes", "rejected"];
|
|
445
458
|
function isReceiptVerdict(v) {
|
|
446
459
|
return typeof v === "string" && RECEIPT_VERDICTS.includes(v);
|
|
447
460
|
}
|
|
461
|
+
var ReceiptVerdicts = {
|
|
462
|
+
ACCEPTED: "accepted",
|
|
463
|
+
ACCEPTED_WITH_NOTES: "accepted_with_notes",
|
|
464
|
+
REJECTED: "rejected"
|
|
465
|
+
};
|
|
448
466
|
var BODY_TYPES = ["handshake", "handshake_response", "delegation", "work_request", "work_response", "receipt", "dispute"];
|
|
449
467
|
function isBodyType(v) {
|
|
450
468
|
return typeof v === "string" && BODY_TYPES.includes(v);
|
|
451
469
|
}
|
|
470
|
+
var BodyTypes = {
|
|
471
|
+
HANDSHAKE: "handshake",
|
|
472
|
+
HANDSHAKE_RESPONSE: "handshake_response",
|
|
473
|
+
DELEGATION: "delegation",
|
|
474
|
+
WORK_REQUEST: "work_request",
|
|
475
|
+
WORK_RESPONSE: "work_response",
|
|
476
|
+
RECEIPT: "receipt",
|
|
477
|
+
DISPUTE: "dispute"
|
|
478
|
+
};
|
|
452
479
|
|
|
453
480
|
// src/types/delegation.ts
|
|
454
481
|
var DELEGATION_STATES = [
|
|
@@ -468,6 +495,19 @@ var DELEGATION_ACTIVE_STATES = ["offered", "accepted", "pending_lock_finalizatio
|
|
|
468
495
|
function isDelegationState(v) {
|
|
469
496
|
return typeof v === "string" && DELEGATION_STATES.includes(v);
|
|
470
497
|
}
|
|
498
|
+
var DelegationStates = {
|
|
499
|
+
OFFERED: "offered",
|
|
500
|
+
ACCEPTED: "accepted",
|
|
501
|
+
PENDING_LOCK_FINALIZATION: "pending_lock_finalization",
|
|
502
|
+
LOCKED: "locked",
|
|
503
|
+
DISPUTING: "disputing",
|
|
504
|
+
COMPLETED: "completed",
|
|
505
|
+
DECLINED: "declined",
|
|
506
|
+
CANCELED: "canceled",
|
|
507
|
+
FAILED: "failed",
|
|
508
|
+
REFUNDED: "refunded",
|
|
509
|
+
DISPUTE_RESOLVED: "dispute_resolved"
|
|
510
|
+
};
|
|
471
511
|
|
|
472
512
|
// src/types/relationship.ts
|
|
473
513
|
var RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused", "closed"];
|
|
@@ -475,12 +515,53 @@ var LIVE_RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused"];
|
|
|
475
515
|
function isRelationshipState(v) {
|
|
476
516
|
return typeof v === "string" && RELATIONSHIP_STATE_NAMES.includes(v);
|
|
477
517
|
}
|
|
518
|
+
var RelationshipStates = {
|
|
519
|
+
PENDING: "pending",
|
|
520
|
+
ACTIVE: "active",
|
|
521
|
+
PAUSED: "paused",
|
|
522
|
+
CLOSED: "closed"
|
|
523
|
+
};
|
|
478
524
|
|
|
479
525
|
// src/types/work-log.ts
|
|
480
526
|
var WORK_LOG_STATES = ["requested", "responded"];
|
|
481
527
|
function isWorkLogState(v) {
|
|
482
528
|
return typeof v === "string" && WORK_LOG_STATES.includes(v);
|
|
483
529
|
}
|
|
530
|
+
var WorkLogStates = {
|
|
531
|
+
REQUESTED: "requested",
|
|
532
|
+
RESPONDED: "responded"
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
// src/types/event.ts
|
|
536
|
+
var READ_MODEL_STATUSES = ["materialized", "rejected"];
|
|
537
|
+
function isReadModelStatus(v) {
|
|
538
|
+
return typeof v === "string" && READ_MODEL_STATUSES.includes(v);
|
|
539
|
+
}
|
|
540
|
+
var ReadModelStatuses = {
|
|
541
|
+
MATERIALIZED: "materialized",
|
|
542
|
+
REJECTED: "rejected"
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
// src/types/discovery.ts
|
|
546
|
+
var DISCOVERY_SORTS = ["reputation", "recent", "created"];
|
|
547
|
+
function isDiscoverySort(v) {
|
|
548
|
+
return typeof v === "string" && DISCOVERY_SORTS.includes(v);
|
|
549
|
+
}
|
|
550
|
+
var DiscoverySorts = {
|
|
551
|
+
REPUTATION: "reputation",
|
|
552
|
+
RECENT: "recent",
|
|
553
|
+
CREATED: "created"
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
// src/types/inbox.ts
|
|
557
|
+
var INBOX_BLOCK_SCOPES = ["account", "did"];
|
|
558
|
+
function isInboxBlockScope(v) {
|
|
559
|
+
return typeof v === "string" && INBOX_BLOCK_SCOPES.includes(v);
|
|
560
|
+
}
|
|
561
|
+
var InboxBlockScopes = {
|
|
562
|
+
ACCOUNT: "account",
|
|
563
|
+
DID: "did"
|
|
564
|
+
};
|
|
484
565
|
|
|
485
566
|
// src/assets.ts
|
|
486
567
|
var SOLANA_CLUSTER_IDS = {
|
|
@@ -552,12 +633,20 @@ function isWhitelistedAssetId(assetId, cluster) {
|
|
|
552
633
|
return cluster === void 0 || hit.cluster === cluster;
|
|
553
634
|
}
|
|
554
635
|
var CAIP19_REGEX = /^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}$/;
|
|
636
|
+
var ASSET_DECIMALS_MIN = 0;
|
|
637
|
+
var ASSET_DECIMALS_MAX = 18;
|
|
638
|
+
var ASSET_SYMBOL_MIN_LEN = 1;
|
|
639
|
+
var ASSET_SYMBOL_MAX_LEN = 16;
|
|
640
|
+
var DECIMAL_AMOUNT_REGEX = /^\d{1,30}(\.\d{1,18})?$/;
|
|
641
|
+
function isDecimalAmountString(v) {
|
|
642
|
+
return typeof v === "string" && DECIMAL_AMOUNT_REGEX.test(v);
|
|
643
|
+
}
|
|
555
644
|
function isAssetIdentifier(value) {
|
|
556
645
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
557
646
|
const v = value;
|
|
558
647
|
if (typeof v.asset_id !== "string" || !CAIP19_REGEX.test(v.asset_id)) return false;
|
|
559
|
-
if (typeof v.decimals !== "number" || !Number.isInteger(v.decimals) || v.decimals <
|
|
560
|
-
if (v.symbol !== void 0 && (typeof v.symbol !== "string" || v.symbol.length
|
|
648
|
+
if (typeof v.decimals !== "number" || !Number.isInteger(v.decimals) || v.decimals < ASSET_DECIMALS_MIN || v.decimals > ASSET_DECIMALS_MAX) return false;
|
|
649
|
+
if (v.symbol !== void 0 && (typeof v.symbol !== "string" || v.symbol.length < ASSET_SYMBOL_MIN_LEN || v.symbol.length > ASSET_SYMBOL_MAX_LEN)) return false;
|
|
561
650
|
return true;
|
|
562
651
|
}
|
|
563
652
|
function resolveAsset(input) {
|
|
@@ -724,6 +813,32 @@ var LOCK_ACCOUNT_SIZE = 269;
|
|
|
724
813
|
var LOCK_ACCOUNT_DISCRIMINATOR = new Uint8Array([8, 255, 36, 202, 210, 22, 57, 137]);
|
|
725
814
|
var LOCK_STATE_NAMES = ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
|
|
726
815
|
var LOCK_TERMINAL_STATES = ["canceled", "paid", "revoked", "dispute_resolved", "dispute_closed"];
|
|
816
|
+
var LockTerminalStates = {
|
|
817
|
+
CANCELED: "canceled",
|
|
818
|
+
PAID: "paid",
|
|
819
|
+
REVOKED: "revoked",
|
|
820
|
+
DISPUTE_RESOLVED: "dispute_resolved",
|
|
821
|
+
DISPUTE_CLOSED: "dispute_closed"
|
|
822
|
+
};
|
|
823
|
+
var ESCROW_RELEASE_METHODS = ["buyer_approved", "review_timeout"];
|
|
824
|
+
function isEscrowReleaseMethod(v) {
|
|
825
|
+
return typeof v === "string" && ESCROW_RELEASE_METHODS.includes(v);
|
|
826
|
+
}
|
|
827
|
+
var LockStates = {
|
|
828
|
+
CREATED: "created",
|
|
829
|
+
CANCELED: "canceled",
|
|
830
|
+
IN_PROGRESS: "in_progress",
|
|
831
|
+
SUBMITTED: "submitted",
|
|
832
|
+
PAID: "paid",
|
|
833
|
+
REVOKED: "revoked",
|
|
834
|
+
DISPUTING: "disputing",
|
|
835
|
+
DISPUTE_RESOLVED: "dispute_resolved",
|
|
836
|
+
DISPUTE_CLOSED: "dispute_closed"
|
|
837
|
+
};
|
|
838
|
+
var EscrowReleaseMethods = {
|
|
839
|
+
BUYER_APPROVED: "buyer_approved",
|
|
840
|
+
REVIEW_TIMEOUT: "review_timeout"
|
|
841
|
+
};
|
|
727
842
|
var NATIVE_SOL_MINT_BASE58 = "11111111111111111111111111111111";
|
|
728
843
|
function decodeLockAccount(data) {
|
|
729
844
|
if (data.length !== LOCK_ACCOUNT_SIZE) {
|
|
@@ -776,35 +891,103 @@ function readU64LE(buf, off) {
|
|
|
776
891
|
return v;
|
|
777
892
|
}
|
|
778
893
|
|
|
894
|
+
// src/errors/post-commit.ts
|
|
895
|
+
var POST_COMMIT_ERROR_CODES = [
|
|
896
|
+
// delegation handler (offer / accept / decline / cancel / fund)
|
|
897
|
+
"DELEGATION_ALREADY_EXISTS",
|
|
898
|
+
"DELEGATION_INVALID_STATE",
|
|
899
|
+
"DELEGATION_NOT_FOUND",
|
|
900
|
+
"DELEGATION_RELATIONSHIP_MISMATCH",
|
|
901
|
+
"DELEGATION_ACCEPTER_IS_OFFERER",
|
|
902
|
+
"DELEGATION_DECLINER_IS_OFFERER",
|
|
903
|
+
"DELEGATION_CANCELER_NOT_OFFERER",
|
|
904
|
+
"DELEGATION_ASSET_NOT_ALLOWED",
|
|
905
|
+
"DELEGATION_PRICING_MISMATCH",
|
|
906
|
+
"DELEGATION_CAPACITY_EXCEEDED",
|
|
907
|
+
"DELEGATION_PENDING_LOCK",
|
|
908
|
+
"DELEGATION_FUNDER_NOT_OFFERER",
|
|
909
|
+
"DELEGATION_ALREADY_FUNDED",
|
|
910
|
+
// work handler (request / respond)
|
|
911
|
+
"WORK_DELEGATION_NOT_FOUND",
|
|
912
|
+
"WORK_DELEGATION_NOT_ACTIVE",
|
|
913
|
+
"WORK_RELATIONSHIP_MISMATCH",
|
|
914
|
+
"WORK_REQUESTER_NOT_OFFERER",
|
|
915
|
+
"WORK_REQUEST_ALREADY_EXISTS",
|
|
916
|
+
"WORK_REQUEST_NOT_FOUND",
|
|
917
|
+
"WORK_RESPONDER_IS_CALLER",
|
|
918
|
+
"WORK_INVALID_STATE",
|
|
919
|
+
// receipt handler (propose)
|
|
920
|
+
"RECEIPT_ALREADY_EXISTS",
|
|
921
|
+
"RECEIPT_DELEGATION_NOT_FOUND",
|
|
922
|
+
"RECEIPT_DELEGATION_NOT_ACTIVE",
|
|
923
|
+
"RECEIPT_RELATIONSHIP_MISMATCH",
|
|
924
|
+
"RECEIPT_ISSUER_IS_CALLER",
|
|
925
|
+
"RECEIPT_NOT_FOUND",
|
|
926
|
+
"RECEIPT_INVALID_STATE",
|
|
927
|
+
"RECEIPT_RESPONSE_HASH_NOT_FOUND",
|
|
928
|
+
"RECEIPT_REQUEST_HASH_NOT_FOUND",
|
|
929
|
+
"RECEIPT_DELIVERABLE_HASH_MISMATCH"
|
|
930
|
+
];
|
|
931
|
+
var POST_COMMIT_ERROR_CODE_PREFIXES = ["ESC_LOCK_", "SDK_"];
|
|
932
|
+
var POST_COMMIT_SET = new Set(POST_COMMIT_ERROR_CODES);
|
|
933
|
+
function isPostCommitErrorCode(code) {
|
|
934
|
+
return POST_COMMIT_SET.has(code) || POST_COMMIT_ERROR_CODE_PREFIXES.some((p) => code.startsWith(p));
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
exports.ASSET_DECIMALS_MAX = ASSET_DECIMALS_MAX;
|
|
938
|
+
exports.ASSET_DECIMALS_MIN = ASSET_DECIMALS_MIN;
|
|
939
|
+
exports.ASSET_SYMBOL_MAX_LEN = ASSET_SYMBOL_MAX_LEN;
|
|
940
|
+
exports.ASSET_SYMBOL_MIN_LEN = ASSET_SYMBOL_MIN_LEN;
|
|
779
941
|
exports.ASSET_WHITELIST = ASSET_WHITELIST;
|
|
780
942
|
exports.ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = ASSOCIATED_TOKEN_PROGRAM_ID_BASE58;
|
|
781
943
|
exports.BODY_TYPES = BODY_TYPES;
|
|
944
|
+
exports.BodyTypes = BodyTypes;
|
|
782
945
|
exports.CAIP19_REGEX = CAIP19_REGEX;
|
|
783
946
|
exports.CREATE_LOCK_DISCRIMINATOR = CREATE_LOCK_DISCRIMINATOR;
|
|
784
947
|
exports.CREATE_LOCK_NATIVE_DISCRIMINATOR = CREATE_LOCK_NATIVE_DISCRIMINATOR;
|
|
948
|
+
exports.CURRENT_PROTOCOL_VERSION = CURRENT_PROTOCOL_VERSION;
|
|
949
|
+
exports.DECIMAL_AMOUNT_REGEX = DECIMAL_AMOUNT_REGEX;
|
|
785
950
|
exports.DECLINE_REASONS = DECLINE_REASONS;
|
|
786
951
|
exports.DELEGATION_ACTIONS = DELEGATION_ACTIONS;
|
|
787
952
|
exports.DELEGATION_ACTIVE_STATES = DELEGATION_ACTIVE_STATES;
|
|
788
953
|
exports.DELEGATION_STATES = DELEGATION_STATES;
|
|
789
954
|
exports.DEVNET_MINTS = DEVNET_MINTS;
|
|
955
|
+
exports.DISCOVERY_SORTS = DISCOVERY_SORTS;
|
|
956
|
+
exports.DelegationActions = DelegationActions;
|
|
957
|
+
exports.DelegationStates = DelegationStates;
|
|
958
|
+
exports.DiscoverySorts = DiscoverySorts;
|
|
790
959
|
exports.ED25519_SIG_PREFIX = ED25519_SIG_PREFIX;
|
|
791
960
|
exports.ESCROW_PDA_SEEDS = ESCROW_PDA_SEEDS;
|
|
961
|
+
exports.ESCROW_PROGRAM_ID_BASE58 = ESCROW_PROGRAM_ID_BASE58;
|
|
962
|
+
exports.ESCROW_RELEASE_METHODS = ESCROW_RELEASE_METHODS;
|
|
963
|
+
exports.EscrowReleaseMethods = EscrowReleaseMethods;
|
|
792
964
|
exports.HANDSHAKE_DECISIONS = HANDSHAKE_DECISIONS;
|
|
965
|
+
exports.HandshakeDecisions = HandshakeDecisions;
|
|
966
|
+
exports.INBOX_BLOCK_SCOPES = INBOX_BLOCK_SCOPES;
|
|
967
|
+
exports.InboxBlockScopes = InboxBlockScopes;
|
|
793
968
|
exports.LIVE_RELATIONSHIP_STATE_NAMES = LIVE_RELATIONSHIP_STATE_NAMES;
|
|
794
969
|
exports.LOCK_ACCOUNT_DISCRIMINATOR = LOCK_ACCOUNT_DISCRIMINATOR;
|
|
795
970
|
exports.LOCK_ACCOUNT_SIZE = LOCK_ACCOUNT_SIZE;
|
|
796
971
|
exports.LOCK_STATE_NAMES = LOCK_STATE_NAMES;
|
|
797
972
|
exports.LOCK_TERMINAL_STATES = LOCK_TERMINAL_STATES;
|
|
973
|
+
exports.LockStates = LockStates;
|
|
974
|
+
exports.LockTerminalStates = LockTerminalStates;
|
|
798
975
|
exports.MAINNET_MINTS = MAINNET_MINTS;
|
|
799
976
|
exports.MAX_CLOCK_SKEW_SECONDS = MAX_CLOCK_SKEW_SECONDS;
|
|
800
977
|
exports.MAX_ENVELOPE_TTL_SECONDS = MAX_ENVELOPE_TTL_SECONDS;
|
|
801
978
|
exports.NATIVE_SOL_MINT_BASE58 = NATIVE_SOL_MINT_BASE58;
|
|
802
979
|
exports.NO_ARG_LIFECYCLE_INSTRUCTIONS = NO_ARG_LIFECYCLE_INSTRUCTIONS;
|
|
803
980
|
exports.OWNER_SIGNING_METHODS = OWNER_SIGNING_METHODS;
|
|
981
|
+
exports.POST_COMMIT_ERROR_CODES = POST_COMMIT_ERROR_CODES;
|
|
982
|
+
exports.POST_COMMIT_ERROR_CODE_PREFIXES = POST_COMMIT_ERROR_CODE_PREFIXES;
|
|
804
983
|
exports.PROTOCOL_VERSIONS = PROTOCOL_VERSIONS;
|
|
805
984
|
exports.Purpose = Purpose;
|
|
985
|
+
exports.READ_MODEL_STATUSES = READ_MODEL_STATUSES;
|
|
806
986
|
exports.RECEIPT_VERDICTS = RECEIPT_VERDICTS;
|
|
807
987
|
exports.RELATIONSHIP_STATE_NAMES = RELATIONSHIP_STATE_NAMES;
|
|
988
|
+
exports.ReadModelStatuses = ReadModelStatuses;
|
|
989
|
+
exports.ReceiptVerdicts = ReceiptVerdicts;
|
|
990
|
+
exports.RelationshipStates = RelationshipStates;
|
|
808
991
|
exports.SCRYPT_PARAMS = SCRYPT_PARAMS;
|
|
809
992
|
exports.SHA256_HEX_RE = SHA256_HEX_RE;
|
|
810
993
|
exports.SLIP44_SOLANA = SLIP44_SOLANA;
|
|
@@ -815,6 +998,7 @@ exports.TOKEN_2022_PROGRAM_ID_BASE58 = TOKEN_2022_PROGRAM_ID_BASE58;
|
|
|
815
998
|
exports.WELL_KNOWN_ASSETS = WELL_KNOWN_ASSETS;
|
|
816
999
|
exports.WELL_KNOWN_ASSET_KEYS = WELL_KNOWN_ASSET_KEYS;
|
|
817
1000
|
exports.WORK_LOG_STATES = WORK_LOG_STATES;
|
|
1001
|
+
exports.WorkLogStates = WorkLogStates;
|
|
818
1002
|
exports.base58btcDecode = base58btcDecode;
|
|
819
1003
|
exports.base58btcEncode = base58btcEncode;
|
|
820
1004
|
exports.buildCreateLockIxData = buildCreateLockIxData;
|
|
@@ -842,10 +1026,16 @@ exports.getPublicKey = getPublicKey2;
|
|
|
842
1026
|
exports.instructionDiscriminator = instructionDiscriminator;
|
|
843
1027
|
exports.isAssetIdentifier = isAssetIdentifier;
|
|
844
1028
|
exports.isBodyType = isBodyType;
|
|
1029
|
+
exports.isDecimalAmountString = isDecimalAmountString;
|
|
845
1030
|
exports.isDeclineReason = isDeclineReason;
|
|
846
1031
|
exports.isDelegationAction = isDelegationAction;
|
|
847
1032
|
exports.isDelegationState = isDelegationState;
|
|
1033
|
+
exports.isDiscoverySort = isDiscoverySort;
|
|
1034
|
+
exports.isEscrowReleaseMethod = isEscrowReleaseMethod;
|
|
848
1035
|
exports.isHandshakeDecision = isHandshakeDecision;
|
|
1036
|
+
exports.isInboxBlockScope = isInboxBlockScope;
|
|
1037
|
+
exports.isPostCommitErrorCode = isPostCommitErrorCode;
|
|
1038
|
+
exports.isReadModelStatus = isReadModelStatus;
|
|
849
1039
|
exports.isReceiptVerdict = isReceiptVerdict;
|
|
850
1040
|
exports.isRelationshipState = isRelationshipState;
|
|
851
1041
|
exports.isSha256Hex = isSha256Hex;
|