@polymarket/relayer-client 0.0.3 → 0.0.5

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.
@@ -1,5 +1,5 @@
1
1
  import { AxiosRequestHeaders } from "axios";
2
- import { AuthArgs } from "../../src/types";
2
+ import { AuthArgs } from "../types";
3
3
  export declare class AuthHandler {
4
4
  readonly url: string;
5
5
  readonly token?: string;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AuthHandler = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const http_helpers_1 = require("../../src/http-helpers");
5
+ const http_helpers_1 = require("../http-helpers");
6
6
  const POLYMARKET_COOKIE_NAME = "polymarket";
7
7
  class AuthHandler {
8
8
  constructor(args) {
package/dist/client.d.ts CHANGED
@@ -5,9 +5,8 @@ export declare class RelayClient {
5
5
  readonly relayerUrl: string;
6
6
  readonly chainId: number;
7
7
  readonly signer?: Wallet | JsonRpcSigner;
8
- readonly wsRelayerUrl?: string;
9
8
  private authHandler?;
10
- constructor(relayerUrl: string, chainId: number, authArgs?: AuthArgs, signer?: Wallet | JsonRpcSigner, wsRelayerUrl?: string);
9
+ constructor(relayerUrl: string, chainId: number, signer?: Wallet | JsonRpcSigner, authArgs?: AuthArgs);
11
10
  getOk(): Promise<any>;
12
11
  getRelayAddress(): Promise<AddressPayload>;
13
12
  getNonce(signerAddress: string, signerType: string): Promise<NoncePayload>;
@@ -16,7 +15,6 @@ export declare class RelayClient {
16
15
  executeProxyTransactions(txns: ProxyTransaction[]): Promise<any>;
17
16
  executeSafeTransactions(txns: SafeTransaction[]): Promise<any>;
18
17
  deploySafe(): Promise<any>;
19
- initializeWsConnection(transactionId?: string): Promise<void>;
20
18
  private postTransactionRequest;
21
19
  private send;
22
20
  }
package/dist/client.js CHANGED
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RelayClient = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const ethers_1 = require("ethers");
6
- const ws_1 = require("ws");
7
6
  const http_helpers_1 = require("./http-helpers");
8
7
  const types_1 = require("./types");
9
8
  const endpoints_1 = require("./endpoints");
@@ -12,20 +11,17 @@ const encode_1 = require("./encode");
12
11
  const create_1 = require("./builder/create");
13
12
  const auth_1 = require("./auth");
14
13
  class RelayClient {
15
- constructor(relayerUrl, chainId, authArgs, signer, wsRelayerUrl) {
14
+ constructor(relayerUrl, chainId, signer, authArgs) {
16
15
  this.relayerUrl = relayerUrl.endsWith("/") ? relayerUrl.slice(0, -1) : relayerUrl;
17
16
  this.chainId = chainId;
18
- if (authArgs !== undefined) {
19
- this.authHandler = new auth_1.AuthHandler(authArgs);
20
- }
21
17
  if (signer !== undefined) {
22
18
  this.signer = signer;
23
19
  if (signer.provider == undefined) {
24
20
  throw new Error("signer must have provider attached");
25
21
  }
26
22
  }
27
- if (wsRelayerUrl !== undefined) {
28
- this.wsRelayerUrl = wsRelayerUrl;
23
+ if (authArgs !== undefined) {
24
+ this.authHandler = new auth_1.AuthHandler(authArgs);
29
25
  }
30
26
  }
31
27
  getOk() {
@@ -113,45 +109,6 @@ class RelayClient {
113
109
  return this.postTransactionRequest(request);
114
110
  });
115
111
  }
116
- initializeWsConnection(transactionId) {
117
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
118
- if (this.signer == undefined) {
119
- throw new Error("missing signer");
120
- }
121
- if (this.authHandler == undefined) {
122
- throw new Error("missing auth handler");
123
- }
124
- if (this.wsRelayerUrl == undefined) {
125
- throw new Error("missing websocket url");
126
- }
127
- const from = yield this.signer.getAddress();
128
- const txns = [];
129
- if (transactionId !== undefined) {
130
- txns.push(transactionId);
131
- }
132
- const authCookies = yield this.authHandler.getPolymarketCookies();
133
- const req = {
134
- address: from,
135
- transactions: txns,
136
- cookies: authCookies,
137
- };
138
- const ws = new ws_1.WebSocket(`${this.wsRelayerUrl}${endpoints_1.WS_CONNECTION}`);
139
- ws.on("open", function () {
140
- ws.send(JSON.stringify(req));
141
- setInterval(() => {
142
- ws.send("PING");
143
- }, 5000);
144
- });
145
- ws.onmessage = function (msg) {
146
- console.log(`Received ws message:`);
147
- console.log(msg.data);
148
- };
149
- ws.on("close", function (e) {
150
- console.log("WS Connection closed, reason: " + e);
151
- return;
152
- });
153
- });
154
- }
155
112
  postTransactionRequest(req) {
156
113
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
157
114
  return this.send(`${this.relayerUrl}${endpoints_1.SUBMIT_TRANSACTION}`, http_helpers_1.POST, undefined, req);
@@ -3,4 +3,3 @@ export declare const GET_NONCE = "/nonce";
3
3
  export declare const GET_RELAY_PAYLOAD = "/relay-payload";
4
4
  export declare const GET_TRANSACTION = "/transaction";
5
5
  export declare const SUBMIT_TRANSACTION = "/submit";
6
- export declare const WS_CONNECTION = "/ws";
package/dist/endpoints.js CHANGED
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WS_CONNECTION = exports.SUBMIT_TRANSACTION = exports.GET_TRANSACTION = exports.GET_RELAY_PAYLOAD = exports.GET_NONCE = exports.GET_ADDRESS = void 0;
3
+ exports.SUBMIT_TRANSACTION = exports.GET_TRANSACTION = exports.GET_RELAY_PAYLOAD = exports.GET_NONCE = exports.GET_ADDRESS = void 0;
4
4
  exports.GET_ADDRESS = "/address";
5
5
  exports.GET_NONCE = "/nonce";
6
6
  exports.GET_RELAY_PAYLOAD = "/relay-payload";
7
7
  exports.GET_TRANSACTION = "/transaction";
8
8
  exports.SUBMIT_TRANSACTION = "/submit";
9
- exports.WS_CONNECTION = "/ws";
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.3",
4
+ "version": "0.0.5",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [