@telika/sdk 0.1.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 ADDED
@@ -0,0 +1,68 @@
1
+ # @telika/sdk
2
+
3
+ TypeScript SDK for the Telika blockchain-anchored verification system on Polygon.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @telika/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { ProofGenerator, BlockchainClient } from '@telika/sdk';
15
+
16
+ // Generate a proof for an identity verification event
17
+ const proof = ProofGenerator.createIdentityProof({
18
+ telikaId: 'TLK-001',
19
+ verificationMethod: 'document-check',
20
+ verifiedAt: Date.now(),
21
+ verifierAddress: '0x...',
22
+ });
23
+
24
+ // Anchor it on Polygon
25
+ const client = new BlockchainClient({
26
+ contractAddress: '0x...',
27
+ rpcUrl: 'https://polygon-mainnet.g.alchemy.com/v2/YOUR_KEY',
28
+ privateKey: '0x...',
29
+ });
30
+
31
+ const tx = await client.anchorProof(
32
+ proof.hash,
33
+ 0, // EventType.IdentityVerification
34
+ 'TLK-001',
35
+ JSON.stringify(proof.metadata)
36
+ );
37
+ ```
38
+
39
+ ## Event Types
40
+
41
+ | Type | Value | Description |
42
+ |------|-------|-------------|
43
+ | `IdentityVerification` | `0` | Founder identity verified |
44
+ | `FundingDisbursement` | `1` | Funding sent to founder |
45
+ | `MilestoneConfirmation` | `2` | Milestone achieved |
46
+ | `ScoreUpdate` | `3` | Telika score recalculated |
47
+
48
+ ## API
49
+
50
+ ### ProofGenerator
51
+
52
+ - `generateProofHash(eventData)` — Generate a keccak256 proof hash
53
+ - `createIdentityProof(data)` — Create an identity verification proof
54
+ - `createFundingProof(data)` — Create a funding disbursement proof
55
+ - `createMilestoneProof(data)` — Create a milestone confirmation proof
56
+ - `createScoreProof(data)` — Create a score update proof
57
+ - `generateMetadata(eventType, options)` — Generate proof metadata
58
+
59
+ ### BlockchainClient
60
+
61
+ - `anchorProof(hash, eventType, telikaId, metadata)` — Anchor a proof on-chain
62
+ - `verifyProof(proofHash)` — Verify a proof exists on-chain
63
+ - `getProofsByTelikaId(telikaId)` — Get all proofs for a Telika ID
64
+ - `listenForProofs(callback)` — Listen for new proof events
65
+
66
+ ## License
67
+
68
+ MIT — [Telika Africa](https://telika.ai)
package/dist/abi.d.ts ADDED
@@ -0,0 +1,214 @@
1
+ /**
2
+ * TelikaVerification Contract ABI
3
+ *
4
+ * Minimal ABI containing only the functions and events needed by the SDK.
5
+ * This avoids requiring the full contract artifacts as a dependency.
6
+ */
7
+ export declare const TELIKA_VERIFICATION_ABI: readonly [{
8
+ readonly name: "anchorProof";
9
+ readonly type: "function";
10
+ readonly stateMutability: "nonpayable";
11
+ readonly inputs: readonly [{
12
+ readonly name: "proofHash";
13
+ readonly type: "bytes32";
14
+ }, {
15
+ readonly name: "eventType";
16
+ readonly type: "uint8";
17
+ }, {
18
+ readonly name: "telikaId";
19
+ readonly type: "string";
20
+ }, {
21
+ readonly name: "metadata";
22
+ readonly type: "string";
23
+ }];
24
+ readonly outputs: readonly [];
25
+ }, {
26
+ readonly name: "verifyProof";
27
+ readonly type: "function";
28
+ readonly stateMutability: "view";
29
+ readonly inputs: readonly [{
30
+ readonly name: "proofHash";
31
+ readonly type: "bytes32";
32
+ }];
33
+ readonly outputs: readonly [{
34
+ readonly name: "exists";
35
+ readonly type: "bool";
36
+ }, {
37
+ readonly name: "record";
38
+ readonly type: "tuple";
39
+ readonly components: readonly [{
40
+ readonly name: "proofHash";
41
+ readonly type: "bytes32";
42
+ }, {
43
+ readonly name: "eventType";
44
+ readonly type: "uint8";
45
+ }, {
46
+ readonly name: "telikaId";
47
+ readonly type: "string";
48
+ }, {
49
+ readonly name: "timestamp";
50
+ readonly type: "uint256";
51
+ }, {
52
+ readonly name: "metadata";
53
+ readonly type: "string";
54
+ }, {
55
+ readonly name: "anchoredBy";
56
+ readonly type: "address";
57
+ }];
58
+ }];
59
+ }, {
60
+ readonly name: "getProofsByTelikaId";
61
+ readonly type: "function";
62
+ readonly stateMutability: "view";
63
+ readonly inputs: readonly [{
64
+ readonly name: "telikaId";
65
+ readonly type: "string";
66
+ }];
67
+ readonly outputs: readonly [{
68
+ readonly name: "proofHashes";
69
+ readonly type: "bytes32[]";
70
+ }];
71
+ }, {
72
+ readonly name: "getProofCount";
73
+ readonly type: "function";
74
+ readonly stateMutability: "view";
75
+ readonly inputs: readonly [{
76
+ readonly name: "telikaId";
77
+ readonly type: "string";
78
+ }];
79
+ readonly outputs: readonly [{
80
+ readonly name: "count";
81
+ readonly type: "uint256";
82
+ }];
83
+ }, {
84
+ readonly name: "getProof";
85
+ readonly type: "function";
86
+ readonly stateMutability: "view";
87
+ readonly inputs: readonly [{
88
+ readonly name: "proofHash";
89
+ readonly type: "bytes32";
90
+ }];
91
+ readonly outputs: readonly [{
92
+ readonly name: "record";
93
+ readonly type: "tuple";
94
+ readonly components: readonly [{
95
+ readonly name: "proofHash";
96
+ readonly type: "bytes32";
97
+ }, {
98
+ readonly name: "eventType";
99
+ readonly type: "uint8";
100
+ }, {
101
+ readonly name: "telikaId";
102
+ readonly type: "string";
103
+ }, {
104
+ readonly name: "timestamp";
105
+ readonly type: "uint256";
106
+ }, {
107
+ readonly name: "metadata";
108
+ readonly type: "string";
109
+ }, {
110
+ readonly name: "anchoredBy";
111
+ readonly type: "address";
112
+ }];
113
+ }];
114
+ }, {
115
+ readonly name: "getProofsByTelikaIdPaginated";
116
+ readonly type: "function";
117
+ readonly stateMutability: "view";
118
+ readonly inputs: readonly [{
119
+ readonly name: "telikaId";
120
+ readonly type: "string";
121
+ }, {
122
+ readonly name: "offset";
123
+ readonly type: "uint256";
124
+ }, {
125
+ readonly name: "limit";
126
+ readonly type: "uint256";
127
+ }];
128
+ readonly outputs: readonly [{
129
+ readonly name: "proofHashes";
130
+ readonly type: "bytes32[]";
131
+ }];
132
+ }, {
133
+ readonly name: "totalProofs";
134
+ readonly type: "function";
135
+ readonly stateMutability: "view";
136
+ readonly inputs: readonly [];
137
+ readonly outputs: readonly [{
138
+ readonly name: "";
139
+ readonly type: "uint256";
140
+ }];
141
+ }, {
142
+ readonly name: "ANCHOR_ROLE";
143
+ readonly type: "function";
144
+ readonly stateMutability: "view";
145
+ readonly inputs: readonly [];
146
+ readonly outputs: readonly [{
147
+ readonly name: "";
148
+ readonly type: "bytes32";
149
+ }];
150
+ }, {
151
+ readonly name: "hasRole";
152
+ readonly type: "function";
153
+ readonly stateMutability: "view";
154
+ readonly inputs: readonly [{
155
+ readonly name: "role";
156
+ readonly type: "bytes32";
157
+ }, {
158
+ readonly name: "account";
159
+ readonly type: "address";
160
+ }];
161
+ readonly outputs: readonly [{
162
+ readonly name: "";
163
+ readonly type: "bool";
164
+ }];
165
+ }, {
166
+ readonly name: "grantRole";
167
+ readonly type: "function";
168
+ readonly stateMutability: "nonpayable";
169
+ readonly inputs: readonly [{
170
+ readonly name: "role";
171
+ readonly type: "bytes32";
172
+ }, {
173
+ readonly name: "account";
174
+ readonly type: "address";
175
+ }];
176
+ readonly outputs: readonly [];
177
+ }, {
178
+ readonly name: "revokeRole";
179
+ readonly type: "function";
180
+ readonly stateMutability: "nonpayable";
181
+ readonly inputs: readonly [{
182
+ readonly name: "role";
183
+ readonly type: "bytes32";
184
+ }, {
185
+ readonly name: "account";
186
+ readonly type: "address";
187
+ }];
188
+ readonly outputs: readonly [];
189
+ }, {
190
+ readonly name: "ProofAnchored";
191
+ readonly type: "event";
192
+ readonly inputs: readonly [{
193
+ readonly name: "proofHash";
194
+ readonly type: "bytes32";
195
+ readonly indexed: true;
196
+ }, {
197
+ readonly name: "eventType";
198
+ readonly type: "uint8";
199
+ readonly indexed: true;
200
+ }, {
201
+ readonly name: "telikaId";
202
+ readonly type: "string";
203
+ readonly indexed: false;
204
+ }, {
205
+ readonly name: "timestamp";
206
+ readonly type: "uint256";
207
+ readonly indexed: false;
208
+ }, {
209
+ readonly name: "anchoredBy";
210
+ readonly type: "address";
211
+ readonly indexed: false;
212
+ }];
213
+ }];
214
+ //# sourceMappingURL=abi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abi.d.ts","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqJ1B,CAAC"}
package/dist/abi.js ADDED
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ /**
3
+ * TelikaVerification Contract ABI
4
+ *
5
+ * Minimal ABI containing only the functions and events needed by the SDK.
6
+ * This avoids requiring the full contract artifacts as a dependency.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.TELIKA_VERIFICATION_ABI = void 0;
10
+ exports.TELIKA_VERIFICATION_ABI = [
11
+ // =========================================================================
12
+ // Write Functions
13
+ // =========================================================================
14
+ {
15
+ name: "anchorProof",
16
+ type: "function",
17
+ stateMutability: "nonpayable",
18
+ inputs: [
19
+ { name: "proofHash", type: "bytes32" },
20
+ { name: "eventType", type: "uint8" },
21
+ { name: "telikaId", type: "string" },
22
+ { name: "metadata", type: "string" },
23
+ ],
24
+ outputs: [],
25
+ },
26
+ // =========================================================================
27
+ // Read Functions
28
+ // =========================================================================
29
+ {
30
+ name: "verifyProof",
31
+ type: "function",
32
+ stateMutability: "view",
33
+ inputs: [{ name: "proofHash", type: "bytes32" }],
34
+ outputs: [
35
+ { name: "exists", type: "bool" },
36
+ {
37
+ name: "record",
38
+ type: "tuple",
39
+ components: [
40
+ { name: "proofHash", type: "bytes32" },
41
+ { name: "eventType", type: "uint8" },
42
+ { name: "telikaId", type: "string" },
43
+ { name: "timestamp", type: "uint256" },
44
+ { name: "metadata", type: "string" },
45
+ { name: "anchoredBy", type: "address" },
46
+ ],
47
+ },
48
+ ],
49
+ },
50
+ {
51
+ name: "getProofsByTelikaId",
52
+ type: "function",
53
+ stateMutability: "view",
54
+ inputs: [{ name: "telikaId", type: "string" }],
55
+ outputs: [{ name: "proofHashes", type: "bytes32[]" }],
56
+ },
57
+ {
58
+ name: "getProofCount",
59
+ type: "function",
60
+ stateMutability: "view",
61
+ inputs: [{ name: "telikaId", type: "string" }],
62
+ outputs: [{ name: "count", type: "uint256" }],
63
+ },
64
+ {
65
+ name: "getProof",
66
+ type: "function",
67
+ stateMutability: "view",
68
+ inputs: [{ name: "proofHash", type: "bytes32" }],
69
+ outputs: [
70
+ {
71
+ name: "record",
72
+ type: "tuple",
73
+ components: [
74
+ { name: "proofHash", type: "bytes32" },
75
+ { name: "eventType", type: "uint8" },
76
+ { name: "telikaId", type: "string" },
77
+ { name: "timestamp", type: "uint256" },
78
+ { name: "metadata", type: "string" },
79
+ { name: "anchoredBy", type: "address" },
80
+ ],
81
+ },
82
+ ],
83
+ },
84
+ {
85
+ name: "getProofsByTelikaIdPaginated",
86
+ type: "function",
87
+ stateMutability: "view",
88
+ inputs: [
89
+ { name: "telikaId", type: "string" },
90
+ { name: "offset", type: "uint256" },
91
+ { name: "limit", type: "uint256" },
92
+ ],
93
+ outputs: [{ name: "proofHashes", type: "bytes32[]" }],
94
+ },
95
+ {
96
+ name: "totalProofs",
97
+ type: "function",
98
+ stateMutability: "view",
99
+ inputs: [],
100
+ outputs: [{ name: "", type: "uint256" }],
101
+ },
102
+ // =========================================================================
103
+ // Access Control
104
+ // =========================================================================
105
+ {
106
+ name: "ANCHOR_ROLE",
107
+ type: "function",
108
+ stateMutability: "view",
109
+ inputs: [],
110
+ outputs: [{ name: "", type: "bytes32" }],
111
+ },
112
+ {
113
+ name: "hasRole",
114
+ type: "function",
115
+ stateMutability: "view",
116
+ inputs: [
117
+ { name: "role", type: "bytes32" },
118
+ { name: "account", type: "address" },
119
+ ],
120
+ outputs: [{ name: "", type: "bool" }],
121
+ },
122
+ {
123
+ name: "grantRole",
124
+ type: "function",
125
+ stateMutability: "nonpayable",
126
+ inputs: [
127
+ { name: "role", type: "bytes32" },
128
+ { name: "account", type: "address" },
129
+ ],
130
+ outputs: [],
131
+ },
132
+ {
133
+ name: "revokeRole",
134
+ type: "function",
135
+ stateMutability: "nonpayable",
136
+ inputs: [
137
+ { name: "role", type: "bytes32" },
138
+ { name: "account", type: "address" },
139
+ ],
140
+ outputs: [],
141
+ },
142
+ // =========================================================================
143
+ // Events
144
+ // =========================================================================
145
+ {
146
+ name: "ProofAnchored",
147
+ type: "event",
148
+ inputs: [
149
+ { name: "proofHash", type: "bytes32", indexed: true },
150
+ { name: "eventType", type: "uint8", indexed: true },
151
+ { name: "telikaId", type: "string", indexed: false },
152
+ { name: "timestamp", type: "uint256", indexed: false },
153
+ { name: "anchoredBy", type: "address", indexed: false },
154
+ ],
155
+ },
156
+ ];
157
+ //# sourceMappingURL=abi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abi.js","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,uBAAuB,GAAG;IACrC,4EAA4E;IAC5E,kBAAkB;IAClB,4EAA4E;IAC5E;QACE,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;YACtC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE;YACpC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE;YACpC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE;SACrC;QACD,OAAO,EAAE,EAAE;KACZ;IAED,4EAA4E;IAC5E,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E,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;YACnD,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE;YACpD,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;YACtD,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;SACxD;KACF;CACO,CAAC"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Telika Blockchain Client
3
+ *
4
+ * Provides a high-level API for interacting with the TelikaVerification smart contract
5
+ * on the Polygon network. Handles transaction signing, gas estimation, event monitoring,
6
+ * and read/write operations.
7
+ *
8
+ * Usage:
9
+ * // Read-only client (no private key needed)
10
+ * const reader = new TelikaBlockchainClient({
11
+ * rpcUrl: "https://polygon-amoy.g.alchemy.com/v2/KEY",
12
+ * contractAddress: "0x...",
13
+ * });
14
+ *
15
+ * // Read-write client (private key required for anchoring)
16
+ * const writer = new TelikaBlockchainClient({
17
+ * rpcUrl: "https://polygon-amoy.g.alchemy.com/v2/KEY",
18
+ * contractAddress: "0x...",
19
+ * privateKey: "0x...",
20
+ * });
21
+ */
22
+ import { ContractTransactionResponse } from "ethers";
23
+ import { TelikaClientConfig, EventType, ProofRecord, VerificationResult, ProofMetadata } from "./types";
24
+ export declare class TelikaBlockchainClient {
25
+ private provider;
26
+ private contract;
27
+ private signer?;
28
+ private config;
29
+ constructor(config: TelikaClientConfig);
30
+ /**
31
+ * Anchor a cryptographic proof on-chain.
32
+ *
33
+ * @param proofHash - The keccak256 hash of the verification event data (from proof-generator)
34
+ * @param eventType - The type of verification event
35
+ * @param telikaId - The unique Telika identifier
36
+ * @param metadata - Non-sensitive metadata to store alongside the proof
37
+ * @returns Transaction response with hash and wait() method
38
+ * @throws Error if no signer is configured
39
+ */
40
+ anchorProof(proofHash: string, eventType: EventType, telikaId: string, metadata: ProofMetadata | string): Promise<ContractTransactionResponse>;
41
+ /**
42
+ * Anchor a proof and wait for transaction confirmation.
43
+ * Convenience wrapper around anchorProof() that waits for the receipt.
44
+ *
45
+ * @param proofHash - The keccak256 proof hash
46
+ * @param eventType - The event type
47
+ * @param telikaId - The Telika ID
48
+ * @param metadata - Proof metadata
49
+ * @param confirmations - Number of confirmations to wait for (default: 1)
50
+ * @returns Object with transaction hash and block number
51
+ */
52
+ anchorProofAndWait(proofHash: string, eventType: EventType, telikaId: string, metadata: ProofMetadata | string, confirmations?: number): Promise<{
53
+ txHash: string;
54
+ blockNumber: number;
55
+ }>;
56
+ /**
57
+ * Verify whether a proof exists on-chain and retrieve its record.
58
+ *
59
+ * @param proofHash - The proof hash to verify
60
+ * @returns Verification result with existence flag and proof record
61
+ */
62
+ verifyProof(proofHash: string): Promise<VerificationResult>;
63
+ /**
64
+ * Get all proof hashes associated with a Telika ID.
65
+ *
66
+ * @param telikaId - The unique Telika identifier
67
+ * @returns Array of proof hash strings
68
+ */
69
+ getProofsByTelikaId(telikaId: string): Promise<string[]>;
70
+ /**
71
+ * Get all proof records for a Telika ID (fetches each proof's full record).
72
+ *
73
+ * @param telikaId - The unique Telika identifier
74
+ * @returns Array of full proof records
75
+ */
76
+ getFullProofsByTelikaId(telikaId: string): Promise<ProofRecord[]>;
77
+ /**
78
+ * Get the count of proofs for a Telika ID.
79
+ *
80
+ * @param telikaId - The unique Telika identifier
81
+ * @returns Number of proofs anchored for this ID
82
+ */
83
+ getProofCount(telikaId: string): Promise<number>;
84
+ /**
85
+ * Get the total number of proofs anchored across all Telika IDs.
86
+ */
87
+ getTotalProofs(): Promise<number>;
88
+ /**
89
+ * Get paginated proof hashes for a Telika ID.
90
+ *
91
+ * @param telikaId - The Telika ID to query
92
+ * @param offset - Starting index
93
+ * @param limit - Maximum number of results
94
+ * @returns Array of proof hashes
95
+ */
96
+ getProofsPaginated(telikaId: string, offset: number, limit: number): Promise<string[]>;
97
+ /**
98
+ * Listen for new ProofAnchored events.
99
+ *
100
+ * @param callback - Function called when a new proof is anchored
101
+ * @returns Cleanup function to stop listening
102
+ */
103
+ onProofAnchored(callback: (event: {
104
+ proofHash: string;
105
+ eventType: EventType;
106
+ telikaId: string;
107
+ timestamp: number;
108
+ anchoredBy: string;
109
+ }) => void): () => void;
110
+ /**
111
+ * Query historical ProofAnchored events.
112
+ *
113
+ * @param fromBlock - Starting block number (default: last 10000 blocks)
114
+ * @param toBlock - Ending block number (default: latest)
115
+ * @returns Array of proof anchored events
116
+ */
117
+ queryProofEvents(fromBlock?: number, toBlock?: number): Promise<Array<{
118
+ proofHash: string;
119
+ eventType: EventType;
120
+ telikaId: string;
121
+ timestamp: number;
122
+ anchoredBy: string;
123
+ blockNumber: number;
124
+ transactionHash: string;
125
+ }>>;
126
+ /**
127
+ * Check if an address has the ANCHOR_ROLE.
128
+ *
129
+ * @param address - The address to check
130
+ * @returns Whether the address can anchor proofs
131
+ */
132
+ hasAnchorRole(address: string): Promise<boolean>;
133
+ /**
134
+ * Grant ANCHOR_ROLE to an address (requires admin role).
135
+ *
136
+ * @param address - The address to grant the role to
137
+ * @returns Transaction response
138
+ */
139
+ grantAnchorRole(address: string): Promise<ContractTransactionResponse>;
140
+ /**
141
+ * Revoke ANCHOR_ROLE from an address (requires admin role).
142
+ *
143
+ * @param address - The address to revoke the role from
144
+ * @returns Transaction response
145
+ */
146
+ revokeAnchorRole(address: string): Promise<ContractTransactionResponse>;
147
+ /**
148
+ * Get the contract address.
149
+ */
150
+ getContractAddress(): string;
151
+ /**
152
+ * Get the current signer address (if configured).
153
+ */
154
+ getSignerAddress(): Promise<string | undefined>;
155
+ /**
156
+ * Get the current block number.
157
+ */
158
+ getBlockNumber(): Promise<number>;
159
+ /**
160
+ * Get the balance of the signer (in MATIC/ETH).
161
+ */
162
+ getSignerBalance(): Promise<string>;
163
+ private requireSigner;
164
+ private parseProofRecord;
165
+ }
166
+ //# sourceMappingURL=blockchain-client.d.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