@polymarket/relayer-client 1.0.14 → 1.0.15

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 (149) hide show
  1. package/dist/builder/create.d.ts +2 -3
  2. package/dist/builder/create.js +3 -4
  3. package/dist/builder/proxy.d.ts +2 -3
  4. package/dist/builder/proxy.js +10 -6
  5. package/dist/builder/safe.d.ts +2 -3
  6. package/dist/builder/safe.js +11 -8
  7. package/dist/builder/utils.js +4 -2
  8. package/dist/client.d.ts +18 -7
  9. package/dist/client.js +20 -26
  10. package/dist/encode/proxy.js +2 -1
  11. package/dist/encode/safe.js +3 -2
  12. package/dist/encode/utils.js +3 -4
  13. package/dist/http-helpers/index.js +1 -1
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +1 -0
  16. package/dist/manual/index.d.ts +3 -3
  17. package/dist/manual/index.js +17 -12
  18. package/dist/response/index.d.ts +2 -12
  19. package/dist/response/index.js +2 -25
  20. package/dist/{src/response → response}/relayer.js +0 -1
  21. package/dist/{src/response → response}/viem.js +0 -1
  22. package/dist/{src/signeradapter → signeradapter}/adapter.js +11 -9
  23. package/dist/{src/signeradapter → signeradapter}/index.js +0 -1
  24. package/dist/{src/signeradapter → signeradapter}/interfaces.d.ts +1 -1
  25. package/dist/{src/signeradapter → signeradapter}/interfaces.js +0 -1
  26. package/dist/types.d.ts +1 -1
  27. package/dist/types.js +4 -4
  28. package/dist/utils/index.js +1 -2
  29. package/package.json +1 -1
  30. package/dist/examples/deploySafe.d.ts +0 -1
  31. package/dist/examples/deploySafe.js +0 -30
  32. package/dist/examples/deploySafe.js.map +0 -1
  33. package/dist/examples/getAddress.d.ts +0 -1
  34. package/dist/examples/getAddress.js +0 -23
  35. package/dist/examples/getAddress.js.map +0 -1
  36. package/dist/examples/getNonce.d.ts +0 -1
  37. package/dist/examples/getNonce.js +0 -27
  38. package/dist/examples/getNonce.js.map +0 -1
  39. package/dist/examples/getRelayPayload.d.ts +0 -1
  40. package/dist/examples/getRelayPayload.js +0 -27
  41. package/dist/examples/getRelayPayload.js.map +0 -1
  42. package/dist/examples/getTransaction.d.ts +0 -1
  43. package/dist/examples/getTransaction.js +0 -23
  44. package/dist/examples/getTransaction.js.map +0 -1
  45. package/dist/examples/getTransactions.d.ts +0 -1
  46. package/dist/examples/getTransactions.js +0 -23
  47. package/dist/examples/getTransactions.js.map +0 -1
  48. package/dist/examples/poll.d.ts +0 -1
  49. package/dist/examples/poll.js +0 -26
  50. package/dist/examples/poll.js.map +0 -1
  51. package/dist/examples/proxyExecute.d.ts +0 -1
  52. package/dist/examples/proxyExecute.js +0 -45
  53. package/dist/examples/proxyExecute.js.map +0 -1
  54. package/dist/examples/safeExecute.d.ts +0 -1
  55. package/dist/examples/safeExecute.js +0 -45
  56. package/dist/examples/safeExecute.js.map +0 -1
  57. package/dist/examples/safeExecuteFail.d.ts +0 -1
  58. package/dist/examples/safeExecuteFail.js +0 -55
  59. package/dist/examples/safeExecuteFail.js.map +0 -1
  60. package/dist/examples/safeExecuteManual.d.ts +0 -1
  61. package/dist/examples/safeExecuteManual.js +0 -45
  62. package/dist/examples/safeExecuteManual.js.map +0 -1
  63. package/dist/src/abis/erc20Abi.d.ts +0 -38
  64. package/dist/src/abis/erc20Abi.js +0 -226
  65. package/dist/src/abis/erc20Abi.js.map +0 -1
  66. package/dist/src/abis/index.d.ts +0 -5
  67. package/dist/src/abis/index.js +0 -9
  68. package/dist/src/abis/index.js.map +0 -1
  69. package/dist/src/abis/multisend.d.ts +0 -13
  70. package/dist/src/abis/multisend.js +0 -21
  71. package/dist/src/abis/multisend.js.map +0 -1
  72. package/dist/src/abis/proxyFactory.d.ts +0 -66
  73. package/dist/src/abis/proxyFactory.js +0 -323
  74. package/dist/src/abis/proxyFactory.js.map +0 -1
  75. package/dist/src/abis/safe.d.ts +0 -35
  76. package/dist/src/abis/safe.js +0 -1142
  77. package/dist/src/abis/safe.js.map +0 -1
  78. package/dist/src/abis/safeFactory.d.ts +0 -60
  79. package/dist/src/abis/safeFactory.js +0 -228
  80. package/dist/src/abis/safeFactory.js.map +0 -1
  81. package/dist/src/auth/handler.d.ts +0 -15
  82. package/dist/src/auth/handler.js +0 -50
  83. package/dist/src/auth/handler.js.map +0 -1
  84. package/dist/src/auth/index.d.ts +0 -1
  85. package/dist/src/auth/index.js +0 -5
  86. package/dist/src/auth/index.js.map +0 -1
  87. package/dist/src/builder/create.d.ts +0 -3
  88. package/dist/src/builder/create.js +0 -56
  89. package/dist/src/builder/create.js.map +0 -1
  90. package/dist/src/builder/index.d.ts +0 -4
  91. package/dist/src/builder/index.js +0 -8
  92. package/dist/src/builder/index.js.map +0 -1
  93. package/dist/src/builder/proxy.d.ts +0 -3
  94. package/dist/src/builder/proxy.js +0 -94
  95. package/dist/src/builder/proxy.js.map +0 -1
  96. package/dist/src/builder/safe.d.ts +0 -4
  97. package/dist/src/builder/safe.js +0 -131
  98. package/dist/src/builder/safe.js.map +0 -1
  99. package/dist/src/builder/utils.d.ts +0 -2
  100. package/dist/src/builder/utils.js +0 -14
  101. package/dist/src/builder/utils.js.map +0 -1
  102. package/dist/src/client.d.ts +0 -37
  103. package/dist/src/client.js +0 -187
  104. package/dist/src/client.js.map +0 -1
  105. package/dist/src/constants/index.d.ts +0 -7
  106. package/dist/src/constants/index.js +0 -11
  107. package/dist/src/constants/index.js.map +0 -1
  108. package/dist/src/encode/index.d.ts +0 -3
  109. package/dist/src/encode/index.js +0 -7
  110. package/dist/src/encode/index.js.map +0 -1
  111. package/dist/src/encode/proxy.d.ts +0 -2
  112. package/dist/src/encode/proxy.js +0 -11
  113. package/dist/src/encode/proxy.js.map +0 -1
  114. package/dist/src/encode/safe.d.ts +0 -2
  115. package/dist/src/encode/safe.js +0 -22
  116. package/dist/src/encode/safe.js.map +0 -1
  117. package/dist/src/encode/utils.d.ts +0 -6
  118. package/dist/src/encode/utils.js +0 -48
  119. package/dist/src/encode/utils.js.map +0 -1
  120. package/dist/src/endpoints.d.ts +0 -5
  121. package/dist/src/endpoints.js +0 -9
  122. package/dist/src/endpoints.js.map +0 -1
  123. package/dist/src/http-helpers/index.d.ts +0 -10
  124. package/dist/src/http-helpers/index.js +0 -54
  125. package/dist/src/http-helpers/index.js.map +0 -1
  126. package/dist/src/index.d.ts +0 -3
  127. package/dist/src/index.js +0 -7
  128. package/dist/src/index.js.map +0 -1
  129. package/dist/src/manual/index.d.ts +0 -5
  130. package/dist/src/manual/index.js +0 -33
  131. package/dist/src/manual/index.js.map +0 -1
  132. package/dist/src/response/index.d.ts +0 -2
  133. package/dist/src/response/index.js +0 -6
  134. package/dist/src/response/index.js.map +0 -1
  135. package/dist/src/response/relayer.js.map +0 -1
  136. package/dist/src/response/viem.js.map +0 -1
  137. package/dist/src/signeradapter/adapter.js.map +0 -1
  138. package/dist/src/signeradapter/index.js.map +0 -1
  139. package/dist/src/signeradapter/interfaces.js.map +0 -1
  140. package/dist/src/types.d.ts +0 -127
  141. package/dist/src/types.js +0 -32
  142. package/dist/src/types.js.map +0 -1
  143. package/dist/src/utils/index.d.ts +0 -1
  144. package/dist/src/utils/index.js +0 -8
  145. package/dist/src/utils/index.js.map +0 -1
  146. /package/dist/{src/response → response}/relayer.d.ts +0 -0
  147. /package/dist/{src/response → response}/viem.d.ts +0 -0
  148. /package/dist/{src/signeradapter → signeradapter}/adapter.d.ts +0 -0
  149. /package/dist/{src/signeradapter → signeradapter}/index.d.ts +0 -0
