@degenerate/generic 0.3.2 → 0.6.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.
- package/dist/_settings/cryptography-settings.d.ts +5 -1
- package/dist/_settings/cryptography-settings.d.ts.map +1 -1
- package/dist/_settings/cryptography-settings.js +5 -1
- package/dist/_settings/database-settings.d.ts +3 -0
- package/dist/_settings/database-settings.d.ts.map +1 -1
- package/dist/_settings/database-settings.js +3 -0
- package/dist/crypto/index.d.ts +5 -9
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js +7 -9
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.d.ts +22 -0
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.d.ts.map +1 -0
- package/dist/crypto/private-public-keys/create-ed25519-keys-from-mnemonic.js +65 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.d.ts +11 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.d.ts.map +1 -0
- package/dist/crypto/private-public-keys/get-ed25519-public-key-from-private-key.js +15 -0
- package/dist/crypto/signature/create-ed25519-signature.d.ts +16 -0
- package/dist/crypto/signature/create-ed25519-signature.d.ts.map +1 -0
- package/dist/crypto/signature/create-ed25519-signature.js +26 -0
- package/dist/crypto/signature/ed25519-primitives.d.ts +25 -0
- package/dist/crypto/signature/ed25519-primitives.d.ts.map +1 -0
- package/dist/crypto/signature/ed25519-primitives.js +65 -0
- package/dist/crypto/signature/verify-ed25519-signature.d.ts +13 -0
- package/dist/crypto/signature/verify-ed25519-signature.d.ts.map +1 -0
- package/dist/crypto/signature/verify-ed25519-signature.js +31 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +1 -0
- package/dist/errors/settlement/settlement-errors.d.ts +74 -0
- package/dist/errors/settlement/settlement-errors.d.ts.map +1 -0
- package/dist/errors/settlement/settlement-errors.js +93 -0
- package/dist/errors/share-data/share-data-errors.d.ts +13 -0
- package/dist/errors/share-data/share-data-errors.d.ts.map +1 -1
- package/dist/errors/share-data/share-data-errors.js +19 -1
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +1 -0
- package/dist/models/safe/transactions/sharedata-transactions-models.d.ts +10 -0
- package/dist/models/safe/transactions/sharedata-transactions-models.d.ts.map +1 -1
- package/dist/models/settlement/settlement-models.d.ts +221 -0
- package/dist/models/settlement/settlement-models.d.ts.map +1 -0
- package/dist/models/settlement/settlement-models.js +152 -0
- package/dist/models/share-data/share-data-crypto-models.d.ts +37 -0
- package/dist/models/share-data/share-data-crypto-models.d.ts.map +1 -1
- package/dist/models/share-data/share-data-crypto-models.js +41 -1
- package/dist/models/share-data/share-data-persistence-models.d.ts +12 -2
- package/dist/models/share-data/share-data-persistence-models.d.ts.map +1 -1
- package/dist/models/share-data/share-data-persistence-models.js +9 -2
- package/dist/models/shareblock/shareblock-models.d.ts +395 -10
- package/dist/models/shareblock/shareblock-models.d.ts.map +1 -1
- package/dist/models/shareblock/shareblock-models.js +275 -10
- package/package.json +3 -4
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts +0 -12
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.js +0 -54
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts +0 -11
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-private-key.js +0 -50
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts +0 -11
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/create-key-pair-from-public-key.js +0 -51
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts +0 -10
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.js +0 -51
- package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts +0 -11
- package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/generate-key-pair.js +0 -49
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts +0 -15
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts.map +0 -1
- package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.js +0 -21
- package/dist/crypto/signature/create-crypto-signature.d.ts +0 -20
- package/dist/crypto/signature/create-crypto-signature.d.ts.map +0 -1
- package/dist/crypto/signature/create-crypto-signature.js +0 -26
- package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts +0 -17
- package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts.map +0 -1
- package/dist/crypto/signature/verify-crypto-signature-by-data.js +0 -61
- package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts +0 -17
- package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts.map +0 -1
- package/dist/crypto/signature/verify-crypto-signature-by-hash.js +0 -58
|
@@ -138,6 +138,19 @@ export declare class ShareDataTransactionProofFailedError extends BaseError {
|
|
|
138
138
|
export declare class ShareDataTransactionNotAuthorizedError extends BaseError {
|
|
139
139
|
constructor(shareDataId: string, signingPublicKey: string);
|
|
140
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* This error is thrown when a delegated-signer registration is rejected.
|
|
143
|
+
* Distinct from {@link ShareDataTransactionNotAuthorizedError} (which rejects a
|
|
144
|
+
* runtime *transaction* whose signer is not authorized): this rejects the
|
|
145
|
+
* *registration* of a delegate — either because the registration proof was not
|
|
146
|
+
* signed by the block's `creationPublicKey` (only the owner may delegate; there
|
|
147
|
+
* is no transitive delegation), because the granted function-id set is empty,
|
|
148
|
+
* or because the proof's `purpose` does not bind the exact
|
|
149
|
+
* `(signerPublicKey, functionIds)` grant being registered.
|
|
150
|
+
*/
|
|
151
|
+
export declare class ShareDataDelegationNotAuthorizedError extends BaseError {
|
|
152
|
+
constructor(shareDataId: string, registeringPublicKey: string);
|
|
153
|
+
}
|
|
141
154
|
/**
|
|
142
155
|
* This error is thrown when the system attempts to get the previous share data hash
|
|
143
156
|
* but the share data has not been initialized for the proof yet.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-data-errors.d.ts","sourceRoot":"","sources":["../../../src/errors/share-data/share-data-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;IACjD;;OAEG;gBACS,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc;CAGjE;AAED;;GAEG;AACH,qBAAa,2CAA4C,SAAQ,SAAS;IACtE;;OAEG;gBACS,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,SAAS;IAClD;;OAEG;gBACS,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,yDAA0D,SAAQ,SAAS;IACpF;;OAEG;gBACS,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAI5E;AAGD;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,SAAS;IACxD;;OAEG;gBACS,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM;CAIjG;AAKD;;GAEG;AACH,qBAAa,yCAA0C,SAAQ,SAAS;IACpE;;OAEG;gBACS,MAAM,EAAE,MAAM;CAG7B;AAED;;GAEG;AACH,qBAAa,0CAA2C,SAAQ,SAAS;IACrE;;OAEG;gBACS,MAAM,EAAE,MAAM;CAG7B;AAID;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,SAAS;gBAC1C,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;gBACrC,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,SAAS;gBACtC,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,iCAAkC,SAAQ,SAAS;gBAChD,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,6CAA8C,SAAQ,SAAS;gBAC5D,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,SAAS;gBAC9C,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,0CAA2C,SAAQ,SAAS;gBACzD,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,SAAS;gBAClD,WAAW,EAAE,MAAM;CAGlC;AAED;;;;;;;;;GASG;AACH,qBAAa,oCAAqC,SAAQ,SAAS;gBACnD,WAAW,EAAE,MAAM;CAGlC;AAED;;;;;;;;;GASG;AACH,qBAAa,sCAAuC,SAAQ,SAAS;gBACrD,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;CAM5D;AAED;;;GAGG;AACH,qBAAa,sCAAuC,SAAQ,SAAS;gBACrD,WAAW,EAAE,MAAM;CAIlC;AAED;;;;;;GAMG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;gBACxC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAGlD"}
|
|
1
|
+
{"version":3,"file":"share-data-errors.d.ts","sourceRoot":"","sources":["../../../src/errors/share-data/share-data-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;IACjD;;OAEG;gBACS,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc;CAGjE;AAED;;GAEG;AACH,qBAAa,2CAA4C,SAAQ,SAAS;IACtE;;OAEG;gBACS,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,SAAS;IAClD;;OAEG;gBACS,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,yDAA0D,SAAQ,SAAS;IACpF;;OAEG;gBACS,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAI5E;AAGD;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,SAAS;IACxD;;OAEG;gBACS,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM;CAIjG;AAKD;;GAEG;AACH,qBAAa,yCAA0C,SAAQ,SAAS;IACpE;;OAEG;gBACS,MAAM,EAAE,MAAM;CAG7B;AAED;;GAEG;AACH,qBAAa,0CAA2C,SAAQ,SAAS;IACrE;;OAEG;gBACS,MAAM,EAAE,MAAM;CAG7B;AAID;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,SAAS;gBAC1C,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;gBACrC,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,SAAS;gBACtC,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,iCAAkC,SAAQ,SAAS;gBAChD,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,6CAA8C,SAAQ,SAAS;gBAC5D,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,SAAS;gBAC9C,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,0CAA2C,SAAQ,SAAS;gBACzD,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,SAAS;gBAClD,WAAW,EAAE,MAAM;CAGlC;AAED;;;;;;;;;GASG;AACH,qBAAa,oCAAqC,SAAQ,SAAS;gBACnD,WAAW,EAAE,MAAM;CAGlC;AAED;;;;;;;;;GASG;AACH,qBAAa,sCAAuC,SAAQ,SAAS;gBACrD,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;CAM5D;AAED;;;;;;;;;GASG;AACH,qBAAa,qCAAsC,SAAQ,SAAS;gBACpD,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM;CAOhE;AAED;;;GAGG;AACH,qBAAa,sCAAuC,SAAQ,SAAS;gBACrD,WAAW,EAAE,MAAM;CAIlC;AAED;;;;;;GAMG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;gBACxC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAGlD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ShareDataPersistenceError = exports.ShareDataPreviousHashNotAvailableError = exports.ShareDataTransactionNotAuthorizedError = exports.ShareDataTransactionProofFailedError = exports.ShareDataStructuralProofFailedError = exports.ShareDataStructuralProofAlreadyExistsError = exports.ShareDataCryptoProofFailedError = exports.CryptoInitializationPublicKeyIsDifferentError = exports.ShareDataCryptoAlreadyExistsError = exports.ShareDataDuplicateError = exports.ShareDataNotFoundError = exports.ShareDataAlreadyExistsError = exports.ShareRuleProposedConditionsNotPresentError = exports.ShareRuleCurrentConditionsNotPresentError = exports.ShareDataFunctionHashNotValid = exports.ShareDataFunctionBeingAppliedDoesNotExistOnShareDataError = exports.ShareDataIntegrityError = exports.ShareDataCurrentAndProposalDataMatchesError = exports.ShareDataIsLockedError = void 0;
|
|
3
|
+
exports.ShareDataPersistenceError = exports.ShareDataPreviousHashNotAvailableError = exports.ShareDataDelegationNotAuthorizedError = exports.ShareDataTransactionNotAuthorizedError = exports.ShareDataTransactionProofFailedError = exports.ShareDataStructuralProofFailedError = exports.ShareDataStructuralProofAlreadyExistsError = exports.ShareDataCryptoProofFailedError = exports.CryptoInitializationPublicKeyIsDifferentError = exports.ShareDataCryptoAlreadyExistsError = exports.ShareDataDuplicateError = exports.ShareDataNotFoundError = exports.ShareDataAlreadyExistsError = exports.ShareRuleProposedConditionsNotPresentError = exports.ShareRuleCurrentConditionsNotPresentError = exports.ShareDataFunctionHashNotValid = exports.ShareDataFunctionBeingAppliedDoesNotExistOnShareDataError = exports.ShareDataIntegrityError = exports.ShareDataCurrentAndProposalDataMatchesError = exports.ShareDataIsLockedError = void 0;
|
|
4
4
|
const base_error_1 = require("../base-error");
|
|
5
5
|
/**
|
|
6
6
|
* This error is thrown when a function is tried to be applied to the share data thats state is locked.
|
|
@@ -195,6 +195,24 @@ class ShareDataTransactionNotAuthorizedError extends base_error_1.BaseError {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
exports.ShareDataTransactionNotAuthorizedError = ShareDataTransactionNotAuthorizedError;
|
|
198
|
+
/**
|
|
199
|
+
* This error is thrown when a delegated-signer registration is rejected.
|
|
200
|
+
* Distinct from {@link ShareDataTransactionNotAuthorizedError} (which rejects a
|
|
201
|
+
* runtime *transaction* whose signer is not authorized): this rejects the
|
|
202
|
+
* *registration* of a delegate — either because the registration proof was not
|
|
203
|
+
* signed by the block's `creationPublicKey` (only the owner may delegate; there
|
|
204
|
+
* is no transitive delegation), because the granted function-id set is empty,
|
|
205
|
+
* or because the proof's `purpose` does not bind the exact
|
|
206
|
+
* `(signerPublicKey, functionIds)` grant being registered.
|
|
207
|
+
*/
|
|
208
|
+
class ShareDataDelegationNotAuthorizedError extends base_error_1.BaseError {
|
|
209
|
+
constructor(shareDataId, registeringPublicKey) {
|
|
210
|
+
super(`Share data with id ${shareDataId} rejected a delegated-signer registration: ` +
|
|
211
|
+
`key ${registeringPublicKey} is not authorized to delegate, or the registration ` +
|
|
212
|
+
`proof does not bind the requested grant.`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
exports.ShareDataDelegationNotAuthorizedError = ShareDataDelegationNotAuthorizedError;
|
|
198
216
|
/**
|
|
199
217
|
* This error is thrown when the system attempts to get the previous share data hash
|
|
200
218
|
* but the share data has not been initialized for the proof yet.
|
package/dist/models/index.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ export * from './safe/safe-transaction-models';
|
|
|
17
17
|
export * from './share-data/share-data-crypto-models';
|
|
18
18
|
export * from './share-data/share-data-models';
|
|
19
19
|
export * from './share-data/share-data-persistence-models';
|
|
20
|
+
export * from './settlement/settlement-models';
|
|
20
21
|
export * from './shareblock/shareblock-models';
|
|
21
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAEA,cAAc,sDAAsD,CAAC;AACrE,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAElD,cAAc,2BAA2B,CAAC;AAE1C,cAAc,qDAAqD,CAAC;AACpE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mDAAmD,CAAC;AAClE,cAAc,gCAAgC,CAAC;AAG/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAEA,cAAc,sDAAsD,CAAC;AACrE,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAElD,cAAc,2BAA2B,CAAC;AAE1C,cAAc,qDAAqD,CAAC;AACpE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mDAAmD,CAAC;AAClE,cAAc,gCAAgC,CAAC;AAG/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC"}
|
package/dist/models/index.js
CHANGED
|
@@ -38,4 +38,5 @@ __exportStar(require("./safe/safe-transaction-models"), exports);
|
|
|
38
38
|
__exportStar(require("./share-data/share-data-crypto-models"), exports);
|
|
39
39
|
__exportStar(require("./share-data/share-data-models"), exports);
|
|
40
40
|
__exportStar(require("./share-data/share-data-persistence-models"), exports);
|
|
41
|
+
__exportStar(require("./settlement/settlement-models"), exports);
|
|
41
42
|
__exportStar(require("./shareblock/shareblock-models"), exports);
|
|
@@ -33,6 +33,8 @@ export declare const ISAFETransactionShareDataDataSchema: z.ZodObject<{
|
|
|
33
33
|
Clearing: "Clearing";
|
|
34
34
|
Funding: "Funding";
|
|
35
35
|
Distribution: "Distribution";
|
|
36
|
+
GraceRepayment: "GraceRepayment";
|
|
37
|
+
Settlement: "Settlement";
|
|
36
38
|
}>;
|
|
37
39
|
relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
|
|
38
40
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -91,6 +93,8 @@ export declare const ISAFETransactionShareDataSchema: z.ZodObject<{
|
|
|
91
93
|
Clearing: "Clearing";
|
|
92
94
|
Funding: "Funding";
|
|
93
95
|
Distribution: "Distribution";
|
|
96
|
+
GraceRepayment: "GraceRepayment";
|
|
97
|
+
Settlement: "Settlement";
|
|
94
98
|
}>;
|
|
95
99
|
relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
|
|
96
100
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -148,6 +152,8 @@ export declare const ISAFETransactionShareDataAddSchema: z.ZodObject<{
|
|
|
148
152
|
Clearing: "Clearing";
|
|
149
153
|
Funding: "Funding";
|
|
150
154
|
Distribution: "Distribution";
|
|
155
|
+
GraceRepayment: "GraceRepayment";
|
|
156
|
+
Settlement: "Settlement";
|
|
151
157
|
}>;
|
|
152
158
|
relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
|
|
153
159
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -204,6 +210,8 @@ export declare const ISAFETransactionShareDataUpdateSchema: z.ZodObject<{
|
|
|
204
210
|
Clearing: "Clearing";
|
|
205
211
|
Funding: "Funding";
|
|
206
212
|
Distribution: "Distribution";
|
|
213
|
+
GraceRepayment: "GraceRepayment";
|
|
214
|
+
Settlement: "Settlement";
|
|
207
215
|
}>;
|
|
208
216
|
relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
|
|
209
217
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -260,6 +268,8 @@ export declare const ISAFETransactionShareDataDeleteSchema: z.ZodObject<{
|
|
|
260
268
|
Clearing: "Clearing";
|
|
261
269
|
Funding: "Funding";
|
|
262
270
|
Distribution: "Distribution";
|
|
271
|
+
GraceRepayment: "GraceRepayment";
|
|
272
|
+
Settlement: "Settlement";
|
|
263
273
|
}>;
|
|
264
274
|
relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
|
|
265
275
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedata-transactions-models.d.ts","sourceRoot":"","sources":["../../../../src/models/safe/transactions/sharedata-transactions-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,mBAAmB,EACnB,yBAAyB,EAG5B,MAAM,4BAA4B,CAAC;AASpC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,mCAAmC
|
|
1
|
+
{"version":3,"file":"sharedata-transactions-models.d.ts","sourceRoot":"","sources":["../../../../src/models/safe/transactions/sharedata-transactions-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,mBAAmB,EACnB,yBAAyB,EAG5B,MAAM,4BAA4B,CAAC;AASpC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK9C,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAEhG;;GAEG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAO1C,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAIxF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK7C,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAE9F;;GAEG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKhD,CAAC;AAEH,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAEpG;;GAEG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKhD,CAAC;AAEH,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Two-phase-commit phase of a settlement, journaled on the coordinator's
|
|
4
|
+
* state. The legal transition graph (enforced by `buildSettlementPhaseRule`):
|
|
5
|
+
*
|
|
6
|
+
* PREPARING ──▶ COMMITTING ──▶ COMMITTED (terminal)
|
|
7
|
+
* │
|
|
8
|
+
* └────────▶ ABORTING ──▶ ABORTED (terminal)
|
|
9
|
+
*
|
|
10
|
+
* `COMMITTING` is the point of no return: once reached, every leg was already
|
|
11
|
+
* reserved, so the settlement can only roll forward. Failures before that
|
|
12
|
+
* point route to `ABORTING`. Terminals are sinks.
|
|
13
|
+
*/
|
|
14
|
+
export declare const SettlementPhaseSchema: z.ZodEnum<{
|
|
15
|
+
PREPARING: "PREPARING";
|
|
16
|
+
COMMITTING: "COMMITTING";
|
|
17
|
+
ABORTING: "ABORTING";
|
|
18
|
+
COMMITTED: "COMMITTED";
|
|
19
|
+
ABORTED: "ABORTED";
|
|
20
|
+
}>;
|
|
21
|
+
export type SettlementPhase = z.infer<typeof SettlementPhaseSchema>;
|
|
22
|
+
/**
|
|
23
|
+
* Per-leg status as tracked by the coordinator (a superset of the member
|
|
24
|
+
* block's `ReservationStatus`):
|
|
25
|
+
*
|
|
26
|
+
* - `planned` — in the plan, not yet reserved on its block.
|
|
27
|
+
* - `reserved` — successfully held on its block (PREPARE done for this leg).
|
|
28
|
+
* - `committed` — finalized on its block.
|
|
29
|
+
* - `released` — unwound on its block (abort path).
|
|
30
|
+
* - `failed` — its reserve threw (drift/overdraw); triggers settlement
|
|
31
|
+
* abort.
|
|
32
|
+
*/
|
|
33
|
+
export declare const SettlementLegStatusSchema: z.ZodEnum<{
|
|
34
|
+
reserved: "reserved";
|
|
35
|
+
committed: "committed";
|
|
36
|
+
released: "released";
|
|
37
|
+
planned: "planned";
|
|
38
|
+
failed: "failed";
|
|
39
|
+
}>;
|
|
40
|
+
export type SettlementLegStatus = z.infer<typeof SettlementLegStatusSchema>;
|
|
41
|
+
/**
|
|
42
|
+
* One leg of a settlement plan as recorded on the coordinator. A transfer is a
|
|
43
|
+
* `debit` leg (source) + a `credit` leg (destination) of equal `amountCents`.
|
|
44
|
+
* `againstHash` pins the leg to the target block's current-state hash at plan
|
|
45
|
+
* time (D5): if the block advanced, the reserve fails and the settlement
|
|
46
|
+
* aborts. `currency` is not carried per-leg — a settlement is single-currency
|
|
47
|
+
* (see the coordinator's `currency`).
|
|
48
|
+
*/
|
|
49
|
+
export declare const ISettlementLegSchema: z.ZodObject<{
|
|
50
|
+
blockId: z.ZodString;
|
|
51
|
+
direction: z.ZodEnum<{
|
|
52
|
+
debit: "debit";
|
|
53
|
+
credit: "credit";
|
|
54
|
+
}>;
|
|
55
|
+
amountCents: z.ZodNumber;
|
|
56
|
+
againstHash: z.ZodString;
|
|
57
|
+
status: z.ZodEnum<{
|
|
58
|
+
reserved: "reserved";
|
|
59
|
+
committed: "committed";
|
|
60
|
+
released: "released";
|
|
61
|
+
planned: "planned";
|
|
62
|
+
failed: "failed";
|
|
63
|
+
}>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export type ISettlementLeg = z.infer<typeof ISettlementLegSchema>;
|
|
66
|
+
/**
|
|
67
|
+
* The coordinator ShareBlock's state. A Settlement block is not a money-
|
|
68
|
+
* holding block — its inherited `balance` stays at zero and `participants` is
|
|
69
|
+
* empty; its real payload is the plan (`legs`), the 2PC `phase`, and the
|
|
70
|
+
* timestamps. The block's append-only transaction history is the durable
|
|
71
|
+
* journal that crash-recovery re-drives.
|
|
72
|
+
*/
|
|
73
|
+
export declare const ISettlementShareBlockStateSchema: z.ZodObject<{
|
|
74
|
+
balance: z.ZodNumber;
|
|
75
|
+
isOpen: z.ZodBoolean;
|
|
76
|
+
participants: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
77
|
+
userId: z.ZodString;
|
|
78
|
+
role: z.ZodEnum<{
|
|
79
|
+
Borrower: "Borrower";
|
|
80
|
+
Lender: "Lender";
|
|
81
|
+
Platform: "Platform";
|
|
82
|
+
Recipient: "Recipient";
|
|
83
|
+
}>;
|
|
84
|
+
committedAmount: z.ZodNumber;
|
|
85
|
+
settledAmount: z.ZodNumber;
|
|
86
|
+
}, z.core.$strip>>;
|
|
87
|
+
reservations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
88
|
+
settlementId: z.ZodString;
|
|
89
|
+
direction: z.ZodEnum<{
|
|
90
|
+
debit: "debit";
|
|
91
|
+
credit: "credit";
|
|
92
|
+
}>;
|
|
93
|
+
amountCents: z.ZodNumber;
|
|
94
|
+
currency: z.ZodString;
|
|
95
|
+
againstHash: z.ZodString;
|
|
96
|
+
status: z.ZodEnum<{
|
|
97
|
+
reserved: "reserved";
|
|
98
|
+
committed: "committed";
|
|
99
|
+
released: "released";
|
|
100
|
+
}>;
|
|
101
|
+
}, z.core.$strip>>>;
|
|
102
|
+
blockType: z.ZodLiteral<"Settlement">;
|
|
103
|
+
settlementId: z.ZodString;
|
|
104
|
+
currency: z.ZodString;
|
|
105
|
+
phase: z.ZodEnum<{
|
|
106
|
+
PREPARING: "PREPARING";
|
|
107
|
+
COMMITTING: "COMMITTING";
|
|
108
|
+
ABORTING: "ABORTING";
|
|
109
|
+
COMMITTED: "COMMITTED";
|
|
110
|
+
ABORTED: "ABORTED";
|
|
111
|
+
}>;
|
|
112
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
113
|
+
blockId: z.ZodString;
|
|
114
|
+
direction: z.ZodEnum<{
|
|
115
|
+
debit: "debit";
|
|
116
|
+
credit: "credit";
|
|
117
|
+
}>;
|
|
118
|
+
amountCents: z.ZodNumber;
|
|
119
|
+
againstHash: z.ZodString;
|
|
120
|
+
status: z.ZodEnum<{
|
|
121
|
+
reserved: "reserved";
|
|
122
|
+
committed: "committed";
|
|
123
|
+
released: "released";
|
|
124
|
+
planned: "planned";
|
|
125
|
+
failed: "failed";
|
|
126
|
+
}>;
|
|
127
|
+
}, z.core.$strip>>;
|
|
128
|
+
openedAtMs: z.ZodNumber;
|
|
129
|
+
terminalAtMs: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
}, z.core.$strip>;
|
|
131
|
+
export type ISettlementShareBlockState = z.infer<typeof ISettlementShareBlockStateSchema>;
|
|
132
|
+
/**
|
|
133
|
+
* Input for the coordinator `openSettlement` function — establishes the plan
|
|
134
|
+
* as the first journaled transaction (phase `PREPARING`, every leg `planned`).
|
|
135
|
+
*/
|
|
136
|
+
export declare const ISettlementOpenInputSchema: z.ZodObject<{
|
|
137
|
+
userId: z.ZodString;
|
|
138
|
+
settlementId: z.ZodString;
|
|
139
|
+
currency: z.ZodString;
|
|
140
|
+
legs: z.ZodArray<z.ZodObject<{
|
|
141
|
+
blockId: z.ZodString;
|
|
142
|
+
direction: z.ZodEnum<{
|
|
143
|
+
debit: "debit";
|
|
144
|
+
credit: "credit";
|
|
145
|
+
}>;
|
|
146
|
+
amountCents: z.ZodNumber;
|
|
147
|
+
againstHash: z.ZodString;
|
|
148
|
+
status: z.ZodEnum<{
|
|
149
|
+
reserved: "reserved";
|
|
150
|
+
committed: "committed";
|
|
151
|
+
released: "released";
|
|
152
|
+
planned: "planned";
|
|
153
|
+
failed: "failed";
|
|
154
|
+
}>;
|
|
155
|
+
}, z.core.$strip>>;
|
|
156
|
+
openedAtMs: z.ZodNumber;
|
|
157
|
+
}, z.core.$strip>;
|
|
158
|
+
export type ISettlementOpenInput = z.infer<typeof ISettlementOpenInputSchema>;
|
|
159
|
+
/**
|
|
160
|
+
* Input for `markLegReserved` — advances one leg `planned → reserved` once its
|
|
161
|
+
* block-side reserve succeeds. Legs are addressed by `blockId`.
|
|
162
|
+
*/
|
|
163
|
+
export declare const ISettlementMarkLegReservedInputSchema: z.ZodObject<{
|
|
164
|
+
userId: z.ZodString;
|
|
165
|
+
blockId: z.ZodString;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
export type ISettlementMarkLegReservedInput = z.infer<typeof ISettlementMarkLegReservedInputSchema>;
|
|
168
|
+
/**
|
|
169
|
+
* Input for `beginCommit` — the commit point: phase `PREPARING → COMMITTING`.
|
|
170
|
+
* Valid only when every leg is `reserved`.
|
|
171
|
+
*/
|
|
172
|
+
export declare const ISettlementBeginCommitInputSchema: z.ZodObject<{
|
|
173
|
+
userId: z.ZodString;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
export type ISettlementBeginCommitInput = z.infer<typeof ISettlementBeginCommitInputSchema>;
|
|
176
|
+
/**
|
|
177
|
+
* Input for `markLegCommitted` — advances one leg `reserved → committed` after
|
|
178
|
+
* its block-side commit lands.
|
|
179
|
+
*/
|
|
180
|
+
export declare const ISettlementMarkLegCommittedInputSchema: z.ZodObject<{
|
|
181
|
+
userId: z.ZodString;
|
|
182
|
+
blockId: z.ZodString;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
export type ISettlementMarkLegCommittedInput = z.infer<typeof ISettlementMarkLegCommittedInputSchema>;
|
|
185
|
+
/**
|
|
186
|
+
* Input for `finishCommit` — phase `COMMITTING → COMMITTED` (terminal) once
|
|
187
|
+
* every leg is committed. Stamps `terminalAtMs`.
|
|
188
|
+
*/
|
|
189
|
+
export declare const ISettlementFinishCommitInputSchema: z.ZodObject<{
|
|
190
|
+
userId: z.ZodString;
|
|
191
|
+
terminalAtMs: z.ZodNumber;
|
|
192
|
+
}, z.core.$strip>;
|
|
193
|
+
export type ISettlementFinishCommitInput = z.infer<typeof ISettlementFinishCommitInputSchema>;
|
|
194
|
+
/**
|
|
195
|
+
* Input for `beginAbort` — phase `PREPARING → ABORTING` when a leg fails to
|
|
196
|
+
* reserve before the commit point. `reason` is optional audit context.
|
|
197
|
+
*/
|
|
198
|
+
export declare const ISettlementBeginAbortInputSchema: z.ZodObject<{
|
|
199
|
+
userId: z.ZodString;
|
|
200
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
201
|
+
}, z.core.$strip>;
|
|
202
|
+
export type ISettlementBeginAbortInput = z.infer<typeof ISettlementBeginAbortInputSchema>;
|
|
203
|
+
/**
|
|
204
|
+
* Input for `markLegReleased` — advances a `reserved` leg to `released` after
|
|
205
|
+
* its block-side release unwinds the hold (abort path).
|
|
206
|
+
*/
|
|
207
|
+
export declare const ISettlementMarkLegReleasedInputSchema: z.ZodObject<{
|
|
208
|
+
userId: z.ZodString;
|
|
209
|
+
blockId: z.ZodString;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
export type ISettlementMarkLegReleasedInput = z.infer<typeof ISettlementMarkLegReleasedInputSchema>;
|
|
212
|
+
/**
|
|
213
|
+
* Input for `finishAbort` — phase `ABORTING → ABORTED` (terminal) once every
|
|
214
|
+
* reserved leg is released. Stamps `terminalAtMs`.
|
|
215
|
+
*/
|
|
216
|
+
export declare const ISettlementFinishAbortInputSchema: z.ZodObject<{
|
|
217
|
+
userId: z.ZodString;
|
|
218
|
+
terminalAtMs: z.ZodNumber;
|
|
219
|
+
}, z.core.$strip>;
|
|
220
|
+
export type ISettlementFinishAbortInput = z.infer<typeof ISettlementFinishAbortInputSchema>;
|
|
221
|
+
//# sourceMappingURL=settlement-models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlement-models.d.ts","sourceRoot":"","sources":["../../../src/models/settlement/settlement-models.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AASpB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB;;;;;;EAMhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB;;;;;;EAMpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAM5E;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;iBAM/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAY3C,CAAC;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAM1F;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;iBAMrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,qCAAqC;;;iBAGhD,CAAC;AACH,MAAM,MAAM,+BAA+B,GACvC,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,iCAAiC;;iBAE5C,CAAC;AACH,MAAM,MAAM,2BAA2B,GACnC,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,sCAAsC;;;iBAGjD,CAAC;AACH,MAAM,MAAM,gCAAgC,GACxC,CAAC,CAAC,KAAK,CAAC,OAAO,sCAAsC,CAAC,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,kCAAkC;;;iBAG7C,CAAC;AACH,MAAM,MAAM,4BAA4B,GACpC,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,gCAAgC;;;iBAG3C,CAAC;AACH,MAAM,MAAM,0BAA0B,GAClC,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,qCAAqC;;;iBAGhD,CAAC;AACH,MAAM,MAAM,+BAA+B,GACvC,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,iCAAiC;;;iBAG5C,CAAC;AACH,MAAM,MAAM,2BAA2B,GACnC,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ISettlementFinishAbortInputSchema = exports.ISettlementMarkLegReleasedInputSchema = exports.ISettlementBeginAbortInputSchema = exports.ISettlementFinishCommitInputSchema = exports.ISettlementMarkLegCommittedInputSchema = exports.ISettlementBeginCommitInputSchema = exports.ISettlementMarkLegReservedInputSchema = exports.ISettlementOpenInputSchema = exports.ISettlementShareBlockStateSchema = exports.ISettlementLegSchema = exports.SettlementLegStatusSchema = exports.SettlementPhaseSchema = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const shareblock_models_1 = require("../shareblock/shareblock-models");
|
|
9
|
+
//#region Phase + leg status
|
|
10
|
+
/**
|
|
11
|
+
* Two-phase-commit phase of a settlement, journaled on the coordinator's
|
|
12
|
+
* state. The legal transition graph (enforced by `buildSettlementPhaseRule`):
|
|
13
|
+
*
|
|
14
|
+
* PREPARING ──▶ COMMITTING ──▶ COMMITTED (terminal)
|
|
15
|
+
* │
|
|
16
|
+
* └────────▶ ABORTING ──▶ ABORTED (terminal)
|
|
17
|
+
*
|
|
18
|
+
* `COMMITTING` is the point of no return: once reached, every leg was already
|
|
19
|
+
* reserved, so the settlement can only roll forward. Failures before that
|
|
20
|
+
* point route to `ABORTING`. Terminals are sinks.
|
|
21
|
+
*/
|
|
22
|
+
exports.SettlementPhaseSchema = zod_1.default.enum([
|
|
23
|
+
'PREPARING',
|
|
24
|
+
'COMMITTING',
|
|
25
|
+
'ABORTING',
|
|
26
|
+
'COMMITTED',
|
|
27
|
+
'ABORTED',
|
|
28
|
+
]);
|
|
29
|
+
/**
|
|
30
|
+
* Per-leg status as tracked by the coordinator (a superset of the member
|
|
31
|
+
* block's `ReservationStatus`):
|
|
32
|
+
*
|
|
33
|
+
* - `planned` — in the plan, not yet reserved on its block.
|
|
34
|
+
* - `reserved` — successfully held on its block (PREPARE done for this leg).
|
|
35
|
+
* - `committed` — finalized on its block.
|
|
36
|
+
* - `released` — unwound on its block (abort path).
|
|
37
|
+
* - `failed` — its reserve threw (drift/overdraw); triggers settlement
|
|
38
|
+
* abort.
|
|
39
|
+
*/
|
|
40
|
+
exports.SettlementLegStatusSchema = zod_1.default.enum([
|
|
41
|
+
'planned',
|
|
42
|
+
'reserved',
|
|
43
|
+
'committed',
|
|
44
|
+
'released',
|
|
45
|
+
'failed',
|
|
46
|
+
]);
|
|
47
|
+
//#endregion Phase + leg status
|
|
48
|
+
//#region Leg + coordinator state
|
|
49
|
+
/**
|
|
50
|
+
* One leg of a settlement plan as recorded on the coordinator. A transfer is a
|
|
51
|
+
* `debit` leg (source) + a `credit` leg (destination) of equal `amountCents`.
|
|
52
|
+
* `againstHash` pins the leg to the target block's current-state hash at plan
|
|
53
|
+
* time (D5): if the block advanced, the reserve fails and the settlement
|
|
54
|
+
* aborts. `currency` is not carried per-leg — a settlement is single-currency
|
|
55
|
+
* (see the coordinator's `currency`).
|
|
56
|
+
*/
|
|
57
|
+
exports.ISettlementLegSchema = zod_1.default.object({
|
|
58
|
+
blockId: zod_1.default.string(),
|
|
59
|
+
direction: shareblock_models_1.SettlementLegDirectionSchema,
|
|
60
|
+
amountCents: zod_1.default.number().int().positive(),
|
|
61
|
+
againstHash: zod_1.default.string(),
|
|
62
|
+
status: exports.SettlementLegStatusSchema,
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* The coordinator ShareBlock's state. A Settlement block is not a money-
|
|
66
|
+
* holding block — its inherited `balance` stays at zero and `participants` is
|
|
67
|
+
* empty; its real payload is the plan (`legs`), the 2PC `phase`, and the
|
|
68
|
+
* timestamps. The block's append-only transaction history is the durable
|
|
69
|
+
* journal that crash-recovery re-drives.
|
|
70
|
+
*/
|
|
71
|
+
exports.ISettlementShareBlockStateSchema = shareblock_models_1.IShareBlockStateSchema.extend({
|
|
72
|
+
blockType: zod_1.default.literal(shareblock_models_1.ShareBlockTypeSchema.enum.Settlement),
|
|
73
|
+
settlementId: zod_1.default.string(),
|
|
74
|
+
// Opaque currency code; equality-checked against member legs, never
|
|
75
|
+
// converted. Loosened from the base `min(3).max(3)` per the settlement
|
|
76
|
+
// design (one settlement = one currency).
|
|
77
|
+
currency: zod_1.default.string(),
|
|
78
|
+
phase: exports.SettlementPhaseSchema,
|
|
79
|
+
legs: zod_1.default.array(exports.ISettlementLegSchema),
|
|
80
|
+
openedAtMs: zod_1.default.number().int().nonnegative(),
|
|
81
|
+
/** Stamped when the block reaches a terminal phase (COMMITTED/ABORTED). */
|
|
82
|
+
terminalAtMs: zod_1.default.number().int().nonnegative().optional(),
|
|
83
|
+
});
|
|
84
|
+
//#endregion Leg + coordinator state
|
|
85
|
+
//#region Coordinator function inputs
|
|
86
|
+
/**
|
|
87
|
+
* Input for the coordinator `openSettlement` function — establishes the plan
|
|
88
|
+
* as the first journaled transaction (phase `PREPARING`, every leg `planned`).
|
|
89
|
+
*/
|
|
90
|
+
exports.ISettlementOpenInputSchema = zod_1.default.object({
|
|
91
|
+
userId: zod_1.default.string(),
|
|
92
|
+
settlementId: zod_1.default.string(),
|
|
93
|
+
currency: zod_1.default.string(),
|
|
94
|
+
legs: zod_1.default.array(exports.ISettlementLegSchema),
|
|
95
|
+
openedAtMs: zod_1.default.number().int().nonnegative(),
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* Input for `markLegReserved` — advances one leg `planned → reserved` once its
|
|
99
|
+
* block-side reserve succeeds. Legs are addressed by `blockId`.
|
|
100
|
+
*/
|
|
101
|
+
exports.ISettlementMarkLegReservedInputSchema = zod_1.default.object({
|
|
102
|
+
userId: zod_1.default.string(),
|
|
103
|
+
blockId: zod_1.default.string(),
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* Input for `beginCommit` — the commit point: phase `PREPARING → COMMITTING`.
|
|
107
|
+
* Valid only when every leg is `reserved`.
|
|
108
|
+
*/
|
|
109
|
+
exports.ISettlementBeginCommitInputSchema = zod_1.default.object({
|
|
110
|
+
userId: zod_1.default.string(),
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* Input for `markLegCommitted` — advances one leg `reserved → committed` after
|
|
114
|
+
* its block-side commit lands.
|
|
115
|
+
*/
|
|
116
|
+
exports.ISettlementMarkLegCommittedInputSchema = zod_1.default.object({
|
|
117
|
+
userId: zod_1.default.string(),
|
|
118
|
+
blockId: zod_1.default.string(),
|
|
119
|
+
});
|
|
120
|
+
/**
|
|
121
|
+
* Input for `finishCommit` — phase `COMMITTING → COMMITTED` (terminal) once
|
|
122
|
+
* every leg is committed. Stamps `terminalAtMs`.
|
|
123
|
+
*/
|
|
124
|
+
exports.ISettlementFinishCommitInputSchema = zod_1.default.object({
|
|
125
|
+
userId: zod_1.default.string(),
|
|
126
|
+
terminalAtMs: zod_1.default.number().int().nonnegative(),
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* Input for `beginAbort` — phase `PREPARING → ABORTING` when a leg fails to
|
|
130
|
+
* reserve before the commit point. `reason` is optional audit context.
|
|
131
|
+
*/
|
|
132
|
+
exports.ISettlementBeginAbortInputSchema = zod_1.default.object({
|
|
133
|
+
userId: zod_1.default.string(),
|
|
134
|
+
reason: zod_1.default.string().optional(),
|
|
135
|
+
});
|
|
136
|
+
/**
|
|
137
|
+
* Input for `markLegReleased` — advances a `reserved` leg to `released` after
|
|
138
|
+
* its block-side release unwinds the hold (abort path).
|
|
139
|
+
*/
|
|
140
|
+
exports.ISettlementMarkLegReleasedInputSchema = zod_1.default.object({
|
|
141
|
+
userId: zod_1.default.string(),
|
|
142
|
+
blockId: zod_1.default.string(),
|
|
143
|
+
});
|
|
144
|
+
/**
|
|
145
|
+
* Input for `finishAbort` — phase `ABORTING → ABORTED` (terminal) once every
|
|
146
|
+
* reserved leg is released. Stamps `terminalAtMs`.
|
|
147
|
+
*/
|
|
148
|
+
exports.ISettlementFinishAbortInputSchema = zod_1.default.object({
|
|
149
|
+
userId: zod_1.default.string(),
|
|
150
|
+
terminalAtMs: zod_1.default.number().int().nonnegative(),
|
|
151
|
+
});
|
|
152
|
+
//#endregion Coordinator function inputs
|
|
@@ -45,6 +45,43 @@ export declare const ShareDataProofsSchema: z.ZodRecord<z.ZodString, z.ZodObject
|
|
|
45
45
|
purpose: z.ZodString;
|
|
46
46
|
}, z.core.$strip>>;
|
|
47
47
|
export type ShareDataProofs = z.infer<typeof ShareDataProofsSchema>;
|
|
48
|
+
/**
|
|
49
|
+
* A single delegated-signer grant on a block: a public key the block owner has
|
|
50
|
+
* authorized to propose runtime transactions, scoped to a specific set of
|
|
51
|
+
* function ids (least privilege — a granted key can only drive the function(s)
|
|
52
|
+
* it was delegated, not arbitrary mutations).
|
|
53
|
+
*
|
|
54
|
+
* Field-declaration order is load-bearing, NOT cosmetic — same constraint as
|
|
55
|
+
* {@link IShareDataCryptoProofSchema}. The grant is folded into the canonical
|
|
56
|
+
* share-data string via order-sensitive `JSON.stringify` (see `getArrayString`
|
|
57
|
+
* / `calculateShareDataString`), so a grant that round-trips through `.parse()`
|
|
58
|
+
* (persistence reload) must come back with the SAME key order a freshly-built
|
|
59
|
+
* grant has, or the block's hash diverges and later proofs fail to verify.
|
|
60
|
+
* Keep `publicKey` before `functionIds`, matching the object literal pushed in
|
|
61
|
+
* `ShareData.addAuthorizedSigner`.
|
|
62
|
+
*/
|
|
63
|
+
export declare const IAuthorizedSignerSchema: z.ZodObject<{
|
|
64
|
+
publicKey: z.ZodString;
|
|
65
|
+
functionIds: z.ZodArray<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type IAuthorizedSigner = z.infer<typeof IAuthorizedSignerSchema>;
|
|
68
|
+
/** Prefix marking a structural proof's `purpose` as a delegate registration. */
|
|
69
|
+
export declare const DELEGATE_PURPOSE_PREFIX = "delegate:";
|
|
70
|
+
/**
|
|
71
|
+
* Builds the canonical `purpose` for a delegated-signer registration proof.
|
|
72
|
+
*
|
|
73
|
+
* The registration proof is signed over the block's PRE-append state (the grant
|
|
74
|
+
* is not yet folded into `_authorizedSigners` at signing time), so the proof's
|
|
75
|
+
* `purpose` is the only thing that cryptographically attests to the exact
|
|
76
|
+
* `(signerPublicKey, functionIds)` grant. Binding both into the purpose means a
|
|
77
|
+
* tampered snapshot cannot widen a delegate's scope (add function ids) or lift
|
|
78
|
+
* the signature to authorize a different key without invalidating the proof.
|
|
79
|
+
*
|
|
80
|
+
* `functionIds` are normalized (trimmed, de-duped, sorted) and JSON-encoded so
|
|
81
|
+
* the encoding is collision-free regardless of characters in the ids and
|
|
82
|
+
* order-independent across live-create and replay.
|
|
83
|
+
*/
|
|
84
|
+
export declare const buildDelegatePurpose: (signerPublicKey: string, functionIds: string[]) => string;
|
|
48
85
|
/**
|
|
49
86
|
* This contains the interface for the share data property config
|
|
50
87
|
* for creating strings from the object to ensure that signatures and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-data-crypto-models.d.ts","sourceRoot":"","sources":["../../../src/models/share-data/share-data-crypto-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB;;GAEG;AACH,eAAO,MAAM,iCAAiC;;;;;iBAK5C,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAE5F;;;;;;;;;;GAUG;AASH,eAAO,MAAM,2BAA2B;;;;;;;iBAOtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB;;;;;;;kBAAoD,CAAC;AAEvF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"share-data-crypto-models.d.ts","sourceRoot":"","sources":["../../../src/models/share-data/share-data-crypto-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB;;GAEG;AACH,eAAO,MAAM,iCAAiC;;;;;iBAK5C,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAE5F;;;;;;;;;;GAUG;AASH,eAAO,MAAM,2BAA2B;;;;;;;iBAOtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB;;;;;;;kBAAoD,CAAC;AAEvF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uBAAuB;;;iBAGlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,gFAAgF;AAChF,eAAO,MAAM,uBAAuB,cAAc,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAC7B,iBAAiB,MAAM,EACvB,aAAa,MAAM,EAAE,KACtB,MAKF,CAAC;AAMF;;;;GAIG;AACH,eAAO,MAAM,8BAA8B;;;iBAGzC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;kBAA0C,CAAC;AAE9E,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAMtE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMpD,CAAC;AACH,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yCAAyC,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IShareDataAdditionalValuesToIncludeSchema = exports.IShareDataConfigSchema = exports.IShareDataPropertyConfigSchema = exports.ShareDataProofsSchema = exports.IShareDataCryptoProofSchema = exports.IShareDataInitialCryptoDataSchema = void 0;
|
|
3
|
+
exports.IShareDataAdditionalValuesToIncludeSchema = exports.IShareDataConfigSchema = exports.IShareDataPropertyConfigSchema = exports.buildDelegatePurpose = exports.DELEGATE_PURPOSE_PREFIX = exports.IAuthorizedSignerSchema = exports.ShareDataProofsSchema = exports.IShareDataCryptoProofSchema = exports.IShareDataInitialCryptoDataSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const share_rule_models_1 = require("../rules/share-rule-models");
|
|
6
6
|
const share_data_models_1 = require("./share-data-models");
|
|
@@ -51,6 +51,46 @@ exports.IShareDataCryptoProofSchema = zod_1.z.object({
|
|
|
51
51
|
* `addFunction` / `addRule` call.
|
|
52
52
|
*/
|
|
53
53
|
exports.ShareDataProofsSchema = zod_1.z.record(zod_1.z.string(), exports.IShareDataCryptoProofSchema);
|
|
54
|
+
/**
|
|
55
|
+
* A single delegated-signer grant on a block: a public key the block owner has
|
|
56
|
+
* authorized to propose runtime transactions, scoped to a specific set of
|
|
57
|
+
* function ids (least privilege — a granted key can only drive the function(s)
|
|
58
|
+
* it was delegated, not arbitrary mutations).
|
|
59
|
+
*
|
|
60
|
+
* Field-declaration order is load-bearing, NOT cosmetic — same constraint as
|
|
61
|
+
* {@link IShareDataCryptoProofSchema}. The grant is folded into the canonical
|
|
62
|
+
* share-data string via order-sensitive `JSON.stringify` (see `getArrayString`
|
|
63
|
+
* / `calculateShareDataString`), so a grant that round-trips through `.parse()`
|
|
64
|
+
* (persistence reload) must come back with the SAME key order a freshly-built
|
|
65
|
+
* grant has, or the block's hash diverges and later proofs fail to verify.
|
|
66
|
+
* Keep `publicKey` before `functionIds`, matching the object literal pushed in
|
|
67
|
+
* `ShareData.addAuthorizedSigner`.
|
|
68
|
+
*/
|
|
69
|
+
exports.IAuthorizedSignerSchema = zod_1.z.object({
|
|
70
|
+
publicKey: zod_1.z.string(), // the delegate's public key (hex)
|
|
71
|
+
functionIds: zod_1.z.array(zod_1.z.string()), // the function ids this key may drive (sorted)
|
|
72
|
+
});
|
|
73
|
+
/** Prefix marking a structural proof's `purpose` as a delegate registration. */
|
|
74
|
+
exports.DELEGATE_PURPOSE_PREFIX = 'delegate:';
|
|
75
|
+
/**
|
|
76
|
+
* Builds the canonical `purpose` for a delegated-signer registration proof.
|
|
77
|
+
*
|
|
78
|
+
* The registration proof is signed over the block's PRE-append state (the grant
|
|
79
|
+
* is not yet folded into `_authorizedSigners` at signing time), so the proof's
|
|
80
|
+
* `purpose` is the only thing that cryptographically attests to the exact
|
|
81
|
+
* `(signerPublicKey, functionIds)` grant. Binding both into the purpose means a
|
|
82
|
+
* tampered snapshot cannot widen a delegate's scope (add function ids) or lift
|
|
83
|
+
* the signature to authorize a different key without invalidating the proof.
|
|
84
|
+
*
|
|
85
|
+
* `functionIds` are normalized (trimmed, de-duped, sorted) and JSON-encoded so
|
|
86
|
+
* the encoding is collision-free regardless of characters in the ids and
|
|
87
|
+
* order-independent across live-create and replay.
|
|
88
|
+
*/
|
|
89
|
+
const buildDelegatePurpose = (signerPublicKey, functionIds) => {
|
|
90
|
+
const normalized = Array.from(new Set(functionIds.map((id) => id.trim()).filter((id) => id.length > 0))).sort();
|
|
91
|
+
return `${exports.DELEGATE_PURPOSE_PREFIX}${signerPublicKey}:${JSON.stringify(normalized)}`;
|
|
92
|
+
};
|
|
93
|
+
exports.buildDelegatePurpose = buildDelegatePurpose;
|
|
54
94
|
//#endregion Share Data Crypto Schemas
|
|
55
95
|
//#region Stringify Configurations
|
|
56
96
|
/**
|