@polymarket/relayer-client 1.0.2 → 1.0.4
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 +3 -2
- package/dist/client.js +16 -5
- 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 +6 -1
- package/dist/types.js +2 -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,6 +17,7 @@ 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
22
|
pollUntilState(transactionId: string, states: string[], maxPolls?: number): Promise<RelayerTransaction | undefined>;
|
|
22
23
|
private submitTransaction;
|
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;
|
|
@@ -68,7 +68,7 @@ class RelayClient {
|
|
|
68
68
|
nonce: rp.nonce,
|
|
69
69
|
};
|
|
70
70
|
const request = yield builder_1.buildProxyTransactionRequest(this.signer, args);
|
|
71
|
-
console.log(`Client side request creation took: ${(Date.now() - start) / 1000} seconds`);
|
|
71
|
+
console.log(`Client side proxy request creation took: ${(Date.now() - start) / 1000} seconds`);
|
|
72
72
|
return this.submitTransaction(request);
|
|
73
73
|
});
|
|
74
74
|
}
|
|
@@ -88,10 +88,21 @@ class RelayClient {
|
|
|
88
88
|
chainId: this.chainId,
|
|
89
89
|
};
|
|
90
90
|
const request = yield builder_1.buildSafeTransactionRequest(this.signer, args);
|
|
91
|
-
console.log(`Client side request creation took: ${(Date.now() - start) / 1000} seconds`);
|
|
91
|
+
console.log(`Client side safe request creation took: ${(Date.now() - start) / 1000} seconds`);
|
|
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,8 +118,8 @@ class RelayClient {
|
|
|
107
118
|
payment: "0",
|
|
108
119
|
paymentReceiver: ethers_1.ethers.constants.AddressZero,
|
|
109
120
|
};
|
|
110
|
-
const request = yield
|
|
111
|
-
console.log(`Client side request creation took: ${(Date.now() - start) / 1000} seconds`);
|
|
121
|
+
const request = yield builder_1.buildSafeCreateTransactionRequest(this.signer, args);
|
|
122
|
+
console.log(`Client side deploy request creation took: ${(Date.now() - start) / 1000} seconds`);
|
|
112
123
|
return this.submitTransaction(request);
|
|
113
124
|
});
|
|
114
125
|
}
|
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",
|
|
@@ -83,13 +84,13 @@ export interface SafeCreateTransactionArgs {
|
|
|
83
84
|
export declare enum RelayerTransactionState {
|
|
84
85
|
STATE_NEW = "STATE_NEW",
|
|
85
86
|
STATE_EXECUTED = "STATE_EXECUTED",
|
|
87
|
+
STATE_MINED = "STATE_MINED",
|
|
86
88
|
STATE_INVALID = "STATE_INVALID",
|
|
87
89
|
STATE_CONFIRMED = "STATE_CONFIRMED",
|
|
88
90
|
STATE_FAILED = "STATE_FAILED"
|
|
89
91
|
}
|
|
90
92
|
export interface RelayerTransactionResponse {
|
|
91
93
|
transactionID: string;
|
|
92
|
-
transactionHash: string;
|
|
93
94
|
state: string;
|
|
94
95
|
}
|
|
95
96
|
export interface RelayerSubRequest {
|
|
@@ -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
|
@@ -23,7 +23,9 @@ var RelayerTransactionState;
|
|
|
23
23
|
(function (RelayerTransactionState) {
|
|
24
24
|
RelayerTransactionState["STATE_NEW"] = "STATE_NEW";
|
|
25
25
|
RelayerTransactionState["STATE_EXECUTED"] = "STATE_EXECUTED";
|
|
26
|
+
RelayerTransactionState["STATE_MINED"] = "STATE_MINED";
|
|
26
27
|
RelayerTransactionState["STATE_INVALID"] = "STATE_INVALID";
|
|
27
28
|
RelayerTransactionState["STATE_CONFIRMED"] = "STATE_CONFIRMED";
|
|
28
29
|
RelayerTransactionState["STATE_FAILED"] = "STATE_FAILED";
|
|
29
30
|
})(RelayerTransactionState = exports.RelayerTransactionState || (exports.RelayerTransactionState = {}));
|
|
31
|
+
;
|