@@ -1,4 +1,3 @@
1
- import { Wallet } from "@ethersproject/wallet";
2
- import { JsonRpcSigner } from "@ethersproject/providers";
3
1
  import { SafeCreateTransactionArgs, TransactionRequest } from "../types";
4
- export declare function buildSafeCreateTransactionRequest(signer: Wallet | JsonRpcSigner, args: SafeCreateTransactionArgs): Promise<TransactionRequest>;
2
+ import { SignerAdapter } from "../signeradapter";
3
+ export declare function buildSafeCreateTransactionRequest(signer: SignerAdapter, args: SafeCreateTransactionArgs): Promise<TransactionRequest>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildSafeCreateTransactionRequest = void 0;
3
+ exports.buildSafeCreateTransactionRequest = buildSafeCreateTransactionRequest;
4
4
  const tslib_1 = require("tslib");
5
5
  const ethers_1 = require("ethers");
6
6
  const types_1 = require("../types");
@@ -25,7 +25,7 @@ function createSafeCreateSignature(signer, chainId, paymentToken, payment, payme
25
25
  payment: ethers_1.BigNumber.from(payment),
26
26
  paymentReceiver,
27
27
  };
28
- return signer._signTypedData(domain, types, values);
28
+ return signer.signTypedData(domain, types, values);
29
29
  });
30
30
  }
