@0xsequence/migration
Advanced tools
Comparing version 0.0.0-20230417133433 to 0.0.0-20230504182418
@@ -5,33 +5,6 @@ 'use strict'; | ||
var core = require('@0xsequence/core'); | ||
var ethers = require('ethers'); | ||
var core = require('@0xsequence/core'); | ||
var abi = require('@0xsequence/abi'); | ||
async function versionOf(address, firstImageHash, contexts, reader) { | ||
if (!core.commons.context.isValidVersionedContext(contexts)) { | ||
throw new Error("Invalid versioned context"); | ||
} | ||
const versions = Object.values(contexts); | ||
// if not deployed we need to check to which version | ||
// the counterfactual address belongs to | ||
if (!(await reader.isDeployed(address))) { | ||
return counterfactualVersion(address, firstImageHash, versions); | ||
} | ||
// if deployed we need to check the implementation address | ||
const implementation = await reader.implementation(address); | ||
if (!implementation || implementation === ethers.ethers.constants.AddressZero) { | ||
throw new Error('Invalid implementation address'); | ||
} | ||
for (let i = 0; i < versions.length; i++) { | ||
if (versions[i].mainModule === implementation || versions[i].mainModuleUpgradable === implementation) { | ||
return versions[i].version; | ||
} | ||
} | ||
// If we can't find the version then either the address is invalid, | ||
// or the version is not in VersionedContext | ||
throw new Error('Could not find version for deployed address'); | ||
} | ||
function counterfactualVersion(address, firstImageHash, versions) { | ||
@@ -51,3 +24,2 @@ for (let i = 0; i < versions.length; i++) { | ||
__proto__: null, | ||
versionOf: versionOf, | ||
counterfactualVersion: counterfactualVersion | ||
@@ -54,0 +26,0 @@ }); |
@@ -5,33 +5,6 @@ 'use strict'; | ||
var core = require('@0xsequence/core'); | ||
var ethers = require('ethers'); | ||
var core = require('@0xsequence/core'); | ||
var abi = require('@0xsequence/abi'); | ||
async function versionOf(address, firstImageHash, contexts, reader) { | ||
if (!core.commons.context.isValidVersionedContext(contexts)) { | ||
throw new Error("Invalid versioned context"); | ||
} | ||
const versions = Object.values(contexts); | ||
// if not deployed we need to check to which version | ||
// the counterfactual address belongs to | ||
if (!(await reader.isDeployed(address))) { | ||
return counterfactualVersion(address, firstImageHash, versions); | ||
} | ||
// if deployed we need to check the implementation address | ||
const implementation = await reader.implementation(address); | ||
if (!implementation || implementation === ethers.ethers.constants.AddressZero) { | ||
throw new Error('Invalid implementation address'); | ||
} | ||
for (let i = 0; i < versions.length; i++) { | ||
if (versions[i].mainModule === implementation || versions[i].mainModuleUpgradable === implementation) { | ||
return versions[i].version; | ||
} | ||
} | ||
// If we can't find the version then either the address is invalid, | ||
// or the version is not in VersionedContext | ||
throw new Error('Could not find version for deployed address'); | ||
} | ||
function counterfactualVersion(address, firstImageHash, versions) { | ||
@@ -51,3 +24,2 @@ for (let i = 0; i < versions.length; i++) { | ||
__proto__: null, | ||
versionOf: versionOf, | ||
counterfactualVersion: counterfactualVersion | ||
@@ -54,0 +26,0 @@ }); |
@@ -0,32 +1,5 @@ | ||
import { commons, v2 } from '@0xsequence/core'; | ||
import { ethers } from 'ethers'; | ||
import { commons, v2 } from '@0xsequence/core'; | ||
import { walletContracts } from '@0xsequence/abi'; | ||
async function versionOf(address, firstImageHash, contexts, reader) { | ||
if (!commons.context.isValidVersionedContext(contexts)) { | ||
throw new Error("Invalid versioned context"); | ||
} | ||
const versions = Object.values(contexts); | ||
// if not deployed we need to check to which version | ||
// the counterfactual address belongs to | ||
if (!(await reader.isDeployed(address))) { | ||
return counterfactualVersion(address, firstImageHash, versions); | ||
} | ||
// if deployed we need to check the implementation address | ||
const implementation = await reader.implementation(address); | ||
if (!implementation || implementation === ethers.constants.AddressZero) { | ||
throw new Error('Invalid implementation address'); | ||
} | ||
for (let i = 0; i < versions.length; i++) { | ||
if (versions[i].mainModule === implementation || versions[i].mainModuleUpgradable === implementation) { | ||
return versions[i].version; | ||
} | ||
} | ||
// If we can't find the version then either the address is invalid, | ||
// or the version is not in VersionedContext | ||
throw new Error('Could not find version for deployed address'); | ||
} | ||
function counterfactualVersion(address, firstImageHash, versions) { | ||
@@ -46,3 +19,2 @@ for (let i = 0; i < versions.length; i++) { | ||
__proto__: null, | ||
versionOf: versionOf, | ||
counterfactualVersion: counterfactualVersion | ||
@@ -49,0 +21,0 @@ }); |
import { commons } from '@0xsequence/core'; | ||
export declare function versionOf(address: string, firstImageHash: string, contexts: commons.context.VersionedContext, reader: commons.reader.Reader): Promise<number>; | ||
export declare function counterfactualVersion(address: string, firstImageHash: string, versions: commons.context.WalletContext[]): number; | ||
@@ -4,0 +3,0 @@ export interface Version<C extends commons.config.Config, S extends commons.signature.Signature<C>, U extends commons.signature.UnrecoveredSignature> { |
{ | ||
"name": "@0xsequence/migration", | ||
"version": "0.0.0-20230417133433", | ||
"version": "0.0.0-20230504182418", | ||
"description": "tools for migrating sequence wallets to new versions", | ||
@@ -13,5 +13,5 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/migration", | ||
"ethers": "^5.5.2", | ||
"@0xsequence/abi": "0.0.0-20230417133433", | ||
"@0xsequence/wallet": "0.0.0-20230417133433", | ||
"@0xsequence/core": "0.0.0-20230417133433" | ||
"@0xsequence/abi": "0.0.0-20230504182418", | ||
"@0xsequence/core": "0.0.0-20230504182418", | ||
"@0xsequence/wallet": "0.0.0-20230504182418" | ||
}, | ||
@@ -18,0 +18,0 @@ "devDependencies": { |
import { ethers } from "ethers" | ||
import { commons } from '@0xsequence/core' | ||
export async function versionOf( | ||
address: string, | ||
firstImageHash: string, | ||
contexts: commons.context.VersionedContext, | ||
reader: commons.reader.Reader | ||
): Promise<number> { | ||
if (!commons.context.isValidVersionedContext(contexts)) { | ||
throw new Error("Invalid versioned context") | ||
} | ||
const versions = Object.values(contexts) | ||
// if not deployed we need to check to which version | ||
// the counterfactual address belongs to | ||
if (!(await reader.isDeployed(address))) { | ||
return counterfactualVersion(address, firstImageHash, versions) | ||
} | ||
// if deployed we need to check the implementation address | ||
const implementation = await reader.implementation(address) | ||
if (!implementation || implementation === ethers.constants.AddressZero) { | ||
throw new Error('Invalid implementation address') | ||
} | ||
for (let i = 0; i < versions.length; i++) { | ||
if (versions[i].mainModule === implementation || versions[i].mainModuleUpgradable === implementation) { | ||
return versions[i].version | ||
} | ||
} | ||
// If we can't find the version then either the address is invalid, | ||
// or the version is not in VersionedContext | ||
throw new Error('Could not find version for deployed address') | ||
} | ||
export function counterfactualVersion( | ||
@@ -40,0 +5,0 @@ address: string, |
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
49450
961
+ Added@0xsequence/abi@0.0.0-20230504182418(transitive)
+ Added@0xsequence/core@0.0.0-20230504182418(transitive)
+ Added@0xsequence/guard@0.0.0-20230504182418(transitive)
+ Added@0xsequence/indexer@0.0.0-20230504182418(transitive)
+ Added@0xsequence/network@0.0.0-20230504182418(transitive)
+ Added@0xsequence/relayer@0.0.0-20230504182418(transitive)
+ Added@0xsequence/signhub@0.0.0-20230504182418(transitive)
+ Added@0xsequence/utils@0.0.0-20230504182418(transitive)
+ Added@0xsequence/wallet@0.0.0-20230504182418(transitive)
- Removed@0xsequence/abi@0.0.0-20230417133433(transitive)
- Removed@0xsequence/core@0.0.0-20230417133433(transitive)
- Removed@0xsequence/guard@0.0.0-20230417133433(transitive)
- Removed@0xsequence/indexer@0.0.0-20230417133433(transitive)
- Removed@0xsequence/network@0.0.0-20230417133433(transitive)
- Removed@0xsequence/relayer@0.0.0-20230417133433(transitive)
- Removed@0xsequence/signhub@0.0.0-20230417133433(transitive)
- Removed@0xsequence/utils@0.0.0-20230417133433(transitive)
- Removed@0xsequence/wallet@0.0.0-20230417133433(transitive)