starknet 8.4.0 → 8.5.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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +79 -2
- package/dist/index.global.js +178 -5
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +182 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +178 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -9040,8 +9040,181 @@ var StarknetId = class _StarknetId {
|
|
|
9040
9040
|
}
|
|
9041
9041
|
};
|
|
9042
9042
|
|
|
9043
|
+
// src/provider/extensions/brotherId.ts
|
|
9044
|
+
function isBrotherDomain(domain) {
|
|
9045
|
+
return domain.endsWith(".brother");
|
|
9046
|
+
}
|
|
9047
|
+
function encodeBrotherDomain(domain) {
|
|
9048
|
+
const brotherName = domain.endsWith(".brother") ? domain.replace(".brother", "") : domain;
|
|
9049
|
+
return useEncoded(brotherName);
|
|
9050
|
+
}
|
|
9051
|
+
function decodeBrotherDomain(encoded) {
|
|
9052
|
+
const decoded = useDecoded([encoded]);
|
|
9053
|
+
if (decoded.endsWith(".stark")) {
|
|
9054
|
+
return decoded.replace(".stark", ".brother");
|
|
9055
|
+
}
|
|
9056
|
+
return decoded ? `${decoded}.brother` : decoded;
|
|
9057
|
+
}
|
|
9058
|
+
function getBrotherIdContract(chainId) {
|
|
9059
|
+
switch (chainId) {
|
|
9060
|
+
case _StarknetChainId.SN_MAIN:
|
|
9061
|
+
return "0x0212f1c57700f5a3913dd11efba540196aad4cf67772f7090c62709dd804fa74";
|
|
9062
|
+
default:
|
|
9063
|
+
return "0x0212f1c57700f5a3913dd11efba540196aad4cf67772f7090c62709dd804fa74";
|
|
9064
|
+
}
|
|
9065
|
+
}
|
|
9066
|
+
var BrotherId = class _BrotherId {
|
|
9067
|
+
/**
|
|
9068
|
+
* Gets the primary Brother domain name for an address
|
|
9069
|
+
* @param address - The address to get the domain for
|
|
9070
|
+
* @param BrotherIdContract - Optional contract address
|
|
9071
|
+
* @returns The domain name with .brother suffix
|
|
9072
|
+
*/
|
|
9073
|
+
async getBrotherName(address, BrotherIdContract) {
|
|
9074
|
+
return _BrotherId.getBrotherName(
|
|
9075
|
+
// After Mixin, this is ProviderInterface
|
|
9076
|
+
this,
|
|
9077
|
+
address,
|
|
9078
|
+
BrotherIdContract
|
|
9079
|
+
);
|
|
9080
|
+
}
|
|
9081
|
+
/**
|
|
9082
|
+
* Gets the address associated with a Brother domain name
|
|
9083
|
+
* @param name - The domain name (with or without .brother suffix)
|
|
9084
|
+
* @param BrotherIdContract - Optional contract address
|
|
9085
|
+
* @returns The resolver address for the domain
|
|
9086
|
+
*/
|
|
9087
|
+
async getAddressFromBrotherName(name, BrotherIdContract) {
|
|
9088
|
+
return _BrotherId.getAddressFromBrotherName(
|
|
9089
|
+
// After Mixin, this is ProviderInterface
|
|
9090
|
+
this,
|
|
9091
|
+
name,
|
|
9092
|
+
BrotherIdContract
|
|
9093
|
+
);
|
|
9094
|
+
}
|
|
9095
|
+
/**
|
|
9096
|
+
* Gets the complete profile information for a Brother domain
|
|
9097
|
+
* @param address - The address to get the profile for
|
|
9098
|
+
* @param BrotherIdContract - Optional contract address
|
|
9099
|
+
* @returns The complete Brother profile information
|
|
9100
|
+
*/
|
|
9101
|
+
async getBrotherProfile(address, BrotherIdContract) {
|
|
9102
|
+
return _BrotherId.getBrotherProfile(
|
|
9103
|
+
// After Mixin, this is ProviderInterface
|
|
9104
|
+
this,
|
|
9105
|
+
address,
|
|
9106
|
+
BrotherIdContract
|
|
9107
|
+
);
|
|
9108
|
+
}
|
|
9109
|
+
/**
|
|
9110
|
+
* Static implementation of getBrotherName
|
|
9111
|
+
* @param provider - The provider interface
|
|
9112
|
+
* @param address - The address to get the domain for
|
|
9113
|
+
* @param BrotherIdContract - Optional contract address
|
|
9114
|
+
* @returns The domain name with .brother suffix
|
|
9115
|
+
*/
|
|
9116
|
+
static async getBrotherName(provider, address, BrotherIdContract) {
|
|
9117
|
+
const chainId = await provider.getChainId();
|
|
9118
|
+
const contract = BrotherIdContract ?? getBrotherIdContract(chainId);
|
|
9119
|
+
try {
|
|
9120
|
+
const primaryDomain = await provider.callContract({
|
|
9121
|
+
contractAddress: contract,
|
|
9122
|
+
entrypoint: "getPrimary",
|
|
9123
|
+
calldata: CallData.compile({
|
|
9124
|
+
user: address
|
|
9125
|
+
})
|
|
9126
|
+
});
|
|
9127
|
+
if (!primaryDomain[0] || primaryDomain[0] === "0x0") {
|
|
9128
|
+
throw Error("Brother name not found");
|
|
9129
|
+
}
|
|
9130
|
+
const encodedDomain = BigInt(primaryDomain[0]);
|
|
9131
|
+
return decodeBrotherDomain(encodedDomain);
|
|
9132
|
+
} catch (e) {
|
|
9133
|
+
if (e instanceof Error && e.message === "Brother name not found") {
|
|
9134
|
+
throw e;
|
|
9135
|
+
}
|
|
9136
|
+
throw Error("Could not get brother name");
|
|
9137
|
+
}
|
|
9138
|
+
}
|
|
9139
|
+
/**
|
|
9140
|
+
* Static implementation of getAddressFromBrotherName
|
|
9141
|
+
* @param provider - The provider interface
|
|
9142
|
+
* @param name - The domain name
|
|
9143
|
+
* @param BrotherIdContract - Optional contract address
|
|
9144
|
+
* @returns The resolver address
|
|
9145
|
+
*/
|
|
9146
|
+
static async getAddressFromBrotherName(provider, name, BrotherIdContract) {
|
|
9147
|
+
const brotherName = name.endsWith(".brother") ? name : `${name}.brother`;
|
|
9148
|
+
if (!isBrotherDomain(brotherName)) {
|
|
9149
|
+
throw new Error("Invalid domain, must be a valid .brother domain");
|
|
9150
|
+
}
|
|
9151
|
+
const chainId = await provider.getChainId();
|
|
9152
|
+
const contract = BrotherIdContract ?? getBrotherIdContract(chainId);
|
|
9153
|
+
try {
|
|
9154
|
+
const domainDetails = await provider.callContract({
|
|
9155
|
+
contractAddress: contract,
|
|
9156
|
+
entrypoint: "get_details_by_domain",
|
|
9157
|
+
calldata: CallData.compile({
|
|
9158
|
+
domain: encodeBrotherDomain(brotherName)
|
|
9159
|
+
})
|
|
9160
|
+
});
|
|
9161
|
+
if (!domainDetails[0] || domainDetails[1] === "0x0") {
|
|
9162
|
+
throw Error("Could not get address from brother name");
|
|
9163
|
+
}
|
|
9164
|
+
return domainDetails[1];
|
|
9165
|
+
} catch {
|
|
9166
|
+
throw Error("Could not get address from brother name");
|
|
9167
|
+
}
|
|
9168
|
+
}
|
|
9169
|
+
/**
|
|
9170
|
+
* Static implementation of getBrotherProfile
|
|
9171
|
+
* @param provider - The provider interface
|
|
9172
|
+
* @param address - The address to get the profile for
|
|
9173
|
+
* @param BrotherIdContract - Optional contract address
|
|
9174
|
+
* @returns The complete Brother profile
|
|
9175
|
+
*/
|
|
9176
|
+
static async getBrotherProfile(provider, address, BrotherIdContract) {
|
|
9177
|
+
const chainId = await provider.getChainId();
|
|
9178
|
+
const contract = BrotherIdContract ?? getBrotherIdContract(chainId);
|
|
9179
|
+
try {
|
|
9180
|
+
const primaryDomain = await provider.callContract({
|
|
9181
|
+
contractAddress: contract,
|
|
9182
|
+
entrypoint: "getPrimary",
|
|
9183
|
+
calldata: CallData.compile({
|
|
9184
|
+
user: address
|
|
9185
|
+
})
|
|
9186
|
+
});
|
|
9187
|
+
if (!primaryDomain[0] || primaryDomain[0] === "0x0") {
|
|
9188
|
+
throw Error("Brother profile not found");
|
|
9189
|
+
}
|
|
9190
|
+
const encodedDomain = BigInt(primaryDomain[0]);
|
|
9191
|
+
const decodedDomain = decodeBrotherDomain(encodedDomain);
|
|
9192
|
+
const domain = decodedDomain.replace(".brother", "");
|
|
9193
|
+
const domainDetails = await provider.callContract({
|
|
9194
|
+
contractAddress: contract,
|
|
9195
|
+
entrypoint: "get_details_by_domain",
|
|
9196
|
+
calldata: CallData.compile({
|
|
9197
|
+
domain: encodeBrotherDomain(domain)
|
|
9198
|
+
})
|
|
9199
|
+
});
|
|
9200
|
+
return {
|
|
9201
|
+
name: domain,
|
|
9202
|
+
resolver: domainDetails[1],
|
|
9203
|
+
tokenId: domainDetails[2],
|
|
9204
|
+
expiryDate: parseInt(domainDetails[3], 16),
|
|
9205
|
+
lastTransferTime: parseInt(domainDetails[4], 16)
|
|
9206
|
+
};
|
|
9207
|
+
} catch (e) {
|
|
9208
|
+
if (e instanceof Error && e.message === "Brother profile not found") {
|
|
9209
|
+
throw e;
|
|
9210
|
+
}
|
|
9211
|
+
throw Error("Could not get brother profile");
|
|
9212
|
+
}
|
|
9213
|
+
}
|
|
9214
|
+
};
|
|
9215
|
+
|
|
9043
9216
|
// src/provider/extensions/default.ts
|
|
9044
|
-
var RpcProvider2 = class extends Mixin(RpcProvider, StarknetId) {
|
|
9217
|
+
var RpcProvider2 = class extends Mixin(RpcProvider, StarknetId, BrotherId) {
|
|
9045
9218
|
};
|
|
9046
9219
|
|
|
9047
9220
|
// src/provider/interface.ts
|
|
@@ -12209,7 +12382,10 @@ export {
|
|
|
12209
12382
|
BlockStatus,
|
|
12210
12383
|
BlockTag,
|
|
12211
12384
|
CairoByteArray,
|
|
12385
|
+
CairoBytes31,
|
|
12212
12386
|
CairoCustomEnum,
|
|
12387
|
+
CairoFelt,
|
|
12388
|
+
CairoFelt252,
|
|
12213
12389
|
CairoFixedArray,
|
|
12214
12390
|
CairoInt128,
|
|
12215
12391
|
CairoInt16,
|
|
@@ -12223,6 +12399,7 @@ export {
|
|
|
12223
12399
|
CairoUint128,
|
|
12224
12400
|
CairoUint16,
|
|
12225
12401
|
CairoUint256,
|
|
12402
|
+
CairoUint32,
|
|
12226
12403
|
CairoUint512,
|
|
12227
12404
|
CairoUint64,
|
|
12228
12405
|
CairoUint8,
|