31
31
  function buildSafeCreateTransactionRequest(signer, args) {
@@ -36,7 +36,7 @@ function buildSafeCreateTransactionRequest(signer, args) {
36
36
  payment: args.payment,
37
37
  paymentReceiver: args.paymentReceiver,
38
38
  };
39
- const safeAddress = utils_1.deriveSafe(args.from);
39
+ const safeAddress = (0, utils_1.deriveSafe)(args.from);
40
40
  const request = {
41
41
  from: args.from,
42
42
  to: constants_1.SAFE_FACTORY_ADDRESS,
@@ -52,4 +52,3 @@ function buildSafeCreateTransactionRequest(signer, args) {
52
52
  return request;
53
53
  });
54
54
  }
55
- exports.buildSafeCreateTransactionRequest = buildSafeCreateTransactionRequest;
@@ -1,4 +1,3 @@
1
- import { Wallet } from "@ethersproject/wallet";
2
- import { JsonRpcSigner, Provider } from "@ethersproject/providers";
3
1
  import { ProxyTransactionArgs, TransactionRequest } from "../types";
4
- export declare function buildProxyTransactionRequest(signer: Wallet | JsonRpcSigner, provider: Provider, args: ProxyTransactionArgs): Promise<TransactionRequest>;
2
+ import { SignerAdapter } from "../signeradapter";
3
+ export declare function buildProxyTransactionRequest(signer: SignerAdapter, args: ProxyTransactionArgs, metadata?: string): Promise<TransactionRequest>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildProxyTransactionRequest = void 0;
3
+ exports.buildProxyTransactionRequest = buildProxyTransactionRequest;
4
4
  const tslib_1 = require("tslib");
5
5
  const web3_utils_1 = tslib_1.__importDefault(require("web3-utils"));
6
6
  const constants_1 = require("../constants");
@@ -42,19 +42,20 @@ function createStructHash(from, to, data, txFee, gasPrice, gasLimit, nonce, rela
42
42
  toUint256NoPrefix(ethers_1.BigNumber.from(nonce).toHexString()) +
43
43
  removeHexPrefix(relayHubAddress) +
44
44
  removeHexPrefix(relayAddress);
45
- return utils_2.keccak256("0x" + dataToHash);
45
+ return (0, utils_2.keccak256)("0x" + dataToHash);
46
46
  }
47
47
  function createProxySignature(signer, structHash) {
48
48
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
49
- return signer.signMessage(utils_2.arrayify(structHash));
49
+ return signer.signMessage(structHash);
50
50
  });
51
51
  }
52
- function buildProxyTransactionRequest(signer, provider, args) {
52
+ function buildProxyTransactionRequest(signer, args, metadata) {
53
53
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
54
54
  const to = constants_1.PROXY_WALLET_FACTORY_ADDRESS;
55
- const proxy = utils_1.deriveProxyWallet(args.from);
55
+ const proxy = (0, utils_1.deriveProxyWallet)(args.from);
56
56
  const relayerFee = "0";
57
57
  const relayHub = constants_1.RELAY_HUB_ADDRESS;
58
+ const provider = yield signer.getProvider();
58
59
  const gasLimit = yield provider.estimateGas({
59
60
  from: args.from,
60
61
  to: to,
@@ -70,6 +71,9 @@ function buildProxyTransactionRequest(signer, provider, args) {
70
71
  };
71
72
  const txHash = createStructHash(args.from, to, args.data, relayerFee, args.gasPrice, gasLimitStr, args.nonce, relayHub, args.relay);
72
73
  const sig = yield createProxySignature(signer, txHash);
74
+ if (metadata == undefined) {
75
+ metadata = "";
76
+ }
73
77
  const req = {
74
78
  from: args.from,
75
79
  to: to,
@@ -79,10 +83,10 @@ function buildProxyTransactionRequest(signer, provider, args) {
79
83
  signature: sig,
80
84
  signatureParams: sigParams,
81
85
  type: types_1.TransactionType.PROXY,
86
+ metadata: metadata,
82
87
  };
83
88
  console.log(`Created Proxy Transaction Request:`);
84
89
  console.log(req);
85
90
  return req;
86
91
  });
87
92
  }
88
- exports.buildProxyTransactionRequest = buildProxyTransactionRequest;
@@ -1,5 +1,4 @@
1
- import { Wallet } from "@ethersproject/wallet";
2
- import { JsonRpcSigner } from "@ethersproject/providers";
3
1
  import { SafeTransaction, SafeTransactionArgs, TransactionRequest } from "../types";
2
+ import { SignerAdapter } from "../signeradapter";
4
3
  export declare function aggregateTransaction(txns: SafeTransaction[]): SafeTransaction;
5
- export declare function buildSafeTransactionRequest(signer: Wallet | JsonRpcSigner, args: SafeTransactionArgs): Promise<TransactionRequest>;
4
+ export declare function buildSafeTransactionRequest(signer: SignerAdapter, args: SafeTransactionArgs, metadata?: string): Promise<TransactionRequest>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildSafeTransactionRequest = exports.aggregateTransaction = void 0;
3
+ exports.aggregateTransaction = aggregateTransaction;
4
+ exports.buildSafeTransactionRequest = buildSafeTransactionRequest;
4
5
  const tslib_1 = require("tslib");
5
6
  const types_1 = require("../types");
6
7
  const utils_1 = require("./utils");
@@ -10,7 +11,7 @@ const safe_1 = require("../encode/safe");
10
11
  const utils_3 = require("../encode/utils");
11
12
  function createSafeSignature(signer, structHash) {
12
13
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
- return signer.signMessage(ethers_1.ethers.utils.arrayify(structHash));
14
+ return signer.signMessage(structHash);
14
15
  });
15
16
  }
