@midnames/sdk 1.0.0 → 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/dist/core.d.ts +2 -1
- package/dist/core.js +25 -17
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/managed/index.d.ts +3 -2
- package/dist/managed/index.js +1 -13
- package/dist/managed/index.js.map +1 -1
- package/dist/managed/leaf.compact +70 -29
- package/dist/managed/managed/leaf/contract/index.d.ts +78 -25
- package/dist/managed/managed/leaf/contract/index.js +1251 -515
- package/dist/managed/managed/leaf/contract/index.js.map +1 -1
- package/dist/managed/utils.d.ts +5 -0
- package/dist/managed/utils.js +19 -0
- package/dist/managed/utils.js.map +1 -0
- package/dist/operations.d.ts +10 -39
- package/dist/operations.js +68 -352
- package/dist/provider.d.ts +8 -1
- package/dist/provider.js +31 -6
- package/dist/react/DomainProfileWidget.js +5 -2
- package/dist/react/HolographicCard.js +5 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -2
- package/dist/types.d.ts +5 -1
- package/dist/utils/domain.d.ts +5 -0
- package/dist/utils/domain.js +18 -0
- package/dist/utils/imageResolver.js +19 -19
- package/dist/utils/sanitize.d.ts +6 -0
- package/dist/utils/sanitize.js +28 -0
- package/managed/index.js +1 -13
- package/managed/index.js.map +1 -1
- package/managed/leaf.compact +70 -29
- package/managed/managed/leaf/contract/index.js +1251 -515
- package/managed/managed/leaf/contract/index.js.map +1 -1
- package/managed/utils.js +19 -0
- package/managed/utils.js.map +1 -0
- package/package.json +4 -3
package/dist/core.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import type { PublicDataProvider } from "@midnight-ntwrk/midnight-js-types";
|
|
|
2
2
|
import { type DomainData } from "../managed/index.js";
|
|
3
3
|
import type { DomainInfo, DomainSettings, DomainProfileData } from "./types.js";
|
|
4
4
|
import { Result } from "./results.js";
|
|
5
|
-
export declare const TESTNET_TLD_ADDRESS
|
|
5
|
+
export declare const TESTNET_TLD_ADDRESS: string;
|
|
6
|
+
export declare const PREVIEW_TLD_ADDRESS: string;
|
|
6
7
|
export declare function queryContractStateSafely(publicDataProvider: PublicDataProvider, contractAddress: string): Promise<Result<any>>;
|
|
7
8
|
export declare function resolveDomain(domain: string, options?: {
|
|
8
9
|
provider?: PublicDataProvider;
|
package/dist/core.js
CHANGED
|
@@ -2,19 +2,15 @@ import { getNetworkId } from "@midnight-ntwrk/midnight-js-network-id";
|
|
|
2
2
|
import { ShieldedCoinPublicKey } from "@midnight-ntwrk/wallet-sdk-address-format";
|
|
3
3
|
import { ledger } from "./managed/index.js";
|
|
4
4
|
import { formatContractAddress, bytesToHex } from "./utils/address.js";
|
|
5
|
-
import { normalizeDomain, parseFullDomain, DEFAULT_TLD, isTLD } from "./utils/domain.js";
|
|
5
|
+
import { normalizeDomain, parseFullDomain, DEFAULT_TLD, isTLD, domainToKey, keyToDomain } from "./utils/domain.js";
|
|
6
6
|
import { success, failure, wrapAsync } from "./results.js";
|
|
7
7
|
import { NetworkError, ContractNotFoundError, DomainNotFoundError, InvalidDomainError, } from "./errors.js";
|
|
8
|
-
import { getDefaultProvider } from "./provider.js";
|
|
9
|
-
export const TESTNET_TLD_ADDRESS =
|
|
8
|
+
import { getDefaultProvider, getNetworkConfig, NETWORK_REGISTRY } from "./provider.js";
|
|
9
|
+
export const TESTNET_TLD_ADDRESS = NETWORK_REGISTRY.preprod.tldAddress;
|
|
10
|
+
export const PREVIEW_TLD_ADDRESS = NETWORK_REGISTRY.preview.tldAddress;
|
|
10
11
|
function getDefaultTldAddress() {
|
|
11
12
|
const currentNetwork = getNetworkId();
|
|
12
|
-
|
|
13
|
-
case "preprod":
|
|
14
|
-
return TESTNET_TLD_ADDRESS;
|
|
15
|
-
default:
|
|
16
|
-
throw new Error("Provide an address to use the resolver on a Standalone Network.");
|
|
17
|
-
}
|
|
13
|
+
return getNetworkConfig(currentNetwork).tldAddress;
|
|
18
14
|
}
|
|
19
15
|
function getTargetFromLedger(contractLedger) {
|
|
20
16
|
const target = contractLedger.DOMAIN_TARGET;
|
|
@@ -61,10 +57,10 @@ async function traverseDomainHierarchy(publicDataProvider, fullDomain, returnFin
|
|
|
61
57
|
return failure(contractStateResult.error);
|
|
62
58
|
}
|
|
63
59
|
const contractLedger = ledger(contractStateResult.data.data);
|
|
64
|
-
if (!contractLedger.domains.member(part)) {
|
|
60
|
+
if (!contractLedger.domains.member(domainToKey(part).key)) {
|
|
65
61
|
return failure(new DomainNotFoundError(`${part} in ${fullDomain}`));
|
|
66
62
|
}
|
|
67
|
-
const domainData = contractLedger.domains.lookup(part);
|
|
63
|
+
const domainData = contractLedger.domains.lookup(domainToKey(part).key);
|
|
68
64
|
const resolverBytes = domainData.resolver.bytes;
|
|
69
65
|
// Use raw hex for queryContractState (no 0200 prefix)
|
|
70
66
|
currentResolver = bytesToHex(resolverBytes);
|
|
@@ -109,10 +105,10 @@ async function getDomainInfoInContract(contractAddress, domainName, options = {}
|
|
|
109
105
|
if (!contractStateResult.success)
|
|
110
106
|
return failure(contractStateResult.error);
|
|
111
107
|
const contractLedger = ledger(contractStateResult.data.data);
|
|
112
|
-
if (!contractLedger.domains.member(domainName)) {
|
|
108
|
+
if (!contractLedger.domains.member(domainToKey(domainName).key)) {
|
|
113
109
|
return failure(new DomainNotFoundError(domainName));
|
|
114
110
|
}
|
|
115
|
-
const domainData = contractLedger.domains.lookup(domainName);
|
|
111
|
+
const domainData = contractLedger.domains.lookup(domainToKey(domainName).key);
|
|
116
112
|
const ownerCoinPublicKey = new ShieldedCoinPublicKey(Buffer.from(domainData.owner.bytes));
|
|
117
113
|
const ownerAddress = ShieldedCoinPublicKey.codec
|
|
118
114
|
.encode(getNetworkId(), ownerCoinPublicKey)
|
|
@@ -189,7 +185,11 @@ export async function getDomainSettings(fullDomain, options = {}) {
|
|
|
189
185
|
return failure(ledgerResult.error);
|
|
190
186
|
return success({
|
|
191
187
|
coinColor: ledgerResult.data.COIN_COLOR,
|
|
192
|
-
|
|
188
|
+
costs: {
|
|
189
|
+
short: ledgerResult.data.COST_SHORT,
|
|
190
|
+
medium: ledgerResult.data.COST_MED,
|
|
191
|
+
long: ledgerResult.data.COST_LONG,
|
|
192
|
+
},
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
195
|
// Normal case: subdomain — resolve via getDomainInfo
|
|
@@ -202,7 +202,11 @@ export async function getDomainSettings(fullDomain, options = {}) {
|
|
|
202
202
|
return failure(ledgerResult.error);
|
|
203
203
|
return success({
|
|
204
204
|
coinColor: ledgerResult.data.COIN_COLOR,
|
|
205
|
-
|
|
205
|
+
costs: {
|
|
206
|
+
short: ledgerResult.data.COST_SHORT,
|
|
207
|
+
medium: ledgerResult.data.COST_MED,
|
|
208
|
+
long: ledgerResult.data.COST_LONG,
|
|
209
|
+
},
|
|
206
210
|
});
|
|
207
211
|
}
|
|
208
212
|
catch (error) {
|
|
@@ -229,7 +233,11 @@ export async function getDomainProfile(fullDomain, options = {}) {
|
|
|
229
233
|
fields.set(key, value);
|
|
230
234
|
const settings = {
|
|
231
235
|
coinColor: ledgerResult.data.COIN_COLOR,
|
|
232
|
-
|
|
236
|
+
costs: {
|
|
237
|
+
short: ledgerResult.data.COST_SHORT,
|
|
238
|
+
medium: ledgerResult.data.COST_MED,
|
|
239
|
+
long: ledgerResult.data.COST_LONG,
|
|
240
|
+
},
|
|
233
241
|
};
|
|
234
242
|
return success({
|
|
235
243
|
fullDomain: normalized,
|
|
@@ -264,7 +272,7 @@ export async function getSubdomains(fullDomain, options = {}) {
|
|
|
264
272
|
return failure(ledgerResult.error);
|
|
265
273
|
const subdomains = new Map();
|
|
266
274
|
for (const [name, data] of ledgerResult.data.domains) {
|
|
267
|
-
subdomains.set(name, data);
|
|
275
|
+
subdomains.set(keyToDomain(name), data);
|
|
268
276
|
}
|
|
269
277
|
return success(subdomains);
|
|
270
278
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ export * from './utils/domain.js';
|
|
|
3
3
|
export * from './utils/address.js';
|
|
4
4
|
export * from './core.js';
|
|
5
5
|
export * from './provider.js';
|
|
6
|
-
export
|
|
6
|
+
export { buildKvs, insertField, clearField, clearAllFields, addMultipleFields, updateDomainTarget, updateDomainColor, updateDomainCosts, transferDomainOwnership, setDomainResolver, registerDomainFor, buyDomainFor, changeDomainOwner, } from './operations.js';
|
|
7
7
|
export * from './results.js';
|
|
8
8
|
export * from './errors.js';
|
|
9
9
|
export * from './controller-types.js';
|
|
10
|
+
export { resolveImageUrl } from './utils/imageResolver.js';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,8 @@ export * from './utils/domain.js';
|
|
|
3
3
|
export * from './utils/address.js';
|
|
4
4
|
export * from './core.js';
|
|
5
5
|
export * from './provider.js';
|
|
6
|
-
export
|
|
6
|
+
export { buildKvs, insertField, clearField, clearAllFields, addMultipleFields, updateDomainTarget, updateDomainColor, updateDomainCosts, transferDomainOwnership, setDomainResolver, registerDomainFor, buyDomainFor, changeDomainOwner, } from './operations.js';
|
|
7
7
|
export * from './results.js';
|
|
8
8
|
export * from './errors.js';
|
|
9
9
|
export * from './controller-types.js';
|
|
10
|
+
export { resolveImageUrl } from './utils/imageResolver.js';
|
package/dist/managed/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * as Leaf from "./managed/leaf/contract";
|
|
2
|
-
export { type DomainData, type Either, type Maybe, type Witnesses, type Ledger, ledger, Contract } from "./managed/leaf/contract";
|
|
1
|
+
export * as Leaf from "./managed/leaf/contract/index.js";
|
|
2
|
+
export { type DomainData, type Either, type Maybe, type Witnesses, type Ledger, ledger, Contract } from "./managed/leaf/contract/index.js";
|
|
3
|
+
export { domainToKey, keyToDomain } from "./utils.js";
|
package/dist/managed/index.js
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
/* export * as Registry from "./managed/registry/contract/index.cjs";
|
|
2
|
-
export * as Resolver from "./managed/resolver/contract/index.cjs";
|
|
3
|
-
export * as UnifiedDomain from "./managed/unified-domain/contract/index.cjs";
|
|
4
|
-
export * as NS from "./managed/ns/contract/index.cjs";
|
|
5
|
-
export * from "./witnesses.js";
|
|
6
|
-
export { type RegistryRecord } from "./managed/registry/contract/index.cjs";
|
|
7
|
-
export { type ResolutionData } from "./managed/resolver/contract/index.cjs";
|
|
8
|
-
export { type DomainData as UnifiedDomainData } from "./managed/unified-domain/contract/index.cjs";
|
|
9
|
-
export {
|
|
10
|
-
type DomainData,
|
|
11
|
-
type DomainReference,
|
|
12
|
-
} from "./managed/ns/contract/index.cjs";
|
|
13
|
-
*/
|
|
14
1
|
export * as Leaf from "./managed/leaf/contract/index.js";
|
|
15
2
|
export { ledger, Contract } from "./managed/leaf/contract/index.js";
|
|
3
|
+
export { domainToKey, keyToDomain } from "./utils.js";
|
|
16
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAML,MAAM,EACN,QAAQ,EACT,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
pragma language_version 0.20;
|
|
1
|
+
pragma language_version >= 0.20;
|
|
2
2
|
/// # Unshielded Nameservice
|
|
3
3
|
///
|
|
4
4
|
/// Example:
|
|
@@ -26,19 +26,19 @@ import CompactStandardLibrary;
|
|
|
26
26
|
|
|
27
27
|
// This is sealed. If the domain is sold in the parent contract
|
|
28
28
|
// The new owner should deploy a new resolver.
|
|
29
|
-
export sealed ledger PARENT_DOMAIN: Maybe<
|
|
29
|
+
export sealed ledger PARENT_DOMAIN: Maybe<Bytes<32>>;
|
|
30
30
|
export sealed ledger PARENT_RESOLVER: ContractAddress;
|
|
31
|
-
export sealed ledger DOMAIN: Maybe<
|
|
31
|
+
export sealed ledger DOMAIN: Maybe<Bytes<32>>;
|
|
32
32
|
|
|
33
33
|
export ledger DOMAIN_OWNER: ZswapCoinPublicKey;
|
|
34
34
|
// This domain could target either a wallet or a contract
|
|
35
35
|
export ledger DOMAIN_TARGET: Either<ZswapCoinPublicKey, ContractAddress>;
|
|
36
36
|
|
|
37
37
|
// Map<domain, (owner, resolver)>.
|
|
38
|
-
export ledger domains: Map<
|
|
38
|
+
export ledger domains: Map<Bytes<32>, DomainData>;
|
|
39
39
|
|
|
40
40
|
// Set of domains saved here owned by address.
|
|
41
|
-
export ledger domains_owned: Map<ZswapCoinPublicKey, Set<
|
|
41
|
+
export ledger domains_owned: Map<ZswapCoinPublicKey, Set<Bytes<32>>>;
|
|
42
42
|
|
|
43
43
|
export ledger fields: Map<Opaque<'string'>, Opaque<'string'>>;
|
|
44
44
|
|
|
@@ -51,12 +51,14 @@ struct DomainData {
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
constructor(
|
|
54
|
-
parent_domain: Maybe<
|
|
54
|
+
parent_domain: Maybe<Bytes<32>>,
|
|
55
55
|
parent_resolver: ContractAddress,
|
|
56
56
|
target: Either<ZswapCoinPublicKey, ContractAddress>,
|
|
57
|
-
domain: Maybe<
|
|
57
|
+
domain: Maybe<Bytes<32>>,
|
|
58
58
|
coin_color: Bytes<32>,
|
|
59
|
-
|
|
59
|
+
cost_short: Uint<128>,
|
|
60
|
+
cost_med: Uint<128>,
|
|
61
|
+
cost_long: Uint<128>,
|
|
60
62
|
kvs: Vector<10, Maybe<[Opaque<'string'>, Opaque<'string'>]>>
|
|
61
63
|
) {
|
|
62
64
|
DOMAIN_OWNER = ownPublicKey();
|
|
@@ -65,7 +67,9 @@ constructor(
|
|
|
65
67
|
DOMAIN_TARGET = disclose(target);
|
|
66
68
|
DOMAIN = disclose(domain);
|
|
67
69
|
COIN_COLOR = disclose(coin_color);
|
|
68
|
-
|
|
70
|
+
COST_SHORT = disclose(cost_short);
|
|
71
|
+
COST_MED = disclose(cost_med);
|
|
72
|
+
COST_LONG = disclose(cost_long);
|
|
69
73
|
for (const kv of kvs) {
|
|
70
74
|
if (disclose(kv) != none<[Opaque<'string'>, Opaque<'string'>]>()) {
|
|
71
75
|
fields.insert(disclose(kv.value[0]),disclose(kv.value[1]));
|
|
@@ -78,16 +82,20 @@ constructor(
|
|
|
78
82
|
// ===========================================
|
|
79
83
|
|
|
80
84
|
export ledger COIN_COLOR: Bytes<32>;
|
|
81
|
-
export ledger
|
|
85
|
+
export ledger COST_SHORT: Uint<128>; // ≤3 chars
|
|
86
|
+
export ledger COST_MED: Uint<128>; // 4 chars
|
|
87
|
+
export ledger COST_LONG: Uint<128>; // 5+ chars
|
|
82
88
|
|
|
83
|
-
export circuit update_color(c: Bytes<32>)
|
|
89
|
+
export circuit update_color(c: Bytes<32>): [] {
|
|
84
90
|
assert(DOMAIN_OWNER == ownPublicKey(), "Not the owner");
|
|
85
91
|
COIN_COLOR = disclose(c);
|
|
86
92
|
}
|
|
87
93
|
|
|
88
|
-
export circuit
|
|
94
|
+
export circuit update_costs(cost_short: Uint<128>, cost_med: Uint<128>, cost_long: Uint<128>): [] {
|
|
89
95
|
assert(DOMAIN_OWNER == ownPublicKey(), "Not the owner");
|
|
90
|
-
|
|
96
|
+
COST_SHORT = disclose(cost_short);
|
|
97
|
+
COST_MED = disclose(cost_med);
|
|
98
|
+
COST_LONG = disclose(cost_long);
|
|
91
99
|
}
|
|
92
100
|
|
|
93
101
|
export circuit update_target_and_fields(
|
|
@@ -104,21 +112,43 @@ export circuit update_target_and_fields(
|
|
|
104
112
|
|
|
105
113
|
}
|
|
106
114
|
|
|
107
|
-
export circuit buy_domain_for(owner: ZswapCoinPublicKey, domain:
|
|
115
|
+
export circuit buy_domain_for(owner: ZswapCoinPublicKey, domain: Bytes<32>, len: Uint<32>, resolver: ContractAddress): [] {
|
|
116
|
+
assert(len <= 32, "len must be <= 32");
|
|
117
|
+
assert(len >= 1, "domain name cannot be empty");
|
|
118
|
+
|
|
119
|
+
const valid = fold(
|
|
120
|
+
(acc: Boolean, byte: Uint<8>, i: Uint<8>): Boolean =>
|
|
121
|
+
acc && (((i as Uint<32>) < len) || (byte == 255)),
|
|
122
|
+
true, domain,
|
|
123
|
+
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
|
|
124
|
+
);
|
|
125
|
+
assert(valid, "Invalid domain key padding");
|
|
126
|
+
|
|
108
127
|
assert(!domains.member(disclose(domain)), "Domain already exists");
|
|
109
128
|
|
|
110
|
-
//
|
|
111
|
-
|
|
129
|
+
// pricing: shared color, per-tier cost
|
|
130
|
+
const d_len = disclose(len);
|
|
131
|
+
if (d_len <= 3) {
|
|
132
|
+
receiveUnshielded(COIN_COLOR, COST_SHORT);
|
|
133
|
+
sendUnshielded(COIN_COLOR, COST_SHORT, right<ContractAddress, UserAddress>(UserAddress { bytes: DOMAIN_OWNER.bytes }));
|
|
134
|
+
} else if (d_len == 4) {
|
|
135
|
+
receiveUnshielded(COIN_COLOR, COST_MED);
|
|
136
|
+
sendUnshielded(COIN_COLOR, COST_MED, right<ContractAddress, UserAddress>(UserAddress { bytes: DOMAIN_OWNER.bytes }));
|
|
137
|
+
} else {
|
|
138
|
+
receiveUnshielded(COIN_COLOR, COST_LONG);
|
|
139
|
+
sendUnshielded(COIN_COLOR, COST_LONG, right<ContractAddress, UserAddress>(UserAddress { bytes: DOMAIN_OWNER.bytes }));
|
|
140
|
+
}
|
|
112
141
|
|
|
113
142
|
const d_owner = disclose(owner);
|
|
114
143
|
const domain_data = DomainData {
|
|
115
144
|
d_owner,
|
|
116
145
|
disclose(resolver)
|
|
117
146
|
};
|
|
118
|
-
|
|
119
|
-
|
|
147
|
+
domains.insert(disclose(domain), disclose(domain_data));
|
|
148
|
+
|
|
149
|
+
// Track domains owned by address
|
|
120
150
|
if (!domains_owned.member(d_owner)) {
|
|
121
|
-
domains_owned.insert(d_owner, default<Set<
|
|
151
|
+
domains_owned.insert(d_owner, default<Set<Bytes<32>>>);
|
|
122
152
|
}
|
|
123
153
|
domains_owned.lookup(d_owner).insert(disclose(domain));
|
|
124
154
|
}
|
|
@@ -142,12 +172,23 @@ export circuit clear_field(k: Opaque<'string'>): [] {
|
|
|
142
172
|
fields.remove(disclose(k));
|
|
143
173
|
}
|
|
144
174
|
|
|
145
|
-
export circuit clear_all_fields(
|
|
175
|
+
export circuit clear_all_fields(): [] {
|
|
146
176
|
assert(DOMAIN_OWNER == ownPublicKey(), "Not the domain owner");
|
|
147
177
|
fields.resetToDefault();
|
|
148
178
|
}
|
|
149
179
|
|
|
150
|
-
export circuit register_domain_for(owner: ZswapCoinPublicKey, domain:
|
|
180
|
+
export circuit register_domain_for(owner: ZswapCoinPublicKey, domain: Bytes<32>, len: Uint<32>, resolver: ContractAddress): [] {
|
|
181
|
+
assert(len <= 32, "len must be <= 32");
|
|
182
|
+
assert(len >= 1, "domain name cannot be empty");
|
|
183
|
+
|
|
184
|
+
const valid = fold(
|
|
185
|
+
(acc: Boolean, byte: Uint<8>, i: Uint<8>): Boolean =>
|
|
186
|
+
acc && (((i as Uint<32>) < len) || (byte == 255)),
|
|
187
|
+
true, domain,
|
|
188
|
+
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
|
|
189
|
+
);
|
|
190
|
+
assert(valid, "Invalid domain key padding");
|
|
191
|
+
|
|
151
192
|
assert(!domains.member(disclose(domain)), "Domain already exists");
|
|
152
193
|
assert(DOMAIN_OWNER == ownPublicKey(), "Not the domain owner");
|
|
153
194
|
|
|
@@ -161,12 +202,12 @@ export circuit register_domain_for(owner: ZswapCoinPublicKey, domain: Opaque<'st
|
|
|
161
202
|
|
|
162
203
|
// Track domains owned by address
|
|
163
204
|
if (!domains_owned.member(d_owner)) {
|
|
164
|
-
domains_owned.insert(d_owner, default<Set<
|
|
205
|
+
domains_owned.insert(d_owner, default<Set<Bytes<32>>>);
|
|
165
206
|
}
|
|
166
207
|
domains_owned.lookup(d_owner).insert(disclose(domain));
|
|
167
208
|
}
|
|
168
209
|
|
|
169
|
-
export circuit set_resolver(domain:
|
|
210
|
+
export circuit set_resolver(domain: Bytes<32>, resolver: ContractAddress): [] {
|
|
170
211
|
assert(domains.member(disclose(domain)), "Domain does not exist");
|
|
171
212
|
|
|
172
213
|
const current_data = domains.lookup(disclose(domain));
|
|
@@ -186,7 +227,7 @@ export circuit update_domain_target(new_target: Either<ZswapCoinPublicKey, Contr
|
|
|
186
227
|
DOMAIN_TARGET = disclose(new_target);
|
|
187
228
|
}
|
|
188
229
|
|
|
189
|
-
export circuit transfer_domain(domain:
|
|
230
|
+
export circuit transfer_domain(domain: Bytes<32>, new_owner: ZswapCoinPublicKey): [] {
|
|
190
231
|
assert(domains.member(disclose(domain)), "Domain does not exist");
|
|
191
232
|
|
|
192
233
|
const current_data = domains.lookup(disclose(domain));
|
|
@@ -202,7 +243,7 @@ export circuit transfer_domain(domain: Opaque<'string'>, new_owner: ZswapCoinPub
|
|
|
202
243
|
// Update ownership tracking
|
|
203
244
|
domains_owned.lookup(ownPublicKey()).remove(disclose(domain));
|
|
204
245
|
if (!domains_owned.member(disclose(new_owner))) {
|
|
205
|
-
domains_owned.insert(disclose(new_owner), default<Set<
|
|
246
|
+
domains_owned.insert(disclose(new_owner), default<Set<Bytes<32>>>);
|
|
206
247
|
}
|
|
207
248
|
domains_owned.lookup(disclose(new_owner)).insert(disclose(domain));
|
|
208
249
|
}
|
|
@@ -216,12 +257,12 @@ export circuit change_owner(new_owner: ZswapCoinPublicKey) : [] {
|
|
|
216
257
|
|
|
217
258
|
/*
|
|
218
259
|
Read only, but not pure, so let's not use those
|
|
219
|
-
export circuit resolve(domain:
|
|
260
|
+
export circuit resolve(domain: Bytes<32>): DomainData {
|
|
220
261
|
assert(domains.member(disclose(domain)), "Domain does not exist");
|
|
221
262
|
return domains.lookup(disclose(domain));
|
|
222
263
|
}
|
|
223
264
|
|
|
224
|
-
export circuit get_parent_domain(): Maybe<
|
|
265
|
+
export circuit get_parent_domain(): Maybe<Bytes<32>> {
|
|
225
266
|
return PARENT_DOMAIN;
|
|
226
267
|
}
|
|
227
268
|
|
|
@@ -229,7 +270,7 @@ export circuit get_contract_owner(): ZswapCoinPublicKey {
|
|
|
229
270
|
return DOMAIN_OWNER;
|
|
230
271
|
}
|
|
231
272
|
|
|
232
|
-
export circuit get_domain(): Maybe<
|
|
273
|
+
export circuit get_domain(): Maybe<Bytes<32>> {
|
|
233
274
|
return DOMAIN;
|
|
234
275
|
}
|
|
235
276
|
|
|
@@ -241,7 +282,7 @@ export circuit get_parent_resolver(): ContractAddress {
|
|
|
241
282
|
return PARENT_RESOLVER;
|
|
242
283
|
}
|
|
243
284
|
|
|
244
|
-
export circuit addr_owns_domain(addr: ZswapCoinPublicKey, domain:
|
|
285
|
+
export circuit addr_owns_domain(addr: ZswapCoinPublicKey, domain: Bytes<32>): Boolean {
|
|
245
286
|
assert(domains_owned.member(disclose(addr)), "Address does not own domains in this register");
|
|
246
287
|
return domains_owned.lookup(disclose(addr)).member(disclose(domain));
|
|
247
288
|
}
|
|
@@ -13,14 +13,18 @@ export type Witnesses<PS> = {
|
|
|
13
13
|
|
|
14
14
|
export type ImpureCircuits<PS> = {
|
|
15
15
|
update_color(context: __compactRuntime.CircuitContext<PS>, c_0: Uint8Array): __compactRuntime.CircuitResults<PS, []>;
|
|
16
|
-
|
|
16
|
+
update_costs(context: __compactRuntime.CircuitContext<PS>,
|
|
17
|
+
cost_short_0: bigint,
|
|
18
|
+
cost_med_0: bigint,
|
|
19
|
+
cost_long_0: bigint): __compactRuntime.CircuitResults<PS, []>;
|
|
17
20
|
update_target_and_fields(context: __compactRuntime.CircuitContext<PS>,
|
|
18
21
|
new_target_0: Either<{ bytes: Uint8Array },
|
|
19
22
|
{ bytes: Uint8Array }>,
|
|
20
23
|
kvs_0: Maybe<[string, string]>[]): __compactRuntime.CircuitResults<PS, []>;
|
|
21
24
|
buy_domain_for(context: __compactRuntime.CircuitContext<PS>,
|
|
22
25
|
owner_0: { bytes: Uint8Array },
|
|
23
|
-
domain_0:
|
|
26
|
+
domain_0: Uint8Array,
|
|
27
|
+
len_0: bigint,
|
|
24
28
|
resolver_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
25
29
|
add_multiple_fields(context: __compactRuntime.CircuitContext<PS>,
|
|
26
30
|
kvs_0: Maybe<[string, string]>[]): __compactRuntime.CircuitResults<PS, []>;
|
|
@@ -28,20 +32,60 @@ export type ImpureCircuits<PS> = {
|
|
|
28
32
|
k_0: string,
|
|
29
33
|
v_0: string): __compactRuntime.CircuitResults<PS, []>;
|
|
30
34
|
clear_field(context: __compactRuntime.CircuitContext<PS>, k_0: string): __compactRuntime.CircuitResults<PS, []>;
|
|
31
|
-
clear_all_fields(context: __compactRuntime.CircuitContext<PS
|
|
32
|
-
domain_0: string): __compactRuntime.CircuitResults<PS, []>;
|
|
35
|
+
clear_all_fields(context: __compactRuntime.CircuitContext<PS>): __compactRuntime.CircuitResults<PS, []>;
|
|
33
36
|
register_domain_for(context: __compactRuntime.CircuitContext<PS>,
|
|
34
37
|
owner_0: { bytes: Uint8Array },
|
|
35
|
-
domain_0:
|
|
38
|
+
domain_0: Uint8Array,
|
|
39
|
+
len_0: bigint,
|
|
36
40
|
resolver_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
37
41
|
set_resolver(context: __compactRuntime.CircuitContext<PS>,
|
|
38
|
-
domain_0:
|
|
42
|
+
domain_0: Uint8Array,
|
|
39
43
|
resolver_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
40
44
|
update_domain_target(context: __compactRuntime.CircuitContext<PS>,
|
|
41
45
|
new_target_0: Either<{ bytes: Uint8Array },
|
|
42
46
|
{ bytes: Uint8Array }>): __compactRuntime.CircuitResults<PS, []>;
|
|
43
47
|
transfer_domain(context: __compactRuntime.CircuitContext<PS>,
|
|
44
|
-
domain_0:
|
|
48
|
+
domain_0: Uint8Array,
|
|
49
|
+
new_owner_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
50
|
+
change_owner(context: __compactRuntime.CircuitContext<PS>,
|
|
51
|
+
new_owner_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type ProvableCircuits<PS> = {
|
|
55
|
+
update_color(context: __compactRuntime.CircuitContext<PS>, c_0: Uint8Array): __compactRuntime.CircuitResults<PS, []>;
|
|
56
|
+
update_costs(context: __compactRuntime.CircuitContext<PS>,
|
|
57
|
+
cost_short_0: bigint,
|
|
58
|
+
cost_med_0: bigint,
|
|
59
|
+
cost_long_0: bigint): __compactRuntime.CircuitResults<PS, []>;
|
|
60
|
+
update_target_and_fields(context: __compactRuntime.CircuitContext<PS>,
|
|
61
|
+
new_target_0: Either<{ bytes: Uint8Array },
|
|
62
|
+
{ bytes: Uint8Array }>,
|
|
63
|
+
kvs_0: Maybe<[string, string]>[]): __compactRuntime.CircuitResults<PS, []>;
|
|
64
|
+
buy_domain_for(context: __compactRuntime.CircuitContext<PS>,
|
|
65
|
+
owner_0: { bytes: Uint8Array },
|
|
66
|
+
domain_0: Uint8Array,
|
|
67
|
+
len_0: bigint,
|
|
68
|
+
resolver_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
69
|
+
add_multiple_fields(context: __compactRuntime.CircuitContext<PS>,
|
|
70
|
+
kvs_0: Maybe<[string, string]>[]): __compactRuntime.CircuitResults<PS, []>;
|
|
71
|
+
insert_field(context: __compactRuntime.CircuitContext<PS>,
|
|
72
|
+
k_0: string,
|
|
73
|
+
v_0: string): __compactRuntime.CircuitResults<PS, []>;
|
|
74
|
+
clear_field(context: __compactRuntime.CircuitContext<PS>, k_0: string): __compactRuntime.CircuitResults<PS, []>;
|
|
75
|
+
clear_all_fields(context: __compactRuntime.CircuitContext<PS>): __compactRuntime.CircuitResults<PS, []>;
|
|
76
|
+
register_domain_for(context: __compactRuntime.CircuitContext<PS>,
|
|
77
|
+
owner_0: { bytes: Uint8Array },
|
|
78
|
+
domain_0: Uint8Array,
|
|
79
|
+
len_0: bigint,
|
|
80
|
+
resolver_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
81
|
+
set_resolver(context: __compactRuntime.CircuitContext<PS>,
|
|
82
|
+
domain_0: Uint8Array,
|
|
83
|
+
resolver_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
84
|
+
update_domain_target(context: __compactRuntime.CircuitContext<PS>,
|
|
85
|
+
new_target_0: Either<{ bytes: Uint8Array },
|
|
86
|
+
{ bytes: Uint8Array }>): __compactRuntime.CircuitResults<PS, []>;
|
|
87
|
+
transfer_domain(context: __compactRuntime.CircuitContext<PS>,
|
|
88
|
+
domain_0: Uint8Array,
|
|
45
89
|
new_owner_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
46
90
|
change_owner(context: __compactRuntime.CircuitContext<PS>,
|
|
47
91
|
new_owner_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
@@ -52,14 +96,18 @@ export type PureCircuits = {
|
|
|
52
96
|
|
|
53
97
|
export type Circuits<PS> = {
|
|
54
98
|
update_color(context: __compactRuntime.CircuitContext<PS>, c_0: Uint8Array): __compactRuntime.CircuitResults<PS, []>;
|
|
55
|
-
|
|
99
|
+
update_costs(context: __compactRuntime.CircuitContext<PS>,
|
|
100
|
+
cost_short_0: bigint,
|
|
101
|
+
cost_med_0: bigint,
|
|
102
|
+
cost_long_0: bigint): __compactRuntime.CircuitResults<PS, []>;
|
|
56
103
|
update_target_and_fields(context: __compactRuntime.CircuitContext<PS>,
|
|
57
104
|
new_target_0: Either<{ bytes: Uint8Array },
|
|
58
105
|
{ bytes: Uint8Array }>,
|
|
59
106
|
kvs_0: Maybe<[string, string]>[]): __compactRuntime.CircuitResults<PS, []>;
|
|
60
107
|
buy_domain_for(context: __compactRuntime.CircuitContext<PS>,
|
|
61
108
|
owner_0: { bytes: Uint8Array },
|
|
62
|
-
domain_0:
|
|
109
|
+
domain_0: Uint8Array,
|
|
110
|
+
len_0: bigint,
|
|
63
111
|
resolver_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
64
112
|
add_multiple_fields(context: __compactRuntime.CircuitContext<PS>,
|
|
65
113
|
kvs_0: Maybe<[string, string]>[]): __compactRuntime.CircuitResults<PS, []>;
|
|
@@ -67,37 +115,37 @@ export type Circuits<PS> = {
|
|
|
67
115
|
k_0: string,
|
|
68
116
|
v_0: string): __compactRuntime.CircuitResults<PS, []>;
|
|
69
117
|
clear_field(context: __compactRuntime.CircuitContext<PS>, k_0: string): __compactRuntime.CircuitResults<PS, []>;
|
|
70
|
-
clear_all_fields(context: __compactRuntime.CircuitContext<PS
|
|
71
|
-
domain_0: string): __compactRuntime.CircuitResults<PS, []>;
|
|
118
|
+
clear_all_fields(context: __compactRuntime.CircuitContext<PS>): __compactRuntime.CircuitResults<PS, []>;
|
|
72
119
|
register_domain_for(context: __compactRuntime.CircuitContext<PS>,
|
|
73
120
|
owner_0: { bytes: Uint8Array },
|
|
74
|
-
domain_0:
|
|
121
|
+
domain_0: Uint8Array,
|
|
122
|
+
len_0: bigint,
|
|
75
123
|
resolver_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
76
124
|
set_resolver(context: __compactRuntime.CircuitContext<PS>,
|
|
77
|
-
domain_0:
|
|
125
|
+
domain_0: Uint8Array,
|
|
78
126
|
resolver_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
79
127
|
update_domain_target(context: __compactRuntime.CircuitContext<PS>,
|
|
80
128
|
new_target_0: Either<{ bytes: Uint8Array },
|
|
81
129
|
{ bytes: Uint8Array }>): __compactRuntime.CircuitResults<PS, []>;
|
|
82
130
|
transfer_domain(context: __compactRuntime.CircuitContext<PS>,
|
|
83
|
-
domain_0:
|
|
131
|
+
domain_0: Uint8Array,
|
|
84
132
|
new_owner_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
85
133
|
change_owner(context: __compactRuntime.CircuitContext<PS>,
|
|
86
134
|
new_owner_0: { bytes: Uint8Array }): __compactRuntime.CircuitResults<PS, []>;
|
|
87
135
|
}
|
|
88
136
|
|
|
89
137
|
export type Ledger = {
|
|
90
|
-
readonly PARENT_DOMAIN: Maybe<
|
|
138
|
+
readonly PARENT_DOMAIN: Maybe<Uint8Array>;
|
|
91
139
|
readonly PARENT_RESOLVER: { bytes: Uint8Array };
|
|
92
|
-
readonly DOMAIN: Maybe<
|
|
140
|
+
readonly DOMAIN: Maybe<Uint8Array>;
|
|
93
141
|
readonly DOMAIN_OWNER: { bytes: Uint8Array };
|
|
94
142
|
readonly DOMAIN_TARGET: Either<{ bytes: Uint8Array }, { bytes: Uint8Array }>;
|
|
95
143
|
domains: {
|
|
96
144
|
isEmpty(): boolean;
|
|
97
145
|
size(): bigint;
|
|
98
|
-
member(key_0:
|
|
99
|
-
lookup(key_0:
|
|
100
|
-
[Symbol.iterator](): Iterator<[
|
|
146
|
+
member(key_0: Uint8Array): boolean;
|
|
147
|
+
lookup(key_0: Uint8Array): DomainData;
|
|
148
|
+
[Symbol.iterator](): Iterator<[Uint8Array, DomainData]>
|
|
101
149
|
};
|
|
102
150
|
domains_owned: {
|
|
103
151
|
isEmpty(): boolean;
|
|
@@ -106,8 +154,8 @@ export type Ledger = {
|
|
|
106
154
|
lookup(key_0: { bytes: Uint8Array }): {
|
|
107
155
|
isEmpty(): boolean;
|
|
108
156
|
size(): bigint;
|
|
109
|
-
member(elem_0:
|
|
110
|
-
[Symbol.iterator](): Iterator<
|
|
157
|
+
member(elem_0: Uint8Array): boolean;
|
|
158
|
+
[Symbol.iterator](): Iterator<Uint8Array>
|
|
111
159
|
}
|
|
112
160
|
};
|
|
113
161
|
fields: {
|
|
@@ -118,7 +166,9 @@ export type Ledger = {
|
|
|
118
166
|
[Symbol.iterator](): Iterator<[string, string]>
|
|
119
167
|
};
|
|
120
168
|
readonly COIN_COLOR: Uint8Array;
|
|
121
|
-
readonly
|
|
169
|
+
readonly COST_SHORT: bigint;
|
|
170
|
+
readonly COST_MED: bigint;
|
|
171
|
+
readonly COST_LONG: bigint;
|
|
122
172
|
}
|
|
123
173
|
|
|
124
174
|
export type ContractReferenceLocations = any;
|
|
@@ -129,14 +179,17 @@ export declare class Contract<PS = any, W extends Witnesses<PS> = Witnesses<PS>>
|
|
|
129
179
|
witnesses: W;
|
|
130
180
|
circuits: Circuits<PS>;
|
|
131
181
|
impureCircuits: ImpureCircuits<PS>;
|
|
182
|
+
provableCircuits: ProvableCircuits<PS>;
|
|
132
183
|
constructor(witnesses: W);
|
|
133
184
|
initialState(context: __compactRuntime.ConstructorContext<PS>,
|
|
134
|
-
parent_domain_0: Maybe<
|
|
185
|
+
parent_domain_0: Maybe<Uint8Array>,
|
|
135
186
|
parent_resolver_0: { bytes: Uint8Array },
|
|
136
187
|
target_0: Either<{ bytes: Uint8Array }, { bytes: Uint8Array }>,
|
|
137
|
-
domain_0: Maybe<
|
|
188
|
+
domain_0: Maybe<Uint8Array>,
|
|
138
189
|
coin_color_0: Uint8Array,
|
|
139
|
-
|
|
190
|
+
cost_short_0: bigint,
|
|
191
|
+
cost_med_0: bigint,
|
|
192
|
+
cost_long_0: bigint,
|
|
140
193
|
kvs_0: Maybe<[string, string]>[]): __compactRuntime.ConstructorResult<PS>;
|
|
141
194
|
}
|
|
142
195
|
|