@polymarket/relayer-client 2.0.0 → 2.0.2
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 +3 -1
- package/dist/client.js +7 -1
- package/dist/response/index.js +1 -2
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -26,14 +26,16 @@ export declare class RelayClient {
|
|
|
26
26
|
/**
|
|
27
27
|
* Periodically polls the transaction id until it reaches a desired state
|
|
28
28
|
* Returns the relayer transaction if it does each the desired state
|
|
29
|
+
* Returns undefined if the transaction hits the failed state
|
|
29
30
|
* Times out after maxPolls is reached
|
|
30
31
|
* @param transactionId
|
|
31
32
|
* @param states
|
|
33
|
+
* @param failState
|
|
32
34
|
* @param maxPolls
|
|
33
35
|
* @param pollFrequency
|
|
34
36
|
* @returns
|
|
35
37
|
*/
|
|
36
|
-
pollUntilState(transactionId: string, states: string[], maxPolls?: number, pollFrequency?: number): Promise<RelayerTransaction | undefined>;
|
|
38
|
+
pollUntilState(transactionId: string, states: string[], failState?: string, maxPolls?: number, pollFrequency?: number): Promise<RelayerTransaction | undefined>;
|
|
37
39
|
private submitTransaction;
|
|
38
40
|
private send;
|
|
39
41
|
}
|
package/dist/client.js
CHANGED
|
@@ -119,14 +119,16 @@ class RelayClient {
|
|
|
119
119
|
/**
|
|
120
120
|
* Periodically polls the transaction id until it reaches a desired state
|
|
121
121
|
* Returns the relayer transaction if it does each the desired state
|
|
122
|
+
* Returns undefined if the transaction hits the failed state
|
|
122
123
|
* Times out after maxPolls is reached
|
|
123
124
|
* @param transactionId
|
|
124
125
|
* @param states
|
|
126
|
+
* @param failState
|
|
125
127
|
* @param maxPolls
|
|
126
128
|
* @param pollFrequency
|
|
127
129
|
* @returns
|
|
128
130
|
*/
|
|
129
|
-
async pollUntilState(transactionId, states, maxPolls, pollFrequency) {
|
|
131
|
+
async pollUntilState(transactionId, states, failState, maxPolls, pollFrequency) {
|
|
130
132
|
console.log(`Waiting for transaction ${transactionId} matching states: ${states}...`);
|
|
131
133
|
const maxPollCount = maxPolls != undefined ? maxPolls : 10;
|
|
132
134
|
let pollFreq = 2000; // Default to polling every 2 seconds
|
|
@@ -143,6 +145,10 @@ class RelayClient {
|
|
|
143
145
|
if (states.includes(txn.state)) {
|
|
144
146
|
return txn;
|
|
145
147
|
}
|
|
148
|
+
if (failState != undefined && txn.state == failState) {
|
|
149
|
+
// Return undefined if txn reaches the fail state
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
146
152
|
}
|
|
147
153
|
pollCount++;
|
|
148
154
|
await (0, utils_1.sleep)(pollFreq);
|
package/dist/response/index.js
CHANGED
|
@@ -22,8 +22,7 @@ class ClientRelayerTransactionResponse {
|
|
|
22
22
|
return this.client.pollUntilState(this.transactionID, [
|
|
23
23
|
types_1.RelayerTransactionState.STATE_MINED,
|
|
24
24
|
types_1.RelayerTransactionState.STATE_CONFIRMED,
|
|
25
|
-
|
|
26
|
-
], 30);
|
|
25
|
+
], types_1.RelayerTransactionState.STATE_FAILED, 30);
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
exports.ClientRelayerTransactionResponse = ClientRelayerTransactionResponse;
|