@polymarket/relayer-client 0.0.11 → 0.0.13

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/dist/client.d.ts CHANGED
@@ -2,13 +2,14 @@ import { Wallet } from "@ethersproject/wallet";
2
2
  import { JsonRpcSigner } from "@ethersproject/providers";
3
3
  import { HttpClient } from "./http-helpers";
4
4
  import { AddressPayload, AuthArgs, NoncePayload, ProxyTransaction, RelayPayload, SafeTransaction } from "./types";
5
+ import { AuthHandler } from "./auth";
5
6
  export declare class RelayClient {
6
7
  readonly relayerUrl: string;
7
8
  readonly chainId: number;
8
9
  readonly httpClient: HttpClient;
9
- private authHandler;
10
10
  readonly signer?: Wallet | JsonRpcSigner;
11
- constructor(relayerUrl: string, chainId: number, authArgs: AuthArgs, signer?: Wallet | JsonRpcSigner);
11
+ readonly authHandler?: AuthHandler;
12
+ constructor(relayerUrl: string, chainId: number, signer?: Wallet | JsonRpcSigner, authArgs?: AuthArgs);
12
13
  getRelayAddress(): Promise<AddressPayload>;
13
14
  getNonce(signerAddress: string, signerType: string): Promise<NoncePayload>;
14
15
  getRelayPayload(signerAddress: string, signerType: string): Promise<RelayPayload>;
@@ -17,6 +18,6 @@ export declare class RelayClient {
17
18
  executeProxyTransactions(txns: ProxyTransaction[]): Promise<any>;
18
19
  executeSafeTransactions(txns: SafeTransaction[]): Promise<any>;
19
20
  deploySafe(): Promise<any>;
20
- private postTransactionRequest;
21
+ private post;
21
22
  private send;
22
23
  }
package/dist/client.js CHANGED
@@ -12,17 +12,19 @@ const encode_1 = require("./encode");
12
12
  const builder_2 = require("./builder");
13
13
  const auth_1 = require("./auth");
14
14
  class RelayClient {
15
- constructor(relayerUrl, chainId, authArgs, signer) {
15
+ constructor(relayerUrl, chainId, signer, authArgs) {
16
16
  this.relayerUrl = relayerUrl.endsWith("/") ? relayerUrl.slice(0, -1) : relayerUrl;
17
17
  this.chainId = chainId;
18
18
  this.httpClient = new http_helpers_1.HttpClient();
19
- this.authHandler = new auth_1.AuthHandler(this.httpClient, authArgs);
20
19
  if (signer !== undefined) {
21
20
  this.signer = signer;
22
21
  if (signer.provider == undefined) {
23
22
  throw new Error("signer must have provider attached");
24
23
  }
25
24
  }
25
+ if (authArgs !== undefined) {
26
+ this.authHandler = new auth_1.AuthHandler(this.httpClient, authArgs);
27
+ }
26
28
  }
27
29
  getRelayAddress() {
28
30
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -66,7 +68,7 @@ class RelayClient {
66
68
  };
67
69
  const request = yield builder_1.buildProxyTransactionRequest(this.signer, args);
68
70
  console.log(`Client side request creation took: ${(Date.now() - start) / 1000} seconds`);
69
- return this.postTransactionRequest(request);
71
+ return this.post(request);
70
72
  });
71
73
  }
72
74
  executeSafeTransactions(txns) {
@@ -86,7 +88,7 @@ class RelayClient {
86
88
  };
87
89
  const request = yield builder_1.buildSafeTransactionRequest(this.signer, args);
88
90
  console.log(`Client side request creation took: ${(Date.now() - start) / 1000} seconds`);
89
- return this.postTransactionRequest(request);
91
+ return this.post(request);
90
92
  });
91
93
  }
92
94
  deploySafe() {
@@ -106,10 +108,10 @@ class RelayClient {
106
108
  };
107
109
  const request = yield builder_2.buildSafeCreateTransactionRequest(this.signer, args);
108
110
  console.log(`Client side request creation took: ${(Date.now() - start) / 1000} seconds`);
109
- return this.postTransactionRequest(request);
111
+ return this.post(request);
110
112
  });
111
113
  }
112
- postTransactionRequest(req) {
114
+ post(req) {
113
115
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
114
116
  return this.send(`${this.relayerUrl}${endpoints_1.SUBMIT_TRANSACTION}`, http_helpers_1.POST, undefined, req);
115
117
  });
@@ -119,7 +121,7 @@ class RelayClient {
119
121
  // Explicitly inject the polymarket session cookies
120
122
  // In prod environments, this will be unnecessary as the browser will have the needed cookies
121
123
  // Needed only for local testing
122
- if (!browser_or_node_1.default) {
124
+ if (!browser_or_node_1.default && this.authHandler !== undefined) {
123
125
  const cookie = yield this.authHandler.getPolymarketCookies();
124
126
  if (headers != undefined) {
125
127
  headers["Cookie"] = cookie;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@polymarket/relayer-client",
3
3
  "description": "Client for Polymarket relayers",
4
- "version": "0.0.11",
4
+ "version": "0.0.13",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [