@btc-vision/cli 1.0.7 → 1.0.8
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/build/commands/DeprecateCommand.js +1 -1
- package/build/commands/DomainCommand.d.ts +3 -0
- package/build/commands/DomainCommand.js +241 -0
- package/build/commands/UndeprecateCommand.js +1 -1
- package/build/commands/WebsiteDeployCommand.d.ts +9 -0
- package/build/commands/WebsiteDeployCommand.js +214 -0
- package/build/commands/WebsitePublishCommand.d.ts +7 -0
- package/build/commands/WebsitePublishCommand.js +234 -0
- package/build/index.js +6 -0
- package/build/lib/BtcResolver.abi.d.ts +2 -0
- package/build/lib/BtcResolver.abi.js +280 -0
- package/build/lib/config.js +11 -0
- package/build/lib/ipfs.d.ts +7 -0
- package/build/lib/ipfs.js +119 -0
- package/build/lib/resolver.d.ts +43 -0
- package/build/lib/resolver.js +197 -0
- package/build/types/BtcResolver.d.ts +139 -0
- package/build/types/BtcResolver.js +7 -0
- package/build/types/index.d.ts +1 -0
- package/package.json +1 -1
package/build/lib/ipfs.js
CHANGED
|
@@ -214,3 +214,122 @@ export async function uploadPlugin(filePath) {
|
|
|
214
214
|
const fileName = filePath.split('/').pop() || 'plugin.opnet';
|
|
215
215
|
return pinToIPFS(data, fileName);
|
|
216
216
|
}
|
|
217
|
+
function getAllFiles(dirPath, basePath = '') {
|
|
218
|
+
const files = [];
|
|
219
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
220
|
+
for (const entry of entries) {
|
|
221
|
+
const fullPath = `${dirPath}/${entry.name}`;
|
|
222
|
+
const relativePath = basePath ? `${basePath}/${entry.name}` : entry.name;
|
|
223
|
+
if (entry.isDirectory()) {
|
|
224
|
+
files.push(...getAllFiles(fullPath, relativePath));
|
|
225
|
+
}
|
|
226
|
+
else if (entry.isFile()) {
|
|
227
|
+
files.push({ path: relativePath, fullPath });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return files;
|
|
231
|
+
}
|
|
232
|
+
function getMimeType(filePath) {
|
|
233
|
+
const ext = filePath.split('.').pop()?.toLowerCase() || '';
|
|
234
|
+
const mimeTypes = {
|
|
235
|
+
html: 'text/html',
|
|
236
|
+
htm: 'text/html',
|
|
237
|
+
css: 'text/css',
|
|
238
|
+
js: 'application/javascript',
|
|
239
|
+
mjs: 'application/javascript',
|
|
240
|
+
json: 'application/json',
|
|
241
|
+
png: 'image/png',
|
|
242
|
+
jpg: 'image/jpeg',
|
|
243
|
+
jpeg: 'image/jpeg',
|
|
244
|
+
gif: 'image/gif',
|
|
245
|
+
svg: 'image/svg+xml',
|
|
246
|
+
ico: 'image/x-icon',
|
|
247
|
+
webp: 'image/webp',
|
|
248
|
+
woff: 'font/woff',
|
|
249
|
+
woff2: 'font/woff2',
|
|
250
|
+
ttf: 'font/ttf',
|
|
251
|
+
eot: 'application/vnd.ms-fontobject',
|
|
252
|
+
txt: 'text/plain',
|
|
253
|
+
xml: 'application/xml',
|
|
254
|
+
pdf: 'application/pdf',
|
|
255
|
+
zip: 'application/zip',
|
|
256
|
+
wasm: 'application/wasm',
|
|
257
|
+
};
|
|
258
|
+
return mimeTypes[ext] || 'application/octet-stream';
|
|
259
|
+
}
|
|
260
|
+
export async function uploadDirectory(dirPath, wrapWithDirectory = true) {
|
|
261
|
+
try {
|
|
262
|
+
const config = loadConfig();
|
|
263
|
+
const endpoint = config.ipfsPinningEndpoint;
|
|
264
|
+
if (!endpoint) {
|
|
265
|
+
throw new Error('IPFS pinning endpoint not configured. Run `opnet config set ipfsPinningEndpoint <url>`');
|
|
266
|
+
}
|
|
267
|
+
const files = getAllFiles(dirPath);
|
|
268
|
+
if (files.length === 0) {
|
|
269
|
+
throw new Error('Directory is empty');
|
|
270
|
+
}
|
|
271
|
+
const boundary = '----FormBoundary' + Math.random().toString(36).substring(2);
|
|
272
|
+
const formParts = [];
|
|
273
|
+
let totalSize = 0;
|
|
274
|
+
for (const file of files) {
|
|
275
|
+
const data = fs.readFileSync(file.fullPath);
|
|
276
|
+
totalSize += data.length;
|
|
277
|
+
const mimeType = getMimeType(file.path);
|
|
278
|
+
formParts.push(Buffer.from(`--${boundary}\r\n` +
|
|
279
|
+
`Content-Disposition: form-data; name="file"; filename="${file.path}"\r\n` +
|
|
280
|
+
`Content-Type: ${mimeType}\r\n\r\n`));
|
|
281
|
+
formParts.push(data);
|
|
282
|
+
formParts.push(Buffer.from('\r\n'));
|
|
283
|
+
}
|
|
284
|
+
formParts.push(Buffer.from(`--${boundary}--\r\n`));
|
|
285
|
+
const body = Buffer.concat(formParts);
|
|
286
|
+
const headers = {
|
|
287
|
+
'Content-Type': `multipart/form-data; boundary=${boundary}`,
|
|
288
|
+
'Content-Length': body.length.toString(),
|
|
289
|
+
};
|
|
290
|
+
if (config.ipfsPinningApiKey) {
|
|
291
|
+
headers['Authorization'] = `Bearer ${config.ipfsPinningApiKey}`;
|
|
292
|
+
}
|
|
293
|
+
const url = new URL(endpoint);
|
|
294
|
+
if (wrapWithDirectory) {
|
|
295
|
+
url.searchParams.set('wrap-with-directory', 'true');
|
|
296
|
+
}
|
|
297
|
+
url.searchParams.set('cid-version', '1');
|
|
298
|
+
const response = await httpRequest(url.toString(), {
|
|
299
|
+
method: 'POST',
|
|
300
|
+
headers,
|
|
301
|
+
body,
|
|
302
|
+
timeout: 300000,
|
|
303
|
+
followRedirect: true,
|
|
304
|
+
});
|
|
305
|
+
const lines = response.toString().trim().split('\n');
|
|
306
|
+
let rootCid;
|
|
307
|
+
for (const line of lines) {
|
|
308
|
+
if (!line.trim())
|
|
309
|
+
continue;
|
|
310
|
+
const result = JSON.parse(line);
|
|
311
|
+
if (result.Hash && (result.Name === '' || !result.Name)) {
|
|
312
|
+
rootCid = result.Hash;
|
|
313
|
+
}
|
|
314
|
+
else if (result.Hash && !rootCid) {
|
|
315
|
+
rootCid = result.Hash;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (!rootCid) {
|
|
319
|
+
throw new Error(`Failed to extract root CID from response`);
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
cid: rootCid,
|
|
323
|
+
files: files.length,
|
|
324
|
+
totalSize,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
catch (e) {
|
|
328
|
+
throw new Error(`IPFS directory upload failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
export async function uploadFile(filePath) {
|
|
332
|
+
const data = fs.readFileSync(filePath);
|
|
333
|
+
const fileName = filePath.split('/').pop() || 'file';
|
|
334
|
+
return pinToIPFS(data, fileName);
|
|
335
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Address } from '@btc-vision/transaction';
|
|
2
|
+
import { NetworkName } from '../types/index.js';
|
|
3
|
+
import { IBtcResolver } from '../types/BtcResolver.js';
|
|
4
|
+
export interface DomainInfo {
|
|
5
|
+
exists: boolean;
|
|
6
|
+
owner: Address;
|
|
7
|
+
createdAt: bigint;
|
|
8
|
+
ttl: bigint;
|
|
9
|
+
}
|
|
10
|
+
export interface SubdomainInfo {
|
|
11
|
+
exists: boolean;
|
|
12
|
+
owner: Address;
|
|
13
|
+
parentHash: Uint8Array;
|
|
14
|
+
ttl: bigint;
|
|
15
|
+
}
|
|
16
|
+
export interface ContenthashInfo {
|
|
17
|
+
hashType: number;
|
|
18
|
+
hashData: Uint8Array;
|
|
19
|
+
hashString: string;
|
|
20
|
+
}
|
|
21
|
+
export interface PendingTransferInfo {
|
|
22
|
+
pendingOwner: Address;
|
|
23
|
+
initiatedAt: bigint;
|
|
24
|
+
}
|
|
25
|
+
export declare function getResolverContractAddress(network?: NetworkName): string;
|
|
26
|
+
export declare function getResolverContract(network?: NetworkName, sender?: Address): IBtcResolver;
|
|
27
|
+
export declare function clearResolverCache(): void;
|
|
28
|
+
export declare function getDomain(domainName: string, network?: NetworkName): Promise<DomainInfo | null>;
|
|
29
|
+
export declare function getSubdomain(fullName: string, network?: NetworkName): Promise<SubdomainInfo | null>;
|
|
30
|
+
export declare function getContenthash(name: string, network?: NetworkName): Promise<ContenthashInfo>;
|
|
31
|
+
export declare function resolveName(name: string, network?: NetworkName): Promise<Address | null>;
|
|
32
|
+
export declare function getPendingTransfer(domainName: string, network?: NetworkName): Promise<PendingTransferInfo | null>;
|
|
33
|
+
export declare function getTreasuryAddress(network?: NetworkName): Promise<string>;
|
|
34
|
+
export declare function getDomainPrice(domainName: string, network?: NetworkName): Promise<bigint>;
|
|
35
|
+
export declare function getBaseDomainPrice(network?: NetworkName): Promise<bigint>;
|
|
36
|
+
export declare function getContenthashTypeName(hashType: number): string;
|
|
37
|
+
export declare function detectContenthashType(content: string): number | null;
|
|
38
|
+
export declare function validateDomainName(domain: string): string | null;
|
|
39
|
+
export declare function validateCIDv0(cid: string): string | null;
|
|
40
|
+
export declare function validateCIDv1(cid: string): string | null;
|
|
41
|
+
export declare function validateIPNS(ipnsId: string): string | null;
|
|
42
|
+
export declare function isSubdomain(name: string): boolean;
|
|
43
|
+
export declare function parseDomainName(fullName: string): string;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { getContract } from 'opnet';
|
|
2
|
+
import { CONTENTHASH_TYPE_CIDv0, CONTENTHASH_TYPE_CIDv1, CONTENTHASH_TYPE_IPNS, CONTENTHASH_TYPE_SHA256, } from '../types/BtcResolver.js';
|
|
3
|
+
import { getProvider } from './provider.js';
|
|
4
|
+
import { getNetwork } from './wallet.js';
|
|
5
|
+
import { loadConfig } from './config.js';
|
|
6
|
+
import { BTC_RESOLVER_ABI } from './BtcResolver.abi.js';
|
|
7
|
+
const resolverCache = new Map();
|
|
8
|
+
export function getResolverContractAddress(network) {
|
|
9
|
+
const config = loadConfig();
|
|
10
|
+
const targetNetwork = network || config.defaultNetwork;
|
|
11
|
+
const address = config.resolverAddresses?.[targetNetwork];
|
|
12
|
+
if (!address) {
|
|
13
|
+
throw new Error(`Resolver address not configured for network: ${targetNetwork}\n` +
|
|
14
|
+
`Run: opnet config set resolverAddresses.${targetNetwork} <address>`);
|
|
15
|
+
}
|
|
16
|
+
return address;
|
|
17
|
+
}
|
|
18
|
+
export function getResolverContract(network, sender) {
|
|
19
|
+
const config = loadConfig();
|
|
20
|
+
const targetNetwork = network || config.defaultNetwork;
|
|
21
|
+
const cacheKey = sender ? `${targetNetwork}:${sender.toHex()}` : targetNetwork;
|
|
22
|
+
const cached = resolverCache.get(cacheKey);
|
|
23
|
+
if (cached) {
|
|
24
|
+
return cached;
|
|
25
|
+
}
|
|
26
|
+
const provider = getProvider(targetNetwork);
|
|
27
|
+
const resolverAddress = getResolverContractAddress(targetNetwork);
|
|
28
|
+
const bitcoinNetwork = getNetwork(targetNetwork);
|
|
29
|
+
const contract = getContract(resolverAddress, BTC_RESOLVER_ABI, provider, bitcoinNetwork, sender);
|
|
30
|
+
resolverCache.set(cacheKey, contract);
|
|
31
|
+
return contract;
|
|
32
|
+
}
|
|
33
|
+
export function clearResolverCache() {
|
|
34
|
+
resolverCache.clear();
|
|
35
|
+
}
|
|
36
|
+
export async function getDomain(domainName, network) {
|
|
37
|
+
const contract = getResolverContract(network);
|
|
38
|
+
const result = await contract.getDomain(domainName);
|
|
39
|
+
if (!result.properties.exists) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
exists: result.properties.exists,
|
|
44
|
+
owner: result.properties.owner,
|
|
45
|
+
createdAt: result.properties.createdAt,
|
|
46
|
+
ttl: result.properties.ttl,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export async function getSubdomain(fullName, network) {
|
|
50
|
+
const contract = getResolverContract(network);
|
|
51
|
+
const result = await contract.getSubdomain(fullName);
|
|
52
|
+
if (!result.properties.exists) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
exists: result.properties.exists,
|
|
57
|
+
owner: result.properties.owner,
|
|
58
|
+
parentHash: result.properties.parentHash,
|
|
59
|
+
ttl: result.properties.ttl,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export async function getContenthash(name, network) {
|
|
63
|
+
const contract = getResolverContract(network);
|
|
64
|
+
const result = await contract.getContenthash(name);
|
|
65
|
+
return {
|
|
66
|
+
hashType: result.properties.hashType,
|
|
67
|
+
hashData: result.properties.hashData,
|
|
68
|
+
hashString: result.properties.hashString,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export async function resolveName(name, network) {
|
|
72
|
+
const contract = getResolverContract(network);
|
|
73
|
+
const result = await contract.resolve(name);
|
|
74
|
+
const owner = result.properties.owner;
|
|
75
|
+
if (!owner || owner.toString() === '0'.repeat(64)) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return owner;
|
|
79
|
+
}
|
|
80
|
+
export async function getPendingTransfer(domainName, network) {
|
|
81
|
+
const contract = getResolverContract(network);
|
|
82
|
+
try {
|
|
83
|
+
const result = await contract.getPendingTransfer(domainName);
|
|
84
|
+
const pendingOwner = result.properties.pendingOwner;
|
|
85
|
+
if (!pendingOwner || pendingOwner.toString() === '0'.repeat(64)) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
pendingOwner,
|
|
90
|
+
initiatedAt: result.properties.initiatedAt,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export async function getTreasuryAddress(network) {
|
|
98
|
+
const contract = getResolverContract(network);
|
|
99
|
+
const result = await contract.getTreasuryAddress();
|
|
100
|
+
return result.properties.treasuryAddress;
|
|
101
|
+
}
|
|
102
|
+
export async function getDomainPrice(domainName, network) {
|
|
103
|
+
const contract = getResolverContract(network);
|
|
104
|
+
const result = await contract.getDomainPrice(domainName);
|
|
105
|
+
return result.properties.priceSats;
|
|
106
|
+
}
|
|
107
|
+
export async function getBaseDomainPrice(network) {
|
|
108
|
+
const contract = getResolverContract(network);
|
|
109
|
+
const result = await contract.getBaseDomainPrice();
|
|
110
|
+
return result.properties.priceSats;
|
|
111
|
+
}
|
|
112
|
+
export function getContenthashTypeName(hashType) {
|
|
113
|
+
switch (hashType) {
|
|
114
|
+
case CONTENTHASH_TYPE_CIDv0:
|
|
115
|
+
return 'CIDv0';
|
|
116
|
+
case CONTENTHASH_TYPE_CIDv1:
|
|
117
|
+
return 'CIDv1';
|
|
118
|
+
case CONTENTHASH_TYPE_IPNS:
|
|
119
|
+
return 'IPNS';
|
|
120
|
+
case CONTENTHASH_TYPE_SHA256:
|
|
121
|
+
return 'SHA256';
|
|
122
|
+
default:
|
|
123
|
+
return 'Unknown';
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export function detectContenthashType(content) {
|
|
127
|
+
if (content.startsWith('Qm') && content.length === 46) {
|
|
128
|
+
return CONTENTHASH_TYPE_CIDv0;
|
|
129
|
+
}
|
|
130
|
+
if (content.startsWith('baf')) {
|
|
131
|
+
return CONTENTHASH_TYPE_CIDv1;
|
|
132
|
+
}
|
|
133
|
+
if (content.startsWith('k')) {
|
|
134
|
+
return CONTENTHASH_TYPE_IPNS;
|
|
135
|
+
}
|
|
136
|
+
if (/^[0-9a-fA-F]{64}$/.test(content)) {
|
|
137
|
+
return CONTENTHASH_TYPE_SHA256;
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
export function validateDomainName(domain) {
|
|
142
|
+
if (domain.length < 3) {
|
|
143
|
+
return 'Domain must be at least 3 characters';
|
|
144
|
+
}
|
|
145
|
+
if (domain.length > 63) {
|
|
146
|
+
return 'Domain must be at most 63 characters';
|
|
147
|
+
}
|
|
148
|
+
if (!/^[a-zA-Z0-9]/.test(domain)) {
|
|
149
|
+
return 'Domain must start with alphanumeric character';
|
|
150
|
+
}
|
|
151
|
+
if (!/[a-zA-Z0-9]$/.test(domain)) {
|
|
152
|
+
return 'Domain must end with alphanumeric character';
|
|
153
|
+
}
|
|
154
|
+
if (!/^[a-zA-Z0-9-]+$/.test(domain)) {
|
|
155
|
+
return 'Domain can only contain letters, numbers, and hyphens';
|
|
156
|
+
}
|
|
157
|
+
if (/--/.test(domain)) {
|
|
158
|
+
return 'Domain cannot contain consecutive hyphens';
|
|
159
|
+
}
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
export function validateCIDv0(cid) {
|
|
163
|
+
if (cid.length !== 46) {
|
|
164
|
+
return 'CIDv0 must be 46 characters';
|
|
165
|
+
}
|
|
166
|
+
if (!cid.startsWith('Qm')) {
|
|
167
|
+
return 'CIDv0 must start with "Qm"';
|
|
168
|
+
}
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
export function validateCIDv1(cid) {
|
|
172
|
+
if (cid.length < 50 || cid.length > 128) {
|
|
173
|
+
return 'CIDv1 must be 50-128 characters';
|
|
174
|
+
}
|
|
175
|
+
if (!cid.startsWith('baf')) {
|
|
176
|
+
return 'CIDv1 must start with "baf"';
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
export function validateIPNS(ipnsId) {
|
|
181
|
+
if (ipnsId.length < 50 || ipnsId.length > 128) {
|
|
182
|
+
return 'IPNS ID must be 50-128 characters';
|
|
183
|
+
}
|
|
184
|
+
if (!ipnsId.startsWith('k')) {
|
|
185
|
+
return 'IPNS ID must start with "k"';
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
export function isSubdomain(name) {
|
|
190
|
+
return name.includes('.');
|
|
191
|
+
}
|
|
192
|
+
export function parseDomainName(fullName) {
|
|
193
|
+
if (fullName.endsWith('.btc')) {
|
|
194
|
+
return fullName.slice(0, -4);
|
|
195
|
+
}
|
|
196
|
+
return fullName;
|
|
197
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Address } from '@btc-vision/transaction';
|
|
2
|
+
import { CallResult, IOP_NETContract, OPNetEvent } from 'opnet';
|
|
3
|
+
export declare const CONTENTHASH_TYPE_CIDv0 = 1;
|
|
4
|
+
export declare const CONTENTHASH_TYPE_CIDv1 = 2;
|
|
5
|
+
export declare const CONTENTHASH_TYPE_IPNS = 3;
|
|
6
|
+
export declare const CONTENTHASH_TYPE_SHA256 = 4;
|
|
7
|
+
export type ContenthashType = typeof CONTENTHASH_TYPE_CIDv0 | typeof CONTENTHASH_TYPE_CIDv1 | typeof CONTENTHASH_TYPE_IPNS | typeof CONTENTHASH_TYPE_SHA256;
|
|
8
|
+
export declare const DEFAULT_DOMAIN_PRICE_SATS = 100000n;
|
|
9
|
+
export declare const PREMIUM_3_CHAR_PRICE_SATS = 1000000n;
|
|
10
|
+
export declare const PREMIUM_4_CHAR_PRICE_SATS = 500000n;
|
|
11
|
+
export type DomainRegisteredEvent = {
|
|
12
|
+
readonly domainHash: bigint;
|
|
13
|
+
readonly owner: Address;
|
|
14
|
+
readonly timestamp: bigint;
|
|
15
|
+
};
|
|
16
|
+
export type DomainTransferInitiatedEvent = {
|
|
17
|
+
readonly domainHash: bigint;
|
|
18
|
+
readonly currentOwner: Address;
|
|
19
|
+
readonly newOwner: Address;
|
|
20
|
+
readonly timestamp: bigint;
|
|
21
|
+
};
|
|
22
|
+
export type DomainTransferCompletedEvent = {
|
|
23
|
+
readonly domainHash: bigint;
|
|
24
|
+
readonly previousOwner: Address;
|
|
25
|
+
readonly newOwner: Address;
|
|
26
|
+
readonly timestamp: bigint;
|
|
27
|
+
};
|
|
28
|
+
export type DomainTransferCancelledEvent = {
|
|
29
|
+
readonly domainHash: bigint;
|
|
30
|
+
readonly owner: Address;
|
|
31
|
+
readonly timestamp: bigint;
|
|
32
|
+
};
|
|
33
|
+
export type SubdomainCreatedEvent = {
|
|
34
|
+
readonly parentDomainHash: bigint;
|
|
35
|
+
readonly subdomainHash: bigint;
|
|
36
|
+
readonly owner: Address;
|
|
37
|
+
readonly timestamp: bigint;
|
|
38
|
+
};
|
|
39
|
+
export type SubdomainDeletedEvent = {
|
|
40
|
+
readonly parentDomainHash: bigint;
|
|
41
|
+
readonly subdomainHash: bigint;
|
|
42
|
+
readonly timestamp: bigint;
|
|
43
|
+
};
|
|
44
|
+
export type ContenthashChangedEvent = {
|
|
45
|
+
readonly nameHash: bigint;
|
|
46
|
+
readonly contenthashType: number;
|
|
47
|
+
readonly timestamp: bigint;
|
|
48
|
+
};
|
|
49
|
+
export type ContenthashClearedEvent = {
|
|
50
|
+
readonly nameHash: bigint;
|
|
51
|
+
readonly timestamp: bigint;
|
|
52
|
+
};
|
|
53
|
+
export type TTLChangedEvent = {
|
|
54
|
+
readonly nameHash: bigint;
|
|
55
|
+
readonly oldTTL: bigint;
|
|
56
|
+
readonly newTTL: bigint;
|
|
57
|
+
readonly timestamp: bigint;
|
|
58
|
+
};
|
|
59
|
+
export type DomainPriceChangedEvent = {
|
|
60
|
+
readonly oldPrice: bigint;
|
|
61
|
+
readonly newPrice: bigint;
|
|
62
|
+
readonly timestamp: bigint;
|
|
63
|
+
};
|
|
64
|
+
export type TreasuryChangedEvent = {
|
|
65
|
+
readonly previousAddressHash: bigint;
|
|
66
|
+
readonly newAddressHash: bigint;
|
|
67
|
+
readonly timestamp: bigint;
|
|
68
|
+
};
|
|
69
|
+
export type SetTreasuryAddress = CallResult<{}, OPNetEvent<TreasuryChangedEvent>[]>;
|
|
70
|
+
export type SetDomainPrice = CallResult<{}, OPNetEvent<DomainPriceChangedEvent>[]>;
|
|
71
|
+
export type RegisterDomain = CallResult<{}, OPNetEvent<DomainRegisteredEvent>[]>;
|
|
72
|
+
export type InitiateTransfer = CallResult<{}, OPNetEvent<DomainTransferInitiatedEvent>[]>;
|
|
73
|
+
export type AcceptTransfer = CallResult<{}, OPNetEvent<DomainTransferCompletedEvent>[]>;
|
|
74
|
+
export type CancelTransfer = CallResult<{}, OPNetEvent<DomainTransferCancelledEvent>[]>;
|
|
75
|
+
export type CreateSubdomain = CallResult<{}, OPNetEvent<SubdomainCreatedEvent>[]>;
|
|
76
|
+
export type DeleteSubdomain = CallResult<{}, OPNetEvent<SubdomainDeletedEvent>[]>;
|
|
77
|
+
export type SetContenthashCIDv0 = CallResult<{}, OPNetEvent<ContenthashChangedEvent>[]>;
|
|
78
|
+
export type SetContenthashCIDv1 = CallResult<{}, OPNetEvent<ContenthashChangedEvent>[]>;
|
|
79
|
+
export type SetContenthashIPNS = CallResult<{}, OPNetEvent<ContenthashChangedEvent>[]>;
|
|
80
|
+
export type SetContenthashSHA256 = CallResult<{}, OPNetEvent<ContenthashChangedEvent>[]>;
|
|
81
|
+
export type ClearContenthash = CallResult<{}, OPNetEvent<ContenthashClearedEvent>[]>;
|
|
82
|
+
export type SetTTL = CallResult<{}, OPNetEvent<TTLChangedEvent>[]>;
|
|
83
|
+
export type GetDomain = CallResult<{
|
|
84
|
+
exists: boolean;
|
|
85
|
+
owner: Address;
|
|
86
|
+
createdAt: bigint;
|
|
87
|
+
ttl: bigint;
|
|
88
|
+
}, OPNetEvent<never>[]>;
|
|
89
|
+
export type GetSubdomain = CallResult<{
|
|
90
|
+
exists: boolean;
|
|
91
|
+
owner: Address;
|
|
92
|
+
parentHash: Uint8Array;
|
|
93
|
+
ttl: bigint;
|
|
94
|
+
}, OPNetEvent<never>[]>;
|
|
95
|
+
export type GetContenthash = CallResult<{
|
|
96
|
+
hashType: number;
|
|
97
|
+
hashData: Uint8Array;
|
|
98
|
+
hashString: string;
|
|
99
|
+
}, OPNetEvent<never>[]>;
|
|
100
|
+
export type Resolve = CallResult<{
|
|
101
|
+
owner: Address;
|
|
102
|
+
}, OPNetEvent<never>[]>;
|
|
103
|
+
export type GetPendingTransfer = CallResult<{
|
|
104
|
+
pendingOwner: Address;
|
|
105
|
+
initiatedAt: bigint;
|
|
106
|
+
}, OPNetEvent<never>[]>;
|
|
107
|
+
export type GetTreasuryAddress = CallResult<{
|
|
108
|
+
treasuryAddress: string;
|
|
109
|
+
}, OPNetEvent<never>[]>;
|
|
110
|
+
export type GetDomainPrice = CallResult<{
|
|
111
|
+
priceSats: bigint;
|
|
112
|
+
}, OPNetEvent<never>[]>;
|
|
113
|
+
export type GetBaseDomainPrice = CallResult<{
|
|
114
|
+
priceSats: bigint;
|
|
115
|
+
}, OPNetEvent<never>[]>;
|
|
116
|
+
export interface IBtcResolver extends IOP_NETContract {
|
|
117
|
+
setTreasuryAddress(treasuryAddress: string): Promise<SetTreasuryAddress>;
|
|
118
|
+
setDomainPrice(priceSats: bigint): Promise<SetDomainPrice>;
|
|
119
|
+
registerDomain(domainName: string): Promise<RegisterDomain>;
|
|
120
|
+
initiateTransfer(domainName: string, newOwner: Address): Promise<InitiateTransfer>;
|
|
121
|
+
acceptTransfer(domainName: string): Promise<AcceptTransfer>;
|
|
122
|
+
cancelTransfer(domainName: string): Promise<CancelTransfer>;
|
|
123
|
+
createSubdomain(parentDomain: string, subdomainLabel: string, subdomainOwner: Address): Promise<CreateSubdomain>;
|
|
124
|
+
deleteSubdomain(parentDomain: string, subdomainLabel: string): Promise<DeleteSubdomain>;
|
|
125
|
+
setContenthashCIDv0(name: string, cid: string): Promise<SetContenthashCIDv0>;
|
|
126
|
+
setContenthashCIDv1(name: string, cid: string): Promise<SetContenthashCIDv1>;
|
|
127
|
+
setContenthashIPNS(name: string, ipnsId: string): Promise<SetContenthashIPNS>;
|
|
128
|
+
setContenthashSHA256(name: string, hash: Uint8Array): Promise<SetContenthashSHA256>;
|
|
129
|
+
clearContenthash(name: string): Promise<ClearContenthash>;
|
|
130
|
+
setTTL(name: string, ttl: bigint): Promise<SetTTL>;
|
|
131
|
+
getDomain(domainName: string): Promise<GetDomain>;
|
|
132
|
+
getSubdomain(fullName: string): Promise<GetSubdomain>;
|
|
133
|
+
getContenthash(name: string): Promise<GetContenthash>;
|
|
134
|
+
resolve(name: string): Promise<Resolve>;
|
|
135
|
+
getPendingTransfer(domainName: string): Promise<GetPendingTransfer>;
|
|
136
|
+
getTreasuryAddress(): Promise<GetTreasuryAddress>;
|
|
137
|
+
getDomainPrice(domainName: string): Promise<GetDomainPrice>;
|
|
138
|
+
getBaseDomainPrice(): Promise<GetBaseDomainPrice>;
|
|
139
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const CONTENTHASH_TYPE_CIDv0 = 1;
|
|
2
|
+
export const CONTENTHASH_TYPE_CIDv1 = 2;
|
|
3
|
+
export const CONTENTHASH_TYPE_IPNS = 3;
|
|
4
|
+
export const CONTENTHASH_TYPE_SHA256 = 4;
|
|
5
|
+
export const DEFAULT_DOMAIN_PRICE_SATS = 100000n;
|
|
6
|
+
export const PREMIUM_3_CHAR_PRICE_SATS = 1000000n;
|
|
7
|
+
export const PREMIUM_4_CHAR_PRICE_SATS = 500000n;
|
package/build/types/index.d.ts
CHANGED