@xyo-network/xl1-protocol-sdk 1.16.13 → 1.16.15
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/README.md +18090 -1833
- package/dist/neutral/config/Config.d.ts +2 -2
- package/dist/neutral/config/Log.d.ts +1 -1
- package/dist/neutral/index.mjs +397 -395
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/model/ChainContext/ChainContext.d.ts +4 -2
- package/dist/neutral/model/ChainContext/ChainContext.d.ts.map +1 -1
- package/dist/neutral/provider/XyoClient.d.ts +1 -3
- package/dist/neutral/provider/XyoClient.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/model/ChainContext/ChainContext.ts +9 -3
- package/src/primitives/timeBudget.ts +1 -1
- package/src/provider/XyoClient.ts +2 -2
|
@@ -9,9 +9,11 @@ export interface BaseContext<TCacheValue = string | object | number | bigint> {
|
|
|
9
9
|
logger?: Logger;
|
|
10
10
|
}
|
|
11
11
|
export declare function contextCache<TCacheValue>(context: BaseContext<TCacheValue | unknown>, name: string, create?: () => MapType<string, TCacheValue>): MapType<string, TCacheValue>;
|
|
12
|
-
export
|
|
12
|
+
export interface withContextCacheResponseOptions {
|
|
13
13
|
max?: number;
|
|
14
|
-
|
|
14
|
+
timeBudgetMs?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function withContextCacheResponse<T extends {} | string | number | bigint>(context: BaseContext, name: string, key: string, func: () => Promise<T extends {} | string | number | bigint ? T : never>, { max, timeBudgetMs }?: withContextCacheResponseOptions): Promise<T>;
|
|
15
17
|
export interface ChainContextWrite extends BaseContext, ChainIdentity, ChainStateContextWrite, ChainStoreContextWrite {
|
|
16
18
|
}
|
|
17
19
|
export interface StakedChainContextWrite extends BaseContext, ChainContextWrite, ChainStakeContextWrite {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChainContext.d.ts","sourceRoot":"","sources":["../../../../src/model/ChainContext/ChainContext.ts"],"names":[],"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AS,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EACpF,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,SAAS,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,EACxE,EAAE,GAAY,EAAE,YAAgB,EAAE,GAAE,+BAAoC,GACvE,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED,MAAM,WAAW,iBAAkB,SAAQ,WAAW,EAAE,aAAa,EAAE,sBAAsB,EAAE,sBAAsB;CAAG;AAExH,MAAM,WAAW,uBAAwB,SAAQ,WAAW,EAAE,iBAAiB,EAAE,sBAAsB;CAAG;AAE1G,MAAM,WAAW,gBAAiB,SAAQ,WAAW,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB;CAAG;AAErH,MAAM,WAAW,sBAAuB,SAAQ,WAAW,EAAE,gBAAgB,EAAE,qBAAqB;CAAG;AAEvG,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,iBAAiB,CAAA;AAEnG,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,iBAAiB,GAAG,qBAAqB,GAAG,sBAAsB,CAAA"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import type { GatewayName } from '@xyo-network/xl1-protocol';
|
|
1
2
|
import type { XyoPermissions } from './permissions/index.ts';
|
|
2
3
|
import type { XyoGateway } from './XyoGateway.ts';
|
|
3
|
-
export type GatewayName = string & {
|
|
4
|
-
__gatewayName: true;
|
|
5
|
-
};
|
|
6
4
|
export interface XyoGatewayConfig {
|
|
7
5
|
name: GatewayName;
|
|
8
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XyoClient.d.ts","sourceRoot":"","sources":["../../../src/provider/XyoClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"XyoClient.d.ts","sourceRoot":"","sources":["../../../src/provider/XyoClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,WAAW,CAAA;CAClB;AAED,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAA;IACnD,WAAW,EAAE,cAAc,CAAA;IAE3B,UAAU,CAAC,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,mBAAmB,GAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IACvG,aAAa,CAAC,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACjD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@xyo-network/xl1-protocol-sdk",
|
|
4
|
-
"version": "1.16.
|
|
4
|
+
"version": "1.16.15",
|
|
5
5
|
"description": "XYO Layer One SDK Protocol",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"src"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@xylabs/sdk-js": "~5.0.
|
|
40
|
-
"@xylabs/telemetry": "~5.0.
|
|
41
|
-
"@xyo-network/account-model": "~5.1.
|
|
42
|
-
"@xyo-network/archivist-memory": "~5.1.
|
|
43
|
-
"@xyo-network/archivist-model": "~5.1.
|
|
44
|
-
"@xyo-network/boundwitness-builder": "~5.1.
|
|
45
|
-
"@xyo-network/boundwitness-model": "~5.1.
|
|
46
|
-
"@xyo-network/payload-builder": "~5.1.
|
|
47
|
-
"@xyo-network/payload-model": "~5.1.
|
|
48
|
-
"@xyo-network/wallet": "~5.1.
|
|
49
|
-
"@xyo-network/wallet-model": "~5.1.
|
|
39
|
+
"@xylabs/sdk-js": "~5.0.34",
|
|
40
|
+
"@xylabs/telemetry": "~5.0.34",
|
|
41
|
+
"@xyo-network/account-model": "~5.1.23",
|
|
42
|
+
"@xyo-network/archivist-memory": "~5.1.23",
|
|
43
|
+
"@xyo-network/archivist-model": "~5.1.23",
|
|
44
|
+
"@xyo-network/boundwitness-builder": "~5.1.23",
|
|
45
|
+
"@xyo-network/boundwitness-model": "~5.1.23",
|
|
46
|
+
"@xyo-network/payload-builder": "~5.1.23",
|
|
47
|
+
"@xyo-network/payload-model": "~5.1.23",
|
|
48
|
+
"@xyo-network/wallet": "~5.1.23",
|
|
49
|
+
"@xyo-network/wallet-model": "~5.1.23",
|
|
50
50
|
"@xyo-network/xl1-protocol": "~1.13.11",
|
|
51
51
|
"async-mutex": "~0.5.0",
|
|
52
52
|
"ethers": "~6.15.0",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"@types/node": "~24.10.1",
|
|
58
58
|
"@xylabs/ts-scripts-yarn3": "~7.2.8",
|
|
59
59
|
"@xylabs/tsconfig": "~7.2.8",
|
|
60
|
-
"@xyo-network/account": "~5.1.
|
|
61
|
-
"@xyo-network/boundwitness-validator": "~5.1.
|
|
60
|
+
"@xyo-network/account": "~5.1.23",
|
|
61
|
+
"@xyo-network/boundwitness-validator": "~5.1.23",
|
|
62
62
|
"axios": "^1.13.2",
|
|
63
63
|
"eslint": "^9.39.1",
|
|
64
64
|
"typescript": "~5.9.3",
|
|
@@ -3,6 +3,7 @@ import { isDefined, isUndefined } from '@xylabs/sdk-js'
|
|
|
3
3
|
|
|
4
4
|
import { LruCacheMap, MemoryMap } from '../../driver/index.ts'
|
|
5
5
|
import type { MapType } from '../../map/index.ts'
|
|
6
|
+
import { timeBudget } from '../../primitives/index.ts'
|
|
6
7
|
import type { ChainIdentity } from '../ChainIdentity.ts'
|
|
7
8
|
import type {
|
|
8
9
|
ChainStakeContext, ChainStakeContextRead, ChainStakeContextWrite,
|
|
@@ -31,23 +32,28 @@ export function contextCache<TCacheValue>(
|
|
|
31
32
|
return context.caches[name] as MapType<string, TCacheValue>
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
export interface withContextCacheResponseOptions {
|
|
36
|
+
max?: number
|
|
37
|
+
timeBudgetMs?: number
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
export async function withContextCacheResponse<T extends {} | string | number | bigint>(
|
|
35
41
|
context: BaseContext,
|
|
36
42
|
name: string,
|
|
37
43
|
key: string,
|
|
38
44
|
func: () => Promise<T extends {} | string | number | bigint ? T : never>,
|
|
39
|
-
|
|
45
|
+
{ max = 10_000, timeBudgetMs = 0 }: withContextCacheResponseOptions = {},
|
|
40
46
|
): Promise<T> {
|
|
41
47
|
const cache = contextCache<T>(
|
|
42
48
|
context,
|
|
43
49
|
name,
|
|
44
|
-
() => new LruCacheMap<string, T>({ max
|
|
50
|
+
() => new LruCacheMap<string, T>({ max }),
|
|
45
51
|
)
|
|
46
52
|
const cacheResult = await cache.get(key)
|
|
47
53
|
if (isDefined(cacheResult)) {
|
|
48
54
|
return cacheResult
|
|
49
55
|
}
|
|
50
|
-
const result = await func()
|
|
56
|
+
const result = timeBudgetMs > 0 ? await timeBudget(name, context.logger, func, timeBudgetMs) : await func()
|
|
51
57
|
await cache.set(key, result)
|
|
52
58
|
return result
|
|
53
59
|
}
|
|
@@ -4,7 +4,7 @@ export async function timeBudget<TResult>(name: string, logger: Logger | undefin
|
|
|
4
4
|
const start = Date.now()
|
|
5
5
|
const result = await func()
|
|
6
6
|
const duration = Date.now() - start
|
|
7
|
-
if (duration > budget) {
|
|
7
|
+
if ((budget > 0) && (duration > budget)) {
|
|
8
8
|
logger?.warn(`Function [${name}] execution exceeded budget: ${duration}ms > ${budget}ms`)
|
|
9
9
|
}
|
|
10
10
|
return result
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { GatewayName } from '@xyo-network/xl1-protocol'
|
|
2
|
+
|
|
1
3
|
import type { XyoPermissions } from './permissions/index.ts'
|
|
2
4
|
import type { XyoGateway } from './XyoGateway.ts'
|
|
3
5
|
|
|
4
|
-
export type GatewayName = string & { __gatewayName: true }
|
|
5
|
-
|
|
6
6
|
export interface XyoGatewayConfig {
|
|
7
7
|
name: GatewayName
|
|
8
8
|
}
|