@0xsequence/account
Advanced tools
Comparing version 0.0.0-20230621220927 to 0.0.0-20230622143614
@@ -282,3 +282,3 @@ 'use strict'; | ||
if (!status.presignedConfigurations || status.presignedConfigurations.length === 0) { | ||
return signature; | ||
return new Promise(resolve => resolve(signature)); | ||
} | ||
@@ -288,3 +288,3 @@ const coder = this.coders.signature; | ||
const chainedSignature = coder.chainSignatures(signature, chain); | ||
return coder.encode(chainedSignature); | ||
return coder.trim(chainedSignature); | ||
} | ||
@@ -339,3 +339,3 @@ async publishWitness() { | ||
// save the presigned transaction to the sessions tracker | ||
return this.tracker.savePresignedConfiguration({ | ||
await this.tracker.savePresignedConfiguration({ | ||
wallet: this.address, | ||
@@ -345,2 +345,12 @@ nextConfig: config, | ||
}); | ||
// safety check, tracker should have a reverse lookup for the imageHash | ||
// outside of the local cache | ||
const reverseConfig = await this.tracker.configOfImageHash({ | ||
imageHash: nextImageHash, | ||
noCache: true | ||
}); | ||
if (!reverseConfig || this.coders.config.imageHashOf(reverseConfig) !== nextImageHash) { | ||
throw Error(`Reverse lookup failed for imageHash ${nextImageHash}`); | ||
} | ||
} | ||
@@ -420,3 +430,3 @@ | ||
return _extends({}, signed, { | ||
signature: this.decorateSignature(signed.signature, status) | ||
signature: await this.decorateSignature(signed.signature, status) | ||
}); | ||
@@ -428,5 +438,14 @@ } | ||
const wallet = this.walletForStatus(chainId, status); | ||
const signed = await this.migrator.signNextMigration(this.address, status.version, wallet, editConfig(wallet.config)); | ||
const nextConfig = editConfig(wallet.config); | ||
const signed = await this.migrator.signNextMigration(this.address, status.version, wallet, nextConfig); | ||
if (!signed) return false; | ||
await this.tracker.saveMigration(this.address, signed, this.contexts); | ||
const nextImageHash = this.coders.config.imageHashOf(nextConfig); | ||
const reverseConfig = await this.tracker.configOfImageHash({ | ||
imageHash: nextImageHash, | ||
noCache: true | ||
}); | ||
if (!reverseConfig || this.coders.config.imageHashOf(reverseConfig) !== nextImageHash) { | ||
throw Error(`Reverse lookup failed for imageHash ${nextImageHash}`); | ||
} | ||
return true; | ||
@@ -433,0 +452,0 @@ } |
@@ -282,3 +282,3 @@ 'use strict'; | ||
if (!status.presignedConfigurations || status.presignedConfigurations.length === 0) { | ||
return signature; | ||
return new Promise(resolve => resolve(signature)); | ||
} | ||
@@ -288,3 +288,3 @@ const coder = this.coders.signature; | ||
const chainedSignature = coder.chainSignatures(signature, chain); | ||
return coder.encode(chainedSignature); | ||
return coder.trim(chainedSignature); | ||
} | ||
@@ -339,3 +339,3 @@ async publishWitness() { | ||
// save the presigned transaction to the sessions tracker | ||
return this.tracker.savePresignedConfiguration({ | ||
await this.tracker.savePresignedConfiguration({ | ||
wallet: this.address, | ||
@@ -345,2 +345,12 @@ nextConfig: config, | ||
}); | ||
// safety check, tracker should have a reverse lookup for the imageHash | ||
// outside of the local cache | ||
const reverseConfig = await this.tracker.configOfImageHash({ | ||
imageHash: nextImageHash, | ||
noCache: true | ||
}); | ||
if (!reverseConfig || this.coders.config.imageHashOf(reverseConfig) !== nextImageHash) { | ||
throw Error(`Reverse lookup failed for imageHash ${nextImageHash}`); | ||
} | ||
} | ||
@@ -420,3 +430,3 @@ | ||
return _extends({}, signed, { | ||
signature: this.decorateSignature(signed.signature, status) | ||
signature: await this.decorateSignature(signed.signature, status) | ||
}); | ||
@@ -428,5 +438,14 @@ } | ||
const wallet = this.walletForStatus(chainId, status); | ||
const signed = await this.migrator.signNextMigration(this.address, status.version, wallet, editConfig(wallet.config)); | ||
const nextConfig = editConfig(wallet.config); | ||
const signed = await this.migrator.signNextMigration(this.address, status.version, wallet, nextConfig); | ||
if (!signed) return false; | ||
await this.tracker.saveMigration(this.address, signed, this.contexts); | ||
const nextImageHash = this.coders.config.imageHashOf(nextConfig); | ||
const reverseConfig = await this.tracker.configOfImageHash({ | ||
imageHash: nextImageHash, | ||
noCache: true | ||
}); | ||
if (!reverseConfig || this.coders.config.imageHashOf(reverseConfig) !== nextImageHash) { | ||
throw Error(`Reverse lookup failed for imageHash ${nextImageHash}`); | ||
} | ||
return true; | ||
@@ -433,0 +452,0 @@ } |
@@ -278,3 +278,3 @@ import { commons, universal } from '@0xsequence/core'; | ||
if (!status.presignedConfigurations || status.presignedConfigurations.length === 0) { | ||
return signature; | ||
return new Promise(resolve => resolve(signature)); | ||
} | ||
@@ -284,3 +284,3 @@ const coder = this.coders.signature; | ||
const chainedSignature = coder.chainSignatures(signature, chain); | ||
return coder.encode(chainedSignature); | ||
return coder.trim(chainedSignature); | ||
} | ||
@@ -335,3 +335,3 @@ async publishWitness() { | ||
// save the presigned transaction to the sessions tracker | ||
return this.tracker.savePresignedConfiguration({ | ||
await this.tracker.savePresignedConfiguration({ | ||
wallet: this.address, | ||
@@ -341,2 +341,12 @@ nextConfig: config, | ||
}); | ||
// safety check, tracker should have a reverse lookup for the imageHash | ||
// outside of the local cache | ||
const reverseConfig = await this.tracker.configOfImageHash({ | ||
imageHash: nextImageHash, | ||
noCache: true | ||
}); | ||
if (!reverseConfig || this.coders.config.imageHashOf(reverseConfig) !== nextImageHash) { | ||
throw Error(`Reverse lookup failed for imageHash ${nextImageHash}`); | ||
} | ||
} | ||
@@ -416,3 +426,3 @@ | ||
return _extends({}, signed, { | ||
signature: this.decorateSignature(signed.signature, status) | ||
signature: await this.decorateSignature(signed.signature, status) | ||
}); | ||
@@ -424,5 +434,14 @@ } | ||
const wallet = this.walletForStatus(chainId, status); | ||
const signed = await this.migrator.signNextMigration(this.address, status.version, wallet, editConfig(wallet.config)); | ||
const nextConfig = editConfig(wallet.config); | ||
const signed = await this.migrator.signNextMigration(this.address, status.version, wallet, nextConfig); | ||
if (!signed) return false; | ||
await this.tracker.saveMigration(this.address, signed, this.contexts); | ||
const nextImageHash = this.coders.config.imageHashOf(nextConfig); | ||
const reverseConfig = await this.tracker.configOfImageHash({ | ||
imageHash: nextImageHash, | ||
noCache: true | ||
}); | ||
if (!reverseConfig || this.coders.config.imageHashOf(reverseConfig) !== nextImageHash) { | ||
throw Error(`Reverse lookup failed for imageHash ${nextImageHash}`); | ||
} | ||
return true; | ||
@@ -429,0 +448,0 @@ } |
@@ -73,3 +73,3 @@ import { commons } from '@0xsequence/core'; | ||
decorateTransactions(bundle: commons.transaction.IntendedTransactionBundle, status: AccountStatus): commons.transaction.IntendedTransactionBundle; | ||
decorateSignature<T extends ethers.BytesLike>(signature: T, status: Partial<Pick<AccountStatus, 'presignedConfigurations'>>): T | string; | ||
decorateSignature<T extends ethers.BytesLike>(signature: T, status: Partial<Pick<AccountStatus, 'presignedConfigurations'>>): Promise<T | string>; | ||
publishWitness(): Promise<void>; | ||
@@ -76,0 +76,0 @@ signDigest(digest: ethers.BytesLike, chainId: ethers.BigNumberish, decorate?: boolean): Promise<string>; |
{ | ||
"name": "@0xsequence/account", | ||
"version": "0.0.0-20230621220927", | ||
"version": "0.0.0-20230622143614", | ||
"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-20230621220927", | ||
"@0xsequence/migration": "0.0.0-20230621220927", | ||
"@0xsequence/network": "0.0.0-20230621220927", | ||
"@0xsequence/relayer": "0.0.0-20230621220927", | ||
"@0xsequence/sessions": "0.0.0-20230621220927", | ||
"@0xsequence/utils": "0.0.0-20230621220927", | ||
"@0xsequence/wallet": "0.0.0-20230621220927" | ||
"@0xsequence/core": "0.0.0-20230622143614", | ||
"@0xsequence/migration": "0.0.0-20230622143614", | ||
"@0xsequence/network": "0.0.0-20230622143614", | ||
"@0xsequence/relayer": "0.0.0-20230622143614", | ||
"@0xsequence/sessions": "0.0.0-20230622143614", | ||
"@0xsequence/utils": "0.0.0-20230622143614", | ||
"@0xsequence/wallet": "0.0.0-20230622143614" | ||
}, | ||
@@ -25,4 +25,4 @@ "devDependencies": { | ||
"nyc": "^15.1.0", | ||
"@0xsequence/signhub": "0.0.0-20230621220927", | ||
"@0xsequence/tests": "0.0.0-20230621220927" | ||
"@0xsequence/signhub": "0.0.0-20230622143614", | ||
"@0xsequence/tests": "0.0.0-20230622143614" | ||
}, | ||
@@ -29,0 +29,0 @@ "files": [ |
@@ -390,5 +390,5 @@ import { commons, universal } from '@0xsequence/core' | ||
status: Partial<Pick<AccountStatus, 'presignedConfigurations'>> | ||
): T | string { | ||
): Promise<T | string> { | ||
if (!status.presignedConfigurations || status.presignedConfigurations.length === 0) { | ||
return signature | ||
return new Promise(resolve => resolve(signature)) | ||
} | ||
@@ -400,3 +400,3 @@ | ||
const chainedSignature = coder.chainSignatures(signature, chain) | ||
return coder.encode(chainedSignature) | ||
return coder.trim(chainedSignature) | ||
} | ||
@@ -460,3 +460,3 @@ | ||
// save the presigned transaction to the sessions tracker | ||
return this.tracker.savePresignedConfiguration({ | ||
await this.tracker.savePresignedConfiguration({ | ||
wallet: this.address, | ||
@@ -466,2 +466,13 @@ nextConfig: config, | ||
}) | ||
// safety check, tracker should have a reverse lookup for the imageHash | ||
// outside of the local cache | ||
const reverseConfig = await this.tracker.configOfImageHash({ | ||
imageHash: nextImageHash, | ||
noCache: true | ||
}) | ||
if (!reverseConfig || this.coders.config.imageHashOf(reverseConfig) !== nextImageHash) { | ||
throw Error(`Reverse lookup failed for imageHash ${nextImageHash}`) | ||
} | ||
} | ||
@@ -549,3 +560,3 @@ | ||
...signed, | ||
signature: this.decorateSignature(signed.signature, status) | ||
signature: await this.decorateSignature(signed.signature, status) | ||
} | ||
@@ -562,6 +573,14 @@ } | ||
const wallet = this.walletForStatus(chainId, status) | ||
const signed = await this.migrator.signNextMigration(this.address, status.version, wallet, editConfig(wallet.config)) | ||
const nextConfig = editConfig(wallet.config) | ||
const signed = await this.migrator.signNextMigration(this.address, status.version, wallet, nextConfig) | ||
if (!signed) return false | ||
await this.tracker.saveMigration(this.address, signed, this.contexts) | ||
const nextImageHash = this.coders.config.imageHashOf(nextConfig) | ||
const reverseConfig = await this.tracker.configOfImageHash({ imageHash: nextImageHash, noCache: true }) | ||
if (!reverseConfig || this.coders.config.imageHashOf(reverseConfig) !== nextImageHash) { | ||
throw Error(`Reverse lookup failed for imageHash ${nextImageHash}`) | ||
} | ||
return true | ||
@@ -568,0 +587,0 @@ } |
123352
2556
+ Added@0xsequence/abi@0.0.0-20230622143614(transitive)
+ Added@0xsequence/core@0.0.0-20230622143614(transitive)
+ Added@0xsequence/guard@0.0.0-20230622143614(transitive)
+ Added@0xsequence/indexer@0.0.0-20230622143614(transitive)
+ Added@0xsequence/migration@0.0.0-20230622143614(transitive)
+ Added@0xsequence/network@0.0.0-20230622143614(transitive)
+ Added@0xsequence/relayer@0.0.0-20230622143614(transitive)
+ Added@0xsequence/replacer@0.0.0-20230622143614(transitive)
+ Added@0xsequence/sessions@0.0.0-20230622143614(transitive)
+ Added@0xsequence/signhub@0.0.0-20230622143614(transitive)
+ Added@0xsequence/utils@0.0.0-20230622143614(transitive)
+ Added@0xsequence/wallet@0.0.0-20230622143614(transitive)
- Removed@0xsequence/abi@0.0.0-20230621220927(transitive)
- Removed@0xsequence/core@0.0.0-20230621220927(transitive)
- Removed@0xsequence/guard@0.0.0-20230621220927(transitive)
- Removed@0xsequence/indexer@0.0.0-20230621220927(transitive)
- Removed@0xsequence/migration@0.0.0-20230621220927(transitive)
- Removed@0xsequence/network@0.0.0-20230621220927(transitive)
- Removed@0xsequence/relayer@0.0.0-20230621220927(transitive)
- Removed@0xsequence/replacer@0.0.0-20230621220927(transitive)
- Removed@0xsequence/sessions@0.0.0-20230621220927(transitive)
- Removed@0xsequence/signhub@0.0.0-20230621220927(transitive)
- Removed@0xsequence/utils@0.0.0-20230621220927(transitive)
- Removed@0xsequence/wallet@0.0.0-20230621220927(transitive)