@polymarket/relayer-client 4.0.0 → 4.1.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 (55) hide show
  1. package/dist/abis/erc20Abi.d.ts +38 -0
  2. package/dist/abis/erc20Abi.js +222 -0
  3. package/dist/abis/index.d.ts +5 -0
  4. package/dist/abis/index.js +5 -0
  5. package/dist/abis/multisend.d.ts +13 -0
  6. package/dist/abis/multisend.js +17 -0
  7. package/dist/abis/proxyFactory.d.ts +66 -0
  8. package/dist/abis/proxyFactory.js +319 -0
  9. package/dist/abis/safe.d.ts +35 -0
  10. package/dist/abis/safe.js +1138 -0
  11. package/dist/abis/safeFactory.d.ts +60 -0
  12. package/dist/abis/safeFactory.js +224 -0
  13. package/dist/auth/handler.d.ts +15 -0
  14. package/dist/auth/handler.js +46 -0
  15. package/dist/auth/index.d.ts +1 -0
  16. package/dist/auth/index.js +1 -0
  17. package/dist/builder/create.d.ts +4 -0
  18. package/dist/builder/create.js +48 -0
  19. package/dist/builder/derive.d.ts +2 -0
  20. package/dist/builder/derive.js +16 -0
  21. package/dist/builder/index.d.ts +4 -0
  22. package/dist/builder/index.js +4 -0
  23. package/dist/builder/proxy.d.ts +4 -0
  24. package/dist/builder/proxy.js +72 -0
  25. package/dist/builder/safe.d.ts +5 -0
  26. package/dist/builder/safe.js +105 -0
  27. package/dist/client.d.ts +39 -0
  28. package/dist/client.js +173 -0
  29. package/dist/config/index.d.ts +13 -0
  30. package/dist/config/index.js +30 -0
  31. package/dist/constants/index.d.ts +3 -0
  32. package/dist/constants/index.js +3 -0
  33. package/dist/encode/index.d.ts +2 -0
  34. package/dist/encode/index.js +2 -0
  35. package/dist/encode/proxy.d.ts +2 -0
  36. package/dist/encode/proxy.js +12 -0
  37. package/dist/encode/safe.d.ts +2 -0
  38. package/dist/encode/safe.js +25 -0
  39. package/dist/endpoints.d.ts +5 -0
  40. package/dist/endpoints.js +5 -0
  41. package/dist/http-helpers/index.d.ts +10 -0
  42. package/dist/http-helpers/index.js +46 -0
  43. package/dist/index.d.ts +4 -0
  44. package/dist/index.js +4 -0
  45. package/dist/manual/index.d.ts +5 -0
  46. package/dist/manual/index.js +49 -0
  47. package/dist/response/index.d.ts +21 -0
  48. package/dist/response/index.js +34 -0
  49. package/dist/signer/index.d.ts +26 -0
  50. package/dist/signer/index.js +109 -0
  51. package/dist/types.d.ts +132 -0
  52. package/dist/types.js +27 -0
  53. package/dist/utils/index.d.ts +7 -0
  54. package/dist/utils/index.js +30 -0
  55. package/package.json +8 -2