16
17
  function splitSignature(sig) {
@@ -78,12 +79,11 @@ function aggregateTransaction(txns) {
78
79
  transaction = txns[0];
79
80
  }
80
81
  else {
81
- transaction = safe_1.createSafeMultisendTransaction(txns);
82
+ transaction = (0, safe_1.createSafeMultisendTransaction)(txns);
82
83
  }
83
84
  return transaction;
84
85
  }
85
- exports.aggregateTransaction = aggregateTransaction;
86
- function buildSafeTransactionRequest(signer, args) {
86
+ function buildSafeTransactionRequest(signer, args, metadata) {
87
87
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
88
88
  const transaction = aggregateTransaction(args.transactions);
89
89
  const safeTxnGas = "0";
@@ -91,7 +91,7 @@ function buildSafeTransactionRequest(signer, args) {
91
91
  const gasPrice = "0";
92
92
  const gasToken = ethers_1.ethers.constants.AddressZero;
93
93
  const refundReceiver = ethers_1.ethers.constants.AddressZero;
94
- const safeAddress = utils_1.deriveSafe(args.from);
94
+ const safeAddress = (0, utils_1.deriveSafe)(args.from);
95
95
  // Generate the struct hash
96
96
  // NOTE: this includes a client side optimization over the current relayers
97
97
  // Generates struct hash locally instead of going across the network using the RPC call
@@ -99,7 +99,7 @@ function buildSafeTransactionRequest(signer, args) {
99
99
  const sig = yield createSafeSignature(signer, structHash);
100
100
  // Split the sig then pack it into Gnosis accepted rsv format
101
101
  const splitSig = splitSignature(sig);
102
- const packedSig = utils_3.abiEncodePacked({ type: "uint256", value: splitSig.r }, { type: "uint256", value: splitSig.s }, { type: "uint8", value: splitSig.v });
102
+ const packedSig = (0, utils_3.abiEncodePacked)({ type: "uint256", value: splitSig.r }, { type: "uint256", value: splitSig.s }, { type: "uint8", value: splitSig.v });
103
103
  const sigParams = {
104
104
  gasPrice,
105
105
  operation: `${transaction.operation}`,
@@ -108,6 +108,9 @@ function buildSafeTransactionRequest(signer, args) {
108
108
  gasToken,
109
109
  refundReceiver,
110
110
  };
111
+ if (metadata == undefined) {
112
+ metadata = "";
113
+ }
111
114
  const req = {
112
115
  from: args.from,
113
116
  to: transaction.to,
@@ -117,10 +120,10 @@ function buildSafeTransactionRequest(signer, args) {
117
120
  signature: packedSig,
118
121
  signatureParams: sigParams,
119
122
  type: types_1.TransactionType.SAFE,
123
+ metadata: metadata,
120
124
  };
121
125
  console.log(`Created Safe Transaction Request: `);
122
126
  console.log(req);
123
127
  return req;
124
128
  });
125
129
  }
126
- exports.buildSafeTransactionRequest = buildSafeTransactionRequest;
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deriveSafe = exports.deriveProxyWallet = void 0;
4
4
  const ethers_1 = require("ethers");
5
5
  const constants_1 = require("../constants");
6
- exports.deriveProxyWallet = (address) => {
6
+ const deriveProxyWallet = (address) => {
7
7
  return ethers_1.ethers.utils.getCreate2Address(constants_1.PROXY_WALLET_FACTORY_ADDRESS, ethers_1.ethers.utils.solidityKeccak256(["address"], [address]), constants_1.PROXY_INIT_CODE_HASH);
8
8
  };
9
- exports.deriveSafe = (address) => {
9
+ exports.deriveProxyWallet = deriveProxyWallet;
10
+ const deriveSafe = (address) => {
10
11
  return ethers_1.ethers.utils.getCreate2Address(constants_1.SAFE_FACTORY_ADDRESS, ethers_1.ethers.utils.keccak256(ethers_1.ethers.utils.defaultAbiCoder.encode(["address"], [address])), constants_1.SAFE_INIT_CODE_HASH);
11
12
  };
13
+ exports.deriveSafe = deriveSafe;
package/dist/client.d.ts CHANGED
@@ -1,25 +1,36 @@
1
- import { Wallet } from "@ethersproject/wallet";
2
- import { JsonRpcSigner, TransactionResponse, Provider } from "@ethersproject/providers";
1
+ import { Provider, TransactionResponse } from "@ethersproject/providers";
3
2
  import { HttpClient } from "./http-helpers";
4
3
  import { AddressPayload, AuthArgs, ManualOverrides, NoncePayload, ProxyTransaction, RelayerTransaction, RelayerTransactionResponse, RelayPayload, SafeTransaction } from "./types";
5
4
  import { AuthHandler } from "./auth";
5
+ import { ViemTransactionResponse } from "./response";
6
+ import { SignerAdapter } from "./signeradapter";
6
7
  export declare class RelayClient {
7
8
  readonly relayerUrl: string;
8
9
  readonly chainId: number;
9
10
  readonly httpClient: HttpClient;
10
- readonly signer?: Wallet | JsonRpcSigner;
11
+ readonly signer?: SignerAdapter;
11
12
  readonly provider?: Provider;
12
13
  readonly authHandler?: AuthHandler;
13
- constructor(relayerUrl: string, chainId: number, signer?: Wallet | JsonRpcSigner, provider?: Provider, authArgs?: AuthArgs);
14
+ constructor(relayerUrl: string, chainId: number, signer?: SignerAdapter, authArgs?: AuthArgs);
14
15
  getRelayAddress(): Promise<AddressPayload>;
15
16
  getNonce(signerAddress: string, signerType: string): Promise<NoncePayload>;
16
17
  getRelayPayload(signerAddress: string, signerType: string): Promise<RelayPayload>;
17
18
  getTransaction(transactionId: string): Promise<RelayerTransaction[]>;
18
19
  getTransactions(): Promise<RelayerTransaction[]>;
19
- executeProxyTransactions(txns: ProxyTransaction[]): Promise<RelayerTransactionResponse>;
20
- executeSafeTransactions(txns: SafeTransaction[]): Promise<RelayerTransactionResponse>;
21
- executeManualTransactions(txns: SafeTransaction[], overrides?: ManualOverrides): Promise<TransactionResponse>;
20
+ executeProxyTransactions(txns: ProxyTransaction[], metadata?: string): Promise<RelayerTransactionResponse>;
21
+ executeSafeTransactions(txns: SafeTransaction[], metadata?: string): Promise<RelayerTransactionResponse>;
22
+ executeManualTransactions(txns: SafeTransaction[], overrides?: ManualOverrides): Promise<TransactionResponse | ViemTransactionResponse>;
22
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
+ * Times out after maxPolls is reached
28
+ * @param transactionId
29
+ * @param states
30
+ * @param maxPolls
31
+ * @param pollFrequency
32
+ * @returns
33
+ */
23
34
  pollUntilState(transactionId: string, states: string[], maxPolls?: number, pollFrequency?: number): Promise<RelayerTransaction | undefined>;
24
35
  private submitTransaction;
25
36
  private send;
package/dist/client.js CHANGED
@@ -14,22 +14,12 @@ const utils_1 = require("./utils");
14
14
  const manual_1 = require("./manual");
15
15
  const response_1 = require("./response");
16
16
  class RelayClient {
17
- constructor(relayerUrl, chainId, signer, provider, authArgs) {
17
+ constructor(relayerUrl, chainId, signer, authArgs) {
18
18
  this.relayerUrl = relayerUrl.endsWith("/") ? relayerUrl.slice(0, -1) : relayerUrl;
19
19
  this.chainId = chainId;
20
20
  this.httpClient = new http_helpers_1.HttpClient();
21
- // If the provider is not given, fetch the provider from the signer
22
- if (provider != undefined) {
23
- this.provider = provider;
24
- }
25
21
  if (signer != undefined) {
26
22
  this.signer = signer;
27
- if (signer.provider == undefined && this.provider == undefined) {
28
- throw new Error("signer must have provider attached");
29
- }
30
- if (provider == undefined) {
31
- this.provider = this.signer.provider;
32
- }
33
23
  }
34
24
  if (authArgs !== undefined) {
35
25
  this.authHandler = new auth_1.AuthHandler(this.httpClient, authArgs);
@@ -60,31 +50,28 @@ class RelayClient {
60
50
  return this.send(`${this.relayerUrl}${endpoints_1.GET_TRANSACTION}s`, http_helpers_1.GET);
61
51
  });
62
52
  }
63
- executeProxyTransactions(txns) {
53
+ executeProxyTransactions(txns, metadata) {
64
54
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
65
55
  if (this.signer == undefined) {
66
56
  throw new Error("missing signer");
67
57
  }
68
- if (this.provider == undefined) {
69
- throw new Error("missing provider");
70
- }
71
58
  const start = Date.now();
72
59
  const from = yield this.signer.getAddress();
73
60
  const rp = yield this.getRelayPayload(from, types_1.TransactionType.PROXY);
74
61
  const args = {
75
62
  from: from,
76
63
  gasPrice: "0",
77
- data: encode_1.encodeProxyTransactionData(txns),
64
+ data: (0, encode_1.encodeProxyTransactionData)(txns),
78
65
  relay: rp.address,
79
66
  nonce: rp.nonce,
80
67
  };
81
- const request = yield builder_1.buildProxyTransactionRequest(this.signer, this.provider, args);
68
+ const request = yield (0, builder_1.buildProxyTransactionRequest)(this.signer, args, metadata);
82
69
  console.log(`Client side proxy request creation took: ${(Date.now() - start) / 1000} seconds`);
83
70
  const resp = yield this.submitTransaction(request);
84
71
  return new response_1.ClientRelayerTransactionResponse(resp.transactionID, resp.state, resp.transactionHash, this);
85
72
  });
86
73
  }
87
- executeSafeTransactions(txns) {
74
+ executeSafeTransactions(txns, metadata) {
88
75
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
89
76
  if (this.signer == undefined) {
90
77
  throw new Error("missing signer");
@@ -99,7 +86,7 @@ class RelayClient {
99
86
  nonce: noncePayload.nonce,
100
87
  chainId: this.chainId,
101
88
  };
102
- const request = yield builder_1.buildSafeTransactionRequest(this.signer, args);
89
+ const request = yield (0, builder_1.buildSafeTransactionRequest)(this.signer, args, metadata);
103
90
  console.log(`Client side safe request creation took: ${(Date.now() - start) / 1000} seconds`);
104
91
  const resp = yield this.submitTransaction(request);
105
92
  return new response_1.ClientRelayerTransactionResponse(resp.transactionID, resp.state, resp.transactionHash, this);
@@ -113,12 +100,12 @@ class RelayClient {
113
100
  if (this.signer == undefined) {
114
101
  throw new Error("missing signer");
115
102
  }
116
- return manual_1.executeManualTransactions(this.signer, txns, overrides);
103
+ return (0, manual_1.executeManualTransactions)(this.signer, txns, overrides);
117
104
  });
118
105
  }
119
106
  deploySafe() {
120
- var _a;
121
107
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
108
+ var _a;
122
109
  if (this.signer == undefined) {
123
110
  throw new Error("missing signer");
124
111
  }
@@ -131,15 +118,22 @@ class RelayClient {
131
118
  payment: "0",
132
119
  paymentReceiver: ethers_1.ethers.constants.AddressZero,
133
120
  };
134
- const request = yield builder_1.buildSafeCreateTransactionRequest(this.signer, args);
121
+ const request = yield (0, builder_1.buildSafeCreateTransactionRequest)(this.signer, args);
135
122
  console.log(`Client side deploy request creation took: ${(Date.now() - start) / 1000} seconds`);
136
123
  const resp = yield this.submitTransaction(request);
137
124
  return new response_1.ClientRelayerTransactionResponse(resp.transactionID, resp.state, resp.transactionHash, this);
138
125
  });
139
126
  }
140
- // Periodically polls the transaction id until it reaches a desired state
141
- // Returns the relayer transaction if it does each the desired state
142
- // Times out after 10s
127
+ /**
128
+ * Periodically polls the transaction id until it reaches a desired state
129
+ * Returns the relayer transaction if it does each the desired state
130
+ * Times out after maxPolls is reached
131
+ * @param transactionId
132
+ * @param states
133
+ * @param maxPolls
134
+ * @param pollFrequency
135
+ * @returns
136
+ */
143
137
  pollUntilState(transactionId, states, maxPolls, pollFrequency) {
144
138
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
145
139
  console.log(`Waiting for transaction ${transactionId} matching states: ${states}...`);
@@ -160,7 +154,7 @@ class RelayClient {
160
154
  }
161
155
  }
162
156
  pollCount++;
163
- yield utils_1.sleep(pollFreq);
157
+ yield (0, utils_1.sleep)(pollFreq);
164
158
  }
165
159
  console.log(`Transaction not found or not in given states, timing out`);
166
160
  });
@@ -4,6 +4,7 @@ exports.encodeProxyTransactionData = void 0;
4
4
  const utils_1 = require("ethers/lib/utils");
5
5
  const abis_1 = require("../abis");
6
6
  const factoryInterface = new utils_1.Interface(abis_1.proxyWalletFactory);
7
- exports.encodeProxyTransactionData = (txns) => {
7
+ const encodeProxyTransactionData = (txns) => {
8
8
  return factoryInterface.encodeFunctionData("proxy((uint8,address,uint256,bytes)[])", [txns]);
9
9
  };
10
+ exports.encodeProxyTransactionData = encodeProxyTransactionData;
@@ -7,9 +7,9 @@ const abis_1 = require("../abis");
7
7
  const types_1 = require("../types");
8
8
  const utils_2 = require("./utils");
9
9
  const multisendInterface = new utils_1.Interface(abis_1.multisendAbi);
10
- exports.createSafeMultisendTransaction = (txns) => {
10
+ const createSafeMultisendTransaction = (txns) => {
11
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 }))),
12
+ (0, utils_2.joinHexData)(txns.map(tx => (0, utils_2.abiEncodePacked)({ type: "uint8", value: tx.operation }, { type: "address", value: tx.to }, { type: "uint256", value: tx.value }, { type: "uint256", value: (0, utils_2.getHexDataLength)(tx.data) }, { type: "bytes", value: tx.data }))),
13
13
  ]);
