@0xsequence/account 1.6.0 → 1.6.1
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');
|
|
@@ -553,6 +554,51 @@ class Account {
|
|
|
553
554
|
}
|
|
554
555
|
return decorated;
|
|
555
556
|
}
|
|
557
|
+
buildOnChainSignature(digest) {
|
|
558
|
+
const subdigest = core.commons.signature.subdigestOf({
|
|
559
|
+
digest: ethers.ethers.utils.hexlify(digest),
|
|
560
|
+
chainId: 0,
|
|
561
|
+
address: this.address
|
|
562
|
+
});
|
|
563
|
+
const hexSubdigest = ethers.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.ethers.utils.Interface(abi.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
|
+
}
|
|
556
602
|
async buildEIP6492Signature(signature, status, chainId) {
|
|
557
603
|
const bootstrapBundle = await this.buildBootstrapTransactions(status, chainId);
|
|
558
604
|
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');
|
|
@@ -553,6 +554,51 @@ class Account {
|
|
|
553
554
|
}
|
|
554
555
|
return decorated;
|
|
555
556
|
}
|
|
557
|
+
buildOnChainSignature(digest) {
|
|
558
|
+
const subdigest = core.commons.signature.subdigestOf({
|
|
559
|
+
digest: ethers.ethers.utils.hexlify(digest),
|
|
560
|
+
chainId: 0,
|
|
561
|
+
address: this.address
|
|
562
|
+
});
|
|
563
|
+
const hexSubdigest = ethers.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.ethers.utils.Interface(abi.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
|
+
}
|
|
556
602
|
async buildEIP6492Signature(signature, status, chainId) {
|
|
557
603
|
const bootstrapBundle = await this.buildBootstrapTransactions(status, chainId);
|
|
558
604
|
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';
|
|
@@ -549,6 +550,51 @@ class Account {
|
|
|
549
550
|
}
|
|
550
551
|
return decorated;
|
|
551
552
|
}
|
|
553
|
+
buildOnChainSignature(digest) {
|
|
554
|
+
const subdigest = commons.signature.subdigestOf({
|
|
555
|
+
digest: ethers.utils.hexlify(digest),
|
|
556
|
+
chainId: 0,
|
|
557
|
+
address: this.address
|
|
558
|
+
});
|
|
559
|
+
const hexSubdigest = ethers.utils.hexlify(subdigest);
|
|
560
|
+
const config = this.coders.config.fromSimple({
|
|
561
|
+
// Threshold *only* needs to be > 0, this is not a magic number
|
|
562
|
+
// we only use 2 ** 15 because it may lead to lower gas costs in some chains
|
|
563
|
+
threshold: 32768,
|
|
564
|
+
checkpoint: 0,
|
|
565
|
+
signers: [],
|
|
566
|
+
subdigests: [hexSubdigest]
|
|
567
|
+
});
|
|
568
|
+
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi);
|
|
569
|
+
const bundle = {
|
|
570
|
+
entrypoint: this.address,
|
|
571
|
+
transactions: [{
|
|
572
|
+
to: this.address,
|
|
573
|
+
data: walletInterface.encodeFunctionData(
|
|
574
|
+
// *NEVER* use updateImageHash here, as it would effectively destroy the wallet
|
|
575
|
+
// setExtraImageHash sets an additional imageHash, without changing the current one
|
|
576
|
+
'setExtraImageHash', [this.coders.config.imageHashOf(config),
|
|
577
|
+
// 2 ** 255 instead of max uint256, to have more zeros in the calldata
|
|
578
|
+
'57896044618658097711785492504343953926634992332820282019728792003956564819968']),
|
|
579
|
+
// Conservative gas limit, used because the current relayer
|
|
580
|
+
// has trouble estimating gas for this transaction
|
|
581
|
+
gasLimit: 250000
|
|
582
|
+
}]
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
// Fire and forget request to save the config
|
|
586
|
+
this.tracker.saveWalletConfig({
|
|
587
|
+
config
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
// Encode a signature proof for the given subdigest
|
|
591
|
+
// use `chainId = 0` to make it simpler, as this signature is only a proof
|
|
592
|
+
const signature = this.coders.signature.encodeSigners(config, new Map(), [hexSubdigest], 0).encoded;
|
|
593
|
+
return {
|
|
594
|
+
bundle,
|
|
595
|
+
signature
|
|
596
|
+
};
|
|
597
|
+
}
|
|
552
598
|
async buildEIP6492Signature(signature, status, chainId) {
|
|
553
599
|
const bootstrapBundle = await this.buildBootstrapTransactions(status, chainId);
|
|
554
600
|
if (bootstrapBundle.transactions.length === 0) {
|
|
@@ -85,6 +85,10 @@ export declare class Account {
|
|
|
85
85
|
decorateSignature<T extends ethers.BytesLike>(signature: T, status: Partial<Pick<AccountStatus, 'presignedConfigurations'>>): Promise<T | string>;
|
|
86
86
|
publishWitness(): Promise<void>;
|
|
87
87
|
signDigest(digest: ethers.BytesLike, chainId: ethers.BigNumberish, decorate?: boolean, cantValidateBehavior?: 'ignore' | 'eip6492' | 'throw', metadata?: object): Promise<string>;
|
|
88
|
+
buildOnChainSignature(digest: ethers.BytesLike): {
|
|
89
|
+
bundle: commons.transaction.TransactionBundle;
|
|
90
|
+
signature: string;
|
|
91
|
+
};
|
|
88
92
|
private buildEIP6492Signature;
|
|
89
93
|
editConfig(changes: {
|
|
90
94
|
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.1",
|
|
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.1",
|
|
14
|
+
"@0xsequence/core": "1.6.1",
|
|
15
|
+
"@0xsequence/migration": "1.6.1",
|
|
16
|
+
"@0xsequence/network": "1.6.1",
|
|
17
|
+
"@0xsequence/relayer": "1.6.1",
|
|
18
|
+
"@0xsequence/sessions": "1.6.1",
|
|
19
|
+
"@0xsequence/utils": "1.6.1",
|
|
20
|
+
"@0xsequence/wallet": "1.6.1"
|
|
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.1",
|
|
26
|
+
"@0xsequence/tests": "1.6.1"
|
|
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'
|
|
@@ -526,6 +527,50 @@ export class Account {
|
|
|
526
527
|
return decorated
|
|
527
528
|
}
|
|
528
529
|
|
|
530
|
+
buildOnChainSignature(digest: ethers.BytesLike): { bundle: commons.transaction.TransactionBundle; signature: string } {
|
|
531
|
+
const subdigest = commons.signature.subdigestOf({ digest: ethers.utils.hexlify(digest), chainId: 0, address: this.address })
|
|
532
|
+
const hexSubdigest = ethers.utils.hexlify(subdigest)
|
|
533
|
+
const config = this.coders.config.fromSimple({
|
|
534
|
+
// Threshold *only* needs to be > 0, this is not a magic number
|
|
535
|
+
// we only use 2 ** 15 because it may lead to lower gas costs in some chains
|
|
536
|
+
threshold: 32768,
|
|
537
|
+
checkpoint: 0,
|
|
538
|
+
signers: [],
|
|
539
|
+
subdigests: [hexSubdigest]
|
|
540
|
+
})
|
|
541
|
+
|
|
542
|
+
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi)
|
|
543
|
+
const bundle: commons.transaction.TransactionBundle = {
|
|
544
|
+
entrypoint: this.address,
|
|
545
|
+
transactions: [
|
|
546
|
+
{
|
|
547
|
+
to: this.address,
|
|
548
|
+
data: walletInterface.encodeFunctionData(
|
|
549
|
+
// *NEVER* use updateImageHash here, as it would effectively destroy the wallet
|
|
550
|
+
// setExtraImageHash sets an additional imageHash, without changing the current one
|
|
551
|
+
'setExtraImageHash',
|
|
552
|
+
[
|
|
553
|
+
this.coders.config.imageHashOf(config),
|
|
554
|
+
// 2 ** 255 instead of max uint256, to have more zeros in the calldata
|
|
555
|
+
'57896044618658097711785492504343953926634992332820282019728792003956564819968'
|
|
556
|
+
]
|
|
557
|
+
),
|
|
558
|
+
// Conservative gas limit, used because the current relayer
|
|
559
|
+
// has trouble estimating gas for this transaction
|
|
560
|
+
gasLimit: 250000
|
|
561
|
+
}
|
|
562
|
+
]
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// Fire and forget request to save the config
|
|
566
|
+
this.tracker.saveWalletConfig({ config })
|
|
567
|
+
|
|
568
|
+
// Encode a signature proof for the given subdigest
|
|
569
|
+
// use `chainId = 0` to make it simpler, as this signature is only a proof
|
|
570
|
+
const signature = this.coders.signature.encodeSigners(config, new Map(), [hexSubdigest], 0).encoded
|
|
571
|
+
return { bundle, signature }
|
|
572
|
+
}
|
|
573
|
+
|
|
529
574
|
private async buildEIP6492Signature(signature: string, status: AccountStatus, chainId: ethers.BigNumberish): Promise<string> {
|
|
530
575
|
const bootstrapBundle = await this.buildBootstrapTransactions(status, chainId)
|
|
531
576
|
if (bootstrapBundle.transactions.length === 0) {
|