@0xsequence/provider 1.1.0 → 1.1.2
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-provider.cjs.dev.js +38 -17
- package/dist/0xsequence-provider.cjs.prod.js +38 -17
- package/dist/0xsequence-provider.esm.js +38 -17
- package/dist/declarations/src/client.d.ts +5 -5
- package/dist/declarations/src/init.d.ts +1 -1
- package/dist/declarations/src/provider.d.ts +3 -3
- package/dist/declarations/src/signer.d.ts +5 -5
- package/package.json +10 -10
- package/src/client.ts +76 -76
- package/src/extended.ts +3 -4
- package/src/init.ts +30 -27
- package/src/provider.ts +36 -66
- package/src/signer.ts +38 -54
- package/src/transactions.ts +23 -0
- package/src/transports/extension-transport/extension-message-handler.ts +4 -1
- package/src/transports/extension-transport/index.ts +1 -1
- package/src/transports/mux-transport/mux-message-provider.ts +15 -14
- package/src/transports/proxy-transport/proxy-message-channel.ts +0 -1
- package/src/transports/proxy-transport/proxy-message-provider.ts +12 -8
- package/src/transports/unreal-transport/index.ts +1 -1
- package/src/transports/unreal-transport/overridelogs.ts +1 -3
- package/src/transports/wallet-request-handler.ts +67 -40
- package/src/transports/window-transport/window-message-provider.ts +4 -3
- package/src/types.ts +25 -12
- package/src/utils/index.ts +2 -12
- package/src/utils.ts +12 -13
package/src/utils/index.ts
CHANGED
|
@@ -33,12 +33,7 @@ export class WalletUtils {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// Verify signature of a digest, one of a message, typedData or other
|
|
36
|
-
async isValidSignature(
|
|
37
|
-
address: string,
|
|
38
|
-
digest: Uint8Array,
|
|
39
|
-
signature: string,
|
|
40
|
-
chainId: number
|
|
41
|
-
): Promise<boolean> {
|
|
36
|
+
async isValidSignature(address: string, digest: Uint8Array, signature: string, chainId: number): Promise<boolean> {
|
|
42
37
|
return isValidSignature(address, digest, signature, this.signer.getProvider(chainId))
|
|
43
38
|
}
|
|
44
39
|
|
|
@@ -56,12 +51,7 @@ export class WalletUtils {
|
|
|
56
51
|
}
|
|
57
52
|
|
|
58
53
|
// Verify typedData signature
|
|
59
|
-
isValidTypedDataSignature(
|
|
60
|
-
address: string,
|
|
61
|
-
typedData: TypedData,
|
|
62
|
-
signature: string,
|
|
63
|
-
chainId: number
|
|
64
|
-
): Promise<boolean> {
|
|
54
|
+
isValidTypedDataSignature(address: string, typedData: TypedData, signature: string, chainId: number): Promise<boolean> {
|
|
65
55
|
return this.isValidSignature(address, encodeTypedDataDigest(typedData), signature, chainId)
|
|
66
56
|
}
|
|
67
57
|
|
package/src/utils.ts
CHANGED
|
@@ -95,7 +95,6 @@ export const isValidTypedDataSignature = (
|
|
|
95
95
|
return isValidSignature(address, encodeTypedDataDigest(typedData), signature, provider)
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
99
98
|
export const isBrowserExtension = (): boolean =>
|
|
100
99
|
window.location.protocol === 'chrome-extension:' || window.location.protocol === 'moz-extension:'
|
|
101
100
|
|
|
@@ -120,7 +119,7 @@ export interface ItemStore {
|
|
|
120
119
|
}
|
|
121
120
|
|
|
122
121
|
export class MemoryItemStore implements ItemStore {
|
|
123
|
-
private callbacks: { key: string
|
|
122
|
+
private callbacks: { key: string; cb: (value: string | null) => void }[] = []
|
|
124
123
|
private store: Record<string, string> = {}
|
|
125
124
|
|
|
126
125
|
getItem(key: string): string | null {
|
|
@@ -129,7 +128,7 @@ export class MemoryItemStore implements ItemStore {
|
|
|
129
128
|
|
|
130
129
|
setItem(key: string, value: string): void {
|
|
131
130
|
this.store[key] = value
|
|
132
|
-
this.callbacks.filter(
|
|
131
|
+
this.callbacks.filter(c => c.key === key).forEach(c => c.cb(value))
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
removeItem(key: string): void {
|
|
@@ -140,13 +139,13 @@ export class MemoryItemStore implements ItemStore {
|
|
|
140
139
|
this.callbacks.push({ key, cb })
|
|
141
140
|
|
|
142
141
|
return () => {
|
|
143
|
-
this.callbacks = this.callbacks.filter(
|
|
142
|
+
this.callbacks = this.callbacks.filter(c => c.cb !== cb)
|
|
144
143
|
}
|
|
145
144
|
}
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
export class LocalStorage implements ItemStore {
|
|
149
|
-
private callbacks: { key: string
|
|
148
|
+
private callbacks: { key: string; cb: (value: string | null) => void }[] = []
|
|
150
149
|
|
|
151
150
|
static isAvailable(): boolean {
|
|
152
151
|
return typeof window === 'object' && typeof window.localStorage === 'object'
|
|
@@ -157,10 +156,10 @@ export class LocalStorage implements ItemStore {
|
|
|
157
156
|
throw new Error('LocalStorage is not available')
|
|
158
157
|
}
|
|
159
158
|
|
|
160
|
-
window.addEventListener('storage',
|
|
159
|
+
window.addEventListener('storage', e => {
|
|
161
160
|
const { key } = e
|
|
162
|
-
const cb = this.callbacks.filter(
|
|
163
|
-
cb.forEach(
|
|
161
|
+
const cb = this.callbacks.filter(c => c.key === key)
|
|
162
|
+
cb.forEach(c => c.cb(this.getItem(key!)))
|
|
164
163
|
})
|
|
165
164
|
}
|
|
166
165
|
|
|
@@ -173,7 +172,7 @@ export class LocalStorage implements ItemStore {
|
|
|
173
172
|
|
|
174
173
|
// Trigger callbacks
|
|
175
174
|
// NOTICE: the event is not triggered on the same window
|
|
176
|
-
this.callbacks.filter(
|
|
175
|
+
this.callbacks.filter(c => c.key === key).forEach(c => c.cb(value))
|
|
177
176
|
}
|
|
178
177
|
|
|
179
178
|
removeItem(key: string): void {
|
|
@@ -181,14 +180,14 @@ export class LocalStorage implements ItemStore {
|
|
|
181
180
|
|
|
182
181
|
// Trigger callbacks
|
|
183
182
|
// NOTICE: the event is not triggered on the same window
|
|
184
|
-
this.callbacks.filter(
|
|
183
|
+
this.callbacks.filter(c => c.key === key).forEach(c => c.cb(null))
|
|
185
184
|
}
|
|
186
185
|
|
|
187
186
|
onItemChange(key: string, cb: (value: string | null) => void): () => void {
|
|
188
187
|
this.callbacks.push({ key, cb })
|
|
189
188
|
|
|
190
189
|
return () => {
|
|
191
|
-
this.callbacks = this.callbacks.filter(
|
|
190
|
+
this.callbacks = this.callbacks.filter(c => c.cb !== cb)
|
|
192
191
|
}
|
|
193
192
|
}
|
|
194
193
|
}
|
|
@@ -202,11 +201,11 @@ export function useBestStore(): ItemStore {
|
|
|
202
201
|
}
|
|
203
202
|
|
|
204
203
|
export async function resolveArrayProperties<T>(
|
|
205
|
-
object: Readonly<ethers.utils.Deferrable<T>> |
|
|
204
|
+
object: Readonly<ethers.utils.Deferrable<T>> | Readonly<ethers.utils.Deferrable<T>>[]
|
|
206
205
|
): Promise<T> {
|
|
207
206
|
if (Array.isArray(object)) {
|
|
208
207
|
// T must include array type
|
|
209
|
-
return Promise.all(object.map(
|
|
208
|
+
return Promise.all(object.map(o => ethers.utils.resolveProperties(o))) as any
|
|
210
209
|
}
|
|
211
210
|
|
|
212
211
|
return ethers.utils.resolveProperties(object)
|