14
14
  return {
15
15
  to: constants_1.SAFE_MULTISEND_ADDRESS,
@@ -18,3 +18,4 @@ exports.createSafeMultisendTransaction = (txns) => {
18
18
  operation: types_1.OperationType.DelegateCall,
19
19
  };
20
20
  };
21
+ exports.createSafeMultisendTransaction = createSafeMultisendTransaction;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getHexDataLength = exports.abiEncodePacked = exports.joinHexData = void 0;
3
+ exports.joinHexData = joinHexData;
4
+ exports.abiEncodePacked = abiEncodePacked;
5
+ exports.getHexDataLength = getHexDataLength;
4
6
  const abi_1 = require("@ethersproject/abi");
5
7
  function joinHexData(hexData) {
6
8
  return `0x${hexData
@@ -10,7 +12,6 @@ function joinHexData(hexData) {
10
12
  })
11
13
  .join('')}`;
12
14
  }
13
- exports.joinHexData = joinHexData;
14
15
  function abiEncodePacked(...params) {
15
16
  return joinHexData(params.map(({ type, value }) => {
16
17
  const encoded = abi_1.defaultAbiCoder.encode([type], [value]);
@@ -40,8 +41,6 @@ function abiEncodePacked(...params) {
40
41
  throw new Error(`unsupported type ${type}`);
41
42
  }));
42
43
  }
43
- exports.abiEncodePacked = abiEncodePacked;
44
44
  function getHexDataLength(hexData) {
45
45
  return Math.ceil((hexData.startsWith("0x") ? hexData.length - 2 : hexData.length) / 2);
46
46
  }
47
- exports.getHexDataLength = getHexDataLength;
@@ -12,8 +12,8 @@ class HttpClient {
12
12
  this.instance = axios_1.default.create({ withCredentials: true });
13
13
  }
14
14
  send(endpoint, method, headers, data, params) {
15
- var _a, _b, _c;
16
15
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
+ var _a, _b, _c;
17
17
  if (headers != undefined) {
18
18
  headers["Access-Control-Allow-Credentials"] = true;
19
19
  }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./client";
2
2
  export * from "./types";
3
+ export * from "./signeradapter";
package/dist/index.js CHANGED
@@ -3,3 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./client"), exports);
5
5
  tslib_1.__exportStar(require("./types"), exports);
6
+ tslib_1.__exportStar(require("./signeradapter"), exports);
@@ -1,5 +1,5 @@
1
- import { JsonRpcSigner } from "@ethersproject/providers";
2
1
  import { TransactionResponse } from "@ethersproject/abstract-provider";
3
- import { Wallet } from "ethers";
4
2
  import { SafeTransaction, ManualOverrides } from "../types";
5
- export declare function executeManualTransactions(signer: Wallet | JsonRpcSigner, transactions: SafeTransaction[], overrides: ManualOverrides): Promise<TransactionResponse>;
3
+ import { SignerAdapter } from "../signeradapter";
4
+ import { ViemTransactionResponse } from "../response";
5
+ export declare function executeManualTransactions(signer: SignerAdapter, transactions: SafeTransaction[], overrides: ManualOverrides): Promise<TransactionResponse | ViemTransactionResponse>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeManualTransactions = void 0;
3
+ exports.executeManualTransactions = executeManualTransactions;
4
4
  const tslib_1 = require("tslib");
5
5
  const ethers_1 = require("ethers");
6
6
  const builder_1 = require("../builder");
@@ -9,18 +9,23 @@ const abis_1 = require("../abis");
9
9
  function executeManualTransactions(signer, transactions, overrides) {
10
10
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
11
  const from = yield signer.getAddress();
12
- const aggTxn = builder_1.aggregateTransaction(transactions);
13
- const sig = encode_1.abiEncodePacked({ type: "uint256", value: from }, // r
12
+ const aggTxn = (0, builder_1.aggregateTransaction)(transactions);
13
+ const sig = (0, encode_1.abiEncodePacked)({ type: "uint256", value: from }, // r
14
14
  { type: "uint256", value: 0 }, // s
15
15
  { type: "uint8", value: 1 });
16
- const safeAddress = builder_1.deriveSafe(from);
17
- const safeContract = new ethers_1.ethers.Contract(safeAddress, abis_1.safeAbi, signer);
18
- if (overrides.gasLimit == undefined) {
19
- const gasLimit = yield safeContract.estimateGas.execTransaction(aggTxn.to, aggTxn.value, aggTxn.data, aggTxn.operation, 0, 0, 0, ethers_1.ethers.constants.AddressZero, ethers_1.ethers.constants.AddressZero, sig);
20
- console.log(`Estimated gas Limit: ${gasLimit}`);
21
- overrides.gasLimit = gasLimit;
22
- }
23
- return safeContract.execTransaction(aggTxn.to, aggTxn.value, aggTxn.data, aggTxn.operation, 0, 0, 0, ethers_1.ethers.constants.AddressZero, ethers_1.ethers.constants.AddressZero, sig, overrides);
16
+ const safeAddress = (0, builder_1.deriveSafe)(from);
17
+ const args = [
18
+ aggTxn.to,
19
+ aggTxn.value,
20
+ aggTxn.data,
21
+ aggTxn.operation,
22
+ 0,
23
+ 0,
24
+ 0,
25
+ ethers_1.ethers.constants.AddressZero,
26
+ ethers_1.ethers.constants.AddressZero,
27
+ sig,
28
+ ];
29
+ return signer.writeContract(safeAddress, abis_1.safeAbi, overrides, "execTransaction", args);
24
30
  });
25
31
  }
26
- exports.executeManualTransactions = executeManualTransactions;
@@ -1,12 +1,2 @@
1
- import { RelayClient } from "../client";
2
- import { RelayerTransaction, RelayerTransactionResponse } from "../types";
3
- export declare class ClientRelayerTransactionResponse implements RelayerTransactionResponse {
4
- readonly client: RelayClient;
5
- readonly transactionID: string;
6
- readonly transactionHash: string;
7
- readonly hash: string;
8
- readonly state: string;
9
- constructor(transactionID: string, state: string, transactionHash: string, client: RelayClient);
10
- getTransaction(): Promise<RelayerTransaction[]>;
11
- wait(): Promise<RelayerTransaction | undefined>;
12
- }
1
+ export * from "./relayer";
2
+ export * from "./viem";
@@ -1,28 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClientRelayerTransactionResponse = void 0;
4
3
  const tslib_1 = require("tslib");
5
- const types_1 = require("../types");
6
- class ClientRelayerTransactionResponse {
7
- constructor(transactionID, state, transactionHash, client) {
8
- this.transactionID = transactionID;
9
- this.state = state;
10
- this.transactionHash = transactionHash;
11
- this.hash = transactionHash;
12
- this.client = client;
13
- }
14
- getTransaction() {
15
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
- return this.client.getTransaction(this.transactionID);
17
- });
18
- }
19
- wait() {
20
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
- return this.client.pollUntilState(this.transactionID, [
22
- types_1.RelayerTransactionState.STATE_MINED,
23
- types_1.RelayerTransactionState.STATE_CONFIRMED,
24
- ], 30);
25
- });
26
- }
27
- }
28
- exports.ClientRelayerTransactionResponse = ClientRelayerTransactionResponse;
4
+ tslib_1.__exportStar(require("./relayer"), exports);
5
+ tslib_1.__exportStar(require("./viem"), exports);
@@ -26,4 +26,3 @@ class ClientRelayerTransactionResponse {
26
26
  }
