@nucypher/taco 0.3.0 → 0.5.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 +14 -18
- package/dist/cjs/conditions/base/contract.js +6 -6
- package/dist/cjs/conditions/base/contract.js.map +1 -1
- package/dist/cjs/conditions/base/rpc.d.ts +7 -7
- package/dist/cjs/conditions/base/time.d.ts +5 -5
- package/dist/cjs/conditions/compound-condition.js.map +1 -1
- package/dist/cjs/conditions/condition-expr.d.ts +3 -7
- package/dist/cjs/conditions/condition-expr.js +2 -9
- package/dist/cjs/conditions/condition-expr.js.map +1 -1
- package/dist/cjs/conditions/condition-factory.js.map +1 -1
- package/dist/cjs/conditions/condition.d.ts +3 -2
- package/dist/cjs/conditions/condition.js +12 -2
- package/dist/cjs/conditions/condition.js.map +1 -1
- package/dist/cjs/conditions/const.d.ts +1 -3
- package/dist/cjs/conditions/const.js +7 -4
- package/dist/cjs/conditions/const.js.map +1 -1
- package/dist/cjs/conditions/context/context.d.ts +21 -17
- package/dist/cjs/conditions/context/context.js +107 -70
- package/dist/cjs/conditions/context/context.js.map +1 -1
- package/dist/cjs/conditions/predefined/erc20.js +2 -2
- package/dist/cjs/conditions/predefined/erc20.js.map +1 -1
- package/dist/cjs/conditions/predefined/erc721.js +3 -3
- package/dist/cjs/conditions/predefined/erc721.js.map +1 -1
- package/dist/cjs/conditions/shared.d.ts +3 -3
- package/dist/cjs/conditions/shared.js +8 -4
- package/dist/cjs/conditions/shared.js.map +1 -1
- package/dist/cjs/conditions/zod.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 -2
- package/dist/cjs/index.js +2 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/taco.d.ts +5 -22
- package/dist/cjs/taco.js +10 -31
- package/dist/cjs/taco.js.map +1 -1
- package/dist/cjs/tdec.d.ts +3 -3
- package/dist/cjs/tdec.js +16 -12
- package/dist/cjs/tdec.js.map +1 -1
- package/dist/cjs/types.d.ts +1 -0
- package/dist/cjs/types.js +8 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/es/conditions/base/contract.d.ts +14 -18
- package/dist/es/conditions/base/contract.js +3 -3
- package/dist/es/conditions/base/contract.js.map +1 -1
- package/dist/es/conditions/base/rpc.d.ts +7 -7
- package/dist/es/conditions/base/time.d.ts +5 -5
- package/dist/es/conditions/compound-condition.js.map +1 -1
- package/dist/es/conditions/condition-expr.d.ts +3 -7
- package/dist/es/conditions/condition-expr.js +4 -11
- package/dist/es/conditions/condition-expr.js.map +1 -1
- package/dist/es/conditions/condition-factory.js.map +1 -1
- package/dist/es/conditions/condition.d.ts +3 -2
- package/dist/es/conditions/condition.js +13 -3
- package/dist/es/conditions/condition.js.map +1 -1
- package/dist/es/conditions/const.d.ts +1 -3
- package/dist/es/conditions/const.js +6 -3
- package/dist/es/conditions/const.js.map +1 -1
- package/dist/es/conditions/context/context.d.ts +21 -17
- package/dist/es/conditions/context/context.js +108 -71
- package/dist/es/conditions/context/context.js.map +1 -1
- package/dist/es/conditions/predefined/erc20.js +2 -2
- package/dist/es/conditions/predefined/erc20.js.map +1 -1
- package/dist/es/conditions/predefined/erc721.js +3 -3
- package/dist/es/conditions/predefined/erc721.js.map +1 -1
- package/dist/es/conditions/shared.d.ts +3 -3
- package/dist/es/conditions/shared.js +8 -4
- package/dist/es/conditions/shared.js.map +1 -1
- package/dist/es/conditions/zod.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 -2
- package/dist/es/index.js +2 -3
- package/dist/es/index.js.map +1 -1
- package/dist/es/taco.d.ts +5 -22
- package/dist/es/taco.js +10 -29
- package/dist/es/taco.js.map +1 -1
- package/dist/es/tdec.d.ts +3 -3
- package/dist/es/tdec.js +17 -13
- package/dist/es/tdec.js.map +1 -1
- package/dist/es/types.d.ts +1 -0
- package/dist/es/types.js +3 -0
- package/dist/es/types.js.map +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.es.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/dist/cjs/conditions/context/providers.d.ts +0 -16
- package/dist/cjs/conditions/context/providers.js +0 -111
- package/dist/cjs/conditions/context/providers.js.map +0 -1
- package/dist/cjs/web3.d.ts +0 -33
- package/dist/cjs/web3.js +0 -3
- package/dist/cjs/web3.js.map +0 -1
- package/dist/es/conditions/context/providers.d.ts +0 -16
- package/dist/es/conditions/context/providers.js +0 -107
- package/dist/es/conditions/context/providers.js.map +0 -1
- package/dist/es/web3.d.ts +0 -33
- package/dist/es/web3.js +0 -2
- package/dist/es/web3.js.map +0 -1
package/README.md
CHANGED
|
@@ -142,25 +142,21 @@ declare const functionAbiSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
142
142
|
}>;
|
|
143
143
|
export type FunctionAbiProps = z.infer<typeof functionAbiSchema>;
|
|
144
144
|
export declare const ContractConditionType = "contract";
|
|
145
|
-
export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<
|
|
146
|
-
conditionType: z.ZodDefault<z.ZodLiteral<"rpc">>;
|
|
145
|
+
export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<{
|
|
147
146
|
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.ZodString, z.ZodLiteral<":userAddress">]>, "atleastone">, z.ZodTuple<[z.ZodUnion<[z.ZodString, z.ZodLiteral<":userAddress">]>, z.ZodType<any, z.ZodTypeDef, any>], null>]>;
|
|
150
147
|
returnValueTest: z.ZodObject<{
|
|
151
148
|
index: z.ZodOptional<z.ZodNumber>;
|
|
152
149
|
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
153
150
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
154
151
|
}, "strip", z.ZodTypeAny, {
|
|
155
152
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
156
|
-
value?: any;
|
|
157
153
|
index?: number | undefined;
|
|
154
|
+
value?: any;
|
|
158
155
|
}, {
|
|
159
156
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
160
|
-
value?: any;
|
|
161
157
|
index?: number | undefined;
|
|
158
|
+
value?: any;
|
|
162
159
|
}>;
|
|
163
|
-
}, {
|
|
164
160
|
conditionType: z.ZodDefault<z.ZodLiteral<"contract">>;
|
|
165
161
|
contractAddress: z.ZodString;
|
|
166
162
|
standardContractType: z.ZodOptional<z.ZodEnum<["ERC20", "ERC721"]>>;
|
|
@@ -305,17 +301,18 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<z.objectU
|
|
|
305
301
|
stateMutability: "view" | "pure";
|
|
306
302
|
}>>;
|
|
307
303
|
parameters: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
|
|
308
|
-
}
|
|
304
|
+
}, "strip", z.ZodTypeAny, {
|
|
309
305
|
conditionType: "contract";
|
|
310
306
|
method: string;
|
|
311
307
|
parameters: any[];
|
|
312
308
|
returnValueTest: {
|
|
313
309
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
314
|
-
value?: any;
|
|
315
310
|
index?: number | undefined;
|
|
311
|
+
value?: any;
|
|
316
312
|
};
|
|
317
313
|
contractAddress: string;
|
|
318
314
|
chain?: z.Primitive;
|
|
315
|
+
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
319
316
|
functionAbi?: {
|
|
320
317
|
type: "function";
|
|
321
318
|
name: string;
|
|
@@ -335,18 +332,18 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<z.objectU
|
|
|
335
332
|
}[]];
|
|
336
333
|
stateMutability: "view" | "pure";
|
|
337
334
|
} | undefined;
|
|
338
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
339
335
|
}, {
|
|
340
336
|
method: string;
|
|
341
337
|
parameters: any[];
|
|
342
338
|
returnValueTest: {
|
|
343
339
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
344
|
-
value?: any;
|
|
345
340
|
index?: number | undefined;
|
|
341
|
+
value?: any;
|
|
346
342
|
};
|
|
347
343
|
contractAddress: string;
|
|
348
|
-
conditionType?: "contract" | undefined;
|
|
349
344
|
chain?: z.Primitive;
|
|
345
|
+
conditionType?: "contract" | undefined;
|
|
346
|
+
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
350
347
|
functionAbi?: {
|
|
351
348
|
type: "function";
|
|
352
349
|
name: string;
|
|
@@ -366,18 +363,18 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<z.objectU
|
|
|
366
363
|
}[]];
|
|
367
364
|
stateMutability: "view" | "pure";
|
|
368
365
|
} | undefined;
|
|
369
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
370
366
|
}>, {
|
|
371
367
|
conditionType: "contract";
|
|
372
368
|
method: string;
|
|
373
369
|
parameters: any[];
|
|
374
370
|
returnValueTest: {
|
|
375
371
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
376
|
-
value?: any;
|
|
377
372
|
index?: number | undefined;
|
|
373
|
+
value?: any;
|
|
378
374
|
};
|
|
379
375
|
contractAddress: string;
|
|
380
376
|
chain?: z.Primitive;
|
|
377
|
+
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
381
378
|
functionAbi?: {
|
|
382
379
|
type: "function";
|
|
383
380
|
name: string;
|
|
@@ -397,18 +394,18 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<z.objectU
|
|
|
397
394
|
}[]];
|
|
398
395
|
stateMutability: "view" | "pure";
|
|
399
396
|
} | undefined;
|
|
400
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
401
397
|
}, {
|
|
402
398
|
method: string;
|
|
403
399
|
parameters: any[];
|
|
404
400
|
returnValueTest: {
|
|
405
401
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
406
|
-
value?: any;
|
|
407
402
|
index?: number | undefined;
|
|
403
|
+
value?: any;
|
|
408
404
|
};
|
|
409
405
|
contractAddress: string;
|
|
410
|
-
conditionType?: "contract" | undefined;
|
|
411
406
|
chain?: z.Primitive;
|
|
407
|
+
conditionType?: "contract" | undefined;
|
|
408
|
+
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
412
409
|
functionAbi?: {
|
|
413
410
|
type: "function";
|
|
414
411
|
name: string;
|
|
@@ -428,7 +425,6 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<z.objectU
|
|
|
428
425
|
}[]];
|
|
429
426
|
stateMutability: "view" | "pure";
|
|
430
427
|
} | undefined;
|
|
431
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
432
428
|
}>;
|
|
433
429
|
export type ContractConditionProps = z.infer<typeof contractConditionSchema>;
|
|
434
430
|
export declare class ContractCondition extends Condition {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContractCondition = exports.contractConditionSchema = exports.ContractConditionType = void 0;
|
|
4
|
+
const shared_1 = require("@nucypher/shared");
|
|
4
5
|
const ethers_1 = require("ethers");
|
|
5
6
|
const zod_1 = require("zod");
|
|
6
7
|
const condition_1 = require("../condition");
|
|
7
|
-
const
|
|
8
|
-
const shared_1 = require("../shared");
|
|
8
|
+
const shared_2 = require("../shared");
|
|
9
9
|
const rpc_1 = require("./rpc");
|
|
10
10
|
// TODO: Consider replacing with `z.unknown`:
|
|
11
11
|
// Since Solidity types are tied to Solidity version, we may not be able to accurately represent them in Zod.
|
|
@@ -15,9 +15,9 @@ const EthBaseTypes = [
|
|
|
15
15
|
'string',
|
|
16
16
|
'address',
|
|
17
17
|
'address payable',
|
|
18
|
-
...Array.from({ length: 32 }, (_v, i) => `bytes${i + 1}`),
|
|
18
|
+
...Array.from({ length: 32 }, (_v, i) => `bytes${i + 1}`), // bytes1 through bytes32
|
|
19
19
|
'bytes',
|
|
20
|
-
...Array.from({ length: 32 }, (_v, i) => `uint${8 * (i + 1)}`),
|
|
20
|
+
...Array.from({ length: 32 }, (_v, i) => `uint${8 * (i + 1)}`), // uint8 through uint256
|
|
21
21
|
...Array.from({ length: 32 }, (_v, i) => `int${8 * (i + 1)}`), // int8 through int256
|
|
22
22
|
];
|
|
23
23
|
const functionAbiVariableSchema = zod_1.z
|
|
@@ -65,11 +65,11 @@ exports.contractConditionSchema = rpc_1.rpcConditionSchema
|
|
|
65
65
|
conditionType: zod_1.z
|
|
66
66
|
.literal(exports.ContractConditionType)
|
|
67
67
|
.default(exports.ContractConditionType),
|
|
68
|
-
contractAddress: zod_1.z.string().regex(
|
|
68
|
+
contractAddress: zod_1.z.string().regex(shared_1.ETH_ADDRESS_REGEXP).length(42),
|
|
69
69
|
standardContractType: zod_1.z.enum(['ERC20', 'ERC721']).optional(),
|
|
70
70
|
method: zod_1.z.string(),
|
|
71
71
|
functionAbi: functionAbiSchema.optional(),
|
|
72
|
-
parameters: zod_1.z.array(
|
|
72
|
+
parameters: zod_1.z.array(shared_2.paramOrContextParamSchema),
|
|
73
73
|
})
|
|
74
74
|
// Adding this custom logic causes the return type to be ZodEffects instead of ZodObject
|
|
75
75
|
// https://github.com/colinhacks/zod/issues/2474
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../../src/conditions/base/contract.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAChC,6BAAwB;AAExB,4CAAyC;AACzC,
|
|
1
|
+
{"version":3,"file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AAC,YAAY,CAAC;CACrB,CACF,CAAC;AAIS,QAAA,qBAAqB,GAAG,UAAU,CAAC;AAEnC,QAAA,uBAAuB,GAAG,wBAAkB;KACtD,MAAM,CAAC;IACN,aAAa,EAAE,OAAC;SACb,OAAO,CAAC,6BAAqB,CAAC;SAC9B,OAAO,CAAC,6BAAqB,CAAC;IACjC,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,2BAAkB,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IAChE,oBAAoB,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC5D,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;IAClB,WAAW,EAAE,iBAAiB,CAAC,QAAQ,EAAE;IACzC,UAAU,EAAE,OAAC,CAAC,KAAK,CAAC,kCAAyB,CAAC;CAC/C,CAAC;IACF,wFAAwF;IACxF,gDAAgD;KAC/C,MAAM;AACL,0EAA0E;AAC1E,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,EAC1E;IACE,OAAO,EACL,oFAAoF;IACtF,IAAI,EAAE,CAAC,sBAAsB,CAAC;CAC/B,CACF,CAAC;AAIJ,MAAa,iBAAkB,SAAQ,qBAAS;IAC9C,YAAY,KAAgD;QAC1D,KAAK,CAAC,+BAAuB,EAAE;YAC7B,aAAa,EAAE,6BAAqB;YACpC,GAAG,KAAK;SACT,CAAC,CAAC;IACL,CAAC;CACF;AAPD,8CAOC"}
|
|
@@ -6,37 +6,37 @@ export declare const rpcConditionSchema: z.ZodObject<{
|
|
|
6
6
|
conditionType: z.ZodDefault<z.ZodLiteral<"rpc">>;
|
|
7
7
|
chain: z.ZodNever | z.ZodLiteral<z.Primitive> | z.ZodUnion<[z.ZodLiteral<z.Primitive>, z.ZodLiteral<z.Primitive>, ...z.ZodLiteral<z.Primitive>[]]>;
|
|
8
8
|
method: z.ZodEnum<["eth_getBalance"]>;
|
|
9
|
-
parameters: z.ZodUnion<[z.ZodArray<z.ZodUnion<[z.ZodString, z.
|
|
9
|
+
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>]>;
|
|
10
10
|
returnValueTest: z.ZodObject<{
|
|
11
11
|
index: z.ZodOptional<z.ZodNumber>;
|
|
12
12
|
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
13
13
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
14
14
|
}, "strip", z.ZodTypeAny, {
|
|
15
15
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
16
|
-
value?: any;
|
|
17
16
|
index?: number | undefined;
|
|
17
|
+
value?: any;
|
|
18
18
|
}, {
|
|
19
19
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
20
|
-
value?: any;
|
|
21
20
|
index?: number | undefined;
|
|
21
|
+
value?: any;
|
|
22
22
|
}>;
|
|
23
23
|
}, "strip", z.ZodTypeAny, {
|
|
24
24
|
conditionType: "rpc";
|
|
25
25
|
method: "eth_getBalance";
|
|
26
|
-
parameters: [string, ...string[]] | [string, any];
|
|
26
|
+
parameters: ([string, ...string[]] | [string, any]) & ([string, ...string[]] | [string, any] | undefined);
|
|
27
27
|
returnValueTest: {
|
|
28
28
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
29
|
-
value?: any;
|
|
30
29
|
index?: number | undefined;
|
|
30
|
+
value?: any;
|
|
31
31
|
};
|
|
32
32
|
chain?: z.Primitive;
|
|
33
33
|
}, {
|
|
34
34
|
method: "eth_getBalance";
|
|
35
|
-
parameters: [string, ...string[]] | [string, any];
|
|
35
|
+
parameters: ([string, ...string[]] | [string, any]) & ([string, ...string[]] | [string, any] | undefined);
|
|
36
36
|
returnValueTest: {
|
|
37
37
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
38
|
-
value?: any;
|
|
39
38
|
index?: number | undefined;
|
|
39
|
+
value?: any;
|
|
40
40
|
};
|
|
41
41
|
conditionType?: "rpc" | undefined;
|
|
42
42
|
chain?: z.Primitive;
|
|
@@ -13,31 +13,31 @@ export declare const timeConditionSchema: z.ZodObject<{
|
|
|
13
13
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
14
14
|
}, "strip", z.ZodTypeAny, {
|
|
15
15
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
16
|
-
value?: any;
|
|
17
16
|
index?: number | undefined;
|
|
17
|
+
value?: any;
|
|
18
18
|
}, {
|
|
19
19
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
20
|
-
value?: any;
|
|
21
20
|
index?: number | undefined;
|
|
21
|
+
value?: any;
|
|
22
22
|
}>;
|
|
23
23
|
}, "strip", z.ZodTypeAny, {
|
|
24
24
|
conditionType: "time";
|
|
25
25
|
method: "blocktime";
|
|
26
26
|
returnValueTest: {
|
|
27
27
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
28
|
-
value?: any;
|
|
29
28
|
index?: number | undefined;
|
|
29
|
+
value?: any;
|
|
30
30
|
};
|
|
31
31
|
chain?: z.Primitive;
|
|
32
32
|
}, {
|
|
33
33
|
returnValueTest: {
|
|
34
34
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
35
|
-
value?: any;
|
|
36
35
|
index?: number | undefined;
|
|
36
|
+
value?: any;
|
|
37
37
|
};
|
|
38
38
|
conditionType?: "time" | undefined;
|
|
39
|
-
chain?: z.Primitive;
|
|
40
39
|
method?: "blocktime" | undefined;
|
|
40
|
+
chain?: z.Primitive;
|
|
41
41
|
}>;
|
|
42
42
|
export type TimeConditionProps = z.infer<typeof timeConditionSchema>;
|
|
43
43
|
export declare class TimeCondition extends Condition {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compound-condition.js","sourceRoot":"","sources":["../../../src/conditions/compound-condition.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,8CAA0D;AAC1D,oCAAgD;AAChD,sCAAkD;AAClD,2CAAwD;AAG3C,QAAA,qBAAqB,GAAG,UAAU,CAAC;AAEnC,QAAA,uBAAuB,GAAgB,OAAC;KAClD,MAAM,CAAC;IACN,aAAa,EAAE,OAAC;SACb,OAAO,CAAC,6BAAqB,CAAC;SAC9B,OAAO,CAAC,6BAAqB,CAAC;IACjC,QAAQ,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACtC,QAAQ,EAAE,OAAC;SACR,KAAK,CACJ,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACV,OAAC,CAAC,KAAK,CAAC;QACN,wBAAkB;QAClB,0BAAmB;QACnB,kCAAuB;QACvB,+BAAuB;KACxB,CAAC,CACH,CACF;SACA,GAAG,CAAC,CAAC,CAAC;CACV,CAAC;KACD,MAAM,CACL,CAAC,SAAS,EAAE,EAAE;IACZ,yDAAyD;IACzD,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"compound-condition.js","sourceRoot":"","sources":["../../../src/conditions/compound-condition.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,8CAA0D;AAC1D,oCAAgD;AAChD,sCAAkD;AAClD,2CAAwD;AAG3C,QAAA,qBAAqB,GAAG,UAAU,CAAC;AAEnC,QAAA,uBAAuB,GAAgB,OAAC;KAClD,MAAM,CAAC;IACN,aAAa,EAAE,OAAC;SAC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,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACzC,IAAI,OAAO,YAAY,qBAAS,EAAE,CAAC;gBACjC,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;YACzB,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,iBAAiB,CAAC;YAC3B,QAAQ;YACR,QAAQ,EAAE,SAAS;SACpB,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,UAA8B;QAC7C,OAAO,iBAAiB,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;IAEM,MAAM,CAAC,GAAG,CAAC,UAA8B;QAC9C,OAAO,iBAAiB,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;IAEM,MAAM,CAAC,GAAG,CAAC,SAA2B;QAC3C,OAAO,iBAAiB,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;CACF;AAnCD,8CAmCC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { Conditions as
|
|
2
|
-
import { ethers } from 'ethers';
|
|
1
|
+
import { Conditions as CoreConditions } from '@nucypher/nucypher-core';
|
|
3
2
|
import { Condition } from './condition';
|
|
4
|
-
import { ConditionContext, CustomContextParam } from './context';
|
|
5
3
|
export type ConditionExpressionJSON = {
|
|
6
4
|
version: string;
|
|
7
5
|
condition: Record<string, unknown>;
|
|
@@ -15,9 +13,7 @@ export declare class ConditionExpression {
|
|
|
15
13
|
static fromObj(obj: ConditionExpressionJSON): ConditionExpression;
|
|
16
14
|
toJson(): string;
|
|
17
15
|
static fromJSON(json: string): ConditionExpression;
|
|
18
|
-
|
|
19
|
-
static
|
|
20
|
-
buildContext(provider: ethers.providers.Provider, customParameters?: Record<string, CustomContextParam>, signer?: ethers.Signer): ConditionContext;
|
|
21
|
-
contextRequiresSigner(): boolean;
|
|
16
|
+
toCoreCondition(): CoreConditions;
|
|
17
|
+
static fromCoreConditions(conditions: CoreConditions): ConditionExpression;
|
|
22
18
|
equals(other: ConditionExpression): boolean;
|
|
23
19
|
}
|
|
@@ -5,7 +5,6 @@ const nucypher_core_1 = require("@nucypher/nucypher-core");
|
|
|
5
5
|
const shared_1 = require("@nucypher/shared");
|
|
6
6
|
const semver_1 = require("semver");
|
|
7
7
|
const condition_factory_1 = require("./condition-factory");
|
|
8
|
-
const context_1 = require("./context");
|
|
9
8
|
const ERR_VERSION = (provided, current) => `Version provided, ${provided}, is incompatible with current version, ${current}`;
|
|
10
9
|
const ERR_CONDITION = (condition) => `Invalid condition: unrecognized condition data ${JSON.stringify(condition)}`;
|
|
11
10
|
class ConditionExpression {
|
|
@@ -41,18 +40,12 @@ class ConditionExpression {
|
|
|
41
40
|
static fromJSON(json) {
|
|
42
41
|
return ConditionExpression.fromObj(JSON.parse(json));
|
|
43
42
|
}
|
|
44
|
-
|
|
43
|
+
toCoreCondition() {
|
|
45
44
|
return new nucypher_core_1.Conditions((0, shared_1.toJSON)(this.toObj()));
|
|
46
45
|
}
|
|
47
|
-
static
|
|
46
|
+
static fromCoreConditions(conditions) {
|
|
48
47
|
return ConditionExpression.fromJSON(conditions.toString());
|
|
49
48
|
}
|
|
50
|
-
buildContext(provider, customParameters = {}, signer) {
|
|
51
|
-
return new context_1.ConditionContext(provider, this.condition, customParameters, signer);
|
|
52
|
-
}
|
|
53
|
-
contextRequiresSigner() {
|
|
54
|
-
return this.condition.requiresSigner();
|
|
55
|
-
}
|
|
56
49
|
equals(other) {
|
|
57
50
|
return [
|
|
58
51
|
this.version === other.version,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition-expr.js","sourceRoot":"","sources":["../../../src/conditions/condition-expr.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AACvE,6CAA0C;
|
|
1
|
+
{"version":3,"file":"condition-expr.js","sourceRoot":"","sources":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BAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACrE,OAAO,IAAI,mBAAmB,CAAC,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IAEM,MAAM;QACX,OAAO,IAAA,eAAM,EAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9B,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,IAAY;QACjC,OAAO,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;IAEM,eAAe;QACpB,OAAO,IAAI,0BAAc,CAAC,IAAA,eAAM,EAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IAEM,MAAM,CAAC,kBAAkB,CAAC,UAA0B;QACzD,OAAO,mBAAmB,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC7D,CAAC;IAEM,MAAM,CAAC,KAA0B;QACtC,OAAO;YACL,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO;YAC9B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;SACvC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;;AApDH,kDAqDC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition-factory.js","sourceRoot":"","sources":["../../../src/conditions/condition-factory.ts"],"names":[],"mappings":";;;AAAA,8CAIyB;AACzB,oCAA+E;AAC/E,sCAIqB;AACrB,6DAI8B;AAG9B,MAAM,0BAA0B,GAAG,CAAC,IAAY,EAAE,EAAE,CAClD,2BAA2B,IAAI,EAAE,CAAC;AAEpC,MAAa,gBAAgB;IACpB,MAAM,CAAC,kBAAkB,CAAC,KAAqB;QACpD,QAAQ,KAAK,CAAC,aAAa,EAAE;
|
|
1
|
+
{"version":3,"file":"condition-factory.js","sourceRoot":"","sources":["../../../src/conditions/condition-factory.ts"],"names":[],"mappings":";;;AAAA,8CAIyB;AACzB,oCAA+E;AAC/E,sCAIqB;AACrB,6DAI8B;AAG9B,MAAM,0BAA0B,GAAG,CAAC,IAAY,EAAE,EAAE,CAClD,2BAA2B,IAAI,EAAE,CAAC;AAEpC,MAAa,gBAAgB;IACpB,MAAM,CAAC,kBAAkB,CAAC,KAAqB;QACpD,QAAQ,KAAK,CAAC,aAAa,EAAE,CAAC;YAC5B,KAAK,sBAAgB;gBACnB,OAAO,IAAI,kBAAY,CAAC,KAA0B,CAAC,CAAC;YACtD,KAAK,wBAAiB;gBACpB,OAAO,IAAI,oBAAa,CAAC,KAA2B,CAAC,CAAC;YACxD,KAAK,gCAAqB;gBACxB,OAAO,IAAI,4BAAiB,CAAC,KAA+B,CAAC,CAAC;YAChE,KAAK,0CAAqB;gBACxB,OAAO,IAAI,sCAAiB,CAAC,KAA+B,CAAC,CAAC;YAChE;gBACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;CACF;AAfD,4CAeC"}
|
|
@@ -9,8 +9,9 @@ export declare class Condition {
|
|
|
9
9
|
data?: ConditionProps;
|
|
10
10
|
error?: z.ZodError;
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
findParamWithAuthentication(): string | null;
|
|
13
|
+
requiresAuthentication(): boolean;
|
|
14
|
+
toObj(): ConditionProps;
|
|
14
15
|
equals(other: Condition): boolean;
|
|
15
16
|
}
|
|
16
17
|
export {};
|
|
@@ -23,8 +23,18 @@ class Condition {
|
|
|
23
23
|
}
|
|
24
24
|
return { error: result.error };
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
// TODO: Fix this method and add a test for it
|
|
27
|
+
findParamWithAuthentication() {
|
|
28
|
+
const serialized = JSON.stringify(this.value);
|
|
29
|
+
for (const param of const_1.USER_ADDRESS_PARAMS) {
|
|
30
|
+
if (serialized.includes(param)) {
|
|
31
|
+
return param;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
requiresAuthentication() {
|
|
37
|
+
return Boolean(this.findParamWithAuthentication());
|
|
28
38
|
}
|
|
29
39
|
toObj() {
|
|
30
40
|
const { data, error } = Condition.validate(this.schema, this.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../src/conditions/condition.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAGhD,
|
|
1
|
+
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../src/conditions/condition.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAGhD,mCAA8C;AAK9C,MAAM,qBAAqB,GAAG,CAAC,KAAiB,EAAE,EAAE,CAClD,sBAAsB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;AAEvD,MAAa,SAAS;IAEF;IACA;IAFlB,YACkB,MAAuB,EACvB,KAAqB;QADrB,WAAM,GAAN,MAAM,CAAiB;QACvB,UAAK,GAAL,KAAK,CAAgB;QAErC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC1D,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAEM,MAAM,CAAC,QAAQ,CACpB,MAAuB,EACvB,KAAqB;QAKrB,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAED,8CAA8C;IACvC,2BAA2B;QAChC,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9C,KAAK,MAAM,KAAK,IAAI,2BAAmB,EAAE,CAAC;YACxC,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,sBAAsB;QAC3B,OAAO,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK;QACV,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACpE,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,KAAgB;QAC5B,OAAO,IAAA,qBAAY,EAAC,IAAI,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IACnD,CAAC;CACF;AApDD,8BAoDC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ChainId } from '@nucypher/shared';
|
|
2
|
-
export declare const USER_ADDRESS_PARAM = ":userAddress";
|
|
3
|
-
export declare const ETH_ADDRESS_REGEXP: RegExp;
|
|
4
2
|
export declare const CONTEXT_PARAM_REGEXP: RegExp;
|
|
5
3
|
export declare const CONTEXT_PARAM_PREFIX = ":";
|
|
6
4
|
export declare const SUPPORTED_CHAIN_IDS: ChainId[];
|
|
7
|
-
export declare const
|
|
5
|
+
export declare const USER_ADDRESS_PARAMS: string[];
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.USER_ADDRESS_PARAMS = exports.SUPPORTED_CHAIN_IDS = exports.CONTEXT_PARAM_PREFIX = exports.CONTEXT_PARAM_REGEXP = void 0;
|
|
4
4
|
const shared_1 = require("@nucypher/shared");
|
|
5
|
-
|
|
6
|
-
exports.ETH_ADDRESS_REGEXP = new RegExp('^0x[a-fA-F0-9]{40}$');
|
|
5
|
+
const taco_auth_1 = require("@nucypher/taco-auth");
|
|
7
6
|
// Only allow alphanumeric characters and underscores
|
|
8
7
|
exports.CONTEXT_PARAM_REGEXP = new RegExp('^:[a-zA-Z_][a-zA-Z0-9_]*$');
|
|
9
8
|
exports.CONTEXT_PARAM_PREFIX = ':';
|
|
@@ -13,5 +12,9 @@ exports.SUPPORTED_CHAIN_IDS = [
|
|
|
13
12
|
shared_1.ChainId.SEPOLIA,
|
|
14
13
|
shared_1.ChainId.ETHEREUM_MAINNET,
|
|
15
14
|
];
|
|
16
|
-
exports.
|
|
15
|
+
exports.USER_ADDRESS_PARAMS = [
|
|
16
|
+
taco_auth_1.USER_ADDRESS_PARAM_EXTERNAL_EIP4361,
|
|
17
|
+
// Ordering matters, this should always be last
|
|
18
|
+
taco_auth_1.USER_ADDRESS_PARAM_DEFAULT,
|
|
19
|
+
];
|
|
17
20
|
//# sourceMappingURL=const.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../src/conditions/const.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../src/conditions/const.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,mDAG6B;AAE7B,qDAAqD;AACxC,QAAA,oBAAoB,GAAG,IAAI,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAE/D,QAAA,oBAAoB,GAAG,GAAG,CAAC;AAE3B,QAAA,mBAAmB,GAAG;IACjC,gBAAO,CAAC,OAAO;IACf,gBAAO,CAAC,IAAI;IACZ,gBAAO,CAAC,OAAO;IACf,gBAAO,CAAC,gBAAgB;CACzB,CAAC;AAEW,QAAA,mBAAmB,GAAG;IACjC,+CAAmC;IACnC,+CAA+C;IAC/C,sCAA0B;CAC3B,CAAC"}
|
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ThresholdMessageKit } from '@nucypher/nucypher-core';
|
|
2
|
+
import { AuthProvider, AuthSignature } from '@nucypher/taco-auth';
|
|
3
|
+
import { CoreContext } from '../../types';
|
|
3
4
|
import { Condition } from '../condition';
|
|
4
|
-
import { TypedSignature } from './providers';
|
|
5
5
|
export type CustomContextParam = string | number | boolean;
|
|
6
|
-
export type ContextParam = CustomContextParam |
|
|
6
|
+
export type ContextParam = CustomContextParam | AuthSignature;
|
|
7
|
+
export declare const RESERVED_CONTEXT_PARAMS: string[];
|
|
7
8
|
export declare class ConditionContext {
|
|
8
|
-
|
|
9
|
-
private
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
private validate;
|
|
15
|
-
toObj: () => Promise<Record<string, ContextParam>>;
|
|
9
|
+
requestedContextParameters: Set<string>;
|
|
10
|
+
private customContextParameters;
|
|
11
|
+
private authProviders;
|
|
12
|
+
constructor(condition: Condition);
|
|
13
|
+
private static validateCoreConditions;
|
|
14
|
+
private validateNoMissingContextParameters;
|
|
16
15
|
private fillContextParameters;
|
|
17
|
-
private
|
|
18
|
-
private
|
|
16
|
+
private validateAuthProviders;
|
|
17
|
+
private fillAuthContextParameters;
|
|
18
|
+
private validateCustomContextParameter;
|
|
19
|
+
private static isContextParameter;
|
|
20
|
+
private static findContextParameters;
|
|
21
|
+
addCustomContextParameterValues(customContextParameters: Record<string, CustomContextParam>): void;
|
|
22
|
+
addAuthProvider(contextParam: string, authProvider: AuthProvider): void;
|
|
19
23
|
toJson(): Promise<string>;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
static
|
|
24
|
+
toCoreContext(): Promise<CoreContext>;
|
|
25
|
+
toContextParameters: () => Promise<Record<string, ContextParam>>;
|
|
26
|
+
static fromMessageKit(messageKit: ThresholdMessageKit): ConditionContext;
|
|
23
27
|
}
|