@polymarket/relayer-client 2.0.1 → 3.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 (42) hide show
  1. package/dist/abis/erc20Abi.js +1 -4
  2. package/dist/abis/index.d.ts +5 -5
  3. package/dist/abis/index.js +5 -8
  4. package/dist/abis/multisend.js +1 -4
  5. package/dist/abis/proxyFactory.js +1 -4
  6. package/dist/abis/safe.js +1 -4
  7. package/dist/abis/safeFactory.js +1 -4
  8. package/dist/auth/handler.d.ts +2 -2
  9. package/dist/auth/handler.js +3 -7
  10. package/dist/auth/index.d.ts +1 -1
  11. package/dist/auth/index.js +1 -4
  12. package/dist/builder/create.d.ts +2 -2
  13. package/dist/builder/create.js +7 -10
  14. package/dist/builder/derive.js +10 -15
  15. package/dist/builder/index.d.ts +4 -4
  16. package/dist/builder/index.js +4 -7
  17. package/dist/builder/proxy.d.ts +2 -2
  18. package/dist/builder/proxy.js +13 -16
  19. package/dist/builder/safe.d.ts +2 -2
  20. package/dist/builder/safe.js +14 -18
  21. package/dist/client.d.ts +8 -6
  22. package/dist/client.js +46 -50
  23. package/dist/config/index.js +1 -5
  24. package/dist/constants/index.js +3 -6
  25. package/dist/encode/index.d.ts +2 -2
  26. package/dist/encode/index.js +2 -5
  27. package/dist/encode/proxy.d.ts +1 -1
  28. package/dist/encode/proxy.js +6 -9
  29. package/dist/encode/safe.d.ts +1 -1
  30. package/dist/encode/safe.js +9 -13
  31. package/dist/endpoints.js +5 -8
  32. package/dist/http-helpers/index.js +8 -13
  33. package/dist/index.d.ts +4 -4
  34. package/dist/index.js +4 -7
  35. package/dist/manual/index.d.ts +3 -3
  36. package/dist/manual/index.js +15 -18
  37. package/dist/response/index.d.ts +2 -2
  38. package/dist/response/index.js +6 -12
  39. package/dist/types.d.ts +0 -3
  40. package/dist/types.js +8 -11
  41. package/dist/utils/index.js +7 -11
  42. package/package.json +9 -5
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.erc20Abi = void 0;
4
- exports.erc20Abi = [
1
+ export const erc20Abi = [
5
2
  {
6
3
  "constant": true,
7
4
  "inputs": [],
@@ -1,5 +1,5 @@
1
- export * from "./safeFactory";
2
- export * from "./proxyFactory";
3
- export * from "./erc20Abi";
4
- export * from "./safe";
5
- export * from "./multisend";
1
+ export * from "./safeFactory.ts";
2
+ export * from "./proxyFactory.ts";
3
+ export * from "./erc20Abi.ts";
4
+ export * from "./safe.ts";
5
+ export * from "./multisend.ts";
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./safeFactory"), exports);
5
- tslib_1.__exportStar(require("./proxyFactory"), exports);
6
- tslib_1.__exportStar(require("./erc20Abi"), exports);
7
- tslib_1.__exportStar(require("./safe"), exports);
8
- tslib_1.__exportStar(require("./multisend"), exports);
1
+ export * from "./safeFactory.js";
2
+ export * from "./proxyFactory.js";
3
+ export * from "./erc20Abi.js";
4
+ export * from "./safe.js";
5
+ export * from "./multisend.js";
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.multisendAbi = void 0;
4
- exports.multisendAbi = [
1
+ export const multisendAbi = [
5
2
  {
6
3
  "constant": false,
7
4
  "inputs": [
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.proxyWalletFactory = void 0;
4
- exports.proxyWalletFactory = [
1
+ export const proxyWalletFactory = [
5
2
  {
6
3
  "constant": false,
7
4
  "inputs": [
package/dist/abis/safe.js CHANGED
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.safeAbi = void 0;
4
- exports.safeAbi = [
1
+ export const safeAbi = [
5
2
  {
6
3
  "anonymous": false,
7
4
  "inputs": [
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.safeFactoryAbi = void 0;
4
- exports.safeFactoryAbi = [
1
+ export const safeFactoryAbi = [
5
2
  {
6
3
  "inputs": [
7
4
  {
@@ -1,5 +1,5 @@
1
- import { HttpClient } from "../http-helpers";
2
- import { AuthArgs } from "../types";
1
+ import { HttpClient } from "../http-helpers/index.ts";
2
+ import { AuthArgs } from "../types.ts";
3
3
  export declare class AuthHandler {
4
4
  readonly url: string;
5
5
  readonly httpClient: HttpClient;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuthHandler = void 0;
4
- const http_helpers_1 = require("../http-helpers");
1
+ import { GET } from "../http-helpers/index.js";
5
2
  const POLYMARKET_COOKIE_NAME = "polymarket";
6
- class AuthHandler {
3
+ export class AuthHandler {
7
4
  url;
8
5
  httpClient;
9
6
  token;
@@ -23,7 +20,7 @@ class AuthHandler {
23
20
  async login() {
24
21
  if (this.cookie == undefined) {
25
22
  // Logging in will set the session cookies on the httpClient
26
- const resp = await this.httpClient.send(`${this.url}/login/internal`, http_helpers_1.GET, { Authorization: `Bearer ${this.token}` });
23
+ const resp = await this.httpClient.send(`${this.url}/login/internal`, GET, { Authorization: `Bearer ${this.token}` });
27
24
  const cookies = resp.headers['set-cookie'];
28
25
  let aggregatedCookie = "";
29
26
  for (const cookie of cookies) {
@@ -45,4 +42,3 @@ class AuthHandler {
45
42
  return this.cookie;
46
43
  }
47
44
  }
48
- exports.AuthHandler = AuthHandler;
@@ -1 +1 @@
1
- export * from "./handler";
1
+ export * from "./handler.ts";
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./handler"), exports);
1
+ export * from "./handler.js";
@@ -1,4 +1,4 @@
1
- import { SafeCreateTransactionArgs, TransactionRequest } from "../types";
1
+ import { SafeCreateTransactionArgs, TransactionRequest } from "../types.ts";
2
2
  import { IAbstractSigner } from "@polymarket/abstract-signer";
3
- import { SafeContractConfig } from "../config";
3
+ import { SafeContractConfig } from "../config/index.ts";
4
4
  export declare function buildSafeCreateTransactionRequest(signer: IAbstractSigner, safeContractConfig: SafeContractConfig, args: SafeCreateTransactionArgs): Promise<TransactionRequest>;
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildSafeCreateTransactionRequest = buildSafeCreateTransactionRequest;
4
- const types_1 = require("../types");
5
- const constants_1 = require("../constants");
6
- const derive_1 = require("./derive");
1
+ import { TransactionType } from "../types.js";
2
+ import { SAFE_FACTORY_NAME } from "../constants/index.js";
3
+ import { deriveSafe } from "./derive.js";
7
4
  async function createSafeCreateSignature(signer, safeFactory, chainId, paymentToken, payment, paymentReceiver) {
8
5
  const domain = {
9
- name: constants_1.SAFE_FACTORY_NAME,
6
+ name: SAFE_FACTORY_NAME,
10
7
  chainId: BigInt(chainId),
11
8
  verifyingContract: safeFactory,
12
9
  };
@@ -26,7 +23,7 @@ async function createSafeCreateSignature(signer, safeFactory, chainId, paymentTo
26
23
  console.log(`Sig: ${sig}`);
27
24
  return sig;
28
25
  }
29
- async function buildSafeCreateTransactionRequest(signer, safeContractConfig, args) {
26
+ export async function buildSafeCreateTransactionRequest(signer, safeContractConfig, args) {
30
27
  const safeFactory = safeContractConfig.SafeFactory;
31
28
  const sig = await createSafeCreateSignature(signer, safeFactory, args.chainId, args.paymentToken, args.payment, args.paymentReceiver);
32
29
  const sigParams = {
@@ -34,7 +31,7 @@ async function buildSafeCreateTransactionRequest(signer, safeContractConfig, arg
34
31
  payment: args.payment,
35
32
  paymentReceiver: args.paymentReceiver,
36
33
  };
37
- const safeAddress = (0, derive_1.deriveSafe)(args.from, safeFactory);
34
+ const safeAddress = deriveSafe(args.from, safeFactory);
38
35
  const request = {
39
36
  from: args.from,
40
37
  to: safeFactory,
@@ -43,7 +40,7 @@ async function buildSafeCreateTransactionRequest(signer, safeContractConfig, arg
43
40
  data: "0x",
44
41
  signature: sig,
45
42
  signatureParams: sigParams,
46
- type: types_1.TransactionType.SAFE_CREATE,
43
+ type: TransactionType.SAFE_CREATE,
47
44
  };
48
45
  console.log(`Created a SAFE-CREATE Transaction:`);
49
46
  console.log(request);
@@ -1,21 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deriveSafe = exports.deriveProxyWallet = void 0;
4
- const viem_1 = require("viem");
5
- const constants_1 = require("../constants");
6
- const deriveProxyWallet = (address, proxyFactory) => {
7
- return (0, viem_1.getCreate2Address)({
8
- bytecodeHash: constants_1.PROXY_INIT_CODE_HASH,
1
+ import { keccak256, encodePacked, getCreate2Address, encodeAbiParameters } from 'viem';
2
+ import { SAFE_INIT_CODE_HASH, PROXY_INIT_CODE_HASH } from "../constants/index.js";
3
+ export const deriveProxyWallet = (address, proxyFactory) => {
4
+ return getCreate2Address({
5
+ bytecodeHash: PROXY_INIT_CODE_HASH,
9
6
  from: proxyFactory,
10
- salt: (0, viem_1.keccak256)((0, viem_1.encodePacked)(["address"], [address]))
7
+ salt: keccak256(encodePacked(["address"], [address]))
11
8
  });
12
9
  };
13
- exports.deriveProxyWallet = deriveProxyWallet;
14
- const deriveSafe = (address, safeFactory) => {
15
- return (0, viem_1.getCreate2Address)({
16
- bytecodeHash: constants_1.SAFE_INIT_CODE_HASH,
10
+ export const deriveSafe = (address, safeFactory) => {
11
+ return getCreate2Address({
12
+ bytecodeHash: SAFE_INIT_CODE_HASH,
17
13
  from: safeFactory,
18
- salt: (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ name: 'address', type: 'address' }], [address]))
14
+ salt: keccak256(encodeAbiParameters([{ name: 'address', type: 'address' }], [address]))
19
15
  });
20
16
  };
21
- exports.deriveSafe = deriveSafe;
@@ -1,4 +1,4 @@
1
- export * from "./proxy";
2
- export * from "./safe";
3
- export * from "./create";
4
- export * from "./derive";
1
+ export * from "./proxy.ts";
2
+ export * from "./safe.ts";
3
+ export * from "./create.ts";
4
+ export * from "./derive.ts";
@@ -1,7 +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);
5
- tslib_1.__exportStar(require("./safe"), exports);
6
- tslib_1.__exportStar(require("./create"), exports);
7
- tslib_1.__exportStar(require("./derive"), exports);
1
+ export * from "./proxy.js";
2
+ export * from "./safe.js";
3
+ export * from "./create.js";
4
+ export * from "./derive.js";
@@ -1,4 +1,4 @@
1
1
  import { IAbstractSigner } from "@polymarket/abstract-signer";
2
- import { ProxyTransactionArgs, TransactionRequest } from "../types";
3
- import { ProxyContractConfig } from "../config";
2
+ import { ProxyTransactionArgs, TransactionRequest } from "../types.ts";
3
+ import { ProxyContractConfig } from "../config/index.ts";
4
4
  export declare function buildProxyTransactionRequest(signer: IAbstractSigner, args: ProxyTransactionArgs, proxyContractConfig: ProxyContractConfig, metadata?: string): Promise<TransactionRequest>;
@@ -1,21 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildProxyTransactionRequest = buildProxyTransactionRequest;
4
- const viem_1 = require("viem");
5
- const types_1 = require("../types");
6
- const derive_1 = require("./derive");
1
+ import { concat, keccak256, toHex } from "viem";
2
+ import { TransactionType } from "../types.js";
3
+ import { deriveProxyWallet } from "./derive.js";
7
4
  function createStructHash(from, to, data, txFee, gasPrice, gasLimit, nonce, relayHubAddress, relayAddress) {
8
- const relayHubPrefix = (0, viem_1.toHex)("rlx:");
5
+ const relayHubPrefix = toHex("rlx:");
9
6
  const encodedFrom = from;
10
7
  const encodedTo = to;
11
8
  const encodedData = data;
12
- const encodedTxFee = (0, viem_1.toHex)(BigInt(txFee), { size: 32 });
13
- const encodedGasPrice = (0, viem_1.toHex)(BigInt(gasPrice), { size: 32 });
14
- const encodedGasLimit = (0, viem_1.toHex)(BigInt(gasLimit), { size: 32 });
15
- const encodedNonce = (0, viem_1.toHex)(BigInt(nonce), { size: 32 });
9
+ const encodedTxFee = toHex(BigInt(txFee), { size: 32 });
10
+ const encodedGasPrice = toHex(BigInt(gasPrice), { size: 32 });
11
+ const encodedGasLimit = toHex(BigInt(gasLimit), { size: 32 });
12
+ const encodedNonce = toHex(BigInt(nonce), { size: 32 });
16
13
  const encodedRelayHubAddress = relayHubAddress;
17
14
  const encodedRelayAddress = relayAddress;
18
- const dataToHash = (0, viem_1.concat)([
15
+ const dataToHash = concat([
19
16
  relayHubPrefix,
20
17
  encodedFrom,
21
18
  encodedTo,
@@ -27,15 +24,15 @@ function createStructHash(from, to, data, txFee, gasPrice, gasLimit, nonce, rela
27
24
  encodedRelayHubAddress,
28
25
  encodedRelayAddress,
29
26
  ]);
30
- return (0, viem_1.keccak256)(dataToHash);
27
+ return keccak256(dataToHash);
31
28
  }
32
29
  async function createProxySignature(signer, structHash) {
33
30
  return signer.signMessage(structHash);
34
31
  }
35
- async function buildProxyTransactionRequest(signer, args, proxyContractConfig, metadata) {
32
+ export async function buildProxyTransactionRequest(signer, args, proxyContractConfig, metadata) {
36
33
  const proxyWalletFactory = proxyContractConfig.ProxyFactory;
37
34
  const to = proxyWalletFactory;
38
- const proxy = (0, derive_1.deriveProxyWallet)(args.from, proxyWalletFactory);
35
+ const proxy = deriveProxyWallet(args.from, proxyWalletFactory);
39
36
  const relayerFee = "0";
40
37
  const relayHub = proxyContractConfig.RelayHub;
41
38
  const gasLimit = args.gasLimit ? args.gasLimit : await signer.estimateGas({
@@ -64,7 +61,7 @@ async function buildProxyTransactionRequest(signer, args, proxyContractConfig, m
64
61
  nonce: args.nonce,
65
62
  signature: sig,
66
63
  signatureParams: sigParams,
67
- type: types_1.TransactionType.PROXY,
64
+ type: TransactionType.PROXY,
68
65
  metadata: metadata,
69
66
  };
70
67
  console.log(`Created Proxy Transaction Request:`);
@@ -1,5 +1,5 @@
1
1
  import { IAbstractSigner } from "@polymarket/abstract-signer";
2
- import { SafeTransaction, SafeTransactionArgs, TransactionRequest } from "../types";
3
- import { SafeContractConfig } from "../config";
2
+ import { SafeTransaction, SafeTransactionArgs, TransactionRequest } from "../types.ts";
3
+ import { SafeContractConfig } from "../config/index.ts";
4
4
  export declare function aggregateTransaction(txns: SafeTransaction[], safeMultisend: string): SafeTransaction;
5
5
  export declare function buildSafeTransactionRequest(signer: IAbstractSigner, args: SafeTransactionArgs, safeContractConfig: SafeContractConfig, metadata?: string): Promise<TransactionRequest>;
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.aggregateTransaction = aggregateTransaction;
4
- exports.buildSafeTransactionRequest = buildSafeTransactionRequest;
5
- const viem_1 = require("viem");
6
- const types_1 = require("../types");
7
- const derive_1 = require("./derive");
8
- const safe_1 = require("../encode/safe");
9
- const utils_1 = require("../utils");
1
+ import { hashTypedData, zeroAddress } from "viem";
2
+ import { TransactionType } from "../types.js";
3
+ import { deriveSafe } from "./derive.js";
4
+ import { createSafeMultisendTransaction } from "../encode/safe.js";
5
+ import { splitAndPackSig } from "../utils/index.js";
10
6
  async function createSafeSignature(signer, structHash) {
11
7
  return signer.signMessage(structHash);
12
8
  }
@@ -46,36 +42,36 @@ function createStructHash(chainId, safe, to, value, data, operation, safeTxGas,
46
42
  };
47
43
  // // viem hashTypedData
48
44
  // const structHash = _TypedDataEncoder.hash(domain, types, values);
49
- const structHash = (0, viem_1.hashTypedData)({ primaryType: "SafeTx", domain: domain, types: types, message: values });
45
+ const structHash = hashTypedData({ primaryType: "SafeTx", domain: domain, types: types, message: values });
50
46
  return structHash;
51
47
  }
52
- function aggregateTransaction(txns, safeMultisend) {
48
+ export function aggregateTransaction(txns, safeMultisend) {
53
49
  let transaction;
54
50
  if (txns.length == 1) {
55
51
  transaction = txns[0];
56
52
  }
57
53
  else {
58
- transaction = (0, safe_1.createSafeMultisendTransaction)(txns, safeMultisend);
54
+ transaction = createSafeMultisendTransaction(txns, safeMultisend);
59
55
  }
60
56
  return transaction;
61
57
  }
62
- async function buildSafeTransactionRequest(signer, args, safeContractConfig, metadata) {
58
+ export async function buildSafeTransactionRequest(signer, args, safeContractConfig, metadata) {
63
59
  const safeFactory = safeContractConfig.SafeFactory;
64
60
  const safeMultisend = safeContractConfig.SafeMultisend;
65
61
  const transaction = aggregateTransaction(args.transactions, safeMultisend);
66
62
  const safeTxnGas = "0";
67
63
  const baseGas = "0";
68
64
  const gasPrice = "0";
69
- const gasToken = viem_1.zeroAddress;
70
- const refundReceiver = viem_1.zeroAddress;
71
- const safeAddress = (0, derive_1.deriveSafe)(args.from, safeFactory);
65
+ const gasToken = zeroAddress;
66
+ const refundReceiver = zeroAddress;
67
+ const safeAddress = deriveSafe(args.from, safeFactory);
72
68
  // Generate the struct hash
73
69
  // NOTE: this includes a client side optimization over the current relayers
74
70
  // Generates struct hash locally instead of going across the network using the RPC call
75
71
  const structHash = createStructHash(args.chainId, safeAddress, transaction.to, transaction.value, transaction.data, transaction.operation, safeTxnGas, baseGas, gasPrice, gasToken, refundReceiver, args.nonce);
76
72
  const sig = await createSafeSignature(signer, structHash);
77
73
  // Split the sig then pack it into Gnosis accepted rsv format
78
- const packedSig = (0, utils_1.splitAndPackSig)(sig);
74
+ const packedSig = splitAndPackSig(sig);
79
75
  const sigParams = {
80
76
  gasPrice,
81
77
  operation: `${transaction.operation}`,
@@ -95,7 +91,7 @@ async function buildSafeTransactionRequest(signer, args, safeContractConfig, met
95
91
  nonce: args.nonce,
96
92
  signature: packedSig,
97
93
  signatureParams: sigParams,
98
- type: types_1.TransactionType.SAFE,
94
+ type: TransactionType.SAFE,
99
95
  metadata: metadata,
100
96
  };
101
97
  console.log(`Created Safe Transaction Request: `);
package/dist/client.d.ts CHANGED
@@ -2,10 +2,10 @@ import { Wallet } from "@ethersproject/wallet";
2
2
  import { JsonRpcSigner } from "@ethersproject/providers";
3
3
  import { WalletClient } from "viem";
4
4
  import { IAbstractSigner } from "@polymarket/abstract-signer";
5
- import { HttpClient } from "./http-helpers";
6
- import { AddressPayload, AuthArgs, IManualTransactionResponse, ManualOverrides, NoncePayload, Overrides, ProxyTransaction, RelayerTransaction, RelayerTransactionResponse, RelayPayload, SafeTransaction } from "./types";
7
- import { AuthHandler } from "./auth";
8
- import { ContractConfig } from "./config";
5
+ import { HttpClient } from "./http-helpers/index.ts";
6
+ import { AddressPayload, AuthArgs, IManualTransactionResponse, ManualOverrides, NoncePayload, ProxyTransaction, RelayerTransaction, RelayerTransactionResponse, RelayPayload, SafeTransaction } from "./types.ts";
7
+ import { AuthHandler } from "./auth/handler.ts";
8
+ import { ContractConfig } from "./config/index.ts";
9
9
  export declare class RelayClient {
10
10
  readonly relayerUrl: string;
11
11
  readonly chainId: number;
@@ -19,21 +19,23 @@ export declare class RelayClient {
19
19
  getRelayPayload(signerAddress: string, signerType: string): Promise<RelayPayload>;
20
20
  getTransaction(transactionId: string): Promise<RelayerTransaction[]>;
21
21
  getTransactions(): Promise<RelayerTransaction[]>;
22
- executeProxyTransactions(txns: ProxyTransaction[], metadata?: string, overrides?: Overrides): Promise<RelayerTransactionResponse>;
22
+ executeProxyTransactions(txns: ProxyTransaction[], metadata?: string): Promise<RelayerTransactionResponse>;
23
23
  executeSafeTransactions(txns: SafeTransaction[], metadata?: string): Promise<RelayerTransactionResponse>;
24
24
  executeManualTransactions(txns: SafeTransaction[], overrides?: ManualOverrides): Promise<IManualTransactionResponse>;
25
25
  deploySafe(): Promise<RelayerTransactionResponse>;
26
26
  /**
27
27
  * Periodically polls the transaction id until it reaches a desired state
28
28
  * Returns the relayer transaction if it does each the desired state
29
+ * Returns undefined if the transaction hits the failed state
29
30
  * Times out after maxPolls is reached
30
31
  * @param transactionId
31
32
  * @param states
33
+ * @param failState
32
34
  * @param maxPolls
33
35
  * @param pollFrequency
34
36
  * @returns
35
37
  */
36
- pollUntilState(transactionId: string, states: string[], maxPolls?: number, pollFrequency?: number): Promise<RelayerTransaction | undefined>;
38
+ pollUntilState(transactionId: string, states: string[], failState?: string, maxPolls?: number, pollFrequency?: number): Promise<RelayerTransaction | undefined>;
37
39
  private submitTransaction;
38
40
  private send;
39
41
  }
package/dist/client.js CHANGED
@@ -1,21 +1,17 @@
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 {
1
+ import { isBrowser } from "browser-or-node";
2
+ import { zeroAddress } from "viem";
3
+ import { createAbstractSigner } from "@polymarket/abstract-signer";
4
+ import { GET, POST, HttpClient, } from "./http-helpers/index.js";
5
+ import { TransactionType } from "./types.js";
6
+ import { GET_ADDRESS, GET_NONCE, GET_RELAY_PAYLOAD, GET_TRANSACTION, SUBMIT_TRANSACTION, } from "./endpoints.js";
7
+ import { buildProxyTransactionRequest, buildSafeTransactionRequest, buildSafeCreateTransactionRequest, } from "./builder/index.js";
8
+ import { encodeProxyTransactionData } from "./encode/index.js";
9
+ import { AuthHandler } from "./auth/handler.js";
10
+ import { sleep } from "./utils/index.js";
11
+ import { executeManualTransactions } from "./manual/index.js";
12
+ import { ClientRelayerTransactionResponse } from "./response/index.js";
13
+ import { getContractConfig } from "./config/index.js";
14
+ export class RelayClient {
19
15
  relayerUrl;
20
16
  chainId;
21
17
  contractConfig;
@@ -25,54 +21,49 @@ class RelayClient {
25
21
  constructor(relayerUrl, chainId, signer, authArgs) {
26
22
  this.relayerUrl = relayerUrl.endsWith("/") ? relayerUrl.slice(0, -1) : relayerUrl;
27
23
  this.chainId = chainId;
28
- this.contractConfig = (0, config_1.getContractConfig)(chainId);
29
- this.httpClient = new http_helpers_1.HttpClient();
24
+ this.contractConfig = getContractConfig(chainId);
25
+ this.httpClient = new HttpClient();
30
26
  if (signer != undefined) {
31
- this.signer = (0, abstract_signer_1.createAbstractSigner)(chainId, signer);
27
+ this.signer = createAbstractSigner(chainId, signer);
32
28
  }
33
29
  if (authArgs !== undefined) {
34
- this.authHandler = new auth_1.AuthHandler(this.httpClient, authArgs);
30
+ this.authHandler = new AuthHandler(this.httpClient, authArgs);
35
31
  }
36
32
  }
37
33
  async getRelayAddress() {
38
- return this.send(`${this.relayerUrl}${endpoints_1.GET_ADDRESS}`, http_helpers_1.GET);
34
+ return this.send(`${this.relayerUrl}${GET_ADDRESS}`, GET);
39
35
  }
40
36
  async getNonce(signerAddress, signerType) {
41
- return this.send(`${this.relayerUrl}${endpoints_1.GET_NONCE}?address=${signerAddress}&type=${signerType}`, http_helpers_1.GET);
37
+ return this.send(`${this.relayerUrl}${GET_NONCE}?address=${signerAddress}&type=${signerType}`, GET);
42
38
  }
43
39
  async getRelayPayload(signerAddress, signerType) {
44
- return this.send(`${this.relayerUrl}${endpoints_1.GET_RELAY_PAYLOAD}?address=${signerAddress}&type=${signerType}`, http_helpers_1.GET);
40
+ return this.send(`${this.relayerUrl}${GET_RELAY_PAYLOAD}?address=${signerAddress}&type=${signerType}`, GET);
45
41
  }
46
42
  async getTransaction(transactionId) {
47
- return this.send(`${this.relayerUrl}${endpoints_1.GET_TRANSACTION}?id=${transactionId}`, http_helpers_1.GET);
43
+ return this.send(`${this.relayerUrl}${GET_TRANSACTION}?id=${transactionId}`, GET);
48
44
  }
49
45
  async getTransactions() {
50
- return this.send(`${this.relayerUrl}${endpoints_1.GET_TRANSACTION}s`, http_helpers_1.GET);
46
+ return this.send(`${this.relayerUrl}${GET_TRANSACTION}s`, GET);
51
47
  }
52
- async executeProxyTransactions(txns, metadata, overrides) {
48
+ async executeProxyTransactions(txns, metadata) {
53
49
  if (this.signer == undefined) {
54
50
  throw new Error("missing signer");
55
51
  }
56
52
  const start = Date.now();
57
53
  const from = await this.signer.getAddress();
58
- const rp = await this.getRelayPayload(from, types_1.TransactionType.PROXY);
54
+ const rp = await this.getRelayPayload(from, TransactionType.PROXY);
59
55
  const args = {
60
56
  from: from,
61
57
  gasPrice: "0",
62
- data: (0, encode_1.encodeProxyTransactionData)(txns),
58
+ data: encodeProxyTransactionData(txns),
63
59
  relay: rp.address,
64
60
  nonce: rp.nonce,
65
61
  };
66
- let gasLimitStr = undefined;
67
- if (overrides != undefined && overrides.gasLimit != undefined) {
68
- gasLimitStr = overrides.gasLimit.toString();
69
- }
70
- args.gasLimit = gasLimitStr;
71
62
  const proxyContractConfig = this.contractConfig.ProxyContracts;
72
- const request = await (0, builder_1.buildProxyTransactionRequest)(this.signer, args, proxyContractConfig, metadata);
63
+ const request = await buildProxyTransactionRequest(this.signer, args, proxyContractConfig, metadata);
73
64
  console.log(`Client side proxy request creation took: ${(Date.now() - start) / 1000} seconds`);
74
65
  const resp = await this.submitTransaction(request);
75
- return new response_1.ClientRelayerTransactionResponse(resp.transactionID, resp.state, resp.transactionHash, this);
66
+ return new ClientRelayerTransactionResponse(resp.transactionID, resp.state, resp.transactionHash, this);
76
67
  }
77
68
  async executeSafeTransactions(txns, metadata) {
78
69
  if (this.signer == undefined) {
@@ -80,7 +71,7 @@ class RelayClient {
80
71
  }
81
72
  const start = Date.now();
82
73
  const from = await this.signer.getAddress();
83
- const noncePayload = await this.getNonce(from, types_1.TransactionType.SAFE);
74
+ const noncePayload = await this.getNonce(from, TransactionType.SAFE);
84
75
  const args = {
85
76
  transactions: txns,
86
77
  from,
@@ -88,10 +79,10 @@ class RelayClient {
88
79
  chainId: this.chainId,
89
80
  };
90
81
  const safeContractConfig = this.contractConfig.SafeContracts;
91
- const request = await (0, builder_1.buildSafeTransactionRequest)(this.signer, args, safeContractConfig, metadata);
82
+ const request = await buildSafeTransactionRequest(this.signer, args, safeContractConfig, metadata);
92
83
  console.log(`Client side safe request creation took: ${(Date.now() - start) / 1000} seconds`);
93
84
  const resp = await this.submitTransaction(request);
94
- return new response_1.ClientRelayerTransactionResponse(resp.transactionID, resp.state, resp.transactionHash, this);
85
+ return new ClientRelayerTransactionResponse(resp.transactionID, resp.state, resp.transactionHash, this);
95
86
  }
96
87
  async executeManualTransactions(txns, overrides) {
97
88
  if (overrides == undefined) {
@@ -100,7 +91,7 @@ class RelayClient {
100
91
  if (this.signer == undefined) {
101
92
  throw new Error("missing signer");
102
93
  }
103
- return (0, manual_1.executeManualTransactions)(this.signer, this.contractConfig.SafeContracts, txns, overrides);
94
+ return executeManualTransactions(this.signer, this.contractConfig.SafeContracts, txns, overrides);
104
95
  }
105
96
  async deploySafe() {
106
97
  if (this.signer == undefined) {
@@ -111,27 +102,29 @@ class RelayClient {
111
102
  const args = {
112
103
  from: from,
113
104
  chainId: this.chainId,
114
- paymentToken: viem_1.zeroAddress,
105
+ paymentToken: zeroAddress,
115
106
  payment: "0",
116
- paymentReceiver: viem_1.zeroAddress,
107
+ paymentReceiver: zeroAddress,
117
108
  };
118
109
  const safeContractConfig = this.contractConfig.SafeContracts;
119
- const request = await (0, builder_1.buildSafeCreateTransactionRequest)(this.signer, safeContractConfig, args);
110
+ const request = await buildSafeCreateTransactionRequest(this.signer, safeContractConfig, args);
120
111
  console.log(`Client side deploy request creation took: ${(Date.now() - start) / 1000} seconds`);
121
112
  const resp = await this.submitTransaction(request);
122
- return new response_1.ClientRelayerTransactionResponse(resp.transactionID, resp.state, resp.transactionHash, this);
113
+ return new ClientRelayerTransactionResponse(resp.transactionID, resp.state, resp.transactionHash, this);
123
114
  }
124
115
  /**
125
116
  * Periodically polls the transaction id until it reaches a desired state
126
117
  * Returns the relayer transaction if it does each the desired state
118
+ * Returns undefined if the transaction hits the failed state
127
119
  * Times out after maxPolls is reached
128
120
  * @param transactionId
129
121
  * @param states
122
+ * @param failState
130
123
  * @param maxPolls
131
124
  * @param pollFrequency
132
125
  * @returns
133
126
  */
134
- async pollUntilState(transactionId, states, maxPolls, pollFrequency) {
127
+ async pollUntilState(transactionId, states, failState, maxPolls, pollFrequency) {
135
128
  console.log(`Waiting for transaction ${transactionId} matching states: ${states}...`);
136
129
  const maxPollCount = maxPolls != undefined ? maxPolls : 10;
137
130
  let pollFreq = 2000; // Default to polling every 2 seconds
@@ -148,20 +141,24 @@ class RelayClient {
148
141
  if (states.includes(txn.state)) {
149
142
  return txn;
150
143
  }
144
+ if (failState != undefined && txn.state == failState) {
145
+ // Return undefined if txn reaches the fail state
146
+ return undefined;
147
+ }
151
148
  }
152
149
  pollCount++;
153
- await (0, utils_1.sleep)(pollFreq);
150
+ await sleep(pollFreq);
154
151
  }
155
152
  console.log(`Transaction not found or not in given states, timing out`);
156
153
  }
157
154
  async submitTransaction(req) {
158
- return this.send(`${this.relayerUrl}${endpoints_1.SUBMIT_TRANSACTION}`, http_helpers_1.POST, undefined, req);
155
+ return this.send(`${this.relayerUrl}${SUBMIT_TRANSACTION}`, POST, undefined, req);
159
156
  }
160
157
  async send(endpoint, method, headers, data, params) {
161
158
  // Explicitly inject the polymarket session cookies
162
159
  // In prod environments, this will be unnecessary as the browser will have the needed cookies
163
160
  // Needed only for local testing
164
- if (!browser_or_node_1.default && this.authHandler !== undefined) {
161
+ if (!isBrowser && this.authHandler !== undefined) {
165
162
  const cookie = await this.authHandler.getPolymarketCookies();
166
163
  if (headers != undefined) {
167
164
  headers["Cookie"] = cookie;
@@ -174,4 +171,3 @@ class RelayClient {
174
171
  return resp.data;
175
172
  }
176
173
  }
177
- exports.RelayClient = RelayClient;
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getContractConfig = void 0;
4
1
  ;
5
2
  const AMOY = {
6
3
  ProxyContracts: {
@@ -22,7 +19,7 @@ const POL = {
22
19
  SafeMultisend: "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761",
23
20
  }
24
21
  };
25
- const getContractConfig = (chainId) => {
22
+ export const getContractConfig = (chainId) => {
26
23
  switch (chainId) {
27
24
  case 137:
28
25
  return POL;
@@ -32,4 +29,3 @@ const getContractConfig = (chainId) => {
32
29
  throw new Error("Invalid network");
33
30
  }
34
31
  };
35
- exports.getContractConfig = getContractConfig;
@@ -1,6 +1,3 @@
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
+ export const PROXY_INIT_CODE_HASH = "0xd21df8dc65880a8606f09fe0ce3df9b8869287ab0b058be05aa9e8af6330a00b";
2
+ export const SAFE_INIT_CODE_HASH = "0x2bce2127ff07fb632d16c8347c4ebf501f4841168bed00d9e6ef715ddb6fcecf";
3
+ export const SAFE_FACTORY_NAME = "Polymarket Contract Proxy Factory";
@@ -1,2 +1,2 @@
1
- export * from "./proxy";
2
- export * from "./safe";
1
+ export * from "./proxy.ts";
2
+ export * from "./safe.ts";
@@ -1,5 +1,2 @@
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
+ export * from "./proxy.js";
2
+ export * from "./safe.js";
@@ -1,2 +1,2 @@
1
- import { ProxyTransaction } from "../types";
1
+ import { ProxyTransaction } from "../types.ts";
2
2
  export declare function encodeProxyTransactionData(txns: ProxyTransaction[]): string;
@@ -1,14 +1,11 @@
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,
1
+ import { proxyWalletFactory } from "../abis/index.js";
2
+ import { encodeFunctionData, prepareEncodeFunctionData } from "viem";
3
+ const proxy = prepareEncodeFunctionData({
4
+ abi: proxyWalletFactory,
8
5
  functionName: 'proxy',
9
6
  });
10
- function encodeProxyTransactionData(txns) {
11
- return (0, viem_1.encodeFunctionData)({
7
+ export function encodeProxyTransactionData(txns) {
8
+ return encodeFunctionData({
12
9
  ...proxy,
13
10
  args: [txns],
14
11
  });
@@ -1,2 +1,2 @@
1
- import { SafeTransaction } from "../types";
1
+ import { SafeTransaction } from "../types.ts";
2
2
  export declare const createSafeMultisendTransaction: (txns: SafeTransaction[], safeMultisendAddress: string) => SafeTransaction;
@@ -1,23 +1,19 @@
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,
1
+ import { concatHex, encodeFunctionData, encodePacked, prepareEncodeFunctionData, size } from "viem";
2
+ import { multisendAbi } from "../abis/index.js";
3
+ import { OperationType } from "../types.js";
4
+ const multisend = prepareEncodeFunctionData({
5
+ abi: multisendAbi,
9
6
  functionName: "multiSend",
10
7
  });
11
- const createSafeMultisendTransaction = (txns, safeMultisendAddress) => {
8
+ export const createSafeMultisendTransaction = (txns, safeMultisendAddress) => {
12
9
  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]))),
10
+ concatHex(txns.map(tx => encodePacked(["uint8", "address", "uint256", "uint256", "bytes"], [tx.operation, tx.to, BigInt(tx.value), BigInt(size(tx.data)), tx.data]))),
14
11
  ];
15
- const data = (0, viem_1.encodeFunctionData)({ ...multisend, args: args });
12
+ const data = encodeFunctionData({ ...multisend, args: args });
16
13
  return {
17
14
  to: safeMultisendAddress,
18
15
  value: "0",
19
16
  data: data,
20
- operation: types_1.OperationType.DelegateCall,
17
+ operation: OperationType.DelegateCall,
21
18
  };
22
19
  };
23
- exports.createSafeMultisendTransaction = createSafeMultisendTransaction;
package/dist/endpoints.js CHANGED
@@ -1,8 +1,5 @@
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
+ export const GET_ADDRESS = "/address";
2
+ export const GET_NONCE = "/nonce";
3
+ export const GET_RELAY_PAYLOAD = "/relay-payload";
4
+ export const GET_TRANSACTION = "/transaction";
5
+ export const SUBMIT_TRANSACTION = "/submit";
@@ -1,16 +1,12 @@
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 {
1
+ import axios from "axios";
2
+ export const GET = "GET";
3
+ export const POST = "POST";
4
+ export const DELETE = "DELETE";
5
+ export const PUT = "PUT";
6
+ export class HttpClient {
11
7
  instance;
12
8
  constructor() {
13
- this.instance = axios_1.default.create({ withCredentials: true });
9
+ this.instance = axios.create({ withCredentials: true });
14
10
  }
15
11
  async send(endpoint, method, headers, data, params) {
16
12
  if (headers != undefined) {
@@ -27,7 +23,7 @@ class HttpClient {
27
23
  return resp;
28
24
  }
29
25
  catch (err) {
30
- if (axios_1.default.isAxiosError(err)) {
26
+ if (axios.isAxiosError(err)) {
31
27
  if (err.response) {
32
28
  const errPayload = {
33
29
  error: "request error",
@@ -48,4 +44,3 @@ class HttpClient {
48
44
  }
49
45
  }
50
46
  }
51
- exports.HttpClient = HttpClient;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from "./client";
2
- export * from "./encode";
3
- export * from "./types";
4
- export * from "./response";
1
+ export * from "./client.ts";
2
+ export * from "./encode/index.ts";
3
+ export * from "./types.ts";
4
+ export * from "./response/index.ts";
package/dist/index.js CHANGED
@@ -1,7 +1,4 @@
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
+ export * from "./client.js";
2
+ export * from "./encode/index.js";
3
+ export * from "./types.js";
4
+ export * from "./response/index.js";
@@ -1,5 +1,5 @@
1
1
  import { IAbstractSigner } from "@polymarket/abstract-signer";
2
- import { SafeContractConfig } from "../config";
3
- import { SafeTransaction, ManualOverrides } from "../types";
4
- import { ManualTransactionResponse } from "../response";
2
+ import { SafeContractConfig } from "../config/index.ts";
3
+ import { SafeTransaction, ManualOverrides } from "../types.ts";
4
+ import { ManualTransactionResponse } from "../response/index.ts";
5
5
  export declare function executeManualTransactions(signer: IAbstractSigner, safeContractConfig: SafeContractConfig, transactions: SafeTransaction[], overrides: ManualOverrides): Promise<ManualTransactionResponse>;
@@ -1,22 +1,19 @@
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,
1
+ import { encodePacked, hexToBigInt, zeroAddress } from "viem";
2
+ import { encodeFunctionData, prepareEncodeFunctionData } from "viem";
3
+ import { safeAbi } from "../abis/index.js";
4
+ import { aggregateTransaction, deriveSafe } from "../builder/index.js";
5
+ import { ManualTransactionResponse } from "../response/index.js";
6
+ const safeExecTransaction = prepareEncodeFunctionData({
7
+ abi: safeAbi,
11
8
  functionName: 'execTransaction',
12
9
  });
13
- async function executeManualTransactions(signer, safeContractConfig, transactions, overrides) {
10
+ export async function executeManualTransactions(signer, safeContractConfig, transactions, overrides) {
14
11
  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);
12
+ const aggTxn = aggregateTransaction(transactions, safeContractConfig.SafeMultisend);
13
+ const sig = encodePacked(["uint256", "uint256", "uint8"], [BigInt(hexToBigInt(from)), BigInt(0), 1]);
14
+ const safeAddress = deriveSafe(from, safeContractConfig.SafeFactory);
18
15
  // calldata
19
- const data = (0, viem_2.encodeFunctionData)({ ...safeExecTransaction, args: [
16
+ const data = encodeFunctionData({ ...safeExecTransaction, args: [
20
17
  aggTxn.to,
21
18
  aggTxn.value,
22
19
  aggTxn.data,
@@ -24,8 +21,8 @@ async function executeManualTransactions(signer, safeContractConfig, transaction
24
21
  0,
25
22
  0,
26
23
  0,
27
- viem_1.zeroAddress,
28
- viem_1.zeroAddress,
24
+ zeroAddress,
25
+ zeroAddress,
29
26
  sig,
30
27
  ] });
31
28
  if (overrides.gasLimit == undefined) {
@@ -46,5 +43,5 @@ async function executeManualTransactions(signer, safeContractConfig, transaction
46
43
  const waitFunc = (txHash) => {
47
44
  return signer.waitTillMined(txHash);
48
45
  };
49
- return new response_1.ManualTransactionResponse(txHash, waitFunc);
46
+ return new ManualTransactionResponse(txHash, waitFunc);
50
47
  }
@@ -1,5 +1,5 @@
1
- import { RelayClient } from "../client";
2
- import { IManualTransactionResponse, RelayerTransaction, RelayerTransactionResponse } from "../types";
1
+ import { RelayClient } from "../client.ts";
2
+ import { IManualTransactionResponse, RelayerTransaction, RelayerTransactionResponse } from "../types.ts";
3
3
  export declare class ClientRelayerTransactionResponse implements RelayerTransactionResponse {
4
4
  readonly client: RelayClient;
5
5
  readonly transactionID: string;
@@ -1,8 +1,5 @@
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 {
1
+ import { RelayerTransactionState } from "../types.js";
2
+ export class ClientRelayerTransactionResponse {
6
3
  client;
7
4
  transactionID;
8
5
  transactionHash;
@@ -20,14 +17,12 @@ class ClientRelayerTransactionResponse {
20
17
  }
21
18
  async wait() {
22
19
  return this.client.pollUntilState(this.transactionID, [
23
- types_1.RelayerTransactionState.STATE_MINED,
24
- types_1.RelayerTransactionState.STATE_CONFIRMED,
25
- types_1.RelayerTransactionState.STATE_FAILED,
26
- ], 30);
20
+ RelayerTransactionState.STATE_MINED,
21
+ RelayerTransactionState.STATE_CONFIRMED,
22
+ ], RelayerTransactionState.STATE_FAILED, 30);
27
23
  }
28
24
  }
29
- exports.ClientRelayerTransactionResponse = ClientRelayerTransactionResponse;
30
- class ManualTransactionResponse {
25
+ export class ManualTransactionResponse {
31
26
  hash;
32
27
  transactionHash;
33
28
  waitTillMined;
@@ -40,4 +35,3 @@ class ManualTransactionResponse {
40
35
  return this.waitTillMined(this.hash);
41
36
  }
42
37
  }
43
- exports.ManualTransactionResponse = ManualTransactionResponse;
package/dist/types.d.ts CHANGED
@@ -126,9 +126,6 @@ export interface RelayerTransactionResponse {
126
126
  getTransaction: () => Promise<RelayerTransaction[]>;
127
127
  wait: () => Promise<RelayerTransaction | undefined>;
128
128
  }
129
- export interface Overrides {
130
- gasLimit?: bigint;
131
- }
132
129
  export interface ManualOverrides {
133
130
  gasLimit?: bigint;
134
131
  gasPrice?: bigint;
package/dist/types.js CHANGED
@@ -1,25 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RelayerTransactionState = exports.OperationType = exports.CallType = exports.TransactionType = void 0;
4
- var TransactionType;
1
+ export var TransactionType;
5
2
  (function (TransactionType) {
6
3
  TransactionType["PROXY"] = "PROXY";
7
4
  TransactionType["SAFE"] = "SAFE";
8
5
  TransactionType["SAFE_CREATE"] = "SAFE-CREATE";
9
- })(TransactionType || (exports.TransactionType = TransactionType = {}));
10
- var CallType;
6
+ })(TransactionType || (TransactionType = {}));
7
+ export var CallType;
11
8
  (function (CallType) {
12
9
  CallType["Invalid"] = "0";
13
10
  CallType["Call"] = "1";
14
11
  CallType["DelegateCall"] = "2";
15
- })(CallType || (exports.CallType = CallType = {}));
12
+ })(CallType || (CallType = {}));
16
13
  // Safe Transactions
17
- var OperationType;
14
+ export var OperationType;
18
15
  (function (OperationType) {
19
16
  OperationType[OperationType["Call"] = 0] = "Call";
20
17
  OperationType[OperationType["DelegateCall"] = 1] = "DelegateCall";
21
- })(OperationType || (exports.OperationType = OperationType = {}));
22
- var RelayerTransactionState;
18
+ })(OperationType || (OperationType = {}));
19
+ export var RelayerTransactionState;
23
20
  (function (RelayerTransactionState) {
24
21
  RelayerTransactionState["STATE_NEW"] = "STATE_NEW";
25
22
  RelayerTransactionState["STATE_EXECUTED"] = "STATE_EXECUTED";
@@ -27,5 +24,5 @@ var RelayerTransactionState;
27
24
  RelayerTransactionState["STATE_INVALID"] = "STATE_INVALID";
28
25
  RelayerTransactionState["STATE_CONFIRMED"] = "STATE_CONFIRMED";
29
26
  RelayerTransactionState["STATE_FAILED"] = "STATE_FAILED";
30
- })(RelayerTransactionState || (exports.RelayerTransactionState = RelayerTransactionState = {}));
27
+ })(RelayerTransactionState || (RelayerTransactionState = {}));
31
28
  ;
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.splitAndPackSig = splitAndPackSig;
4
- exports.sleep = sleep;
5
- const viem_1 = require("viem");
6
- function splitAndPackSig(sig) {
1
+ import { encodePacked, hexToBigInt } from "viem";
2
+ export function splitAndPackSig(sig) {
7
3
  const splitSig = splitSignature(sig);
8
- const packedSig = (0, viem_1.encodePacked)(["uint256", "uint256", "uint8"], [BigInt(splitSig.r), BigInt(splitSig.s), parseInt(splitSig.v)]);
4
+ const packedSig = encodePacked(["uint256", "uint256", "uint8"], [BigInt(splitSig.r), BigInt(splitSig.s), parseInt(splitSig.v)]);
9
5
  return packedSig;
10
6
  }
11
7
  function splitSignature(sig) {
@@ -24,11 +20,11 @@ function splitSignature(sig) {
24
20
  }
25
21
  sig = sig.slice(0, -2) + sigV.toString(16);
26
22
  return {
27
- r: (0, viem_1.hexToBigInt)('0x' + sig.slice(2, 66)).toString(),
28
- s: (0, viem_1.hexToBigInt)('0x' + sig.slice(66, 130)).toString(),
29
- v: (0, viem_1.hexToBigInt)('0x' + sig.slice(130, 132)).toString(),
23
+ r: hexToBigInt('0x' + sig.slice(2, 66)).toString(),
24
+ s: hexToBigInt('0x' + sig.slice(66, 130)).toString(),
25
+ v: hexToBigInt('0x' + sig.slice(130, 132)).toString(),
30
26
  };
31
27
  }
32
- function sleep(ms) {
28
+ export function sleep(ms) {
33
29
  return new Promise(resolve => setTimeout(resolve, ms));
34
30
  }
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@polymarket/relayer-client",
3
3
  "description": "Client for Polymarket relayers",
4
- "version": "2.0.1",
4
+ "version": "3.0.0",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
7
8
  "files": [
8
9
  "/dist"
9
10
  ],
11
+ "sideEffects": false,
10
12
  "scripts": {
11
13
  "build": "make build",
12
14
  "clean": "rm -rf ./dist",
@@ -28,15 +30,17 @@
28
30
  "ts-node": "^9.1.1",
29
31
  "tsconfig-paths": "^4.2.0",
30
32
  "tslib": "^2.8.1",
33
+ "tsx": "^4.20.3",
34
+ "typescript": "^5.8.3",
31
35
  "ws": "^8.11.0"
32
36
  },
33
37
  "dependencies": {
34
- "@polymarket/abstract-signer": "0.0.5",
35
- "axios": "^0.27.2",
38
+ "@ethersproject/providers": "5.7.2",
39
+ "@ethersproject/wallet": "5.7.0",
40
+ "@polymarket/abstract-signer": "0.0.8",
41
+ "axios": "^1.13.2",
36
42
  "browser-or-node": "^3.0.0",
37
43
  "ethers": "5.7.2",
38
- "tsx": "^4.20.3",
39
- "typescript": "^5.8.3",
40
44
  "viem": "^2.31.4"
41
45
  }
42
46
  }