@xyo-network/chain-reward-redemption 1.16.15 → 1.16.17
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/package.json +11 -8
- package/dist/node/modules/DerivedAddressWalletTransferSentinel/spec/DerivedAddressWalletTransferSentinel.spec.d.ts +0 -2
- package/dist/node/modules/DerivedAddressWalletTransferSentinel/spec/DerivedAddressWalletTransferSentinel.spec.d.ts.map +0 -1
- package/src/modules/DerivedAddressWalletTransferSentinel/spec/DerivedAddressWalletTransferSentinel.spec.ts +0 -147
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/chain-reward-redemption",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.17",
|
|
4
4
|
"description": "XYO Layer One Rewards",
|
|
5
5
|
"homepage": "https://xylabs.com",
|
|
6
6
|
"bugs": {
|
|
@@ -33,7 +33,10 @@
|
|
|
33
33
|
"types": "./dist/node/index.d.ts",
|
|
34
34
|
"files": [
|
|
35
35
|
"dist",
|
|
36
|
-
"src"
|
|
36
|
+
"src",
|
|
37
|
+
"!**/*.bench.*",
|
|
38
|
+
"!**/*.spec.*",
|
|
39
|
+
"!**/*.test.*"
|
|
37
40
|
],
|
|
38
41
|
"scripts": {
|
|
39
42
|
"build-tests": "tsc --noEmit --lib dom,esnext",
|
|
@@ -58,8 +61,8 @@
|
|
|
58
61
|
"@xyo-network/archivist-view": "~5.1.23",
|
|
59
62
|
"@xyo-network/bios": "~7.1.1",
|
|
60
63
|
"@xyo-network/boundwitness-model": "~5.1.23",
|
|
61
|
-
"@xyo-network/chain-protocol": "~1.16.
|
|
62
|
-
"@xyo-network/chain-telemetry": "~1.16.
|
|
64
|
+
"@xyo-network/chain-protocol": "~1.16.17",
|
|
65
|
+
"@xyo-network/chain-telemetry": "~1.16.17",
|
|
63
66
|
"@xyo-network/manifest-model": "~5.1.23",
|
|
64
67
|
"@xyo-network/manifest-wrapper": "~5.1.23",
|
|
65
68
|
"@xyo-network/module-abstract": "~5.1.23",
|
|
@@ -74,8 +77,8 @@
|
|
|
74
77
|
"@xyo-network/wallet": "~5.1.23",
|
|
75
78
|
"@xyo-network/wallet-model": "~5.1.23",
|
|
76
79
|
"@xyo-network/xl1-protocol": "~1.13.11",
|
|
77
|
-
"@xyo-network/xl1-protocol-sdk": "~1.16.
|
|
78
|
-
"@xyo-network/xl1-rpc": "~1.16.
|
|
80
|
+
"@xyo-network/xl1-protocol-sdk": "~1.16.17",
|
|
81
|
+
"@xyo-network/xl1-rpc": "~1.16.17",
|
|
79
82
|
"async-mutex": "~0.5.0",
|
|
80
83
|
"compression": "~1.8.1",
|
|
81
84
|
"cors": "~2.8.5",
|
|
@@ -100,8 +103,8 @@
|
|
|
100
103
|
"@xyo-network/archivist-mongodb": "~5.1.23",
|
|
101
104
|
"@xyo-network/bios-model": "~7.1.1",
|
|
102
105
|
"@xyo-network/boundwitness-builder": "~5.1.23",
|
|
103
|
-
"@xyo-network/chain-protocol": "~1.16.
|
|
104
|
-
"@xyo-network/chain-services": "~1.16.
|
|
106
|
+
"@xyo-network/chain-protocol": "~1.16.17",
|
|
107
|
+
"@xyo-network/chain-services": "~1.16.17",
|
|
105
108
|
"@xyo-network/manifest-wrapper": "~5.1.23",
|
|
106
109
|
"@xyo-network/module-abstract": "~5.1.23",
|
|
107
110
|
"@xyo-network/module-abstract-mongodb": "~5.1.23",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DerivedAddressWalletTransferSentinel.spec.d.ts","sourceRoot":"","sources":["../../../../../src/modules/DerivedAddressWalletTransferSentinel/spec/DerivedAddressWalletTransferSentinel.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import { toEthAddress, toHex } from '@xylabs/sdk-js'
|
|
4
|
-
import { Account } from '@xyo-network/account'
|
|
5
|
-
import { TestChainId } from '@xyo-network/chain-protocol'
|
|
6
|
-
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
7
|
-
import {
|
|
8
|
-
asAttoXL1, asXL1BlockNumber, AttoXL1ConvertFactor,
|
|
9
|
-
} from '@xyo-network/xl1-protocol'
|
|
10
|
-
import type {
|
|
11
|
-
EIP712DataPayload, XyoGatewayRunner, XyoRunner, XyoViewer,
|
|
12
|
-
} from '@xyo-network/xl1-protocol-sdk'
|
|
13
|
-
import {
|
|
14
|
-
EIP712DataPayloadSchema, signEIP712Message,
|
|
15
|
-
SimpleXyoGatewayRunner,
|
|
16
|
-
SimpleXyoSigner,
|
|
17
|
-
} from '@xyo-network/xl1-protocol-sdk'
|
|
18
|
-
import { XyoBaseConnection } from '@xyo-network/xl1-rpc'
|
|
19
|
-
import { Wallet } from 'ethers'
|
|
20
|
-
import {
|
|
21
|
-
beforeEach, describe, expect, it,
|
|
22
|
-
} from 'vitest'
|
|
23
|
-
import { mock } from 'vitest-mock-extended'
|
|
24
|
-
|
|
25
|
-
import { DerivedAddressWalletTransferSentinel } from '../DerivedAddressWalletTransferSentinel.ts'
|
|
26
|
-
|
|
27
|
-
describe('DerivedAddressWalletTransferSentinel', () => {
|
|
28
|
-
let sentinel: DerivedAddressWalletTransferSentinel
|
|
29
|
-
let gateway: XyoGatewayRunner
|
|
30
|
-
const nbf = 1000
|
|
31
|
-
const exp = 2000
|
|
32
|
-
const currentBlockNumber = asXL1BlockNumber(Math.floor((nbf + exp) / 2), true)
|
|
33
|
-
const accountBalanceXl1 = 10n
|
|
34
|
-
const accountBalance = asAttoXL1(accountBalanceXl1 * AttoXL1ConvertFactor.xl1)
|
|
35
|
-
const domain = {
|
|
36
|
-
name: 'XL1 Nodeless Staking',
|
|
37
|
-
version: '1',
|
|
38
|
-
chainId: 1,
|
|
39
|
-
}
|
|
40
|
-
const types = {
|
|
41
|
-
'Claim Confirmation': [
|
|
42
|
-
{
|
|
43
|
-
name: 'From',
|
|
44
|
-
type: 'address',
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: 'To XL1 Address (shortened)',
|
|
48
|
-
type: 'string',
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: 'XL1 Amount',
|
|
52
|
-
type: 'string',
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: 'XL1 Not before block',
|
|
56
|
-
type: 'uint256',
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: 'XL1 Not after block',
|
|
60
|
-
type: 'uint256',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: 'To XL1 Address',
|
|
64
|
-
type: 'string',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
name: 'XL1 Amount (Hex)',
|
|
68
|
-
type: 'string',
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
beforeEach(async () => {
|
|
74
|
-
const singerAccount = await Account.random()
|
|
75
|
-
const signer = new SimpleXyoSigner(singerAccount)
|
|
76
|
-
const viewer = mock<XyoViewer>()
|
|
77
|
-
viewer.chainId.mockResolvedValue(TestChainId)
|
|
78
|
-
viewer.currentBlockNumber.mockResolvedValue(currentBlockNumber)
|
|
79
|
-
viewer.accountBalance.mockResolvedValue(accountBalance)
|
|
80
|
-
const runner = mock<XyoRunner>()
|
|
81
|
-
runner.broadcastTransaction.mockImplementation(async tx => await PayloadBuilder.hash(tx[0]))
|
|
82
|
-
const connection = new XyoBaseConnection({ runner, viewer })
|
|
83
|
-
gateway = new SimpleXyoGatewayRunner(connection, signer)
|
|
84
|
-
sentinel = await DerivedAddressWalletTransferSentinel.create({ gateway, account: 'random' })
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
describe('with valid inputs', () => {
|
|
88
|
-
it('should submit tx', async () => {
|
|
89
|
-
// Arrange
|
|
90
|
-
const signer = Wallet.createRandom()
|
|
91
|
-
const address = await signer.getAddress()
|
|
92
|
-
const to = await Account.random()
|
|
93
|
-
const payload: EIP712DataPayload = {
|
|
94
|
-
schema: EIP712DataPayloadSchema,
|
|
95
|
-
domain,
|
|
96
|
-
types,
|
|
97
|
-
values: {
|
|
98
|
-
'From': toEthAddress(address),
|
|
99
|
-
'To XL1 Address': to.address,
|
|
100
|
-
'To XL1 Address (shortened)': to.address.slice(0, 10),
|
|
101
|
-
'XL1 Amount': accountBalanceXl1.toString(),
|
|
102
|
-
'XL1 Amount (Hex)': toHex(accountBalance),
|
|
103
|
-
'XL1 Not after block': 2000,
|
|
104
|
-
'XL1 Not before block': 1000,
|
|
105
|
-
},
|
|
106
|
-
}
|
|
107
|
-
const signature = await signEIP712Message(signer, payload)
|
|
108
|
-
|
|
109
|
-
// Act
|
|
110
|
-
const result = await sentinel.report([payload, signature])
|
|
111
|
-
|
|
112
|
-
// Assert
|
|
113
|
-
expect(result).toBeDefined()
|
|
114
|
-
expect(result.length).toBeGreaterThan(0)
|
|
115
|
-
})
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
describe('with invalid inputs', () => {
|
|
119
|
-
it('should not submit tx', async () => {
|
|
120
|
-
// Arrange
|
|
121
|
-
const signer = Wallet.createRandom()
|
|
122
|
-
const address = await signer.getAddress()
|
|
123
|
-
const to = await Account.random()
|
|
124
|
-
const payload: EIP712DataPayload = {
|
|
125
|
-
schema: EIP712DataPayloadSchema,
|
|
126
|
-
domain,
|
|
127
|
-
types,
|
|
128
|
-
values: {
|
|
129
|
-
'From': toEthAddress(address),
|
|
130
|
-
'To XL1 Address': to.address,
|
|
131
|
-
'To XL1 Address (shortened)': to.address.slice(0, 10),
|
|
132
|
-
'XL1 Amount': accountBalanceXl1.toString(),
|
|
133
|
-
'XL1 Amount (Hex)': toHex(accountBalance),
|
|
134
|
-
'XL1 Not after block': 2000,
|
|
135
|
-
'XL1 Not before block': 1000,
|
|
136
|
-
},
|
|
137
|
-
}
|
|
138
|
-
const signature = await signEIP712Message(signer, payload)
|
|
139
|
-
// Tamper with the signature to make it invalid
|
|
140
|
-
signature.signature
|
|
141
|
-
= '0xfda3a8b0bacb1c6573f46757e04214153850c5bd125faef4f1ca6756f0d4e8f9799591e101c295b1ed48a607a7acf2de96a6281c49ab3697b392a7201a9beb911b'
|
|
142
|
-
|
|
143
|
-
// Act
|
|
144
|
-
await expect(sentinel.report([payload, signature])).rejects.toThrowError()
|
|
145
|
-
})
|
|
146
|
-
})
|
|
147
|
-
})
|