@polymarket/relayer-client 1.0.9 → 1.0.11
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/proxy.d.ts +2 -2
- package/dist/builder/proxy.js +3 -2
- package/dist/client.d.ts +3 -2
- package/dist/client.js +14 -4
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/builder/proxy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Wallet } from "@ethersproject/wallet";
|
|
2
|
-
import { JsonRpcSigner } from "@ethersproject/providers";
|
|
2
|
+
import { JsonRpcSigner, Provider } from "@ethersproject/providers";
|
|
3
3
|
import { ProxyTransactionArgs, TransactionRequest } from "../types";
|
|
4
|
-
export declare function buildProxyTransactionRequest(signer: Wallet | JsonRpcSigner, args: ProxyTransactionArgs): Promise<TransactionRequest>;
|
|
4
|
+
export declare function buildProxyTransactionRequest(signer: Wallet | JsonRpcSigner, provider: Provider, args: ProxyTransactionArgs): Promise<TransactionRequest>;
|
package/dist/builder/proxy.js
CHANGED
|
@@ -49,13 +49,14 @@ function createProxySignature(signer, structHash) {
|
|
|
49
49
|
return signer.signMessage(utils_2.arrayify(structHash));
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
function buildProxyTransactionRequest(signer, args) {
|
|
52
|
+
function buildProxyTransactionRequest(signer, provider, args) {
|
|
53
53
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
54
|
const to = constants_1.PROXY_WALLET_FACTORY_ADDRESS;
|
|
55
55
|
const proxy = utils_1.deriveProxyWallet(args.from);
|
|
56
56
|
const relayerFee = "0";
|
|
57
57
|
const relayHub = constants_1.RELAY_HUB_ADDRESS;
|
|
58
|
-
const gasLimit = yield
|
|
58
|
+
const gasLimit = yield provider.estimateGas({
|
|
59
|
+
from: args.from,
|
|
59
60
|
to: to,
|
|
60
61
|
data: args.data,
|
|
61
62
|
});
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Wallet } from "@ethersproject/wallet";
|
|
2
|
-
import { JsonRpcSigner, TransactionResponse } from "@ethersproject/providers";
|
|
2
|
+
import { JsonRpcSigner, TransactionResponse, Provider } from "@ethersproject/providers";
|
|
3
3
|
import { HttpClient } from "./http-helpers";
|
|
4
4
|
import { AddressPayload, AuthArgs, ManualOverrides, NoncePayload, ProxyTransaction, RelayerTransaction, RelayerTransactionResponse, RelayPayload, SafeTransaction } from "./types";
|
|
5
5
|
import { AuthHandler } from "./auth";
|
|
@@ -8,8 +8,9 @@ export declare class RelayClient {
|
|
|
8
8
|
readonly chainId: number;
|
|
9
9
|
readonly httpClient: HttpClient;
|
|
10
10
|
readonly signer?: Wallet | JsonRpcSigner;
|
|
11
|
+
readonly provider?: Provider;
|
|
11
12
|
readonly authHandler?: AuthHandler;
|
|
12
|
-
constructor(relayerUrl: string, chainId: number, signer?: Wallet | JsonRpcSigner, authArgs?: AuthArgs);
|
|
13
|
+
constructor(relayerUrl: string, chainId: number, signer?: Wallet | JsonRpcSigner, provider?: Provider, authArgs?: AuthArgs);
|
|
13
14
|
getRelayAddress(): Promise<AddressPayload>;
|
|
14
15
|
getNonce(signerAddress: string, signerType: string): Promise<NoncePayload>;
|
|
15
16
|
getRelayPayload(signerAddress: string, signerType: string): Promise<RelayPayload>;
|
package/dist/client.js
CHANGED
|
@@ -14,15 +14,22 @@ const utils_1 = require("./utils");
|
|
|
14
14
|
const manual_1 = require("./manual");
|
|
15
15
|
const response_1 = require("./response");
|
|
16
16
|
class RelayClient {
|
|
17
|
-
constructor(relayerUrl, chainId, signer, authArgs) {
|
|
17
|
+
constructor(relayerUrl, chainId, signer, provider, authArgs) {
|
|
18
18
|
this.relayerUrl = relayerUrl.endsWith("/") ? relayerUrl.slice(0, -1) : relayerUrl;
|
|
19
19
|
this.chainId = chainId;
|
|
20
20
|
this.httpClient = new http_helpers_1.HttpClient();
|
|
21
|
-
|
|
21
|
+
// If the provider is not given, fetch the provider from the signer
|
|
22
|
+
if (provider != undefined) {
|
|
23
|
+
this.provider = provider;
|
|
24
|
+
}
|
|
25
|
+
if (signer != undefined) {
|
|
22
26
|
this.signer = signer;
|
|
23
|
-
if (signer.provider == undefined) {
|
|
27
|
+
if (signer.provider == undefined && this.provider == undefined) {
|
|
24
28
|
throw new Error("signer must have provider attached");
|
|
25
29
|
}
|
|
30
|
+
if (provider == undefined) {
|
|
31
|
+
this.provider = this.signer.provider;
|
|
32
|
+
}
|
|
26
33
|
}
|
|
27
34
|
if (authArgs !== undefined) {
|
|
28
35
|
this.authHandler = new auth_1.AuthHandler(this.httpClient, authArgs);
|
|
@@ -58,6 +65,9 @@ class RelayClient {
|
|
|
58
65
|
if (this.signer == undefined) {
|
|
59
66
|
throw new Error("missing signer");
|
|
60
67
|
}
|
|
68
|
+
if (this.provider == undefined) {
|
|
69
|
+
throw new Error("missing provider");
|
|
70
|
+
}
|
|
61
71
|
const start = Date.now();
|
|
62
72
|
const from = yield this.signer.getAddress();
|
|
63
73
|
const rp = yield this.getRelayPayload(from, types_1.TransactionType.PROXY);
|
|
@@ -68,7 +78,7 @@ class RelayClient {
|
|
|
68
78
|
relay: rp.address,
|
|
69
79
|
nonce: rp.nonce,
|
|
70
80
|
};
|
|
71
|
-
const request = yield builder_1.buildProxyTransactionRequest(this.signer, args);
|
|
81
|
+
const request = yield builder_1.buildProxyTransactionRequest(this.signer, this.provider, args);
|
|
72
82
|
console.log(`Client side proxy request creation took: ${(Date.now() - start) / 1000} seconds`);
|
|
73
83
|
const resp = yield this.submitTransaction(request);
|
|
74
84
|
return new response_1.ClientRelayerTransactionResponse(resp.transactionID, resp.state, resp.transactionHash, this);
|
package/dist/types.d.ts
CHANGED
|
@@ -116,6 +116,7 @@ export interface RelayerTransaction {
|
|
|
116
116
|
export interface RelayerTransactionResponse {
|
|
117
117
|
transactionID: string;
|
|
118
118
|
state: string;
|
|
119
|
+
hash: string;
|
|
119
120
|
transactionHash: string;
|
|
120
121
|
getTransaction: () => Promise<RelayerTransaction[]>;
|
|
121
122
|
wait: () => Promise<RelayerTransaction | undefined>;
|