@polymarket/relayer-client 0.0.1

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 (48) hide show
  1. package/README.md +1 -0
  2. package/dist/abis/erc20Abi.d.ts +38 -0
  3. package/dist/abis/erc20Abi.js +225 -0
  4. package/dist/abis/index.d.ts +5 -0
  5. package/dist/abis/index.js +8 -0
  6. package/dist/abis/multisend.d.ts +13 -0
  7. package/dist/abis/multisend.js +20 -0
  8. package/dist/abis/proxyFactory.d.ts +66 -0
  9. package/dist/abis/proxyFactory.js +322 -0
  10. package/dist/abis/safe.d.ts +35 -0
  11. package/dist/abis/safe.js +1141 -0
  12. package/dist/abis/safeFactory.d.ts +60 -0
  13. package/dist/abis/safeFactory.js +227 -0
  14. package/dist/auth/handler.d.ts +12 -0
  15. package/dist/auth/handler.js +62 -0
  16. package/dist/auth/index.d.ts +1 -0
  17. package/dist/auth/index.js +4 -0
  18. package/dist/builder/create.d.ts +4 -0
  19. package/dist/builder/create.js +55 -0
  20. package/dist/builder/index.d.ts +2 -0
  21. package/dist/builder/index.js +5 -0
  22. package/dist/builder/proxy.d.ts +4 -0
  23. package/dist/builder/proxy.js +88 -0
  24. package/dist/builder/safe.d.ts +4 -0
  25. package/dist/builder/safe.js +125 -0
  26. package/dist/builder/utils.d.ts +2 -0
  27. package/dist/builder/utils.js +12 -0
  28. package/dist/client.d.ts +21 -0
  29. package/dist/client.js +159 -0
  30. package/dist/constants/index.d.ts +6 -0
  31. package/dist/constants/index.js +9 -0
  32. package/dist/encode/index.d.ts +1 -0
  33. package/dist/encode/index.js +4 -0
  34. package/dist/encode/proxy.d.ts +2 -0
  35. package/dist/encode/proxy.js +9 -0
  36. package/dist/encode/safe.d.ts +2 -0
  37. package/dist/encode/safe.js +20 -0
  38. package/dist/encode/utils.d.ts +6 -0
  39. package/dist/encode/utils.js +47 -0
  40. package/dist/endpoints.d.ts +6 -0
  41. package/dist/endpoints.js +9 -0
  42. package/dist/http-helpers/index.d.ts +16 -0
  43. package/dist/http-helpers/index.js +58 -0
  44. package/dist/main.d.ts +1 -0
  45. package/dist/main.js +17 -0
  46. package/dist/types.d.ts +92 -0
  47. package/dist/types.js +21 -0
  48. package/package.json +47 -0