@@ -0,0 +1,60 @@
1
+ export declare const safeFactoryAbi: ({
2
+ inputs: {
3
+ internalType: string;
4
+ name: string;
5
+ type: string;
6
+ }[];
7
+ stateMutability: string;
8
+ type: string;
9
+ anonymous?: undefined;
10
+ name?: undefined;
11
+ outputs?: undefined;
12
+ } | {
13
+ anonymous: boolean;
14
+ inputs: {
15
+ indexed: boolean;
16
+ internalType: string;
17
+ name: string;
18
+ type: string;
19
+ }[];
20
+ name: string;
21
+ type: string;
22
+ stateMutability?: undefined;
23
+ outputs?: undefined;
24
+ } | {
25
+ inputs: {
26
+ internalType: string;
27
+ name: string;
28
+ type: string;
29
+ }[];
30
+ name: string;
31
+ outputs: {
32
+ internalType: string;
33
+ name: string;
34
+ type: string;
35
+ }[];
36
+ stateMutability: string;
37
+ type: string;
38
+ anonymous?: undefined;
39
+ } | {
40
+ inputs: ({
41
+ internalType: string;
42
+ name: string;
43
+ type: string;
44
+ components?: undefined;
45
+ } | {
46
+ components: {
47
+ internalType: string;
48
+ name: string;
49
+ type: string;
50
+ }[];
51
+ internalType: string;
52
+ name: string;
53
+ type: string;
54
+ })[];
55
+ name: string;
56
+ outputs: never[];
57
+ stateMutability: string;
58
+ type: string;
59
+ anonymous?: undefined;
60
+ })[];
@@ -0,0 +1,224 @@
1
+ export const safeFactoryAbi = [
2
+ {
3
+ inputs: [
4
+ {
5
+ internalType: "address",
6
+ name: "_masterCopy",
7
+ type: "address",
8
+ },
9
+ {
10
+ internalType: "address",
11
+ name: "_fallbackHandler",
12
+ type: "address",
13
+ },
14
+ ],
15
+ stateMutability: "nonpayable",
16
+ type: "constructor",
17
+ },
18
+ {
19
+ anonymous: false,
20
+ inputs: [
21
+ {
22
+ indexed: false,
23
+ internalType: "contract GnosisSafe",
24
+ name: "proxy",
25
+ type: "address",
26
+ },
27
+ {
28
+ indexed: false,
29
+ internalType: "address",
30
+ name: "owner",
31
+ type: "address",
32
+ },
33
+ ],
34
+ name: "ProxyCreation",
35
+ type: "event",
36
+ },
37
+ {
38
+ inputs: [],
39
+ name: "CREATE_PROXY_TYPEHASH",
40
+ outputs: [
41
+ {
42
+ internalType: "bytes32",
43
+ name: "",
44
+ type: "bytes32",
45
+ },
46
+ ],
47
+ stateMutability: "view",
48
+ type: "function",
49
+ },
50
+ {
51
+ inputs: [],
52
+ name: "DOMAIN_TYPEHASH",
53
+ outputs: [
54
+ {
55
+ internalType: "bytes32",
56
+ name: "",
57
+ type: "bytes32",
58
+ },
59
+ ],
60
+ stateMutability: "view",
61
+ type: "function",
62
+ },
63
+ {
64
+ inputs: [],
65
+ name: "NAME",
66
+ outputs: [
67
+ {
68
+ internalType: "string",
69
+ name: "",
70
+ type: "string",
71
+ },
72
+ ],
73
+ stateMutability: "view",
74
+ type: "function",
75
+ },
76
+ {
77
+ inputs: [
78
+ {
79
+ internalType: "address",
80
+ name: "user",
81
+ type: "address",
82
+ },
83
+ ],
84
+ name: "computeProxyAddress",
85
+ outputs: [
86
+ {
87
+ internalType: "address",
88
+ name: "",
89
+ type: "address",
90
+ },
91
+ ],
92
+ stateMutability: "view",
93
+ type: "function",
94
+ },
95
+ {
96
+ inputs: [
97
+ {
98
+ internalType: "address",
99
+ name: "paymentToken",
100
+ type: "address",
101
+ },
102
+ {
103
+ internalType: "uint256",
104
+ name: "payment",
105
+ type: "uint256",
106
+ },
107
+ {
108
+ internalType: "address payable",
109
+ name: "paymentReceiver",
110
+ type: "address",
111
+ },
112
+ {
113
+ components: [
114
+ {
115
+ internalType: "uint8",
116
+ name: "v",
117
+ type: "uint8",
118
+ },
119
+ {
120
+ internalType: "bytes32",
121
+ name: "r",
122
+ type: "bytes32",
123
+ },
124
+ {
125
+ internalType: "bytes32",
126
+ name: "s",
127
+ type: "bytes32",
128
+ },
129
+ ],
130
+ internalType: "struct SafeProxyFactory.Sig",
131
+ name: "createSig",
132
+ type: "tuple",
133
+ },
134
+ ],
135
+ name: "createProxy",
136
+ outputs: [],
137
+ stateMutability: "nonpayable",
138
+ type: "function",
139
+ },
140
+ {
141
+ inputs: [],
142
+ name: "domainSeparator",
143
+ outputs: [
144
+ {
145
+ internalType: "bytes32",
146
+ name: "",
147
+ type: "bytes32",
148
+ },
149
+ ],
150
+ stateMutability: "view",
151
+ type: "function",
152
+ },
153
+ {
154
+ inputs: [],
155
+ name: "fallbackHandler",
156
+ outputs: [
157
+ {
158
+ internalType: "address",
159
+ name: "",
160
+ type: "address",
161
+ },
162
+ ],
163
+ stateMutability: "view",
164
+ type: "function",
165
+ },
166
+ {
167
+ inputs: [],
168
+ name: "getContractBytecode",
169
+ outputs: [
170
+ {
171
+ internalType: "bytes",
172
+ name: "",
173
+ type: "bytes",
174
+ },
175
+ ],
176
+ stateMutability: "view",
177
+ type: "function",
178
+ },
179
+ {
180
+ inputs: [
181
+ {
182
+ internalType: "address",
183
+ name: "user",
184
+ type: "address",
185
+ },
186
+ ],
187
+ name: "getSalt",
188
+ outputs: [
189
+ {
190
+ internalType: "bytes32",
191
+ name: "",
192
+ type: "bytes32",
193
+ },
194
+ ],
195
+ stateMutability: "pure",
196
+ type: "function",
197
+ },
198
+ {
199
+ inputs: [],
200
+ name: "masterCopy",
201
+ outputs: [
202
+ {
203
+ internalType: "address",
204
+ name: "",
205
+ type: "address",
206
+ },
207
+ ],
208
+ stateMutability: "view",
209
+ type: "function",
210
+ },
211
+ {
212
+ inputs: [],
213
+ name: "proxyCreationCode",
214
+ outputs: [
215
+ {
216
+ internalType: "bytes",
217
+ name: "",
218
+ type: "bytes",
219
+ },
220
+ ],
221
+ stateMutability: "pure",
222
+ type: "function",
223
+ },
224
+ ];
@@ -0,0 +1,15 @@
1
+ import { type HttpClient } from "../http-helpers/index.ts";
2
+ import type { AuthArgs } from "../types.ts";
3
+ export declare class AuthHandler {
4
+ readonly url: string;
5
+ readonly httpClient: HttpClient;
6
+ readonly token?: string;
7
+ private cookie?;
8
+ constructor(httpClient: HttpClient, args: AuthArgs);
9
+ /**
10
+ * Logs in to the auth url
11
+ * Extracts polymarket session cookies from the auth response header and cache it locally.
12
+ */
13
+ login(): Promise<void>;
14
+ getPolymarketCookies(): Promise<string>;
15
+ }
@@ -0,0 +1,46 @@
1
+ import { GET } from "../http-helpers/index.js";
2
+ const POLYMARKET_COOKIE_NAME = "polymarket";
3
+ export class AuthHandler {
4
+ url;
5
+ httpClient;
6
+ token;
7
+ cookie;
8
+ constructor(httpClient, args) {
9
+ if (args.authUrl === undefined || args.authToken === undefined) {
10
+ throw new Error("invalid authorization arguments");
11
+ }
12
+ this.url = args.authUrl.endsWith("/") ? args.authUrl.slice(0, -1) : args.authUrl;
13
+ this.token = args.authToken;
14
+ this.httpClient = httpClient;
15
+ }
16
+ /**
17
+ * Logs in to the auth url
18
+ * Extracts polymarket session cookies from the auth response header and cache it locally.
19
+ */
20
+ async login() {
21
+ if (this.cookie === undefined) {
22
+ // Logging in will set the session cookies on the httpClient
23
+ const resp = await this.httpClient.send(`${this.url}/login/internal`, GET, {
24
+ Authorization: `Bearer ${this.token}`,
25
+ });
26
+ const cookies = resp.headers["set-cookie"];
27
+ let aggregatedCookie = "";
28
+ for (const cookie of cookies) {
29
+ if (cookie.includes(POLYMARKET_COOKIE_NAME)) {
30
+ aggregatedCookie += `${cookie}; `;
31
+ }
32
+ }
33
+ if (aggregatedCookie !== "") {
34
+ this.cookie = aggregatedCookie;
35
+ }
36
+ console.log(`Successfully logged in!`);
37
+ }
38
+ }
39
+ async getPolymarketCookies() {
40
+ if (this.cookie === undefined) {
41
+ console.log("Authorization not set, logging in...");
42
+ await this.login();
43
+ }
44
+ return this.cookie;
45
+ }
46
+ }
@@ -0,0 +1 @@
1
+ export * from "./handler.ts";
@@ -0,0 +1 @@
1
+ export * from "./handler.js";
@@ -0,0 +1,4 @@
1
+ import type { SafeContractConfig } from "../config/index.ts";
2
+ import type { RelayerSigner } from "../signer/index.ts";
3
+ import { type SafeCreateTransactionArgs, type TransactionRequest } from "../types.ts";
4
+ export declare function buildSafeCreateTransactionRequest(signer: RelayerSigner, safeContractConfig: SafeContractConfig, args: SafeCreateTransactionArgs): Promise<TransactionRequest>;
@@ -0,0 +1,48 @@
1
+ import { SAFE_FACTORY_NAME } from "../constants/index.js";
2
+ import { TransactionType, } from "../types.js";
3
+ import { deriveSafe } from "./derive.js";
4
+ async function createSafeCreateSignature(signer, safeFactory, chainId, paymentToken, payment, paymentReceiver) {
5
+ const domain = {
6
+ name: SAFE_FACTORY_NAME,
7
+ chainId: BigInt(chainId),
8
+ verifyingContract: safeFactory,
9
+ };
10
+ const types = {
11
+ CreateProxy: [
12
+ { name: "paymentToken", type: "address" },
13
+ { name: "payment", type: "uint256" },
14
+ { name: "paymentReceiver", type: "address" },
15
+ ],
16
+ };
17
+ const values = {
18
+ paymentToken,
19
+ payment: BigInt(payment),
20
+ paymentReceiver,
21
+ };
22
+ const sig = await signer.signTypedData(domain, types, values, "CreateProxy");
23
+ console.log(`Sig: ${sig}`);
24
+ return sig;
25
+ }
26
+ export async function buildSafeCreateTransactionRequest(signer, safeContractConfig, args) {
27
+ const safeFactory = safeContractConfig.SafeFactory;
28
+ const sig = await createSafeCreateSignature(signer, safeFactory, args.chainId, args.paymentToken, args.payment, args.paymentReceiver);
29
+ const sigParams = {
30
+ paymentToken: args.paymentToken,
31
+ payment: args.payment,
32
+ paymentReceiver: args.paymentReceiver,
33
+ };
34
+ const safeAddress = deriveSafe(args.from, safeFactory);
35
+ const request = {
36
+ from: args.from,
37
+ to: safeFactory,
38
+ // Note: obviously the safe here does not exist yet but useful to have this data in the db
39
+ proxyWallet: safeAddress,
40
+ data: "0x",
41
+ signature: sig,
42
+ signatureParams: sigParams,
43
+ type: TransactionType.SAFE_CREATE,
44
+ };
45
+ console.log(`Created a SAFE-CREATE Transaction:`);
46
+ console.log(request);
47
+ return request;
48
+ }
@@ -0,0 +1,2 @@
1
+ export declare const deriveProxyWallet: (address: string, proxyFactory: string) => string;
2
+ export declare const deriveSafe: (address: string, safeFactory: string) => string;
@@ -0,0 +1,16 @@
1
+ import { encodeAbiParameters, encodePacked, getCreate2Address, keccak256 } from "viem";
2
+ import { PROXY_INIT_CODE_HASH, SAFE_INIT_CODE_HASH } from "../constants/index.js";
3
+ export const deriveProxyWallet = (address, proxyFactory) => {
4
+ return getCreate2Address({
5
+ bytecodeHash: PROXY_INIT_CODE_HASH,
6
+ from: proxyFactory,
7
+ salt: keccak256(encodePacked(["address"], [address])),
8
+ });
9
+ };
10
+ export const deriveSafe = (address, safeFactory) => {
11
+ return getCreate2Address({
12
+ bytecodeHash: SAFE_INIT_CODE_HASH,
13
+ from: safeFactory,
14
+ salt: keccak256(encodeAbiParameters([{ name: "address", type: "address" }], [address])),
15
+ });
16
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./create.ts";
2
+ export * from "./derive.ts";
3
+ export * from "./proxy.ts";
4
+ export * from "./safe.ts";
@@ -0,0 +1,4 @@
1
+ export * from "./create.js";
2
+ export * from "./derive.js";
3
+ export * from "./proxy.js";
4
+ export * from "./safe.js";
@@ -0,0 +1,4 @@
1
+ import type { ProxyContractConfig } from "../config/index.ts";
2
+ import type { RelayerSigner } from "../signer/index.ts";
3
+ import { type ProxyTransactionArgs, type TransactionRequest } from "../types.ts";
4
+ export declare function buildProxyTransactionRequest(signer: RelayerSigner, args: ProxyTransactionArgs, proxyContractConfig: ProxyContractConfig, metadata?: string): Promise<TransactionRequest>;
@@ -0,0 +1,72 @@
1
+ import { concat, keccak256, toHex } from "viem";
2
+ import { TransactionType, } from "../types.js";
3
+ import { deriveProxyWallet } from "./derive.js";
4
+ function createStructHash(from, to, data, txFee, gasPrice, gasLimit, nonce, relayHubAddress, relayAddress) {
5
+ const relayHubPrefix = toHex("rlx:");
6
+ const encodedFrom = from;
7
+ const encodedTo = to;
8
+ const encodedData = data;
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 });
13
+ const encodedRelayHubAddress = relayHubAddress;
14
+ const encodedRelayAddress = relayAddress;
15
+ const dataToHash = concat([
16
+ relayHubPrefix,
17
+ encodedFrom,
18
+ encodedTo,
19
+ encodedData,
20
+ encodedTxFee,
21
+ encodedGasPrice,
22
+ encodedGasLimit,
23
+ encodedNonce,
24
+ encodedRelayHubAddress,
25
+ encodedRelayAddress,
26
+ ]);
27
+ return keccak256(dataToHash);
28
+ }
29
+ async function createProxySignature(signer, structHash) {
30
+ return signer.signMessage(structHash);
31
+ }
32
+ export async function buildProxyTransactionRequest(signer, args, proxyContractConfig, metadata) {
33
+ const proxyWalletFactory = proxyContractConfig.ProxyFactory;
34
+ const to = proxyWalletFactory;
35
+ const proxy = deriveProxyWallet(args.from, proxyWalletFactory);
36
+ const relayerFee = "0";
37
+ const relayHub = proxyContractConfig.RelayHub;
38
+ const gasLimit = args.gasLimit
39
+ ? args.gasLimit
40
+ : await signer.estimateGas({
41
+ from: args.from,
42
+ to: to,
43
+ data: args.data,
44
+ });
45
+ const gasLimitStr = gasLimit.toString();
46
+ const sigParams = {
47
+ gasPrice: args.gasPrice,
48
+ gasLimit: gasLimitStr,
49
+ relayerFee: relayerFee,
50
+ relayHub: relayHub,
51
+ relay: args.relay,
52
+ };
53
+ const txHash = createStructHash(args.from, to, args.data, relayerFee, args.gasPrice, gasLimitStr, args.nonce, relayHub, args.relay);
54
+ const sig = await createProxySignature(signer, txHash);
55
+ if (metadata === undefined) {
56
+ metadata = "";
57
+ }
58
+ const req = {
59
+ from: args.from,
60
+ to: to,
61
+ proxyWallet: proxy,
62
+ data: args.data,
63
+ nonce: args.nonce,
64
+ signature: sig,
65
+ signatureParams: sigParams,
66
+ type: TransactionType.PROXY,
67
+ metadata: metadata,
68
+ };
69
+ console.log(`Created Proxy Transaction Request:`);
70
+ console.log(req);
71
+ return req;
72
+ }
@@ -0,0 +1,5 @@
1
+ import type { SafeContractConfig } from "../config/index.ts";
2
+ import type { RelayerSigner } from "../signer/index.ts";
3
+ import { type SafeTransaction, type SafeTransactionArgs, type TransactionRequest } from "../types.ts";
4
+ export declare function aggregateTransaction(txns: SafeTransaction[], safeMultisend: string): SafeTransaction;
5
+ export declare function buildSafeTransactionRequest(signer: RelayerSigner, args: SafeTransactionArgs, safeContractConfig: SafeContractConfig, metadata?: string): Promise<TransactionRequest>;
@@ -0,0 +1,105 @@
1
+ import { hashTypedData, zeroAddress } from "viem";
2
+ import { createSafeMultisendTransaction } from "../encode/safe.js";
3
+ import { TransactionType, } from "../types.js";
4
+ import { splitAndPackSig } from "../utils/index.js";
5
+ import { deriveSafe } from "./derive.js";
6
+ async function createSafeSignature(signer, structHash) {
7
+ return signer.signMessage(structHash);
8
+ }
9
+ function createStructHash(chainId, safe, to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, nonce) {
10
+ const domain = {
11
+ chainId: chainId,
12
+ verifyingContract: safe,
13
+ };
14
+ const types = {
15
+ // keccak256(
16
+ // "SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)"
17
+ // );
18
+ SafeTx: [
19
+ { name: "to", type: "address" },
20
+ { name: "value", type: "uint256" },
21
+ { name: "data", type: "bytes" },
22
+ { name: "operation", type: "uint8" },
23
+ { name: "safeTxGas", type: "uint256" },
24
+ { name: "baseGas", type: "uint256" },
25
+ { name: "gasPrice", type: "uint256" },
26
+ { name: "gasToken", type: "address" },
27
+ { name: "refundReceiver", type: "address" },
28
+ { name: "nonce", type: "uint256" },
29
+ ],
30
+ };
31
+ const values = {
32
+ to: to,
33
+ value: value,
34
+ data: data,
35
+ operation: operation,
36
+ safeTxGas: safeTxGas,
37
+ baseGas: baseGas,
38
+ gasPrice: gasPrice,
39
+ gasToken: gasToken,
40
+ refundReceiver: refundReceiver,
41
+ nonce: nonce,
42
+ };
43
+ // // viem hashTypedData
44
+ // const structHash = _TypedDataEncoder.hash(domain, types, values);
45
+ const structHash = hashTypedData({
46
+ primaryType: "SafeTx",
47
+ domain: domain,
48
+ types: types,
49
+ message: values,
50
+ });
51
+ return structHash;
52
+ }
53
+ export function aggregateTransaction(txns, safeMultisend) {
54
+ let transaction;
55
+ if (txns.length === 1) {
56
+ transaction = txns[0];
57
+ }
58
+ else {
59
+ transaction = createSafeMultisendTransaction(txns, safeMultisend);
60
+ }
61
+ return transaction;
62
+ }
63
+ export async function buildSafeTransactionRequest(signer, args, safeContractConfig, metadata) {
64
+ const safeFactory = safeContractConfig.SafeFactory;
65
+ const safeMultisend = safeContractConfig.SafeMultisend;
66
+ const transaction = aggregateTransaction(args.transactions, safeMultisend);
67
+ const safeTxnGas = "0";
68
+ const baseGas = "0";
69
+ const gasPrice = "0";
70
+ const gasToken = zeroAddress;
71
+ const refundReceiver = zeroAddress;
72
+ const safeAddress = deriveSafe(args.from, safeFactory);
73
+ // Generate the struct hash
74
+ // NOTE: this includes a client side optimization over the current relayers
75
+ // Generates struct hash locally instead of going across the network using the RPC call
76
+ const structHash = createStructHash(args.chainId, safeAddress, transaction.to, transaction.value, transaction.data, transaction.operation, safeTxnGas, baseGas, gasPrice, gasToken, refundReceiver, args.nonce);
77
+ const sig = await createSafeSignature(signer, structHash);
78
+ // Split the sig then pack it into Gnosis accepted rsv format
79
+ const packedSig = splitAndPackSig(sig);
80
+ const sigParams = {
81
+ gasPrice,
82
+ operation: `${transaction.operation}`,
83
+ safeTxnGas,
84
+ baseGas,
85
+ gasToken,
86
+ refundReceiver,
87
+ };
88
+ if (metadata === undefined) {
89
+ metadata = "";
90
+ }
91
+ const req = {
92
+ from: args.from,
93
+ to: transaction.to,
94
+ proxyWallet: safeAddress,
95
+ data: transaction.data,
96
+ nonce: args.nonce,
97
+ signature: packedSig,
98
+ signatureParams: sigParams,
99
+ type: TransactionType.SAFE,
100
+ metadata: metadata,
101
+ };
102
+ console.log(`Created Safe Transaction Request: `);
103
+ console.log(req);
104
+ return req;
105
+ }
@@ -0,0 +1,39 @@
1
+ import { type WalletClient } from "viem";
2
+ import { AuthHandler } from "./auth/handler.ts";
3
+ import { type ContractConfig } from "./config/index.ts";
4
+ import { HttpClient } from "./http-helpers/index.ts";
5
+ import { type RelayerSigner } from "./signer/index.ts";
6
+ import { type AddressPayload, type AuthArgs, type IManualTransactionResponse, type ManualOverrides, type NoncePayload, type ProxyTransaction, type RelayerTransaction, type RelayerTransactionResponse, type RelayPayload, type SafeTransaction } from "./types.ts";
7
+ export declare class RelayClient {
8
+ readonly relayerUrl: string;
9
+ readonly chainId: number;
10
+ readonly contractConfig: ContractConfig;
11
+ readonly httpClient: HttpClient;
12
+ readonly signer?: RelayerSigner;
13
+ readonly authHandler?: AuthHandler;
14
+ constructor(relayerUrl: string, chainId: number, signer?: WalletClient, authArgs?: AuthArgs);
15
+ getRelayAddress(): Promise<AddressPayload>;
16
+ getNonce(signerAddress: string, signerType: string): Promise<NoncePayload>;
17
+ getRelayPayload(signerAddress: string, signerType: string): Promise<RelayPayload>;
18
+ getTransaction(transactionId: string): Promise<RelayerTransaction[]>;
19
+ getTransactions(): Promise<RelayerTransaction[]>;
20
+ executeProxyTransactions(txns: ProxyTransaction[], metadata?: string): Promise<RelayerTransactionResponse>;
21
+ executeSafeTransactions(txns: SafeTransaction[], metadata?: string): Promise<RelayerTransactionResponse>;
22
+ executeManualTransactions(txns: SafeTransaction[], overrides?: ManualOverrides): Promise<IManualTransactionResponse>;
23
+ deploySafe(): Promise<RelayerTransactionResponse>;
24
+ /**
25
+ * Periodically polls the transaction id until it reaches a desired state
26
+ * Returns the relayer transaction if it does each the desired state
27
+ * Returns undefined if the transaction hits the failed state
28
+ * Times out after maxPolls is reached
29
+ * @param transactionId
30
+ * @param states
31
+ * @param failState
32
+ * @param maxPolls
33
+ * @param pollFrequency
34
+ * @returns
35
+ */
36
+ pollUntilState(transactionId: string, states: string[], failState?: string, maxPolls?: number, pollFrequency?: number): Promise<RelayerTransaction | undefined>;
37
+ private submitTransaction;
38
+ private send;
39
+ }