@bbuilders/djeon402-core 1.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/README.md +240 -0
- package/dist/index.cjs +639 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1051 -0
- package/dist/index.d.ts +1051 -0
- package/dist/index.js +616 -0
- package/dist/index.js.map +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# @bbuilders/djeon402/core
|
|
2
|
+
|
|
3
|
+
Core types, ABIs, constants, and utilities for the DJEON402 token ecosystem.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides the foundational building blocks shared across all DJEON402 SDK packages:
|
|
8
|
+
|
|
9
|
+
- **TypeScript type definitions** for all contract interactions
|
|
10
|
+
- **Smart contract ABIs** (DJEON402 token and KYC Registry)
|
|
11
|
+
- **EIP-712 constants** for typed structured data signing
|
|
12
|
+
- **Utility functions** for formatting, validation, and data transformation
|
|
13
|
+
|
|
14
|
+
This package is designed to be used as a dependency by other SDK packages (@bbuilders/djeon402/sdk-node, @bbuilders/djeon402/sdk-client) and is not typically installed directly by end users.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @bbuilders/djeon402/core
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Package Contents
|
|
23
|
+
|
|
24
|
+
### ABIs
|
|
25
|
+
|
|
26
|
+
Contract Application Binary Interfaces for interacting with DJEON402 smart contracts:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { DJEON402_ABI, KYC_REGISTRY_ABI } from '@bbuilders/djeon402/core';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- `DJEON402_ABI` - ERC-20 token contract with x402, KYC, admin features
|
|
33
|
+
- `KYC_REGISTRY_ABI` - KYC registry contract for user verification
|
|
34
|
+
|
|
35
|
+
### Types
|
|
36
|
+
|
|
37
|
+
Comprehensive TypeScript type definitions:
|
|
38
|
+
|
|
39
|
+
#### Token Types
|
|
40
|
+
```typescript
|
|
41
|
+
interface TokenInfo {
|
|
42
|
+
name: string;
|
|
43
|
+
symbol: string;
|
|
44
|
+
decimals: number;
|
|
45
|
+
totalSupply: string;
|
|
46
|
+
totalSupplyRaw: string;
|
|
47
|
+
paused: boolean;
|
|
48
|
+
contractAddress: Address;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface BalanceResult {
|
|
52
|
+
address: Address;
|
|
53
|
+
balance: string;
|
|
54
|
+
balanceRaw: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface TransferResult {
|
|
58
|
+
success: boolean;
|
|
59
|
+
hash: Hash;
|
|
60
|
+
blockNumber: string;
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Admin Types
|
|
65
|
+
```typescript
|
|
66
|
+
interface RolesResult {
|
|
67
|
+
DEFAULT_ADMIN_ROLE: Hex;
|
|
68
|
+
MINTER_ROLE: Hex;
|
|
69
|
+
BURNER_ROLE: Hex;
|
|
70
|
+
PAUSER_ROLE: Hex;
|
|
71
|
+
BLACKLISTER_ROLE: Hex;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface BlacklistResult {
|
|
75
|
+
address: Address;
|
|
76
|
+
isBlacklisted: boolean;
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### KYC Types
|
|
81
|
+
```typescript
|
|
82
|
+
type KYCLevel = 0 | 1 | 2 | 3;
|
|
83
|
+
type KYCLevelName = 'None' | 'Tier1' | 'Tier2' | 'Tier3';
|
|
84
|
+
|
|
85
|
+
interface KYCData {
|
|
86
|
+
level: KYCLevel;
|
|
87
|
+
levelName: KYCLevelName;
|
|
88
|
+
expiryDate: number;
|
|
89
|
+
expiryDateReadable: string;
|
|
90
|
+
kycHash: string;
|
|
91
|
+
isActive: boolean;
|
|
92
|
+
dailyLimit: string;
|
|
93
|
+
dailyLimitRaw: string;
|
|
94
|
+
dailySpent: string;
|
|
95
|
+
dailySpentRaw: string;
|
|
96
|
+
userAddress: Address;
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### x402 Types (EIP-3009)
|
|
101
|
+
```typescript
|
|
102
|
+
interface TransferAuthorizationSignature {
|
|
103
|
+
from: Address;
|
|
104
|
+
to: Address;
|
|
105
|
+
value: bigint;
|
|
106
|
+
validAfter: bigint;
|
|
107
|
+
validBefore: bigint;
|
|
108
|
+
nonce: Hex;
|
|
109
|
+
v: number;
|
|
110
|
+
r: Hex;
|
|
111
|
+
s: Hex;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
interface ReceiveAuthorizationSignature {
|
|
115
|
+
from: Address;
|
|
116
|
+
to: Address;
|
|
117
|
+
value: bigint;
|
|
118
|
+
validAfter: bigint;
|
|
119
|
+
validBefore: bigint;
|
|
120
|
+
nonce: Hex;
|
|
121
|
+
v: number;
|
|
122
|
+
r: Hex;
|
|
123
|
+
s: Hex;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
interface SignTransferAuthParams {
|
|
127
|
+
privateKey: `0x${string}`;
|
|
128
|
+
from: Address;
|
|
129
|
+
to: Address;
|
|
130
|
+
amount: string;
|
|
131
|
+
validAfter?: bigint;
|
|
132
|
+
validBefore?: bigint;
|
|
133
|
+
nonce?: Hex;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface SignReceiveAuthParams {
|
|
137
|
+
privateKey: `0x${string}`;
|
|
138
|
+
from: Address;
|
|
139
|
+
to: Address;
|
|
140
|
+
amount: string;
|
|
141
|
+
validAfter?: bigint;
|
|
142
|
+
validBefore?: bigint;
|
|
143
|
+
nonce?: Hex;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
interface CancelAuthorizationParams {
|
|
147
|
+
privateKey: `0x${string}`;
|
|
148
|
+
authorizer: Address;
|
|
149
|
+
nonce: Hex;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
interface CancelAuthorizationResult {
|
|
153
|
+
success: boolean;
|
|
154
|
+
hash: Hash;
|
|
155
|
+
blockNumber: string;
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Constants
|
|
160
|
+
|
|
161
|
+
EIP-712 constants for typed structured data signing:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
import {
|
|
165
|
+
TRANSFER_WITH_AUTHORIZATION_TYPEHASH,
|
|
166
|
+
RECEIVE_WITH_AUTHORIZATION_TYPEHASH,
|
|
167
|
+
CANCEL_AUTHORIZATION_TYPEHASH,
|
|
168
|
+
DEFAULT_VALID_AFTER,
|
|
169
|
+
DEFAULT_VALID_BEFORE,
|
|
170
|
+
} from '@bbuilders/djeon402/core';
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Utilities
|
|
174
|
+
|
|
175
|
+
Helper functions for formatting and validation:
|
|
176
|
+
|
|
177
|
+
#### Formatting
|
|
178
|
+
```typescript
|
|
179
|
+
import {
|
|
180
|
+
formatTokenAmount,
|
|
181
|
+
parseTokenAmount,
|
|
182
|
+
formatTimestamp,
|
|
183
|
+
getKYCLevelName,
|
|
184
|
+
} from '@bbuilders/djeon402/core';
|
|
185
|
+
|
|
186
|
+
// Format raw token amount to human-readable string
|
|
187
|
+
const formatted = formatTokenAmount('1000000000000000000', 18); // "1.0"
|
|
188
|
+
|
|
189
|
+
// Parse human-readable amount to raw bigint
|
|
190
|
+
const raw = parseTokenAmount('1.5', 18); // 1500000000000000000n
|
|
191
|
+
|
|
192
|
+
// Format UNIX timestamp to readable date
|
|
193
|
+
const date = formatTimestamp(1735632000); // "2024-12-31T00:00:00.000Z"
|
|
194
|
+
|
|
195
|
+
// Get KYC level name
|
|
196
|
+
const levelName = getKYCLevelName(2); // "Tier2"
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### Validation
|
|
200
|
+
```typescript
|
|
201
|
+
import {
|
|
202
|
+
validateAddress,
|
|
203
|
+
validatePrivateKey,
|
|
204
|
+
validateAmount,
|
|
205
|
+
} from '@bbuilders/djeon402/core';
|
|
206
|
+
|
|
207
|
+
// Validate Ethereum address
|
|
208
|
+
validateAddress('0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'); // throws if invalid
|
|
209
|
+
|
|
210
|
+
// Validate private key format
|
|
211
|
+
validatePrivateKey('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80');
|
|
212
|
+
|
|
213
|
+
// Validate amount string
|
|
214
|
+
validateAmount('100.5'); // throws if invalid
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Usage in SDK Packages
|
|
218
|
+
|
|
219
|
+
This package is designed to be imported by other SDK packages:
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
// In @bbuilders/djeon402/sdk-node
|
|
223
|
+
import {
|
|
224
|
+
DJEON402_ABI,
|
|
225
|
+
type TokenInfo,
|
|
226
|
+
type TransferResult,
|
|
227
|
+
formatTokenAmount,
|
|
228
|
+
validateAddress,
|
|
229
|
+
} from '@bbuilders/djeon402/core';
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
MIT
|
|
235
|
+
|
|
236
|
+
## Related Packages
|
|
237
|
+
|
|
238
|
+
- [@bbuilders/djeon402/sdk-node](../sdk-node) - Node.js/Backend SDK
|
|
239
|
+
- [@bbuilders/djeon402/sdk-client](../sdk-client) - Browser/Frontend SDK
|
|
240
|
+
- [djeon402-sdk](../sdk-py) - Python SDK
|