@prosopo/types 0.2.0 → 0.2.2

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.
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const common = require("@prosopo/common");
4
+ const z = require("zod");
5
+ const DatabaseTypes = z.z.enum(["mongo", "mongoMemory"]);
6
+ const EnvironmentTypesSchema = z.z.enum(["development", "rococo", "kusama", "polkadot", "shiden"]);
7
+ const NetworkNamesSchema = EnvironmentTypesSchema;
8
+ const DatabaseConfigSchema = z.z.record(
9
+ EnvironmentTypesSchema,
10
+ z.z.object({
11
+ type: z.z.string(),
12
+ endpoint: z.z.string(),
13
+ dbname: z.z.string(),
14
+ authSource: z.z.string()
15
+ })
16
+ ).optional();
17
+ const BatchCommitConfigSchema = z.z.object({
18
+ interval: z.z.number().positive(),
19
+ maxBatchExtrinsicPercentage: z.z.number().positive()
20
+ });
21
+ const ProsopoBaseConfigSchema = z.z.object({
22
+ logLevel: common.LogLevel,
23
+ defaultEnvironment: EnvironmentTypesSchema.default(EnvironmentTypesSchema.Values.development),
24
+ // The account with which to query the contract and sign transactions
25
+ account: z.z.object({
26
+ address: z.z.string(),
27
+ secret: z.z.string().optional(),
28
+ password: z.z.string().optional()
29
+ })
30
+ });
31
+ const NetworkConfigSchema = z.z.object({
32
+ endpoint: z.z.string().url(),
33
+ contract: z.z.object({
34
+ address: z.z.string(),
35
+ name: z.z.string()
36
+ }),
37
+ accounts: z.z.array(z.z.string()).optional()
38
+ });
39
+ const ProsopoNetworksSchema = z.z.record(NetworkNamesSchema, NetworkConfigSchema.required()).default({
40
+ development: {
41
+ endpoint: "ws://127.0.0.1:9944",
42
+ contract: {
43
+ address: "",
44
+ name: ""
45
+ },
46
+ accounts: []
47
+ }
48
+ });
49
+ const ProsopoBasicConfigSchema = ProsopoBaseConfigSchema.merge(
50
+ z.z.object({
51
+ networks: ProsopoNetworksSchema,
52
+ database: DatabaseConfigSchema.optional()
53
+ })
54
+ );
55
+ const ProsopoCaptchaCountConfigSchema = z.z.object({
56
+ solved: z.z.object({
57
+ count: z.z.number().positive()
58
+ }),
59
+ unsolved: z.z.object({
60
+ count: z.z.number().nonnegative()
61
+ })
62
+ });
63
+ const ProsopoImageServerConfigSchema = z.z.object({
64
+ baseURL: z.z.string().url(),
65
+ port: z.z.number().optional().default(9229)
66
+ });
67
+ const ProsopoCaptchaSolutionConfigSchema = z.z.object({
68
+ requiredNumberOfSolutions: z.z.number().positive().min(2),
69
+ solutionWinningPercentage: z.z.number().positive().max(100),
70
+ captchaFilePath: z.z.string(),
71
+ captchaBlockRecency: z.z.number().positive().min(2)
72
+ });
73
+ const ProsopoClientConfigSchema = ProsopoBasicConfigSchema.merge(
74
+ z.z.object({
75
+ userAccountAddress: z.z.string().optional(),
76
+ web2: z.z.boolean(),
77
+ solutionThreshold: z.z.number().positive().max(100),
78
+ dappName: z.z.string(),
79
+ serverUrl: z.z.string().url()
80
+ })
81
+ );
82
+ const ProsopoServerConfigSchema = ProsopoClientConfigSchema;
83
+ const AccountCreatorConfigSchema = z.z.object({
84
+ area: z.z.object({
85
+ width: z.z.number().positive(),
86
+ height: z.z.number().positive()
87
+ }),
88
+ offsetParameter: z.z.number().positive(),
89
+ multiplier: z.z.number().positive(),
90
+ fontSizeFactor: z.z.number().positive(),
91
+ maxShadowBlur: z.z.number().positive(),
92
+ numberOfRounds: z.z.number().positive(),
93
+ seed: z.z.number().positive()
94
+ });
95
+ const SxProps = z.z.record(z.z.string(), z.z.string());
96
+ const ProcaptchaConfigSchema = ProsopoClientConfigSchema.merge(
97
+ z.z.object({
98
+ accountCreator: AccountCreatorConfigSchema.optional(),
99
+ sx: SxProps.optional()
100
+ })
101
+ );
102
+ const ProsopoConfigSchema = ProsopoBasicConfigSchema.merge(
103
+ z.z.object({
104
+ captchas: ProsopoCaptchaCountConfigSchema,
105
+ captchaSolutions: ProsopoCaptchaSolutionConfigSchema,
106
+ batchCommit: BatchCommitConfigSchema,
107
+ server: ProsopoImageServerConfigSchema
108
+ })
109
+ );
110
+ exports.AccountCreatorConfigSchema = AccountCreatorConfigSchema;
111
+ exports.BatchCommitConfigSchema = BatchCommitConfigSchema;
112
+ exports.DatabaseConfigSchema = DatabaseConfigSchema;
113
+ exports.DatabaseTypes = DatabaseTypes;
114
+ exports.EnvironmentTypesSchema = EnvironmentTypesSchema;
115
+ exports.NetworkConfigSchema = NetworkConfigSchema;
116
+ exports.NetworkNamesSchema = NetworkNamesSchema;
117
+ exports.ProcaptchaConfigSchema = ProcaptchaConfigSchema;
118
+ exports.ProsopoBaseConfigSchema = ProsopoBaseConfigSchema;
119
+ exports.ProsopoBasicConfigSchema = ProsopoBasicConfigSchema;
120
+ exports.ProsopoCaptchaCountConfigSchema = ProsopoCaptchaCountConfigSchema;
121
+ exports.ProsopoCaptchaSolutionConfigSchema = ProsopoCaptchaSolutionConfigSchema;
122
+ exports.ProsopoClientConfigSchema = ProsopoClientConfigSchema;
123
+ exports.ProsopoConfigSchema = ProsopoConfigSchema;
124
+ exports.ProsopoImageServerConfigSchema = ProsopoImageServerConfigSchema;
125
+ exports.ProsopoNetworksSchema = ProsopoNetworksSchema;
126
+ exports.ProsopoServerConfigSchema = ProsopoServerConfigSchema;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const config = require("./config.cjs");
4
+ exports.AccountCreatorConfigSchema = config.AccountCreatorConfigSchema;
5
+ exports.BatchCommitConfigSchema = config.BatchCommitConfigSchema;
6
+ exports.DatabaseConfigSchema = config.DatabaseConfigSchema;
7
+ exports.DatabaseTypes = config.DatabaseTypes;
8
+ exports.EnvironmentTypesSchema = config.EnvironmentTypesSchema;
9
+ exports.NetworkConfigSchema = config.NetworkConfigSchema;
10
+ exports.NetworkNamesSchema = config.NetworkNamesSchema;
11
+ exports.ProcaptchaConfigSchema = config.ProcaptchaConfigSchema;
12
+ exports.ProsopoBaseConfigSchema = config.ProsopoBaseConfigSchema;
13
+ exports.ProsopoBasicConfigSchema = config.ProsopoBasicConfigSchema;
14
+ exports.ProsopoCaptchaCountConfigSchema = config.ProsopoCaptchaCountConfigSchema;
15
+ exports.ProsopoCaptchaSolutionConfigSchema = config.ProsopoCaptchaSolutionConfigSchema;
16
+ exports.ProsopoClientConfigSchema = config.ProsopoClientConfigSchema;
17
+ exports.ProsopoConfigSchema = config.ProsopoConfigSchema;
18
+ exports.ProsopoImageServerConfigSchema = config.ProsopoImageServerConfigSchema;
19
+ exports.ProsopoNetworksSchema = config.ProsopoNetworksSchema;
20
+ exports.ProsopoServerConfigSchema = config.ProsopoServerConfigSchema;
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const types = require("@polkadot/types");
4
+ const z = require("zod");
5
+ const AbiParamSpec = z.object({
6
+ name: z.string(),
7
+ type: z.union([z.number(), z.string()])
8
+ });
9
+ const AbiFieldSpec = z.object({
10
+ name: z.string().optional(),
11
+ type: z.number(),
12
+ typeName: z.string().optional()
13
+ });
14
+ const AbiVariantSpec = z.object({
15
+ index: z.number(),
16
+ name: z.string()
17
+ });
18
+ const AbiStorageEnumFieldSpec = z.object({
19
+ name: z.string(),
20
+ fields: z.array(z.any())
21
+ });
22
+ const AbiStorageEnumSpec = z.record(z.number().min(0), AbiStorageEnumFieldSpec);
23
+ const AbiTypeSpec = z.object({
24
+ id: z.number(),
25
+ type: z.object({
26
+ def: z.object({
27
+ composite: z.object({
28
+ fields: z.array(AbiFieldSpec)
29
+ }).optional(),
30
+ variant: z.object({
31
+ variants: z.union([z.array(AbiVariantSpec).optional(), AbiStorageEnumSpec])
32
+ }).optional(),
33
+ sequence: z.object({
34
+ type: z.number()
35
+ }).optional(),
36
+ array: z.object({
37
+ len: z.number(),
38
+ type: z.number()
39
+ }).optional(),
40
+ primitive: z.string().optional(),
41
+ tuple: z.any().optional()
42
+ }),
43
+ params: z.array(AbiParamSpec).optional(),
44
+ path: z.array(z.string()).optional()
45
+ })
46
+ });
47
+ const AbiEnumSpec = z.object({
48
+ dispatchKey: z.string(),
49
+ variants: z.any()
50
+ });
51
+ const AbiText = z.union([z.instanceof(types.Text), z.string()]);
52
+ const AbiCellSpec = z.object({
53
+ key: AbiText,
54
+ ty: z.union([z.number(), z.string()])
55
+ });
56
+ const AbiTypesSpec = z.array(AbiTypeSpec);
57
+ const AbiStorageFieldSpec = z.lazy(
58
+ () => z.object({
59
+ name: AbiText.optional(),
60
+ layout: z.object({
61
+ leaf: AbiCellSpec.optional(),
62
+ enum: AbiEnumSpec.optional(),
63
+ root: AbiStorageFieldSpec.optional(),
64
+ struct: AbiStorageStructSpec.optional()
65
+ }),
66
+ root_key: AbiText.optional()
67
+ })
68
+ );
69
+ const AbiStorageStructSpec = z.object({
70
+ fields: z.array(AbiStorageFieldSpec),
71
+ name: z.string()
72
+ });
73
+ const AbiStorageSpec = z.object({
74
+ root: z.object({
75
+ layout: z.object({
76
+ struct: AbiStorageStructSpec.optional()
77
+ })
78
+ })
79
+ });
80
+ const AbiSpecDef = z.object({
81
+ constructors: z.array(z.any()),
82
+ docs: z.array(z.any()),
83
+ events: z.array(z.any()),
84
+ messages: z.array(
85
+ z.object({
86
+ label: z.string(),
87
+ selector: z.string()
88
+ })
89
+ )
90
+ });
91
+ var metadataVersion = /* @__PURE__ */ ((metadataVersion2) => {
92
+ metadataVersion2["V1"] = "V1";
93
+ metadataVersion2["V2"] = "V2";
94
+ metadataVersion2["V3"] = "V3";
95
+ return metadataVersion2;
96
+ })(metadataVersion || {});
97
+ const AbiDetailsSpec = z.object({
98
+ spec: AbiSpecDef,
99
+ types: AbiTypesSpec,
100
+ storage: AbiStorageSpec
101
+ });
102
+ const AbiMetaDataSpec = z.object({
103
+ metadataVersion: z.string().optional(),
104
+ source: z.object({
105
+ hash: z.string(),
106
+ language: z.string(),
107
+ compiler: z.string(),
108
+ wasm: z.string().optional()
109
+ }),
110
+ contract: z.object({
111
+ name: z.string(),
112
+ version: z.string(),
113
+ authors: z.array(z.string())
114
+ }),
115
+ [
116
+ "V1"
117
+ /* V1 */
118
+ ]: AbiDetailsSpec.optional(),
119
+ [
120
+ "V2"
121
+ /* V2 */
122
+ ]: AbiDetailsSpec.optional(),
123
+ [
124
+ "V3"
125
+ /* V3 */
126
+ ]: AbiDetailsSpec.optional(),
127
+ spec: AbiSpecDef,
128
+ types: AbiTypesSpec,
129
+ storage: AbiStorageSpec
130
+ });
131
+ exports.AbiCellSpec = AbiCellSpec;
132
+ exports.AbiDetailsSpec = AbiDetailsSpec;
133
+ exports.AbiEnumSpec = AbiEnumSpec;
134
+ exports.AbiFieldSpec = AbiFieldSpec;
135
+ exports.AbiMetaDataSpec = AbiMetaDataSpec;
136
+ exports.AbiParamSpec = AbiParamSpec;
137
+ exports.AbiSpecDef = AbiSpecDef;
138
+ exports.AbiStorageEnumSpec = AbiStorageEnumSpec;
139
+ exports.AbiStorageFieldSpec = AbiStorageFieldSpec;
140
+ exports.AbiStorageSpec = AbiStorageSpec;
141
+ exports.AbiStorageStructSpec = AbiStorageStructSpec;
142
+ exports.AbiText = AbiText;
143
+ exports.AbiTypeSpec = AbiTypeSpec;
144
+ exports.AbiTypesSpec = AbiTypesSpec;
145
+ exports.AbiVariantSpec = AbiVariantSpec;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const artifacts = require("./artifacts.cjs");
4
+ require("./contract.cjs");
5
+ require("./useWeight.cjs");
6
+ require("./batch.cjs");
7
+ require("./typechain/index.cjs");
8
+ exports.AbiCellSpec = artifacts.AbiCellSpec;
9
+ exports.AbiDetailsSpec = artifacts.AbiDetailsSpec;
10
+ exports.AbiEnumSpec = artifacts.AbiEnumSpec;
11
+ exports.AbiFieldSpec = artifacts.AbiFieldSpec;
12
+ exports.AbiMetaDataSpec = artifacts.AbiMetaDataSpec;
13
+ exports.AbiParamSpec = artifacts.AbiParamSpec;
14
+ exports.AbiSpecDef = artifacts.AbiSpecDef;
15
+ exports.AbiStorageEnumSpec = artifacts.AbiStorageEnumSpec;
16
+ exports.AbiStorageFieldSpec = artifacts.AbiStorageFieldSpec;
17
+ exports.AbiStorageSpec = artifacts.AbiStorageSpec;
18
+ exports.AbiStorageStructSpec = artifacts.AbiStorageStructSpec;
19
+ exports.AbiText = artifacts.AbiText;
20
+ exports.AbiTypeSpec = artifacts.AbiTypeSpec;
21
+ exports.AbiTypesSpec = artifacts.AbiTypesSpec;
22
+ exports.AbiVariantSpec = artifacts.AbiVariantSpec;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ require("./types-returns/index.cjs");
3
+ require("./types-arguments/index.cjs");
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var LangError = /* @__PURE__ */ ((LangError2) => {
4
+ LangError2["couldNotReadInput"] = "CouldNotReadInput";
5
+ return LangError2;
6
+ })(LangError || {});
7
+ var Payee = /* @__PURE__ */ ((Payee2) => {
8
+ Payee2["provider"] = "Provider";
9
+ Payee2["dapp"] = "Dapp";
10
+ return Payee2;
11
+ })(Payee || {});
12
+ var DappPayee = /* @__PURE__ */ ((DappPayee2) => {
13
+ DappPayee2["provider"] = "Provider";
14
+ DappPayee2["dapp"] = "Dapp";
15
+ DappPayee2["any"] = "Any";
16
+ return DappPayee2;
17
+ })(DappPayee || {});
18
+ var GovernanceStatus = /* @__PURE__ */ ((GovernanceStatus2) => {
19
+ GovernanceStatus2["active"] = "Active";
20
+ GovernanceStatus2["inactive"] = "Inactive";
21
+ return GovernanceStatus2;
22
+ })(GovernanceStatus || {});
23
+ var Error = /* @__PURE__ */ ((Error2) => {
24
+ Error2["notAdmin"] = "NotAdmin";
25
+ Error2["notOwner"] = "NotOwner";
26
+ Error2["contractTransferFailed"] = "ContractTransferFailed";
27
+ Error2["providerAccountExists"] = "ProviderAccountExists";
28
+ Error2["providerExists"] = "ProviderExists";
29
+ Error2["providerAccountDoesNotExist"] = "ProviderAccountDoesNotExist";
30
+ Error2["providerDoesNotExist"] = "ProviderDoesNotExist";
31
+ Error2["providerInsufficientFunds"] = "ProviderInsufficientFunds";
32
+ Error2["providerInactive"] = "ProviderInactive";
33
+ Error2["providerUrlUsed"] = "ProviderUrlUsed";
34
+ Error2["dappExists"] = "DappExists";
35
+ Error2["dappDoesNotExist"] = "DappDoesNotExist";
36
+ Error2["dappInactive"] = "DappInactive";
37
+ Error2["dappInsufficientFunds"] = "DappInsufficientFunds";
38
+ Error2["captchaDataDoesNotExist"] = "CaptchaDataDoesNotExist";
39
+ Error2["commitDoesNotExist"] = "CommitDoesNotExist";
40
+ Error2["dappUserDoesNotExist"] = "DappUserDoesNotExist";
41
+ Error2["noActiveProviders"] = "NoActiveProviders";
42
+ Error2["datasetIdSolutionsSame"] = "DatasetIdSolutionsSame";
43
+ Error2["codeNotFound"] = "CodeNotFound";
44
+ Error2["unknown"] = "Unknown";
45
+ Error2["invalidContract"] = "InvalidContract";
46
+ Error2["invalidPayee"] = "InvalidPayee";
47
+ Error2["invalidCaptchaStatus"] = "InvalidCaptchaStatus";
48
+ Error2["noCorrectCaptcha"] = "NoCorrectCaptcha";
49
+ Error2["notEnoughActiveProviders"] = "NotEnoughActiveProviders";
50
+ Error2["providerFeeTooHigh"] = "ProviderFeeTooHigh";
51
+ Error2["commitAlreadyExists"] = "CommitAlreadyExists";
52
+ return Error2;
53
+ })(Error || {});
54
+ var CaptchaStatus = /* @__PURE__ */ ((CaptchaStatus2) => {
55
+ CaptchaStatus2["pending"] = "Pending";
56
+ CaptchaStatus2["approved"] = "Approved";
57
+ CaptchaStatus2["disapproved"] = "Disapproved";
58
+ return CaptchaStatus2;
59
+ })(CaptchaStatus || {});
60
+ exports.CaptchaStatus = CaptchaStatus;
61
+ exports.DappPayee = DappPayee;
62
+ exports.Error = Error;
63
+ exports.GovernanceStatus = GovernanceStatus;
64
+ exports.LangError = LangError;
65
+ exports.Payee = Payee;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const captcha = require("./captcha.cjs");
4
+ exports.ArgumentTypes = captcha;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var LangError = /* @__PURE__ */ ((LangError2) => {
4
+ LangError2["couldNotReadInput"] = "CouldNotReadInput";
5
+ return LangError2;
6
+ })(LangError || {});
7
+ var Payee = /* @__PURE__ */ ((Payee2) => {
8
+ Payee2["provider"] = "Provider";
9
+ Payee2["dapp"] = "Dapp";
10
+ return Payee2;
11
+ })(Payee || {});
12
+ var DappPayee = /* @__PURE__ */ ((DappPayee2) => {
13
+ DappPayee2["provider"] = "Provider";
14
+ DappPayee2["dapp"] = "Dapp";
15
+ DappPayee2["any"] = "Any";
16
+ return DappPayee2;
17
+ })(DappPayee || {});
18
+ var GovernanceStatus = /* @__PURE__ */ ((GovernanceStatus2) => {
19
+ GovernanceStatus2["active"] = "Active";
20
+ GovernanceStatus2["inactive"] = "Inactive";
21
+ return GovernanceStatus2;
22
+ })(GovernanceStatus || {});
23
+ var Error = /* @__PURE__ */ ((Error2) => {
24
+ Error2["notAdmin"] = "NotAdmin";
25
+ Error2["notOwner"] = "NotOwner";
26
+ Error2["contractTransferFailed"] = "ContractTransferFailed";
27
+ Error2["providerAccountExists"] = "ProviderAccountExists";
28
+ Error2["providerExists"] = "ProviderExists";
29
+ Error2["providerAccountDoesNotExist"] = "ProviderAccountDoesNotExist";
30
+ Error2["providerDoesNotExist"] = "ProviderDoesNotExist";
31
+ Error2["providerInsufficientFunds"] = "ProviderInsufficientFunds";
32
+ Error2["providerInactive"] = "ProviderInactive";
33
+ Error2["providerUrlUsed"] = "ProviderUrlUsed";
34
+ Error2["dappExists"] = "DappExists";
35
+ Error2["dappDoesNotExist"] = "DappDoesNotExist";
36
+ Error2["dappInactive"] = "DappInactive";
37
+ Error2["dappInsufficientFunds"] = "DappInsufficientFunds";
38
+ Error2["captchaDataDoesNotExist"] = "CaptchaDataDoesNotExist";
39
+ Error2["commitDoesNotExist"] = "CommitDoesNotExist";
40
+ Error2["dappUserDoesNotExist"] = "DappUserDoesNotExist";
41
+ Error2["noActiveProviders"] = "NoActiveProviders";
42
+ Error2["datasetIdSolutionsSame"] = "DatasetIdSolutionsSame";
43
+ Error2["codeNotFound"] = "CodeNotFound";
44
+ Error2["unknown"] = "Unknown";
45
+ Error2["invalidContract"] = "InvalidContract";
46
+ Error2["invalidPayee"] = "InvalidPayee";
47
+ Error2["invalidCaptchaStatus"] = "InvalidCaptchaStatus";
48
+ Error2["noCorrectCaptcha"] = "NoCorrectCaptcha";
49
+ Error2["notEnoughActiveProviders"] = "NotEnoughActiveProviders";
50
+ Error2["providerFeeTooHigh"] = "ProviderFeeTooHigh";
51
+ Error2["commitAlreadyExists"] = "CommitAlreadyExists";
52
+ return Error2;
53
+ })(Error || {});
54
+ var CaptchaStatus = /* @__PURE__ */ ((CaptchaStatus2) => {
55
+ CaptchaStatus2["pending"] = "Pending";
56
+ CaptchaStatus2["approved"] = "Approved";
57
+ CaptchaStatus2["disapproved"] = "Disapproved";
58
+ return CaptchaStatus2;
59
+ })(CaptchaStatus || {});
60
+ exports.CaptchaStatus = CaptchaStatus;
61
+ exports.DappPayee = DappPayee;
62
+ exports.Error = Error;
63
+ exports.GovernanceStatus = GovernanceStatus;
64
+ exports.LangError = LangError;
65
+ exports.Payee = Payee;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const captcha = require("./captcha.cjs");
4
+ exports.CaptchaStatus = captcha.CaptchaStatus;
5
+ exports.DappPayee = captcha.DappPayee;
6
+ exports.Error = captcha.Error;
7
+ exports.GovernanceStatus = captcha.GovernanceStatus;
8
+ exports.LangError = captcha.LangError;
9
+ exports.Payee = captcha.Payee;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ require("./captcha/index.cjs");
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const z = require("zod");
4
+ var CaptchaTypes = /* @__PURE__ */ ((CaptchaTypes2) => {
5
+ CaptchaTypes2["SelectAll"] = "SelectAll";
6
+ return CaptchaTypes2;
7
+ })(CaptchaTypes || {});
8
+ var CaptchaItemTypes = /* @__PURE__ */ ((CaptchaItemTypes2) => {
9
+ CaptchaItemTypes2["Text"] = "text";
10
+ CaptchaItemTypes2["Image"] = "image";
11
+ return CaptchaItemTypes2;
12
+ })(CaptchaItemTypes || {});
13
+ var CaptchaStates = /* @__PURE__ */ ((CaptchaStates2) => {
14
+ CaptchaStates2["Solved"] = "solved";
15
+ CaptchaStates2["Unsolved"] = "unsolved";
16
+ return CaptchaStates2;
17
+ })(CaptchaStates || {});
18
+ const CaptchaSchema = z.z.object({
19
+ captchaId: z.z.union([z.z.string(), z.z.undefined()]),
20
+ captchaContentId: z.z.union([z.z.string(), z.z.undefined()]),
21
+ salt: z.z.string().min(34),
22
+ solution: z.z.number().array().optional(),
23
+ unlabelled: z.z.number().array().optional(),
24
+ timeLimit: z.z.number().optional()
25
+ });
26
+ const CaptchaItemSchema = z.z.object({
27
+ hash: z.z.string(),
28
+ data: z.z.string(),
29
+ type: z.z.nativeEnum(CaptchaItemTypes)
30
+ });
31
+ const HashedCaptchaItemSchema = CaptchaItemSchema.extend({
32
+ hash: z.z.string()
33
+ });
34
+ const LabelledItemSchema = HashedCaptchaItemSchema.extend({
35
+ label: z.z.string()
36
+ });
37
+ const MaybeLabelledHashedItemSchema = HashedCaptchaItemSchema.extend({
38
+ label: z.z.string().optional()
39
+ });
40
+ const SelectAllCaptchaSchemaRaw = CaptchaSchema.extend({
41
+ items: z.z.array(CaptchaItemSchema),
42
+ target: z.z.string()
43
+ });
44
+ const SelectAllCaptchaSchema = SelectAllCaptchaSchemaRaw.extend({
45
+ solution: z.z.string().array().optional(),
46
+ unlabelled: z.z.string().array().optional()
47
+ });
48
+ const CaptchasSchema = z.z.array(SelectAllCaptchaSchemaRaw);
49
+ const CaptchaSolutionSchema = z.z.object({
50
+ captchaId: z.z.string(),
51
+ captchaContentId: z.z.string(),
52
+ solution: z.z.string().array(),
53
+ salt: z.z.string().min(34)
54
+ });
55
+ const CaptchaSolutionArraySchema = z.z.array(CaptchaSolutionSchema);
56
+ const DataSchema = z.z.object({
57
+ items: z.z.array(MaybeLabelledHashedItemSchema)
58
+ });
59
+ const LabelledDataSchema = z.z.object({
60
+ items: z.z.array(LabelledItemSchema)
61
+ });
62
+ const CaptchasContainerSchema = z.z.object({
63
+ captchas: CaptchasSchema,
64
+ format: z.z.nativeEnum(CaptchaTypes)
65
+ });
66
+ const LabelsContainerSchema = z.z.object({
67
+ labels: z.z.array(z.z.string())
68
+ });
69
+ exports.CaptchaItemSchema = CaptchaItemSchema;
70
+ exports.CaptchaItemTypes = CaptchaItemTypes;
71
+ exports.CaptchaSchema = CaptchaSchema;
72
+ exports.CaptchaSolutionArraySchema = CaptchaSolutionArraySchema;
73
+ exports.CaptchaSolutionSchema = CaptchaSolutionSchema;
74
+ exports.CaptchaStates = CaptchaStates;
75
+ exports.CaptchaTypes = CaptchaTypes;
76
+ exports.CaptchasContainerSchema = CaptchasContainerSchema;
77
+ exports.CaptchasSchema = CaptchasSchema;
78
+ exports.DataSchema = DataSchema;
79
+ exports.HashedCaptchaItemSchema = HashedCaptchaItemSchema;
80
+ exports.LabelledDataSchema = LabelledDataSchema;
81
+ exports.LabelledItemSchema = LabelledItemSchema;
82
+ exports.LabelsContainerSchema = LabelsContainerSchema;
83
+ exports.MaybeLabelledHashedItemSchema = MaybeLabelledHashedItemSchema;
84
+ exports.SelectAllCaptchaSchema = SelectAllCaptchaSchema;
85
+ exports.SelectAllCaptchaSchemaRaw = SelectAllCaptchaSchemaRaw;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const captcha = require("./captcha.cjs");
4
+ const z = require("zod");
5
+ const DatasetSchema = z.z.object({
6
+ datasetId: z.z.string().optional(),
7
+ datasetContentId: z.z.string().optional(),
8
+ captchas: captcha.CaptchasSchema,
9
+ format: z.z.nativeEnum(captcha.CaptchaTypes),
10
+ solutionTree: z.z.array(z.z.array(z.z.string())).optional(),
11
+ contentTree: z.z.array(z.z.array(z.z.string())).optional(),
12
+ timeLimit: z.z.number().optional()
13
+ });
14
+ const DatasetWithIdsSchema = z.z.object({
15
+ datasetId: z.z.string(),
16
+ datasetContentId: z.z.string().optional(),
17
+ captchas: z.z.array(captcha.SelectAllCaptchaSchema),
18
+ format: z.z.nativeEnum(captcha.CaptchaTypes),
19
+ solutionTree: z.z.array(z.z.array(z.z.string())).optional(),
20
+ contentTree: z.z.array(z.z.array(z.z.string())).optional()
21
+ });
22
+ const DatasetWithIdsAndTreeSchema = DatasetWithIdsSchema.extend({
23
+ solutionTree: z.z.array(z.z.array(z.z.string())),
24
+ contentTree: z.z.array(z.z.array(z.z.string()))
25
+ });
26
+ exports.DatasetSchema = DatasetSchema;
27
+ exports.DatasetWithIdsAndTreeSchema = DatasetWithIdsAndTreeSchema;
28
+ exports.DatasetWithIdsSchema = DatasetWithIdsSchema;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const captcha = require("./captcha.cjs");
4
+ const dataset = require("./dataset.cjs");
5
+ require("./merkle.cjs");
6
+ require("./assets.cjs");
7
+ exports.CaptchaItemSchema = captcha.CaptchaItemSchema;
8
+ exports.CaptchaItemTypes = captcha.CaptchaItemTypes;
9
+ exports.CaptchaSchema = captcha.CaptchaSchema;
10
+ exports.CaptchaSolutionArraySchema = captcha.CaptchaSolutionArraySchema;
11
+ exports.CaptchaSolutionSchema = captcha.CaptchaSolutionSchema;
12
+ exports.CaptchaStates = captcha.CaptchaStates;
13
+ exports.CaptchaTypes = captcha.CaptchaTypes;
14
+ exports.CaptchasContainerSchema = captcha.CaptchasContainerSchema;
15
+ exports.CaptchasSchema = captcha.CaptchasSchema;
16
+ exports.DataSchema = captcha.DataSchema;
17
+ exports.HashedCaptchaItemSchema = captcha.HashedCaptchaItemSchema;
18
+ exports.LabelledDataSchema = captcha.LabelledDataSchema;
19
+ exports.LabelledItemSchema = captcha.LabelledItemSchema;
20
+ exports.LabelsContainerSchema = captcha.LabelsContainerSchema;
21
+ exports.MaybeLabelledHashedItemSchema = captcha.MaybeLabelledHashedItemSchema;
22
+ exports.SelectAllCaptchaSchema = captcha.SelectAllCaptchaSchema;
23
+ exports.SelectAllCaptchaSchemaRaw = captcha.SelectAllCaptchaSchemaRaw;
24
+ exports.DatasetSchema = dataset.DatasetSchema;
25
+ exports.DatasetWithIdsAndTreeSchema = dataset.DatasetWithIdsAndTreeSchema;
26
+ exports.DatasetWithIdsSchema = dataset.DatasetWithIdsSchema;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("./config/index.cjs");
4
+ require("./contract/index.cjs");
5
+ require("./datasets/index.cjs");
6
+ require("./provider/index.cjs");
7
+ require("./procaptcha/index.cjs");
8
+ const config = require("./config/config.cjs");
9
+ const artifacts = require("./contract/artifacts.cjs");
10
+ const captcha = require("./contract/typechain/captcha/types-returns/captcha.cjs");
11
+ const captcha$1 = require("./contract/typechain/captcha/types-arguments/captcha.cjs");
12
+ const captcha$2 = require("./datasets/captcha.cjs");
13
+ const dataset = require("./datasets/dataset.cjs");
14
+ const api = require("./provider/api.cjs");
15
+ const scheduler = require("./provider/scheduler.cjs");
16
+ const argv = require("./provider/argv.cjs");
17
+ const manager = require("./procaptcha/manager.cjs");
18
+ exports.AccountCreatorConfigSchema = config.AccountCreatorConfigSchema;
19
+ exports.BatchCommitConfigSchema = config.BatchCommitConfigSchema;
20
+ exports.DatabaseConfigSchema = config.DatabaseConfigSchema;
21
+ exports.DatabaseTypes = config.DatabaseTypes;
22
+ exports.EnvironmentTypesSchema = config.EnvironmentTypesSchema;
23
+ exports.NetworkConfigSchema = config.NetworkConfigSchema;
24
+ exports.NetworkNamesSchema = config.NetworkNamesSchema;
25
+ exports.ProcaptchaConfigSchema = config.ProcaptchaConfigSchema;
26
+ exports.ProsopoBaseConfigSchema = config.ProsopoBaseConfigSchema;
27
+ exports.ProsopoBasicConfigSchema = config.ProsopoBasicConfigSchema;
28
+ exports.ProsopoCaptchaCountConfigSchema = config.ProsopoCaptchaCountConfigSchema;
29
+ exports.ProsopoCaptchaSolutionConfigSchema = config.ProsopoCaptchaSolutionConfigSchema;
30
+ exports.ProsopoClientConfigSchema = config.ProsopoClientConfigSchema;
31
+ exports.ProsopoConfigSchema = config.ProsopoConfigSchema;
32
+ exports.ProsopoImageServerConfigSchema = config.ProsopoImageServerConfigSchema;
33
+ exports.ProsopoNetworksSchema = config.ProsopoNetworksSchema;
34
+ exports.ProsopoServerConfigSchema = config.ProsopoServerConfigSchema;
35
+ exports.AbiCellSpec = artifacts.AbiCellSpec;
36
+ exports.AbiDetailsSpec = artifacts.AbiDetailsSpec;
37
+ exports.AbiEnumSpec = artifacts.AbiEnumSpec;
38
+ exports.AbiFieldSpec = artifacts.AbiFieldSpec;
39
+ exports.AbiMetaDataSpec = artifacts.AbiMetaDataSpec;
40
+ exports.AbiParamSpec = artifacts.AbiParamSpec;
41
+ exports.AbiSpecDef = artifacts.AbiSpecDef;
42
+ exports.AbiStorageEnumSpec = artifacts.AbiStorageEnumSpec;
43
+ exports.AbiStorageFieldSpec = artifacts.AbiStorageFieldSpec;
44
+ exports.AbiStorageSpec = artifacts.AbiStorageSpec;
45
+ exports.AbiStorageStructSpec = artifacts.AbiStorageStructSpec;
46
+ exports.AbiText = artifacts.AbiText;
47
+ exports.AbiTypeSpec = artifacts.AbiTypeSpec;
48
+ exports.AbiTypesSpec = artifacts.AbiTypesSpec;
49
+ exports.AbiVariantSpec = artifacts.AbiVariantSpec;
50
+ exports.CaptchaStatus = captcha.CaptchaStatus;
51
+ exports.DappPayee = captcha.DappPayee;
52
+ exports.Error = captcha.Error;
53
+ exports.GovernanceStatus = captcha.GovernanceStatus;
54
+ exports.LangError = captcha.LangError;
55
+ exports.Payee = captcha.Payee;
56
+ exports.ArgumentTypes = captcha$1;
57
+ exports.CaptchaItemSchema = captcha$2.CaptchaItemSchema;
58
+ exports.CaptchaItemTypes = captcha$2.CaptchaItemTypes;
59
+ exports.CaptchaSchema = captcha$2.CaptchaSchema;
60
+ exports.CaptchaSolutionArraySchema = captcha$2.CaptchaSolutionArraySchema;
61
+ exports.CaptchaSolutionSchema = captcha$2.CaptchaSolutionSchema;
62
+ exports.CaptchaStates = captcha$2.CaptchaStates;
63
+ exports.CaptchaTypes = captcha$2.CaptchaTypes;
64
+ exports.CaptchasContainerSchema = captcha$2.CaptchasContainerSchema;
65
+ exports.CaptchasSchema = captcha$2.CaptchasSchema;
66
+ exports.DataSchema = captcha$2.DataSchema;
67
+ exports.HashedCaptchaItemSchema = captcha$2.HashedCaptchaItemSchema;
68
+ exports.LabelledDataSchema = captcha$2.LabelledDataSchema;
69
+ exports.LabelledItemSchema = captcha$2.LabelledItemSchema;
70
+ exports.LabelsContainerSchema = captcha$2.LabelsContainerSchema;
71
+ exports.MaybeLabelledHashedItemSchema = captcha$2.MaybeLabelledHashedItemSchema;
72
+ exports.SelectAllCaptchaSchema = captcha$2.SelectAllCaptchaSchema;
73
+ exports.SelectAllCaptchaSchemaRaw = captcha$2.SelectAllCaptchaSchemaRaw;
74
+ exports.DatasetSchema = dataset.DatasetSchema;
75
+ exports.DatasetWithIdsAndTreeSchema = dataset.DatasetWithIdsAndTreeSchema;
76
+ exports.DatasetWithIdsSchema = dataset.DatasetWithIdsSchema;
77
+ exports.ApiParams = api.ApiParams;
78
+ exports.ApiPaths = api.ApiPaths;
79
+ exports.CaptchaRequestBody = api.CaptchaRequestBody;
80
+ exports.CaptchaSolutionBody = api.CaptchaSolutionBody;
81
+ exports.VerifySolutionBody = api.VerifySolutionBody;
82
+ exports.ScheduledTaskNames = scheduler.ScheduledTaskNames;
83
+ exports.ScheduledTaskStatus = scheduler.ScheduledTaskStatus;
84
+ exports.PayeeSchema = argv.PayeeSchema;
85
+ exports.ProcaptchaOutputSchema = manager.ProcaptchaOutputSchema;
86
+ exports.ProcaptchaResponse = manager.ProcaptchaResponse;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const manager = require("./manager.cjs");
4
+ exports.ProcaptchaOutputSchema = manager.ProcaptchaOutputSchema;
5
+ exports.ProcaptchaResponse = manager.ProcaptchaResponse;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("../provider/index.cjs");
4
+ const z = require("zod");
5
+ const api = require("../provider/api.cjs");
6
+ const ProcaptchaOutputSchema = z.z.object({
7
+ [api.ApiParams.commitmentId]: z.z.string().optional(),
8
+ [api.ApiParams.providerUrl]: z.z.string().optional(),
9
+ [api.ApiParams.dapp]: z.z.string(),
10
+ [api.ApiParams.user]: z.z.string(),
11
+ [api.ApiParams.blockNumber]: z.z.number().optional()
12
+ });
13
+ const ProcaptchaResponse = z.z.object({
14
+ [api.ApiParams.procaptchaResponse]: ProcaptchaOutputSchema
15
+ });
16
+ exports.ProcaptchaOutputSchema = ProcaptchaOutputSchema;
17
+ exports.ProcaptchaResponse = ProcaptchaResponse;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("../datasets/index.cjs");
4
+ const z = require("zod");
5
+ const captcha = require("../datasets/captcha.cjs");
6
+ var ApiPaths = /* @__PURE__ */ ((ApiPaths2) => {
7
+ ApiPaths2["GetCaptchaChallenge"] = "/v1/prosopo/provider/captcha";
8
+ ApiPaths2["SubmitCaptchaSolution"] = "/v1/prosopo/provider/solution";
9
+ ApiPaths2["VerifyCaptchaSolution"] = "/v1/prosopo/provider/verify";
10
+ ApiPaths2["GetProviderStatus"] = "/v1/prosopo/provider/status";
11
+ ApiPaths2["GetProviderDetails"] = "/v1/prosopo/provider/details";
12
+ return ApiPaths2;
13
+ })(ApiPaths || {});
14
+ var ApiParams = /* @__PURE__ */ ((ApiParams2) => {
15
+ ApiParams2["datasetId"] = "datasetId";
16
+ ApiParams2["user"] = "user";
17
+ ApiParams2["dapp"] = "dapp";
18
+ ApiParams2["blockNumber"] = "blockNumber";
19
+ ApiParams2["signature"] = "signature";
20
+ ApiParams2["requestHash"] = "requestHash";
21
+ ApiParams2["captchas"] = "captchas";
22
+ ApiParams2["commitmentId"] = "commitmentId";
23
+ ApiParams2["providerUrl"] = "providerUrl";
24
+ ApiParams2["procaptchaResponse"] = "procaptcha-response";
25
+ return ApiParams2;
26
+ })(ApiParams || {});
27
+ const CaptchaRequestBody = z.z.object({
28
+ [
29
+ "user"
30
+ /* user */
31
+ ]: z.z.string(),
32
+ [
33
+ "dapp"
34
+ /* dapp */
35
+ ]: z.z.string(),
36
+ [
37
+ "datasetId"
38
+ /* datasetId */
39
+ ]: z.z.string(),
40
+ [
41
+ "blockNumber"
42
+ /* blockNumber */
43
+ ]: z.z.string()
44
+ });
45
+ const CaptchaSolutionBody = z.z.object({
46
+ [
47
+ "user"
48
+ /* user */
49
+ ]: z.z.string(),
50
+ [
51
+ "dapp"
52
+ /* dapp */
53
+ ]: z.z.string(),
54
+ [
55
+ "captchas"
56
+ /* captchas */
57
+ ]: z.z.array(captcha.CaptchaSolutionSchema),
58
+ [
59
+ "requestHash"
60
+ /* requestHash */
61
+ ]: z.z.string(),
62
+ [
63
+ "signature"
64
+ /* signature */
65
+ ]: z.z.string()
66
+ // the signature to prove account ownership
67
+ });
68
+ const VerifySolutionBody = z.z.object({
69
+ [
70
+ "user"
71
+ /* user */
72
+ ]: z.z.string(),
73
+ [
74
+ "commitmentId"
75
+ /* commitmentId */
76
+ ]: z.z.string().optional()
77
+ });
78
+ exports.ApiParams = ApiParams;
79
+ exports.ApiPaths = ApiPaths;
80
+ exports.CaptchaRequestBody = CaptchaRequestBody;
81
+ exports.CaptchaSolutionBody = CaptchaSolutionBody;
82
+ exports.VerifySolutionBody = VerifySolutionBody;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("../contract/typechain/index.cjs");
4
+ const z = require("zod");
5
+ const captcha = require("../contract/typechain/captcha/types-returns/captcha.cjs");
6
+ const PayeeSchema = z.z.nativeEnum(captcha.Payee);
7
+ exports.PayeeSchema = PayeeSchema;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("./accounts.cjs");
4
+ const api = require("./api.cjs");
5
+ const scheduler = require("./scheduler.cjs");
6
+ const argv = require("./argv.cjs");
7
+ exports.ApiParams = api.ApiParams;
8
+ exports.ApiPaths = api.ApiPaths;
9
+ exports.CaptchaRequestBody = api.CaptchaRequestBody;
10
+ exports.CaptchaSolutionBody = api.CaptchaSolutionBody;
11
+ exports.VerifySolutionBody = api.VerifySolutionBody;
12
+ exports.ScheduledTaskNames = scheduler.ScheduledTaskNames;
13
+ exports.ScheduledTaskStatus = scheduler.ScheduledTaskStatus;
14
+ exports.PayeeSchema = argv.PayeeSchema;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var ScheduledTaskNames = /* @__PURE__ */ ((ScheduledTaskNames2) => {
4
+ ScheduledTaskNames2["BatchCommitment"] = "BatchCommitment";
5
+ ScheduledTaskNames2["CalculateSolution"] = "CalculateSolution";
6
+ return ScheduledTaskNames2;
7
+ })(ScheduledTaskNames || {});
8
+ var ScheduledTaskStatus = /* @__PURE__ */ ((ScheduledTaskStatus2) => {
9
+ ScheduledTaskStatus2["Pending"] = "Pending";
10
+ ScheduledTaskStatus2["Running"] = "Running";
11
+ ScheduledTaskStatus2["Completed"] = "Completed";
12
+ ScheduledTaskStatus2["Failed"] = "Failed";
13
+ return ScheduledTaskStatus2;
14
+ })(ScheduledTaskStatus || {});
15
+ exports.ScheduledTaskNames = ScheduledTaskNames;
16
+ exports.ScheduledTaskStatus = ScheduledTaskStatus;
package/package.json CHANGED
@@ -1,12 +1,19 @@
1
1
  {
2
2
  "name": "@prosopo/types",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Types for prosopo TypeScript packages",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/cjs/index.cjs"
11
+ }
12
+ },
7
13
  "scripts": {
8
14
  "clean": "tsc --build --clean",
9
- "build": "tsc --build --verbose",
15
+ "build": "tsc --build --verbose tsconfig.json",
16
+ "build:cjs": "npx vite --config vite.cjs.config.ts build",
10
17
  "lint": "npx eslint .",
11
18
  "lint:fix": "npx eslint . --fix --config ../../.eslintrc.js"
12
19
  },
@@ -26,8 +33,8 @@
26
33
  "@polkadot/api-contract": "10.9.1",
27
34
  "@polkadot/types": "10.9.1",
28
35
  "@polkadot/types-codec": "10.9.1",
29
- "@prosopo/common": "0.2.0",
30
- "consola": "^2.15.3",
36
+ "@prosopo/common": "0.2.2",
37
+ "consola": "^3.2.3",
31
38
  "zod": "^3.17.9"
32
39
  },
33
40
  "devDependencies": {
@@ -0,0 +1,6 @@
1
+ import { ViteCommonJSConfig } from '@prosopo/config'
2
+ import path from 'path'
3
+
4
+ export default function () {
5
+ return ViteCommonJSConfig('types', path.resolve('./tsconfig.cjs.json'))
6
+ }