@polymarket/relayer-client 2.0.2 → 4.0.0

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.
Files changed (54) hide show
  1. package/README.md +7 -9
  2. package/package.json +13 -22
  3. package/dist/abis/erc20Abi.d.ts +0 -38
  4. package/dist/abis/erc20Abi.js +0 -225
  5. package/dist/abis/index.d.ts +0 -5
  6. package/dist/abis/index.js +0 -8
  7. package/dist/abis/multisend.d.ts +0 -13
  8. package/dist/abis/multisend.js +0 -20
  9. package/dist/abis/proxyFactory.d.ts +0 -66
  10. package/dist/abis/proxyFactory.js +0 -322
  11. package/dist/abis/safe.d.ts +0 -35
  12. package/dist/abis/safe.js +0 -1141
  13. package/dist/abis/safeFactory.d.ts +0 -60
  14. package/dist/abis/safeFactory.js +0 -227
  15. package/dist/auth/handler.d.ts +0 -15
  16. package/dist/auth/handler.js +0 -48
  17. package/dist/auth/index.d.ts +0 -1
  18. package/dist/auth/index.js +0 -4
  19. package/dist/builder/create.d.ts +0 -4
  20. package/dist/builder/create.js +0 -51
  21. package/dist/builder/derive.d.ts +0 -2
  22. package/dist/builder/derive.js +0 -21
  23. package/dist/builder/index.d.ts +0 -4
  24. package/dist/builder/index.js +0 -7
  25. package/dist/builder/proxy.d.ts +0 -4
  26. package/dist/builder/proxy.js +0 -73
  27. package/dist/builder/safe.d.ts +0 -5
  28. package/dist/builder/safe.js +0 -104
  29. package/dist/client.d.ts +0 -41
  30. package/dist/client.js +0 -178
  31. package/dist/config/index.d.ts +0 -13
  32. package/dist/config/index.js +0 -35
  33. package/dist/constants/index.d.ts +0 -3
  34. package/dist/constants/index.js +0 -6
  35. package/dist/encode/index.d.ts +0 -2
  36. package/dist/encode/index.js +0 -5
  37. package/dist/encode/proxy.d.ts +0 -2
  38. package/dist/encode/proxy.js +0 -15
  39. package/dist/encode/safe.d.ts +0 -2
  40. package/dist/encode/safe.js +0 -23
  41. package/dist/endpoints.d.ts +0 -5
  42. package/dist/endpoints.js +0 -8
  43. package/dist/http-helpers/index.d.ts +0 -10
  44. package/dist/http-helpers/index.js +0 -51
  45. package/dist/index.d.ts +0 -4
  46. package/dist/index.js +0 -7
  47. package/dist/manual/index.d.ts +0 -5
  48. package/dist/manual/index.js +0 -50
  49. package/dist/response/index.d.ts +0 -21
  50. package/dist/response/index.js +0 -42
  51. package/dist/types.d.ts +0 -132
  52. package/dist/types.js +0 -31
  53. package/dist/utils/index.d.ts +0 -7
  54. package/dist/utils/index.js +0 -34
