@xyo-network/core 2.73.4 → 2.74.1
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/Data/AbstractData.d.mts +12 -0
- package/dist/Data/AbstractData.d.mts.map +1 -0
- package/dist/Data/AbstractData.d.ts +12 -0
- package/dist/Data/AbstractData.d.ts.map +1 -0
- package/dist/Data/Data.d.mts +20 -0
- package/dist/Data/Data.d.mts.map +1 -0
- package/dist/Data/Data.d.ts +20 -0
- package/dist/Data/Data.d.ts.map +1 -0
- package/dist/Data/DataLike.d.mts +4 -0
- package/dist/Data/DataLike.d.mts.map +1 -0
- package/dist/Data/DataLike.d.ts +4 -0
- package/dist/Data/DataLike.d.ts.map +1 -0
- package/dist/Data/index.d.mts +5 -0
- package/dist/Data/index.d.mts.map +1 -0
- package/dist/Data/index.d.ts +5 -0
- package/dist/Data/index.d.ts.map +1 -0
- package/dist/Data/toUint8Array.d.mts +4 -0
- package/dist/Data/toUint8Array.d.mts.map +1 -0
- package/dist/Data/toUint8Array.d.ts +4 -0
- package/dist/Data/toUint8Array.d.ts.map +1 -0
- package/dist/docs.json +3241 -4204
- package/dist/index.d.mts +7 -210
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +7 -210
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -321
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -323
- package/dist/index.mjs.map +1 -1
- package/dist/lib/Base.d.mts +13 -0
- package/dist/lib/Base.d.mts.map +1 -0
- package/dist/lib/Base.d.ts +13 -0
- package/dist/lib/Base.d.ts.map +1 -0
- package/dist/lib/Validator.d.mts +9 -0
- package/dist/lib/Validator.d.mts.map +1 -0
- package/dist/lib/Validator.d.ts +9 -0
- package/dist/lib/Validator.d.ts.map +1 -0
- package/dist/lib/dumpErrors.d.mts +3 -0
- package/dist/lib/dumpErrors.d.mts.map +1 -0
- package/dist/lib/dumpErrors.d.ts +3 -0
- package/dist/lib/dumpErrors.d.ts.map +1 -0
- package/dist/lib/index.d.mts +6 -0
- package/dist/lib/index.d.mts.map +1 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/isBrowser.d.mts +2 -0
- package/dist/lib/isBrowser.d.mts.map +1 -0
- package/dist/lib/isBrowser.d.ts +2 -0
- package/dist/lib/isBrowser.d.ts.map +1 -0
- package/dist/lib/uuid.d.mts +2 -0
- package/dist/lib/uuid.d.mts.map +1 -0
- package/dist/lib/uuid.d.ts +2 -0
- package/dist/lib/uuid.d.ts.map +1 -0
- package/package.json +15 -24
- package/src/index.ts +4 -2
- package/src/lib/Base.ts +2 -3
- package/src/lib/Validator.ts +1 -3
- package/src/lib/index.ts +0 -5
- package/src/Hasher/Hasher.ts +0 -96
- package/src/Hasher/index.ts +0 -4
- package/src/Hasher/removeEmptyFields.ts +0 -15
- package/src/Hasher/removeFields.ts +0 -32
- package/src/Hasher/sortFields.ts +0 -29
- package/src/Wasm/WasmSupport.ts +0 -168
- package/src/Wasm/index.ts +0 -1
- package/src/lib/Address/index.ts +0 -2
- package/src/lib/Address/normalizeAddress.ts +0 -5
- package/src/lib/Address/trimAddressPrefix.ts +0 -10
- package/src/lib/AnyObject.ts +0 -2
- package/src/lib/EmptyObject.ts +0 -1
- package/src/lib/ObjectWrapper.ts +0 -12
- package/src/lib/StringKeyObject.ts +0 -4
- package/tsup.config.ts +0 -16
package/src/index.ts
CHANGED
package/src/lib/Base.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Logger } from '@xyo-network/logger'
|
|
2
|
-
|
|
3
|
-
import { AnyObject } from './AnyObject'
|
|
2
|
+
import { AnyObject } from '@xyo-network/object'
|
|
4
3
|
|
|
5
4
|
export type BaseParamsFields = {
|
|
6
5
|
logger?: Logger
|
|
7
6
|
}
|
|
8
7
|
|
|
9
|
-
export type BaseParams<TAdditionalParams extends AnyObject |
|
|
8
|
+
export type BaseParams<TAdditionalParams extends AnyObject | void = void> = TAdditionalParams extends AnyObject
|
|
10
9
|
? BaseParamsFields & TAdditionalParams
|
|
11
10
|
: BaseParamsFields
|
|
12
11
|
|
package/src/lib/Validator.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import { AnyObject, ObjectWrapper } from '@xyo-network/object'
|
|
1
2
|
import { Promisable } from '@xyo-network/promise'
|
|
2
3
|
|
|
3
|
-
import { AnyObject } from './AnyObject'
|
|
4
|
-
import { ObjectWrapper } from './ObjectWrapper'
|
|
5
|
-
|
|
6
4
|
export interface Validator<T extends AnyObject = AnyObject> {
|
|
7
5
|
validate(payload: T): Promisable<Error[]>
|
|
8
6
|
}
|
package/src/lib/index.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
export * from './Address'
|
|
2
|
-
export * from './AnyObject'
|
|
3
1
|
export * from './Base'
|
|
4
2
|
export * from './dumpErrors'
|
|
5
|
-
export * from './EmptyObject'
|
|
6
3
|
export * from './isBrowser'
|
|
7
|
-
export * from './ObjectWrapper'
|
|
8
|
-
export * from './StringKeyObject'
|
|
9
4
|
export * from './uuid'
|
|
10
5
|
export * from './Validator'
|
package/src/Hasher/Hasher.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { cloneDeep } from '@xylabs/lodash'
|
|
2
|
-
import { sha256 } from 'hash-wasm'
|
|
3
|
-
import shajs from 'sha.js'
|
|
4
|
-
|
|
5
|
-
import { AnyObject, ObjectWrapper } from '../lib'
|
|
6
|
-
import { WasmSupport } from '../Wasm'
|
|
7
|
-
import { removeEmptyFields } from './removeEmptyFields'
|
|
8
|
-
import { deepOmitUnderscoreFields } from './removeFields'
|
|
9
|
-
import { sortFields } from './sortFields'
|
|
10
|
-
|
|
11
|
-
const wasmSupportStatic = new WasmSupport(['bigInt'])
|
|
12
|
-
|
|
13
|
-
export class PayloadHasher<T extends AnyObject = AnyObject> extends ObjectWrapper<T> {
|
|
14
|
-
static readonly wasmInitialized = wasmSupportStatic.initialize()
|
|
15
|
-
static readonly wasmSupport = wasmSupportStatic
|
|
16
|
-
|
|
17
|
-
/** @deprecated use hashAsync instead */
|
|
18
|
-
get hash() {
|
|
19
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
20
|
-
return PayloadHasher.hash(this.obj)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get hashFields() {
|
|
24
|
-
return PayloadHasher.hashFields(this.obj)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get stringified() {
|
|
28
|
-
return PayloadHasher.stringify(this.obj)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static async filterExclude<T extends AnyObject>(objs: T[] = [], hash: string[] | string): Promise<T[]> {
|
|
32
|
-
const hashes = Array.isArray(hash) ? hash : [hash]
|
|
33
|
-
return (await this.hashPairs(objs)).filter(([_, objHash]) => !hashes.includes(objHash))?.map((pair) => pair[0])
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static async filterInclude<T extends AnyObject>(objs: T[] = [], hash: string[] | string): Promise<T[]> {
|
|
37
|
-
const hashes = Array.isArray(hash) ? hash : [hash]
|
|
38
|
-
return (await this.hashPairs(objs)).filter(([_, objHash]) => hashes.includes(objHash))?.map((pair) => pair[0])
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static async find<T extends AnyObject>(objs: T[] = [], hash: string): Promise<T | undefined> {
|
|
42
|
-
return (await this.hashPairs(objs)).find(([_, objHash]) => objHash === hash)?.[0]
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** @deprecated use hashSync or hashAsync instead */
|
|
46
|
-
static hash<T extends AnyObject>(obj: T) {
|
|
47
|
-
return shajs('sha256').update(this.stringify(obj)).digest().toString('hex')
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
static async hashAsync<T extends AnyObject>(obj: T): Promise<string> {
|
|
51
|
-
await PayloadHasher.wasmInitialized
|
|
52
|
-
if (PayloadHasher.wasmSupport.canUseWasm) {
|
|
53
|
-
const stringToHash = PayloadHasher.stringify(obj)
|
|
54
|
-
try {
|
|
55
|
-
return await sha256(stringToHash)
|
|
56
|
-
} catch (ex) {
|
|
57
|
-
PayloadHasher.wasmSupport.allowWasm = false
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
61
|
-
return this.hash(obj)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
static hashFields<T extends AnyObject>(obj: T) {
|
|
65
|
-
return removeEmptyFields(deepOmitUnderscoreFields(cloneDeep(obj)))
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
static async hashPairs<T extends AnyObject>(objs: T[]): Promise<[T, string][]> {
|
|
69
|
-
return await Promise.all(objs.map<Promise<[T, string]>>(async (obj) => [obj, await PayloadHasher.hashAsync(obj)]))
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
static hashSync<T extends AnyObject>(obj: T) {
|
|
73
|
-
return shajs('sha256').update(this.stringify(obj)).digest().toString('hex')
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static async hashes<T extends AnyObject>(objs: T[]) {
|
|
77
|
-
return await Promise.all(objs.map((obj) => this.hashAsync(obj)))
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
static stringify<T extends AnyObject>(obj: T) {
|
|
81
|
-
return JSON.stringify(sortFields(this.hashFields(obj)))
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
static async toMap<T extends AnyObject>(objs: T[]): Promise<Record<string, T>> {
|
|
85
|
-
const result: Record<string, T> = {}
|
|
86
|
-
await Promise.all(objs.map(async (obj) => (result[await PayloadHasher.hashAsync(obj)] = obj)))
|
|
87
|
-
return result
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async hashAsync() {
|
|
91
|
-
return await PayloadHasher.hashAsync(this.obj)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** @deprecated use PayloadHasher instead */
|
|
96
|
-
export class Hasher<T extends AnyObject = AnyObject> extends PayloadHasher<T> {}
|
package/src/Hasher/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { typeOf } from '@xyo-network/typeof'
|
|
2
|
-
|
|
3
|
-
export const removeEmptyFields = <T extends Record<string, unknown>>(obj: T) => {
|
|
4
|
-
if (obj === null || Array.isArray(obj)) return obj
|
|
5
|
-
|
|
6
|
-
const newObject: Record<string, unknown> = {}
|
|
7
|
-
Object.entries(obj).forEach(([key, value]) => {
|
|
8
|
-
if (typeOf(value) === 'object') {
|
|
9
|
-
newObject[key] = removeEmptyFields(value as Record<string, unknown>)
|
|
10
|
-
} else if (value !== undefined) {
|
|
11
|
-
newObject[key] = value
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
return newObject as T
|
|
15
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { isObject, mapValues, merge, omitBy, pickBy } from '@xylabs/lodash'
|
|
2
|
-
// eslint-disable-next-line no-restricted-imports
|
|
3
|
-
import type { ValueKeyIteratee } from 'lodash'
|
|
4
|
-
|
|
5
|
-
import { AnyObject } from '../lib'
|
|
6
|
-
|
|
7
|
-
export const deepBy = <T extends AnyObject>(obj: T, predicate: ValueKeyIteratee<T>, func: typeof omitBy | typeof pickBy): T => {
|
|
8
|
-
if (Array.isArray(obj)) {
|
|
9
|
-
return obj
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
//pick the child objects
|
|
13
|
-
const onlyObjects = pickBy<T>(obj, isObject)
|
|
14
|
-
|
|
15
|
-
//pick the child non-objects
|
|
16
|
-
const nonObjects = pickBy<T>(obj, (value) => !isObject(value))
|
|
17
|
-
|
|
18
|
-
const pickedObjects = omitBy(onlyObjects, predicate)
|
|
19
|
-
const pickedNonObjects = omitBy(nonObjects, predicate)
|
|
20
|
-
|
|
21
|
-
const processedObjects = mapValues(pickedObjects, (obj: T) => deepBy(obj, predicate, func))
|
|
22
|
-
|
|
23
|
-
return merge({}, pickedNonObjects, processedObjects) as T
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const deepOmitUnderscoreFields = <T extends AnyObject>(obj: T) => {
|
|
27
|
-
return deepBy(obj, (_, key) => key.startsWith('_'), omitBy)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const deepPickUnderscoreFields = <T extends AnyObject>(obj: T) => {
|
|
31
|
-
return deepBy(obj, (_, key) => key.startsWith('_'), pickBy)
|
|
32
|
-
}
|
package/src/Hasher/sortFields.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { typeOf } from '@xyo-network/typeof'
|
|
2
|
-
|
|
3
|
-
import { AnyObject, StringKeyObject } from '../lib'
|
|
4
|
-
|
|
5
|
-
//if an object, sub-sort
|
|
6
|
-
const subSort = (value: unknown) => {
|
|
7
|
-
switch (typeOf(value)) {
|
|
8
|
-
case 'object':
|
|
9
|
-
return sortFields(value as Record<string, unknown>)
|
|
10
|
-
default:
|
|
11
|
-
return value
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const sortFields = <T extends AnyObject = AnyObject>(obj: T) => {
|
|
16
|
-
if (obj === null) {
|
|
17
|
-
return null
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const stringyObj = obj as StringKeyObject
|
|
21
|
-
|
|
22
|
-
const result: StringKeyObject = {}
|
|
23
|
-
Object.keys(stringyObj)
|
|
24
|
-
.sort()
|
|
25
|
-
.forEach((key) => {
|
|
26
|
-
result[key] = subSort(stringyObj[key])
|
|
27
|
-
})
|
|
28
|
-
return result as T
|
|
29
|
-
}
|
package/src/Wasm/WasmSupport.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
bigInt,
|
|
3
|
-
bulkMemory,
|
|
4
|
-
exceptions,
|
|
5
|
-
extendedConst,
|
|
6
|
-
gc,
|
|
7
|
-
memory64,
|
|
8
|
-
multiValue,
|
|
9
|
-
mutableGlobals,
|
|
10
|
-
referenceTypes,
|
|
11
|
-
relaxedSimd,
|
|
12
|
-
saturatedFloatToInt,
|
|
13
|
-
signExtensions,
|
|
14
|
-
simd,
|
|
15
|
-
streamingCompilation,
|
|
16
|
-
tailCall,
|
|
17
|
-
threads,
|
|
18
|
-
} from 'wasm-feature-detect'
|
|
19
|
-
|
|
20
|
-
export const WasmFeatureDetectors = {
|
|
21
|
-
bigInt: bigInt,
|
|
22
|
-
bulkMemory: bulkMemory,
|
|
23
|
-
exceptions: exceptions,
|
|
24
|
-
extendedConst: extendedConst,
|
|
25
|
-
gc: gc,
|
|
26
|
-
memory64: memory64,
|
|
27
|
-
multiValue: multiValue,
|
|
28
|
-
mutableGlobals: mutableGlobals,
|
|
29
|
-
referenceTypes: referenceTypes,
|
|
30
|
-
relaxedSimd: relaxedSimd,
|
|
31
|
-
saturatedFloatToInt: saturatedFloatToInt,
|
|
32
|
-
signExtensions: signExtensions,
|
|
33
|
-
simd: simd,
|
|
34
|
-
streamingCompilation: streamingCompilation,
|
|
35
|
-
tailCall: tailCall,
|
|
36
|
-
threads: threads,
|
|
37
|
-
} as const
|
|
38
|
-
|
|
39
|
-
export type WasmFeature = keyof typeof WasmFeatureDetectors
|
|
40
|
-
|
|
41
|
-
export class WasmSupport {
|
|
42
|
-
private _allowWasm = true
|
|
43
|
-
private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}
|
|
44
|
-
private _forceWasm = false
|
|
45
|
-
private _isInitialized = false
|
|
46
|
-
private _isWasmFeatureSetSupported = false
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Instance constructor for use where async instantiation
|
|
50
|
-
* is not possible. Where possible, prefer the static
|
|
51
|
-
* create method over use of this constructor directly
|
|
52
|
-
* as no initialization (feature detection) is able to
|
|
53
|
-
* be done here
|
|
54
|
-
* @param desiredFeatures The desired feature set
|
|
55
|
-
*/
|
|
56
|
-
constructor(protected desiredFeatures: WasmFeature[]) {}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Is Wasm allowed
|
|
60
|
-
*/
|
|
61
|
-
get allowWasm(): boolean {
|
|
62
|
-
return this._allowWasm
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Whether or not to allow WASM usage
|
|
66
|
-
*/
|
|
67
|
-
set allowWasm(v: boolean) {
|
|
68
|
-
this._allowWasm = v
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Whether or not Wasm should be used based on the desired
|
|
73
|
-
* feature set, initialization state, or force-use settings
|
|
74
|
-
*/
|
|
75
|
-
get canUseWasm(): boolean {
|
|
76
|
-
return (
|
|
77
|
-
// Just force WASM
|
|
78
|
-
this._forceWasm ||
|
|
79
|
-
// Or if we haven't checked be optimistic
|
|
80
|
-
(this._allowWasm && !this._isInitialized) ||
|
|
81
|
-
// Or if we have checked and WASM is not supported, be realistic
|
|
82
|
-
(this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Returns a object containing a property for each desired wasm feature
|
|
88
|
-
* with a boolean value indicating whether or not the feature is supported
|
|
89
|
-
*/
|
|
90
|
-
get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {
|
|
91
|
-
return { ...this._featureSupport }
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Force use of Wasm
|
|
96
|
-
*/
|
|
97
|
-
get forceWasm(): boolean {
|
|
98
|
-
return this._forceWasm
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Whether or not to force Wasm usage
|
|
102
|
-
*/
|
|
103
|
-
set forceWasm(v: boolean) {
|
|
104
|
-
this._forceWasm = v
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Whether or not Wasm is supported based
|
|
109
|
-
* on the desired feature set
|
|
110
|
-
*/
|
|
111
|
-
get isDesiredFeatureSetSupported(): boolean {
|
|
112
|
-
return this._isWasmFeatureSetSupported
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Whether or not Wasm detection has been run
|
|
117
|
-
* for the desired feature set
|
|
118
|
-
*/
|
|
119
|
-
get isInitialized(): boolean {
|
|
120
|
-
return this._isInitialized
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Static creation & async initialization for use where
|
|
125
|
-
* async instantiation is possible
|
|
126
|
-
* @param desiredFeatures The desired feature set
|
|
127
|
-
* @returns An initialized instance of the class with detection
|
|
128
|
-
* for the desired feature set
|
|
129
|
-
*/
|
|
130
|
-
static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {
|
|
131
|
-
const instance = new WasmSupport(desiredFeatures)
|
|
132
|
-
await instance.initialize()
|
|
133
|
-
return Promise.resolve(instance)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Checks for specific wasm features
|
|
138
|
-
* @param features The list of features to check for
|
|
139
|
-
* @returns True if all the features are supported, false otherwise
|
|
140
|
-
*/
|
|
141
|
-
async featureCheck(features: WasmFeature[]): Promise<boolean> {
|
|
142
|
-
const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()))
|
|
143
|
-
return results.every((result) => result)
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Does feature detection for the desired feature set
|
|
148
|
-
*/
|
|
149
|
-
async initialize(): Promise<void> {
|
|
150
|
-
if (this._isInitialized) return
|
|
151
|
-
await this.detectDesiredFeatures()
|
|
152
|
-
this._isInitialized = true
|
|
153
|
-
return
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
protected async detectDesiredFeatures(): Promise<void> {
|
|
157
|
-
for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
|
|
158
|
-
const desiredFeature = this.desiredFeatures[feature]
|
|
159
|
-
const detector = WasmFeatureDetectors[desiredFeature]
|
|
160
|
-
if (!(await detector())) {
|
|
161
|
-
this._featureSupport[desiredFeature] = false
|
|
162
|
-
} else {
|
|
163
|
-
this._featureSupport[desiredFeature] = true
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every((v) => v)
|
|
167
|
-
}
|
|
168
|
-
}
|
package/src/Wasm/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './WasmSupport'
|
package/src/lib/Address/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const addressPrefix = '0x'
|
|
2
|
-
|
|
3
|
-
// NOTE: To prevent calling `.length` on every invocation, we cache the length
|
|
4
|
-
// but do want to tether it to the length of the actual prefix so it's not some
|
|
5
|
-
// magic number.
|
|
6
|
-
const addressPrefixLength = addressPrefix.length
|
|
7
|
-
|
|
8
|
-
export const trimAddressPrefix = (address: string) => {
|
|
9
|
-
return address.toLowerCase().startsWith(addressPrefix) ? address.substring(addressPrefixLength) : address
|
|
10
|
-
}
|
package/src/lib/AnyObject.ts
DELETED
package/src/lib/EmptyObject.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type EmptyObject = { [key: string]: never }
|
package/src/lib/ObjectWrapper.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EmptyObject } from './EmptyObject'
|
|
2
|
-
import { StringKeyObject } from './StringKeyObject'
|
|
3
|
-
|
|
4
|
-
export abstract class ObjectWrapper<T extends EmptyObject = EmptyObject> {
|
|
5
|
-
readonly obj: T
|
|
6
|
-
constructor(obj: T) {
|
|
7
|
-
this.obj = obj
|
|
8
|
-
}
|
|
9
|
-
protected get stringKeyObj() {
|
|
10
|
-
return this.obj as StringKeyObject
|
|
11
|
-
}
|
|
12
|
-
}
|
package/tsup.config.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup'
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line import/no-default-export
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
bundle: true,
|
|
6
|
-
cjsInterop: true,
|
|
7
|
-
clean: false,
|
|
8
|
-
dts: {
|
|
9
|
-
entry: ['src/index.ts'],
|
|
10
|
-
},
|
|
11
|
-
entry: ['src/index.ts'],
|
|
12
|
-
format: ['cjs', 'esm'],
|
|
13
|
-
sourcemap: true,
|
|
14
|
-
splitting: false,
|
|
15
|
-
tsconfig: 'tsconfig.json',
|
|
16
|
-
})
|