@polymarket/relayer-client 1.0.3 → 1.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.
- package/dist/builder/index.d.ts +1 -0
- package/dist/builder/index.js +1 -0
- package/dist/builder/proxy.js +0 -1
- package/dist/builder/safe.d.ts +2 -1
- package/dist/builder/safe.js +2 -1
- package/dist/client.d.ts +4 -3
- package/dist/client.js +21 -4
- package/dist/encode/index.d.ts +2 -0
- package/dist/encode/index.js +2 -0
- package/dist/manual/index.d.ts +5 -0
- package/dist/manual/index.js +26 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.js +1 -0
- package/package.json +1 -1
package/dist/builder/index.d.ts
CHANGED
package/dist/builder/index.js
CHANGED
package/dist/builder/proxy.js
CHANGED
package/dist/builder/safe.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Wallet } from "@ethersproject/wallet";
|
|
2
2
|
import { JsonRpcSigner } from "@ethersproject/providers";
|
|
3
|
-
import { SafeTransactionArgs, TransactionRequest } from "../types";
|
|
3
|
+
import { SafeTransaction, SafeTransactionArgs, TransactionRequest } from "../types";
|
|
4
|
+
export declare function aggregateTransaction(txns: SafeTransaction[]): SafeTransaction;
|
|
4
5
|
export declare function buildSafeTransactionRequest(signer: Wallet | JsonRpcSigner, args: SafeTransactionArgs): Promise<TransactionRequest>;
|
package/dist/builder/safe.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildSafeTransactionRequest = void 0;
|
|
3
|
+
exports.buildSafeTransactionRequest = exports.aggregateTransaction = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
@@ -82,6 +82,7 @@ function aggregateTransaction(txns) {
|
|
|
82
82
|
}
|
|
83
83
|
return transaction;
|
|
84
84
|
}
|
|
85
|
+
exports.aggregateTransaction = aggregateTransaction;
|
|
85
86
|
function buildSafeTransactionRequest(signer, args) {
|
|
86
87
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
87
88
|
const transaction = aggregateTransaction(args.transactions);
|
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Wallet } from "@ethersproject/wallet";
|
|
2
|
-
import { JsonRpcSigner } from "@ethersproject/providers";
|
|
2
|
+
import { JsonRpcSigner, TransactionResponse } from "@ethersproject/providers";
|
|
3
3
|
import { HttpClient } from "./http-helpers";
|
|
4
|
-
import { AddressPayload, AuthArgs, NoncePayload, ProxyTransaction, RelayerTransaction, RelayerTransactionResponse, RelayPayload, SafeTransaction } from "./types";
|
|
4
|
+
import { AddressPayload, AuthArgs, ManualOverrides, NoncePayload, ProxyTransaction, RelayerTransaction, RelayerTransactionResponse, RelayPayload, SafeTransaction } from "./types";
|
|
5
5
|
import { AuthHandler } from "./auth";
|
|
6
6
|
export declare class RelayClient {
|
|
7
7
|
readonly relayerUrl: string;
|
|
@@ -17,8 +17,9 @@ export declare class RelayClient {
|
|
|
17
17
|
getTransactions(): Promise<RelayerTransaction[]>;
|
|
18
18
|
executeProxyTransactions(txns: ProxyTransaction[]): Promise<RelayerTransactionResponse>;
|
|
19
19
|
executeSafeTransactions(txns: SafeTransaction[]): Promise<RelayerTransactionResponse>;
|
|
20
|
+
executeManualTransactions(txns: SafeTransaction[], overrides?: ManualOverrides): Promise<TransactionResponse>;
|
|
20
21
|
deploySafe(): Promise<RelayerTransactionResponse>;
|
|
21
|
-
pollUntilState(transactionId: string, states: string[], maxPolls?: number): Promise<RelayerTransaction | undefined>;
|
|
22
|
+
pollUntilState(transactionId: string, states: string[], maxPolls?: number, pollFrequency?: number): Promise<RelayerTransaction | undefined>;
|
|
22
23
|
private submitTransaction;
|
|
23
24
|
private send;
|
|
24
25
|
}
|
package/dist/client.js
CHANGED
|
@@ -9,9 +9,9 @@ const types_1 = require("./types");
|
|
|
9
9
|
const endpoints_1 = require("./endpoints");
|
|
10
10
|
const builder_1 = require("./builder");
|
|
11
11
|
const encode_1 = require("./encode");
|
|
12
|
-
const builder_2 = require("./builder");
|
|
13
12
|
const auth_1 = require("./auth");
|
|
14
13
|
const utils_1 = require("./utils");
|
|
14
|
+
const manual_1 = require("./manual");
|
|
15
15
|
class RelayClient {
|
|
16
16
|
constructor(relayerUrl, chainId, signer, authArgs) {
|
|
17
17
|
this.relayerUrl = relayerUrl.endsWith("/") ? relayerUrl.slice(0, -1) : relayerUrl;
|
|
@@ -92,6 +92,17 @@ class RelayClient {
|
|
|
92
92
|
return this.submitTransaction(request);
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
+
executeManualTransactions(txns, overrides) {
|
|
96
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
if (overrides == undefined) {
|
|
98
|
+
overrides = {};
|
|
99
|
+
}
|
|
100
|
+
if (this.signer == undefined) {
|
|
101
|
+
throw new Error("missing signer");
|
|
102
|
+
}
|
|
103
|
+
return manual_1.executeManualTransactions(this.signer, txns, overrides);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
95
106
|
deploySafe() {
|
|
96
107
|
var _a;
|
|
97
108
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -107,7 +118,7 @@ class RelayClient {
|
|
|
107
118
|
payment: "0",
|
|
108
119
|
paymentReceiver: ethers_1.ethers.constants.AddressZero,
|
|
109
120
|
};
|
|
110
|
-
const request = yield
|
|
121
|
+
const request = yield builder_1.buildSafeCreateTransactionRequest(this.signer, args);
|
|
111
122
|
console.log(`Client side deploy request creation took: ${(Date.now() - start) / 1000} seconds`);
|
|
112
123
|
return this.submitTransaction(request);
|
|
113
124
|
});
|
|
@@ -115,10 +126,16 @@ class RelayClient {
|
|
|
115
126
|
// Periodically polls the transaction id until it reaches a desired state
|
|
116
127
|
// Returns the relayer transaction if it does each the desired state
|
|
117
128
|
// Times out after 10s
|
|
118
|
-
pollUntilState(transactionId, states, maxPolls) {
|
|
129
|
+
pollUntilState(transactionId, states, maxPolls, pollFrequency) {
|
|
119
130
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
120
131
|
console.log(`Waiting for transaction ${transactionId} matching states: ${states}...`);
|
|
121
132
|
const maxPollCount = maxPolls != undefined ? maxPolls : 10;
|
|
133
|
+
let pollFreq = 2000; // Default to polling every 2 seconds
|
|
134
|
+
if (pollFrequency != undefined) {
|
|
135
|
+
if (pollFrequency >= 1000) {
|
|
136
|
+
pollFreq = pollFrequency;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
122
139
|
let pollCount = 0;
|
|
123
140
|
while (pollCount < maxPollCount) {
|
|
124
141
|
const txns = yield this.getTransaction(transactionId);
|
|
@@ -129,7 +146,7 @@ class RelayClient {
|
|
|
129
146
|
}
|
|
130
147
|
}
|
|
131
148
|
pollCount++;
|
|
132
|
-
yield utils_1.sleep(
|
|
149
|
+
yield utils_1.sleep(pollFreq);
|
|
133
150
|
}
|
|
134
151
|
console.log(`Transaction not found or not in given states, timing out`);
|
|
135
152
|
});
|
package/dist/encode/index.d.ts
CHANGED
package/dist/encode/index.js
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { JsonRpcSigner } from "@ethersproject/providers";
|
|
2
|
+
import { TransactionResponse } from "@ethersproject/abstract-provider";
|
|
3
|
+
import { Wallet } from "ethers";
|
|
4
|
+
import { SafeTransaction, ManualOverrides } from "../types";
|
|
5
|
+
export declare function executeManualTransactions(signer: Wallet | JsonRpcSigner, transactions: SafeTransaction[], overrides: ManualOverrides): Promise<TransactionResponse>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeManualTransactions = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ethers_1 = require("ethers");
|
|
6
|
+
const builder_1 = require("../builder");
|
|
7
|
+
const encode_1 = require("../encode");
|
|
8
|
+
const abis_1 = require("../abis");
|
|
9
|
+
function executeManualTransactions(signer, transactions, overrides) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const from = yield signer.getAddress();
|
|
12
|
+
const aggTxn = builder_1.aggregateTransaction(transactions);
|
|
13
|
+
const sig = encode_1.abiEncodePacked({ type: "uint256", value: from }, // r
|
|
14
|
+
{ type: "uint256", value: 0 }, // s
|
|
15
|
+
{ type: "uint8", value: 1 });
|
|
16
|
+
const safeAddress = builder_1.deriveSafe(from);
|
|
17
|
+
const safeContract = new ethers_1.ethers.Contract(safeAddress, abis_1.safeAbi, signer);
|
|
18
|
+
if (overrides.gasLimit == undefined) {
|
|
19
|
+
const gasLimit = yield safeContract.estimateGas.execTransaction(aggTxn.to, aggTxn.value, aggTxn.data, aggTxn.operation, 0, 0, 0, ethers_1.ethers.constants.AddressZero, ethers_1.ethers.constants.AddressZero, sig);
|
|
20
|
+
console.log(`Estimated gas Limit: ${gasLimit}`);
|
|
21
|
+
overrides.gasLimit = gasLimit;
|
|
22
|
+
}
|
|
23
|
+
return safeContract.execTransaction(aggTxn.to, aggTxn.value, aggTxn.data, aggTxn.operation, 0, 0, 0, ethers_1.ethers.constants.AddressZero, ethers_1.ethers.constants.AddressZero, sig, overrides);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.executeManualTransactions = executeManualTransactions;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BigNumberish } from "ethers";
|
|
1
2
|
export declare enum TransactionType {
|
|
2
3
|
PROXY = "PROXY",
|
|
3
4
|
SAFE = "SAFE",
|
|
@@ -116,3 +117,7 @@ export interface RelayerTransaction {
|
|
|
116
117
|
createdAt: Date;
|
|
117
118
|
updatedAt: Date;
|
|
118
119
|
}
|
|
120
|
+
export interface ManualOverrides {
|
|
121
|
+
gasLimit?: BigNumberish;
|
|
122
|
+
gasPrice?: BigNumberish;
|
|
123
|
+
}
|
package/dist/types.js
CHANGED