@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.
- package/dist/builder/create.d.ts +2 -3
- package/dist/builder/create.js +3 -4
- package/dist/builder/proxy.d.ts +2 -3
- package/dist/builder/proxy.js +10 -6
- package/dist/builder/safe.d.ts +2 -3
- package/dist/builder/safe.js +11 -8
- package/dist/builder/utils.js +4 -2
- package/dist/client.d.ts +18 -7
- package/dist/client.js +20 -26
- package/dist/encode/proxy.js +2 -1
- package/dist/encode/safe.js +3 -2
- package/dist/encode/utils.js +3 -4
- package/dist/http-helpers/index.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/manual/index.d.ts +3 -3
- package/dist/manual/index.js +17 -12
- package/dist/response/index.d.ts +2 -12
- package/dist/response/index.js +2 -25
- package/dist/{src/response → response}/relayer.js +0 -1
- package/dist/{src/response → response}/viem.js +0 -1
- package/dist/{src/signeradapter → signeradapter}/adapter.js +11 -9
- package/dist/{src/signeradapter → signeradapter}/index.js +0 -1
- package/dist/{src/signeradapter → signeradapter}/interfaces.d.ts +1 -1
- package/dist/{src/signeradapter → signeradapter}/interfaces.js +0 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +4 -4
- package/dist/utils/index.js +1 -2
- package/package.json +1 -1
- package/dist/examples/deploySafe.d.ts +0 -1
- package/dist/examples/deploySafe.js +0 -30
- package/dist/examples/deploySafe.js.map +0 -1
- package/dist/examples/getAddress.d.ts +0 -1
- package/dist/examples/getAddress.js +0 -23
- package/dist/examples/getAddress.js.map +0 -1
- package/dist/examples/getNonce.d.ts +0 -1
- package/dist/examples/getNonce.js +0 -27
- package/dist/examples/getNonce.js.map +0 -1
- package/dist/examples/getRelayPayload.d.ts +0 -1
- package/dist/examples/getRelayPayload.js +0 -27
- package/dist/examples/getRelayPayload.js.map +0 -1
- package/dist/examples/getTransaction.d.ts +0 -1
- package/dist/examples/getTransaction.js +0 -23
- package/dist/examples/getTransaction.js.map +0 -1
- package/dist/examples/getTransactions.d.ts +0 -1
- package/dist/examples/getTransactions.js +0 -23
- package/dist/examples/getTransactions.js.map +0 -1
- package/dist/examples/poll.d.ts +0 -1
- package/dist/examples/poll.js +0 -26
- package/dist/examples/poll.js.map +0 -1
- package/dist/examples/proxyExecute.d.ts +0 -1
- package/dist/examples/proxyExecute.js +0 -45
- package/dist/examples/proxyExecute.js.map +0 -1
- package/dist/examples/safeExecute.d.ts +0 -1
- package/dist/examples/safeExecute.js +0 -45
- package/dist/examples/safeExecute.js.map +0 -1
- package/dist/examples/safeExecuteFail.d.ts +0 -1
- package/dist/examples/safeExecuteFail.js +0 -55
- package/dist/examples/safeExecuteFail.js.map +0 -1
- package/dist/examples/safeExecuteManual.d.ts +0 -1
- package/dist/examples/safeExecuteManual.js +0 -45
- package/dist/examples/safeExecuteManual.js.map +0 -1
- package/dist/src/abis/erc20Abi.d.ts +0 -38
- package/dist/src/abis/erc20Abi.js +0 -226
- package/dist/src/abis/erc20Abi.js.map +0 -1
- package/dist/src/abis/index.d.ts +0 -5
- package/dist/src/abis/index.js +0 -9
- package/dist/src/abis/index.js.map +0 -1
- package/dist/src/abis/multisend.d.ts +0 -13
- package/dist/src/abis/multisend.js +0 -21
- package/dist/src/abis/multisend.js.map +0 -1
- package/dist/src/abis/proxyFactory.d.ts +0 -66
- package/dist/src/abis/proxyFactory.js +0 -323
- package/dist/src/abis/proxyFactory.js.map +0 -1
- package/dist/src/abis/safe.d.ts +0 -35
- package/dist/src/abis/safe.js +0 -1142
- package/dist/src/abis/safe.js.map +0 -1
- package/dist/src/abis/safeFactory.d.ts +0 -60
- package/dist/src/abis/safeFactory.js +0 -228
- package/dist/src/abis/safeFactory.js.map +0 -1
- package/dist/src/auth/handler.d.ts +0 -15
- package/dist/src/auth/handler.js +0 -50
- package/dist/src/auth/handler.js.map +0 -1
- package/dist/src/auth/index.d.ts +0 -1
- package/dist/src/auth/index.js +0 -5
- package/dist/src/auth/index.js.map +0 -1
- package/dist/src/builder/create.d.ts +0 -3
- package/dist/src/builder/create.js +0 -56
- package/dist/src/builder/create.js.map +0 -1
- package/dist/src/builder/index.d.ts +0 -4
- package/dist/src/builder/index.js +0 -8
- package/dist/src/builder/index.js.map +0 -1
- package/dist/src/builder/proxy.d.ts +0 -3
- package/dist/src/builder/proxy.js +0 -94
- package/dist/src/builder/proxy.js.map +0 -1
- package/dist/src/builder/safe.d.ts +0 -4
- package/dist/src/builder/safe.js +0 -131
- package/dist/src/builder/safe.js.map +0 -1
- package/dist/src/builder/utils.d.ts +0 -2
- package/dist/src/builder/utils.js +0 -14
- package/dist/src/builder/utils.js.map +0 -1
- package/dist/src/client.d.ts +0 -37
- package/dist/src/client.js +0 -187
- package/dist/src/client.js.map +0 -1
- package/dist/src/constants/index.d.ts +0 -7
- package/dist/src/constants/index.js +0 -11
- package/dist/src/constants/index.js.map +0 -1
- package/dist/src/encode/index.d.ts +0 -3
- package/dist/src/encode/index.js +0 -7
- package/dist/src/encode/index.js.map +0 -1
- package/dist/src/encode/proxy.d.ts +0 -2
- package/dist/src/encode/proxy.js +0 -11
- package/dist/src/encode/proxy.js.map +0 -1
- package/dist/src/encode/safe.d.ts +0 -2
- package/dist/src/encode/safe.js +0 -22
- package/dist/src/encode/safe.js.map +0 -1
- package/dist/src/encode/utils.d.ts +0 -6
- package/dist/src/encode/utils.js +0 -48
- package/dist/src/encode/utils.js.map +0 -1
- package/dist/src/endpoints.d.ts +0 -5
- package/dist/src/endpoints.js +0 -9
- package/dist/src/endpoints.js.map +0 -1
- package/dist/src/http-helpers/index.d.ts +0 -10
- package/dist/src/http-helpers/index.js +0 -54
- package/dist/src/http-helpers/index.js.map +0 -1
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.js +0 -7
- package/dist/src/index.js.map +0 -1
- package/dist/src/manual/index.d.ts +0 -5
- package/dist/src/manual/index.js +0 -33
- package/dist/src/manual/index.js.map +0 -1
- package/dist/src/response/index.d.ts +0 -2
- package/dist/src/response/index.js +0 -6
- package/dist/src/response/index.js.map +0 -1
- package/dist/src/response/relayer.js.map +0 -1
- package/dist/src/response/viem.js.map +0 -1
- package/dist/src/signeradapter/adapter.js.map +0 -1
- package/dist/src/signeradapter/index.js.map +0 -1
- package/dist/src/signeradapter/interfaces.js.map +0 -1
- package/dist/src/types.d.ts +0 -127
- package/dist/src/types.js +0 -32
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils/index.d.ts +0 -1
- package/dist/src/utils/index.js +0 -8
- package/dist/src/utils/index.js.map +0 -1
- /package/dist/{src/response → response}/relayer.d.ts +0 -0
- /package/dist/{src/response → response}/viem.d.ts +0 -0
- /package/dist/{src/signeradapter → signeradapter}/adapter.d.ts +0 -0
- /package/dist/{src/signeradapter → signeradapter}/index.d.ts +0 -0
package/dist/builder/create.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Wallet } from "@ethersproject/wallet";
|
|
2
|
-
import { JsonRpcSigner } from "@ethersproject/providers";
|
|
3
1
|
import { SafeCreateTransactionArgs, TransactionRequest } from "../types";
|
|
4
|
-
|
|
2
|
+
import { SignerAdapter } from "../signeradapter";
|
|
3
|
+
export declare function buildSafeCreateTransactionRequest(signer: SignerAdapter, args: SafeCreateTransactionArgs): Promise<TransactionRequest>;
|
package/dist/builder/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildSafeCreateTransactionRequest =
|
|
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.
|
|
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;
|
package/dist/builder/proxy.d.ts
CHANGED
|
@@ -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
|
-
|
|
2
|
+
import { SignerAdapter } from "../signeradapter";
|
|
3
|
+
export declare function buildProxyTransactionRequest(signer: SignerAdapter, args: ProxyTransactionArgs, metadata?: string): Promise<TransactionRequest>;
|
package/dist/builder/proxy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildProxyTransactionRequest =
|
|
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(
|
|
49
|
+
return signer.signMessage(structHash);
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
function buildProxyTransactionRequest(signer,
|
|
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;
|
package/dist/builder/safe.d.ts
CHANGED
|
@@ -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:
|
|
4
|
+
export declare function buildSafeTransactionRequest(signer: SignerAdapter, args: SafeTransactionArgs, metadata?: string): Promise<TransactionRequest>;
|
package/dist/builder/safe.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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(
|
|
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
|
-
|
|
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;
|
package/dist/builder/utils.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
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 {
|
|
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?:
|
|
11
|
+
readonly signer?: SignerAdapter;
|
|
11
12
|
readonly provider?: Provider;
|
|
12
13
|
readonly authHandler?: AuthHandler;
|
|
13
|
-
constructor(relayerUrl: string, chainId: number, signer?:
|
|
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,
|
|
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,
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
});
|
package/dist/encode/proxy.js
CHANGED
|
@@ -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
|
-
|
|
7
|
+
const encodeProxyTransactionData = (txns) => {
|
|
8
8
|
return factoryInterface.encodeFunctionData("proxy((uint8,address,uint256,bytes)[])", [txns]);
|
|
9
9
|
};
|
|
10
|
+
exports.encodeProxyTransactionData = encodeProxyTransactionData;
|
package/dist/encode/safe.js
CHANGED
|
@@ -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
|
-
|
|
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;
|
package/dist/encode/utils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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
package/dist/index.js
CHANGED
package/dist/manual/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
3
|
+
import { SignerAdapter } from "../signeradapter";
|
|
4
|
+
import { ViemTransactionResponse } from "../response";
|
|
5
|
+
export declare function executeManualTransactions(signer: SignerAdapter, transactions: SafeTransaction[], overrides: ManualOverrides): Promise<TransactionResponse | ViemTransactionResponse>;
|
package/dist/manual/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeManualTransactions =
|
|
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
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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;
|
package/dist/response/index.d.ts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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";
|
package/dist/response/index.js
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
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);
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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.
|
|
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
|