27
27
  }
28
28
  exports.ClientRelayerTransactionResponse = ClientRelayerTransactionResponse;
29
- //# sourceMappingURL=relayer.js.map
@@ -17,4 +17,3 @@ class ViemTransactionResponse {
17
17
  }
18
18
  }
19
19
  exports.ViemTransactionResponse = ViemTransactionResponse;
20
- //# sourceMappingURL=viem.js.map
@@ -30,8 +30,8 @@ class SignerAdapter {
30
30
  }
31
31
  }
32
32
  getAddress() {
33
- var _a, _b;
34
33
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
34
+ var _a, _b;
35
35
  if (this.ethersSigner != undefined) {
36
36
  return this.ethersSigner.getAddress();
37
37
  }
@@ -49,8 +49,8 @@ class SignerAdapter {
49
49
  });
50
50
  }
51
51
  viemSignMessage(message) {
52
- var _a, _b, _c;
53
52
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
53
+ var _a, _b, _c;
54
54
  if (this.viemSigner == undefined) {
55
55
  throw new Error("must provide viem WalletClient");
56
56
  }
@@ -70,8 +70,8 @@ class SignerAdapter {
70
70
  });
71
71
  }
72
72
  viemSignTypedData(domain, types, values) {
73
- var _a, _b;
74
73
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
74
+ var _a, _b;
75
75
  if (this.viemSigner == undefined) {
76
76
  throw new Error("viem signer must be present");
77
77
  }
@@ -105,8 +105,8 @@ class SignerAdapter {
105
105
  });
