@xyo-network/crypto-address-transaction-history-plugin 4.2.0 → 5.0.1
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/crypto-address-transaction-history-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -28,23 +28,27 @@
|
|
|
28
28
|
},
|
|
29
29
|
"module": "dist/neutral/index.mjs",
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"src"
|
|
34
|
+
],
|
|
31
35
|
"dependencies": {
|
|
32
|
-
"@xylabs/assert": "
|
|
33
|
-
"@xyo-network/abstract-witness": "
|
|
34
|
-
"@xyo-network/crypto-address-transaction-history-payload-plugin": "
|
|
35
|
-
"@xyo-network/module-model": "
|
|
36
|
-
"@xyo-network/payload-model": "
|
|
37
|
-
"@xyo-network/payloadset-plugin": "
|
|
38
|
-
"@xyo-network/witness-model": "
|
|
39
|
-
"ethers": "
|
|
36
|
+
"@xylabs/assert": "~5.0.7",
|
|
37
|
+
"@xyo-network/abstract-witness": "~5.0.2",
|
|
38
|
+
"@xyo-network/crypto-address-transaction-history-payload-plugin": "~5.0.1",
|
|
39
|
+
"@xyo-network/module-model": "~5.0.2",
|
|
40
|
+
"@xyo-network/payload-model": "~5.0.2",
|
|
41
|
+
"@xyo-network/payloadset-plugin": "~5.0.2",
|
|
42
|
+
"@xyo-network/witness-model": "~5.0.2",
|
|
43
|
+
"ethers": "~6.15.0"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
|
-
"@xylabs/ts-scripts-yarn3": "
|
|
43
|
-
"@xylabs/tsconfig": "
|
|
44
|
-
"@xylabs/vitest-extended": "
|
|
45
|
-
"@xyo-network/payload-wrapper": "
|
|
46
|
-
"typescript": "
|
|
47
|
-
"vitest": "
|
|
46
|
+
"@xylabs/ts-scripts-yarn3": "~7.1.0",
|
|
47
|
+
"@xylabs/tsconfig": "~7.1.0",
|
|
48
|
+
"@xylabs/vitest-extended": "~5.0.7",
|
|
49
|
+
"@xyo-network/payload-wrapper": "~5.0.2",
|
|
50
|
+
"typescript": "~5.9.2",
|
|
51
|
+
"vitest": "~3.2.4"
|
|
48
52
|
},
|
|
49
53
|
"publishConfig": {
|
|
50
54
|
"access": "public"
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import type { AccessList, Transaction } from '@xyo-network/crypto-address-transaction-history-payload-plugin'
|
|
4
|
+
import { EtherscanProvider } from 'ethers'
|
|
5
|
+
import {
|
|
6
|
+
describe, expect,
|
|
7
|
+
test,
|
|
8
|
+
} from 'vitest'
|
|
9
|
+
|
|
10
|
+
import { getTransactionsForAddress } from '../getTransactionsForAddress.ts'
|
|
11
|
+
|
|
12
|
+
const validateAccessList = (accessList: AccessList) => {
|
|
13
|
+
expect(accessList).toBeArray()
|
|
14
|
+
for (const list of accessList) {
|
|
15
|
+
expect(list.address).toBeString()
|
|
16
|
+
expect(list.storageKeys).toBeArray()
|
|
17
|
+
for (const storageKey of list.storageKeys) {
|
|
18
|
+
expect(storageKey).toBeString()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line complexity
|
|
24
|
+
const validateTransaction = (t: Transaction) => {
|
|
25
|
+
if (t?.accessList) validateAccessList(t.accessList)
|
|
26
|
+
if (t?.blockHash !== undefined) expect(t.blockHash).toBeString()
|
|
27
|
+
if (t?.blockNumber !== undefined) expect(t.blockNumber).toBeNumber()
|
|
28
|
+
expect(t.chainId).toBeNumber()
|
|
29
|
+
expect(t.confirmations).toBeNumber()
|
|
30
|
+
expect(t.data).toBeString()
|
|
31
|
+
expect(t.from).toBeString()
|
|
32
|
+
expect(t.gasLimit).toBeString()
|
|
33
|
+
if (t?.gasPrice !== undefined) expect(t.gasPrice).toBeString()
|
|
34
|
+
expect(t.hash).toBeString()
|
|
35
|
+
if (t?.maxFeePerGas !== undefined) expect(t.maxFeePerGas).toBeString()
|
|
36
|
+
if (t?.maxPriorityFeePerGas !== undefined) expect(t.maxPriorityFeePerGas).toBeString()
|
|
37
|
+
expect(t.nonce).toBeNumber()
|
|
38
|
+
if (t?.r !== undefined) expect(t.r).toBeString()
|
|
39
|
+
if (t?.raw !== undefined) expect(t.raw).toBeString()
|
|
40
|
+
if (t?.s !== undefined) expect(t.s).toBeString()
|
|
41
|
+
if (t?.timestamp !== undefined) expect(t.timestamp).toBeNumber()
|
|
42
|
+
if (t?.to !== undefined) expect(t.to).toBeString()
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
44
|
+
if (t?.type !== undefined) t.type === null ? expect(t.type).toBeNull() : expect(t.type).toBeNumber()
|
|
45
|
+
if (t?.v !== undefined) expect(t.v).toBeNumber()
|
|
46
|
+
if (t?.value !== undefined) expect(t.value).toBeString()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
describe.skipIf(!process.env.ETHERSCAN_API_KEY)('getTransactionsForAddress', () => {
|
|
50
|
+
const address = '0x35C556C8e97509Bf1f6D286BB0137512E11711a6'
|
|
51
|
+
const network = 'homestead'
|
|
52
|
+
const apiKey = process.env.ETHERSCAN_API_KEY
|
|
53
|
+
const provider = new EtherscanProvider(network, apiKey)
|
|
54
|
+
test('observe', async () => {
|
|
55
|
+
const transactions = await getTransactionsForAddress(address, provider)
|
|
56
|
+
expect(transactions.length).toBeGreaterThan(0)
|
|
57
|
+
for (const transaction of transactions) {
|
|
58
|
+
validateTransaction(transaction)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import { PayloadSetPluginResolver } from '@xyo-network/payloadset-plugin'
|
|
4
|
+
import {
|
|
5
|
+
describe, expect,
|
|
6
|
+
test,
|
|
7
|
+
} from 'vitest'
|
|
8
|
+
|
|
9
|
+
import { AddressTransactionHistoryPlugin } from '../Plugin.ts'
|
|
10
|
+
|
|
11
|
+
describe('AddressTransactionHistoryPlugin', () => {
|
|
12
|
+
test('Add to Resolver', async () => {
|
|
13
|
+
const plugin = AddressTransactionHistoryPlugin()
|
|
14
|
+
const resolver = await new PayloadSetPluginResolver().register(plugin)
|
|
15
|
+
expect(resolver.resolve(plugin.set)).toBeDefined()
|
|
16
|
+
})
|
|
17
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AddressTransactionHistoryWitnessConfigSchema,
|
|
5
|
+
isAddressTransactionHistoryPayload,
|
|
6
|
+
} from '@xyo-network/crypto-address-transaction-history-payload-plugin'
|
|
7
|
+
import { PayloadWrapper } from '@xyo-network/payload-wrapper'
|
|
8
|
+
import { EtherscanProvider } from 'ethers'
|
|
9
|
+
import {
|
|
10
|
+
describe, expect,
|
|
11
|
+
test,
|
|
12
|
+
} from 'vitest'
|
|
13
|
+
|
|
14
|
+
import { AddressTransactionHistoryWitness } from '../Witness.ts'
|
|
15
|
+
|
|
16
|
+
describe.skipIf(!process.env.ETHERSCAN_API_KEY)('AddressTransactionHistoryWitness', () => {
|
|
17
|
+
const address = '0x35C556C8e97509Bf1f6D286BB0137512E11711a6'
|
|
18
|
+
const network = 'homestead'
|
|
19
|
+
const apiKey = process.env.ETHERSCAN_API_KEY
|
|
20
|
+
const provider = new EtherscanProvider(network, apiKey)
|
|
21
|
+
test('observe', async () => {
|
|
22
|
+
const witness = await AddressTransactionHistoryWitness.create({
|
|
23
|
+
config: { address, schema: AddressTransactionHistoryWitnessConfigSchema },
|
|
24
|
+
provider,
|
|
25
|
+
})
|
|
26
|
+
const observation = await witness.observe()
|
|
27
|
+
const transactions = observation.filter(isAddressTransactionHistoryPayload)
|
|
28
|
+
expect(transactions.length).toBeGreaterThan(0)
|
|
29
|
+
expect(observation.length).toEqual(transactions.length)
|
|
30
|
+
for (const transaction of transactions) {
|
|
31
|
+
const wrapped = PayloadWrapper.wrap(transaction)
|
|
32
|
+
expect(await wrapped.getValid()).toBe(true)
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
})
|