@@ -0,0 +1,21 @@
1
+ import { Wallet } from "@ethersproject/wallet";
2
+ import { JsonRpcSigner } from "@ethersproject/providers";
3
+ import { AddressPayload, AuthArgs, NoncePayload, ProxyTransaction, RelayPayload, SafeTransaction } from "./types";
4
+ export declare class RelayClient {
5
+ readonly relayerUrl: string;
6
+ readonly chainId: number;
7
+ readonly signer?: Wallet | JsonRpcSigner;
8
+ readonly wsRelayerUrl?: string;
9
+ private authHandler;
10
+ constructor(relayerUrl: string, chainId: number, authArgs: AuthArgs, signer?: Wallet | JsonRpcSigner, wsRelayerUrl?: string);
11
+ getOk(): Promise<any>;
12
+ getRelayAddress(): Promise<AddressPayload>;
13
+ getNonce(signerAddress: string, signerType: string): Promise<NoncePayload>;
14
+ getRelayPayload(signerAddress: string, signerType: string): Promise<RelayPayload>;
15
+ getTransaction(transactionId: string): Promise<RelayPayload>;
16
+ executeProxyTransactions(txns: ProxyTransaction[]): Promise<any>;
17
+ executeSafeTransactions(txns: SafeTransaction[]): Promise<any>;
18
+ deploySafe(): Promise<any>;
19
+ initializeWsConnection(transactionId?: string): Promise<void>;
20
+ private sendTransactionRequest;
21
+ }
package/dist/client.js ADDED
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RelayClient = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ethers_1 = require("ethers");
6
+ const ws_1 = require("ws");
7
+ const http_helpers_1 = require("./http-helpers");
8
+ const types_1 = require("./types");
9
+ const endpoints_1 = require("./endpoints");
10
+ const builder_1 = require("./builder");
11
+ const encode_1 = require("./encode");
12
+ const create_1 = require("./builder/create");
13
+ const auth_1 = require("./auth");
14
+ class RelayClient {
15
+ constructor(relayerUrl, chainId, authArgs, signer, wsRelayerUrl) {
16
+ this.relayerUrl = relayerUrl.endsWith("/") ? relayerUrl.slice(0, -1) : relayerUrl;
17
+ this.chainId = chainId;
18
+ this.authHandler = new auth_1.AuthHandler(authArgs);
19
+ if (signer !== undefined) {
20
+ this.signer = signer;
21
+ if (signer.provider == undefined) {
22
+ throw new Error("signer must have provider attached");
23
+ }
24
+ }
25
+ if (wsRelayerUrl !== undefined) {
26
+ this.wsRelayerUrl = wsRelayerUrl;
27
+ }
28
+ }
29
+ getOk() {
30
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
31
+ return http_helpers_1.get(`${this.relayerUrl}/`);
32
+ });
33
+ }
34
+ getRelayAddress() {
35
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
36
+ return http_helpers_1.get(`${this.relayerUrl}${endpoints_1.GET_ADDRESS}`, { headers: yield this.authHandler.getAuthHeader() });
37
+ });
38
+ }
39
+ getNonce(signerAddress, signerType) {
40
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
41
+ return http_helpers_1.get(`${this.relayerUrl}${endpoints_1.GET_NONCE}?address=${signerAddress}&type=${signerType}`, { headers: yield this.authHandler.getAuthHeader() });
42
+ });
43
+ }
44
+ getRelayPayload(signerAddress, signerType) {
45
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
46
+ return http_helpers_1.get(`${this.relayerUrl}${endpoints_1.GET_RELAY_PAYLOAD}?address=${signerAddress}&type=${signerType}`, { headers: yield this.authHandler.getAuthHeader() });
47
+ });
48
+ }
49
+ getTransaction(transactionId) {
50
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
51
+ return http_helpers_1.get(`${this.relayerUrl}${endpoints_1.GET_TRANSACTION}?id=${transactionId}`, { headers: yield this.authHandler.getAuthHeader() });
52
+ });
53
+ }
54
+ executeProxyTransactions(txns) {
55
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
56
+ if (this.signer == undefined) {
57
+ throw new Error("missing signer");
58
+ }
59
+ const start = Date.now();
60
+ const from = yield this.signer.getAddress();
61
+ const rp = yield this.getRelayPayload(from, types_1.TransactionType.PROXY);
62
+ const args = {
63
+ from: from,
64
+ gasPrice: "0",
65
+ data: encode_1.encodeProxyTransactionData(txns),
66
+ relay: rp.address,
67
+ nonce: rp.nonce,
68
+ };
69
+ const request = yield builder_1.buildProxyTransactionRequest(this.signer, args);
70
+ console.log(`Client side request creation took: ${(Date.now() - start) / 1000} seconds`);
71
+ return this.sendTransactionRequest(request);
72
+ });
73
+ }
74
+ executeSafeTransactions(txns) {
75
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
76
+ if (this.signer == undefined) {
77
+ throw new Error("missing signer");
78
+ }
79
+ const start = Date.now();
80
+ const from = yield this.signer.getAddress();
81
+ // Note: goes over the network
82
+ const noncePayload = yield this.getNonce(from, types_1.TransactionType.SAFE);
83
+ const args = {
84
+ transactions: txns,
85
+ from,
86
+ nonce: noncePayload.nonce,
87
+ chainId: this.chainId,
88
+ };
89
+ const request = yield builder_1.buildSafeTransactionRequest(this.signer, args);
90
+ console.log(`Client side request creation took: ${(Date.now() - start) / 1000} seconds`);
91
+ return this.sendTransactionRequest(request);
92
+ });
93
+ }
94
+ deploySafe() {
95
+ var _a;
96
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
97
+ if (this.signer == undefined) {
98
+ throw new Error("missing signer");
99
+ }
100
+ const start = Date.now();
101
+ const from = yield ((_a = this.signer) === null || _a === void 0 ? void 0 : _a.getAddress());
102
+ const args = {
103
+ from: from,
104
+ chainId: this.chainId,
105
+ paymentToken: ethers_1.ethers.constants.AddressZero,
106
+ payment: "0",
107
+ paymentReceiver: ethers_1.ethers.constants.AddressZero,
108
+ };
109
+ const request = yield create_1.buildSafeCreateTransactionRequest(this.signer, args);
110
+ console.log(`Client side request creation took: ${(Date.now() - start) / 1000} seconds`);
111
+ return this.sendTransactionRequest(request);
112
+ });
113
+ }
114
+ initializeWsConnection(transactionId) {
115
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
116
+ if (this.signer == undefined) {
117
+ throw new Error("missing signer");
118
+ }
119
+ if (this.wsRelayerUrl == undefined) {
120
+ throw new Error("missing websocket url");
121
+ }
122
+ const from = yield this.signer.getAddress();
123
+ const txns = [];
124
+ if (transactionId !== undefined) {
125
+ txns.push(transactionId);
126
+ }
127
+ const authCookies = yield this.authHandler.getPolymarketCookies();
128
+ const req = {
129
+ address: from,
130
+ transactions: txns,
131
+ cookies: authCookies,
132
+ };
133
+ const ws = new ws_1.WebSocket(`${this.wsRelayerUrl}${endpoints_1.WS_CONNECTION}`);
134
+ ws.on("open", function () {
135
+ ws.send(JSON.stringify(req));
136
+ setInterval(() => {
137
+ ws.send("PING");
138
+ }, 5000);
139
+ });
140
+ ws.onmessage = function (msg) {
141
+ console.log(`Received ws message:`);
142
+ console.log(msg.data);
143
+ };
144
+ ws.on("close", function (e) {
145
+ console.log("WS Connection closed, reason: " + e);
146
+ return;
147
+ });
148
+ });
149
+ }
150
+ sendTransactionRequest(req) {
151
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
152
+ return http_helpers_1.post(`${this.relayerUrl}${endpoints_1.SUBMIT_TRANSACTION}`, {
153
+ data: req,
154
+ headers: yield this.authHandler.getAuthHeader()
155
+ });
156
+ });
157
+ }
158
+ }
159
+ exports.RelayClient = RelayClient;
@@ -0,0 +1,6 @@
1
+ export declare const RELAY_HUB_ADDRESS = "0xD216153c06E857cD7f72665E0aF1d7D82172F494";
2
+ export declare const PROXY_WALLET_FACTORY_ADDRESS = "0xaB45c5A4B0c941a2F231C04C3f49182e1A254052";
3
+ export declare const SAFE_FACTORY_ADDRESS = "0xaacFeEa03eb1561C4e67d661e40682Bd20E3541b";
4
+ export declare const SAFE_MULTISEND_ADDRESS = "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761";
5
+ export declare const SAFE_INIT_CODE_HASH = "0x2bce2127ff07fb632d16c8347c4ebf501f4841168bed00d9e6ef715ddb6fcecf";
6
+ export declare const SAFE_FACTORY_NAME = "Polymarket Contract Proxy Factory";
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SAFE_FACTORY_NAME = exports.SAFE_INIT_CODE_HASH = exports.SAFE_MULTISEND_ADDRESS = exports.SAFE_FACTORY_ADDRESS = exports.PROXY_WALLET_FACTORY_ADDRESS = exports.RELAY_HUB_ADDRESS = void 0;
4
+ exports.RELAY_HUB_ADDRESS = "0xD216153c06E857cD7f72665E0aF1d7D82172F494";
5
+ exports.PROXY_WALLET_FACTORY_ADDRESS = "0xaB45c5A4B0c941a2F231C04C3f49182e1A254052";
6
+ exports.SAFE_FACTORY_ADDRESS = "0xaacFeEa03eb1561C4e67d661e40682Bd20E3541b";
7
+ exports.SAFE_MULTISEND_ADDRESS = "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761";
8
+ exports.SAFE_INIT_CODE_HASH = "0x2bce2127ff07fb632d16c8347c4ebf501f4841168bed00d9e6ef715ddb6fcecf";
9
+ exports.SAFE_FACTORY_NAME = "Polymarket Contract Proxy Factory";
@@ -0,0 +1 @@
1
+ export * from "./proxy";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./proxy"), exports);
@@ -0,0 +1,2 @@
1
+ import { ProxyTransaction } from "../types";
2
+ export declare const encodeProxyTransactionData: (txns: ProxyTransaction[]) => string;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeProxyTransactionData = void 0;
4
+ const utils_1 = require("ethers/lib/utils");
5
+ const abis_1 = require("../abis");
6
+ const factoryInterface = new utils_1.Interface(abis_1.proxyWalletFactory);
7
+ exports.encodeProxyTransactionData = (txns) => {
8
+ return factoryInterface.encodeFunctionData("proxy((uint8,address,uint256,bytes)[])", [txns]);
9
+ };
@@ -0,0 +1,2 @@
1
+ import { SafeTransaction } from "../types";
2
+ export declare const createSafeMultisendTransaction: (txns: SafeTransaction[]) => SafeTransaction;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSafeMultisendTransaction = void 0;
4
+ const utils_1 = require("ethers/lib/utils");
5
+ const constants_1 = require("../constants");
6
+ const abis_1 = require("../abis");
7
+ const types_1 = require("../types");
8
+ const utils_2 = require("./utils");
9
+ const multisendInterface = new utils_1.Interface(abis_1.multisendAbi);
10
+ exports.createSafeMultisendTransaction = (txns) => {
11
+ const data = multisendInterface.encodeFunctionData("multiSend", [
12
+ utils_2.joinHexData(txns.map(tx => utils_2.abiEncodePacked({ type: "uint8", value: tx.operation }, { type: "address", value: tx.to }, { type: "uint256", value: tx.value }, { type: "uint256", value: utils_2.getHexDataLength(tx.data) }, { type: "bytes", value: tx.data }))),
13
+ ]);
14
+ return {
15
+ to: constants_1.SAFE_MULTISEND_ADDRESS,
16
+ value: "0",
17
+ data: data,
18
+ operation: types_1.OperationType.DelegateCall,
19
+ };
20
+ };
@@ -0,0 +1,6 @@
1
+ export declare function joinHexData(hexData: string[]): string;
2
+ export declare function abiEncodePacked(...params: {
3
+ type: string;
4
+ value: any;
5
+ }[]): string;
6
+ export declare function getHexDataLength(hexData: string): number;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHexDataLength = exports.abiEncodePacked = exports.joinHexData = void 0;
4
+ const abi_1 = require("@ethersproject/abi");
5
+ function joinHexData(hexData) {
6
+ return `0x${hexData
7
+ .map((hex) => {
8
+ const stripped = hex.replace(/^0x/, '');
9
+ return stripped.length % 2 === 0 ? stripped : '0' + stripped;
10
+ })
11
+ .join('')}`;
12
+ }
13
+ exports.joinHexData = joinHexData;
14
+ function abiEncodePacked(...params) {
15
+ return joinHexData(params.map(({ type, value }) => {
16
+ const encoded = abi_1.defaultAbiCoder.encode([type], [value]);
17
+ if (type === 'bytes' || type === 'string') {
18
+ const bytesLength = parseInt(encoded.slice(66, 130), 16);
19
+ return encoded.slice(130, 130 + 2 * bytesLength);
20
+ }
21
+ let typeMatch = type.match(/^(?:u?int\d*|bytes\d+|address)\[\]$/);
22
+ if (typeMatch) {
23
+ return encoded.slice(130);
24
+ }
25
+ if (type.startsWith('bytes')) {
26
+ const bytesLength = parseInt(type.slice(5));
27
+ return encoded.slice(2, 2 + 2 * bytesLength);
28
+ }
29
+ typeMatch = type.match(/^u?int(\d*)$/);
30
+ if (typeMatch) {
31
+ if (typeMatch[1] !== '') {
32
+ const bytesLength = parseInt(typeMatch[1]) / 8;
33
+ return encoded.slice(-2 * bytesLength);
34
+ }
35
+ return encoded.slice(-64);
36
+ }
37
+ if (type === 'address') {
38
+ return encoded.slice(-40);
39
+ }
40
+ throw new Error(`unsupported type ${type}`);
41
+ }));
42
+ }
43
+ exports.abiEncodePacked = abiEncodePacked;
44
+ function getHexDataLength(hexData) {
45
+ return Math.ceil((hexData.startsWith("0x") ? hexData.length - 2 : hexData.length) / 2);
46
+ }
47
+ exports.getHexDataLength = getHexDataLength;
@@ -0,0 +1,6 @@
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";
6
+ export declare const WS_CONNECTION = "/ws";
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WS_CONNECTION = 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";
9
+ exports.WS_CONNECTION = "/ws";
@@ -0,0 +1,16 @@
1
+ import { AxiosRequestHeaders, 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 const request: (endpoint: string, method: Method, headers?: any, data?: any, params?: any) => Promise<any>;
7
+ export declare type QueryParams = Record<string, any>;
8
+ export interface RequestOptions {
9
+ headers?: AxiosRequestHeaders;
10
+ data?: any;
11
+ params?: QueryParams;
12
+ }
13
+ export declare const post: (endpoint: string, options?: RequestOptions | undefined) => Promise<any>;
14
+ export declare const raw_get: (endpoint: string, options?: RequestOptions | undefined) => Promise<any>;
15
+ export declare const get: (endpoint: string, options?: RequestOptions | undefined) => Promise<any>;
16
+ export declare const del: (endpoint: string, options?: RequestOptions | undefined) => Promise<any>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.del = exports.get = exports.raw_get = exports.post = exports.request = 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
+ exports.request = (endpoint, method, headers, data, params) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
11
+ var _a, _b, _c, _d;
12
+ try {
13
+ const response = yield axios_1.default({ method, url: endpoint, headers, data, params });
14
+ return response;
15
+ }
16
+ catch (err) {
17
+ if (axios_1.default.isAxiosError(err)) {
18
+ if (err.response) {
19
+ console.error("request error", {
20
+ error: "request error",
21
+ status: (_a = err.response) === null || _a === void 0 ? void 0 : _a.status,
22
+ statusText: (_b = err.response) === null || _b === void 0 ? void 0 : _b.statusText,
23
+ data: (_c = err.response) === null || _c === void 0 ? void 0 : _c.data,
24
+ });
25
+ return (_d = err.response) === null || _d === void 0 ? void 0 : _d.data;
26
+ }
27
+ else {
28
+ return { error: "connection error" };
29
+ }
30
+ }
31
+ return { error: err };
32
+ }
33
+ });
34
+ exports.post = (endpoint, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
35
+ const resp = yield exports.request(endpoint, exports.POST, options === null || options === void 0 ? void 0 : options.headers, options === null || options === void 0 ? void 0 : options.data, options === null || options === void 0 ? void 0 : options.params);
36
+ if ("error" in resp) {
37
+ throw new Error(resp);
38
+ }
39
+ return resp.data;
40
+ });
41
+ exports.raw_get = (endpoint, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
42
+ const resp = yield exports.request(endpoint, exports.GET, options === null || options === void 0 ? void 0 : options.headers, options === null || options === void 0 ? void 0 : options.data, options === null || options === void 0 ? void 0 : options.params);
43
+ if ("error" in resp) {
44
+ throw new Error(resp);
45
+ }
46
+ return resp;
47
+ });
48
+ exports.get = (endpoint, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
49
+ const resp = yield exports.raw_get(endpoint, options);
50
+ return resp.data;
51
+ });
52
+ exports.del = (endpoint, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
53
+ const resp = yield exports.request(endpoint, exports.DELETE, options === null || options === void 0 ? void 0 : options.headers, options === null || options === void 0 ? void 0 : options.data, options === null || options === void 0 ? void 0 : options.params);
54
+ if ("error" in resp) {
55
+ throw new Error(resp);
56
+ }
57
+ return resp.data;
58
+ });
package/dist/main.d.ts ADDED
@@ -0,0 +1 @@
1
+ declare function main(): Promise<void>;
package/dist/main.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ function main() {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ console.log(`Started...`);
14
+ console.log(`Done!`);
15
+ });
16
+ }
17
+ main();
@@ -0,0 +1,92 @@
1
+ export declare enum TransactionType {
2
+ PROXY = "PROXY",
3
+ SAFE = "SAFE",
4
+ SAFE_CREATE = "SAFE-CREATE"
5
+ }
6
+ export interface SignatureParams {
7
+ gasPrice?: string;
8
+ relayerFee?: string;
9
+ gasLimit?: string;
10
+ relayHub?: string;
11
+ relay?: string;
12
+ operation?: string;
13
+ safeTxnGas?: string;
14
+ baseGas?: string;
15
+ gasToken?: string;
16
+ refundReceiver?: string;
17
+ paymentToken?: string;
18
+ payment?: string;
19
+ paymentReceiver?: string;
20
+ }
21
+ export interface AddressPayload {
22
+ address: string;
23
+ }
24
+ export interface NoncePayload {
25
+ nonce: string;
26
+ }
27
+ export interface RelayPayload {
28
+ address: string;
29
+ nonce: string;
30
+ }
31
+ export interface TransactionRequest {
32
+ type: string;
33
+ from: string;
34
+ to: string;
35
+ proxyWallet?: string;
36
+ data: string;
37
+ nonce?: string;
38
+ signature: string;
39
+ signatureParams: SignatureParams;
40
+ metadata?: string;
41
+ }
42
+ export declare enum CallType {
43
+ Invalid = "0",
44
+ Call = "1",
45
+ DelegateCall = "2"
46
+ }
47
+ export interface ProxyTransaction {
48
+ to: string;
49
+ typeCode: CallType;
50
+ data: string;
51
+ value: string;
52
+ }
53
+ export declare enum OperationType {
54
+ Call = 0,
55
+ DelegateCall = 1
56
+ }
57
+ export interface SafeTransaction {
58
+ to: string;
59
+ operation: OperationType;
60
+ data: string;
61
+ value: string;
62
+ }
63
+ export interface ProxyTransactionArgs {
64
+ from: string;
65
+ nonce: string;
66
+ gasPrice: string;
67
+ data: string;
68
+ relay: string;
69
+ }
70
+ export interface SafeTransactionArgs {
71
+ from: string;
72
+ nonce: string;
73
+ chainId: number;
74
+ transactions: SafeTransaction[];
75
+ }
76
+ export interface SafeCreateTransactionArgs {
77
+ from: string;
78
+ chainId: number;
79
+ paymentToken: string;
80
+ payment: string;
81
+ paymentReceiver: string;
82
+ }
83
+ export interface RelayerSubRequest {
84
+ address: string;
85
+ transactions: string[];
86
+ cookies?: string;
87
+ }
88
+ export interface AuthArgs {
89
+ authUrl: string;
90
+ token?: string;
91
+ cookie?: string;
92
+ }
package/dist/types.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OperationType = exports.CallType = exports.TransactionType = void 0;
4
+ var TransactionType;
5
+ (function (TransactionType) {
6
+ TransactionType["PROXY"] = "PROXY";
7
+ TransactionType["SAFE"] = "SAFE";
8
+ TransactionType["SAFE_CREATE"] = "SAFE-CREATE";
9
+ })(TransactionType = exports.TransactionType || (exports.TransactionType = {}));
10
+ var CallType;
11
+ (function (CallType) {
12
+ CallType["Invalid"] = "0";
13
+ CallType["Call"] = "1";
14
+ CallType["DelegateCall"] = "2";
15
+ })(CallType = exports.CallType || (exports.CallType = {}));
16
+ // Safe Transactions
17
+ var OperationType;
18
+ (function (OperationType) {
19
+ OperationType[OperationType["Call"] = 0] = "Call";
20
+ OperationType[OperationType["DelegateCall"] = 1] = "DelegateCall";
21
+ })(OperationType = exports.OperationType || (exports.OperationType = {}));
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@polymarket/relayer-client",
3
+ "description": "Client for Polymarket relayers",
4
+ "version": "0.0.1",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "/dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "yarn clean && tsc --project tsconfig.production.json",
12
+ "clean": "rm -rf ./dist"
13
+ },
14
+ "dependencies": {
15
+ "@polymarket/sdk": "^5.0.3",
16
+ "axios": "^0.27.2",
17
+ "ethers": "^5.7.1"
18
+ },
19
+ "devDependencies": {
20
+ "@types/chai": "^4.3.3",
21
+ "@types/mocha": "^9.1.1",
22
+ "@types/node": "^18.7.18",
23
+ "@types/ws": "^8.5.3",
24
+ "@typescript-eslint/eslint-plugin": "^5.37.0",
25
+ "@typescript-eslint/parser": "^5.37.0",
26
+ "chai": "^4.3.6",
27
+ "eslint": "^8.23.1",
28
+ "eslint-config-prettier": "^8.5.0",
29
+ "eslint-config-standard-with-typescript": "^23.0.0",
30
+ "eslint-plugin-import": "^2.26.0",
31
+ "eslint-plugin-n": "^15.2.5",
32
+ "eslint-plugin-node": "^11.1.0",
33
+ "eslint-plugin-promise": "^6.0.1",
34
+ "eslint-plugin-unused-imports": "^2.0.0",
35
+ "esm": "^3.2.25",
36
+ "dotenv": "^16.0.2",
37
+ "path": "^0.12.7",
38
+ "mocha": "^10.0.0",
39
+ "nyc": "^15.1.0",
40
+ "prettier": "^2.7.1",
41
+ "ts-mocha": "^10.0.0",
42
+ "ts-node": "^9.1.1",
43
+ "typescript": "^3.9.7",
44
+ "web3-utils": "^1.3.5",
45
+ "ws": "^8.11.0"
46
+ }
47
+ }