@cityofzion/bs-neo3 0.9.0 → 0.9.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/.rush/temp/operation/build/state.json +1 -1
- package/.rush/temp/package-deps_build.json +6 -6
- package/CHANGELOG.json +12 -0
- package/CHANGELOG.md +8 -1
- package/dist/DoraBDSNeo3.js +32 -25
- package/package.json +1 -1
- package/src/DoraBDSNeo3.ts +51 -45
- package/src/__tests__/BDSNeo3.spec.ts +31 -33
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
|
+
"packages/bs-neo3/CHANGELOG.json": "3f3d2b73b8c94585680bd6eea606e773f1cfebd4",
|
|
4
|
+
"packages/bs-neo3/CHANGELOG.md": "b151fbc882d1607cdba6f031e47199ffc331ff04",
|
|
3
5
|
"packages/bs-neo3/jest.config.ts": "d944475db93cbe41a9339187fd94b9962e411c43",
|
|
4
6
|
"packages/bs-neo3/jest.setup.ts": "9a1976a32050616d4d2ee95b1aa21041bc4daca3",
|
|
5
|
-
"packages/bs-neo3/package.json": "
|
|
7
|
+
"packages/bs-neo3/package.json": "ae7b212ffc3e029c08d9770feb0ca8b82bca2a77",
|
|
6
8
|
"packages/bs-neo3/src/BSNeo3.ts": "e7235ac3cb4cef569443b4fbef6cb787972de25b",
|
|
7
|
-
"packages/bs-neo3/src/DoraBDSNeo3.ts": "
|
|
9
|
+
"packages/bs-neo3/src/DoraBDSNeo3.ts": "97e90b38cc18fa6376f4c7bb5996d88c57efa5bc",
|
|
8
10
|
"packages/bs-neo3/src/DoraESNeo3.ts": "c3d36ee5c38cda45c08f517c49976af6d69c5711",
|
|
9
11
|
"packages/bs-neo3/src/FlamingoEDSNeo3.ts": "041aa79e04b2fafb6da71178e7bcc7011f416c1d",
|
|
10
12
|
"packages/bs-neo3/src/GhostMarketNDSNeo3.ts": "d7db2a624cf099fe550fa4a906f6127ca4815cac",
|
|
11
13
|
"packages/bs-neo3/src/RpcBDSNeo3.ts": "11a7425844ab09a11c631281e103d1edeab4a63f",
|
|
12
|
-
"packages/bs-neo3/src/__tests__/BDSNeo3.spec.ts": "
|
|
14
|
+
"packages/bs-neo3/src/__tests__/BDSNeo3.spec.ts": "ac5f20eac558af993c97a8d0d214e2865c916d44",
|
|
13
15
|
"packages/bs-neo3/src/__tests__/BSNeo3.spec.ts": "b1a3d7fca99e984f32bfe0b0a6aed3a25b5de375",
|
|
14
16
|
"packages/bs-neo3/src/__tests__/DoraESNeo3.spec.ts": "450e087014c22b1a289e64dd80ff3e6ddfd8c932",
|
|
15
17
|
"packages/bs-neo3/src/__tests__/FlamingoEDSNeo3.spec.ts": "473b1aafe03031a28a8414dfa681b06f843acdf6",
|
|
@@ -21,9 +23,7 @@
|
|
|
21
23
|
"packages/bs-neo3/src/index.ts": "bad314a9ba14b57075684c9b823a934863bac6b2",
|
|
22
24
|
"packages/bs-neo3/tsconfig.build.json": "4dc23fb9c4c5e4d19a9bc3947a47c523f4bd967c",
|
|
23
25
|
"packages/bs-neo3/tsconfig.json": "77cf2b789e9c665b62792f9992cc81ae86296ef7",
|
|
24
|
-
"packages/bs-neo3/.rush/temp/shrinkwrap-deps.json": "7348b8936da22d117d50dfb8445815a3fabc42cb"
|
|
25
|
-
"packages/bs-neo3/CHANGELOG.json": "01f448101fc9ca122dcd35104e1b43ce51d9da41",
|
|
26
|
-
"packages/bs-neo3/CHANGELOG.md": "6d81b432aaa2c568abc4d8a82df569570040bcbc"
|
|
26
|
+
"packages/bs-neo3/.rush/temp/shrinkwrap-deps.json": "7348b8936da22d117d50dfb8445815a3fabc42cb"
|
|
27
27
|
},
|
|
28
28
|
"arguments": "tsc --project tsconfig.build.json "
|
|
29
29
|
}
|
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neo3",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.9.1",
|
|
6
|
+
"tag": "@cityofzion/bs-neo3_v0.9.1",
|
|
7
|
+
"date": "Wed, 06 Dec 2023 21:51:30 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Prevent the getAllTransaction method from breaking when Dora returns data from v1"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.9.0",
|
|
6
18
|
"tag": "@cityofzion/bs-neo3_v0.9.0",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Change Log - @cityofzion/bs-neo3
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 06 Dec 2023 21:51:30 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.9.1
|
|
6
|
+
Wed, 06 Dec 2023 21:51:30 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Prevent the getAllTransaction method from breaking when Dora returns data from v1
|
|
4
11
|
|
|
5
12
|
## 0.9.0
|
|
6
13
|
Tue, 05 Dec 2023 18:42:10 GMT
|
package/dist/DoraBDSNeo3.js
CHANGED
|
@@ -50,36 +50,42 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
|
50
50
|
getTransactionsByAddress({ address, page = 1, }) {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
52
|
const data = yield NeoRest.addressTXFull(address, page, this.network.type);
|
|
53
|
-
const
|
|
53
|
+
const promises = data.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
54
54
|
var _a, _b;
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const
|
|
55
|
+
const transferPromises = [];
|
|
56
|
+
item.notifications.forEach(({ contract: contractHash, state, event_name: eventName }) => {
|
|
57
|
+
const properties = Array.isArray(state) ? state : state.value;
|
|
58
|
+
if (eventName !== 'Transfer' || (properties.length !== 3 && properties.length !== 4))
|
|
59
|
+
return;
|
|
60
|
+
const promise = () => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
var _a;
|
|
62
|
+
const isAsset = properties.length === 3;
|
|
63
|
+
const from = properties[0].value;
|
|
64
|
+
const to = properties[1].value;
|
|
65
|
+
const convertedFrom = from ? this.convertByteStringToAddress(from) : 'Mint';
|
|
66
|
+
const convertedTo = to ? this.convertByteStringToAddress(to) : 'Burn';
|
|
67
|
+
if (isAsset) {
|
|
68
|
+
const token = yield this.getTokenInfo(contractHash);
|
|
69
|
+
const [, , { value: amount }] = properties;
|
|
70
|
+
return {
|
|
71
|
+
amount: neon_js_1.u.BigInteger.fromNumber(amount).toDecimal((_a = token.decimals) !== null && _a !== void 0 ? _a : 0),
|
|
72
|
+
from: convertedFrom,
|
|
73
|
+
to: convertedTo,
|
|
74
|
+
contractHash,
|
|
75
|
+
type: 'token',
|
|
76
|
+
token,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
66
79
|
return {
|
|
67
|
-
amount: neon_js_1.u.BigInteger.fromNumber(amount).toDecimal((_c = token.decimals) !== null && _c !== void 0 ? _c : 0),
|
|
68
80
|
from: convertedFrom,
|
|
69
81
|
to: convertedTo,
|
|
82
|
+
tokenId: properties[3].value,
|
|
70
83
|
contractHash,
|
|
71
|
-
type: '
|
|
72
|
-
token,
|
|
84
|
+
type: 'nft',
|
|
73
85
|
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
to: convertedTo,
|
|
78
|
-
tokenId: properties[3].value,
|
|
79
|
-
contractHash,
|
|
80
|
-
type: 'nft',
|
|
81
|
-
};
|
|
82
|
-
}));
|
|
86
|
+
});
|
|
87
|
+
transferPromises.push(promise());
|
|
88
|
+
});
|
|
83
89
|
const transfers = yield Promise.all(transferPromises);
|
|
84
90
|
const notifications = item.notifications.map(notification => ({
|
|
85
91
|
eventName: notification.event_name,
|
|
@@ -95,7 +101,8 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
|
95
101
|
transfers,
|
|
96
102
|
notifications,
|
|
97
103
|
};
|
|
98
|
-
}))
|
|
104
|
+
}));
|
|
105
|
+
const transactions = yield Promise.all(promises);
|
|
99
106
|
return {
|
|
100
107
|
totalCount: data.totalCount,
|
|
101
108
|
transactions,
|
package/package.json
CHANGED
package/src/DoraBDSNeo3.ts
CHANGED
|
@@ -55,61 +55,67 @@ export class DoraBDSNeo3 extends RPCBDSNeo3 {
|
|
|
55
55
|
page = 1,
|
|
56
56
|
}: TransactionsByAddressParams): Promise<TransactionsByAddressResponse> {
|
|
57
57
|
const data = await NeoRest.addressTXFull(address, page, this.network.type)
|
|
58
|
-
const transactions = await Promise.all(
|
|
59
|
-
data.items.map(async (item): Promise<TransactionResponse> => {
|
|
60
|
-
const filteredTransfers = item.notifications.filter(
|
|
61
|
-
item => item.event_name === 'Transfer' && (item.state.value.length === 3 || item.state.value.length === 4)
|
|
62
|
-
)
|
|
63
|
-
const transferPromises = filteredTransfers.map<Promise<TransactionTransferAsset | TransactionTransferNft>>(
|
|
64
|
-
async ({ contract: contractHash, state: { value: properties } }) => {
|
|
65
|
-
const isAsset = properties.length === 3
|
|
66
|
-
|
|
67
|
-
const from = properties[0].value
|
|
68
|
-
const to = properties[1].value
|
|
69
|
-
const convertedFrom = from ? this.convertByteStringToAddress(from) : 'Mint'
|
|
70
|
-
const convertedTo = to ? this.convertByteStringToAddress(to) : 'Burn'
|
|
71
|
-
|
|
72
|
-
if (isAsset) {
|
|
73
|
-
const token = await this.getTokenInfo(contractHash)
|
|
74
|
-
const [, , { value: amount }] = properties
|
|
75
|
-
return {
|
|
76
|
-
amount: u.BigInteger.fromNumber(amount).toDecimal(token.decimals ?? 0),
|
|
77
|
-
from: convertedFrom,
|
|
78
|
-
to: convertedTo,
|
|
79
|
-
contractHash,
|
|
80
|
-
type: 'token',
|
|
81
|
-
token,
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
58
|
|
|
59
|
+
const promises = data.items.map(async (item): Promise<TransactionResponse> => {
|
|
60
|
+
const transferPromises: Promise<TransactionTransferAsset | TransactionTransferNft>[] = []
|
|
61
|
+
|
|
62
|
+
item.notifications.forEach(({ contract: contractHash, state, event_name: eventName }) => {
|
|
63
|
+
const properties = Array.isArray(state) ? state : state.value
|
|
64
|
+
if (eventName !== 'Transfer' || (properties.length !== 3 && properties.length !== 4)) return
|
|
65
|
+
|
|
66
|
+
const promise = async (): Promise<TransactionTransferAsset | TransactionTransferNft> => {
|
|
67
|
+
const isAsset = properties.length === 3
|
|
68
|
+
|
|
69
|
+
const from = properties[0].value
|
|
70
|
+
const to = properties[1].value
|
|
71
|
+
const convertedFrom = from ? this.convertByteStringToAddress(from) : 'Mint'
|
|
72
|
+
const convertedTo = to ? this.convertByteStringToAddress(to) : 'Burn'
|
|
73
|
+
|
|
74
|
+
if (isAsset) {
|
|
75
|
+
const token = await this.getTokenInfo(contractHash)
|
|
76
|
+
const [, , { value: amount }] = properties
|
|
85
77
|
return {
|
|
78
|
+
amount: u.BigInteger.fromNumber(amount).toDecimal(token.decimals ?? 0),
|
|
86
79
|
from: convertedFrom,
|
|
87
80
|
to: convertedTo,
|
|
88
|
-
tokenId: properties[3].value,
|
|
89
81
|
contractHash,
|
|
90
|
-
type: '
|
|
82
|
+
type: 'token',
|
|
83
|
+
token,
|
|
91
84
|
}
|
|
92
85
|
}
|
|
93
|
-
)
|
|
94
|
-
const transfers = await Promise.all(transferPromises)
|
|
95
86
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
time: Number(item.time),
|
|
104
|
-
hash: item.hash,
|
|
105
|
-
fee: u.BigInteger.fromNumber(item.netfee ?? 0)
|
|
106
|
-
.add(u.BigInteger.fromNumber(item.sysfee ?? 0))
|
|
107
|
-
.toDecimal(this.feeToken.decimals),
|
|
108
|
-
transfers,
|
|
109
|
-
notifications,
|
|
87
|
+
return {
|
|
88
|
+
from: convertedFrom,
|
|
89
|
+
to: convertedTo,
|
|
90
|
+
tokenId: properties[3].value,
|
|
91
|
+
contractHash,
|
|
92
|
+
type: 'nft',
|
|
93
|
+
}
|
|
110
94
|
}
|
|
95
|
+
|
|
96
|
+
transferPromises.push(promise())
|
|
111
97
|
})
|
|
112
|
-
|
|
98
|
+
|
|
99
|
+
const transfers = await Promise.all(transferPromises)
|
|
100
|
+
|
|
101
|
+
const notifications = item.notifications.map<TransactionNotifications>(notification => ({
|
|
102
|
+
eventName: notification.event_name,
|
|
103
|
+
state: notification.state as any,
|
|
104
|
+
}))
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
block: item.block,
|
|
108
|
+
time: Number(item.time),
|
|
109
|
+
hash: item.hash,
|
|
110
|
+
fee: u.BigInteger.fromNumber(item.netfee ?? 0)
|
|
111
|
+
.add(u.BigInteger.fromNumber(item.sysfee ?? 0))
|
|
112
|
+
.toDecimal(this.feeToken.decimals),
|
|
113
|
+
transfers,
|
|
114
|
+
notifications,
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
const transactions = await Promise.all(promises)
|
|
113
119
|
|
|
114
120
|
return {
|
|
115
121
|
totalCount: data.totalCount,
|
|
@@ -27,43 +27,41 @@ describe('BDSNeo3', () => {
|
|
|
27
27
|
}
|
|
28
28
|
)
|
|
29
29
|
|
|
30
|
-
it.each([doraBDSNeo3
|
|
30
|
+
it.each([doraBDSNeo3])(
|
|
31
31
|
'Should be able to get transactions of address - %s',
|
|
32
32
|
async (bdsNeo3: BlockchainDataService) => {
|
|
33
33
|
const address = 'NNmTVFrSPhe7zjgN6iq9cLgXJwLZziUKV6'
|
|
34
|
-
|
|
35
|
-
const response = await bdsNeo3.getTransactionsByAddress({ address, page: 1 })
|
|
34
|
+
const response = await bdsNeo3.getTransactionsByAddress({ address, page: 1 })
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
} catch {}
|
|
36
|
+
response.transactions.forEach(transaction => {
|
|
37
|
+
expect(transaction).toEqual(
|
|
38
|
+
expect.objectContaining({
|
|
39
|
+
block: expect.any(Number),
|
|
40
|
+
hash: expect.any(String),
|
|
41
|
+
time: expect.any(Number),
|
|
42
|
+
fee: expect.any(String),
|
|
43
|
+
notifications: expect.arrayContaining([
|
|
44
|
+
expect.objectContaining({
|
|
45
|
+
eventName: expect.any(String),
|
|
46
|
+
state: expect.arrayContaining([
|
|
47
|
+
{
|
|
48
|
+
type: expect.any(String),
|
|
49
|
+
value: expect.any(String),
|
|
50
|
+
},
|
|
51
|
+
]),
|
|
52
|
+
}),
|
|
53
|
+
]),
|
|
54
|
+
transfers: expect.arrayContaining([
|
|
55
|
+
expect.objectContaining({
|
|
56
|
+
amount: expect.any(String),
|
|
57
|
+
from: expect.any(String),
|
|
58
|
+
to: expect.any(String),
|
|
59
|
+
type: 'token',
|
|
60
|
+
}),
|
|
61
|
+
]),
|
|
62
|
+
})
|
|
63
|
+
)
|
|
64
|
+
})
|
|
67
65
|
}
|
|
68
66
|
)
|
|
69
67
|
|