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