106
106
  }
107
107
  getProvider() {
108
- var _a, _b;
109
108
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
109
+ var _a, _b;
110
110
  if (this.ethersSigner != undefined) {
111
111
  return this.ethersSigner.provider;
112
112
  }
@@ -146,22 +146,25 @@ class SignerAdapter {
146
146
  });
147
147
  }
148
148
  viemWriteContract(address, abi, overrides, functionName, ...args) {
149
- var _a, _b;
150
149
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
150
+ var _a, _b, _c;
151
151
  if (this.viemSigner == undefined) {
152
152
  throw new Error("viem signer must be defined");
153
153
  }
154
- const account = (_b = (_a = this.viemSigner) === null || _a === void 0 ? void 0 : _a.walletClient.account) === null || _b === void 0 ? void 0 : _b.address;
154
+ let addr = address;
155
+ const chain = (_a = this.viemSigner) === null || _a === void 0 ? void 0 : _a.publicClient.chain;
156
+ const account = (_c = (_b = this.viemSigner) === null || _b === void 0 ? void 0 : _b.walletClient.account) === null || _c === void 0 ? void 0 : _c.address;
155
157
  const writeArgs = {
156
158
  account: account,
157
- address: address,
159
+ chain: chain,
160
+ address: addr,
158
161
  abi: abi,
159
162
  functionName: functionName,
160
163
  args: args,
161
164
  };
162
165
  if (overrides.gasLimit != undefined) {
163
166
  let gasLimit = ethers_1.ethers.BigNumber.from(overrides.gasLimit).toBigInt();
164
- writeArgs.gasLimit = gasLimit;
167
+ writeArgs.gas = gasLimit;
165
168
  }
166
169
  if (overrides.gasPrice != undefined) {
167
170
  let gasPrice = ethers_1.ethers.BigNumber.from(overrides.gasPrice).toBigInt();
@@ -173,4 +176,3 @@ class SignerAdapter {
173
176
  }
174
177
  }
175
178
  exports.SignerAdapter = SignerAdapter;
176
- //# sourceMappingURL=adapter.js.map
@@ -3,4 +3,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./adapter"), exports);
5
5
  tslib_1.__exportStar(require("./interfaces"), exports);
6
- //# sourceMappingURL=index.js.map
@@ -5,4 +5,4 @@ export interface ViemSigner {
5
5
  walletClient: WalletClient;
6
6
  publicClient: PublicClient;
7
7
  }
8
- export declare type EthersSigner = Wallet | JsonRpcSigner;
8
+ export type EthersSigner = Wallet | JsonRpcSigner;
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=interfaces.js.map