@xyo-network/xl1-protocol 1.12.6 → 1.12.8
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/AllowedBlockPayload.d.ts +8 -2
- package/dist/neutral/block/AllowedBlockPayload.d.ts.map +1 -1
- package/dist/neutral/constants/defaultRewardRatio.d.ts.map +1 -1
- package/dist/neutral/index.mjs +111 -73
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/interfaces/StepStake.d.ts +8 -0
- package/dist/neutral/interfaces/StepStake.d.ts.map +1 -0
- package/dist/neutral/interfaces/TimeSync.d.ts +6 -0
- package/dist/neutral/interfaces/TimeSync.d.ts.map +1 -0
- package/dist/neutral/interfaces/index.d.ts +1 -0
- package/dist/neutral/interfaces/index.d.ts.map +1 -1
- package/dist/neutral/model.d.ts +5 -1
- package/dist/neutral/model.d.ts.map +1 -1
- package/dist/neutral/payload/elevatable/BridgeBack.d.ts +15 -0
- package/dist/neutral/payload/elevatable/BridgeBack.d.ts.map +1 -0
- package/dist/neutral/payload/elevatable/BridgeComplete.d.ts +13 -0
- package/dist/neutral/payload/elevatable/BridgeComplete.d.ts.map +1 -0
- package/dist/neutral/payload/elevatable/BridgeRequest.d.ts +15 -0
- package/dist/neutral/payload/elevatable/BridgeRequest.d.ts.map +1 -0
- package/dist/neutral/payload/elevatable/Time.d.ts +14 -0
- package/dist/neutral/payload/elevatable/Time.d.ts.map +1 -0
- package/dist/neutral/payload/elevatable/index.d.ts +4 -1
- package/dist/neutral/payload/elevatable/index.d.ts.map +1 -1
- package/dist/neutral/services/BlockRewardService.d.ts.map +1 -1
- package/dist/neutral/services/BlockRewardServiceV2.d.ts +6 -0
- package/dist/neutral/services/BlockRewardServiceV2.d.ts.map +1 -0
- package/dist/neutral/services/NetworkStakeService.d.ts +8 -0
- package/dist/neutral/services/NetworkStakeService.d.ts.map +1 -0
- package/dist/neutral/services/index.d.ts +2 -0
- package/dist/neutral/services/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/block/AllowedBlockPayload.ts +21 -4
- package/src/constants/defaultRewardRatio.ts +1 -0
- package/src/interfaces/StepStake.ts +20 -0
- package/src/interfaces/TimeSync.ts +7 -0
- package/src/interfaces/index.ts +1 -0
- package/src/model.ts +10 -1
- package/src/payload/elevatable/BridgeBack.ts +26 -0
- package/src/payload/elevatable/BridgeComplete.ts +24 -0
- package/src/payload/elevatable/BridgeRequest.ts +30 -0
- package/src/payload/elevatable/Time.ts +25 -0
- package/src/payload/elevatable/index.ts +4 -1
- package/src/services/BlockRewardService.ts +1 -0
- package/src/services/BlockRewardServiceV2.ts +8 -0
- package/src/services/NetworkStakeService.ts +9 -0
- package/src/services/index.ts +2 -0
- package/dist/neutral/payload/elevatable/TransferRequest.d.ts +0 -13
- package/dist/neutral/payload/elevatable/TransferRequest.d.ts.map +0 -1
- package/src/payload/elevatable/TransferRequest.ts +0 -28
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
|
|
4
|
+
import type { CompletedStep } from '../model.ts'
|
|
5
|
+
|
|
6
|
+
export interface StepStakeInterface {
|
|
7
|
+
// this is the prorated stake for all addresses in the step
|
|
8
|
+
stepStake: (step: CompletedStep) => Promisable<Record<Address, bigint>>
|
|
9
|
+
|
|
10
|
+
// this is the prorated stake for a specific address in the step
|
|
11
|
+
stepStakeForAddress: (address: Address, step: CompletedStep) => Promisable<bigint>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Prorated stake is the amount of stake that is allocated to a specific step
|
|
15
|
+
based on the total stake and the number of steps. This is used to ensure
|
|
16
|
+
that the stake is distributed fairly among all steps.
|
|
17
|
+
|
|
18
|
+
The simplest way to calculate it is to enumerate every XL1 block in the step add the current stake at that point to a counter.
|
|
19
|
+
For example, if an Address had a stake of 100 for the entire time, then the prorated stake would be 100 * number of blocks in the step.
|
|
20
|
+
*/
|
package/src/interfaces/index.ts
CHANGED
package/src/model.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
Address, Hash, Hex,
|
|
3
|
+
} from '@xylabs/hex'
|
|
2
4
|
|
|
3
5
|
export type Chain = Address | Hex
|
|
6
|
+
|
|
7
|
+
export type CompletedStep = [
|
|
8
|
+
/* Hash of the block whose previous hash is the last item in the step */
|
|
9
|
+
Hash,
|
|
10
|
+
/* Step number [index into StepSizes] */
|
|
11
|
+
number,
|
|
12
|
+
]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Address, EthAddress } from '@xylabs/hex'
|
|
2
|
+
import { AsObjectFactory } from '@xylabs/object'
|
|
3
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
4
|
+
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
5
|
+
|
|
6
|
+
import type { FromFields } from './Executable.ts'
|
|
7
|
+
|
|
8
|
+
export const BridgeBackSchema = 'network.xyo.chain.bridge.back' as const
|
|
9
|
+
export type BridgeBackSchema = typeof BridgeBackSchema
|
|
10
|
+
|
|
11
|
+
/* Report a bridging from WXL1 to XL1 */
|
|
12
|
+
|
|
13
|
+
export interface BridgeBackFields extends FromFields {
|
|
14
|
+
destAddress: Address
|
|
15
|
+
src: 'ethereum'
|
|
16
|
+
srcAddress: EthAddress
|
|
17
|
+
// usually the source's block number
|
|
18
|
+
srcTime: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block
|
|
22
|
+
export type BridgeBack = Payload<BridgeBackFields, BridgeBackSchema>
|
|
23
|
+
|
|
24
|
+
export const isBridgeBack = isPayloadOfSchemaType<BridgeBack>(BridgeBackSchema)
|
|
25
|
+
|
|
26
|
+
export const asBridgeBack = AsObjectFactory.create(isBridgeBack)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import { AsObjectFactory } from '@xylabs/object'
|
|
3
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
4
|
+
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
5
|
+
|
|
6
|
+
import type { FromFields } from './Executable.ts'
|
|
7
|
+
|
|
8
|
+
export const BridgeCompleteSchema = 'network.xyo.chain.bridge.complete' as const
|
|
9
|
+
export type BridgeCompleteSchema = typeof BridgeCompleteSchema
|
|
10
|
+
|
|
11
|
+
/* Complete a bridging from XL1 to WXL1 */
|
|
12
|
+
|
|
13
|
+
export interface BridgeCompleteFields extends FromFields {
|
|
14
|
+
// usually the destination's block number
|
|
15
|
+
destTime: number
|
|
16
|
+
request: Hash
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block
|
|
20
|
+
export type BridgeComplete = Payload<BridgeCompleteFields, BridgeCompleteSchema>
|
|
21
|
+
|
|
22
|
+
export const isBridgeComplete = isPayloadOfSchemaType<BridgeComplete>(BridgeCompleteSchema)
|
|
23
|
+
|
|
24
|
+
export const asBridgeComplete = AsObjectFactory.create(isBridgeComplete)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Address, EthAddress, Hex,
|
|
3
|
+
} from '@xylabs/hex'
|
|
4
|
+
import { AsObjectFactory } from '@xylabs/object'
|
|
5
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
6
|
+
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
7
|
+
|
|
8
|
+
import type { FromFields } from './Executable.ts'
|
|
9
|
+
|
|
10
|
+
/* Request a bridging from XL1 to WXL1 */
|
|
11
|
+
|
|
12
|
+
export const BridgeRequestSchema = 'network.xyo.chain.bridge.request' as const
|
|
13
|
+
export type BridgeRequestSchema = typeof BridgeRequestSchema
|
|
14
|
+
|
|
15
|
+
export interface BridgeRequestFields extends FromFields {
|
|
16
|
+
amount: Hex
|
|
17
|
+
|
|
18
|
+
dest: 'ethereum'
|
|
19
|
+
destAddress: EthAddress
|
|
20
|
+
|
|
21
|
+
// xl1 address
|
|
22
|
+
srcAddress: Address
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block
|
|
26
|
+
export type BridgeRequest = Payload<BridgeRequestFields, BridgeRequestSchema>
|
|
27
|
+
|
|
28
|
+
export const isBridgeRequest = isPayloadOfSchemaType<BridgeRequest>(BridgeRequestSchema)
|
|
29
|
+
|
|
30
|
+
export const asBridgeRequest = AsObjectFactory.create(isBridgeRequest)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AsObjectFactory } from '@xylabs/object'
|
|
2
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
3
|
+
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
4
|
+
|
|
5
|
+
// xl1 = xl1 block number, epoch = epoch number, ethereum = ethereum block number
|
|
6
|
+
export type TimeDomain = 'xl1' | 'epoch' | 'ethereum'
|
|
7
|
+
|
|
8
|
+
export const TimeSchema = 'network.xyo.time' as const
|
|
9
|
+
export type TimeSchema = typeof TimeSchema
|
|
10
|
+
|
|
11
|
+
export interface TimeFields {
|
|
12
|
+
// in milliseconds
|
|
13
|
+
epoch: number
|
|
14
|
+
// in block number
|
|
15
|
+
ethereum?: number
|
|
16
|
+
// in block number
|
|
17
|
+
xl1?: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type TimePayload = Payload<TimeFields, TimeSchema>
|
|
21
|
+
|
|
22
|
+
export const isTimePayload = isPayloadOfSchemaType<TimePayload>(TimeSchema)
|
|
23
|
+
|
|
24
|
+
export const asTimePayload = AsObjectFactory.create(isTimePayload)
|
|
25
|
+
export const asTimePayloadWithStorageMeta = AsObjectFactory.create(isTimePayload)
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
export * from './BridgeBack.ts'
|
|
2
|
+
export * from './BridgeComplete.ts'
|
|
3
|
+
export * from './BridgeRequest.ts'
|
|
1
4
|
export * from './ChainStakeIntent.ts'
|
|
2
5
|
export * from './Executable.ts'
|
|
3
6
|
export * from './Hash.ts'
|
|
4
7
|
export * from './StepComplete.ts'
|
|
8
|
+
export * from './Time.ts'
|
|
5
9
|
export * from './TransferPayload.ts'
|
|
6
|
-
export * from './TransferRequest.ts'
|
|
@@ -3,5 +3,6 @@ import type { Promisable } from '@xylabs/promise'
|
|
|
3
3
|
import type { ServiceInterface } from './Service.ts'
|
|
4
4
|
|
|
5
5
|
export interface BlockRewardService extends ServiceInterface {
|
|
6
|
+
// The amount of xl1 to send to the producer from the block reward
|
|
6
7
|
getRewardForBlock(block: bigint): Promisable<bigint>
|
|
7
8
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Promisable } from '@xylabs/promise'
|
|
2
|
+
|
|
3
|
+
import type { BlockRewardService } from './BlockRewardService.ts'
|
|
4
|
+
|
|
5
|
+
export interface BlockRewardServiceV2 extends BlockRewardService {
|
|
6
|
+
// The amount of xl1 to send to the step pool from the block reward
|
|
7
|
+
getRewardForStepPool(block: bigint): Promisable<bigint>
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex'
|
|
2
|
+
import type { Promisable } from '@xylabs/promise'
|
|
3
|
+
|
|
4
|
+
import type { CompletedStep } from '../model.ts'
|
|
5
|
+
import type { ServiceInterface } from './Service.ts'
|
|
6
|
+
|
|
7
|
+
export interface NetworkStakeService extends ServiceInterface {
|
|
8
|
+
stepStakeForAddress: (address: Address, step: CompletedStep) => Promisable<bigint>
|
|
9
|
+
}
|
package/src/services/index.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export * from './AccountBalanceService.ts'
|
|
2
2
|
export * from './BlockProducerService.ts'
|
|
3
3
|
export * from './BlockRewardService.ts'
|
|
4
|
+
export * from './BlockRewardServiceV2.ts'
|
|
4
5
|
export * from './Chain/index.ts'
|
|
5
6
|
export * from './ChainIterator/index.ts'
|
|
6
7
|
export * from './ChainServiceCollection.ts'
|
|
7
8
|
export * from './ChainServiceCollectionV2.ts'
|
|
8
9
|
export * from './Election.ts'
|
|
10
|
+
export * from './NetworkStakeService.ts'
|
|
9
11
|
export * from './PendingTransactionsService.ts'
|
|
10
12
|
export * from './Service.ts'
|
|
11
13
|
export * from './StakeIntentService/index.ts'
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Address, Hex } from '@xylabs/hex';
|
|
2
|
-
import type { Payload } from '@xyo-network/payload-model';
|
|
3
|
-
import type { FromFields } from './Executable.ts';
|
|
4
|
-
export declare const TransferRequestSchema: "network.xyo.transfer.request";
|
|
5
|
-
export type TransferRequestSchema = typeof TransferRequestSchema;
|
|
6
|
-
export interface TransferRequestFields extends FromFields {
|
|
7
|
-
epoch: number;
|
|
8
|
-
transfers: Partial<Record<Address, Hex>>;
|
|
9
|
-
}
|
|
10
|
-
export type TransferRequest = Payload<TransferRequestFields, TransferRequestSchema>;
|
|
11
|
-
export declare const isTransferRequest: (x?: unknown | null) => x is TransferRequest;
|
|
12
|
-
export declare const asTransferRequest: import("@xylabs/object").AsTypeFunction<TransferRequest>;
|
|
13
|
-
//# sourceMappingURL=TransferRequest.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TransferRequest.d.ts","sourceRoot":"","sources":["../../../../src/payload/elevatable/TransferRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,GAAG,EACJ,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAGzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,eAAO,MAAM,qBAAqB,EAAG,8BAAuC,CAAA;AAC5E,MAAM,MAAM,qBAAqB,GAAG,OAAO,qBAAqB,CAAA;AAKhE,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD,KAAK,EAAE,MAAM,CAAA;IAEb,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;CACzC;AAGD,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,CAAA;AAEnF,eAAO,MAAM,iBAAiB,8CAAgE,CAAA;AAE9F,eAAO,MAAM,iBAAiB,0DAA4C,CAAA"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Address,
|
|
3
|
-
Hex,
|
|
4
|
-
} from '@xylabs/hex'
|
|
5
|
-
import { AsObjectFactory } from '@xylabs/object'
|
|
6
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
7
|
-
import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
|
|
8
|
-
|
|
9
|
-
import type { FromFields } from './Executable.ts'
|
|
10
|
-
|
|
11
|
-
export const TransferRequestSchema = 'network.xyo.transfer.request' as const
|
|
12
|
-
export type TransferRequestSchema = typeof TransferRequestSchema
|
|
13
|
-
|
|
14
|
-
/* The initial use for this is for a network staker to request a transfer from the step reward account to them for the rewards they are owed */
|
|
15
|
-
/* By definition, a request is valid for 1000 blocks following its inclusion in a block or until the request has been filled */
|
|
16
|
-
|
|
17
|
-
export interface TransferRequestFields extends FromFields {
|
|
18
|
-
epoch: number
|
|
19
|
-
// the amount that is requested to be sent to other addresses
|
|
20
|
-
transfers: Partial<Record<Address, Hex>>
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// if this payload is included in a boundwitness, it needs to be available for inspection to be included in block
|
|
24
|
-
export type TransferRequest = Payload<TransferRequestFields, TransferRequestSchema>
|
|
25
|
-
|
|
26
|
-
export const isTransferRequest = isPayloadOfSchemaType<TransferRequest>(TransferRequestSchema)
|
|
27
|
-
|
|
28
|
-
export const asTransferRequest = AsObjectFactory.create(isTransferRequest)
|