@midnight-ntwrk/midnight-js-types 0.2.5 → 2.0.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/README.md +8 -5
- package/dist/contract.d.ts +81 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.cjs +48 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +46 -1
- package/dist/index.mjs.map +1 -1
- package/dist/logger-provider.d.ts +30 -0
- package/dist/logger-provider.d.ts.map +1 -0
- package/dist/midnight-types.d.ts.map +1 -1
- package/dist/private-state-provider.d.ts +22 -28
- package/dist/private-state-provider.d.ts.map +1 -1
- package/dist/providers.d.ts +12 -4
- package/dist/providers.d.ts.map +1 -1
- package/dist/wallet-provider.d.ts +5 -1
- package/dist/wallet-provider.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
# What is this?
|
|
2
|
-
Provides shared data types and interfaces for all MidnightJS modules.
|
|
3
|
-
This package was created for the [Midnight network](https://midnight.network).
|
|
2
|
+
Provides shared data types and interfaces for all MidnightJS modules.
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
This package was created for the [Midnight network](https://midnight.network).
|
|
5
|
+
|
|
6
|
+
Please visit the [Midnight Developer Hub](https://midnight.network/developer-hub) to learn more.
|
|
7
|
+
|
|
8
|
+
# Use only in Midnight test environments
|
|
9
|
+
Image exclusively for Midnight test environments use.
|
|
7
10
|
|
|
8
11
|
# Agree to Terms
|
|
9
|
-
By downloading and using this image, you agree to [Midnight’s Terms and Conditions](https://midnight.network/static/terms.pdf), which includes the [
|
|
12
|
+
By downloading and using this image, you agree to [Midnight’s Terms and Conditions](https://midnight.network/static/terms.pdf), which includes the [Privacy Policy](https://midnight.network/static/privacy-policy.pdf).
|
|
10
13
|
|
|
11
14
|
# License
|
|
12
15
|
The software provided herein is licensed under the [Apache License V2.0](http://www.apache.org/licenses/LICENSE-2.0).
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { CircuitResults, CircuitContext, WitnessContext, ConstructorContext, ConstructorResult } from '@midnight-ntwrk/compact-runtime';
|
|
2
|
+
/**
|
|
3
|
+
* A circuit which affects the public state.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam PS - The private state modified by the contract witnesses.
|
|
6
|
+
*/
|
|
7
|
+
export type ImpureCircuit<PS> = (context: CircuitContext<PS>, ...args: any[]) => CircuitResults<PS, any>;
|
|
8
|
+
/**
|
|
9
|
+
* A collection of impure circuits defined in a contract.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam PS - The private state modified by the contract witnesses.
|
|
12
|
+
*/
|
|
13
|
+
export type ImpureCircuits<PS> = Record<string, ImpureCircuit<PS>>;
|
|
14
|
+
/**
|
|
15
|
+
* A type representing a witness in a contract.
|
|
16
|
+
*
|
|
17
|
+
* @typeParam PS - The private state modified by the witness.
|
|
18
|
+
*/
|
|
19
|
+
export type Witness<PS> = (context: WitnessContext<any, PS>, ...rest: any[]) => [PS, any];
|
|
20
|
+
/**
|
|
21
|
+
* A type representing all of a contract's witnesses.
|
|
22
|
+
*
|
|
23
|
+
* @typeParam PS - The private state modified by the contract witnesses.
|
|
24
|
+
*/
|
|
25
|
+
export type Witnesses<PS = any> = Record<string, Witness<PS>>;
|
|
26
|
+
/**
|
|
27
|
+
* Interface for a contract. The data types defined in this file are generic shapes for the artifacts
|
|
28
|
+
* produced by the `compactc` compiler. In other words, this `Contract` interface should match the shape
|
|
29
|
+
* of any `Contract` class produced by `compactc`. Midnight.js uses it for generic constraints.
|
|
30
|
+
*
|
|
31
|
+
* @typeParam PS - The private state modified by the contract witnesses.
|
|
32
|
+
* @typeParam W - The contract witnesses type.
|
|
33
|
+
*/
|
|
34
|
+
export interface Contract<PS = any, W extends Witnesses<PS> = Witnesses<PS>> {
|
|
35
|
+
/**
|
|
36
|
+
* The private oracle of the contract.
|
|
37
|
+
*/
|
|
38
|
+
readonly witnesses: W;
|
|
39
|
+
/**
|
|
40
|
+
* The impure circuits defined in a contract. These circuits can be used to create call transactions.
|
|
41
|
+
*/
|
|
42
|
+
readonly impureCircuits: ImpureCircuits<PS>;
|
|
43
|
+
/**
|
|
44
|
+
* Constructs the initial public state of the public oracle of a contract. This is used during
|
|
45
|
+
* deployment transaction construction.
|
|
46
|
+
*/
|
|
47
|
+
initialState(context: ConstructorContext<PS>, ...args: any[]): ConstructorResult<PS>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A union over the impure circuit identifiers of a contract.
|
|
51
|
+
*
|
|
52
|
+
* @typeParam C The contract type for which we would like impure circuit IDs.
|
|
53
|
+
*/
|
|
54
|
+
export type ImpureCircuitId<C extends Contract = Contract> = keyof C['impureCircuits'] & string;
|
|
55
|
+
/**
|
|
56
|
+
* Extracts the private state of a contract.
|
|
57
|
+
*
|
|
58
|
+
* @typeParam C The contract for which we would like the private state.
|
|
59
|
+
*/
|
|
60
|
+
export type PrivateState<C extends Contract> = C extends Contract<infer PS> ? PS : never;
|
|
61
|
+
/**
|
|
62
|
+
* Typesafe version of `Object.keys(contract.impureCircuits)`.
|
|
63
|
+
*
|
|
64
|
+
* @param contract The contract having impure circuits for which we want ids.
|
|
65
|
+
*
|
|
66
|
+
* @typeParam C The contract type for which we would like impure circuit IDs.
|
|
67
|
+
*/
|
|
68
|
+
export declare const getImpureCircuitIds: <C extends Contract>(contract: C) => ImpureCircuitId<C>[];
|
|
69
|
+
/**
|
|
70
|
+
* The parameter types of the circuits in a contract.
|
|
71
|
+
*/
|
|
72
|
+
export type CircuitParameters<C extends Contract, K extends ImpureCircuitId<C>> = Parameters<C['impureCircuits'][K]> extends [CircuitContext<any>, ...infer A] ? A : never;
|
|
73
|
+
/**
|
|
74
|
+
* The return types of the circuits in a contract.
|
|
75
|
+
*/
|
|
76
|
+
export type CircuitReturnType<C extends Contract, K extends ImpureCircuitId<C>> = ReturnType<C['impureCircuits'][K]> extends CircuitResults<any, infer U> ? U : never;
|
|
77
|
+
/**
|
|
78
|
+
* The parameter type of the public state constructor.
|
|
79
|
+
*/
|
|
80
|
+
export type InitialStateParameters<C extends Contract> = Parameters<C['initialState']> extends [ConstructorContext<any>, ...infer A] ? A : never;
|
|
81
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,iCAAiC,CAAC;AAIzC;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,EAAE,IAAI,CAC9B,OAAO,EAAE,cAAc,CAAC,EAAE,CAAC,EAC3B,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,cAAc,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAE7B;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,EAAE,IAAI,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC;AAEnE;;;;GAIG;AACH,MAAM,MAAM,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAE1F;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,EAAE,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9D;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,SAAS,SAAS,CAAC,EAAE,CAAC,GAAG,SAAS,C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;AAEtF;;GAEG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,QAAQ,IACnD,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error describing an invalid protocol scheme.
|
|
3
|
+
*/
|
|
4
|
+
export declare class InvalidProtocolSchemeError extends Error {
|
|
5
|
+
readonly invalidScheme: string;
|
|
6
|
+
readonly allowableSchemes: string[];
|
|
7
|
+
/**
|
|
8
|
+
* @param invalidScheme The invalid scheme.
|
|
9
|
+
* @param allowableSchemes The valid schemes that are allowed.
|
|
10
|
+
*/
|
|
11
|
+
constructor(invalidScheme: string, allowableSchemes: string[]);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;aAMjC,aAAa,EAAE,MAAM;aACrB,gBAAgB,EAAE,MAAM,EAAE;IAN5C;;;OAGG;gBAEe,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,EAAE;CAM7C"}
|
package/dist/index.cjs
CHANGED
|
@@ -90,12 +90,58 @@ class ZKConfigProvider {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
/**
|
|
94
|
+
* An error describing an invalid protocol scheme.
|
|
95
|
+
*/
|
|
96
|
+
class InvalidProtocolSchemeError extends Error {
|
|
97
|
+
invalidScheme;
|
|
98
|
+
allowableSchemes;
|
|
99
|
+
/**
|
|
100
|
+
* @param invalidScheme The invalid scheme.
|
|
101
|
+
* @param allowableSchemes The valid schemes that are allowed.
|
|
102
|
+
*/
|
|
103
|
+
constructor(invalidScheme, allowableSchemes) {
|
|
104
|
+
super(`Invalid protocol scheme: '${invalidScheme}'. Allowable schemes are one of: ${allowableSchemes.join(',')}`);
|
|
105
|
+
this.invalidScheme = invalidScheme;
|
|
106
|
+
this.allowableSchemes = allowableSchemes;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* A valid named log level.
|
|
112
|
+
*/
|
|
113
|
+
exports.LogLevel = void 0;
|
|
114
|
+
(function (LogLevel) {
|
|
115
|
+
/**
|
|
116
|
+
* Log levels typically used by DAapp developers.
|
|
117
|
+
*/
|
|
118
|
+
LogLevel["INFO"] = "info";
|
|
119
|
+
LogLevel["WARN"] = "warn";
|
|
120
|
+
LogLevel["ERROR"] = "error";
|
|
121
|
+
LogLevel["FATAL"] = "fatal";
|
|
122
|
+
/**
|
|
123
|
+
* Log levels used by Midnight.JS to report internal state.
|
|
124
|
+
*/
|
|
125
|
+
LogLevel["DEBUG"] = "debug";
|
|
126
|
+
LogLevel["TRACE"] = "trace";
|
|
127
|
+
})(exports.LogLevel || (exports.LogLevel = {}));
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Typesafe version of `Object.keys(contract.impureCircuits)`.
|
|
131
|
+
*
|
|
132
|
+
* @param contract The contract having impure circuits for which we want ids.
|
|
133
|
+
*
|
|
134
|
+
* @typeParam C The contract type for which we would like impure circuit IDs.
|
|
135
|
+
*/
|
|
136
|
+
const getImpureCircuitIds = (contract) => Object.keys(contract.impureCircuits);
|
|
137
|
+
|
|
138
|
+
Object.defineProperty(exports, "UnprovenTransaction", {
|
|
94
139
|
enumerable: true,
|
|
95
140
|
get: function () { return ledger.UnprovenTransaction; }
|
|
96
141
|
});
|
|
97
142
|
exports.FailEntirely = FailEntirely;
|
|
98
143
|
exports.FailFallible = FailFallible;
|
|
144
|
+
exports.InvalidProtocolSchemeError = InvalidProtocolSchemeError;
|
|
99
145
|
exports.SucceedEntirely = SucceedEntirely;
|
|
100
146
|
exports.ZKConfigProvider = ZKConfigProvider;
|
|
101
147
|
exports.createBalancedTx = createBalancedTx;
|
|
@@ -103,4 +149,5 @@ exports.createProverKey = createProverKey;
|
|
|
103
149
|
exports.createUnbalancedTx = createUnbalancedTx;
|
|
104
150
|
exports.createVerifierKey = createVerifierKey;
|
|
105
151
|
exports.createZKIR = createZKIR;
|
|
152
|
+
exports.getImpureCircuitIds = getImpureCircuitIds;
|
|
106
153
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/midnight-types.ts","../src/zk-config-provider.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;;AAYA;;;;AAIG;AACU,MAAA,eAAe,GAAG,CAAC,UAAsB,KAAe;AACnE,IAAA,OAAO,UAAuB
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/midnight-types.ts","../src/zk-config-provider.ts","../src/errors.ts","../src/logger-provider.ts","../src/contract.ts"],"sourcesContent":[null,null,null,null,null],"names":["LogLevel"],"mappings":";;;;AAYA;;;;AAIG;AACU,MAAA,eAAe,GAAG,CAAC,UAAsB,KAAe;AACnE,IAAA,OAAO,UAAuB;AAChC;AAYA;;;;AAIG;AACU,MAAA,iBAAiB,GAAG,CAAC,UAAsB,KAAiB;AACvE,IAAA,OAAO,UAAyB;AAClC;AAYA;;;;AAIG;AACU,MAAA,UAAU,GAAG,CAAC,UAAsB,KAAU;AACzD,IAAA,OAAO,UAAkB;AAC3B;AAmCA;;;;AAIG;AACU,MAAA,kBAAkB,GAAG,CAAC,EAAe,KAA2B;AAC3E,IAAA,OAAO,EAA2B;AACpC;AAYA;;;AAGG;AACU,MAAA,gBAAgB,GAAG,CAAC,EAAe,KAAyB;AACvE,IAAA,OAAO,EAAyB;AAClC;AAEA;;AAEG;AACI,MAAM,YAAY,GAAG;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A,OAAe;AACf,IAAA,QAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf;;AAEG;AACH,IAAA,QAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,QAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACjB,CAAC,EAbWA,gBAAQ,KAARA,gBAAQ,GAanB,EAAA,CAAA,CAAA;;AC8DD;;;;;;AAMG;AACU,MAAA,mBAAmB,GAAG,CAAqB,QAAW,KACjE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,8 @@ export * from './wallet-provider';
|
|
|
6
6
|
export * from './public-data-provider';
|
|
7
7
|
export * from './providers';
|
|
8
8
|
export * from './zk-config-provider';
|
|
9
|
+
export * from './errors';
|
|
9
10
|
export { UnprovenTransaction } from '@midnight-ntwrk/ledger';
|
|
11
|
+
export * from './logger-provider';
|
|
12
|
+
export { ImpureCircuit, ImpureCircuits, Witness, Witnesses, Contract, ImpureCircuitId, PrivateState, getImpureCircuitIds, CircuitParameters, CircuitReturnType, InitialStateParameters } from './contract';
|
|
10
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EACL,SAAS,EACT,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EACL,SAAS,EACT,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACL,aAAa,EACb,cAAc,EACd,OAAO,EACP,SAAS,EACT,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,YAAY,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -88,5 +88,50 @@ class ZKConfigProvider {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
/**
|
|
92
|
+
* An error describing an invalid protocol scheme.
|
|
93
|
+
*/
|
|
94
|
+
class InvalidProtocolSchemeError extends Error {
|
|
95
|
+
invalidScheme;
|
|
96
|
+
allowableSchemes;
|
|
97
|
+
/**
|
|
98
|
+
* @param invalidScheme The invalid scheme.
|
|
99
|
+
* @param allowableSchemes The valid schemes that are allowed.
|
|
100
|
+
*/
|
|
101
|
+
constructor(invalidScheme, allowableSchemes) {
|
|
102
|
+
super(`Invalid protocol scheme: '${invalidScheme}'. Allowable schemes are one of: ${allowableSchemes.join(',')}`);
|
|
103
|
+
this.invalidScheme = invalidScheme;
|
|
104
|
+
this.allowableSchemes = allowableSchemes;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A valid named log level.
|
|
110
|
+
*/
|
|
111
|
+
var LogLevel;
|
|
112
|
+
(function (LogLevel) {
|
|
113
|
+
/**
|
|
114
|
+
* Log levels typically used by DAapp developers.
|
|
115
|
+
*/
|
|
116
|
+
LogLevel["INFO"] = "info";
|
|
117
|
+
LogLevel["WARN"] = "warn";
|
|
118
|
+
LogLevel["ERROR"] = "error";
|
|
119
|
+
LogLevel["FATAL"] = "fatal";
|
|
120
|
+
/**
|
|
121
|
+
* Log levels used by Midnight.JS to report internal state.
|
|
122
|
+
*/
|
|
123
|
+
LogLevel["DEBUG"] = "debug";
|
|
124
|
+
LogLevel["TRACE"] = "trace";
|
|
125
|
+
})(LogLevel || (LogLevel = {}));
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Typesafe version of `Object.keys(contract.impureCircuits)`.
|
|
129
|
+
*
|
|
130
|
+
* @param contract The contract having impure circuits for which we want ids.
|
|
131
|
+
*
|
|
132
|
+
* @typeParam C The contract type for which we would like impure circuit IDs.
|
|
133
|
+
*/
|
|
134
|
+
const getImpureCircuitIds = (contract) => Object.keys(contract.impureCircuits);
|
|
135
|
+
|
|
136
|
+
export { FailEntirely, FailFallible, InvalidProtocolSchemeError, LogLevel, SucceedEntirely, ZKConfigProvider, createBalancedTx, createProverKey, createUnbalancedTx, createVerifierKey, createZKIR, getImpureCircuitIds };
|
|
92
137
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/midnight-types.ts","../src/zk-config-provider.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;AAYA;;;;AAIG;AACU,MAAA,eAAe,GAAG,CAAC,UAAsB,KAAe;AACnE,IAAA,OAAO,UAAuB
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/midnight-types.ts","../src/zk-config-provider.ts","../src/errors.ts","../src/logger-provider.ts","../src/contract.ts"],"sourcesContent":[null,null,null,null,null],"names":[],"mappings":";;AAYA;;;;AAIG;AACU,MAAA,eAAe,GAAG,CAAC,UAAsB,KAAe;AACnE,IAAA,OAAO,UAAuB;AAChC;AAYA;;;;AAIG;AACU,MAAA,iBAAiB,GAAG,CAAC,UAAsB,KAAiB;AACvE,IAAA,OAAO,UAAyB;AAClC;AAYA;;;;AAIG;AACU,MAAA,UAAU,GAAG,CAAC,UAAsB,KAAU;AACzD,IAAA,OAAO,UAAkB;AAC3B;AAmCA;;;;AAIG;AACU,MAAA,kBAAkB,GAAG,CAAC,EAAe,KAA2B;AAC3E,IAAA,OAAO,EAA2B;AACpC;AAYA;;;AAGG;AACU,MAAA,gBAAgB,GAAG,CAAC,EAAe,KAAyB;AACvE,IAAA,OAAO,EAAyB;AAClC;AAEA;;AAEG;AACI,MAAM,YAAY,GAAG;AAE5B;;;;;AAKG;AACI,MAAM,YAAY,GAAG;AAE5B;;;AAGG;AACI,MAAM,eAAe,GAAG;;ACtI/B;;;;;;AAMG;MACmB,gBAAgB,CAAA;AAmBpC;;;AAGG;IACH,MAAM,eAAe,CAAC,UAAe,EAAA;AACnC,QAAA,OAAO,OAAO,CAAC,GAAG,CAChB,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,KAAI;YAC1B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;AACzC,YAAA,OAAO,CAAC,EAAE,EAAE,GAAG,CAAC;SACjB,CAAC,CACH;;AAGH;;;AAGG;IACH,MAAM,GAAG,CAAC,SAAY,EAAA;QACpB,OAAO;YACL,SAA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export declare enum LogLevel {
|
|
6
|
+
/**
|
|
7
|
+
* Log levels typically used by DAapp developers.
|
|
8
|
+
*/
|
|
9
|
+
INFO = "info",
|
|
10
|
+
WARN = "warn",
|
|
11
|
+
ERROR = "error",
|
|
12
|
+
FATAL = "fatal",
|
|
13
|
+
/**
|
|
14
|
+
* Log levels used by Midnight.JS to report internal state.
|
|
15
|
+
*/
|
|
16
|
+
DEBUG = "debug",
|
|
17
|
+
TRACE = "trace"
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A provider for logging functions.
|
|
21
|
+
*/
|
|
22
|
+
export interface LoggerProvider {
|
|
23
|
+
info?: LogFn;
|
|
24
|
+
warn?: LogFn;
|
|
25
|
+
error?: LogFn;
|
|
26
|
+
debug?: LogFn;
|
|
27
|
+
fatal?: LogFn;
|
|
28
|
+
isLevelEnabled(level: LogLevel): boolean;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=logger-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-provider.d.ts","sourceRoot":"","sources":["../src/logger-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAElC;;GAEG;AACH,oBAAY,QAAQ;IAClB;;OAEG;IACH,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;IACf,KAAK,UAAU;IACf;;OAEG;IACH,KAAK,UAAU;IACf,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,cAAc,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midnight-types.d.ts","sourceRoot":"","sources":["../src/midnight-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE1F;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG;IACnC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,MAAM,CAAC;CACnC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"midnight-types.d.ts","sourceRoot":"","sources":["../src/midnight-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE1F;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG;IACnC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,MAAM,CAAC;CACnC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,YAAY,UAAU,KAAG,SAExD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IACrC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,OAAO,MAAM,CAAC;CACrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,YAAY,UAAU,KAAG,WAE1D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG;IAC9B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,YAAY,UAAU,KAAG,IAEnD,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,MAAM;IACxC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;IACtB;;OAEG;IACH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B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B"}
|
|
@@ -1,63 +1,57 @@
|
|
|
1
|
-
import type { SigningKey } from '@midnight-ntwrk/compact-runtime';
|
|
1
|
+
import type { SigningKey, ContractAddress } from '@midnight-ntwrk/compact-runtime';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* for a particular contract. Each key is the name used to refer to a private state.
|
|
3
|
+
* A type representing an ID used to store a contract's private state.
|
|
5
4
|
*/
|
|
6
|
-
export type
|
|
7
|
-
/**
|
|
8
|
-
* A string key of a {@link PrivateStateSchema} object.
|
|
9
|
-
*/
|
|
10
|
-
export type PrivateStateKey<PSS extends PrivateStateSchema = PrivateStateSchema> = keyof PSS & string;
|
|
5
|
+
export type PrivateStateId = string;
|
|
11
6
|
/**
|
|
12
7
|
* Interface for a typed key-valued store containing contract private states.
|
|
13
8
|
*
|
|
14
|
-
* @typeParam
|
|
15
|
-
*
|
|
16
|
-
* used to refer to a private state.
|
|
9
|
+
* @typeParam PSI - Parameter indicating the private state ID, sometimes a union of string literals.
|
|
10
|
+
* @typeParam PS - Parameter indicating the private state type stored, sometimes a union of private state types.
|
|
17
11
|
*/
|
|
18
|
-
export interface PrivateStateProvider<
|
|
12
|
+
export interface PrivateStateProvider<PSI extends PrivateStateId = PrivateStateId, PS = any> {
|
|
19
13
|
/**
|
|
20
|
-
* Store the given private state at the given
|
|
14
|
+
* Store the given private state at the given private state ID.
|
|
21
15
|
*
|
|
22
|
-
* @param
|
|
16
|
+
* @param privateStateId The private state identifier.
|
|
23
17
|
* @param state The private state to store.
|
|
24
18
|
*/
|
|
25
|
-
set
|
|
19
|
+
set(privateStateId: PSI, state: PS): Promise<void>;
|
|
26
20
|
/**
|
|
27
|
-
* Retrieve the private state at the given
|
|
21
|
+
* Retrieve the private state at the given private state ID.
|
|
28
22
|
*
|
|
29
|
-
* @param
|
|
23
|
+
* @param privateStateId The private state identifier.
|
|
30
24
|
*/
|
|
31
|
-
get
|
|
25
|
+
get(privateStateId: PSI): Promise<PS | null>;
|
|
32
26
|
/**
|
|
33
|
-
* Remove the value at the given
|
|
27
|
+
* Remove the value at the given private state ID.
|
|
34
28
|
*
|
|
35
|
-
* @param
|
|
29
|
+
* @param privateStateId The private state identifier.
|
|
36
30
|
*/
|
|
37
|
-
remove
|
|
31
|
+
remove(privateStateId: PSI): Promise<void>;
|
|
38
32
|
/**
|
|
39
33
|
* Remove all contract private states.
|
|
40
34
|
*/
|
|
41
35
|
clear(): Promise<void>;
|
|
42
36
|
/**
|
|
43
|
-
* Store the given
|
|
37
|
+
* Store the given signing key at the given address.
|
|
44
38
|
*
|
|
45
|
-
* @param
|
|
39
|
+
* @param address The address of the contract having the given signing key.
|
|
46
40
|
* @param signingKey The signing key to store.
|
|
47
41
|
*/
|
|
48
|
-
setSigningKey
|
|
42
|
+
setSigningKey(address: ContractAddress, signingKey: SigningKey): Promise<void>;
|
|
49
43
|
/**
|
|
50
44
|
* Retrieve the signing key for a contract.
|
|
51
45
|
*
|
|
52
|
-
* @param
|
|
46
|
+
* @param address The address of the contract for which to get the signing key.
|
|
53
47
|
*/
|
|
54
|
-
getSigningKey
|
|
48
|
+
getSigningKey(address: ContractAddress): Promise<SigningKey | null>;
|
|
55
49
|
/**
|
|
56
50
|
* Remove the signing key for a contract.
|
|
57
51
|
*
|
|
58
|
-
* @param
|
|
52
|
+
* @param address The address of the contract for which to delete the signing key.
|
|
59
53
|
*/
|
|
60
|
-
removeSigningKey
|
|
54
|
+
removeSigningKey(address: ContractAddress): Promise<void>;
|
|
61
55
|
/**
|
|
62
56
|
* Remove all contract signing keys.
|
|
63
57
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-state-provider.d.ts","sourceRoot":"","sources":["../src/private-state-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"private-state-provider.d.ts","sourceRoot":"","sources":["../src/private-state-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEnF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAIpC;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB,CAAC,GAAG,SAAS,cAAc,GAAG,cAAc,EAAE,EAAE,GAAG,GAAG;IACzF;;;;;OAKG;IACH,GAAG,CAAC,cAAc,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD;;;;OAIG;IACH,GAAG,CAAC,cAAc,EAAE,GAAG,GAAG,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IAE7C;;;;OAIG;IACH,MAAM,CAAC,cAAc,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3C;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;;;OAKG;IACH,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/E;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAEpE;;;;OAIG;IACH,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1D;;OAEG;IACH,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC"}
|
package/dist/providers.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PrivateStateId, PrivateStateProvider } from './private-state-provider';
|
|
2
2
|
import type { PublicDataProvider } from './public-data-provider';
|
|
3
3
|
import type { ProofProvider } from './proof-provider';
|
|
4
4
|
import type { WalletProvider } from './wallet-provider';
|
|
5
5
|
import type { MidnightProvider } from './midnight-provider';
|
|
6
6
|
import type { ZKConfigProvider } from './zk-config-provider';
|
|
7
|
+
import type { LoggerProvider } from './logger-provider';
|
|
8
|
+
import { type ImpureCircuitId } from './contract';
|
|
7
9
|
/**
|
|
8
10
|
* Set of providers needed for transaction construction and submission.
|
|
11
|
+
*
|
|
9
12
|
* @typeParam ICK - A union of string literal types representing the callable circuits.
|
|
10
|
-
* @typeParam
|
|
13
|
+
* @typeParam PSI - Parameter indicating the private state ID, sometimes a union of string literals.
|
|
14
|
+
* @typeParam PS - Parameter indicating the private state type stored, sometimes a union of private state types.
|
|
11
15
|
*/
|
|
12
|
-
export interface MidnightProviders<ICK extends
|
|
16
|
+
export interface MidnightProviders<ICK extends ImpureCircuitId = ImpureCircuitId, PSI extends PrivateStateId = PrivateStateId, PS = any> {
|
|
13
17
|
/**
|
|
14
18
|
* Manages the private state of a contract.
|
|
15
19
|
*/
|
|
16
|
-
readonly privateStateProvider: PrivateStateProvider<
|
|
20
|
+
readonly privateStateProvider: PrivateStateProvider<PSI, PS>;
|
|
17
21
|
/**
|
|
18
22
|
* Retrieves public data from the blockchain.
|
|
19
23
|
*/
|
|
@@ -34,5 +38,9 @@ export interface MidnightProviders<ICK extends string = string, PSS extends Priv
|
|
|
34
38
|
* Submits proven, balanced transactions to the network.
|
|
35
39
|
*/
|
|
36
40
|
readonly midnightProvider: MidnightProvider;
|
|
41
|
+
/**
|
|
42
|
+
* An optional logger that provides utilities for logging at given levels.
|
|
43
|
+
*/
|
|
44
|
+
readonly loggerProvider?: LoggerProvider;
|
|
37
45
|
}
|
|
38
46
|
//# sourceMappingURL=providers.d.ts.map
|
package/dist/providers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":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CoinInfo, CoinPublicKey, EncPublicKey } from '@midnight-ntwrk/ledger';
|
|
2
2
|
import type { BalancedTransaction, UnbalancedTransaction } from './midnight-types';
|
|
3
3
|
/**
|
|
4
4
|
* Interface for a wallet
|
|
@@ -8,6 +8,10 @@ export interface WalletProvider {
|
|
|
8
8
|
* Wallet public coin key
|
|
9
9
|
*/
|
|
10
10
|
readonly coinPublicKey: CoinPublicKey;
|
|
11
|
+
/**
|
|
12
|
+
* Wallet EncryptionPublicKey
|
|
13
|
+
*/
|
|
14
|
+
readonly encryptionPublicKey: EncPublicKey;
|
|
11
15
|
/**
|
|
12
16
|
* Balances selects coins, creates spend proofs, and pays fees for a transaction with call proofs.
|
|
13
17
|
* @param tx The transaction to balance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-provider.d.ts","sourceRoot":"","sources":["../src/wallet-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"wallet-provider.d.ts","sourceRoot":"","sources":["../src/wallet-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,mBAAmB,EAAE,YAAY,CAAC;IAE3C;;;;OAIG;IACH,SAAS,CAAC,EAAE,EAAE,qBAAqB,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC1F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midnight-ntwrk/midnight-js-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Shared data types and interfaces for MidnightJS modules",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"repository": "git@github.com:midnight-ntwrk/artifacts",
|
|
16
|
-
"packageManager": "yarn@4.1
|
|
16
|
+
"packageManager": "yarn@4.9.1",
|
|
17
17
|
"author": "IOHK",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"scripts": {
|