@chainfoundry/chaincodec 0.1.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/chaincodec.darwin-arm64.node +0 -0
- package/chaincodec.darwin-x64.node +0 -0
- package/chaincodec.linux-arm64-gnu.node +0 -0
- package/chaincodec.linux-x64-gnu.node +0 -0
- package/chaincodec.linux-x64-musl.node +0 -0
- package/chaincodec.win32-x64-msvc.node +0 -0
- package/index.d.ts +0 -0
- package/index.js +175 -0
- package/package.json +56 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.d.ts
ADDED
|
File without changes
|
package/index.js
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
// Load the platform-specific native module
|
|
3
|
+
const { existsSync, readFileSync } = require('fs')
|
|
4
|
+
const { join } = require('path')
|
|
5
|
+
|
|
6
|
+
const { platform, arch } = process
|
|
7
|
+
|
|
8
|
+
let nativeBinding = null
|
|
9
|
+
let localFileExisted = false
|
|
10
|
+
let loadError = null
|
|
11
|
+
|
|
12
|
+
function isMusl() {
|
|
13
|
+
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
14
|
+
try {
|
|
15
|
+
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
16
|
+
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return true
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
const { glibcVersionRuntime } = process.report.getReport().header
|
|
22
|
+
return !glibcVersionRuntime
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
switch (platform) {
|
|
27
|
+
case 'android':
|
|
28
|
+
switch (arch) {
|
|
29
|
+
case 'arm64':
|
|
30
|
+
localFileExisted = existsSync(join(__dirname, 'chaincodec.android-arm64.node'))
|
|
31
|
+
try {
|
|
32
|
+
if (localFileExisted) {
|
|
33
|
+
nativeBinding = require('./chaincodec.android-arm64.node')
|
|
34
|
+
} else {
|
|
35
|
+
nativeBinding = require('@chainfoundry/chaincodec-android-arm64')
|
|
36
|
+
}
|
|
37
|
+
} catch (e) {
|
|
38
|
+
loadError = e
|
|
39
|
+
}
|
|
40
|
+
break
|
|
41
|
+
default:
|
|
42
|
+
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
43
|
+
}
|
|
44
|
+
break
|
|
45
|
+
case 'win32':
|
|
46
|
+
switch (arch) {
|
|
47
|
+
case 'x64':
|
|
48
|
+
localFileExisted = existsSync(join(__dirname, 'chaincodec.win32-x64-msvc.node'))
|
|
49
|
+
try {
|
|
50
|
+
if (localFileExisted) {
|
|
51
|
+
nativeBinding = require('./chaincodec.win32-x64-msvc.node')
|
|
52
|
+
} else {
|
|
53
|
+
nativeBinding = require('@chainfoundry/chaincodec-win32-x64-msvc')
|
|
54
|
+
}
|
|
55
|
+
} catch (e) {
|
|
56
|
+
loadError = e
|
|
57
|
+
}
|
|
58
|
+
break
|
|
59
|
+
case 'arm64':
|
|
60
|
+
localFileExisted = existsSync(join(__dirname, 'chaincodec.win32-arm64-msvc.node'))
|
|
61
|
+
try {
|
|
62
|
+
if (localFileExisted) {
|
|
63
|
+
nativeBinding = require('./chaincodec.win32-arm64-msvc.node')
|
|
64
|
+
} else {
|
|
65
|
+
nativeBinding = require('@chainfoundry/chaincodec-win32-arm64-msvc')
|
|
66
|
+
}
|
|
67
|
+
} catch (e) {
|
|
68
|
+
loadError = e
|
|
69
|
+
}
|
|
70
|
+
break
|
|
71
|
+
default:
|
|
72
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
73
|
+
}
|
|
74
|
+
break
|
|
75
|
+
case 'darwin':
|
|
76
|
+
localFileExisted = existsSync(join(__dirname, 'chaincodec.darwin-universal.node'))
|
|
77
|
+
try {
|
|
78
|
+
if (localFileExisted) {
|
|
79
|
+
nativeBinding = require('./chaincodec.darwin-universal.node')
|
|
80
|
+
} else {
|
|
81
|
+
nativeBinding = require('@chainfoundry/chaincodec-darwin-universal')
|
|
82
|
+
}
|
|
83
|
+
} catch {}
|
|
84
|
+
if (!nativeBinding) {
|
|
85
|
+
switch (arch) {
|
|
86
|
+
case 'x64':
|
|
87
|
+
localFileExisted = existsSync(join(__dirname, 'chaincodec.darwin-x64.node'))
|
|
88
|
+
try {
|
|
89
|
+
if (localFileExisted) {
|
|
90
|
+
nativeBinding = require('./chaincodec.darwin-x64.node')
|
|
91
|
+
} else {
|
|
92
|
+
nativeBinding = require('@chainfoundry/chaincodec-darwin-x64')
|
|
93
|
+
}
|
|
94
|
+
} catch (e) {
|
|
95
|
+
loadError = e
|
|
96
|
+
}
|
|
97
|
+
break
|
|
98
|
+
case 'arm64':
|
|
99
|
+
localFileExisted = existsSync(join(__dirname, 'chaincodec.darwin-arm64.node'))
|
|
100
|
+
try {
|
|
101
|
+
if (localFileExisted) {
|
|
102
|
+
nativeBinding = require('./chaincodec.darwin-arm64.node')
|
|
103
|
+
} else {
|
|
104
|
+
nativeBinding = require('@chainfoundry/chaincodec-darwin-arm64')
|
|
105
|
+
}
|
|
106
|
+
} catch (e) {
|
|
107
|
+
loadError = e
|
|
108
|
+
}
|
|
109
|
+
break
|
|
110
|
+
default:
|
|
111
|
+
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
break
|
|
115
|
+
case 'linux':
|
|
116
|
+
switch (arch) {
|
|
117
|
+
case 'x64':
|
|
118
|
+
if (isMusl()) {
|
|
119
|
+
localFileExisted = existsSync(join(__dirname, 'chaincodec.linux-x64-musl.node'))
|
|
120
|
+
try {
|
|
121
|
+
if (localFileExisted) {
|
|
122
|
+
nativeBinding = require('./chaincodec.linux-x64-musl.node')
|
|
123
|
+
} else {
|
|
124
|
+
nativeBinding = require('@chainfoundry/chaincodec-linux-x64-musl')
|
|
125
|
+
}
|
|
126
|
+
} catch (e) {
|
|
127
|
+
loadError = e
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
localFileExisted = existsSync(join(__dirname, 'chaincodec.linux-x64-gnu.node'))
|
|
131
|
+
try {
|
|
132
|
+
if (localFileExisted) {
|
|
133
|
+
nativeBinding = require('./chaincodec.linux-x64-gnu.node')
|
|
134
|
+
} else {
|
|
135
|
+
nativeBinding = require('@chainfoundry/chaincodec-linux-x64-gnu')
|
|
136
|
+
}
|
|
137
|
+
} catch (e) {
|
|
138
|
+
loadError = e
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
break
|
|
142
|
+
case 'arm64':
|
|
143
|
+
localFileExisted = existsSync(join(__dirname, 'chaincodec.linux-arm64-gnu.node'))
|
|
144
|
+
try {
|
|
145
|
+
if (localFileExisted) {
|
|
146
|
+
nativeBinding = require('./chaincodec.linux-arm64-gnu.node')
|
|
147
|
+
} else {
|
|
148
|
+
nativeBinding = require('@chainfoundry/chaincodec-linux-arm64-gnu')
|
|
149
|
+
}
|
|
150
|
+
} catch (e) {
|
|
151
|
+
loadError = e
|
|
152
|
+
}
|
|
153
|
+
break
|
|
154
|
+
default:
|
|
155
|
+
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
156
|
+
}
|
|
157
|
+
break
|
|
158
|
+
default:
|
|
159
|
+
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (!nativeBinding) {
|
|
163
|
+
if (loadError) {
|
|
164
|
+
throw loadError
|
|
165
|
+
}
|
|
166
|
+
throw new Error('Failed to load native @chainfoundry/chaincodec binding')
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const { MemoryRegistry, EvmDecoder, EvmCallDecoder, EvmEncoder, Eip712Parser } = nativeBinding
|
|
170
|
+
|
|
171
|
+
module.exports.MemoryRegistry = MemoryRegistry
|
|
172
|
+
module.exports.EvmDecoder = EvmDecoder
|
|
173
|
+
module.exports.EvmCallDecoder = EvmCallDecoder
|
|
174
|
+
module.exports.EvmEncoder = EvmEncoder
|
|
175
|
+
module.exports.Eip712Parser = Eip712Parser
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chainfoundry/chaincodec",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Universal blockchain ABI decoder — production-grade event & call decoding for Ethereum and EVM chains",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ethereum",
|
|
7
|
+
"evm",
|
|
8
|
+
"abi",
|
|
9
|
+
"decoder",
|
|
10
|
+
"blockchain",
|
|
11
|
+
"web3",
|
|
12
|
+
"chaincodec",
|
|
13
|
+
"arbitrum",
|
|
14
|
+
"base",
|
|
15
|
+
"polygon"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/DarshanKumar89/chainkit"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/DarshanKumar89/chainkit/tree/main/chaincodec",
|
|
23
|
+
"main": "index.js",
|
|
24
|
+
"types": "index.d.ts",
|
|
25
|
+
"napi": {
|
|
26
|
+
"binaryName": "chaincodec",
|
|
27
|
+
"targets": [
|
|
28
|
+
"x86_64-unknown-linux-gnu",
|
|
29
|
+
"x86_64-unknown-linux-musl",
|
|
30
|
+
"aarch64-unknown-linux-gnu",
|
|
31
|
+
"x86_64-apple-darwin",
|
|
32
|
+
"aarch64-apple-darwin",
|
|
33
|
+
"x86_64-pc-windows-msvc"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"index.d.ts",
|
|
38
|
+
"index.js",
|
|
39
|
+
"chaincodec.*.node"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "napi build --platform --release",
|
|
43
|
+
"build:debug": "napi build --platform",
|
|
44
|
+
"test": "node --experimental-vm-modules node_modules/.bin/jest",
|
|
45
|
+
"prepublishOnly": "napi build --platform --release --strip",
|
|
46
|
+
"version": "napi version && git add -A"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@napi-rs/cli": "^3.0.0",
|
|
50
|
+
"typescript": "^5.3.0",
|
|
51
|
+
"jest": "^29.0.0"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">= 14"
|
|
55
|
+
}
|
|
56
|
+
}
|