@0xsequence/sessions
Advanced tools
Comparing version 0.0.0-20230621220927 to 0.0.0-20230622143614
@@ -1508,4 +1508,6 @@ 'use strict'; | ||
// and then we save it to the cache | ||
const config = await this.cache.configOfImageHash(args); | ||
if (config) return config; | ||
if (args.noCache !== true) { | ||
const config = await this.cache.configOfImageHash(args); | ||
if (config) return config; | ||
} | ||
const config2 = await this.tracker.configOfImageHash(args); | ||
@@ -1525,4 +1527,6 @@ if (config2) { | ||
// and then we save it to the cache | ||
const result1 = await this.cache.imageHashOfCounterfactualWallet(args); | ||
if (result1) return result1; | ||
if (args.noCache !== true) { | ||
const result1 = await this.cache.imageHashOfCounterfactualWallet(args); | ||
if (result1) return result1; | ||
} | ||
const result2 = await this.tracker.imageHashOfCounterfactualWallet(args); | ||
@@ -1547,2 +1551,6 @@ if (result2) { | ||
async walletsOfSigner(args) { | ||
if (args.noCache) { | ||
return this.tracker.walletsOfSigner(args); | ||
} | ||
// In this case we need to both aggregate the results from the cache and the tracker | ||
@@ -1549,0 +1557,0 @@ // and then dedupe the results |
@@ -1508,4 +1508,6 @@ 'use strict'; | ||
// and then we save it to the cache | ||
const config = await this.cache.configOfImageHash(args); | ||
if (config) return config; | ||
if (args.noCache !== true) { | ||
const config = await this.cache.configOfImageHash(args); | ||
if (config) return config; | ||
} | ||
const config2 = await this.tracker.configOfImageHash(args); | ||
@@ -1525,4 +1527,6 @@ if (config2) { | ||
// and then we save it to the cache | ||
const result1 = await this.cache.imageHashOfCounterfactualWallet(args); | ||
if (result1) return result1; | ||
if (args.noCache !== true) { | ||
const result1 = await this.cache.imageHashOfCounterfactualWallet(args); | ||
if (result1) return result1; | ||
} | ||
const result2 = await this.tracker.imageHashOfCounterfactualWallet(args); | ||
@@ -1547,2 +1551,6 @@ if (result2) { | ||
async walletsOfSigner(args) { | ||
if (args.noCache) { | ||
return this.tracker.walletsOfSigner(args); | ||
} | ||
// In this case we need to both aggregate the results from the cache and the tracker | ||
@@ -1549,0 +1557,0 @@ // and then dedupe the results |
@@ -1504,4 +1504,6 @@ import { v2, v1, universal, commons } from '@0xsequence/core'; | ||
// and then we save it to the cache | ||
const config = await this.cache.configOfImageHash(args); | ||
if (config) return config; | ||
if (args.noCache !== true) { | ||
const config = await this.cache.configOfImageHash(args); | ||
if (config) return config; | ||
} | ||
const config2 = await this.tracker.configOfImageHash(args); | ||
@@ -1521,4 +1523,6 @@ if (config2) { | ||
// and then we save it to the cache | ||
const result1 = await this.cache.imageHashOfCounterfactualWallet(args); | ||
if (result1) return result1; | ||
if (args.noCache !== true) { | ||
const result1 = await this.cache.imageHashOfCounterfactualWallet(args); | ||
if (result1) return result1; | ||
} | ||
const result2 = await this.tracker.imageHashOfCounterfactualWallet(args); | ||
@@ -1543,2 +1547,6 @@ if (result2) { | ||
async walletsOfSigner(args) { | ||
if (args.noCache) { | ||
return this.tracker.walletsOfSigner(args); | ||
} | ||
// In this case we need to both aggregate the results from the cache and the tracker | ||
@@ -1545,0 +1553,0 @@ // and then dedupe the results |
@@ -34,2 +34,3 @@ import { commons } from '@0xsequence/core'; | ||
imageHash: string; | ||
noCache?: boolean; | ||
}) => Promise<commons.config.Config | undefined>; | ||
@@ -41,2 +42,3 @@ saveWalletConfig: (args: { | ||
wallet: string; | ||
noCache?: boolean; | ||
}) => Promise<{ | ||
@@ -52,2 +54,3 @@ imageHash: string; | ||
signer: string; | ||
noCache?: boolean; | ||
}) => Promise<{ | ||
@@ -54,0 +57,0 @@ wallet: string; |
@@ -18,2 +18,3 @@ import { commons } from '@0xsequence/core'; | ||
imageHash: string; | ||
noCache?: boolean; | ||
}): Promise<commons.config.Config | undefined>; | ||
@@ -25,2 +26,3 @@ saveWalletConfig(args: { | ||
wallet: string; | ||
noCache?: boolean; | ||
}): Promise<{ | ||
@@ -36,2 +38,3 @@ imageHash: string; | ||
signer: string; | ||
noCache?: boolean; | ||
}): Promise<{ | ||
@@ -38,0 +41,0 @@ wallet: string; |
@@ -9,3 +9,3 @@ | ||
key: string; | ||
value: v1.config.WalletConfig | PlainV2Config; | ||
value: v1.config.WalletConfig | v2.config.WalletConfig | PlainV2Config; | ||
}; | ||
@@ -57,4 +57,4 @@ 'v2Nodes': { | ||
getDb(): Promise<IDBPDatabase<LocalTrackerDBSchema>>; | ||
loadConfig: (imageHash: string) => Promise<v1.config.WalletConfig | PlainV2Config | undefined>; | ||
saveConfig: (imageHash: string, config: v1.config.WalletConfig | PlainV2Config) => Promise<void>; | ||
loadConfig: (imageHash: string) => Promise<v1.config.WalletConfig | v2.config.WalletConfig | PlainV2Config | undefined>; | ||
saveConfig: (imageHash: string, config: v1.config.WalletConfig | v2.config.WalletConfig | PlainV2Config) => Promise<void>; | ||
loadV2Node: (nodeHash: string) => Promise<v2.config.Topology | PlainNode | PlainNested | undefined>; | ||
@@ -61,0 +61,0 @@ saveV2Node: (nodeHash: string, node: v2.config.Topology | PlainNode | PlainNested) => Promise<void>; |
@@ -12,4 +12,4 @@ | ||
private migrations; | ||
loadConfig: (imageHash: string) => Promise<v1.config.WalletConfig | PlainV2Config | undefined>; | ||
saveConfig: (imageHash: string, config: v1.config.WalletConfig | PlainV2Config) => Promise<void>; | ||
loadConfig: (imageHash: string) => Promise<v1.config.WalletConfig | v2.config.WalletConfig | PlainV2Config | undefined>; | ||
saveConfig: (imageHash: string, config: v1.config.WalletConfig | v2.config.WalletConfig | PlainV2Config) => Promise<void>; | ||
loadV2Node: (nodeHash: string) => Promise<v2.config.Topology | PlainNode | PlainNested | undefined>; | ||
@@ -16,0 +16,0 @@ saveV2Node: (nodeHash: string, node: v2.config.Topology | PlainNode | PlainNested) => Promise<void>; |
{ | ||
"name": "@0xsequence/sessions", | ||
"version": "0.0.0-20230621220927", | ||
"version": "0.0.0-20230622143614", | ||
"description": "tools for migrating sequence wallets to new versions", | ||
@@ -14,5 +14,5 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/sessions", | ||
"idb": "^7.1.1", | ||
"@0xsequence/core": "0.0.0-20230621220927", | ||
"@0xsequence/migration": "0.0.0-20230621220927", | ||
"@0xsequence/replacer": "0.0.0-20230621220927" | ||
"@0xsequence/core": "0.0.0-20230622143614", | ||
"@0xsequence/migration": "0.0.0-20230622143614", | ||
"@0xsequence/replacer": "0.0.0-20230622143614" | ||
}, | ||
@@ -23,4 +23,4 @@ "devDependencies": { | ||
"nyc": "^15.1.0", | ||
"@0xsequence/signhub": "0.0.0-20230621220927", | ||
"@0xsequence/tests": "0.0.0-20230621220927" | ||
"@0xsequence/tests": "0.0.0-20230622143614", | ||
"@0xsequence/signhub": "0.0.0-20230622143614" | ||
}, | ||
@@ -27,0 +27,0 @@ "files": [ |
@@ -33,3 +33,4 @@ import { commons } from '@0xsequence/core' | ||
configOfImageHash: (args: { | ||
imageHash: string | ||
imageHash: string, | ||
noCache?: boolean | ||
}) => Promise<commons.config.Config | undefined> | ||
@@ -42,3 +43,4 @@ | ||
imageHashOfCounterfactualWallet: (args: { | ||
wallet: string | ||
wallet: string, | ||
noCache?: boolean | ||
}) => Promise<{ | ||
@@ -49,6 +51,10 @@ imageHash: string, | ||
saveCounterfactualWallet: (args: { config: commons.config.Config; context: commons.context.WalletContext[] }) => Promise<void> | ||
saveCounterfactualWallet: (args: { | ||
config: commons.config.Config; | ||
context: commons.context.WalletContext[] | ||
}) => Promise<void> | ||
walletsOfSigner: (args: { | ||
signer: string | ||
signer: string, | ||
noCache?: boolean | ||
}) => Promise<{ | ||
@@ -55,0 +61,0 @@ wallet: string, |
@@ -68,7 +68,9 @@ | ||
async configOfImageHash(args: { imageHash: string }): Promise<commons.config.Config | undefined> { | ||
async configOfImageHash(args: { imageHash: string, noCache?: boolean }): Promise<commons.config.Config | undefined> { | ||
// We first check the cache, if it's not there, we check the tracker | ||
// and then we save it to the cache | ||
const config = await this.cache.configOfImageHash(args) | ||
if (config) return config | ||
if (args.noCache !== true) { | ||
const config = await this.cache.configOfImageHash(args) | ||
if (config) return config | ||
} | ||
@@ -87,7 +89,9 @@ const config2 = await this.tracker.configOfImageHash(args) | ||
async imageHashOfCounterfactualWallet(args: { wallet: string }): Promise<{ imageHash: string; context: commons.context.WalletContext } | undefined> { | ||
async imageHashOfCounterfactualWallet(args: { wallet: string, noCache?: boolean }): Promise<{ imageHash: string; context: commons.context.WalletContext } | undefined> { | ||
// We first check the cache, if it's not there, we check the tracker | ||
// and then we save it to the cache | ||
const result1 = await this.cache.imageHashOfCounterfactualWallet(args) | ||
if (result1) return result1 | ||
if (args.noCache !== true) { | ||
const result1 = await this.cache.imageHashOfCounterfactualWallet(args) | ||
if (result1) return result1 | ||
} | ||
@@ -110,3 +114,7 @@ const result2 = await this.tracker.imageHashOfCounterfactualWallet(args) | ||
async walletsOfSigner(args: { signer: string }): Promise<{ wallet: string; proof: { digest: string; chainId: ethers.BigNumber; signature: string } }[]> { | ||
async walletsOfSigner(args: { signer: string, noCache?: boolean }): Promise<{ wallet: string; proof: { digest: string; chainId: ethers.BigNumber; signature: string } }[]> { | ||
if (args.noCache) { | ||
return this.tracker.walletsOfSigner(args) | ||
} | ||
// In this case we need to both aggregate the results from the cache and the tracker | ||
@@ -113,0 +121,0 @@ // and then dedupe the results |
@@ -10,3 +10,3 @@ import { commons, v1, v2 } from "@0xsequence/core" | ||
key: string, | ||
value: v1.config.WalletConfig | PlainV2Config | ||
value: v1.config.WalletConfig | v2.config.WalletConfig | PlainV2Config | ||
}, | ||
@@ -113,3 +113,3 @@ 'v2Nodes': { | ||
loadConfig = async (imageHash: string): Promise<v1.config.WalletConfig | PlainV2Config | undefined> => { | ||
loadConfig = async (imageHash: string): Promise<v1.config.WalletConfig | v2.config.WalletConfig | PlainV2Config | undefined> => { | ||
const db = await this.getDb() | ||
@@ -119,3 +119,3 @@ return db.get('configs', imageHash).then((c) => recreateBigNumbers(c)) | ||
saveConfig = async (imageHash: string, config: v1.config.WalletConfig | PlainV2Config): Promise<void> => { | ||
saveConfig = async (imageHash: string, config: v1.config.WalletConfig | v2.config.WalletConfig | PlainV2Config): Promise<void> => { | ||
const db = await this.getDb() | ||
@@ -122,0 +122,0 @@ await db.put('configs', config, imageHash) |
@@ -6,3 +6,3 @@ import { commons, v1, v2 } from "@0xsequence/core" | ||
export class MemoryTrackerStore implements TrackerStore { | ||
private configs: { [imageHash: string]: v1.config.WalletConfig | PlainV2Config } = {} | ||
private configs: { [imageHash: string]: v1.config.WalletConfig | v2.config.WalletConfig | PlainV2Config } = {} | ||
private v2Nodes: { [nodeHash: string]: PlainNode | PlainNested | v2.config.Topology } = {} | ||
@@ -14,7 +14,7 @@ private counterfactualWallets: { [wallet: string]: { imageHash: string, context: commons.context.WalletContext } } = {} | ||
loadConfig = (imageHash: string): Promise<v1.config.WalletConfig | PlainV2Config | undefined> => { | ||
loadConfig = (imageHash: string): Promise<v1.config.WalletConfig | v2.config.WalletConfig | PlainV2Config | undefined> => { | ||
return Promise.resolve(this.configs[imageHash]) | ||
} | ||
saveConfig = (imageHash: string, config: v1.config.WalletConfig | PlainV2Config): Promise<void> => { | ||
saveConfig = (imageHash: string, config: v1.config.WalletConfig | v2.config.WalletConfig | PlainV2Config): Promise<void> => { | ||
this.configs[imageHash] = config | ||
@@ -21,0 +21,0 @@ return Promise.resolve() |
290740
7461
+ 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/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/signhub@0.0.0-20230621220927(transitive)
- Removed@0xsequence/utils@0.0.0-20230621220927(transitive)
- Removed@0xsequence/wallet@0.0.0-20230621220927(transitive)