@0xsequence/account
Advanced tools
Comparing version 0.0.0-20230405161104 to 0.0.0-20230405192618
@@ -305,3 +305,3 @@ 'use strict'; | ||
} | ||
async signDigest(digest, chainId, decorate = true, useOnchain = false) { | ||
async signDigest(digest, chainId, decorate = true) { | ||
// If we are signing a digest for chainId zero then we can never be fully migrated | ||
@@ -317,6 +317,5 @@ // because Sequence v1 doesn't allow for signing a message on "all chains" | ||
this.mustBeFullyMigrated(status); | ||
const useStatus = useOnchain ? status.onChain : status; | ||
const wallet = this.walletForStatus(chainId, useStatus); | ||
const wallet = this.walletForStatus(chainId, status); | ||
const signature = await wallet.signDigest(digest); | ||
return decorate ? this.decorateSignature(signature, useStatus) : signature; | ||
return decorate ? this.decorateSignature(signature, status) : signature; | ||
} | ||
@@ -383,2 +382,8 @@ async editConfig(changes) { | ||
// Build the transaction intent, if the transaction has migrations | ||
// then we should use one of the intents of the migrations (anyone will do) | ||
// if it doesn't, then we must build a random intent, this is not ideal | ||
// because we will not be able to track the transaction later | ||
const id = status.signedMigrations.length > 0 ? status.signedMigrations[0].tx.intent.id : ethers.ethers.utils.hexlify(ethers.ethers.utils.randomBytes(32)); | ||
// Everything is encoded as a bundle | ||
@@ -391,13 +396,18 @@ // using the GuestModule of the account version | ||
entrypoint: guestModule, | ||
transactions | ||
transactions, | ||
intent: { | ||
id, | ||
wallet: this.address | ||
} | ||
}; | ||
} | ||
async bootstrapTransactions(chainId) { | ||
const status = await this.status(chainId); | ||
async bootstrapTransactions(chainId, prestatus) { | ||
const status = prestatus || (await this.status(chainId)); | ||
return this.buildBootstrapTransactions(status); | ||
} | ||
async doBootstrap(chainId, feeQuote) { | ||
const bootstrapTxs = await this.bootstrapTransactions(chainId); | ||
const intended = core.commons.transaction.intendTransactionBundle(bootstrapTxs, this.address, chainId, ethers.ethers.utils.hexlify(ethers.ethers.utils.randomBytes(32))); | ||
return this.relayer(chainId).relay(intended, feeQuote); | ||
async doBootstrap(chainId, feeQuote, prestatus) { | ||
const bootstrapTxs = await this.bootstrapTransactions(chainId, prestatus); | ||
return this.relayer(chainId).relay(_extends({}, bootstrapTxs, { | ||
chainId | ||
}), feeQuote); | ||
} | ||
@@ -404,0 +414,0 @@ signMessage(message, chainId) { |
@@ -305,3 +305,3 @@ 'use strict'; | ||
} | ||
async signDigest(digest, chainId, decorate = true, useOnchain = false) { | ||
async signDigest(digest, chainId, decorate = true) { | ||
// If we are signing a digest for chainId zero then we can never be fully migrated | ||
@@ -317,6 +317,5 @@ // because Sequence v1 doesn't allow for signing a message on "all chains" | ||
this.mustBeFullyMigrated(status); | ||
const useStatus = useOnchain ? status.onChain : status; | ||
const wallet = this.walletForStatus(chainId, useStatus); | ||
const wallet = this.walletForStatus(chainId, status); | ||
const signature = await wallet.signDigest(digest); | ||
return decorate ? this.decorateSignature(signature, useStatus) : signature; | ||
return decorate ? this.decorateSignature(signature, status) : signature; | ||
} | ||
@@ -383,2 +382,8 @@ async editConfig(changes) { | ||
// Build the transaction intent, if the transaction has migrations | ||
// then we should use one of the intents of the migrations (anyone will do) | ||
// if it doesn't, then we must build a random intent, this is not ideal | ||
// because we will not be able to track the transaction later | ||
const id = status.signedMigrations.length > 0 ? status.signedMigrations[0].tx.intent.id : ethers.ethers.utils.hexlify(ethers.ethers.utils.randomBytes(32)); | ||
// Everything is encoded as a bundle | ||
@@ -391,13 +396,18 @@ // using the GuestModule of the account version | ||
entrypoint: guestModule, | ||
transactions | ||
transactions, | ||
intent: { | ||
id, | ||
wallet: this.address | ||
} | ||
}; | ||
} | ||
async bootstrapTransactions(chainId) { | ||
const status = await this.status(chainId); | ||
async bootstrapTransactions(chainId, prestatus) { | ||
const status = prestatus || (await this.status(chainId)); | ||
return this.buildBootstrapTransactions(status); | ||
} | ||
async doBootstrap(chainId, feeQuote) { | ||
const bootstrapTxs = await this.bootstrapTransactions(chainId); | ||
const intended = core.commons.transaction.intendTransactionBundle(bootstrapTxs, this.address, chainId, ethers.ethers.utils.hexlify(ethers.ethers.utils.randomBytes(32))); | ||
return this.relayer(chainId).relay(intended, feeQuote); | ||
async doBootstrap(chainId, feeQuote, prestatus) { | ||
const bootstrapTxs = await this.bootstrapTransactions(chainId, prestatus); | ||
return this.relayer(chainId).relay(_extends({}, bootstrapTxs, { | ||
chainId | ||
}), feeQuote); | ||
} | ||
@@ -404,0 +414,0 @@ signMessage(message, chainId) { |
@@ -301,3 +301,3 @@ import { commons, universal } from '@0xsequence/core'; | ||
} | ||
async signDigest(digest, chainId, decorate = true, useOnchain = false) { | ||
async signDigest(digest, chainId, decorate = true) { | ||
// If we are signing a digest for chainId zero then we can never be fully migrated | ||
@@ -313,6 +313,5 @@ // because Sequence v1 doesn't allow for signing a message on "all chains" | ||
this.mustBeFullyMigrated(status); | ||
const useStatus = useOnchain ? status.onChain : status; | ||
const wallet = this.walletForStatus(chainId, useStatus); | ||
const wallet = this.walletForStatus(chainId, status); | ||
const signature = await wallet.signDigest(digest); | ||
return decorate ? this.decorateSignature(signature, useStatus) : signature; | ||
return decorate ? this.decorateSignature(signature, status) : signature; | ||
} | ||
@@ -379,2 +378,8 @@ async editConfig(changes) { | ||
// Build the transaction intent, if the transaction has migrations | ||
// then we should use one of the intents of the migrations (anyone will do) | ||
// if it doesn't, then we must build a random intent, this is not ideal | ||
// because we will not be able to track the transaction later | ||
const id = status.signedMigrations.length > 0 ? status.signedMigrations[0].tx.intent.id : ethers.utils.hexlify(ethers.utils.randomBytes(32)); | ||
// Everything is encoded as a bundle | ||
@@ -387,13 +392,18 @@ // using the GuestModule of the account version | ||
entrypoint: guestModule, | ||
transactions | ||
transactions, | ||
intent: { | ||
id, | ||
wallet: this.address | ||
} | ||
}; | ||
} | ||
async bootstrapTransactions(chainId) { | ||
const status = await this.status(chainId); | ||
async bootstrapTransactions(chainId, prestatus) { | ||
const status = prestatus || (await this.status(chainId)); | ||
return this.buildBootstrapTransactions(status); | ||
} | ||
async doBootstrap(chainId, feeQuote) { | ||
const bootstrapTxs = await this.bootstrapTransactions(chainId); | ||
const intended = commons.transaction.intendTransactionBundle(bootstrapTxs, this.address, chainId, ethers.utils.hexlify(ethers.utils.randomBytes(32))); | ||
return this.relayer(chainId).relay(intended, feeQuote); | ||
async doBootstrap(chainId, feeQuote, prestatus) { | ||
const bootstrapTxs = await this.bootstrapTransactions(chainId, prestatus); | ||
return this.relayer(chainId).relay(_extends({}, bootstrapTxs, { | ||
chainId | ||
}), feeQuote); | ||
} | ||
@@ -400,0 +410,0 @@ signMessage(message, chainId) { |
@@ -83,3 +83,3 @@ import { commons } from '@0xsequence/core'; | ||
publishWitness(): Promise<void>; | ||
signDigest(digest: ethers.BytesLike, chainId: ethers.BigNumberish, decorate?: boolean, useOnchain?: boolean): Promise<string>; | ||
signDigest(digest: ethers.BytesLike, chainId: ethers.BigNumberish, decorate?: boolean): Promise<string>; | ||
editConfig(changes: { | ||
@@ -102,5 +102,5 @@ add?: commons.config.SimpleSigner[]; | ||
*/ | ||
buildBootstrapTransactions(status: AccountStatus): commons.transaction.TransactionBundle; | ||
bootstrapTransactions(chainId: ethers.BigNumberish): Promise<commons.transaction.TransactionBundle>; | ||
doBootstrap(chainId: ethers.BigNumberish, feeQuote?: FeeQuote): Promise<commons.transaction.TransactionResponse<any>>; | ||
buildBootstrapTransactions(status: AccountStatus): Omit<commons.transaction.IntendedTransactionBundle, 'chainId'>; | ||
bootstrapTransactions(chainId: ethers.BigNumberish, prestatus?: AccountStatus): Promise<Omit<commons.transaction.IntendedTransactionBundle, 'chainId'>>; | ||
doBootstrap(chainId: ethers.BigNumberish, feeQuote?: FeeQuote, prestatus?: AccountStatus): Promise<commons.transaction.TransactionResponse<any>>; | ||
signMessage(message: ethers.BytesLike, chainId: ethers.BigNumberish): Promise<string>; | ||
@@ -107,0 +107,0 @@ signTransactions(txs: commons.transaction.Transactionish, chainId: ethers.BigNumberish, pstatus?: AccountStatus): Promise<commons.transaction.SignedTransactionBundle>; |
{ | ||
"name": "@0xsequence/account", | ||
"version": "0.0.0-20230405161104", | ||
"version": "0.0.0-20230405192618", | ||
"description": "tools for migrating sequence wallets to new versions", | ||
@@ -13,9 +13,9 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/account", | ||
"ethers": "^5.5.2", | ||
"@0xsequence/core": "0.0.0-20230405161104", | ||
"@0xsequence/migration": "0.0.0-20230405161104", | ||
"@0xsequence/network": "0.0.0-20230405161104", | ||
"@0xsequence/relayer": "0.0.0-20230405161104", | ||
"@0xsequence/sessions": "0.0.0-20230405161104", | ||
"@0xsequence/utils": "0.0.0-20230405161104", | ||
"@0xsequence/wallet": "0.0.0-20230405161104" | ||
"@0xsequence/core": "0.0.0-20230405192618", | ||
"@0xsequence/migration": "0.0.0-20230405192618", | ||
"@0xsequence/network": "0.0.0-20230405192618", | ||
"@0xsequence/relayer": "0.0.0-20230405192618", | ||
"@0xsequence/sessions": "0.0.0-20230405192618", | ||
"@0xsequence/wallet": "0.0.0-20230405192618", | ||
"@0xsequence/utils": "0.0.0-20230405192618" | ||
}, | ||
@@ -25,4 +25,4 @@ "devDependencies": { | ||
"nyc": "^15.1.0", | ||
"@0xsequence/signhub": "0.0.0-20230405161104", | ||
"@0xsequence/tests": "0.0.0-20230405161104" | ||
"@0xsequence/signhub": "0.0.0-20230405192618", | ||
"@0xsequence/tests": "0.0.0-20230405192618" | ||
}, | ||
@@ -29,0 +29,0 @@ "files": [ |
@@ -428,4 +428,3 @@ import { commons, universal } from '@0xsequence/core' | ||
chainId: ethers.BigNumberish, | ||
decorate: boolean = true, | ||
useOnchain: boolean = false | ||
decorate: boolean = true | ||
): Promise<string> { | ||
@@ -444,7 +443,6 @@ // If we are signing a digest for chainId zero then we can never be fully migrated | ||
const useStatus = useOnchain ? status.onChain : status | ||
const wallet = this.walletForStatus(chainId, useStatus) | ||
const wallet = this.walletForStatus(chainId, status) | ||
const signature = await wallet.signDigest(digest) | ||
return decorate ? this.decorateSignature(signature, useStatus as any) : signature | ||
return decorate ? this.decorateSignature(signature, status) : signature | ||
} | ||
@@ -505,3 +503,3 @@ | ||
status: AccountStatus | ||
): commons.transaction.TransactionBundle { | ||
): Omit<commons.transaction.IntendedTransactionBundle, 'chainId'> { | ||
const transactions: commons.transaction.Transaction[] = [] | ||
@@ -531,6 +529,14 @@ | ||
// Build the transaction intent, if the transaction has migrations | ||
// then we should use one of the intents of the migrations (anyone will do) | ||
// if it doesn't, then we must build a random intent, this is not ideal | ||
// because we will not be able to track the transaction later | ||
const id = status.signedMigrations.length > 0 | ||
? status.signedMigrations[0].tx.intent.id | ||
: ethers.utils.hexlify(ethers.utils.randomBytes(32)) | ||
// Everything is encoded as a bundle | ||
// using the GuestModule of the account version | ||
const { guestModule } = this.contextFor(status.version) | ||
return { entrypoint: guestModule, transactions } | ||
return { entrypoint: guestModule, transactions, intent: { id, wallet: this.address } } | ||
} | ||
@@ -540,4 +546,5 @@ | ||
chainId: ethers.BigNumberish, | ||
): Promise<commons.transaction.TransactionBundle> { | ||
const status = await this.status(chainId) | ||
prestatus?: AccountStatus | ||
): Promise<Omit<commons.transaction.IntendedTransactionBundle, 'chainId'>> { | ||
const status = prestatus || await this.status(chainId) | ||
return this.buildBootstrapTransactions(status) | ||
@@ -548,13 +555,7 @@ } | ||
chainId: ethers.BigNumberish, | ||
feeQuote?: FeeQuote | ||
feeQuote?: FeeQuote, | ||
prestatus?: AccountStatus | ||
) { | ||
const bootstrapTxs = await this.bootstrapTransactions(chainId) | ||
const intended = commons.transaction.intendTransactionBundle( | ||
bootstrapTxs, | ||
this.address, | ||
chainId, | ||
ethers.utils.hexlify(ethers.utils.randomBytes(32)) | ||
) | ||
return this.relayer(chainId).relay(intended, feeQuote) | ||
const bootstrapTxs = await this.bootstrapTransactions(chainId, prestatus) | ||
return this.relayer(chainId).relay({ ...bootstrapTxs, chainId }, feeQuote) | ||
} | ||
@@ -561,0 +562,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111827
2362
+ Added@0xsequence/abi@0.0.0-20230405192618(transitive)
+ Added@0xsequence/core@0.0.0-20230405192618(transitive)
+ Added@0xsequence/guard@0.0.0-20230405192618(transitive)
+ Added@0xsequence/indexer@0.0.0-20230405192618(transitive)
+ Added@0xsequence/migration@0.0.0-20230405192618(transitive)
+ Added@0xsequence/network@0.0.0-20230405192618(transitive)
+ Added@0xsequence/relayer@0.0.0-20230405192618(transitive)
+ Added@0xsequence/replacer@0.0.0-20230405192618(transitive)
+ Added@0xsequence/sessions@0.0.0-20230405192618(transitive)
+ Added@0xsequence/signhub@0.0.0-20230405192618(transitive)
+ Added@0xsequence/utils@0.0.0-20230405192618(transitive)
+ Added@0xsequence/wallet@0.0.0-20230405192618(transitive)
- Removed@0xsequence/abi@0.0.0-20230405161104(transitive)
- Removed@0xsequence/core@0.0.0-20230405161104(transitive)
- Removed@0xsequence/guard@0.0.0-20230405161104(transitive)
- Removed@0xsequence/indexer@0.0.0-20230405161104(transitive)
- Removed@0xsequence/migration@0.0.0-20230405161104(transitive)
- Removed@0xsequence/network@0.0.0-20230405161104(transitive)
- Removed@0xsequence/relayer@0.0.0-20230405161104(transitive)
- Removed@0xsequence/replacer@0.0.0-20230405161104(transitive)
- Removed@0xsequence/sessions@0.0.0-20230405161104(transitive)
- Removed@0xsequence/signhub@0.0.0-20230405161104(transitive)
- Removed@0xsequence/utils@0.0.0-20230405161104(transitive)
- Removed@0xsequence/wallet@0.0.0-20230405161104(transitive)