@0xsequence/replacer
Advanced tools
Comparing version 0.0.0-20230217200148 to 0.0.0-20230301184215
@@ -18,2 +18,24 @@ 'use strict'; | ||
class CachedEIP5719 { | ||
constructor(provider, solver, window = 1000) { | ||
this.provider = provider; | ||
this.solver = solver; | ||
this.window = window; | ||
this.pending = new Map(); | ||
} | ||
async runByEIP5719(address, digest, signature) { | ||
const key = `${address}-${digest}-${signature}`; | ||
const now = Date.now(); | ||
if (this.pending.has(key) && now - this.pending.get(key).timestamp < this.window) { | ||
return this.pending.get(key).promise; | ||
} | ||
const promise = runByEIP5719(address, this.provider, digest, signature, this.solver); | ||
this.pending.set(key, { | ||
timestamp: now, | ||
promise | ||
}); | ||
return promise; | ||
} | ||
} | ||
function eip5719Contract(address, provider) { | ||
@@ -99,2 +121,3 @@ // TODO: for some reason walletContracts is not being loaded from local | ||
exports.CachedEIP5719 = CachedEIP5719; | ||
exports.URISolverIPFS = URISolverIPFS; | ||
@@ -101,0 +124,0 @@ exports.eip1271Contract = eip1271Contract; |
@@ -18,2 +18,24 @@ 'use strict'; | ||
class CachedEIP5719 { | ||
constructor(provider, solver, window = 1000) { | ||
this.provider = provider; | ||
this.solver = solver; | ||
this.window = window; | ||
this.pending = new Map(); | ||
} | ||
async runByEIP5719(address, digest, signature) { | ||
const key = `${address}-${digest}-${signature}`; | ||
const now = Date.now(); | ||
if (this.pending.has(key) && now - this.pending.get(key).timestamp < this.window) { | ||
return this.pending.get(key).promise; | ||
} | ||
const promise = runByEIP5719(address, this.provider, digest, signature, this.solver); | ||
this.pending.set(key, { | ||
timestamp: now, | ||
promise | ||
}); | ||
return promise; | ||
} | ||
} | ||
function eip5719Contract(address, provider) { | ||
@@ -99,2 +121,3 @@ // TODO: for some reason walletContracts is not being loaded from local | ||
exports.CachedEIP5719 = CachedEIP5719; | ||
exports.URISolverIPFS = URISolverIPFS; | ||
@@ -101,0 +124,0 @@ exports.eip1271Contract = eip1271Contract; |
@@ -14,2 +14,24 @@ import { ethers } from 'ethers'; | ||
class CachedEIP5719 { | ||
constructor(provider, solver, window = 1000) { | ||
this.provider = provider; | ||
this.solver = solver; | ||
this.window = window; | ||
this.pending = new Map(); | ||
} | ||
async runByEIP5719(address, digest, signature) { | ||
const key = `${address}-${digest}-${signature}`; | ||
const now = Date.now(); | ||
if (this.pending.has(key) && now - this.pending.get(key).timestamp < this.window) { | ||
return this.pending.get(key).promise; | ||
} | ||
const promise = runByEIP5719(address, this.provider, digest, signature, this.solver); | ||
this.pending.set(key, { | ||
timestamp: now, | ||
promise | ||
}); | ||
return promise; | ||
} | ||
} | ||
function eip5719Contract(address, provider) { | ||
@@ -95,2 +117,2 @@ // TODO: for some reason walletContracts is not being loaded from local | ||
export { URISolverIPFS, eip1271Contract, eip5719Contract, isValidSignature, runByEIP5719 }; | ||
export { CachedEIP5719, URISolverIPFS, eip1271Contract, eip5719Contract, isValidSignature, runByEIP5719 }; |
import { ethers } from "ethers"; | ||
export * from "./cached"; | ||
export declare function eip5719Contract(address: string, provider: ethers.providers.Provider): ethers.Contract; | ||
@@ -3,0 +4,0 @@ export declare function eip1271Contract(address: string, provider: ethers.providers.Provider): ethers.Contract; |
{ | ||
"name": "@0xsequence/replacer", | ||
"version": "0.0.0-20230217200148", | ||
"version": "0.0.0-20230301184215", | ||
"description": "EIP-5719 client implementation", | ||
@@ -12,4 +12,4 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/replacer", | ||
"dependencies": { | ||
"@0xsequence/abi": "0.0.0-20230217200148", | ||
"@0xsequence/core": "0.0.0-20230217200148" | ||
"@0xsequence/abi": "0.0.0-20230301184215", | ||
"@0xsequence/core": "0.0.0-20230301184215" | ||
}, | ||
@@ -16,0 +16,0 @@ "peerDependencies": { |
@@ -7,2 +7,4 @@ | ||
export * from "./cached" | ||
export function eip5719Contract(address: string, provider: ethers.providers.Provider): ethers.Contract { | ||
@@ -9,0 +11,0 @@ // TODO: for some reason walletContracts is not being loaded from local |
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
32265
13
512
+ Added@0xsequence/abi@0.0.0-20230301184215(transitive)
+ Added@0xsequence/core@0.0.0-20230301184215(transitive)
- Removed@0xsequence/abi@0.0.0-20230217200148(transitive)
- Removed@0xsequence/core@0.0.0-20230217200148(transitive)