@xyo-network/crypto-address-transaction-history-plugin 4.1.1 → 5.0.0
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/browser/index.d.ts +5 -38
- package/dist/neutral/index.d.ts +5 -38
- package/dist/node/index.d.ts +5 -38
- package/package.json +16 -13
- package/src/lib/spec/getTransactionsForAddress.spec.ts +61 -0
- package/src/spec/Plugin.spec.ts +17 -0
- package/src/spec/Witness.spec.ts +35 -0
- package/typedoc.json +0 -5
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
7
|
-
import { Schema, Payload } from '@xyo-network/payload-model';
|
|
8
|
-
|
|
9
|
-
type AddressTransactionHistoryWitnessConfig = WitnessConfig<{
|
|
10
|
-
address?: string;
|
|
11
|
-
schema: AddressTransactionHistoryWitnessConfigSchema;
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
/** @deprecated - no longer supported by EtherScan */
|
|
15
|
-
declare const getTransactionsForAddress: (
|
|
16
|
-
/**
|
|
17
|
-
* The address of the wallet to search for NFTs
|
|
18
|
-
*/
|
|
19
|
-
_publicAddress: string,
|
|
20
|
-
/**
|
|
21
|
-
* The ethers provider to use to search
|
|
22
|
-
*/
|
|
23
|
-
_provider: EtherscanProvider) => Promise<Transaction[]>;
|
|
24
|
-
|
|
25
|
-
interface AddressTransactionHistoryWitnessParams extends WitnessParams<AnyConfigSchema<AddressTransactionHistoryWitnessConfig>> {
|
|
26
|
-
provider?: EtherscanProvider;
|
|
27
|
-
}
|
|
28
|
-
declare class AddressTransactionHistoryWitness<TParams extends AddressTransactionHistoryWitnessParams = AddressTransactionHistoryWitnessParams> extends AbstractWitness<TParams> {
|
|
29
|
-
static readonly configSchemas: Schema[];
|
|
30
|
-
static readonly defaultConfigSchema: Schema;
|
|
31
|
-
protected get provider(): EtherscanProvider;
|
|
32
|
-
protected observeHandler(): Promise<Payload[]>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
declare const AddressTransactionHistoryPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<AddressTransactionHistoryWitness<AddressTransactionHistoryWitnessParams>>;
|
|
36
|
-
|
|
37
|
-
export { AddressTransactionHistoryPlugin, AddressTransactionHistoryWitness, AddressTransactionHistoryPlugin as default, getTransactionsForAddress };
|
|
38
|
-
export type { AddressTransactionHistoryWitnessConfig, AddressTransactionHistoryWitnessParams };
|
|
1
|
+
export * from './Config.ts';
|
|
2
|
+
export * from './lib/index.ts';
|
|
3
|
+
export { AddressTransactionHistoryPlugin, AddressTransactionHistoryPlugin as default } from './Plugin.ts';
|
|
4
|
+
export * from './Witness.ts';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
7
|
-
import { Schema, Payload } from '@xyo-network/payload-model';
|
|
8
|
-
|
|
9
|
-
type AddressTransactionHistoryWitnessConfig = WitnessConfig<{
|
|
10
|
-
address?: string;
|
|
11
|
-
schema: AddressTransactionHistoryWitnessConfigSchema;
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
/** @deprecated - no longer supported by EtherScan */
|
|
15
|
-
declare const getTransactionsForAddress: (
|
|
16
|
-
/**
|
|
17
|
-
* The address of the wallet to search for NFTs
|
|
18
|
-
*/
|
|
19
|
-
_publicAddress: string,
|
|
20
|
-
/**
|
|
21
|
-
* The ethers provider to use to search
|
|
22
|
-
*/
|
|
23
|
-
_provider: EtherscanProvider) => Promise<Transaction[]>;
|
|
24
|
-
|
|
25
|
-
interface AddressTransactionHistoryWitnessParams extends WitnessParams<AnyConfigSchema<AddressTransactionHistoryWitnessConfig>> {
|
|
26
|
-
provider?: EtherscanProvider;
|
|
27
|
-
}
|
|
28
|
-
declare class AddressTransactionHistoryWitness<TParams extends AddressTransactionHistoryWitnessParams = AddressTransactionHistoryWitnessParams> extends AbstractWitness<TParams> {
|
|
29
|
-
static readonly configSchemas: Schema[];
|
|
30
|
-
static readonly defaultConfigSchema: Schema;
|
|
31
|
-
protected get provider(): EtherscanProvider;
|
|
32
|
-
protected observeHandler(): Promise<Payload[]>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
declare const AddressTransactionHistoryPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<AddressTransactionHistoryWitness<AddressTransactionHistoryWitnessParams>>;
|
|
36
|
-
|
|
37
|
-
export { AddressTransactionHistoryPlugin, AddressTransactionHistoryWitness, AddressTransactionHistoryPlugin as default, getTransactionsForAddress };
|
|
38
|
-
export type { AddressTransactionHistoryWitnessConfig, AddressTransactionHistoryWitnessParams };
|
|
1
|
+
export * from './Config.ts';
|
|
2
|
+
export * from './lib/index.ts';
|
|
3
|
+
export { AddressTransactionHistoryPlugin, AddressTransactionHistoryPlugin as default } from './Plugin.ts';
|
|
4
|
+
export * from './Witness.ts';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { AnyConfigSchema } from '@xyo-network/module-model';
|
|
7
|
-
import { Schema, Payload } from '@xyo-network/payload-model';
|
|
8
|
-
|
|
9
|
-
type AddressTransactionHistoryWitnessConfig = WitnessConfig<{
|
|
10
|
-
address?: string;
|
|
11
|
-
schema: AddressTransactionHistoryWitnessConfigSchema;
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
/** @deprecated - no longer supported by EtherScan */
|
|
15
|
-
declare const getTransactionsForAddress: (
|
|
16
|
-
/**
|
|
17
|
-
* The address of the wallet to search for NFTs
|
|
18
|
-
*/
|
|
19
|
-
_publicAddress: string,
|
|
20
|
-
/**
|
|
21
|
-
* The ethers provider to use to search
|
|
22
|
-
*/
|
|
23
|
-
_provider: EtherscanProvider) => Promise<Transaction[]>;
|
|
24
|
-
|
|
25
|
-
interface AddressTransactionHistoryWitnessParams extends WitnessParams<AnyConfigSchema<AddressTransactionHistoryWitnessConfig>> {
|
|
26
|
-
provider?: EtherscanProvider;
|
|
27
|
-
}
|
|
28
|
-
declare class AddressTransactionHistoryWitness<TParams extends AddressTransactionHistoryWitnessParams = AddressTransactionHistoryWitnessParams> extends AbstractWitness<TParams> {
|
|
29
|
-
static readonly configSchemas: Schema[];
|
|
30
|
-
static readonly defaultConfigSchema: Schema;
|
|
31
|
-
protected get provider(): EtherscanProvider;
|
|
32
|
-
protected observeHandler(): Promise<Payload[]>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
declare const AddressTransactionHistoryPlugin: () => _xyo_network_payloadset_plugin.PayloadSetWitnessPlugin<AddressTransactionHistoryWitness<AddressTransactionHistoryWitnessParams>>;
|
|
36
|
-
|
|
37
|
-
export { AddressTransactionHistoryPlugin, AddressTransactionHistoryWitness, AddressTransactionHistoryPlugin as default, getTransactionsForAddress };
|
|
38
|
-
export type { AddressTransactionHistoryWitnessConfig, AddressTransactionHistoryWitnessParams };
|
|
1
|
+
export * from './Config.ts';
|
|
2
|
+
export * from './lib/index.ts';
|
|
3
|
+
export { AddressTransactionHistoryPlugin, AddressTransactionHistoryPlugin as default } from './Plugin.ts';
|
|
4
|
+
export * from './Witness.ts';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
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.0",
|
|
4
4
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -28,22 +28,25 @@
|
|
|
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": "^
|
|
36
|
+
"@xylabs/assert": "^5.0.0",
|
|
37
|
+
"@xyo-network/abstract-witness": "^5.0.0",
|
|
38
|
+
"@xyo-network/crypto-address-transaction-history-payload-plugin": "^5.0.0",
|
|
39
|
+
"@xyo-network/module-model": "^5.0.0",
|
|
40
|
+
"@xyo-network/payload-model": "^5.0.0",
|
|
41
|
+
"@xyo-network/payloadset-plugin": "^5.0.0",
|
|
42
|
+
"@xyo-network/witness-model": "^5.0.0",
|
|
39
43
|
"ethers": "^6.15.0"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.
|
|
43
|
-
"@xylabs/tsconfig": "^7.0.
|
|
44
|
-
"@xylabs/vitest-extended": "^
|
|
45
|
-
"@xyo-network/payload-wrapper": "^
|
|
46
|
-
"knip": "^5.62.0",
|
|
46
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.2",
|
|
47
|
+
"@xylabs/tsconfig": "^7.0.2",
|
|
48
|
+
"@xylabs/vitest-extended": "^5.0.0",
|
|
49
|
+
"@xyo-network/payload-wrapper": "^5.0.0",
|
|
47
50
|
"typescript": "^5.8.3",
|
|
48
51
|
"vitest": "^3.2.4"
|
|
49
52
|
},
|
|
@@ -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
|
+
})
|