@polymarket/relayer-client 2.0.1 → 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 +5 -3
- package/dist/client.js +8 -7
- package/dist/response/index.js +1 -2
- package/dist/types.d.ts +0 -3
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { JsonRpcSigner } from "@ethersproject/providers";
|
|
|
3
3
|
import { WalletClient } from "viem";
|
|
4
4
|
import { IAbstractSigner } from "@polymarket/abstract-signer";
|
|
5
5
|
import { HttpClient } from "./http-helpers";
|
|
6
|
-
import { AddressPayload, AuthArgs, IManualTransactionResponse, ManualOverrides, NoncePayload,
|
|
6
|
+
import { AddressPayload, AuthArgs, IManualTransactionResponse, ManualOverrides, NoncePayload, ProxyTransaction, RelayerTransaction, RelayerTransactionResponse, RelayPayload, SafeTransaction } from "./types";
|
|
7
7
|
import { AuthHandler } from "./auth";
|
|
8
8
|
import { ContractConfig } from "./config";
|
|
9
9
|
export declare class RelayClient {
|
|
@@ -19,21 +19,23 @@ export declare class RelayClient {
|
|
|
19
19
|
getRelayPayload(signerAddress: string, signerType: string): Promise<RelayPayload>;
|
|
20
20
|
getTransaction(transactionId: string): Promise<RelayerTransaction[]>;
|
|
21
21
|
getTransactions(): Promise<RelayerTransaction[]>;
|
|
22
|
-
executeProxyTransactions(txns: ProxyTransaction[], metadata?: string
|
|
22
|
+
executeProxyTransactions(txns: ProxyTransaction[], metadata?: string): Promise<RelayerTransactionResponse>;
|
|
23
23
|
executeSafeTransactions(txns: SafeTransaction[], metadata?: string): Promise<RelayerTransactionResponse>;
|
|
24
24
|
executeManualTransactions(txns: SafeTransaction[], overrides?: ManualOverrides): Promise<IManualTransactionResponse>;
|
|
25
25
|
deploySafe(): Promise<RelayerTransactionResponse>;
|
|
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
|
@@ -49,7 +49,7 @@ class RelayClient {
|
|
|
49
49
|
async getTransactions() {
|
|
50
50
|
return this.send(`${this.relayerUrl}${endpoints_1.GET_TRANSACTION}s`, http_helpers_1.GET);
|
|
51
51
|
}
|
|
52
|
-
async executeProxyTransactions(txns, metadata
|
|
52
|
+
async executeProxyTransactions(txns, metadata) {
|
|
53
53
|
if (this.signer == undefined) {
|
|
54
54
|
throw new Error("missing signer");
|
|
55
55
|
}
|
|
@@ -63,11 +63,6 @@ class RelayClient {
|
|
|
63
63
|
relay: rp.address,
|
|
64
64
|
nonce: rp.nonce,
|
|
65
65
|
};
|
|
66
|
-
let gasLimitStr = undefined;
|
|
67
|
-
if (overrides != undefined && overrides.gasLimit != undefined) {
|
|
68
|
-
gasLimitStr = overrides.gasLimit.toString();
|
|
69
|
-
}
|
|
70
|
-
args.gasLimit = gasLimitStr;
|
|
71
66
|
const proxyContractConfig = this.contractConfig.ProxyContracts;
|
|
72
67
|
const request = await (0, builder_1.buildProxyTransactionRequest)(this.signer, args, proxyContractConfig, metadata);
|
|
73
68
|
console.log(`Client side proxy request creation took: ${(Date.now() - start) / 1000} seconds`);
|
|
@@ -124,14 +119,16 @@ class RelayClient {
|
|
|
124
119
|
/**
|
|
125
120
|
* Periodically polls the transaction id until it reaches a desired state
|
|
126
121
|
* Returns the relayer transaction if it does each the desired state
|
|
122
|
+
* Returns undefined if the transaction hits the failed state
|
|
127
123
|
* Times out after maxPolls is reached
|
|
128
124
|
* @param transactionId
|
|
129
125
|
* @param states
|
|
126
|
+
* @param failState
|
|
130
127
|
* @param maxPolls
|
|
131
128
|
* @param pollFrequency
|
|
132
129
|
* @returns
|
|
133
130
|
*/
|
|
134
|
-
async pollUntilState(transactionId, states, maxPolls, pollFrequency) {
|
|
131
|
+
async pollUntilState(transactionId, states, failState, maxPolls, pollFrequency) {
|
|
135
132
|
console.log(`Waiting for transaction ${transactionId} matching states: ${states}...`);
|
|
136
133
|
const maxPollCount = maxPolls != undefined ? maxPolls : 10;
|
|
137
134
|
let pollFreq = 2000; // Default to polling every 2 seconds
|
|
@@ -148,6 +145,10 @@ class RelayClient {
|
|
|
148
145
|
if (states.includes(txn.state)) {
|
|
149
146
|
return txn;
|
|
150
147
|
}
|
|
148
|
+
if (failState != undefined && txn.state == failState) {
|
|
149
|
+
// Return undefined if txn reaches the fail state
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
151
152
|
}
|
|
152
153
|
pollCount++;
|
|
153
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;
|
package/dist/types.d.ts
CHANGED
|
@@ -126,9 +126,6 @@ export interface RelayerTransactionResponse {
|
|
|
126
126
|
getTransaction: () => Promise<RelayerTransaction[]>;
|
|
127
127
|
wait: () => Promise<RelayerTransaction | undefined>;
|
|
128
128
|
}
|
|
129
|
-
export interface Overrides {
|
|
130
|
-
gasLimit?: bigint;
|
|
131
|
-
}
|
|
132
129
|
export interface ManualOverrides {
|
|
133
130
|
gasLimit?: bigint;
|
|
134
131
|
gasPrice?: bigint;
|