@polymarket/relayer-client 1.0.4 → 1.0.6

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
@@ -19,7 +19,7 @@ export declare class RelayClient {
19
19
  executeSafeTransactions(txns: SafeTransaction[]): Promise<RelayerTransactionResponse>;
20
20
  executeManualTransactions(txns: SafeTransaction[], overrides?: ManualOverrides): Promise<TransactionResponse>;
21
21
  deploySafe(): Promise<RelayerTransactionResponse>;
22
- pollUntilState(transactionId: string, states: string[], maxPolls?: number): Promise<RelayerTransaction | undefined>;
22
+ pollUntilState(transactionId: string, states: string[], maxPolls?: number, pollFrequency?: number): Promise<RelayerTransaction | undefined>;
23
23
  private submitTransaction;
24
24
  private send;
25
25
  }
package/dist/client.js CHANGED
@@ -12,6 +12,7 @@ const encode_1 = require("./encode");
12
12
  const auth_1 = require("./auth");
13
13
  const utils_1 = require("./utils");
14
14
  const manual_1 = require("./manual");
15
+ const response_1 = require("./response");
15
16
  class RelayClient {
16
17
  constructor(relayerUrl, chainId, signer, authArgs) {
17
18
  this.relayerUrl = relayerUrl.endsWith("/") ? relayerUrl.slice(0, -1) : relayerUrl;
@@ -69,7 +70,8 @@ class RelayClient {
69
70
  };
70
71
  const request = yield builder_1.buildProxyTransactionRequest(this.signer, args);
71
72
  console.log(`Client side proxy request creation took: ${(Date.now() - start) / 1000} seconds`);
72
- return this.submitTransaction(request);
73
+ const resp = yield this.submitTransaction(request);
74
+ return new response_1.ClientRelayerTransactionResponse(resp.transactionID, resp.state, this);
73
75
  });
74
76
  }
75
77
  executeSafeTransactions(txns) {
@@ -89,7 +91,8 @@ class RelayClient {
89
91
  };
90
92
  const request = yield builder_1.buildSafeTransactionRequest(this.signer, args);
91
93
  console.log(`Client side safe request creation took: ${(Date.now() - start) / 1000} seconds`);
92
- return this.submitTransaction(request);
94
+ const resp = yield this.submitTransaction(request);
95
+ return new response_1.ClientRelayerTransactionResponse(resp.transactionID, resp.state, this);
93
96
  });
94
97
  }
95
98
  executeManualTransactions(txns, overrides) {
@@ -120,16 +123,23 @@ class RelayClient {
120
123
  };
121
124
  const request = yield builder_1.buildSafeCreateTransactionRequest(this.signer, args);
122
125
  console.log(`Client side deploy request creation took: ${(Date.now() - start) / 1000} seconds`);
123
- return this.submitTransaction(request);
126
+ const resp = yield this.submitTransaction(request);
127
+ return new response_1.ClientRelayerTransactionResponse(resp.transactionID, resp.state, this);
124
128
  });
125
129
  }
126
130
  // Periodically polls the transaction id until it reaches a desired state
127
131
  // Returns the relayer transaction if it does each the desired state
128
132
  // Times out after 10s
129
- pollUntilState(transactionId, states, maxPolls) {
133
+ pollUntilState(transactionId, states, maxPolls, pollFrequency) {
130
134
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
131
135
  console.log(`Waiting for transaction ${transactionId} matching states: ${states}...`);
132
136
  const maxPollCount = maxPolls != undefined ? maxPolls : 10;
137
+ let pollFreq = 2000; // Default to polling every 2 seconds
138
+ if (pollFrequency != undefined) {
139
+ if (pollFrequency >= 1000) {
140
+ pollFreq = pollFrequency;
141
+ }
142
+ }
133
143
  let pollCount = 0;
134
144
  while (pollCount < maxPollCount) {
135
145
  const txns = yield this.getTransaction(transactionId);
@@ -140,7 +150,7 @@ class RelayClient {
140
150
  }
141
151
  }
142
152
  pollCount++;
143
- yield utils_1.sleep(1000);
153
+ yield utils_1.sleep(pollFreq);
144
154
  }
145
155
  console.log(`Transaction not found or not in given states, timing out`);
146
156
  });
@@ -0,0 +1,9 @@
1
+ import { RelayClient } from "../client";
2
+ import { RelayerTransactionResponse } from "../types";
3
+ export declare class ClientRelayerTransactionResponse implements RelayerTransactionResponse {
4
+ readonly client: RelayClient;
5
+ readonly transactionID: string;
6
+ readonly state: string;
7
+ constructor(transactionID: string, state: string, client: RelayClient);
8
+ wait(): Promise<boolean>;
9
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientRelayerTransactionResponse = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const types_1 = require("../types");
6
+ class ClientRelayerTransactionResponse {
7
+ constructor(transactionID, state, client) {
8
+ this.transactionID = transactionID;
9
+ this.state = state;
10
+ this.client = client;
11
+ }
12
+ wait() {
13
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
14
+ const txn = yield this.client.pollUntilState(this.transactionID, [
15
+ types_1.RelayerTransactionState.STATE_MINED,
16
+ types_1.RelayerTransactionState.STATE_CONFIRMED,
17
+ ], 30);
18
+ if (txn == undefined) {
19
+ return false;
20
+ }
21
+ return true;
22
+ });
23
+ }
24
+ }
25
+ exports.ClientRelayerTransactionResponse = ClientRelayerTransactionResponse;
package/dist/types.d.ts CHANGED
@@ -92,6 +92,7 @@ export declare enum RelayerTransactionState {
92
92
  export interface RelayerTransactionResponse {
93
93
  transactionID: string;
94
94
  state: string;
95
+ wait: () => Promise<boolean>;
95
96
  }
96
97
  export interface RelayerSubRequest {
97
98
  address: string;
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": "1.0.4",
4
+ "version": "1.0.6",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [