@nucypher/taco 0.4.0 → 0.6.0-alpha.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 +0 -1
- package/dist/cjs/conditions/base/contract.d.ts +2 -432
- package/dist/cjs/conditions/base/contract.js +7 -80
- package/dist/cjs/conditions/base/contract.js.map +1 -1
- package/dist/cjs/conditions/base/index.d.ts +1 -0
- package/dist/cjs/conditions/base/index.js +2 -1
- package/dist/cjs/conditions/base/index.js.map +1 -1
- package/dist/cjs/conditions/base/json-api.d.ts +7 -0
- package/dist/cjs/conditions/base/json-api.js +19 -0
- package/dist/cjs/conditions/base/json-api.js.map +1 -0
- package/dist/cjs/conditions/base/rpc.d.ts +2 -42
- package/dist/cjs/conditions/base/rpc.js +7 -22
- package/dist/cjs/conditions/base/rpc.js.map +1 -1
- package/dist/cjs/conditions/base/time.d.ts +2 -40
- package/dist/cjs/conditions/base/time.js +8 -15
- package/dist/cjs/conditions/base/time.js.map +1 -1
- package/dist/cjs/conditions/compound-condition.d.ts +2 -4
- package/dist/cjs/conditions/compound-condition.js +7 -38
- package/dist/cjs/conditions/compound-condition.js.map +1 -1
- package/dist/cjs/conditions/condition-expr.d.ts +0 -3
- package/dist/cjs/conditions/condition-expr.js +0 -4
- package/dist/cjs/conditions/condition-expr.js.map +1 -1
- package/dist/cjs/conditions/condition-factory.js +11 -0
- package/dist/cjs/conditions/condition-factory.js.map +1 -1
- package/dist/cjs/conditions/condition.d.ts +1 -1
- package/dist/cjs/conditions/condition.js +3 -1
- package/dist/cjs/conditions/condition.js.map +1 -1
- package/dist/cjs/conditions/const.d.ts +1 -2
- package/dist/cjs/conditions/const.js +6 -8
- package/dist/cjs/conditions/const.js.map +1 -1
- package/dist/cjs/conditions/context/context.d.ts +15 -13
- package/dist/cjs/conditions/context/context.js +62 -56
- package/dist/cjs/conditions/context/context.js.map +1 -1
- package/dist/cjs/conditions/if-then-else-condition.d.ts +7 -0
- package/dist/cjs/conditions/if-then-else-condition.js +18 -0
- package/dist/cjs/conditions/if-then-else-condition.js.map +1 -0
- package/dist/cjs/conditions/index.d.ts +2 -0
- package/dist/cjs/conditions/index.js +3 -1
- package/dist/cjs/conditions/index.js.map +1 -1
- package/dist/cjs/conditions/multi-condition.d.ts +2 -0
- package/dist/cjs/conditions/multi-condition.js +35 -0
- package/dist/cjs/conditions/multi-condition.js.map +1 -0
- package/dist/cjs/conditions/schemas/common.d.ts +12 -0
- package/dist/cjs/conditions/schemas/common.js +36 -0
- package/dist/cjs/conditions/schemas/common.js.map +1 -0
- package/dist/cjs/conditions/schemas/compound.d.ts +4 -0
- package/dist/cjs/conditions/schemas/compound.js +36 -0
- package/dist/cjs/conditions/schemas/compound.js.map +1 -0
- package/dist/cjs/conditions/schemas/context.d.ts +3 -0
- package/dist/cjs/conditions/schemas/context.js +16 -0
- package/dist/cjs/conditions/schemas/context.js.map +1 -0
- package/dist/cjs/conditions/schemas/contract.d.ts +428 -0
- package/dist/cjs/conditions/schemas/contract.js +81 -0
- package/dist/cjs/conditions/schemas/contract.js.map +1 -0
- package/dist/cjs/conditions/schemas/if-then-else.d.ts +4 -0
- package/dist/cjs/conditions/schemas/if-then-else.js +40 -0
- package/dist/cjs/conditions/schemas/if-then-else.js.map +1 -0
- package/dist/cjs/conditions/schemas/json-api.d.ts +46 -0
- package/dist/cjs/conditions/schemas/json-api.js +37 -0
- package/dist/cjs/conditions/schemas/json-api.js.map +1 -0
- package/dist/cjs/conditions/schemas/return-value-test.d.ts +15 -0
- package/dist/cjs/conditions/schemas/return-value-test.js +11 -0
- package/dist/cjs/conditions/schemas/return-value-test.js.map +1 -0
- package/dist/cjs/conditions/schemas/rpc.d.ts +42 -0
- package/dist/cjs/conditions/schemas/rpc.js +58 -0
- package/dist/cjs/conditions/schemas/rpc.js.map +1 -0
- package/dist/cjs/conditions/schemas/sequential.d.ts +6 -0
- package/dist/cjs/conditions/schemas/sequential.js +39 -0
- package/dist/cjs/conditions/schemas/sequential.js.map +1 -0
- package/dist/cjs/conditions/schemas/time.d.ts +40 -0
- package/dist/cjs/conditions/schemas/time.js +16 -0
- package/dist/cjs/conditions/schemas/time.js.map +1 -0
- package/dist/cjs/conditions/schemas/utils.d.ts +2 -0
- package/dist/cjs/conditions/schemas/utils.js +21 -0
- package/dist/cjs/conditions/schemas/utils.js.map +1 -0
- package/dist/cjs/conditions/sequential.d.ts +7 -0
- package/dist/cjs/conditions/sequential.js +18 -0
- package/dist/cjs/conditions/sequential.js.map +1 -0
- package/dist/cjs/conditions/shared.d.ts +2 -19
- package/dist/cjs/conditions/shared.js +6 -32
- package/dist/cjs/conditions/shared.js.map +1 -1
- package/dist/cjs/dkg.d.ts +1 -1
- package/dist/cjs/dkg.js +2 -2
- package/dist/cjs/dkg.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -3
- package/dist/cjs/index.js +2 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/taco.d.ts +5 -23
- package/dist/cjs/taco.js +9 -36
- package/dist/cjs/taco.js.map +1 -1
- package/dist/cjs/tdec.d.ts +3 -4
- package/dist/cjs/tdec.js +11 -8
- package/dist/cjs/tdec.js.map +1 -1
- package/dist/es/conditions/base/contract.d.ts +2 -432
- package/dist/es/conditions/base/contract.js +2 -77
- package/dist/es/conditions/base/contract.js.map +1 -1
- package/dist/es/conditions/base/index.d.ts +1 -0
- package/dist/es/conditions/base/index.js +1 -0
- package/dist/es/conditions/base/index.js.map +1 -1
- package/dist/es/conditions/base/json-api.d.ts +7 -0
- package/dist/es/conditions/base/json-api.js +12 -0
- package/dist/es/conditions/base/json-api.js.map +1 -0
- package/dist/es/conditions/base/rpc.d.ts +2 -42
- package/dist/es/conditions/base/rpc.js +2 -16
- package/dist/es/conditions/base/rpc.js.map +1 -1
- package/dist/es/conditions/base/time.d.ts +2 -40
- package/dist/es/conditions/base/time.js +2 -12
- package/dist/es/conditions/base/time.js.map +1 -1
- package/dist/es/conditions/compound-condition.d.ts +2 -4
- package/dist/es/conditions/compound-condition.js +2 -35
- package/dist/es/conditions/compound-condition.js.map +1 -1
- package/dist/es/conditions/condition-expr.d.ts +0 -3
- package/dist/es/conditions/condition-expr.js +0 -4
- package/dist/es/conditions/condition-expr.js.map +1 -1
- package/dist/es/conditions/condition-factory.js +11 -0
- package/dist/es/conditions/condition-factory.js.map +1 -1
- package/dist/es/conditions/condition.d.ts +1 -1
- package/dist/es/conditions/condition.js +1 -0
- package/dist/es/conditions/condition.js.map +1 -1
- package/dist/es/conditions/const.d.ts +1 -2
- package/dist/es/conditions/const.js +5 -7
- package/dist/es/conditions/const.js.map +1 -1
- package/dist/es/conditions/context/context.d.ts +15 -13
- package/dist/es/conditions/context/context.js +63 -57
- package/dist/es/conditions/context/context.js.map +1 -1
- package/dist/es/conditions/if-then-else-condition.d.ts +7 -0
- package/dist/es/conditions/if-then-else-condition.js +12 -0
- package/dist/es/conditions/if-then-else-condition.js.map +1 -0
- package/dist/es/conditions/index.d.ts +2 -0
- package/dist/es/conditions/index.js +2 -0
- package/dist/es/conditions/index.js.map +1 -1
- package/dist/es/conditions/multi-condition.d.ts +2 -0
- package/dist/es/conditions/multi-condition.js +31 -0
- package/dist/es/conditions/multi-condition.js.map +1 -0
- package/dist/es/conditions/schemas/common.d.ts +12 -0
- package/dist/es/conditions/schemas/common.js +33 -0
- package/dist/es/conditions/schemas/common.js.map +1 -0
- package/dist/es/conditions/schemas/compound.d.ts +4 -0
- package/dist/es/conditions/schemas/compound.js +33 -0
- package/dist/es/conditions/schemas/compound.js.map +1 -0
- package/dist/es/conditions/schemas/context.d.ts +3 -0
- package/dist/es/conditions/schemas/context.js +13 -0
- package/dist/es/conditions/schemas/context.js.map +1 -0
- package/dist/es/conditions/schemas/contract.d.ts +428 -0
- package/dist/es/conditions/schemas/contract.js +78 -0
- package/dist/es/conditions/schemas/contract.js.map +1 -0
- package/dist/es/conditions/schemas/if-then-else.d.ts +4 -0
- package/dist/es/conditions/schemas/if-then-else.js +37 -0
- package/dist/es/conditions/schemas/if-then-else.js.map +1 -0
- package/dist/es/conditions/schemas/json-api.d.ts +46 -0
- package/dist/es/conditions/schemas/json-api.js +34 -0
- package/dist/es/conditions/schemas/json-api.js.map +1 -0
- package/dist/es/conditions/schemas/return-value-test.d.ts +15 -0
- package/dist/es/conditions/schemas/return-value-test.js +8 -0
- package/dist/es/conditions/schemas/return-value-test.js.map +1 -0
- package/dist/es/conditions/schemas/rpc.d.ts +42 -0
- package/dist/es/conditions/schemas/rpc.js +32 -0
- package/dist/es/conditions/schemas/rpc.js.map +1 -0
- package/dist/es/conditions/schemas/sequential.d.ts +6 -0
- package/dist/es/conditions/schemas/sequential.js +36 -0
- package/dist/es/conditions/schemas/sequential.js.map +1 -0
- package/dist/es/conditions/schemas/time.d.ts +40 -0
- package/dist/es/conditions/schemas/time.js +13 -0
- package/dist/es/conditions/schemas/time.js.map +1 -0
- package/dist/es/conditions/schemas/utils.d.ts +2 -0
- package/dist/es/conditions/schemas/utils.js +18 -0
- package/dist/es/conditions/schemas/utils.js.map +1 -0
- package/dist/es/conditions/sequential.d.ts +7 -0
- package/dist/es/conditions/sequential.js +12 -0
- package/dist/es/conditions/sequential.js.map +1 -0
- package/dist/es/conditions/shared.d.ts +2 -19
- package/dist/es/conditions/shared.js +2 -33
- package/dist/es/conditions/shared.js.map +1 -1
- package/dist/es/dkg.d.ts +1 -1
- package/dist/es/dkg.js +2 -2
- package/dist/es/dkg.js.map +1 -1
- package/dist/es/index.d.ts +2 -3
- package/dist/es/index.js +2 -5
- package/dist/es/index.js.map +1 -1
- package/dist/es/taco.d.ts +5 -23
- package/dist/es/taco.js +9 -34
- package/dist/es/taco.js.map +1 -1
- package/dist/es/tdec.d.ts +3 -4
- package/dist/es/tdec.js +12 -9
- package/dist/es/tdec.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.es.tsbuildinfo +1 -1
- package/package.json +7 -6
package/dist/cjs/tdec.js
CHANGED
|
@@ -5,6 +5,7 @@ const nucypher_core_1 = require("@nucypher/nucypher-core");
|
|
|
5
5
|
const shared_1 = require("@nucypher/shared");
|
|
6
6
|
const utils_1 = require("ethers/lib/utils");
|
|
7
7
|
const context_1 = require("./conditions/context");
|
|
8
|
+
const dkg_1 = require("./dkg");
|
|
8
9
|
const ERR_DECRYPTION_FAILED = (errors) => `Threshold of responses not met; TACo decryption failed with errors: ${JSON.stringify(errors)}`;
|
|
9
10
|
const ERR_RITUAL_ID_MISMATCH = (expectedRitualId, ritualIds) => `Ritual id mismatch. Expected ${expectedRitualId}, got ${ritualIds}`;
|
|
10
11
|
const encryptMessage = async (plaintext, encryptingKey, conditions, authSigner) => {
|
|
@@ -16,20 +17,22 @@ const encryptMessage = async (plaintext, encryptingKey, conditions, authSigner)
|
|
|
16
17
|
};
|
|
17
18
|
exports.encryptMessage = encryptMessage;
|
|
18
19
|
// Retrieve and decrypt ciphertext using provider and condition expression
|
|
19
|
-
const retrieveAndDecrypt = async (provider, domain,
|
|
20
|
-
const decryptionShares = await retrieve(provider, domain,
|
|
20
|
+
const retrieveAndDecrypt = async (provider, domain, porter, thresholdMessageKit, ritualId, context) => {
|
|
21
|
+
const decryptionShares = await retrieve(provider, domain, porter, thresholdMessageKit, ritualId, context);
|
|
21
22
|
const sharedSecret = (0, nucypher_core_1.combineDecryptionSharesSimple)(decryptionShares);
|
|
22
23
|
return thresholdMessageKit.decryptWithSharedSecret(sharedSecret);
|
|
23
24
|
};
|
|
24
25
|
exports.retrieveAndDecrypt = retrieveAndDecrypt;
|
|
25
26
|
// Retrieve decryption shares
|
|
26
|
-
const retrieve = async (provider, domain,
|
|
27
|
-
const
|
|
28
|
-
const
|
|
27
|
+
const retrieve = async (provider, domain, porter, thresholdMessageKit, ritualId, context) => {
|
|
28
|
+
const ritual = await dkg_1.DkgClient.getActiveRitual(provider, domain, ritualId);
|
|
29
|
+
const dkgParticipants = await shared_1.DkgCoordinatorAgent.getParticipants(provider, domain, ritualId, ritual.sharesNum);
|
|
30
|
+
const conditionContext = context
|
|
31
|
+
? context
|
|
32
|
+
: context_1.ConditionContext.fromMessageKit(thresholdMessageKit);
|
|
29
33
|
const { sharedSecrets, encryptedRequests } = await makeDecryptionRequests(ritualId, conditionContext, dkgParticipants, thresholdMessageKit);
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
if (Object.keys(encryptedResponses).length < threshold) {
|
|
34
|
+
const { encryptedResponses, errors } = await porter.tacoDecrypt(encryptedRequests, ritual.threshold);
|
|
35
|
+
if (Object.keys(encryptedResponses).length < ritual.threshold) {
|
|
33
36
|
throw new Error(ERR_DECRYPTION_FAILED(errors));
|
|
34
37
|
}
|
|
35
38
|
return makeDecryptionShares(encryptedResponses, sharedSecrets, ritualId);
|
package/dist/cjs/tdec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tdec.js","sourceRoot":"","sources":["../../src/tdec.ts"],"names":[],"mappings":";;;AAAA,2DAaiC;AACjC,6CAM0B;
|
|
1
|
+
{"version":3,"file":"tdec.js","sourceRoot":"","sources":["../../src/tdec.ts"],"names":[],"mappings":";;;AAAA,2DAaiC;AACjC,6CAM0B;AAE1B,4CAAuD;AAGvD,kDAAwD;AACxD,+BAAkC;AAElC,MAAM,qBAAqB,GAAG,CAAC,MAAe,EAAE,EAAE,CAChD,uEAAuE,IAAI,CAAC,SAAS,CACnF,MAAM,CACP,EAAE,CAAC;AACN,MAAM,sBAAsB,GAAG,CAC7B,gBAAwB,EACxB,SAAmB,EACnB,EAAE,CAAC,gCAAgC,gBAAgB,SAAS,SAAS,EAAE,CAAC;AAEnE,MAAM,cAAc,GAAG,KAAK,EACjC,SAA8B,EAC9B,aAA2B,EAC3B,UAA+B,EAC/B,UAAyB,EACK,EAAE;IAChC,MAAM,CAAC,UAAU,EAAE,iBAAiB,CAAC,GAAG,IAAA,6BAAa,EACnD,SAAS,YAAY,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,gBAAO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,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC;AAC9C,CAAC,CAAC;AAEF,0DAA0D;AAC1D,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,mCAAmB,CAAC,MAAM,EAAE,CAAC"}
|
|
@@ -1,437 +1,7 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { Condition } from '../condition';
|
|
2
|
+
import { ContractConditionProps } from '../schemas/contract';
|
|
3
3
|
import { OmitConditionType } from '../shared';
|
|
4
|
-
|
|
5
|
-
name: z.ZodString;
|
|
6
|
-
type: z.ZodLiteral<"function">;
|
|
7
|
-
inputs: z.ZodArray<z.ZodObject<{
|
|
8
|
-
name: z.ZodString;
|
|
9
|
-
type: z.ZodEnum<[string, ...string[]]>;
|
|
10
|
-
internalType: z.ZodEnum<[string, ...string[]]>;
|
|
11
|
-
}, "strict", z.ZodTypeAny, {
|
|
12
|
-
type: string;
|
|
13
|
-
name: string;
|
|
14
|
-
internalType: string;
|
|
15
|
-
}, {
|
|
16
|
-
type: string;
|
|
17
|
-
name: string;
|
|
18
|
-
internalType: string;
|
|
19
|
-
}>, "many">;
|
|
20
|
-
outputs: z.ZodArray<z.ZodObject<{
|
|
21
|
-
name: z.ZodString;
|
|
22
|
-
type: z.ZodEnum<[string, ...string[]]>;
|
|
23
|
-
internalType: z.ZodEnum<[string, ...string[]]>;
|
|
24
|
-
}, "strict", z.ZodTypeAny, {
|
|
25
|
-
type: string;
|
|
26
|
-
name: string;
|
|
27
|
-
internalType: string;
|
|
28
|
-
}, {
|
|
29
|
-
type: string;
|
|
30
|
-
name: string;
|
|
31
|
-
internalType: string;
|
|
32
|
-
}>, "atleastone">;
|
|
33
|
-
stateMutability: z.ZodUnion<[z.ZodLiteral<"view">, z.ZodLiteral<"pure">]>;
|
|
34
|
-
}, "strict", z.ZodTypeAny, {
|
|
35
|
-
type: "function";
|
|
36
|
-
name: string;
|
|
37
|
-
inputs: {
|
|
38
|
-
type: string;
|
|
39
|
-
name: string;
|
|
40
|
-
internalType: string;
|
|
41
|
-
}[];
|
|
42
|
-
outputs: [{
|
|
43
|
-
type: string;
|
|
44
|
-
name: string;
|
|
45
|
-
internalType: string;
|
|
46
|
-
}, ...{
|
|
47
|
-
type: string;
|
|
48
|
-
name: string;
|
|
49
|
-
internalType: string;
|
|
50
|
-
}[]];
|
|
51
|
-
stateMutability: "view" | "pure";
|
|
52
|
-
}, {
|
|
53
|
-
type: "function";
|
|
54
|
-
name: string;
|
|
55
|
-
inputs: {
|
|
56
|
-
type: string;
|
|
57
|
-
name: string;
|
|
58
|
-
internalType: string;
|
|
59
|
-
}[];
|
|
60
|
-
outputs: [{
|
|
61
|
-
type: string;
|
|
62
|
-
name: string;
|
|
63
|
-
internalType: string;
|
|
64
|
-
}, ...{
|
|
65
|
-
type: string;
|
|
66
|
-
name: string;
|
|
67
|
-
internalType: string;
|
|
68
|
-
}[]];
|
|
69
|
-
stateMutability: "view" | "pure";
|
|
70
|
-
}>, {
|
|
71
|
-
type: "function";
|
|
72
|
-
name: string;
|
|
73
|
-
inputs: {
|
|
74
|
-
type: string;
|
|
75
|
-
name: string;
|
|
76
|
-
internalType: string;
|
|
77
|
-
}[];
|
|
78
|
-
outputs: [{
|
|
79
|
-
type: string;
|
|
80
|
-
name: string;
|
|
81
|
-
internalType: string;
|
|
82
|
-
}, ...{
|
|
83
|
-
type: string;
|
|
84
|
-
name: string;
|
|
85
|
-
internalType: string;
|
|
86
|
-
}[]];
|
|
87
|
-
stateMutability: "view" | "pure";
|
|
88
|
-
}, {
|
|
89
|
-
type: "function";
|
|
90
|
-
name: string;
|
|
91
|
-
inputs: {
|
|
92
|
-
type: string;
|
|
93
|
-
name: string;
|
|
94
|
-
internalType: string;
|
|
95
|
-
}[];
|
|
96
|
-
outputs: [{
|
|
97
|
-
type: string;
|
|
98
|
-
name: string;
|
|
99
|
-
internalType: string;
|
|
100
|
-
}, ...{
|
|
101
|
-
type: string;
|
|
102
|
-
name: string;
|
|
103
|
-
internalType: string;
|
|
104
|
-
}[]];
|
|
105
|
-
stateMutability: "view" | "pure";
|
|
106
|
-
}>, {
|
|
107
|
-
type: "function";
|
|
108
|
-
name: string;
|
|
109
|
-
inputs: {
|
|
110
|
-
type: string;
|
|
111
|
-
name: string;
|
|
112
|
-
internalType: string;
|
|
113
|
-
}[];
|
|
114
|
-
outputs: [{
|
|
115
|
-
type: string;
|
|
116
|
-
name: string;
|
|
117
|
-
internalType: string;
|
|
118
|
-
}, ...{
|
|
119
|
-
type: string;
|
|
120
|
-
name: string;
|
|
121
|
-
internalType: string;
|
|
122
|
-
}[]];
|
|
123
|
-
stateMutability: "view" | "pure";
|
|
124
|
-
}, {
|
|
125
|
-
type: "function";
|
|
126
|
-
name: string;
|
|
127
|
-
inputs: {
|
|
128
|
-
type: string;
|
|
129
|
-
name: string;
|
|
130
|
-
internalType: string;
|
|
131
|
-
}[];
|
|
132
|
-
outputs: [{
|
|
133
|
-
type: string;
|
|
134
|
-
name: string;
|
|
135
|
-
internalType: string;
|
|
136
|
-
}, ...{
|
|
137
|
-
type: string;
|
|
138
|
-
name: string;
|
|
139
|
-
internalType: string;
|
|
140
|
-
}[]];
|
|
141
|
-
stateMutability: "view" | "pure";
|
|
142
|
-
}>;
|
|
143
|
-
export type FunctionAbiProps = z.infer<typeof functionAbiSchema>;
|
|
144
|
-
export declare const ContractConditionType = "contract";
|
|
145
|
-
export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<{
|
|
146
|
-
conditionType: z.ZodDefault<z.ZodLiteral<"rpc">>;
|
|
147
|
-
chain: z.ZodNever | z.ZodLiteral<z.Primitive> | z.ZodUnion<[z.ZodLiteral<z.Primitive>, z.ZodLiteral<z.Primitive>, ...z.ZodLiteral<z.Primitive>[]]>;
|
|
148
|
-
method: z.ZodEnum<["eth_getBalance"]>;
|
|
149
|
-
parameters: z.ZodUnion<[z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEnum<[":userAddress", ":userAddressExternalEIP4361"]>]>, "atleastone">, z.ZodTuple<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEnum<[":userAddress", ":userAddressExternalEIP4361"]>]>, z.ZodType<any, z.ZodTypeDef, any>], null>]>;
|
|
150
|
-
returnValueTest: z.ZodObject<{
|
|
151
|
-
index: z.ZodOptional<z.ZodNumber>;
|
|
152
|
-
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
153
|
-
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
154
|
-
}, "strip", z.ZodTypeAny, {
|
|
155
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
156
|
-
value?: any;
|
|
157
|
-
index?: number | undefined;
|
|
158
|
-
}, {
|
|
159
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
160
|
-
value?: any;
|
|
161
|
-
index?: number | undefined;
|
|
162
|
-
}>;
|
|
163
|
-
}, {
|
|
164
|
-
conditionType: z.ZodDefault<z.ZodLiteral<"contract">>;
|
|
165
|
-
contractAddress: z.ZodString;
|
|
166
|
-
standardContractType: z.ZodOptional<z.ZodEnum<["ERC20", "ERC721"]>>;
|
|
167
|
-
method: z.ZodString;
|
|
168
|
-
functionAbi: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
169
|
-
name: z.ZodString;
|
|
170
|
-
type: z.ZodLiteral<"function">;
|
|
171
|
-
inputs: z.ZodArray<z.ZodObject<{
|
|
172
|
-
name: z.ZodString;
|
|
173
|
-
type: z.ZodEnum<[string, ...string[]]>;
|
|
174
|
-
internalType: z.ZodEnum<[string, ...string[]]>;
|
|
175
|
-
}, "strict", z.ZodTypeAny, {
|
|
176
|
-
type: string;
|
|
177
|
-
name: string;
|
|
178
|
-
internalType: string;
|
|
179
|
-
}, {
|
|
180
|
-
type: string;
|
|
181
|
-
name: string;
|
|
182
|
-
internalType: string;
|
|
183
|
-
}>, "many">;
|
|
184
|
-
outputs: z.ZodArray<z.ZodObject<{
|
|
185
|
-
name: z.ZodString;
|
|
186
|
-
type: z.ZodEnum<[string, ...string[]]>;
|
|
187
|
-
internalType: z.ZodEnum<[string, ...string[]]>;
|
|
188
|
-
}, "strict", z.ZodTypeAny, {
|
|
189
|
-
type: string;
|
|
190
|
-
name: string;
|
|
191
|
-
internalType: string;
|
|
192
|
-
}, {
|
|
193
|
-
type: string;
|
|
194
|
-
name: string;
|
|
195
|
-
internalType: string;
|
|
196
|
-
}>, "atleastone">;
|
|
197
|
-
stateMutability: z.ZodUnion<[z.ZodLiteral<"view">, z.ZodLiteral<"pure">]>;
|
|
198
|
-
}, "strict", z.ZodTypeAny, {
|
|
199
|
-
type: "function";
|
|
200
|
-
name: string;
|
|
201
|
-
inputs: {
|
|
202
|
-
type: string;
|
|
203
|
-
name: string;
|
|
204
|
-
internalType: string;
|
|
205
|
-
}[];
|
|
206
|
-
outputs: [{
|
|
207
|
-
type: string;
|
|
208
|
-
name: string;
|
|
209
|
-
internalType: string;
|
|
210
|
-
}, ...{
|
|
211
|
-
type: string;
|
|
212
|
-
name: string;
|
|
213
|
-
internalType: string;
|
|
214
|
-
}[]];
|
|
215
|
-
stateMutability: "view" | "pure";
|
|
216
|
-
}, {
|
|
217
|
-
type: "function";
|
|
218
|
-
name: string;
|
|
219
|
-
inputs: {
|
|
220
|
-
type: string;
|
|
221
|
-
name: string;
|
|
222
|
-
internalType: string;
|
|
223
|
-
}[];
|
|
224
|
-
outputs: [{
|
|
225
|
-
type: string;
|
|
226
|
-
name: string;
|
|
227
|
-
internalType: string;
|
|
228
|
-
}, ...{
|
|
229
|
-
type: string;
|
|
230
|
-
name: string;
|
|
231
|
-
internalType: string;
|
|
232
|
-
}[]];
|
|
233
|
-
stateMutability: "view" | "pure";
|
|
234
|
-
}>, {
|
|
235
|
-
type: "function";
|
|
236
|
-
name: string;
|
|
237
|
-
inputs: {
|
|
238
|
-
type: string;
|
|
239
|
-
name: string;
|
|
240
|
-
internalType: string;
|
|
241
|
-
}[];
|
|
242
|
-
outputs: [{
|
|
243
|
-
type: string;
|
|
244
|
-
name: string;
|
|
245
|
-
internalType: string;
|
|
246
|
-
}, ...{
|
|
247
|
-
type: string;
|
|
248
|
-
name: string;
|
|
249
|
-
internalType: string;
|
|
250
|
-
}[]];
|
|
251
|
-
stateMutability: "view" | "pure";
|
|
252
|
-
}, {
|
|
253
|
-
type: "function";
|
|
254
|
-
name: string;
|
|
255
|
-
inputs: {
|
|
256
|
-
type: string;
|
|
257
|
-
name: string;
|
|
258
|
-
internalType: string;
|
|
259
|
-
}[];
|
|
260
|
-
outputs: [{
|
|
261
|
-
type: string;
|
|
262
|
-
name: string;
|
|
263
|
-
internalType: string;
|
|
264
|
-
}, ...{
|
|
265
|
-
type: string;
|
|
266
|
-
name: string;
|
|
267
|
-
internalType: string;
|
|
268
|
-
}[]];
|
|
269
|
-
stateMutability: "view" | "pure";
|
|
270
|
-
}>, {
|
|
271
|
-
type: "function";
|
|
272
|
-
name: string;
|
|
273
|
-
inputs: {
|
|
274
|
-
type: string;
|
|
275
|
-
name: string;
|
|
276
|
-
internalType: string;
|
|
277
|
-
}[];
|
|
278
|
-
outputs: [{
|
|
279
|
-
type: string;
|
|
280
|
-
name: string;
|
|
281
|
-
internalType: string;
|
|
282
|
-
}, ...{
|
|
283
|
-
type: string;
|
|
284
|
-
name: string;
|
|
285
|
-
internalType: string;
|
|
286
|
-
}[]];
|
|
287
|
-
stateMutability: "view" | "pure";
|
|
288
|
-
}, {
|
|
289
|
-
type: "function";
|
|
290
|
-
name: string;
|
|
291
|
-
inputs: {
|
|
292
|
-
type: string;
|
|
293
|
-
name: string;
|
|
294
|
-
internalType: string;
|
|
295
|
-
}[];
|
|
296
|
-
outputs: [{
|
|
297
|
-
type: string;
|
|
298
|
-
name: string;
|
|
299
|
-
internalType: string;
|
|
300
|
-
}, ...{
|
|
301
|
-
type: string;
|
|
302
|
-
name: string;
|
|
303
|
-
internalType: string;
|
|
304
|
-
}[]];
|
|
305
|
-
stateMutability: "view" | "pure";
|
|
306
|
-
}>>;
|
|
307
|
-
parameters: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
|
|
308
|
-
}>, "strip", z.ZodTypeAny, {
|
|
309
|
-
conditionType: "contract";
|
|
310
|
-
method: string;
|
|
311
|
-
parameters: any[];
|
|
312
|
-
returnValueTest: {
|
|
313
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
314
|
-
value?: any;
|
|
315
|
-
index?: number | undefined;
|
|
316
|
-
};
|
|
317
|
-
contractAddress: string;
|
|
318
|
-
chain?: z.Primitive;
|
|
319
|
-
functionAbi?: {
|
|
320
|
-
type: "function";
|
|
321
|
-
name: string;
|
|
322
|
-
inputs: {
|
|
323
|
-
type: string;
|
|
324
|
-
name: string;
|
|
325
|
-
internalType: string;
|
|
326
|
-
}[];
|
|
327
|
-
outputs: [{
|
|
328
|
-
type: string;
|
|
329
|
-
name: string;
|
|
330
|
-
internalType: string;
|
|
331
|
-
}, ...{
|
|
332
|
-
type: string;
|
|
333
|
-
name: string;
|
|
334
|
-
internalType: string;
|
|
335
|
-
}[]];
|
|
336
|
-
stateMutability: "view" | "pure";
|
|
337
|
-
} | undefined;
|
|
338
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
339
|
-
}, {
|
|
340
|
-
method: string;
|
|
341
|
-
parameters: any[];
|
|
342
|
-
returnValueTest: {
|
|
343
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
344
|
-
value?: any;
|
|
345
|
-
index?: number | undefined;
|
|
346
|
-
};
|
|
347
|
-
contractAddress: string;
|
|
348
|
-
conditionType?: "contract" | undefined;
|
|
349
|
-
chain?: z.Primitive;
|
|
350
|
-
functionAbi?: {
|
|
351
|
-
type: "function";
|
|
352
|
-
name: string;
|
|
353
|
-
inputs: {
|
|
354
|
-
type: string;
|
|
355
|
-
name: string;
|
|
356
|
-
internalType: string;
|
|
357
|
-
}[];
|
|
358
|
-
outputs: [{
|
|
359
|
-
type: string;
|
|
360
|
-
name: string;
|
|
361
|
-
internalType: string;
|
|
362
|
-
}, ...{
|
|
363
|
-
type: string;
|
|
364
|
-
name: string;
|
|
365
|
-
internalType: string;
|
|
366
|
-
}[]];
|
|
367
|
-
stateMutability: "view" | "pure";
|
|
368
|
-
} | undefined;
|
|
369
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
370
|
-
}>, {
|
|
371
|
-
conditionType: "contract";
|
|
372
|
-
method: string;
|
|
373
|
-
parameters: any[];
|
|
374
|
-
returnValueTest: {
|
|
375
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
376
|
-
value?: any;
|
|
377
|
-
index?: number | undefined;
|
|
378
|
-
};
|
|
379
|
-
contractAddress: string;
|
|
380
|
-
chain?: z.Primitive;
|
|
381
|
-
functionAbi?: {
|
|
382
|
-
type: "function";
|
|
383
|
-
name: string;
|
|
384
|
-
inputs: {
|
|
385
|
-
type: string;
|
|
386
|
-
name: string;
|
|
387
|
-
internalType: string;
|
|
388
|
-
}[];
|
|
389
|
-
outputs: [{
|
|
390
|
-
type: string;
|
|
391
|
-
name: string;
|
|
392
|
-
internalType: string;
|
|
393
|
-
}, ...{
|
|
394
|
-
type: string;
|
|
395
|
-
name: string;
|
|
396
|
-
internalType: string;
|
|
397
|
-
}[]];
|
|
398
|
-
stateMutability: "view" | "pure";
|
|
399
|
-
} | undefined;
|
|
400
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
401
|
-
}, {
|
|
402
|
-
method: string;
|
|
403
|
-
parameters: any[];
|
|
404
|
-
returnValueTest: {
|
|
405
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
406
|
-
value?: any;
|
|
407
|
-
index?: number | undefined;
|
|
408
|
-
};
|
|
409
|
-
contractAddress: string;
|
|
410
|
-
conditionType?: "contract" | undefined;
|
|
411
|
-
chain?: z.Primitive;
|
|
412
|
-
functionAbi?: {
|
|
413
|
-
type: "function";
|
|
414
|
-
name: string;
|
|
415
|
-
inputs: {
|
|
416
|
-
type: string;
|
|
417
|
-
name: string;
|
|
418
|
-
internalType: string;
|
|
419
|
-
}[];
|
|
420
|
-
outputs: [{
|
|
421
|
-
type: string;
|
|
422
|
-
name: string;
|
|
423
|
-
internalType: string;
|
|
424
|
-
}, ...{
|
|
425
|
-
type: string;
|
|
426
|
-
name: string;
|
|
427
|
-
internalType: string;
|
|
428
|
-
}[]];
|
|
429
|
-
stateMutability: "view" | "pure";
|
|
430
|
-
} | undefined;
|
|
431
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
432
|
-
}>;
|
|
433
|
-
export type ContractConditionProps = z.infer<typeof contractConditionSchema>;
|
|
4
|
+
export { ContractConditionProps, contractConditionSchema, ContractConditionType, FunctionAbiProps, } from '../schemas/contract';
|
|
434
5
|
export declare class ContractCondition extends Condition {
|
|
435
6
|
constructor(value: OmitConditionType<ContractConditionProps>);
|
|
436
7
|
}
|
|
437
|
-
export {};
|
|
@@ -1,81 +1,6 @@
|
|
|
1
|
-
import { ETH_ADDRESS_REGEXP } from '@nucypher/shared';
|
|
2
|
-
import { ethers } from 'ethers';
|
|
3
|
-
import { z } from 'zod';
|
|
4
1
|
import { Condition } from '../condition';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
// TODO: Consider replacing with `z.unknown`:
|
|
8
|
-
// Since Solidity types are tied to Solidity version, we may not be able to accurately represent them in Zod.
|
|
9
|
-
// Alternatively, find a TS Solidity type lib.
|
|
10
|
-
const EthBaseTypes = [
|
|
11
|
-
'bool',
|
|
12
|
-
'string',
|
|
13
|
-
'address',
|
|
14
|
-
'address payable',
|
|
15
|
-
...Array.from({ length: 32 }, (_v, i) => `bytes${i + 1}`), // bytes1 through bytes32
|
|
16
|
-
'bytes',
|
|
17
|
-
...Array.from({ length: 32 }, (_v, i) => `uint${8 * (i + 1)}`), // uint8 through uint256
|
|
18
|
-
...Array.from({ length: 32 }, (_v, i) => `int${8 * (i + 1)}`), // int8 through int256
|
|
19
|
-
];
|
|
20
|
-
const functionAbiVariableSchema = z
|
|
21
|
-
.object({
|
|
22
|
-
name: z.string(),
|
|
23
|
-
type: z.enum(EthBaseTypes),
|
|
24
|
-
internalType: z.enum(EthBaseTypes), // TODO: Do we need to validate this?
|
|
25
|
-
})
|
|
26
|
-
.strict();
|
|
27
|
-
const functionAbiSchema = z
|
|
28
|
-
.object({
|
|
29
|
-
name: z.string(),
|
|
30
|
-
type: z.literal('function'),
|
|
31
|
-
inputs: z.array(functionAbiVariableSchema).min(0),
|
|
32
|
-
outputs: z.array(functionAbiVariableSchema).nonempty(),
|
|
33
|
-
stateMutability: z.union([z.literal('view'), z.literal('pure')]),
|
|
34
|
-
})
|
|
35
|
-
.strict()
|
|
36
|
-
.refine((functionAbi) => {
|
|
37
|
-
let asInterface;
|
|
38
|
-
try {
|
|
39
|
-
// `stringify` here because ethers.utils.Interface doesn't accept a Zod schema
|
|
40
|
-
asInterface = new ethers.utils.Interface(JSON.stringify([functionAbi]));
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
const functionsInAbi = Object.values(asInterface.functions || {});
|
|
46
|
-
return functionsInAbi.length === 1;
|
|
47
|
-
}, {
|
|
48
|
-
message: '"functionAbi" must contain a single function definition',
|
|
49
|
-
path: ['functionAbi'],
|
|
50
|
-
})
|
|
51
|
-
.refine((functionAbi) => {
|
|
52
|
-
const asInterface = new ethers.utils.Interface(JSON.stringify([functionAbi]));
|
|
53
|
-
const nrOfInputs = asInterface.fragments[0].inputs.length;
|
|
54
|
-
return functionAbi.inputs.length === nrOfInputs;
|
|
55
|
-
}, {
|
|
56
|
-
message: '"parameters" must have the same length as "functionAbi.inputs"',
|
|
57
|
-
path: ['parameters'],
|
|
58
|
-
});
|
|
59
|
-
export const ContractConditionType = 'contract';
|
|
60
|
-
export const contractConditionSchema = rpcConditionSchema
|
|
61
|
-
.extend({
|
|
62
|
-
conditionType: z
|
|
63
|
-
.literal(ContractConditionType)
|
|
64
|
-
.default(ContractConditionType),
|
|
65
|
-
contractAddress: z.string().regex(ETH_ADDRESS_REGEXP).length(42),
|
|
66
|
-
standardContractType: z.enum(['ERC20', 'ERC721']).optional(),
|
|
67
|
-
method: z.string(),
|
|
68
|
-
functionAbi: functionAbiSchema.optional(),
|
|
69
|
-
parameters: z.array(paramOrContextParamSchema),
|
|
70
|
-
})
|
|
71
|
-
// Adding this custom logic causes the return type to be ZodEffects instead of ZodObject
|
|
72
|
-
// https://github.com/colinhacks/zod/issues/2474
|
|
73
|
-
.refine(
|
|
74
|
-
// A check to see if either 'standardContractType' or 'functionAbi' is set
|
|
75
|
-
(data) => Boolean(data.standardContractType) !== Boolean(data.functionAbi), {
|
|
76
|
-
message: "At most one of the fields 'standardContractType' and 'functionAbi' must be defined",
|
|
77
|
-
path: ['standardContractType'],
|
|
78
|
-
});
|
|
2
|
+
import { contractConditionSchema, ContractConditionType, } from '../schemas/contract';
|
|
3
|
+
export { contractConditionSchema, ContractConditionType, } from '../schemas/contract';
|
|
79
4
|
export class ContractCondition extends Condition {
|
|
80
5
|
constructor(value) {
|
|
81
6
|
super(contractConditionSchema, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../../src/conditions/base/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../../src/conditions/base/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAEL,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAEL,uBAAuB,EACvB,qBAAqB,GAEtB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C,YAAY,KAAgD;QAC1D,KAAK,CAAC,uBAAuB,EAAE;YAC7B,aAAa,EAAE,qBAAqB;YACpC,GAAG,KAAK;SACT,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Exporting classes here instead of their respective schema files to
|
|
2
2
|
// avoid circular dependency on Condition class.
|
|
3
3
|
export * as contract from './contract';
|
|
4
|
+
export * as jsonApi from './json-api';
|
|
4
5
|
export * as rpc from './rpc';
|
|
5
6
|
export * as time from './time';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/conditions/base/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,gDAAgD;AAEhD,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/conditions/base/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,gDAAgD;AAEhD,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Condition } from '../condition';
|
|
2
|
+
import { JsonApiConditionProps } from '../schemas/json-api';
|
|
3
|
+
import { OmitConditionType } from '../shared';
|
|
4
|
+
export { JsonApiConditionProps, jsonApiConditionSchema, JsonApiConditionType, jsonPathSchema, } from '../schemas/json-api';
|
|
5
|
+
export declare class JsonApiCondition extends Condition {
|
|
6
|
+
constructor(value: OmitConditionType<JsonApiConditionProps>);
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Condition } from '../condition';
|
|
2
|
+
import { jsonApiConditionSchema, JsonApiConditionType, } from '../schemas/json-api';
|
|
3
|
+
export { jsonApiConditionSchema, JsonApiConditionType, jsonPathSchema, } from '../schemas/json-api';
|
|
4
|
+
export class JsonApiCondition extends Condition {
|
|
5
|
+
constructor(value) {
|
|
6
|
+
super(jsonApiConditionSchema, {
|
|
7
|
+
conditionType: JsonApiConditionType,
|
|
8
|
+
...value,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=json-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-api.js","sourceRoot":"","sources":["../../../../src/conditions/base/json-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAEL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAEL,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAC7C,YAAY,KAA+C;QACzD,KAAK,CAAC,sBAAsB,EAAE;YAC5B,aAAa,EAAE,oBAAoB;YACnC,GAAG,KAAK;SACT,CAAC,CAAC;IACL,CAAC;CACF"}
|