@xyo-network/xl1-protocol 1.13.11 → 1.13.13
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.map +1 -1
- package/dist/neutral/index.mjs +147 -183
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/model/BlockNumber/BlockNumber.d.ts +2 -2
- package/dist/neutral/model/BlockNumber/BlockNumber.d.ts.map +1 -1
- package/dist/neutral/model/BlockNumber/EthBlockNumber.d.ts +2 -2
- package/dist/neutral/model/BlockNumber/EthBlockNumber.d.ts.map +1 -1
- package/dist/neutral/model/BlockNumber/XL1BlockNumber.d.ts +2 -2
- package/dist/neutral/model/BlockNumber/XL1BlockNumber.d.ts.map +1 -1
- package/dist/neutral/model/BlockRange/BlockRange.d.ts +3 -3
- package/dist/neutral/model/BlockRange/BlockRange.d.ts.map +1 -1
- package/dist/neutral/model/BlockRange/EthBlockRange.d.ts +3 -3
- package/dist/neutral/model/BlockRange/EthBlockRange.d.ts.map +1 -1
- package/dist/neutral/model/BlockRange/Range.d.ts +2 -2
- package/dist/neutral/model/BlockRange/Range.d.ts.map +1 -1
- package/dist/neutral/model/BlockRange/XL1BlockRange.d.ts +3 -3
- package/dist/neutral/model/BlockRange/XL1BlockRange.d.ts.map +1 -1
- package/dist/neutral/model/index.d.ts +0 -1
- package/dist/neutral/model/index.d.ts.map +1 -1
- package/dist/neutral/payload/elevatable/TransferPayload.d.ts +12 -19
- package/dist/neutral/payload/elevatable/TransferPayload.d.ts.map +1 -1
- package/package.json +23 -18
- package/src/block/AllowedBlockPayload.ts +1 -1
- package/src/model/BlockNumber/BlockNumber.ts +1 -1
- package/src/model/BlockNumber/EthBlockNumber.ts +1 -1
- package/src/model/BlockNumber/XL1BlockNumber.ts +1 -1
- package/src/model/BlockRange/BlockRange.ts +3 -3
- package/src/model/BlockRange/EthBlockRange.ts +3 -3
- package/src/model/BlockRange/Range.ts +2 -3
- package/src/model/BlockRange/XL1BlockRange.ts +3 -3
- package/src/model/index.ts +0 -1
- package/src/payload/elevatable/TransferPayload.ts +2 -13
- package/dist/neutral/amount/specs/Xl1Amount.spec.d.ts +0 -2
- package/dist/neutral/amount/specs/Xl1Amount.spec.d.ts.map +0 -1
- package/dist/neutral/model/zod/Config.d.ts +0 -6
- package/dist/neutral/model/zod/Config.d.ts.map +0 -1
- package/dist/neutral/model/zod/index.d.ts +0 -5
- package/dist/neutral/model/zod/index.d.ts.map +0 -1
- package/dist/neutral/model/zod/zodAsFactory.d.ts +0 -7
- package/dist/neutral/model/zod/zodAsFactory.d.ts.map +0 -1
- package/dist/neutral/model/zod/zodIsFactory.d.ts +0 -3
- package/dist/neutral/model/zod/zodIsFactory.d.ts.map +0 -1
- package/dist/neutral/model/zod/zodToFactory.d.ts +0 -6
- package/dist/neutral/model/zod/zodToFactory.d.ts.map +0 -1
- package/dist/neutral/payload/elevatable/Bridge/spec/Bridge.test.d.ts +0 -2
- package/dist/neutral/payload/elevatable/Bridge/spec/Bridge.test.d.ts.map +0 -1
- package/src/amount/specs/Xl1Amount.spec.ts +0 -181
- package/src/model/zod/Config.ts +0 -7
- package/src/model/zod/index.ts +0 -4
- package/src/model/zod/zodAsFactory.ts +0 -43
- package/src/model/zod/zodIsFactory.ts +0 -5
- package/src/model/zod/zodToFactory.ts +0 -7
- package/src/payload/elevatable/Bridge/spec/Bridge.test.ts +0 -128
- package/src/payload/elevatable/Bridge/spec/__snapshots__/Bridge.test.ts.snap +0 -71
package/src/model/zod/Config.ts
DELETED
package/src/model/zod/index.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { AssertConfig } from '@xylabs/hex'
|
|
2
|
-
import { assertError } from '@xylabs/hex'
|
|
3
|
-
import type z from 'zod'
|
|
4
|
-
|
|
5
|
-
import type { ZodFactoryConfig } from './Config.ts'
|
|
6
|
-
|
|
7
|
-
export function zodAsFactory<T>(zod: z.ZodType<T>, name: string) {
|
|
8
|
-
function asFunc(value: unknown): T | undefined
|
|
9
|
-
function asFunc(value: unknown, assert: ZodFactoryConfig): T
|
|
10
|
-
function asFunc(value: unknown, assert?: ZodFactoryConfig): T | undefined {
|
|
11
|
-
const result = zod.safeParse(value)
|
|
12
|
-
if (result.success) {
|
|
13
|
-
return result.data
|
|
14
|
-
}
|
|
15
|
-
if (assert !== undefined) {
|
|
16
|
-
let assertConfig: AssertConfig
|
|
17
|
-
switch (typeof assert) {
|
|
18
|
-
case 'string': {
|
|
19
|
-
assertConfig = `[${name}][${value}] ${assert}`
|
|
20
|
-
break
|
|
21
|
-
}
|
|
22
|
-
case 'object': {
|
|
23
|
-
assertConfig = `[${name}][${assert.name}][${value}] ${result.error.message}`
|
|
24
|
-
break
|
|
25
|
-
}
|
|
26
|
-
case 'boolean': {
|
|
27
|
-
assertConfig = `[${name}][${value}] ${result.error.message}`
|
|
28
|
-
break
|
|
29
|
-
}
|
|
30
|
-
case 'function': {
|
|
31
|
-
assertConfig = assert(value, result.error.message)
|
|
32
|
-
break
|
|
33
|
-
}
|
|
34
|
-
default: {
|
|
35
|
-
assertConfig = true
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return assertError(value, assertConfig, result.error.message)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return asFunc
|
|
43
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { toAddress, toHex } from '@xylabs/hex'
|
|
2
|
-
import {
|
|
3
|
-
describe, expect, it,
|
|
4
|
-
} from 'vitest'
|
|
5
|
-
|
|
6
|
-
import type { ChainId } from '../../../../model/index.ts'
|
|
7
|
-
import { AttoXL1ConvertFactor } from '../../../../xl1/index.ts'
|
|
8
|
-
import type { BridgeDestinationObservationFields } from '../BridgeDestinationObservation.ts'
|
|
9
|
-
import type { BridgeIntentFields } from '../BridgeIntent.ts'
|
|
10
|
-
import type { BridgeSourceObservationFields } from '../BridgeSourceObservation.ts'
|
|
11
|
-
|
|
12
|
-
describe('Bridge', () => {
|
|
13
|
-
const srcAmount = toHex(100n * AttoXL1ConvertFactor.xl1) // 100 XL1 in AttoXL1
|
|
14
|
-
const destAmount = srcAmount // 1:1 for test
|
|
15
|
-
|
|
16
|
-
const xl1ChainId: ChainId = toHex('dd381fbb392c85160d8b0453e446757b12384046')
|
|
17
|
-
const ethChainId = toHex('0x1')
|
|
18
|
-
|
|
19
|
-
const xl1Address = toAddress('1111111111111111111111111111111111111111')
|
|
20
|
-
const ethAddress = toAddress('0x2222222222222222222222222222222222222222')
|
|
21
|
-
|
|
22
|
-
const bridgeableTokenContract = toHex('0x3333333333333333333333333333333333333333')
|
|
23
|
-
|
|
24
|
-
const nonce = 'd5eeff33-d5bc-4aca-9ecb-3406c02a5dc4'
|
|
25
|
-
|
|
26
|
-
const xl1TxHash = toHex('0x4444444444444444444444444444444444444444444444444444444444444444') // Some XL1 tx hash
|
|
27
|
-
const ethTxHash = toHex('0x5555555555555555555555555555555555555555555555555555555555555555') // Some Eth tx hash
|
|
28
|
-
|
|
29
|
-
describe('XL1 to ETH', () => {
|
|
30
|
-
it('Sender issues BridgeIntent', () => {
|
|
31
|
-
const intent: BridgeIntentFields = {
|
|
32
|
-
// Source
|
|
33
|
-
src: xl1ChainId, // From XL1
|
|
34
|
-
srcAddress: xl1Address, // From XL1 sender
|
|
35
|
-
srcAmount,
|
|
36
|
-
srcToken: xl1ChainId, // In XL1
|
|
37
|
-
|
|
38
|
-
// Destination
|
|
39
|
-
dest: ethChainId, // To Ethereum
|
|
40
|
-
destAddress: ethAddress,
|
|
41
|
-
destAmount,
|
|
42
|
-
destToken: bridgeableTokenContract,
|
|
43
|
-
|
|
44
|
-
// Details
|
|
45
|
-
nonce,
|
|
46
|
-
}
|
|
47
|
-
expect(intent).toMatchSnapshot()
|
|
48
|
-
})
|
|
49
|
-
it('BridgeObservation (XL1 Side)', () => {
|
|
50
|
-
const observation: BridgeSourceObservationFields = {
|
|
51
|
-
// Source
|
|
52
|
-
src: xl1ChainId, // From XL1
|
|
53
|
-
srcAddress: xl1Address, // From XL1 sender
|
|
54
|
-
srcAmount,
|
|
55
|
-
srcToken: xl1ChainId, // In XL1
|
|
56
|
-
|
|
57
|
-
// Destination
|
|
58
|
-
dest: ethChainId, // To Ethereum
|
|
59
|
-
destAddress: ethAddress,
|
|
60
|
-
destAmount,
|
|
61
|
-
destToken: bridgeableTokenContract,
|
|
62
|
-
|
|
63
|
-
// Observation
|
|
64
|
-
srcConfirmation: xl1TxHash,
|
|
65
|
-
}
|
|
66
|
-
expect(observation).toMatchSnapshot()
|
|
67
|
-
})
|
|
68
|
-
it('BridgeObservation (ETH Side)', () => {
|
|
69
|
-
const observation: BridgeDestinationObservationFields = {
|
|
70
|
-
// Source
|
|
71
|
-
src: xl1ChainId, // From XL1
|
|
72
|
-
srcAddress: xl1Address, // From XL1 sender
|
|
73
|
-
srcAmount,
|
|
74
|
-
srcToken: xl1ChainId, // In XL1
|
|
75
|
-
|
|
76
|
-
// Destination
|
|
77
|
-
dest: ethChainId, // To Ethereum
|
|
78
|
-
destAddress: ethAddress,
|
|
79
|
-
destAmount,
|
|
80
|
-
destToken: bridgeableTokenContract,
|
|
81
|
-
|
|
82
|
-
// Observation
|
|
83
|
-
destConfirmation: ethTxHash,
|
|
84
|
-
}
|
|
85
|
-
expect(observation).toMatchSnapshot()
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
describe('ETH to XL1', () => {
|
|
89
|
-
it('BridgeObservation (ETH Side)', () => {
|
|
90
|
-
const observation: BridgeSourceObservationFields = {
|
|
91
|
-
// Source
|
|
92
|
-
src: ethChainId, // From Ethereum
|
|
93
|
-
srcToken: bridgeableTokenContract, // In Ethereum
|
|
94
|
-
srcAddress: ethAddress, // From Ethereum sender
|
|
95
|
-
srcAmount,
|
|
96
|
-
|
|
97
|
-
// Destination
|
|
98
|
-
dest: xl1ChainId, // To XL1
|
|
99
|
-
destToken: xl1ChainId, // In XL1
|
|
100
|
-
destAddress: xl1Address, // To XL1 Address
|
|
101
|
-
destAmount,
|
|
102
|
-
|
|
103
|
-
// Observation
|
|
104
|
-
srcConfirmation: ethTxHash,
|
|
105
|
-
}
|
|
106
|
-
expect(observation).toMatchSnapshot()
|
|
107
|
-
})
|
|
108
|
-
it('BridgeObservation (XL1 Side)', () => {
|
|
109
|
-
const observation: BridgeDestinationObservationFields = {
|
|
110
|
-
// Source
|
|
111
|
-
src: ethChainId, // From Ethereum
|
|
112
|
-
srcToken: bridgeableTokenContract, // In Ethereum
|
|
113
|
-
srcAddress: ethAddress, // From Ethereum sender
|
|
114
|
-
srcAmount,
|
|
115
|
-
|
|
116
|
-
// Destination
|
|
117
|
-
dest: xl1ChainId, // To XL1
|
|
118
|
-
destToken: xl1ChainId, // In XL1
|
|
119
|
-
destAddress: xl1Address, // To XL1 Address
|
|
120
|
-
destAmount,
|
|
121
|
-
|
|
122
|
-
// Observation
|
|
123
|
-
destConfirmation: xl1TxHash,
|
|
124
|
-
}
|
|
125
|
-
expect(observation).toMatchSnapshot()
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
})
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`Bridge > ETH to XL1 > BridgeObservation (ETH Side) 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"dest": "dd381fbb392c85160d8b0453e446757b12384046",
|
|
6
|
-
"destAddress": "1111111111111111111111111111111111111111",
|
|
7
|
-
"destAmount": "056bc75e2d63100000",
|
|
8
|
-
"destToken": "dd381fbb392c85160d8b0453e446757b12384046",
|
|
9
|
-
"src": "01",
|
|
10
|
-
"srcAddress": "2222222222222222222222222222222222222222",
|
|
11
|
-
"srcAmount": "056bc75e2d63100000",
|
|
12
|
-
"srcConfirmation": "5555555555555555555555555555555555555555555555555555555555555555",
|
|
13
|
-
"srcToken": "3333333333333333333333333333333333333333",
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
exports[`Bridge > ETH to XL1 > BridgeObservation (XL1 Side) 1`] = `
|
|
18
|
-
{
|
|
19
|
-
"dest": "dd381fbb392c85160d8b0453e446757b12384046",
|
|
20
|
-
"destAddress": "1111111111111111111111111111111111111111",
|
|
21
|
-
"destAmount": "056bc75e2d63100000",
|
|
22
|
-
"destConfirmation": "4444444444444444444444444444444444444444444444444444444444444444",
|
|
23
|
-
"destToken": "dd381fbb392c85160d8b0453e446757b12384046",
|
|
24
|
-
"src": "01",
|
|
25
|
-
"srcAddress": "2222222222222222222222222222222222222222",
|
|
26
|
-
"srcAmount": "056bc75e2d63100000",
|
|
27
|
-
"srcToken": "3333333333333333333333333333333333333333",
|
|
28
|
-
}
|
|
29
|
-
`;
|
|
30
|
-
|
|
31
|
-
exports[`Bridge > XL1 to ETH > BridgeObservation (ETH Side) 1`] = `
|
|
32
|
-
{
|
|
33
|
-
"dest": "01",
|
|
34
|
-
"destAddress": "2222222222222222222222222222222222222222",
|
|
35
|
-
"destAmount": "056bc75e2d63100000",
|
|
36
|
-
"destConfirmation": "5555555555555555555555555555555555555555555555555555555555555555",
|
|
37
|
-
"destToken": "3333333333333333333333333333333333333333",
|
|
38
|
-
"src": "dd381fbb392c85160d8b0453e446757b12384046",
|
|
39
|
-
"srcAddress": "1111111111111111111111111111111111111111",
|
|
40
|
-
"srcAmount": "056bc75e2d63100000",
|
|
41
|
-
"srcToken": "dd381fbb392c85160d8b0453e446757b12384046",
|
|
42
|
-
}
|
|
43
|
-
`;
|
|
44
|
-
|
|
45
|
-
exports[`Bridge > XL1 to ETH > BridgeObservation (XL1 Side) 1`] = `
|
|
46
|
-
{
|
|
47
|
-
"dest": "01",
|
|
48
|
-
"destAddress": "2222222222222222222222222222222222222222",
|
|
49
|
-
"destAmount": "056bc75e2d63100000",
|
|
50
|
-
"destToken": "3333333333333333333333333333333333333333",
|
|
51
|
-
"src": "dd381fbb392c85160d8b0453e446757b12384046",
|
|
52
|
-
"srcAddress": "1111111111111111111111111111111111111111",
|
|
53
|
-
"srcAmount": "056bc75e2d63100000",
|
|
54
|
-
"srcConfirmation": "4444444444444444444444444444444444444444444444444444444444444444",
|
|
55
|
-
"srcToken": "dd381fbb392c85160d8b0453e446757b12384046",
|
|
56
|
-
}
|
|
57
|
-
`;
|
|
58
|
-
|
|
59
|
-
exports[`Bridge > XL1 to ETH > Sender issues BridgeIntent 1`] = `
|
|
60
|
-
{
|
|
61
|
-
"dest": "01",
|
|
62
|
-
"destAddress": "2222222222222222222222222222222222222222",
|
|
63
|
-
"destAmount": "056bc75e2d63100000",
|
|
64
|
-
"destToken": "3333333333333333333333333333333333333333",
|
|
65
|
-
"nonce": "d5eeff33-d5bc-4aca-9ecb-3406c02a5dc4",
|
|
66
|
-
"src": "dd381fbb392c85160d8b0453e446757b12384046",
|
|
67
|
-
"srcAddress": "1111111111111111111111111111111111111111",
|
|
68
|
-
"srcAmount": "056bc75e2d63100000",
|
|
69
|
-
"srcToken": "dd381fbb392c85160d8b0453e446757b12384046",
|
|
70
|
-
}
|
|
71
|
-
`;
|