@0xsequence/account 1.6.0 → 1.6.2
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.
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var abi = require('@0xsequence/abi');
|
|
5
6
|
var core = require('@0xsequence/core');
|
|
6
7
|
var migration = require('@0xsequence/migration');
|
|
7
8
|
var relayer = require('@0xsequence/relayer');
|
|
@@ -212,12 +213,14 @@ class Account {
|
|
|
212
213
|
this.migrations = void 0;
|
|
213
214
|
this.orchestrator = void 0;
|
|
214
215
|
this.jwt = void 0;
|
|
216
|
+
this.projectAccessKey = void 0;
|
|
215
217
|
this.address = ethers.ethers.utils.getAddress(options.address);
|
|
216
218
|
this.contexts = options.contexts;
|
|
217
219
|
this.tracker = options.tracker;
|
|
218
220
|
this.networks = options.networks;
|
|
219
221
|
this.orchestrator = options.orchestrator;
|
|
220
222
|
this.jwt = options.jwt;
|
|
223
|
+
this.projectAccessKey = options.projectAccessKey;
|
|
221
224
|
this.migrations = options.migrations || migration.defaults.DefaultMigrations;
|
|
222
225
|
this.migrator = new migration.migrator.Migrator(options.tracker, this.migrations, this.contexts);
|
|
223
226
|
}
|
|
@@ -243,7 +246,8 @@ class Account {
|
|
|
243
246
|
contexts: options.contexts,
|
|
244
247
|
networks: options.networks,
|
|
245
248
|
orchestrator: options.orchestrator,
|
|
246
|
-
migrations: options.migrations
|
|
249
|
+
migrations: options.migrations,
|
|
250
|
+
projectAccessKey: options.projectAccessKey
|
|
247
251
|
});
|
|
248
252
|
}
|
|
249
253
|
getAddress() {
|
|
@@ -268,7 +272,7 @@ class Account {
|
|
|
268
272
|
providerFor(chainId) {
|
|
269
273
|
const found = this.network(chainId);
|
|
270
274
|
if (!found.provider && !found.rpcUrl) throw new Error(`Provider not found for chainId ${chainId}`);
|
|
271
|
-
return found.provider || new ethers.ethers.providers.StaticJsonRpcProvider(utils.getEthersConnectionInfo(found.rpcUrl,
|
|
275
|
+
return found.provider || new ethers.ethers.providers.StaticJsonRpcProvider(utils.getEthersConnectionInfo(found.rpcUrl, this.projectAccessKey, this.jwt), {
|
|
272
276
|
name: '',
|
|
273
277
|
chainId: ethers.ethers.BigNumber.from(chainId).toNumber()
|
|
274
278
|
});
|
|
@@ -285,6 +289,7 @@ class Account {
|
|
|
285
289
|
if (!found.relayer) throw new Error(`Relayer not found for chainId ${chainId}`);
|
|
286
290
|
if (relayer.isRelayer(found.relayer)) return found.relayer;
|
|
287
291
|
return new relayer.RpcRelayer(_extends({}, found.relayer, {
|
|
292
|
+
projectAccessKey: this.projectAccessKey,
|
|
288
293
|
jwtAuth: this.jwt
|
|
289
294
|
}));
|
|
290
295
|
}
|
|
@@ -553,6 +558,51 @@ class Account {
|
|
|
553
558
|
}
|
|
554
559
|
return decorated;
|
|
555
560
|
}
|
|
561
|
+
buildOnChainSignature(digest) {
|
|
562
|
+
const subdigest = core.commons.signature.subdigestOf({
|
|
563
|
+
digest: ethers.ethers.utils.hexlify(digest),
|
|
564
|
+
chainId: 0,
|
|
565
|
+
address: this.address
|
|
566
|
+
});
|
|
567
|
+
const hexSubdigest = ethers.ethers.utils.hexlify(subdigest);
|
|
568
|
+
const config = this.coders.config.fromSimple({
|
|
569
|
+
// Threshold *only* needs to be > 0, this is not a magic number
|
|
570
|
+
// we only use 2 ** 15 because it may lead to lower gas costs in some chains
|
|
571
|
+
threshold: 32768,
|
|
572
|
+
checkpoint: 0,
|
|
573
|
+
signers: [],
|
|
574
|
+
subdigests: [hexSubdigest]
|
|
575
|
+
});
|
|
576
|
+
const walletInterface = new ethers.ethers.utils.Interface(abi.walletContracts.mainModule.abi);
|
|
577
|
+
const bundle = {
|
|
578
|
+
entrypoint: this.address,
|
|
579
|
+
transactions: [{
|
|
580
|
+
to: this.address,
|
|
581
|
+
data: walletInterface.encodeFunctionData(
|
|
582
|
+
// *NEVER* use updateImageHash here, as it would effectively destroy the wallet
|
|
583
|
+
// setExtraImageHash sets an additional imageHash, without changing the current one
|
|
584
|
+
'setExtraImageHash', [this.coders.config.imageHashOf(config),
|
|
585
|
+
// 2 ** 255 instead of max uint256, to have more zeros in the calldata
|
|
586
|
+
'57896044618658097711785492504343953926634992332820282019728792003956564819968']),
|
|
587
|
+
// Conservative gas limit, used because the current relayer
|
|
588
|
+
// has trouble estimating gas for this transaction
|
|
589
|
+
gasLimit: 250000
|
|
590
|
+
}]
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
// Fire and forget request to save the config
|
|
594
|
+
this.tracker.saveWalletConfig({
|
|
595
|
+
config
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
// Encode a signature proof for the given subdigest
|
|
599
|
+
// use `chainId = 0` to make it simpler, as this signature is only a proof
|
|
600
|
+
const signature = this.coders.signature.encodeSigners(config, new Map(), [hexSubdigest], 0).encoded;
|
|
601
|
+
return {
|
|
602
|
+
bundle,
|
|
603
|
+
signature
|
|
604
|
+
};
|
|
605
|
+
}
|
|
556
606
|
async buildEIP6492Signature(signature, status, chainId) {
|
|
557
607
|
const bootstrapBundle = await this.buildBootstrapTransactions(status, chainId);
|
|
558
608
|
if (bootstrapBundle.transactions.length === 0) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var abi = require('@0xsequence/abi');
|
|
5
6
|
var core = require('@0xsequence/core');
|
|
6
7
|
var migration = require('@0xsequence/migration');
|
|
7
8
|
var relayer = require('@0xsequence/relayer');
|
|
@@ -212,12 +213,14 @@ class Account {
|
|
|
212
213
|
this.migrations = void 0;
|
|
213
214
|
this.orchestrator = void 0;
|
|
214
215
|
this.jwt = void 0;
|
|
216
|
+
this.projectAccessKey = void 0;
|
|
215
217
|
this.address = ethers.ethers.utils.getAddress(options.address);
|
|
216
218
|
this.contexts = options.contexts;
|
|
217
219
|
this.tracker = options.tracker;
|
|
218
220
|
this.networks = options.networks;
|
|
219
221
|
this.orchestrator = options.orchestrator;
|
|
220
222
|
this.jwt = options.jwt;
|
|
223
|
+
this.projectAccessKey = options.projectAccessKey;
|
|
221
224
|
this.migrations = options.migrations || migration.defaults.DefaultMigrations;
|
|
222
225
|
this.migrator = new migration.migrator.Migrator(options.tracker, this.migrations, this.contexts);
|
|
223
226
|
}
|
|
@@ -243,7 +246,8 @@ class Account {
|
|
|
243
246
|
contexts: options.contexts,
|
|
244
247
|
networks: options.networks,
|
|
245
248
|
orchestrator: options.orchestrator,
|
|
246
|
-
migrations: options.migrations
|
|
249
|
+
migrations: options.migrations,
|
|
250
|
+
projectAccessKey: options.projectAccessKey
|
|
247
251
|
});
|
|
248
252
|
}
|
|
249
253
|
getAddress() {
|
|
@@ -268,7 +272,7 @@ class Account {
|
|
|
268
272
|
providerFor(chainId) {
|
|
269
273
|
const found = this.network(chainId);
|
|
270
274
|
if (!found.provider && !found.rpcUrl) throw new Error(`Provider not found for chainId ${chainId}`);
|
|
271
|
-
return found.provider || new ethers.ethers.providers.StaticJsonRpcProvider(utils.getEthersConnectionInfo(found.rpcUrl,
|
|
275
|
+
return found.provider || new ethers.ethers.providers.StaticJsonRpcProvider(utils.getEthersConnectionInfo(found.rpcUrl, this.projectAccessKey, this.jwt), {
|
|
272
276
|
name: '',
|
|
273
277
|
chainId: ethers.ethers.BigNumber.from(chainId).toNumber()
|
|
274
278
|
});
|
|
@@ -285,6 +289,7 @@ class Account {
|
|
|
285
289
|
if (!found.relayer) throw new Error(`Relayer not found for chainId ${chainId}`);
|
|
286
290
|
if (relayer.isRelayer(found.relayer)) return found.relayer;
|
|
287
291
|
return new relayer.RpcRelayer(_extends({}, found.relayer, {
|
|
292
|
+
projectAccessKey: this.projectAccessKey,
|
|
288
293
|
jwtAuth: this.jwt
|
|
289
294
|
}));
|
|
290
295
|
}
|
|
@@ -553,6 +558,51 @@ class Account {
|
|
|
553
558
|
}
|
|
554
559
|
return decorated;
|
|
555
560
|
}
|
|
561
|
+
buildOnChainSignature(digest) {
|
|
562
|
+
const subdigest = core.commons.signature.subdigestOf({
|
|
563
|
+
digest: ethers.ethers.utils.hexlify(digest),
|
|
564
|
+
chainId: 0,
|
|
565
|
+
address: this.address
|
|
566
|
+
});
|
|
567
|
+
const hexSubdigest = ethers.ethers.utils.hexlify(subdigest);
|
|
568
|
+
const config = this.coders.config.fromSimple({
|
|
569
|
+
// Threshold *only* needs to be > 0, this is not a magic number
|
|
570
|
+
// we only use 2 ** 15 because it may lead to lower gas costs in some chains
|
|
571
|
+
threshold: 32768,
|
|
572
|
+
checkpoint: 0,
|
|
573
|
+
signers: [],
|
|
574
|
+
subdigests: [hexSubdigest]
|
|
575
|
+
});
|
|
576
|
+
const walletInterface = new ethers.ethers.utils.Interface(abi.walletContracts.mainModule.abi);
|
|
577
|
+
const bundle = {
|
|
578
|
+
entrypoint: this.address,
|
|
579
|
+
transactions: [{
|
|
580
|
+
to: this.address,
|
|
581
|
+
data: walletInterface.encodeFunctionData(
|
|
582
|
+
// *NEVER* use updateImageHash here, as it would effectively destroy the wallet
|
|
583
|
+
// setExtraImageHash sets an additional imageHash, without changing the current one
|
|
584
|
+
'setExtraImageHash', [this.coders.config.imageHashOf(config),
|
|
585
|
+
// 2 ** 255 instead of max uint256, to have more zeros in the calldata
|
|
586
|
+
'57896044618658097711785492504343953926634992332820282019728792003956564819968']),
|
|
587
|
+
// Conservative gas limit, used because the current relayer
|
|
588
|
+
// has trouble estimating gas for this transaction
|
|
589
|
+
gasLimit: 250000
|
|
590
|
+
}]
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
// Fire and forget request to save the config
|
|
594
|
+
this.tracker.saveWalletConfig({
|
|
595
|
+
config
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
// Encode a signature proof for the given subdigest
|
|
599
|
+
// use `chainId = 0` to make it simpler, as this signature is only a proof
|
|
600
|
+
const signature = this.coders.signature.encodeSigners(config, new Map(), [hexSubdigest], 0).encoded;
|
|
601
|
+
return {
|
|
602
|
+
bundle,
|
|
603
|
+
signature
|
|
604
|
+
};
|
|
605
|
+
}
|
|
556
606
|
async buildEIP6492Signature(signature, status, chainId) {
|
|
557
607
|
const bootstrapBundle = await this.buildBootstrapTransactions(status, chainId);
|
|
558
608
|
if (bootstrapBundle.transactions.length === 0) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { walletContracts } from '@0xsequence/abi';
|
|
1
2
|
import { commons, universal } from '@0xsequence/core';
|
|
2
3
|
import { defaults, migrator, version } from '@0xsequence/migration';
|
|
3
4
|
import { proto, isRelayer, RpcRelayer } from '@0xsequence/relayer';
|
|
@@ -208,12 +209,14 @@ class Account {
|
|
|
208
209
|
this.migrations = void 0;
|
|
209
210
|
this.orchestrator = void 0;
|
|
210
211
|
this.jwt = void 0;
|
|
212
|
+
this.projectAccessKey = void 0;
|
|
211
213
|
this.address = ethers.utils.getAddress(options.address);
|
|
212
214
|
this.contexts = options.contexts;
|
|
213
215
|
this.tracker = options.tracker;
|
|
214
216
|
this.networks = options.networks;
|
|
215
217
|
this.orchestrator = options.orchestrator;
|
|
216
218
|
this.jwt = options.jwt;
|
|
219
|
+
this.projectAccessKey = options.projectAccessKey;
|
|
217
220
|
this.migrations = options.migrations || defaults.DefaultMigrations;
|
|
218
221
|
this.migrator = new migrator.Migrator(options.tracker, this.migrations, this.contexts);
|
|
219
222
|
}
|
|
@@ -239,7 +242,8 @@ class Account {
|
|
|
239
242
|
contexts: options.contexts,
|
|
240
243
|
networks: options.networks,
|
|
241
244
|
orchestrator: options.orchestrator,
|
|
242
|
-
migrations: options.migrations
|
|
245
|
+
migrations: options.migrations,
|
|
246
|
+
projectAccessKey: options.projectAccessKey
|
|
243
247
|
});
|
|
244
248
|
}
|
|
245
249
|
getAddress() {
|
|
@@ -264,7 +268,7 @@ class Account {
|
|
|
264
268
|
providerFor(chainId) {
|
|
265
269
|
const found = this.network(chainId);
|
|
266
270
|
if (!found.provider && !found.rpcUrl) throw new Error(`Provider not found for chainId ${chainId}`);
|
|
267
|
-
return found.provider || new ethers.providers.StaticJsonRpcProvider(getEthersConnectionInfo(found.rpcUrl,
|
|
271
|
+
return found.provider || new ethers.providers.StaticJsonRpcProvider(getEthersConnectionInfo(found.rpcUrl, this.projectAccessKey, this.jwt), {
|
|
268
272
|
name: '',
|
|
269
273
|
chainId: ethers.BigNumber.from(chainId).toNumber()
|
|
270
274
|
});
|
|
@@ -281,6 +285,7 @@ class Account {
|
|
|
281
285
|
if (!found.relayer) throw new Error(`Relayer not found for chainId ${chainId}`);
|
|
282
286
|
if (isRelayer(found.relayer)) return found.relayer;
|
|
283
287
|
return new RpcRelayer(_extends({}, found.relayer, {
|
|
288
|
+
projectAccessKey: this.projectAccessKey,
|
|
284
289
|
jwtAuth: this.jwt
|
|
285
290
|
}));
|
|
286
291
|
}
|
|
@@ -549,6 +554,51 @@ class Account {
|
|
|
549
554
|
}
|
|
550
555
|
return decorated;
|
|
551
556
|
}
|
|
557
|
+
buildOnChainSignature(digest) {
|
|
558
|
+
const subdigest = commons.signature.subdigestOf({
|
|
559
|
+
digest: ethers.utils.hexlify(digest),
|
|
560
|
+
chainId: 0,
|
|
561
|
+
address: this.address
|
|
562
|
+
});
|
|
563
|
+
const hexSubdigest = ethers.utils.hexlify(subdigest);
|
|
564
|
+
const config = this.coders.config.fromSimple({
|
|
565
|
+
// Threshold *only* needs to be > 0, this is not a magic number
|
|
566
|
+
// we only use 2 ** 15 because it may lead to lower gas costs in some chains
|
|
567
|
+
threshold: 32768,
|
|
568
|
+
checkpoint: 0,
|
|
569
|
+
signers: [],
|
|
570
|
+
subdigests: [hexSubdigest]
|
|
571
|
+
});
|
|
572
|
+
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi);
|
|
573
|
+
const bundle = {
|
|
574
|
+
entrypoint: this.address,
|
|
575
|
+
transactions: [{
|
|
576
|
+
to: this.address,
|
|
577
|
+
data: walletInterface.encodeFunctionData(
|
|
578
|
+
// *NEVER* use updateImageHash here, as it would effectively destroy the wallet
|
|
579
|
+
// setExtraImageHash sets an additional imageHash, without changing the current one
|
|
580
|
+
'setExtraImageHash', [this.coders.config.imageHashOf(config),
|
|
581
|
+
// 2 ** 255 instead of max uint256, to have more zeros in the calldata
|
|
582
|
+
'57896044618658097711785492504343953926634992332820282019728792003956564819968']),
|
|
583
|
+
// Conservative gas limit, used because the current relayer
|
|
584
|
+
// has trouble estimating gas for this transaction
|
|
585
|
+
gasLimit: 250000
|
|
586
|
+
}]
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
// Fire and forget request to save the config
|
|
590
|
+
this.tracker.saveWalletConfig({
|
|
591
|
+
config
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
// Encode a signature proof for the given subdigest
|
|
595
|
+
// use `chainId = 0` to make it simpler, as this signature is only a proof
|
|
596
|
+
const signature = this.coders.signature.encodeSigners(config, new Map(), [hexSubdigest], 0).encoded;
|
|
597
|
+
return {
|
|
598
|
+
bundle,
|
|
599
|
+
signature
|
|
600
|
+
};
|
|
601
|
+
}
|
|
552
602
|
async buildEIP6492Signature(signature, status, chainId) {
|
|
553
603
|
const bootstrapBundle = await this.buildBootstrapTransactions(status, chainId);
|
|
554
604
|
if (bootstrapBundle.transactions.length === 0) {
|
|
@@ -36,6 +36,7 @@ export type AccountOptions = {
|
|
|
36
36
|
orchestrator: SignatureOrchestrator;
|
|
37
37
|
networks: NetworkConfig[];
|
|
38
38
|
jwt?: string;
|
|
39
|
+
projectAccessKey?: string;
|
|
39
40
|
};
|
|
40
41
|
export interface PreparedTransactions {
|
|
41
42
|
transactions: commons.transaction.SimulatedTransaction[];
|
|
@@ -52,6 +53,7 @@ export declare class Account {
|
|
|
52
53
|
readonly migrations: migrator.Migrations;
|
|
53
54
|
private orchestrator;
|
|
54
55
|
private jwt?;
|
|
56
|
+
private projectAccessKey?;
|
|
55
57
|
constructor(options: AccountOptions);
|
|
56
58
|
getSigner(chainId: ChainId, options?: AccountSignerOptions): AccountSigner;
|
|
57
59
|
static new(options: {
|
|
@@ -61,6 +63,7 @@ export declare class Account {
|
|
|
61
63
|
orchestrator: SignatureOrchestrator;
|
|
62
64
|
networks: NetworkConfig[];
|
|
63
65
|
migrations?: migrator.Migrations;
|
|
66
|
+
projectAccessKey?: string;
|
|
64
67
|
}): Promise<Account>;
|
|
65
68
|
getAddress(): Promise<string>;
|
|
66
69
|
get version(): number;
|
|
@@ -85,6 +88,10 @@ export declare class Account {
|
|
|
85
88
|
decorateSignature<T extends ethers.BytesLike>(signature: T, status: Partial<Pick<AccountStatus, 'presignedConfigurations'>>): Promise<T | string>;
|
|
86
89
|
publishWitness(): Promise<void>;
|
|
87
90
|
signDigest(digest: ethers.BytesLike, chainId: ethers.BigNumberish, decorate?: boolean, cantValidateBehavior?: 'ignore' | 'eip6492' | 'throw', metadata?: object): Promise<string>;
|
|
91
|
+
buildOnChainSignature(digest: ethers.BytesLike): {
|
|
92
|
+
bundle: commons.transaction.TransactionBundle;
|
|
93
|
+
signature: string;
|
|
94
|
+
};
|
|
88
95
|
private buildEIP6492Signature;
|
|
89
96
|
editConfig(changes: {
|
|
90
97
|
add?: commons.config.SimpleSigner[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/account",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "tools for migrating sequence wallets to new versions",
|
|
5
5
|
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/account",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -10,19 +10,20 @@
|
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"ethers": "^5.5.2",
|
|
13
|
-
"@0xsequence/
|
|
14
|
-
"@0xsequence/
|
|
15
|
-
"@0xsequence/
|
|
16
|
-
"@0xsequence/
|
|
17
|
-
"@0xsequence/
|
|
18
|
-
"@0xsequence/
|
|
19
|
-
"@0xsequence/
|
|
13
|
+
"@0xsequence/abi": "1.6.2",
|
|
14
|
+
"@0xsequence/core": "1.6.2",
|
|
15
|
+
"@0xsequence/migration": "1.6.2",
|
|
16
|
+
"@0xsequence/network": "1.6.2",
|
|
17
|
+
"@0xsequence/relayer": "1.6.2",
|
|
18
|
+
"@0xsequence/sessions": "1.6.2",
|
|
19
|
+
"@0xsequence/utils": "1.6.2",
|
|
20
|
+
"@0xsequence/wallet": "1.6.2"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
23
24
|
"nyc": "^15.1.0",
|
|
24
|
-
"@0xsequence/
|
|
25
|
-
"@0xsequence/
|
|
25
|
+
"@0xsequence/signhub": "1.6.2",
|
|
26
|
+
"@0xsequence/tests": "1.6.2"
|
|
26
27
|
},
|
|
27
28
|
"files": [
|
|
28
29
|
"src",
|
package/src/account.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { walletContracts } from '@0xsequence/abi'
|
|
1
2
|
import { commons, universal } from '@0xsequence/core'
|
|
2
3
|
import { WalletSignRequestMetadata } from '@0xsequence/core/src/commons'
|
|
3
4
|
import { migrator, defaults, version } from '@0xsequence/migration'
|
|
@@ -56,6 +57,9 @@ export type AccountOptions = {
|
|
|
56
57
|
|
|
57
58
|
// Jwt
|
|
58
59
|
jwt?: string
|
|
60
|
+
|
|
61
|
+
// Project access key
|
|
62
|
+
projectAccessKey?: string
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
export interface PreparedTransactions {
|
|
@@ -101,6 +105,8 @@ export class Account {
|
|
|
101
105
|
|
|
102
106
|
private jwt?: string
|
|
103
107
|
|
|
108
|
+
private projectAccessKey?: string
|
|
109
|
+
|
|
104
110
|
constructor(options: AccountOptions) {
|
|
105
111
|
this.address = ethers.utils.getAddress(options.address)
|
|
106
112
|
|
|
@@ -109,6 +115,7 @@ export class Account {
|
|
|
109
115
|
this.networks = options.networks
|
|
110
116
|
this.orchestrator = options.orchestrator
|
|
111
117
|
this.jwt = options.jwt
|
|
118
|
+
this.projectAccessKey = options.projectAccessKey
|
|
112
119
|
|
|
113
120
|
this.migrations = options.migrations || defaults.DefaultMigrations
|
|
114
121
|
this.migrator = new migrator.Migrator(options.tracker, this.migrations, this.contexts)
|
|
@@ -125,6 +132,7 @@ export class Account {
|
|
|
125
132
|
orchestrator: SignatureOrchestrator
|
|
126
133
|
networks: NetworkConfig[]
|
|
127
134
|
migrations?: migrator.Migrations
|
|
135
|
+
projectAccessKey?: string
|
|
128
136
|
}): Promise<Account> {
|
|
129
137
|
const mig = new migrator.Migrator(options.tracker, options.migrations ?? defaults.DefaultMigrations, options.contexts)
|
|
130
138
|
|
|
@@ -144,7 +152,8 @@ export class Account {
|
|
|
144
152
|
contexts: options.contexts,
|
|
145
153
|
networks: options.networks,
|
|
146
154
|
orchestrator: options.orchestrator,
|
|
147
|
-
migrations: options.migrations
|
|
155
|
+
migrations: options.migrations,
|
|
156
|
+
projectAccessKey: options.projectAccessKey
|
|
148
157
|
})
|
|
149
158
|
}
|
|
150
159
|
|
|
@@ -180,7 +189,7 @@ export class Account {
|
|
|
180
189
|
if (!found.provider && !found.rpcUrl) throw new Error(`Provider not found for chainId ${chainId}`)
|
|
181
190
|
return (
|
|
182
191
|
found.provider ||
|
|
183
|
-
new ethers.providers.StaticJsonRpcProvider(getEthersConnectionInfo(found.rpcUrl,
|
|
192
|
+
new ethers.providers.StaticJsonRpcProvider(getEthersConnectionInfo(found.rpcUrl, this.projectAccessKey, this.jwt), {
|
|
184
193
|
name: '',
|
|
185
194
|
chainId: ethers.BigNumber.from(chainId).toNumber()
|
|
186
195
|
})
|
|
@@ -199,7 +208,7 @@ export class Account {
|
|
|
199
208
|
const found = this.network(chainId)
|
|
200
209
|
if (!found.relayer) throw new Error(`Relayer not found for chainId ${chainId}`)
|
|
201
210
|
if (isRelayer(found.relayer)) return found.relayer
|
|
202
|
-
return new RpcRelayer({ ...found.relayer, jwtAuth: this.jwt })
|
|
211
|
+
return new RpcRelayer({ ...found.relayer, projectAccessKey: this.projectAccessKey, jwtAuth: this.jwt })
|
|
203
212
|
}
|
|
204
213
|
|
|
205
214
|
setOrchestrator(orchestrator: SignatureOrchestrator) {
|
|
@@ -526,6 +535,50 @@ export class Account {
|
|
|
526
535
|
return decorated
|
|
527
536
|
}
|
|
528
537
|
|
|
538
|
+
buildOnChainSignature(digest: ethers.BytesLike): { bundle: commons.transaction.TransactionBundle; signature: string } {
|
|
539
|
+
const subdigest = commons.signature.subdigestOf({ digest: ethers.utils.hexlify(digest), chainId: 0, address: this.address })
|
|
540
|
+
const hexSubdigest = ethers.utils.hexlify(subdigest)
|
|
541
|
+
const config = this.coders.config.fromSimple({
|
|
542
|
+
// Threshold *only* needs to be > 0, this is not a magic number
|
|
543
|
+
// we only use 2 ** 15 because it may lead to lower gas costs in some chains
|
|
544
|
+
threshold: 32768,
|
|
545
|
+
checkpoint: 0,
|
|
546
|
+
signers: [],
|
|
547
|
+
subdigests: [hexSubdigest]
|
|
548
|
+
})
|
|
549
|
+
|
|
550
|
+
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi)
|
|
551
|
+
const bundle: commons.transaction.TransactionBundle = {
|
|
552
|
+
entrypoint: this.address,
|
|
553
|
+
transactions: [
|
|
554
|
+
{
|
|
555
|
+
to: this.address,
|
|
556
|
+
data: walletInterface.encodeFunctionData(
|
|
557
|
+
// *NEVER* use updateImageHash here, as it would effectively destroy the wallet
|
|
558
|
+
// setExtraImageHash sets an additional imageHash, without changing the current one
|
|
559
|
+
'setExtraImageHash',
|
|
560
|
+
[
|
|
561
|
+
this.coders.config.imageHashOf(config),
|
|
562
|
+
// 2 ** 255 instead of max uint256, to have more zeros in the calldata
|
|
563
|
+
'57896044618658097711785492504343953926634992332820282019728792003956564819968'
|
|
564
|
+
]
|
|
565
|
+
),
|
|
566
|
+
// Conservative gas limit, used because the current relayer
|
|
567
|
+
// has trouble estimating gas for this transaction
|
|
568
|
+
gasLimit: 250000
|
|
569
|
+
}
|
|
570
|
+
]
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// Fire and forget request to save the config
|
|
574
|
+
this.tracker.saveWalletConfig({ config })
|
|
575
|
+
|
|
576
|
+
// Encode a signature proof for the given subdigest
|
|
577
|
+
// use `chainId = 0` to make it simpler, as this signature is only a proof
|
|
578
|
+
const signature = this.coders.signature.encodeSigners(config, new Map(), [hexSubdigest], 0).encoded
|
|
579
|
+
return { bundle, signature }
|
|
580
|
+
}
|
|
581
|
+
|
|
529
582
|
private async buildEIP6492Signature(signature: string, status: AccountStatus, chainId: ethers.BigNumberish): Promise<string> {
|
|
530
583
|
const bootstrapBundle = await this.buildBootstrapTransactions(status, chainId)
|
|
531
584
|
if (bootstrapBundle.transactions.length === 0) {
|