@0xsequence/replacer 0.0.0-20240408185635 → 0.0.0-20240428001038
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/0xsequence-replacer.cjs.dev.js +3 -5
- package/dist/0xsequence-replacer.cjs.prod.js +3 -5
- package/dist/0xsequence-replacer.esm.js +3 -5
- package/dist/declarations/src/cached.d.ts +2 -2
- package/dist/declarations/src/index.d.ts +4 -4
- package/package.json +4 -4
- package/src/cached.ts +1 -1
- package/src/index.ts +8 -9
|
@@ -61,7 +61,7 @@ function eip1271Contract(address, provider) {
|
|
|
61
61
|
async function isValidSignature(address, provider, digest, signature) {
|
|
62
62
|
// First we try to validate the signature using Ethers
|
|
63
63
|
try {
|
|
64
|
-
const addr = ethers.ethers.recoverAddress(digest,
|
|
64
|
+
const addr = ethers.ethers.utils.recoverAddress(digest, signature);
|
|
65
65
|
if (addr.toLowerCase() === address.toLowerCase()) return true;
|
|
66
66
|
} catch (_unused) {}
|
|
67
67
|
|
|
@@ -95,11 +95,9 @@ async function runByEIP5719(address, provider, digest, signature, solver, tries
|
|
|
95
95
|
} catch (_unused4) {}
|
|
96
96
|
const altUri = await tryAwait(eip5719Contract(address, provider).getAlternativeSignature(digest));
|
|
97
97
|
if (!altUri || altUri === '') throw new Error('EIP5719 - Invalid signature and no alternative signature');
|
|
98
|
-
const altSignature = ethers.ethers.hexlify(await (solver || new URISolverIPFS()).resolve(altUri));
|
|
98
|
+
const altSignature = ethers.ethers.utils.hexlify(await (solver || new URISolverIPFS()).resolve(altUri));
|
|
99
99
|
if (!altSignature || altSignature === '') throw new Error('EIP5719 - Empty alternative signature');
|
|
100
|
-
if (altSignature === ethers.ethers.hexlify(signature))
|
|
101
|
-
throw new Error('EIP5719 - Alternative signature is invalid or the same');
|
|
102
|
-
}
|
|
100
|
+
if (altSignature === ethers.ethers.utils.hexlify(signature)) throw new Error('EIP5719 - Alternative signature is invalid or the same');
|
|
103
101
|
return runByEIP5719(address, provider, digest, altSignature, solver, tries + 1);
|
|
104
102
|
}
|
|
105
103
|
class URISolverIPFS {
|
|
@@ -61,7 +61,7 @@ function eip1271Contract(address, provider) {
|
|
|
61
61
|
async function isValidSignature(address, provider, digest, signature) {
|
|
62
62
|
// First we try to validate the signature using Ethers
|
|
63
63
|
try {
|
|
64
|
-
const addr = ethers.ethers.recoverAddress(digest,
|
|
64
|
+
const addr = ethers.ethers.utils.recoverAddress(digest, signature);
|
|
65
65
|
if (addr.toLowerCase() === address.toLowerCase()) return true;
|
|
66
66
|
} catch (_unused) {}
|
|
67
67
|
|
|
@@ -95,11 +95,9 @@ async function runByEIP5719(address, provider, digest, signature, solver, tries
|
|
|
95
95
|
} catch (_unused4) {}
|
|
96
96
|
const altUri = await tryAwait(eip5719Contract(address, provider).getAlternativeSignature(digest));
|
|
97
97
|
if (!altUri || altUri === '') throw new Error('EIP5719 - Invalid signature and no alternative signature');
|
|
98
|
-
const altSignature = ethers.ethers.hexlify(await (solver || new URISolverIPFS()).resolve(altUri));
|
|
98
|
+
const altSignature = ethers.ethers.utils.hexlify(await (solver || new URISolverIPFS()).resolve(altUri));
|
|
99
99
|
if (!altSignature || altSignature === '') throw new Error('EIP5719 - Empty alternative signature');
|
|
100
|
-
if (altSignature === ethers.ethers.hexlify(signature))
|
|
101
|
-
throw new Error('EIP5719 - Alternative signature is invalid or the same');
|
|
102
|
-
}
|
|
100
|
+
if (altSignature === ethers.ethers.utils.hexlify(signature)) throw new Error('EIP5719 - Alternative signature is invalid or the same');
|
|
103
101
|
return runByEIP5719(address, provider, digest, altSignature, solver, tries + 1);
|
|
104
102
|
}
|
|
105
103
|
class URISolverIPFS {
|
|
@@ -57,7 +57,7 @@ function eip1271Contract(address, provider) {
|
|
|
57
57
|
async function isValidSignature(address, provider, digest, signature) {
|
|
58
58
|
// First we try to validate the signature using Ethers
|
|
59
59
|
try {
|
|
60
|
-
const addr = ethers.recoverAddress(digest,
|
|
60
|
+
const addr = ethers.utils.recoverAddress(digest, signature);
|
|
61
61
|
if (addr.toLowerCase() === address.toLowerCase()) return true;
|
|
62
62
|
} catch (_unused) {}
|
|
63
63
|
|
|
@@ -91,11 +91,9 @@ async function runByEIP5719(address, provider, digest, signature, solver, tries
|
|
|
91
91
|
} catch (_unused4) {}
|
|
92
92
|
const altUri = await tryAwait(eip5719Contract(address, provider).getAlternativeSignature(digest));
|
|
93
93
|
if (!altUri || altUri === '') throw new Error('EIP5719 - Invalid signature and no alternative signature');
|
|
94
|
-
const altSignature = ethers.hexlify(await (solver || new URISolverIPFS()).resolve(altUri));
|
|
94
|
+
const altSignature = ethers.utils.hexlify(await (solver || new URISolverIPFS()).resolve(altUri));
|
|
95
95
|
if (!altSignature || altSignature === '') throw new Error('EIP5719 - Empty alternative signature');
|
|
96
|
-
if (altSignature === ethers.hexlify(signature))
|
|
97
|
-
throw new Error('EIP5719 - Alternative signature is invalid or the same');
|
|
98
|
-
}
|
|
96
|
+
if (altSignature === ethers.utils.hexlify(signature)) throw new Error('EIP5719 - Alternative signature is invalid or the same');
|
|
99
97
|
return runByEIP5719(address, provider, digest, altSignature, solver, tries + 1);
|
|
100
98
|
}
|
|
101
99
|
class URISolverIPFS {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { URISolver } from "./index.js";
|
|
3
3
|
export declare class CachedEIP5719 {
|
|
4
|
-
provider: ethers.Provider;
|
|
4
|
+
provider: ethers.providers.Provider;
|
|
5
5
|
solver?: URISolver | undefined;
|
|
6
6
|
window: number;
|
|
7
|
-
constructor(provider: ethers.Provider, solver?: URISolver | undefined, window?: number);
|
|
7
|
+
constructor(provider: ethers.providers.Provider, solver?: URISolver | undefined, window?: number);
|
|
8
8
|
private pending;
|
|
9
9
|
runByEIP5719(address: string, digest: ethers.BytesLike, signature: ethers.BytesLike): Promise<ethers.BytesLike>;
|
|
10
10
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
export * from "./cached.js";
|
|
3
|
-
export declare function eip5719Contract(address: string, provider: ethers.Provider): ethers.Contract;
|
|
4
|
-
export declare function eip1271Contract(address: string, provider: ethers.Provider): ethers.Contract;
|
|
5
|
-
export declare function isValidSignature(address: string, provider: ethers.Provider, digest: ethers.BytesLike, signature: ethers.BytesLike): Promise<boolean>;
|
|
3
|
+
export declare function eip5719Contract(address: string, provider: ethers.providers.Provider): ethers.Contract;
|
|
4
|
+
export declare function eip1271Contract(address: string, provider: ethers.providers.Provider): ethers.Contract;
|
|
5
|
+
export declare function isValidSignature(address: string, provider: ethers.providers.Provider, digest: ethers.BytesLike, signature: ethers.BytesLike): Promise<boolean>;
|
|
6
6
|
export interface URISolver {
|
|
7
7
|
resolve: (uri: string) => Promise<string>;
|
|
8
8
|
}
|
|
9
|
-
export declare function runByEIP5719(address: string, provider: ethers.Provider, digest: ethers.BytesLike, signature: ethers.BytesLike, solver?: URISolver, tries?: number): Promise<ethers.BytesLike>;
|
|
9
|
+
export declare function runByEIP5719(address: string, provider: ethers.providers.Provider, digest: ethers.BytesLike, signature: ethers.BytesLike, solver?: URISolver, tries?: number): Promise<ethers.BytesLike>;
|
|
10
10
|
export declare class URISolverIPFS implements URISolver {
|
|
11
11
|
gateway: string;
|
|
12
12
|
constructor(gateway?: string);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/replacer",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20240428001038",
|
|
4
4
|
"description": "EIP-5719 client implementation",
|
|
5
5
|
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/replacer",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"author": "Horizon Blockchain Games",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@0xsequence/abi": "0.0.0-
|
|
13
|
-
"@0xsequence/core": "0.0.0-
|
|
12
|
+
"@0xsequence/abi": "0.0.0-20240428001038",
|
|
13
|
+
"@0xsequence/core": "0.0.0-20240428001038"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"ethers": "
|
|
16
|
+
"ethers": ">=5.5"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {},
|
|
19
19
|
"files": [
|
package/src/cached.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { commons } from '@0xsequence/core'
|
|
|
5
5
|
|
|
6
6
|
export * from './cached'
|
|
7
7
|
|
|
8
|
-
export function eip5719Contract(address: string, provider: ethers.Provider): ethers.Contract {
|
|
8
|
+
export function eip5719Contract(address: string, provider: ethers.providers.Provider): ethers.Contract {
|
|
9
9
|
// TODO: for some reason walletContracts is not being loaded from local
|
|
10
10
|
// remove this code once fixed
|
|
11
11
|
const abi = [
|
|
@@ -31,19 +31,19 @@ export function eip5719Contract(address: string, provider: ethers.Provider): eth
|
|
|
31
31
|
return new ethers.Contract(address, abi, provider)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export function eip1271Contract(address: string, provider: ethers.Provider): ethers.Contract {
|
|
34
|
+
export function eip1271Contract(address: string, provider: ethers.providers.Provider): ethers.Contract {
|
|
35
35
|
return new ethers.Contract(address, walletContracts.erc1271.abi, provider)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export async function isValidSignature(
|
|
39
39
|
address: string,
|
|
40
|
-
provider: ethers.Provider,
|
|
40
|
+
provider: ethers.providers.Provider,
|
|
41
41
|
digest: ethers.BytesLike,
|
|
42
42
|
signature: ethers.BytesLike
|
|
43
43
|
): Promise<boolean> {
|
|
44
44
|
// First we try to validate the signature using Ethers
|
|
45
45
|
try {
|
|
46
|
-
const addr = ethers.recoverAddress(digest,
|
|
46
|
+
const addr = ethers.utils.recoverAddress(digest, signature)
|
|
47
47
|
if (addr.toLowerCase() === address.toLowerCase()) return true
|
|
48
48
|
} catch {}
|
|
49
49
|
|
|
@@ -72,7 +72,7 @@ async function tryAwait<T>(promise: Promise<T>): Promise<T | undefined> {
|
|
|
72
72
|
|
|
73
73
|
export async function runByEIP5719(
|
|
74
74
|
address: string,
|
|
75
|
-
provider: ethers.Provider,
|
|
75
|
+
provider: ethers.providers.Provider,
|
|
76
76
|
digest: ethers.BytesLike,
|
|
77
77
|
signature: ethers.BytesLike,
|
|
78
78
|
solver?: URISolver,
|
|
@@ -94,11 +94,10 @@ export async function runByEIP5719(
|
|
|
94
94
|
const altUri = await tryAwait(eip5719Contract(address, provider).getAlternativeSignature(digest) as Promise<string>)
|
|
95
95
|
if (!altUri || altUri === '') throw new Error('EIP5719 - Invalid signature and no alternative signature')
|
|
96
96
|
|
|
97
|
-
const altSignature = ethers.hexlify(await (solver || new URISolverIPFS()).resolve(altUri))
|
|
97
|
+
const altSignature = ethers.utils.hexlify(await (solver || new URISolverIPFS()).resolve(altUri))
|
|
98
98
|
if (!altSignature || altSignature === '') throw new Error('EIP5719 - Empty alternative signature')
|
|
99
|
-
if (altSignature === ethers.hexlify(signature))
|
|
100
|
-
|
|
101
|
-
}
|
|
99
|
+
if (altSignature === ethers.utils.hexlify(signature)) throw new Error('EIP5719 - Alternative signature is invalid or the same')
|
|
100
|
+
|
|
102
101
|
return runByEIP5719(address, provider, digest, altSignature, solver, tries + 1)
|
|
103
102
|
}
|
|
104
103
|
|