@xyo-network/xl1-protocol-sdk 1.15.27 → 1.15.28
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/neutral/block/primitives/blockFromBlockNumber.d.ts +1 -1
- package/dist/neutral/block/primitives/blockFromBlockNumber.d.ts.map +1 -1
- package/dist/neutral/block/primitives/index.d.ts +1 -0
- package/dist/neutral/block/primitives/index.d.ts.map +1 -1
- package/dist/neutral/block/primitives/toStepIdentityString.d.ts +3 -0
- package/dist/neutral/block/primitives/toStepIdentityString.d.ts.map +1 -0
- package/dist/neutral/config/Config.d.ts +2 -2
- package/dist/neutral/config/Log.d.ts +1 -1
- package/dist/neutral/driver/cache/LruCacheMap.d.ts +13 -0
- package/dist/neutral/driver/cache/LruCacheMap.d.ts.map +1 -0
- package/dist/neutral/driver/cache/index.d.ts +2 -0
- package/dist/neutral/driver/cache/index.d.ts.map +1 -0
- package/dist/neutral/driver/index.d.ts +3 -0
- package/dist/neutral/driver/index.d.ts.map +1 -0
- package/dist/neutral/driver/memory/MemoryMap.d.ts +12 -0
- package/dist/neutral/driver/memory/MemoryMap.d.ts.map +1 -0
- package/dist/neutral/driver/memory/index.d.ts +2 -0
- package/dist/neutral/driver/memory/index.d.ts.map +1 -0
- package/dist/neutral/eip-712/Payloads/EIP712Data.d.ts +0 -16
- package/dist/neutral/eip-712/Payloads/EIP712Data.d.ts.map +1 -1
- package/dist/neutral/index.d.ts +1 -2
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +193 -62
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/instances/index.d.ts +0 -2
- package/dist/neutral/instances/index.d.ts.map +1 -1
- package/dist/neutral/model/ChainContext/ChainContext.d.ts +14 -4
- package/dist/neutral/model/ChainContext/ChainContext.d.ts.map +1 -1
- package/dist/neutral/model/ChainContext/ChainStateContext.d.ts +1 -1
- package/dist/neutral/model/ChainContext/ChainStateContext.d.ts.map +1 -1
- package/dist/neutral/model/ChainStake/ChainStakeRead.d.ts +12 -12
- package/dist/neutral/model/ChainStake/ChainStakeRead.d.ts.map +1 -1
- package/dist/neutral/model/StakeEvents.d.ts +1 -0
- package/dist/neutral/model/StakeEvents.d.ts.map +1 -1
- package/dist/neutral/primitives/index.d.ts +1 -0
- package/dist/neutral/primitives/index.d.ts.map +1 -1
- package/dist/neutral/primitives/timeBudget.d.ts +3 -0
- package/dist/neutral/primitives/timeBudget.d.ts.map +1 -0
- package/dist/neutral/transaction/buildUnsignedTransaction.d.ts +2 -2
- package/dist/neutral/transaction/buildUnsignedTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/primitives/transactionElevatedPayloads.d.ts +2 -2
- package/dist/neutral/transaction/primitives/transactionElevatedPayloads.d.ts.map +1 -1
- package/package.json +28 -27
- package/src/block/primitives/blockFromBlockNumber.ts +30 -27
- package/src/block/primitives/index.ts +1 -0
- package/src/block/primitives/toStepIdentityString.ts +5 -0
- package/src/block/primitives/transfers/transfersStepSummaryFromRange.ts +2 -2
- package/src/block/primitives/transfers/transfersSummary.ts +2 -2
- package/src/driver/cache/LruCacheMap.ts +42 -0
- package/src/driver/cache/index.ts +1 -0
- package/src/driver/index.ts +2 -0
- package/src/driver/memory/MemoryMap.ts +42 -0
- package/src/driver/memory/index.ts +1 -0
- package/src/eip-712/Payloads/EIP712Data.ts +0 -19
- package/src/index.ts +1 -2
- package/src/instances/index.ts +0 -2
- package/src/model/ChainContext/ChainContext.ts +49 -4
- package/src/model/ChainContext/ChainStateContext.ts +1 -1
- package/src/model/ChainStake/ChainStakeRead.ts +12 -12
- package/src/model/StakeEvents.ts +1 -0
- package/src/primitives/index.ts +1 -0
- package/src/primitives/summary/balances/balancesStepSummaryFromRange.ts +2 -2
- package/src/primitives/summary/balances/balancesSummary.ts +3 -3
- package/src/primitives/summary/transfers/transfersStepSummaryFromRange.ts +2 -2
- package/src/primitives/summary/transfers/transfersSummary.ts +3 -3
- package/src/primitives/timeBudget.ts +11 -0
- package/src/transaction/buildUnsignedTransaction.ts +4 -8
- package/src/transaction/primitives/transactionElevatedPayloads.ts +2 -2
- package/src/transaction/script.ts +3 -3
- package/dist/neutral/ChainServiceCollection.d.ts +0 -61
- package/dist/neutral/ChainServiceCollection.d.ts.map +0 -1
- package/dist/neutral/instances/ShiftedBigIntConfig.d.ts +0 -9
- package/dist/neutral/instances/ShiftedBigIntConfig.d.ts.map +0 -1
- package/dist/neutral/instances/XL1Amount.d.ts +0 -15
- package/dist/neutral/instances/XL1Amount.d.ts.map +0 -1
- package/src/ChainServiceCollection.ts +0 -66
- package/src/instances/ShiftedBigIntConfig.ts +0 -8
- package/src/instances/XL1Amount.ts +0 -29
|
@@ -6,8 +6,6 @@ export * from './Fees.ts';
|
|
|
6
6
|
export * from './modifiers/index.ts';
|
|
7
7
|
export * from './Object.ts';
|
|
8
8
|
export * from './Payload.ts';
|
|
9
|
-
export * from './ShiftedBigIntConfig.ts';
|
|
10
9
|
export * from './Signature.ts';
|
|
11
10
|
export * from './transaction/index.ts';
|
|
12
|
-
export * from './XL1Amount.ts';
|
|
13
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/instances/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/instances/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,wBAAwB,CAAA"}
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
+
import type { Logger } from '@xylabs/logger';
|
|
2
|
+
import type { MapType } from '../../map/index.ts';
|
|
1
3
|
import type { ChainIdentity } from '../ChainIdentity.ts';
|
|
2
4
|
import type { ChainStakeContext, ChainStakeContextRead, ChainStakeContextWrite } from './ChainStakeContext.ts';
|
|
3
5
|
import type { ChainStateContextRead, ChainStateContextWrite } from './ChainStateContext.ts';
|
|
4
6
|
import type { ChainStoreContext, ChainStoreContextRead, ChainStoreContextWrite } from './ChainStoreContext.ts';
|
|
5
|
-
export interface
|
|
7
|
+
export interface BaseContext<TCacheValue = string | object | number | bigint> {
|
|
8
|
+
caches?: Record<string, MapType<string, TCacheValue>>;
|
|
9
|
+
logger?: Logger;
|
|
6
10
|
}
|
|
7
|
-
export
|
|
11
|
+
export declare function contextCache<TCacheValue>(context: BaseContext<TCacheValue | unknown>, name: string, create?: () => MapType<string, TCacheValue>): MapType<string, TCacheValue>;
|
|
12
|
+
export declare function withContextCacheResponse<T extends {} | string | number | bigint>(context: BaseContext, name: string, key: string, func: () => Promise<T extends {} | string | number | bigint ? T : never>, options?: {
|
|
13
|
+
max?: number;
|
|
14
|
+
}): Promise<T>;
|
|
15
|
+
export interface ChainContextWrite extends BaseContext, ChainIdentity, ChainStateContextWrite, ChainStoreContextWrite {
|
|
8
16
|
}
|
|
9
|
-
export interface
|
|
17
|
+
export interface StakedChainContextWrite extends BaseContext, ChainContextWrite, ChainStakeContextWrite {
|
|
10
18
|
}
|
|
11
|
-
export interface
|
|
19
|
+
export interface ChainContextRead extends BaseContext, ChainIdentity, ChainStateContextRead, ChainStoreContextRead {
|
|
20
|
+
}
|
|
21
|
+
export interface StakedChainContextRead extends BaseContext, ChainContextRead, ChainStakeContextRead {
|
|
12
22
|
}
|
|
13
23
|
export type ChainContext = ChainIdentity & ChainContextRead & ChainContextWrite & ChainStoreContext;
|
|
14
24
|
export type StakedChainContext = ChainContext & ChainStakeContext & ChainStakeContextRead & ChainStakeContextWrite;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChainContext.d.ts","sourceRoot":"","sources":["../../../../src/model/ChainContext/ChainContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EACV,iBAAiB,EAAE,qBAAqB,EAAE,sBAAsB,EACjE,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC3F,OAAO,KAAK,EACV,iBAAiB,EAAE,qBAAqB,EAAE,sBAAsB,EACjE,MAAM,wBAAwB,CAAA;AAE/B,MAAM,WAAW,iBAAkB,SAAQ,aAAa,EAAE,sBAAsB,EAAE,sBAAsB;CAAG;
|
|
1
|
+
{"version":3,"file":"ChainContext.d.ts","sourceRoot":"","sources":["../../../../src/model/ChainContext/ChainContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAI5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EACV,iBAAiB,EAAE,qBAAqB,EAAE,sBAAsB,EACjE,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC3F,OAAO,KAAK,EACV,iBAAiB,EAAE,qBAAqB,EAAE,sBAAsB,EACjE,MAAM,wBAAwB,CAAA;AAE/B,MAAM,WAAW,WAAW,CAAC,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM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qB,GAAG,sBAAsB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChainStateContext.d.ts","sourceRoot":"","sources":["../../../../src/model/ChainContext/ChainStateContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,WAAW,qBAAqB;IACpC,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"ChainStateContext.d.ts","sourceRoot":"","sources":["../../../../src/model/ChainContext/ChainStateContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,WAAW,qBAAqB;IACpC,IAAI,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;CACnC;AAED,MAAM,WAAW,sBAAsB;CAAG;AAE1C,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GAAG,sBAAsB,CAAA"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { Address } from '@xylabs/hex';
|
|
2
2
|
import type { Promisable } from '@xylabs/promise';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Position } from '@xyo-network/xl1-protocol';
|
|
4
4
|
export interface ChainStakeRead {
|
|
5
|
-
active(): Promisable<bigint>;
|
|
6
|
-
activeByAddressStaked(address: string): Promisable<bigint>;
|
|
7
|
-
activeByStaker(address: string): Promisable<bigint>;
|
|
8
|
-
pending(): Promisable<bigint>;
|
|
9
|
-
pendingByStaker(staker: string): Promisable<bigint>;
|
|
10
|
-
stakeById(id: number): Promisable<
|
|
11
|
-
stakeByStaker(staker: Address, slot: number): Promisable<
|
|
12
|
-
stakesByStaked(staked: Address, range?: [number, number |
|
|
13
|
-
stakesByStaker(staker: Address, range?: [number, number |
|
|
14
|
-
withdrawn(): Promisable<bigint>;
|
|
15
|
-
withdrawnByStaker(staker: string): Promisable<bigint>;
|
|
5
|
+
active(time?: number): Promisable<bigint>;
|
|
6
|
+
activeByAddressStaked(address: string, time?: number): Promisable<bigint>;
|
|
7
|
+
activeByStaker(address: string, time?: number): Promisable<bigint>;
|
|
8
|
+
pending(time?: number): Promisable<bigint>;
|
|
9
|
+
pendingByStaker(staker: string, time?: number): Promisable<bigint>;
|
|
10
|
+
stakeById(id: number, time?: number): Promisable<Position>;
|
|
11
|
+
stakeByStaker(staker: Address, slot: number, time?: number): Promisable<Position>;
|
|
12
|
+
stakesByStaked(staked: Address, range?: [number, number | undefined]): Promisable<Position[]>;
|
|
13
|
+
stakesByStaker(staker: Address, range?: [number, number | undefined]): Promisable<Position[]>;
|
|
14
|
+
withdrawn(time?: number): Promisable<bigint>;
|
|
15
|
+
withdrawnByStaker(staker: string, time?: number): Promisable<bigint>;
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=ChainStakeRead.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChainStakeRead.d.ts","sourceRoot":"","sources":["../../../../src/model/ChainStake/ChainStakeRead.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ChainStakeRead.d.ts","sourceRoot":"","sources":["../../../../src/model/ChainStake/ChainStakeRead.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AAEzD,MAAM,WAAW,cAAc;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ventName = StakeEventName> exten
|
|
|
26
26
|
args: StakeEventArgs;
|
|
27
27
|
}
|
|
28
28
|
export interface StakeEventsRead {
|
|
29
|
+
positionCount(range: [number, number | 'latest']): Promisable<number>;
|
|
29
30
|
stakeEvents<TName extends StakeEventName>(range: [number, number | 'latest'], filter?: StakeEventFilter<TName>): Promisable<StakeEvent<TName>[]>;
|
|
30
31
|
}
|
|
31
32
|
//# sourceMappingURL=StakeEvents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StakeEvents.d.ts","sourceRoot":"","sources":["../../../src/model/StakeEvents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,eAAO,MAAM,eAAe,2DAA4D,CAAA;AACxF,MAAM,MAAM,cAAc,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC,CAAA;AAE3D,MAAM,WAAW,aAAa,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,SAAS,UAAU,GAAG,EAAE;IACzF,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,WAAW,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM;IACxD,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE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,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAA;AAE5F,MAAM,WAAW,gBAAgB,CAAC,KAAK,SAAS,cAAc,GAAG,cAAc,CAAE,SAAQ,WAAW,CAAC,KAAK,CAAC;IACzG,IAAI,CAAC,EAAE,oBAAoB,CAAA;CAC5B;AAED,MAAM,WAAW,UAAU,CAAC,KAAK,SAAS,cAAc,GAAG,cAAc,CAAE,SAAQ,aAAa,CAAC,KAAK,CAAC;IACrG,IAAI,EAAE,cAAc,CAAA;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;IACrE,WAAW,CAAC,KAAK,SAAS,cAAc,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC,EAAE,MAAM,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;CACjJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeBudget.d.ts","sourceRoot":"","sources":["../../../src/primitives/timeBudget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,wBAAsB,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQlJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address } from '@xylabs/hex';
|
|
2
2
|
import type { Payload } from '@xyo-network/payload-model';
|
|
3
|
-
import type { AllowedBlockPayload, ChainId, TransactionFeesBigInt,
|
|
4
|
-
export declare function buildUnsignedTransaction(chain: ChainId, onChainPayloads: AllowedBlockPayload[], offChainPayloads: Payload[], nbf: number, exp: number, from: Address, fees?: TransactionFeesBigInt): Promise<
|
|
3
|
+
import type { AllowedBlockPayload, ChainId, TransactionFeesBigInt, UnsignedHydratedTransaction } from '@xyo-network/xl1-protocol';
|
|
4
|
+
export declare function buildUnsignedTransaction(chain: ChainId, onChainPayloads: AllowedBlockPayload[], offChainPayloads: Payload[], nbf: number, exp: number, from: Address, fees?: TransactionFeesBigInt): Promise<UnsignedHydratedTransaction>;
|
|
5
5
|
//# sourceMappingURL=buildUnsignedTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUnsignedTransaction.d.ts","sourceRoot":"","sources":["../../../src/transaction/buildUnsignedTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAI1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,EACV,mBAAmB,
|
|
1
|
+
{"version":3,"file":"buildUnsignedTransaction.d.ts","sourceRoot":"","sources":["../../../src/transaction/buildUnsignedTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAI1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,KAAK,EACV,mBAAmB,EAAE,OAAO,EAAwF,qBAAqB,EACzI,2BAA2B,EAC5B,MAAM,2BAA2B,CAAA;AAGlC,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,mBAAmB,EAAE,EACtC,gBAAgB,EAAE,OAAO,EAAE,EAC3B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,OAAO,EACb,IAAI,GAAE,qBAA8C,GACnD,OAAO,CAAC,2BAA2B,CAAC,CAmCtC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Hash } from '@xylabs/hex';
|
|
2
|
-
import type { Payload,
|
|
2
|
+
import type { Payload, WithHashMeta } from '@xyo-network/payload-model';
|
|
3
3
|
import type { SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness } from '@xyo-network/xl1-protocol';
|
|
4
4
|
export declare function transactionElevatedPayloadHashes(transaction: TransactionBoundWitness): Hash[];
|
|
5
|
-
export declare function transactionElevatedPayloads([transaction, payloads]: SignedHydratedTransactionWithStorageMeta):
|
|
5
|
+
export declare function transactionElevatedPayloads([transaction, payloads]: SignedHydratedTransactionWithStorageMeta): WithHashMeta<Payload>[];
|
|
6
6
|
//# sourceMappingURL=transactionElevatedPayloads.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactionElevatedPayloads.d.ts","sourceRoot":"","sources":["../../../../src/transaction/primitives/transactionElevatedPayloads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,IAAI,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"transactionElevatedPayloads.d.ts","sourceRoot":"","sources":["../../../../src/transaction/primitives/transactionElevatedPayloads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,IAAI,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,wCAAwC,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAIlH,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,uBAAuB,GAAG,IAAI,EAAE,CAG7F;AAED,wBAAgB,2BAA2B,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,wCAAwC,GAAG,YAAY,CAAC,OAAO,CAAC,EAAE,CAItI"}
|
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.15.
|
|
4
|
+
"version": "1.15.28",
|
|
5
5
|
"description": "XYO Layer One SDK Protocol",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -36,38 +36,39 @@
|
|
|
36
36
|
"src"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@xylabs/array": "~5.0.
|
|
40
|
-
"@xylabs/arraybuffer": "~5.0.
|
|
41
|
-
"@xylabs/assert": "~5.0.
|
|
42
|
-
"@xylabs/delay": "~5.0.
|
|
43
|
-
"@xylabs/hex": "~5.0.
|
|
44
|
-
"@xylabs/logger": "~5.0.
|
|
45
|
-
"@xylabs/object": "~5.0.
|
|
46
|
-
"@xylabs/promise": "~5.0.
|
|
47
|
-
"@xylabs/telemetry": "~5.0.
|
|
48
|
-
"@xylabs/typeof": "~5.0.
|
|
49
|
-
"@xyo-network/account-model": "~5.1.
|
|
50
|
-
"@xyo-network/archivist-model": "~5.1.
|
|
51
|
-
"@xyo-network/boundwitness-builder": "~5.1.
|
|
52
|
-
"@xyo-network/boundwitness-model": "~5.1.
|
|
53
|
-
"@xyo-network/payload-builder": "~5.1.
|
|
54
|
-
"@xyo-network/payload-model": "~5.1.
|
|
55
|
-
"@xyo-network/wallet": "~5.1.
|
|
56
|
-
"@xyo-network/wallet-model": "~5.1.
|
|
57
|
-
"@xyo-network/xl1-protocol": "~1.12.
|
|
39
|
+
"@xylabs/array": "~5.0.18",
|
|
40
|
+
"@xylabs/arraybuffer": "~5.0.18",
|
|
41
|
+
"@xylabs/assert": "~5.0.18",
|
|
42
|
+
"@xylabs/delay": "~5.0.18",
|
|
43
|
+
"@xylabs/hex": "~5.0.18",
|
|
44
|
+
"@xylabs/logger": "~5.0.18",
|
|
45
|
+
"@xylabs/object": "~5.0.18",
|
|
46
|
+
"@xylabs/promise": "~5.0.18",
|
|
47
|
+
"@xylabs/telemetry": "~5.0.18",
|
|
48
|
+
"@xylabs/typeof": "~5.0.18",
|
|
49
|
+
"@xyo-network/account-model": "~5.1.17",
|
|
50
|
+
"@xyo-network/archivist-model": "~5.1.17",
|
|
51
|
+
"@xyo-network/boundwitness-builder": "~5.1.17",
|
|
52
|
+
"@xyo-network/boundwitness-model": "~5.1.17",
|
|
53
|
+
"@xyo-network/payload-builder": "~5.1.17",
|
|
54
|
+
"@xyo-network/payload-model": "~5.1.17",
|
|
55
|
+
"@xyo-network/wallet": "~5.1.17",
|
|
56
|
+
"@xyo-network/wallet-model": "~5.1.17",
|
|
57
|
+
"@xyo-network/xl1-protocol": "~1.12.102",
|
|
58
58
|
"async-mutex": "~0.5.0",
|
|
59
59
|
"ethers": "~6.15.0",
|
|
60
|
+
"lru-cache": "^11.2.2",
|
|
60
61
|
"zod": "~4.1.12"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
|
-
"@types/node": "~24.
|
|
64
|
-
"@xylabs/ts-scripts-yarn3": "~7.
|
|
65
|
-
"@xylabs/tsconfig": "~7.
|
|
66
|
-
"@xyo-network/account": "~5.1.
|
|
67
|
-
"@xyo-network/boundwitness-validator": "~5.1.
|
|
68
|
-
"eslint": "^9.39.
|
|
64
|
+
"@types/node": "~24.10.0",
|
|
65
|
+
"@xylabs/ts-scripts-yarn3": "~7.2.4",
|
|
66
|
+
"@xylabs/tsconfig": "~7.2.4",
|
|
67
|
+
"@xyo-network/account": "~5.1.17",
|
|
68
|
+
"@xyo-network/boundwitness-validator": "~5.1.17",
|
|
69
|
+
"eslint": "^9.39.1",
|
|
69
70
|
"typescript": "~5.9.3",
|
|
70
|
-
"vitest": "~
|
|
71
|
+
"vitest": "~4.0.7"
|
|
71
72
|
},
|
|
72
73
|
"engines": {
|
|
73
74
|
"node": ">=22.3 <23"
|
|
@@ -4,35 +4,38 @@ import type { WithStorageMeta } from '@xyo-network/payload-model'
|
|
|
4
4
|
import type { BlockBoundWitness, XL1BlockNumber } from '@xyo-network/xl1-protocol'
|
|
5
5
|
import { asBlockBoundWitnessWithStorageMeta, StepSizes } from '@xyo-network/xl1-protocol'
|
|
6
6
|
|
|
7
|
-
import type
|
|
7
|
+
import { type ChainContextRead, withContextCacheResponse } from '../../model/index.ts'
|
|
8
8
|
|
|
9
9
|
export async function blockFromBlockNumber(context: ChainContextRead, blockNumber: XL1BlockNumber): Promise<WithStorageMeta<BlockBoundWitness>> {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
while (currentBlock.block > blockNumber) {
|
|
17
|
-
let jumpHash: Hash | null = currentBlock.previous
|
|
18
|
-
let jumpBlockNumber = currentBlock.block - 1
|
|
19
|
-
for (const [step, stepSize] of StepSizes.entries()) {
|
|
20
|
-
const possibleJumpBlockNumber = currentBlock.block - (currentBlock.block % stepSize) - 1
|
|
21
|
-
if (possibleJumpBlockNumber >= blockNumber && possibleJumpBlockNumber <= jumpBlockNumber) {
|
|
22
|
-
jumpBlockNumber = possibleJumpBlockNumber
|
|
23
|
-
jumpHash = asHash(currentBlock.step_hashes.at(step), () => `Step hash not found for step ${step} in block ${currentBlock.block}`)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const newBlock = await context.store.chainMap.get(
|
|
27
|
-
asHash(jumpHash, () => `Jump hash not found for block number [${blockNumber}]: ${jumpBlockNumber} ${toSafeJsonString(currentBlock, 10)}`),
|
|
28
|
-
)
|
|
29
|
-
currentBlock = asBlockBoundWitnessWithStorageMeta(newBlock, () => `Block not found for hash: ${jumpHash}`, { required: true })
|
|
30
|
-
if (currentBlock.block === blockNumber) {
|
|
31
|
-
break
|
|
32
|
-
}
|
|
10
|
+
const cacheKey = `${blockNumber}`
|
|
11
|
+
return await withContextCacheResponse(context, 'blockFromBlockNumber', cacheKey, async () => {
|
|
12
|
+
const [headHash] = await context.head()
|
|
13
|
+
const result = await context.store.chainMap.get(headHash)
|
|
14
|
+
let currentBlock = asBlockBoundWitnessWithStorageMeta(result, () => `Head block not found for hash: ${headHash}`, { required: true })
|
|
33
15
|
if (currentBlock.block < blockNumber) {
|
|
34
|
-
throw new Error(`Block number ${blockNumber} is
|
|
16
|
+
throw new Error(`Error: Block number ${blockNumber} is greater than head ${currentBlock.block}.`)
|
|
17
|
+
}
|
|
18
|
+
while (currentBlock.block > blockNumber) {
|
|
19
|
+
let jumpHash: Hash | null = currentBlock.previous
|
|
20
|
+
let jumpBlockNumber = currentBlock.block - 1
|
|
21
|
+
for (const [step, stepSize] of StepSizes.entries()) {
|
|
22
|
+
const possibleJumpBlockNumber = currentBlock.block - (currentBlock.block % stepSize) - 1
|
|
23
|
+
if (possibleJumpBlockNumber >= blockNumber && possibleJumpBlockNumber <= jumpBlockNumber) {
|
|
24
|
+
jumpBlockNumber = possibleJumpBlockNumber
|
|
25
|
+
jumpHash = asHash(currentBlock.step_hashes.at(step), () => `Step hash not found for step ${step} in block ${currentBlock.block}`)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const newBlock = await context.store.chainMap.get(
|
|
29
|
+
asHash(jumpHash, () => `Jump hash not found for block number [${blockNumber}]: ${jumpBlockNumber} ${toSafeJsonString(currentBlock, 10)}`),
|
|
30
|
+
)
|
|
31
|
+
currentBlock = asBlockBoundWitnessWithStorageMeta(newBlock, () => `Block not found for hash: ${jumpHash}`, { required: true })
|
|
32
|
+
if (currentBlock.block === blockNumber) {
|
|
33
|
+
break
|
|
34
|
+
}
|
|
35
|
+
if (currentBlock.block < blockNumber) {
|
|
36
|
+
throw new Error(`Block number ${blockNumber} is not a valid step block number for block ${headHash}.`)
|
|
37
|
+
}
|
|
35
38
|
}
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
return currentBlock
|
|
40
|
+
})
|
|
38
41
|
}
|
|
@@ -24,7 +24,7 @@ export async function transfersStepSummaryFromRange(
|
|
|
24
24
|
// console.log(`transfersStepSummaryFromRange: head=${head}, range=${range[0]}-${range[1]}`)
|
|
25
25
|
const frameHeadHash = await hashFromBlockNumber(context, range[1])
|
|
26
26
|
const frameSize = range[1] - range[0] + 1
|
|
27
|
-
const
|
|
27
|
+
const [headHash] = await context.head()
|
|
28
28
|
|
|
29
29
|
let result: TransfersStepSummary | undefined = undefined
|
|
30
30
|
|
|
@@ -39,7 +39,7 @@ export async function transfersStepSummaryFromRange(
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
result = {
|
|
42
|
-
schema: TransfersStepSummarySchema, hash:
|
|
42
|
+
schema: TransfersStepSummarySchema, hash: headHash, stepSize: -1, transfers,
|
|
43
43
|
}
|
|
44
44
|
} else {
|
|
45
45
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -14,8 +14,8 @@ export async function transfersSummary(
|
|
|
14
14
|
context: TransfersStepSummaryContext,
|
|
15
15
|
): Promise<Partial<Record<Address, Partial<Record<Address, bigint>>>>> {
|
|
16
16
|
return await spanRootAsync('transferSummary', async () => {
|
|
17
|
-
const
|
|
18
|
-
const headResult = await context.store.chainMap.get(
|
|
17
|
+
const [headHash] = await context.head()
|
|
18
|
+
const headResult = await context.store.chainMap.get(headHash)
|
|
19
19
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta(headResult, () => `Head block not found for hash: ${context.head}`, { required: true })
|
|
20
20
|
const rangeStart = asXL1BlockNumber(isDefined(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0)
|
|
21
21
|
const ranges = deepCalculateFramesFromRange([rangeStart, asXL1BlockNumber(headBoundWitness.block)])
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LRUCache } from 'lru-cache'
|
|
2
|
+
|
|
3
|
+
import type { SynchronousMap } from '../../map/index.ts'
|
|
4
|
+
|
|
5
|
+
export class LruCacheMap<K extends {}, V extends {} | string | number | bigint, FC = () => void> implements SynchronousMap<K, V> {
|
|
6
|
+
private lruCache: LRUCache<K, V, FC>
|
|
7
|
+
|
|
8
|
+
constructor(options?: LRUCache.Options<K, V, FC>) {
|
|
9
|
+
this.lruCache = new LRUCache<K, V, FC>(options ?? { max: 5000 })
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
clear(): void {
|
|
13
|
+
this.lruCache.clear()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
delete(id: K): boolean {
|
|
17
|
+
return this.lruCache.delete(id)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get(id: K): V | undefined {
|
|
21
|
+
return this.lruCache.get(id)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getMany(id: K[]): V[] {
|
|
25
|
+
const results: V[] = []
|
|
26
|
+
for (const key of id) {
|
|
27
|
+
const value = this.lruCache.get(key)
|
|
28
|
+
if (value !== undefined) {
|
|
29
|
+
results.push(value)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return results
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
has(id: K): boolean {
|
|
36
|
+
return this.lruCache.has(id)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
set(id: K, data: V) {
|
|
40
|
+
this.lruCache.set(id, data)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LruCacheMap.ts'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { isDefined } from '@xylabs/typeof'
|
|
2
|
+
|
|
3
|
+
import type { SynchronousMap } from '../../map/index.ts'
|
|
4
|
+
|
|
5
|
+
export class MemoryMap<K extends {}, V = {}> implements SynchronousMap<K, V> {
|
|
6
|
+
private map: Map<K, V>
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
this.map = new Map<K, V>()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
clear(): void {
|
|
13
|
+
this.map.clear()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
delete(id: K): boolean {
|
|
17
|
+
return this.map.delete(id)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get(id: K): V | undefined {
|
|
21
|
+
return this.map.get(id)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getMany(ids: K[]): V[] {
|
|
25
|
+
const results: V[] = []
|
|
26
|
+
for (const id of ids) {
|
|
27
|
+
const data = this.map.get(id)
|
|
28
|
+
if (isDefined(data)) {
|
|
29
|
+
results.push(data)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return results
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
has(id: K): boolean {
|
|
36
|
+
return this.map.has(id)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
set(id: K, data: V) {
|
|
40
|
+
this.map.set(id, data)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MemoryMap.ts'
|
|
@@ -13,30 +13,11 @@ export const EIP712DataPayloadFieldsZod = z.object({
|
|
|
13
13
|
})
|
|
14
14
|
export type EIP712DataPayloadFields = z.infer<typeof EIP712DataPayloadFieldsZod>
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Use EIP712DataPayloadFields instead
|
|
18
|
-
*/
|
|
19
|
-
export type EIP712PayloadFields = EIP712DataPayloadFields
|
|
20
|
-
|
|
21
16
|
export const EIP712DataPayloadSchema = 'network.xyo.chains.ethereum.eip712.data' as const
|
|
22
17
|
export type EIP712DataPayloadSchema = typeof EIP712DataPayloadSchema
|
|
23
18
|
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated Use EIP712DataPayloadSchema instead
|
|
26
|
-
*/
|
|
27
|
-
export const EIP712PayloadSchema = EIP712DataPayloadSchema
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated Use EIP712DataPayloadSchema instead
|
|
30
|
-
*/
|
|
31
|
-
export type EIP712PayloadSchema = typeof EIP712DataPayloadSchema
|
|
32
|
-
|
|
33
19
|
export type EIP712DataPayload = Payload<EIP712DataPayloadFields, EIP712DataPayloadSchema>
|
|
34
20
|
|
|
35
|
-
/**
|
|
36
|
-
* @deprecated Use EIP712DataPayload instead
|
|
37
|
-
*/
|
|
38
|
-
export type EIP712Payload = EIP712DataPayload
|
|
39
|
-
|
|
40
21
|
export const isEIP712DataPayload = isPayloadOfZodType<EIP712DataPayload>(
|
|
41
22
|
EIP712DataPayloadFieldsZod,
|
|
42
23
|
EIP712DataPayloadSchema,
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export * from './block/index.ts'
|
|
2
|
-
export * from './ChainServiceCollection.ts'
|
|
3
2
|
export * from './ChainServiceCollectionV2.ts'
|
|
4
3
|
export * from './config/index.ts'
|
|
5
4
|
export * from './constants.ts'
|
|
5
|
+
export * from './driver/index.ts'
|
|
6
6
|
export * from './eip-712/index.ts'
|
|
7
7
|
export * from './instances/index.ts'
|
|
8
8
|
export * from './map/index.ts'
|
|
@@ -10,7 +10,6 @@ export * from './model/index.ts'
|
|
|
10
10
|
export * from './multipliers.ts'
|
|
11
11
|
export * from './payloads/index.ts'
|
|
12
12
|
export * from './primitives/index.ts'
|
|
13
|
-
export * from './primitives/index.ts'
|
|
14
13
|
export * from './SignedBigInt.ts'
|
|
15
14
|
export * from './time/index.ts'
|
|
16
15
|
export * from './transaction/index.ts'
|
package/src/instances/index.ts
CHANGED
|
@@ -6,7 +6,5 @@ export * from './Fees.ts'
|
|
|
6
6
|
export * from './modifiers/index.ts'
|
|
7
7
|
export * from './Object.ts'
|
|
8
8
|
export * from './Payload.ts'
|
|
9
|
-
export * from './ShiftedBigIntConfig.ts'
|
|
10
9
|
export * from './Signature.ts'
|
|
11
10
|
export * from './transaction/index.ts'
|
|
12
|
-
export * from './XL1Amount.ts'
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { Logger } from '@xylabs/logger'
|
|
2
|
+
import { isDefined, isUndefined } from '@xylabs/typeof'
|
|
3
|
+
|
|
4
|
+
import { LruCacheMap, MemoryMap } from '../../driver/index.ts'
|
|
5
|
+
import type { MapType } from '../../map/index.ts'
|
|
1
6
|
import type { ChainIdentity } from '../ChainIdentity.ts'
|
|
2
7
|
import type {
|
|
3
8
|
ChainStakeContext, ChainStakeContextRead, ChainStakeContextWrite,
|
|
@@ -7,13 +12,53 @@ import type {
|
|
|
7
12
|
ChainStoreContext, ChainStoreContextRead, ChainStoreContextWrite,
|
|
8
13
|
} from './ChainStoreContext.ts'
|
|
9
14
|
|
|
10
|
-
export interface
|
|
15
|
+
export interface BaseContext<TCacheValue = string | object | number | bigint> {
|
|
16
|
+
caches?: Record<string, MapType<string, TCacheValue>>
|
|
17
|
+
logger?: Logger
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function contextCache<TCacheValue>(
|
|
21
|
+
context: BaseContext<TCacheValue | unknown>,
|
|
22
|
+
name: string,
|
|
23
|
+
create?: () => MapType<string, TCacheValue>,
|
|
24
|
+
): MapType<string, TCacheValue> {
|
|
25
|
+
if (!context.caches) {
|
|
26
|
+
context.caches = {}
|
|
27
|
+
}
|
|
28
|
+
if (isUndefined(context.caches[name])) {
|
|
29
|
+
context.caches[name] = create?.() ?? new MemoryMap<string, TCacheValue>()
|
|
30
|
+
}
|
|
31
|
+
return context.caches[name] as MapType<string, TCacheValue>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function withContextCacheResponse<T extends {} | string | number | bigint>(
|
|
35
|
+
context: BaseContext,
|
|
36
|
+
name: string,
|
|
37
|
+
key: string,
|
|
38
|
+
func: () => Promise<T extends {} | string | number | bigint ? T : never>,
|
|
39
|
+
options?: { max?: number },
|
|
40
|
+
): Promise<T> {
|
|
41
|
+
const cache = contextCache<T>(
|
|
42
|
+
context,
|
|
43
|
+
name,
|
|
44
|
+
() => new LruCacheMap<string, T>({ max: options?.max ?? 10_000 }),
|
|
45
|
+
)
|
|
46
|
+
const cacheResult = await cache.get(key)
|
|
47
|
+
if (isDefined(cacheResult)) {
|
|
48
|
+
return cacheResult
|
|
49
|
+
}
|
|
50
|
+
const result = await func()
|
|
51
|
+
await cache.set(key, result)
|
|
52
|
+
return result
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ChainContextWrite extends BaseContext, ChainIdentity, ChainStateContextWrite, ChainStoreContextWrite {}
|
|
11
56
|
|
|
12
|
-
export interface StakedChainContextWrite extends ChainContextWrite, ChainStakeContextWrite {}
|
|
57
|
+
export interface StakedChainContextWrite extends BaseContext, ChainContextWrite, ChainStakeContextWrite {}
|
|
13
58
|
|
|
14
|
-
export interface ChainContextRead extends ChainIdentity, ChainStateContextRead, ChainStoreContextRead {}
|
|
59
|
+
export interface ChainContextRead extends BaseContext, ChainIdentity, ChainStateContextRead, ChainStoreContextRead {}
|
|
15
60
|
|
|
16
|
-
export interface StakedChainContextRead extends ChainContextRead, ChainStakeContextRead {}
|
|
61
|
+
export interface StakedChainContextRead extends BaseContext, ChainContextRead, ChainStakeContextRead {}
|
|
17
62
|
|
|
18
63
|
export type ChainContext = ChainIdentity & ChainContextRead & ChainContextWrite & ChainStoreContext
|
|
19
64
|
|