package/dist/client.d.ts DELETED
@@ -1,41 +0,0 @@
1
- import { Wallet } from "@ethersproject/wallet";
2
- import { JsonRpcSigner } from "@ethersproject/providers";
3
- import { WalletClient } from "viem";
4
- import { IAbstractSigner } from "@polymarket/abstract-signer";
5
- import { HttpClient } from "./http-helpers";
6
- import { AddressPayload, AuthArgs, IManualTransactionResponse, ManualOverrides, NoncePayload, ProxyTransaction, RelayerTransaction, RelayerTransactionResponse, RelayPayload, SafeTransaction } from "./types";
7
- import { AuthHandler } from "./auth";
8
- import { ContractConfig } from "./config";
9
- export declare class RelayClient {
10
- readonly relayerUrl: string;
11
- readonly chainId: number;
12
- readonly contractConfig: ContractConfig;
13
- readonly httpClient: HttpClient;
14
- readonly signer?: IAbstractSigner;
15
- readonly authHandler?: AuthHandler;
16
- constructor(relayerUrl: string, chainId: number, signer?: Wallet | JsonRpcSigner | WalletClient, authArgs?: AuthArgs);
17
- getRelayAddress(): Promise<AddressPayload>;
18
- getNonce(signerAddress: string, signerType: string): Promise<NoncePayload>;
19
- getRelayPayload(signerAddress: string, signerType: string): Promise<RelayPayload>;
20
- getTransaction(transactionId: string): Promise<RelayerTransaction[]>;
21
- getTransactions(): Promise<RelayerTransaction[]>;
22
- executeProxyTransactions(txns: ProxyTransaction[], metadata?: string): Promise<RelayerTransactionResponse>;
23
- executeSafeTransactions(txns: SafeTransaction[], metadata?: string): Promise<RelayerTransactionResponse>;
24
- executeManualTransactions(txns: SafeTransaction[], overrides?: ManualOverrides): Promise<IManualTransactionResponse>;
25
- deploySafe(): Promise<RelayerTransactionResponse>;
26
- /**
27
- * Periodically polls the transaction id until it reaches a desired state
28
- * Returns the relayer transaction if it does each the desired state
29
- * Returns undefined if the transaction hits the failed state
30
- * Times out after maxPolls is reached
31
- * @param transactionId
32
- * @param states
33
- * @param failState
34
- * @param maxPolls
35
- * @param pollFrequency
36
- * @returns
37
- */
38
- pollUntilState(transactionId: string, states: string[], failState?: string, maxPolls?: number, pollFrequency?: number): Promise<RelayerTransaction | undefined>;
39
- private submitTransaction;
40
- private send;
41
- }
package/dist/client.js DELETED
@@ -1,178 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RelayClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const browser_or_node_1 = tslib_1.__importDefault(require("browser-or-node"));
6
- const viem_1 = require("viem");
7
- const abstract_signer_1 = require("@polymarket/abstract-signer");
8
- const http_helpers_1 = require("./http-helpers");
9
- const types_1 = require("./types");
10
- const endpoints_1 = require("./endpoints");
11
- const builder_1 = require("./builder");
12
- const encode_1 = require("./encode");
13
- const auth_1 = require("./auth");
14
- const utils_1 = require("./utils");
15
- const manual_1 = require("./manual");
16
- const response_1 = require("./response");
17
- const config_1 = require("./config");
18
- class RelayClient {
19
- relayerUrl;
20
- chainId;
21
- contractConfig;
22
- httpClient;
23
- signer;
24
- authHandler;
25
- constructor(relayerUrl, chainId, signer, authArgs) {
26
- this.relayerUrl = relayerUrl.endsWith("/") ? relayerUrl.slice(0, -1) : relayerUrl;
27
- this.chainId = chainId;
28
- this.contractConfig = (0, config_1.getContractConfig)(chainId);
29
- this.httpClient = new http_helpers_1.HttpClient();
30
- if (signer != undefined) {
31
- this.signer = (0, abstract_signer_1.createAbstractSigner)(chainId, signer);
32
- }
33
- if (authArgs !== undefined) {
34
- this.authHandler = new auth_1.AuthHandler(this.httpClient, authArgs);
35
- }
36
- }
37
- async getRelayAddress() {
38
- return this.send(`${this.relayerUrl}${endpoints_1.GET_ADDRESS}`, http_helpers_1.GET);
39
- }
40
- async getNonce(signerAddress, signerType) {
41
- return this.send(`${this.relayerUrl}${endpoints_1.GET_NONCE}?address=${signerAddress}&type=${signerType}`, http_helpers_1.GET);
42
- }
43
- async getRelayPayload(signerAddress, signerType) {
44
- return this.send(`${this.relayerUrl}${endpoints_1.GET_RELAY_PAYLOAD}?address=${signerAddress}&type=${signerType}`, http_helpers_1.GET);
45
- }
46
- async getTransaction(transactionId) {
47
- return this.send(`${this.relayerUrl}${endpoints_1.GET_TRANSACTION}?id=${transactionId}`, http_helpers_1.GET);
48
- }
49
- async getTransactions() {
50
- return this.send(`${this.relayerUrl}${endpoints_1.GET_TRANSACTION}s`, http_helpers_1.GET);
51
- }
52
- async executeProxyTransactions(txns, metadata) {
53
- if (this.signer == undefined) {
54
- throw new Error("missing signer");
55
- }
56
- const start = Date.now();
57
- const from = await this.signer.getAddress();
58
- const rp = await this.getRelayPayload(from, types_1.TransactionType.PROXY);
59
- const args = {
60
- from: from,
61
- gasPrice: "0",
62
- data: (0, encode_1.encodeProxyTransactionData)(txns),
63
- relay: rp.address,
64
- nonce: rp.nonce,
65
- };
66
- const proxyContractConfig = this.contractConfig.ProxyContracts;
67
- const request = await (0, builder_1.buildProxyTransactionRequest)(this.signer, args, proxyContractConfig, metadata);
68
- console.log(`Client side proxy request creation took: ${(Date.now() - start) / 1000} seconds`);
69
- const resp = await this.submitTransaction(request);
70
- return new response_1.ClientRelayerTransactionResponse(resp.transactionID, resp.state, resp.transactionHash, this);
71
- }
72
- async executeSafeTransactions(txns, metadata) {
73
- if (this.signer == undefined) {
74
- throw new Error("missing signer");
75
- }
76
- const start = Date.now();
77
- const from = await this.signer.getAddress();
78
- const noncePayload = await this.getNonce(from, types_1.TransactionType.SAFE);
79
- const args = {
80
- transactions: txns,
81
- from,
82
- nonce: noncePayload.nonce,
83
- chainId: this.chainId,
84
- };
85
- const safeContractConfig = this.contractConfig.SafeContracts;
86
- const request = await (0, builder_1.buildSafeTransactionRequest)(this.signer, args, safeContractConfig, metadata);
87
- console.log(`Client side safe request creation took: ${(Date.now() - start) / 1000} seconds`);
88
- const resp = await this.submitTransaction(request);
89
- return new response_1.ClientRelayerTransactionResponse(resp.transactionID, resp.state, resp.transactionHash, this);
90
- }
91
- async executeManualTransactions(txns, overrides) {
92
- if (overrides == undefined) {
93
- overrides = {};
94
- }
95
- if (this.signer == undefined) {
96
- throw new Error("missing signer");
97
- }
98
- return (0, manual_1.executeManualTransactions)(this.signer, this.contractConfig.SafeContracts, txns, overrides);
99
- }
100
- async deploySafe() {
101
- if (this.signer == undefined) {
102
- throw new Error("missing signer");
103
- }
104
- const start = Date.now();
105
- const from = await this.signer?.getAddress();
106
- const args = {
107
- from: from,
108
- chainId: this.chainId,
109
- paymentToken: viem_1.zeroAddress,
110
- payment: "0",
111
- paymentReceiver: viem_1.zeroAddress,
112
- };
113
- const safeContractConfig = this.contractConfig.SafeContracts;
114
- const request = await (0, builder_1.buildSafeCreateTransactionRequest)(this.signer, safeContractConfig, args);
115
- console.log(`Client side deploy request creation took: ${(Date.now() - start) / 1000} seconds`);
116
- const resp = await this.submitTransaction(request);
117
- return new response_1.ClientRelayerTransactionResponse(resp.transactionID, resp.state, resp.transactionHash, this);
118
- }
119
- /**
120
- * Periodically polls the transaction id until it reaches a desired state
121
- * Returns the relayer transaction if it does each the desired state
122
- * Returns undefined if the transaction hits the failed state
123
- * Times out after maxPolls is reached
124
- * @param transactionId
125
- * @param states
126
- * @param failState
127
- * @param maxPolls
128
- * @param pollFrequency
129
- * @returns
130
- */
131
- async pollUntilState(transactionId, states, failState, maxPolls, pollFrequency) {
132
- console.log(`Waiting for transaction ${transactionId} matching states: ${states}...`);
133
- const maxPollCount = maxPolls != undefined ? maxPolls : 10;
134
- let pollFreq = 2000; // Default to polling every 2 seconds
135
- if (pollFrequency != undefined) {
136
- if (pollFrequency >= 1000) {
137
- pollFreq = pollFrequency;
138
- }
139
- }
140
- let pollCount = 0;
141
- while (pollCount < maxPollCount) {
142
- const txns = await this.getTransaction(transactionId);
143
- if (txns.length > 0) {
144
- const txn = txns[0];
145
- if (states.includes(txn.state)) {
146
- return txn;
147
- }
148
- if (failState != undefined && txn.state == failState) {
149
- // Return undefined if txn reaches the fail state
150
- return undefined;
151
- }
152
- }
153
- pollCount++;
154
- await (0, utils_1.sleep)(pollFreq);
155
- }
156
- console.log(`Transaction not found or not in given states, timing out`);
157
- }
158
- async submitTransaction(req) {
159
- return this.send(`${this.relayerUrl}${endpoints_1.SUBMIT_TRANSACTION}`, http_helpers_1.POST, undefined, req);
160
- }
161
- async send(endpoint, method, headers, data, params) {
162
- // Explicitly inject the polymarket session cookies
163
- // In prod environments, this will be unnecessary as the browser will have the needed cookies
164
- // Needed only for local testing
165
- if (!browser_or_node_1.default && this.authHandler !== undefined) {
166
- const cookie = await this.authHandler.getPolymarketCookies();
167
- if (headers != undefined) {
168
- headers["Cookie"] = cookie;
169
- }
170
- else {
171
- headers = { "Cookie": cookie };
172
- }
173
- }
174
- const resp = await this.httpClient.send(endpoint, method, headers, data, params);
175
- return resp.data;
176
- }
177
- }
178
- exports.RelayClient = RelayClient;
@@ -1,13 +0,0 @@
1
- export interface ProxyContractConfig {
2
- RelayHub: string;
3
- ProxyFactory: string;
4
- }
5
- export interface SafeContractConfig {
6
- SafeFactory: string;
7
- SafeMultisend: string;
8
- }
9
- export interface ContractConfig {
10
- ProxyContracts: ProxyContractConfig;
11
- SafeContracts: SafeContractConfig;
12
- }
13
- export declare const getContractConfig: (chainId: number) => ContractConfig;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getContractConfig = void 0;
4
- ;
5
- const AMOY = {
6
- ProxyContracts: {
7
- ProxyFactory: "",
8
- RelayHub: ""
9
- },
10
- SafeContracts: {
11
- SafeFactory: "",
12
- SafeMultisend: "",
13
- }
14
- };
15
- const POL = {
16
- ProxyContracts: {
17
- ProxyFactory: "0xaB45c5A4B0c941a2F231C04C3f49182e1A254052",
18
- RelayHub: "0xD216153c06E857cD7f72665E0aF1d7D82172F494"
19
- },
20
- SafeContracts: {
21
- SafeFactory: "0xaacFeEa03eb1561C4e67d661e40682Bd20E3541b",
22
- SafeMultisend: "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761",
23
- }
24
- };
25
- const getContractConfig = (chainId) => {
26
- switch (chainId) {
27
- case 137:
28
- return POL;
29
- case 80002:
30
- return AMOY;
31
- default:
32
- throw new Error("Invalid network");
33
- }
34
- };
35
- exports.getContractConfig = getContractConfig;
@@ -1,3 +0,0 @@
1
- export declare const PROXY_INIT_CODE_HASH = "0xd21df8dc65880a8606f09fe0ce3df9b8869287ab0b058be05aa9e8af6330a00b";
2
- export declare const SAFE_INIT_CODE_HASH = "0x2bce2127ff07fb632d16c8347c4ebf501f4841168bed00d9e6ef715ddb6fcecf";
3
- export declare const SAFE_FACTORY_NAME = "Polymarket Contract Proxy Factory";
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SAFE_FACTORY_NAME = exports.SAFE_INIT_CODE_HASH = exports.PROXY_INIT_CODE_HASH = void 0;
4
- exports.PROXY_INIT_CODE_HASH = "0xd21df8dc65880a8606f09fe0ce3df9b8869287ab0b058be05aa9e8af6330a00b";
5
- exports.SAFE_INIT_CODE_HASH = "0x2bce2127ff07fb632d16c8347c4ebf501f4841168bed00d9e6ef715ddb6fcecf";
6
- exports.SAFE_FACTORY_NAME = "Polymarket Contract Proxy Factory";
@@ -1,2 +0,0 @@
1
- export * from "./proxy";
2
- export * from "./safe";
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./proxy"), exports);
5
- tslib_1.__exportStar(require("./safe"), exports);
@@ -1,2 +0,0 @@
1
- import { ProxyTransaction } from "../types";
2
- export declare function encodeProxyTransactionData(txns: ProxyTransaction[]): string;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encodeProxyTransactionData = encodeProxyTransactionData;
4
- const abis_1 = require("../abis");
5
- const viem_1 = require("viem");
6
- const proxy = (0, viem_1.prepareEncodeFunctionData)({
7
- abi: abis_1.proxyWalletFactory,
8
- functionName: 'proxy',
9
- });
10
- function encodeProxyTransactionData(txns) {
11
- return (0, viem_1.encodeFunctionData)({
12
- ...proxy,
13
- args: [txns],
14
- });
15
- }
@@ -1,2 +0,0 @@
1
- import { SafeTransaction } from "../types";
2
- export declare const createSafeMultisendTransaction: (txns: SafeTransaction[], safeMultisendAddress: string) => SafeTransaction;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSafeMultisendTransaction = void 0;
4
- const viem_1 = require("viem");
5
- const abis_1 = require("../abis");
6
- const types_1 = require("../types");
7
- const multisend = (0, viem_1.prepareEncodeFunctionData)({
8
- abi: abis_1.multisendAbi,
9
- functionName: "multiSend",
10
- });
11
- const createSafeMultisendTransaction = (txns, safeMultisendAddress) => {
12
- const args = [
13
- (0, viem_1.concatHex)(txns.map(tx => (0, viem_1.encodePacked)(["uint8", "address", "uint256", "uint256", "bytes"], [tx.operation, tx.to, BigInt(tx.value), BigInt((0, viem_1.size)(tx.data)), tx.data]))),
14
- ];
15
- const data = (0, viem_1.encodeFunctionData)({ ...multisend, args: args });
16
- return {
17
- to: safeMultisendAddress,
18
- value: "0",
19
- data: data,
20
- operation: types_1.OperationType.DelegateCall,
21
- };
22
- };
23
- exports.createSafeMultisendTransaction = createSafeMultisendTransaction;
@@ -1,5 +0,0 @@
1
- export declare const GET_ADDRESS = "/address";
2
- export declare const GET_NONCE = "/nonce";
3
- export declare const GET_RELAY_PAYLOAD = "/relay-payload";
4
- export declare const GET_TRANSACTION = "/transaction";
5
- export declare const SUBMIT_TRANSACTION = "/submit";
package/dist/endpoints.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SUBMIT_TRANSACTION = exports.GET_TRANSACTION = exports.GET_RELAY_PAYLOAD = exports.GET_NONCE = exports.GET_ADDRESS = void 0;
4
- exports.GET_ADDRESS = "/address";
5
- exports.GET_NONCE = "/nonce";
6
- exports.GET_RELAY_PAYLOAD = "/relay-payload";
7
- exports.GET_TRANSACTION = "/transaction";
8
- exports.SUBMIT_TRANSACTION = "/submit";
@@ -1,10 +0,0 @@
1
- import { AxiosInstance, AxiosResponse, Method } from "axios";
2
- export declare const GET = "GET";
3
- export declare const POST = "POST";
4
- export declare const DELETE = "DELETE";
5
- export declare const PUT = "PUT";
6
- export declare class HttpClient {
7
- readonly instance: AxiosInstance;
8
- constructor();
9
- send(endpoint: string, method: Method, headers?: any, data?: any, params?: any): Promise<AxiosResponse>;
10
- }
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpClient = exports.PUT = exports.DELETE = exports.POST = exports.GET = void 0;
4
- const tslib_1 = require("tslib");
5
- const axios_1 = tslib_1.__importDefault(require("axios"));
6
- exports.GET = "GET";
7
- exports.POST = "POST";
8
- exports.DELETE = "DELETE";
9
- exports.PUT = "PUT";
10
- class HttpClient {
11
- instance;
12
- constructor() {
13
- this.instance = axios_1.default.create({ withCredentials: true });
14
- }
15
- async send(endpoint, method, headers, data, params) {
16
- if (headers != undefined) {
17
- headers["Access-Control-Allow-Credentials"] = true;
18
- }
19
- try {
20
- const resp = await this.instance.request({
21
- method,
22
- url: endpoint,
23
- headers,
24
- data,
25
- params
26
- });
27
- return resp;
28
- }
29
- catch (err) {
30
- if (axios_1.default.isAxiosError(err)) {
31
- if (err.response) {
32
- const errPayload = {
33
- error: "request error",
34
- status: err.response?.status,
35
- statusText: err.response?.statusText,
36
- data: err.response?.data,
37
- };
38
- console.error("request error", errPayload);
39
- throw new Error(JSON.stringify(errPayload));
40
- }
41
- else {
42
- const errPayload = { error: "connection error" };
43
- console.error("connection error", errPayload);
44
- throw new Error(JSON.stringify(errPayload));
45
- }
46
- }
47
- throw new Error(JSON.stringify({ error: err }));
48
- }
49
- }
50
- }
51
- exports.HttpClient = HttpClient;
package/dist/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from "./client";
2
- export * from "./encode";
3
- export * from "./types";
4
- export * from "./response";
package/dist/index.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./client"), exports);
5
- tslib_1.__exportStar(require("./encode"), exports);
6
- tslib_1.__exportStar(require("./types"), exports);
7
- tslib_1.__exportStar(require("./response"), exports);
@@ -1,5 +0,0 @@
1
- import { IAbstractSigner } from "@polymarket/abstract-signer";
2
- import { SafeContractConfig } from "../config";
3
- import { SafeTransaction, ManualOverrides } from "../types";
4
- import { ManualTransactionResponse } from "../response";
5
- export declare function executeManualTransactions(signer: IAbstractSigner, safeContractConfig: SafeContractConfig, transactions: SafeTransaction[], overrides: ManualOverrides): Promise<ManualTransactionResponse>;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeManualTransactions = executeManualTransactions;
4
- const viem_1 = require("viem");
5
- const viem_2 = require("viem");
6
- const abis_1 = require("../abis");
7
- const builder_1 = require("../builder");
8
- const response_1 = require("../response");
9
- const safeExecTransaction = (0, viem_2.prepareEncodeFunctionData)({
10
- abi: abis_1.safeAbi,
11
- functionName: 'execTransaction',
12
- });
13
- async function executeManualTransactions(signer, safeContractConfig, transactions, overrides) {
14
- const from = await signer.getAddress();
15
- const aggTxn = (0, builder_1.aggregateTransaction)(transactions, safeContractConfig.SafeMultisend);
16
- const sig = (0, viem_1.encodePacked)(["uint256", "uint256", "uint8"], [BigInt((0, viem_1.hexToBigInt)(from)), BigInt(0), 1]);
17
- const safeAddress = (0, builder_1.deriveSafe)(from, safeContractConfig.SafeFactory);
18
- // calldata
19
- const data = (0, viem_2.encodeFunctionData)({ ...safeExecTransaction, args: [
20
- aggTxn.to,
21
- aggTxn.value,
22
- aggTxn.data,
23
- aggTxn.operation,
24
- 0,
25
- 0,
26
- 0,
27
- viem_1.zeroAddress,
28
- viem_1.zeroAddress,
29
- sig,
30
- ] });
31
- if (overrides.gasLimit == undefined) {
32
- const gasLimit = await signer.estimateGas({
33
- to: safeAddress,
34
- data: data,
35
- from: from,
36
- });
37
- console.log(`Estimated gas Limit: ${gasLimit}`);
38
- overrides.gasLimit = gasLimit;
39
- }
40
- const txHash = await signer.sendTransaction({
41
- data: data,
42
- to: safeAddress,
43
- gasPrice: overrides.gasPrice,
44
- gasLimit: overrides.gasLimit,
45
- });
46
- const waitFunc = (txHash) => {
47
- return signer.waitTillMined(txHash);
48
- };
49
- return new response_1.ManualTransactionResponse(txHash, waitFunc);
50
- }
@@ -1,21 +0,0 @@
1
- import { RelayClient } from "../client";
2
- import { IManualTransactionResponse, RelayerTransaction, RelayerTransactionResponse } from "../types";
3
- export declare class ClientRelayerTransactionResponse implements RelayerTransactionResponse {
4
- readonly client: RelayClient;
5
- readonly transactionID: string;
6
- readonly transactionHash: string;
7
- readonly hash: string;
8
- readonly state: string;
9
- constructor(transactionID: string, state: string, transactionHash: string, client: RelayClient);
10
- getTransaction(): Promise<RelayerTransaction[]>;
11
- wait(): Promise<RelayerTransaction | undefined>;
12
- }
13
- type WaitUntilMinedFunction = (transactionHash: string) => Promise<any>;
14
- export declare class ManualTransactionResponse implements IManualTransactionResponse {
15
- readonly hash: string;
16
- readonly transactionHash: string;
17
- private waitTillMined;
18
- constructor(transactionHash: string, waitTillMinedFunc: WaitUntilMinedFunction);
19
- wait(): Promise<any>;
20
- }
21
- export {};
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ManualTransactionResponse = exports.ClientRelayerTransactionResponse = void 0;
4
- const types_1 = require("../types");
5
- class ClientRelayerTransactionResponse {
6
- client;
7
- transactionID;
8
- transactionHash;
9
- hash;
10
- state;
11
- constructor(transactionID, state, transactionHash, client) {
12
- this.transactionID = transactionID;
13
- this.state = state;
14
- this.transactionHash = transactionHash;
15
- this.hash = transactionHash;
16
- this.client = client;
17
- }
18
- async getTransaction() {
19
- return this.client.getTransaction(this.transactionID);
20
- }
21
- async wait() {
22
- return this.client.pollUntilState(this.transactionID, [
23
- types_1.RelayerTransactionState.STATE_MINED,
24
- types_1.RelayerTransactionState.STATE_CONFIRMED,
25
- ], types_1.RelayerTransactionState.STATE_FAILED, 30);
26
- }
27
- }
28
- exports.ClientRelayerTransactionResponse = ClientRelayerTransactionResponse;
29
- class ManualTransactionResponse {
30
- hash;
31
- transactionHash;
32
- waitTillMined;
33
- constructor(transactionHash, waitTillMinedFunc) {
34
- this.transactionHash = transactionHash;
35
- this.hash = transactionHash;
36
- this.waitTillMined = waitTillMinedFunc;
37
- }
38
- async wait() {
39
- return this.waitTillMined(this.hash);
40
- }
41
- }
42
- exports.ManualTransactionResponse = ManualTransactionResponse;