@medialane/sdk 0.85.7 → 0.85.9
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/starknet/index.cjs +121 -0
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +44 -1
- package/dist/starknet/index.d.ts +44 -1
- package/dist/starknet/index.js +108 -1
- package/dist/starknet/index.js.map +1 -1
- package/package.json +1 -1
package/dist/starknet/index.cjs
CHANGED
|
@@ -11595,6 +11595,113 @@ function buildDeployAccountParams(ownerPubkey, salt = 0) {
|
|
|
11595
11595
|
contractAddress: computeAccountAddress(ownerPubkey, salt)
|
|
11596
11596
|
};
|
|
11597
11597
|
}
|
|
11598
|
+
var norm = (address) => normalizeAddress("STARKNET", address);
|
|
11599
|
+
var SIGNER_TYPE_NAMES = ["Starknet", "Secp256k1", "Secp256r1"];
|
|
11600
|
+
function encodeFeltArray(items) {
|
|
11601
|
+
return [starknet.num.toHex(items.length), ...items];
|
|
11602
|
+
}
|
|
11603
|
+
function encodeStarknetSigner(pubkey) {
|
|
11604
|
+
return ["0x0", starknet.num.toHex(pubkey)];
|
|
11605
|
+
}
|
|
11606
|
+
function encodeStarknetSignerArray(pubkeys) {
|
|
11607
|
+
return [starknet.num.toHex(pubkeys.length), ...pubkeys.flatMap(encodeStarknetSigner)];
|
|
11608
|
+
}
|
|
11609
|
+
function buildSetFirstGuardianCall(address, guardianPubkey) {
|
|
11610
|
+
return {
|
|
11611
|
+
contractAddress: norm(address),
|
|
11612
|
+
entrypoint: "change_guardians",
|
|
11613
|
+
calldata: [...encodeFeltArray([]), ...encodeStarknetSignerArray([guardianPubkey])]
|
|
11614
|
+
};
|
|
11615
|
+
}
|
|
11616
|
+
function buildTriggerEscapeOwnerCall(targetAddress, newOwnerPubkey) {
|
|
11617
|
+
return {
|
|
11618
|
+
contractAddress: norm(targetAddress),
|
|
11619
|
+
entrypoint: "trigger_escape_owner",
|
|
11620
|
+
calldata: encodeStarknetSigner(newOwnerPubkey)
|
|
11621
|
+
};
|
|
11622
|
+
}
|
|
11623
|
+
function buildCompleteEscapeOwnerCall(targetAddress) {
|
|
11624
|
+
return { contractAddress: norm(targetAddress), entrypoint: "escape_owner", calldata: [] };
|
|
11625
|
+
}
|
|
11626
|
+
function buildCancelEscapeCall(address) {
|
|
11627
|
+
return { contractAddress: norm(address), entrypoint: "cancel_escape", calldata: [] };
|
|
11628
|
+
}
|
|
11629
|
+
function decodeGuardiansInfo(res) {
|
|
11630
|
+
const len = Number(res[0]);
|
|
11631
|
+
const out = [];
|
|
11632
|
+
for (let i = 0; i < len; i++) {
|
|
11633
|
+
const base = 1 + i * 3;
|
|
11634
|
+
out.push({
|
|
11635
|
+
type: SIGNER_TYPE_NAMES[Number(res[base])] ?? "Starknet",
|
|
11636
|
+
guid: res[base + 1],
|
|
11637
|
+
storedValue: res[base + 2]
|
|
11638
|
+
});
|
|
11639
|
+
}
|
|
11640
|
+
return out;
|
|
11641
|
+
}
|
|
11642
|
+
var ESCAPE_TYPE_NAMES = ["None", "Guardian", "Owner"];
|
|
11643
|
+
var ESCAPE_STATUS_NAMES = ["None", "NotReady", "Ready", "Expired"];
|
|
11644
|
+
function decodeEscapeAndStatus(res) {
|
|
11645
|
+
const readyAt = Number(res[0]);
|
|
11646
|
+
const escapeType = ESCAPE_TYPE_NAMES[Number(res[1])] ?? "None";
|
|
11647
|
+
const optionTag = Number(res[2]);
|
|
11648
|
+
const statusIndex = optionTag === 0 ? 5 : 3;
|
|
11649
|
+
const status = ESCAPE_STATUS_NAMES[Number(res[statusIndex])] ?? "None";
|
|
11650
|
+
return { readyAt, escapeType, status };
|
|
11651
|
+
}
|
|
11652
|
+
async function getGuardians(provider, address) {
|
|
11653
|
+
const res = await provider.callContract({
|
|
11654
|
+
contractAddress: norm(address),
|
|
11655
|
+
entrypoint: "get_guardians_info",
|
|
11656
|
+
calldata: []
|
|
11657
|
+
});
|
|
11658
|
+
return decodeGuardiansInfo(res);
|
|
11659
|
+
}
|
|
11660
|
+
async function getEscape(provider, address) {
|
|
11661
|
+
const res = await provider.callContract({
|
|
11662
|
+
contractAddress: norm(address),
|
|
11663
|
+
entrypoint: "get_escape_and_status",
|
|
11664
|
+
calldata: []
|
|
11665
|
+
});
|
|
11666
|
+
return decodeEscapeAndStatus(res);
|
|
11667
|
+
}
|
|
11668
|
+
async function getEscapeSecurityPeriod(provider, address) {
|
|
11669
|
+
const res = await provider.callContract({
|
|
11670
|
+
contractAddress: norm(address),
|
|
11671
|
+
entrypoint: "get_escape_security_period",
|
|
11672
|
+
calldata: []
|
|
11673
|
+
});
|
|
11674
|
+
return Number(res[0]);
|
|
11675
|
+
}
|
|
11676
|
+
async function deriveAesKey(prfSecret, hkdfInfo) {
|
|
11677
|
+
const hkdf = await crypto.subtle.importKey("raw", prfSecret, "HKDF", false, ["deriveKey"]);
|
|
11678
|
+
return crypto.subtle.deriveKey(
|
|
11679
|
+
{ name: "HKDF", hash: "SHA-256", salt: new Uint8Array(0), info: hkdfInfo },
|
|
11680
|
+
hkdf,
|
|
11681
|
+
{ name: "AES-GCM", length: 256 },
|
|
11682
|
+
false,
|
|
11683
|
+
["encrypt", "decrypt"]
|
|
11684
|
+
);
|
|
11685
|
+
}
|
|
11686
|
+
function generateStarkKeyPair() {
|
|
11687
|
+
const privateKeyHex = "0x" + Array.from(starknet.ec.starkCurve.utils.randomPrivateKey()).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
11688
|
+
return { privateKeyHex, publicKeyHex: starknet.ec.starkCurve.getStarkKey(privateKeyHex) };
|
|
11689
|
+
}
|
|
11690
|
+
async function sealPrivateKey(aesKey, iv, privateKeyHex) {
|
|
11691
|
+
return crypto.subtle.encrypt(
|
|
11692
|
+
{ name: "AES-GCM", iv },
|
|
11693
|
+
aesKey,
|
|
11694
|
+
new TextEncoder().encode(privateKeyHex)
|
|
11695
|
+
);
|
|
11696
|
+
}
|
|
11697
|
+
async function unsealPrivateKey(aesKey, iv, ciphertext) {
|
|
11698
|
+
const buf = await crypto.subtle.decrypt({ name: "AES-GCM", iv }, aesKey, ciphertext);
|
|
11699
|
+
return new TextDecoder().decode(buf);
|
|
11700
|
+
}
|
|
11701
|
+
function signWithPrivateKey(privateKeyHex, msgHash) {
|
|
11702
|
+
const sig = starknet.ec.starkCurve.sign(msgHash, privateKeyHex);
|
|
11703
|
+
return [starknet.num.toHex(sig.r), starknet.num.toHex(sig.s)];
|
|
11704
|
+
}
|
|
11598
11705
|
|
|
11599
11706
|
exports.ADMIN_HEADERS = ADMIN_HEADERS;
|
|
11600
11707
|
exports.ADMIN_SCOPE = ADMIN_SCOPE;
|
|
@@ -11633,25 +11740,36 @@ exports.adminRequestDigest = adminRequestDigest;
|
|
|
11633
11740
|
exports.build1155CancellationTypedData = build1155CancellationTypedData;
|
|
11634
11741
|
exports.build1155OrderTypedData = build1155OrderTypedData;
|
|
11635
11742
|
exports.buildAdminSessionTypedData = buildAdminSessionTypedData;
|
|
11743
|
+
exports.buildCancelEscapeCall = buildCancelEscapeCall;
|
|
11636
11744
|
exports.buildCancellationTypedData = buildCancellationTypedData;
|
|
11637
11745
|
exports.buildChangeOwnersCall = buildChangeOwnersCall;
|
|
11746
|
+
exports.buildCompleteEscapeOwnerCall = buildCompleteEscapeOwnerCall;
|
|
11638
11747
|
exports.buildCreateCreatorCoinCall = buildCreateCreatorCoinCall;
|
|
11639
11748
|
exports.buildDeployAccountParams = buildDeployAccountParams;
|
|
11640
11749
|
exports.buildFeeCall = buildFeeCall;
|
|
11641
11750
|
exports.buildLaunchOnEkuboCalls = buildLaunchOnEkuboCalls;
|
|
11642
11751
|
exports.buildOrderTypedData = buildOrderTypedData;
|
|
11752
|
+
exports.buildSetFirstGuardianCall = buildSetFirstGuardianCall;
|
|
11753
|
+
exports.buildTriggerEscapeOwnerCall = buildTriggerEscapeOwnerCall;
|
|
11643
11754
|
exports.buybackQuoteRaw = buybackQuoteRaw;
|
|
11644
11755
|
exports.coinToRaw = toRaw;
|
|
11645
11756
|
exports.computeAccountAddress = computeAccountAddress;
|
|
11646
11757
|
exports.computeOwnerGuid = computeOwnerGuid;
|
|
11647
11758
|
exports.createAdminSessionGrant = createAdminSessionGrant;
|
|
11759
|
+
exports.decodeEscapeAndStatus = decodeEscapeAndStatus;
|
|
11760
|
+
exports.decodeGuardiansInfo = decodeGuardiansInfo;
|
|
11761
|
+
exports.deriveAesKey = deriveAesKey;
|
|
11648
11762
|
exports.deriveOwnerKeyPair = deriveOwnerKeyPair;
|
|
11649
11763
|
exports.encodeAdminHeaders = encodeAdminHeaders;
|
|
11650
11764
|
exports.encodeByteArray = encodeByteArray;
|
|
11651
11765
|
exports.fdvHuman = fdvHuman;
|
|
11766
|
+
exports.generateStarkKeyPair = generateStarkKeyPair;
|
|
11652
11767
|
exports.getCounter = getCounter;
|
|
11653
11768
|
exports.getCounter1155 = getCounter1155;
|
|
11654
11769
|
exports.getCreatorCoinPrice = getCreatorCoinPrice;
|
|
11770
|
+
exports.getEscape = getEscape;
|
|
11771
|
+
exports.getEscapeSecurityPeriod = getEscapeSecurityPeriod;
|
|
11772
|
+
exports.getGuardians = getGuardians;
|
|
11655
11773
|
exports.getOrderDetails = getOrderDetails;
|
|
11656
11774
|
exports.getOrderDetails1155 = getOrderDetails1155;
|
|
11657
11775
|
exports.getSiwsStorageKey = getSiwsStorageKey;
|
|
@@ -11664,11 +11782,14 @@ exports.parseCreatorCoinCreated = parseCreatorCoinCreated;
|
|
|
11664
11782
|
exports.priceToEkuboParams = priceToEkuboParams;
|
|
11665
11783
|
exports.randomNonce = randomNonce;
|
|
11666
11784
|
exports.requestSiwsToken = requestSiwsToken;
|
|
11785
|
+
exports.sealPrivateKey = sealPrivateKey;
|
|
11667
11786
|
exports.sessionKeyHashOf = sessionKeyHashOf;
|
|
11668
11787
|
exports.signAdminRequest = signAdminRequest;
|
|
11788
|
+
exports.signWithPrivateKey = signWithPrivateKey;
|
|
11669
11789
|
exports.storeSiwsToken = storeSiwsToken;
|
|
11670
11790
|
exports.teamCoinsRaw = teamCoinsRaw;
|
|
11671
11791
|
exports.toDropContractConditions = toContractConditions;
|
|
11792
|
+
exports.unsealPrivateKey = unsealPrivateKey;
|
|
11672
11793
|
exports.validateCoinName = validateName;
|
|
11673
11794
|
exports.validateCoinSupply = validateSupply;
|
|
11674
11795
|
exports.validateCoinSymbol = validateSymbol;
|