@0xsequence/relayer 2.0.26 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/0xsequence-relayer.cjs.dev.js +8 -4
- package/dist/0xsequence-relayer.cjs.prod.js +8 -4
- package/dist/0xsequence-relayer.esm.js +8 -4
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/rpc-relayer/index.d.ts +2 -1
- package/package.json +6 -6
- package/src/index.ts +2 -1
- package/src/rpc-relayer/index.ts +23 -15
|
@@ -1001,7 +1001,7 @@ class RpcRelayer {
|
|
|
1001
1001
|
}
|
|
1002
1002
|
|
|
1003
1003
|
// before the request is made
|
|
1004
|
-
init.headers = _extends({},
|
|
1004
|
+
init.headers = _extends({}, headers, init.headers);
|
|
1005
1005
|
return fetch(input, init);
|
|
1006
1006
|
};
|
|
1007
1007
|
this.service = new Relayer(options.url, this._fetch);
|
|
@@ -1105,7 +1105,9 @@ class RpcRelayer {
|
|
|
1105
1105
|
to: entrypoint,
|
|
1106
1106
|
data: ethers.ethers.hexlify(data),
|
|
1107
1107
|
simulate: options == null ? void 0 : options.simulate
|
|
1108
|
-
}
|
|
1108
|
+
}, _extends({}, options != null && options.projectAccessKey ? {
|
|
1109
|
+
'X-Access-Key': options.projectAccessKey
|
|
1110
|
+
} : undefined));
|
|
1109
1111
|
return {
|
|
1110
1112
|
options: feeOptions,
|
|
1111
1113
|
quote: {
|
|
@@ -1132,7 +1134,7 @@ class RpcRelayer {
|
|
|
1132
1134
|
utils.logger.info(`[rpc-relayer/getNonce] got next nonce for wallet ${address} ${decodedNonce} space: ${decodedSpace}`);
|
|
1133
1135
|
return nonce;
|
|
1134
1136
|
}
|
|
1135
|
-
async relay(signedTxs, quote, waitForReceipt = true) {
|
|
1137
|
+
async relay(signedTxs, quote, waitForReceipt = true, projectAccessKey) {
|
|
1136
1138
|
var _this = this;
|
|
1137
1139
|
utils.logger.info(`[rpc-relayer/relay] relaying signed meta-transactions ${JSON.stringify(signedTxs, utils.bigintReplacer)} with quote ${JSON.stringify(quote, utils.bigintReplacer)}`);
|
|
1138
1140
|
let typecheckedQuote;
|
|
@@ -1155,7 +1157,9 @@ class RpcRelayer {
|
|
|
1155
1157
|
input: data
|
|
1156
1158
|
},
|
|
1157
1159
|
quote: typecheckedQuote
|
|
1158
|
-
}
|
|
1160
|
+
}, _extends({}, projectAccessKey ? {
|
|
1161
|
+
'X-Access-Key': projectAccessKey
|
|
1162
|
+
} : undefined));
|
|
1159
1163
|
utils.logger.info(`[rpc-relayer/relay] got relay result ${JSON.stringify(metaTxn, utils.bigintReplacer)}`);
|
|
1160
1164
|
if (waitForReceipt) {
|
|
1161
1165
|
return this.wait(signedTxs.intent.id);
|
|
@@ -1001,7 +1001,7 @@ class RpcRelayer {
|
|
|
1001
1001
|
}
|
|
1002
1002
|
|
|
1003
1003
|
// before the request is made
|
|
1004
|
-
init.headers = _extends({},
|
|
1004
|
+
init.headers = _extends({}, headers, init.headers);
|
|
1005
1005
|
return fetch(input, init);
|
|
1006
1006
|
};
|
|
1007
1007
|
this.service = new Relayer(options.url, this._fetch);
|
|
@@ -1105,7 +1105,9 @@ class RpcRelayer {
|
|
|
1105
1105
|
to: entrypoint,
|
|
1106
1106
|
data: ethers.ethers.hexlify(data),
|
|
1107
1107
|
simulate: options == null ? void 0 : options.simulate
|
|
1108
|
-
}
|
|
1108
|
+
}, _extends({}, options != null && options.projectAccessKey ? {
|
|
1109
|
+
'X-Access-Key': options.projectAccessKey
|
|
1110
|
+
} : undefined));
|
|
1109
1111
|
return {
|
|
1110
1112
|
options: feeOptions,
|
|
1111
1113
|
quote: {
|
|
@@ -1132,7 +1134,7 @@ class RpcRelayer {
|
|
|
1132
1134
|
utils.logger.info(`[rpc-relayer/getNonce] got next nonce for wallet ${address} ${decodedNonce} space: ${decodedSpace}`);
|
|
1133
1135
|
return nonce;
|
|
1134
1136
|
}
|
|
1135
|
-
async relay(signedTxs, quote, waitForReceipt = true) {
|
|
1137
|
+
async relay(signedTxs, quote, waitForReceipt = true, projectAccessKey) {
|
|
1136
1138
|
var _this = this;
|
|
1137
1139
|
utils.logger.info(`[rpc-relayer/relay] relaying signed meta-transactions ${JSON.stringify(signedTxs, utils.bigintReplacer)} with quote ${JSON.stringify(quote, utils.bigintReplacer)}`);
|
|
1138
1140
|
let typecheckedQuote;
|
|
@@ -1155,7 +1157,9 @@ class RpcRelayer {
|
|
|
1155
1157
|
input: data
|
|
1156
1158
|
},
|
|
1157
1159
|
quote: typecheckedQuote
|
|
1158
|
-
}
|
|
1160
|
+
}, _extends({}, projectAccessKey ? {
|
|
1161
|
+
'X-Access-Key': projectAccessKey
|
|
1162
|
+
} : undefined));
|
|
1159
1163
|
utils.logger.info(`[rpc-relayer/relay] got relay result ${JSON.stringify(metaTxn, utils.bigintReplacer)}`);
|
|
1160
1164
|
if (waitForReceipt) {
|
|
1161
1165
|
return this.wait(signedTxs.intent.id);
|
|
@@ -997,7 +997,7 @@ class RpcRelayer {
|
|
|
997
997
|
}
|
|
998
998
|
|
|
999
999
|
// before the request is made
|
|
1000
|
-
init.headers = _extends({},
|
|
1000
|
+
init.headers = _extends({}, headers, init.headers);
|
|
1001
1001
|
return fetch(input, init);
|
|
1002
1002
|
};
|
|
1003
1003
|
this.service = new Relayer(options.url, this._fetch);
|
|
@@ -1101,7 +1101,9 @@ class RpcRelayer {
|
|
|
1101
1101
|
to: entrypoint,
|
|
1102
1102
|
data: ethers.hexlify(data),
|
|
1103
1103
|
simulate: options == null ? void 0 : options.simulate
|
|
1104
|
-
}
|
|
1104
|
+
}, _extends({}, options != null && options.projectAccessKey ? {
|
|
1105
|
+
'X-Access-Key': options.projectAccessKey
|
|
1106
|
+
} : undefined));
|
|
1105
1107
|
return {
|
|
1106
1108
|
options: feeOptions,
|
|
1107
1109
|
quote: {
|
|
@@ -1128,7 +1130,7 @@ class RpcRelayer {
|
|
|
1128
1130
|
logger.info(`[rpc-relayer/getNonce] got next nonce for wallet ${address} ${decodedNonce} space: ${decodedSpace}`);
|
|
1129
1131
|
return nonce;
|
|
1130
1132
|
}
|
|
1131
|
-
async relay(signedTxs, quote, waitForReceipt = true) {
|
|
1133
|
+
async relay(signedTxs, quote, waitForReceipt = true, projectAccessKey) {
|
|
1132
1134
|
var _this = this;
|
|
1133
1135
|
logger.info(`[rpc-relayer/relay] relaying signed meta-transactions ${JSON.stringify(signedTxs, bigintReplacer)} with quote ${JSON.stringify(quote, bigintReplacer)}`);
|
|
1134
1136
|
let typecheckedQuote;
|
|
@@ -1151,7 +1153,9 @@ class RpcRelayer {
|
|
|
1151
1153
|
input: data
|
|
1152
1154
|
},
|
|
1153
1155
|
quote: typecheckedQuote
|
|
1154
|
-
}
|
|
1156
|
+
}, _extends({}, projectAccessKey ? {
|
|
1157
|
+
'X-Access-Key': projectAccessKey
|
|
1158
|
+
} : undefined));
|
|
1155
1159
|
logger.info(`[rpc-relayer/relay] got relay result ${JSON.stringify(metaTxn, bigintReplacer)}`);
|
|
1156
1160
|
if (waitForReceipt) {
|
|
1157
1161
|
return this.wait(signedTxs.intent.id);
|
|
@@ -15,7 +15,7 @@ export interface Relayer {
|
|
|
15
15
|
}>;
|
|
16
16
|
gasRefundOptions(address: string, ...transactions: commons.transaction.Transaction[]): Promise<FeeOption[]>;
|
|
17
17
|
getNonce(address: string, space?: ethers.BigNumberish, blockTag?: ethers.BlockTag): Promise<ethers.BigNumberish>;
|
|
18
|
-
relay(signedTxs: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote, waitForReceipt?: boolean): Promise<commons.transaction.TransactionResponse>;
|
|
18
|
+
relay(signedTxs: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote, waitForReceipt?: boolean, projectAccessKey?: string): Promise<commons.transaction.TransactionResponse>;
|
|
19
19
|
wait(metaTxnId: string | commons.transaction.SignedTransactionBundle, timeout?: number, delay?: number, maxFails?: number): Promise<commons.transaction.TransactionResponse>;
|
|
20
20
|
}
|
|
21
21
|
export * from "./local-relayer.js";
|
|
@@ -26,13 +26,14 @@ export declare class RpcRelayer implements Relayer {
|
|
|
26
26
|
}>;
|
|
27
27
|
getFeeOptionsRaw(entrypoint: string, data: ethers.BytesLike, options?: {
|
|
28
28
|
simulate?: boolean;
|
|
29
|
+
projectAccessKey?: string;
|
|
29
30
|
}): Promise<{
|
|
30
31
|
options: FeeOption[];
|
|
31
32
|
quote?: FeeQuote;
|
|
32
33
|
}>;
|
|
33
34
|
gasRefundOptions(address: string, ...transactions: commons.transaction.Transaction[]): Promise<FeeOption[]>;
|
|
34
35
|
getNonce(address: string, space?: ethers.BigNumberish): Promise<ethers.BigNumberish>;
|
|
35
|
-
relay(signedTxs: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote, waitForReceipt?: boolean): Promise<commons.transaction.TransactionResponse<RelayerTxReceipt>>;
|
|
36
|
+
relay(signedTxs: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote, waitForReceipt?: boolean, projectAccessKey?: string): Promise<commons.transaction.TransactionResponse<RelayerTxReceipt>>;
|
|
36
37
|
wait(metaTxnId: string | commons.transaction.SignedTransactionBundle, timeout?: number, delay?: number, maxFails?: number): Promise<commons.transaction.TransactionResponse<RelayerTxReceipt>>;
|
|
37
38
|
}
|
|
38
39
|
export type RelayerTxReceipt = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/relayer",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "relayer sub-package for Sequence",
|
|
5
5
|
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/relayer",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
"ethers": ">=6"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@0xsequence/abi": "2.0
|
|
16
|
-
"@0xsequence/core": "2.0
|
|
17
|
-
"@0xsequence/utils": "2.0
|
|
15
|
+
"@0xsequence/abi": "2.1.0",
|
|
16
|
+
"@0xsequence/core": "2.1.0",
|
|
17
|
+
"@0xsequence/utils": "2.1.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@0xsequence/wallet-contracts": "^3.0.1",
|
|
21
21
|
"ethers": "6.13.4",
|
|
22
|
-
"@0xsequence/signhub": "2.0
|
|
23
|
-
"@0xsequence/tests": "2.0
|
|
22
|
+
"@0xsequence/signhub": "2.1.0",
|
|
23
|
+
"@0xsequence/tests": "2.1.0"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"src",
|
package/src/index.ts
CHANGED
|
@@ -40,7 +40,8 @@ export interface Relayer {
|
|
|
40
40
|
relay(
|
|
41
41
|
signedTxs: commons.transaction.IntendedTransactionBundle,
|
|
42
42
|
quote?: FeeQuote,
|
|
43
|
-
waitForReceipt?: boolean
|
|
43
|
+
waitForReceipt?: boolean,
|
|
44
|
+
projectAccessKey?: string
|
|
44
45
|
): Promise<commons.transaction.TransactionResponse>
|
|
45
46
|
|
|
46
47
|
// wait for transaction confirmation
|
package/src/rpc-relayer/index.ts
CHANGED
|
@@ -61,7 +61,7 @@ export class RpcRelayer implements Relayer {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// before the request is made
|
|
64
|
-
init!.headers = { ...
|
|
64
|
+
init!.headers = { ...headers, ...init!.headers }
|
|
65
65
|
|
|
66
66
|
return fetch(input, init)
|
|
67
67
|
}
|
|
@@ -160,14 +160,18 @@ export class RpcRelayer implements Relayer {
|
|
|
160
160
|
data: ethers.BytesLike,
|
|
161
161
|
options?: {
|
|
162
162
|
simulate?: boolean
|
|
163
|
+
projectAccessKey?: string
|
|
163
164
|
}
|
|
164
165
|
): Promise<{ options: FeeOption[]; quote?: FeeQuote }> {
|
|
165
|
-
const { options: feeOptions, quote } = await this.service.feeOptions(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
const { options: feeOptions, quote } = await this.service.feeOptions(
|
|
167
|
+
{
|
|
168
|
+
wallet: entrypoint,
|
|
169
|
+
to: entrypoint,
|
|
170
|
+
data: ethers.hexlify(data),
|
|
171
|
+
simulate: options?.simulate
|
|
172
|
+
},
|
|
173
|
+
{ ...(options?.projectAccessKey ? { 'X-Access-Key': options.projectAccessKey } : undefined) }
|
|
174
|
+
)
|
|
171
175
|
|
|
172
176
|
return { options: feeOptions, quote: { _tag: 'FeeQuote', _quote: quote } }
|
|
173
177
|
}
|
|
@@ -190,7 +194,8 @@ export class RpcRelayer implements Relayer {
|
|
|
190
194
|
async relay(
|
|
191
195
|
signedTxs: commons.transaction.IntendedTransactionBundle,
|
|
192
196
|
quote?: FeeQuote,
|
|
193
|
-
waitForReceipt: boolean = true
|
|
197
|
+
waitForReceipt: boolean = true,
|
|
198
|
+
projectAccessKey?: string
|
|
194
199
|
): Promise<commons.transaction.TransactionResponse<RelayerTxReceipt>> {
|
|
195
200
|
logger.info(
|
|
196
201
|
`[rpc-relayer/relay] relaying signed meta-transactions ${JSON.stringify(signedTxs, bigintReplacer)} with quote ${JSON.stringify(quote, bigintReplacer)}`
|
|
@@ -211,14 +216,17 @@ export class RpcRelayer implements Relayer {
|
|
|
211
216
|
}
|
|
212
217
|
|
|
213
218
|
const data = commons.transaction.encodeBundleExecData(signedTxs)
|
|
214
|
-
const metaTxn = await this.service.sendMetaTxn(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
+
const metaTxn = await this.service.sendMetaTxn(
|
|
220
|
+
{
|
|
221
|
+
call: {
|
|
222
|
+
walletAddress: signedTxs.intent.wallet,
|
|
223
|
+
contract: signedTxs.entrypoint,
|
|
224
|
+
input: data
|
|
225
|
+
},
|
|
226
|
+
quote: typecheckedQuote
|
|
219
227
|
},
|
|
220
|
-
|
|
221
|
-
|
|
228
|
+
{ ...(projectAccessKey ? { 'X-Access-Key': projectAccessKey } : undefined) }
|
|
229
|
+
)
|
|
222
230
|
|
|
223
231
|
logger.info(`[rpc-relayer/relay] got relay result ${JSON.stringify(metaTxn, bigintReplacer)}`)
|
|
224
232
|
|