@medialane/sdk 0.145.0 → 0.146.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/dist/{errors-SGwgtvtF.d.cts → errors-BU-LJRp3.d.cts} +1 -16
- package/dist/{errors-DUiebYFo.d.ts → errors-CTfk25XX.d.ts} +1 -16
- package/dist/index.cjs +0 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -7
- package/dist/index.d.ts +2 -7
- package/dist/index.js +0 -9
- package/dist/index.js.map +1 -1
- package/dist/starknet/index.cjs +12 -68
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +7 -23
- package/dist/starknet/index.d.ts +7 -23
- package/dist/starknet/index.js +12 -66
- package/dist/starknet/index.js.map +1 -1
- package/package.json +1 -1
package/dist/starknet/index.cjs
CHANGED
|
@@ -352,7 +352,6 @@ var ApiClient = class {
|
|
|
352
352
|
getActiveOrdersForToken(contract, tokenId) {
|
|
353
353
|
return this.get(`/v1/orders/token/${this.addr(contract)}/${tokenId}`);
|
|
354
354
|
}
|
|
355
|
-
/** Offers others made on the address's assets. */
|
|
356
355
|
getReceivedOffers(address, opts = {}) {
|
|
357
356
|
const params = new URLSearchParams({ page: String(opts.page ?? 1), limit: String(opts.limit ?? 50) });
|
|
358
357
|
return this.get(`/v1/orders/received/${this.addr(address)}?${params}`);
|
|
@@ -511,7 +510,6 @@ var ApiClient = class {
|
|
|
511
510
|
uploadMetadata(metadata) {
|
|
512
511
|
return this.post("/v1/metadata/upload", metadata);
|
|
513
512
|
}
|
|
514
|
-
/** Pins several JSON files as one IPFS directory, e.g. a drop's token metadata. */
|
|
515
513
|
async uploadMetadataDirectory(files) {
|
|
516
514
|
const res = await this.post("/v1/metadata/upload-directory", { files });
|
|
517
515
|
return res.data;
|
|
@@ -565,7 +563,6 @@ var ApiClient = class {
|
|
|
565
563
|
headers: this.asSubject(siwsToken)
|
|
566
564
|
});
|
|
567
565
|
}
|
|
568
|
-
/** @deprecated Use the funding methods (`createFunding`, or `fundWithChainTransfer` from `@medialane/sdk/starknet`). This call only nudges a legacy scanner and never credits anything itself. */
|
|
569
566
|
checkDeposit(txHash, siwsToken) {
|
|
570
567
|
return this.request("/v1/portal/credits/check", {
|
|
571
568
|
method: "POST",
|
|
@@ -757,14 +754,9 @@ var ApiClient = class {
|
|
|
757
754
|
async verifyEmailCode(email, code) {
|
|
758
755
|
await this.post("/v1/auth/email/verify-code", { email, code });
|
|
759
756
|
}
|
|
760
|
-
/**
|
|
761
|
-
* Makes the passkey the only owner of the session account's wallet. `signature` is the passkey's owner-alive
|
|
762
|
-
* proof for the wallet. Answers 409 when the wallet is already set up.
|
|
763
|
-
*/
|
|
764
757
|
setupWalletKey(params) {
|
|
765
758
|
return this.post("/v1/users/me/wallet/key", params);
|
|
766
759
|
}
|
|
767
|
-
/** The session account's wallet, and whether its passkey still has to be set up (`setupWalletKey`). */
|
|
768
760
|
async getSessionWallet() {
|
|
769
761
|
const body = await this.post("/v1/users/me/wallet", {});
|
|
770
762
|
return body.walletAddress ? { walletAddress: body.walletAddress, needsKeySetup: body.needsKeySetup === true } : null;
|
|
@@ -12431,12 +12423,11 @@ function computeAccountAddress(ownerPubkey, salt = 0) {
|
|
|
12431
12423
|
}
|
|
12432
12424
|
var STARKNET_SIGNER_TYPE = "0x537461726b6e6574205369676e6572";
|
|
12433
12425
|
var OPTION_NONE = "0x1";
|
|
12434
|
-
var OPTION_SOME = "0x0";
|
|
12435
12426
|
var SIGNER_STARKNET = "0x0";
|
|
12436
12427
|
function computeOwnerGuid(ownerPubkey) {
|
|
12437
12428
|
return starknet.hash.computePoseidonHash(STARKNET_SIGNER_TYPE, starknet.num.toHex(ownerPubkey));
|
|
12438
12429
|
}
|
|
12439
|
-
function changeOwners(accountAddress, guidsToRemove, pubkeysToAdd
|
|
12430
|
+
function changeOwners(accountAddress, guidsToRemove, pubkeysToAdd) {
|
|
12440
12431
|
return {
|
|
12441
12432
|
contractAddress: accountAddress,
|
|
12442
12433
|
entrypoint: "change_owners",
|
|
@@ -12445,55 +12436,10 @@ function changeOwners(accountAddress, guidsToRemove, pubkeysToAdd, ownerAlive) {
|
|
|
12445
12436
|
...guidsToRemove,
|
|
12446
12437
|
starknet.num.toHex(pubkeysToAdd.length),
|
|
12447
12438
|
...pubkeysToAdd.flatMap((p) => [SIGNER_STARKNET, starknet.num.toHex(p)]),
|
|
12448
|
-
|
|
12439
|
+
OPTION_NONE
|
|
12449
12440
|
]
|
|
12450
12441
|
};
|
|
12451
12442
|
}
|
|
12452
|
-
function ownerAliveTypedData(newOwnerGuid, expiration, chainId) {
|
|
12453
|
-
return {
|
|
12454
|
-
types: {
|
|
12455
|
-
StarknetDomain: [
|
|
12456
|
-
{ name: "name", type: "shortstring" },
|
|
12457
|
-
{ name: "version", type: "shortstring" },
|
|
12458
|
-
{ name: "chainId", type: "shortstring" },
|
|
12459
|
-
{ name: "revision", type: "shortstring" }
|
|
12460
|
-
],
|
|
12461
|
-
"Owner Alive": [
|
|
12462
|
-
{ name: "Owner GUID", type: "felt" },
|
|
12463
|
-
{ name: "Signature expiration", type: "timestamp" }
|
|
12464
|
-
]
|
|
12465
|
-
},
|
|
12466
|
-
primaryType: "Owner Alive",
|
|
12467
|
-
domain: { name: "Owner Alive", version: "1", chainId, revision: "1" },
|
|
12468
|
-
message: { "Owner GUID": newOwnerGuid, "Signature expiration": expiration }
|
|
12469
|
-
};
|
|
12470
|
-
}
|
|
12471
|
-
function ownerAliveCalldata(proof) {
|
|
12472
|
-
if (proof.signature.length !== 2) {
|
|
12473
|
-
throw new Error("owner-alive proof needs an r and s from the incoming owner");
|
|
12474
|
-
}
|
|
12475
|
-
return [
|
|
12476
|
-
OPTION_SOME,
|
|
12477
|
-
SIGNER_STARKNET,
|
|
12478
|
-
starknet.num.toHex(proof.newOwnerPubkey),
|
|
12479
|
-
starknet.num.toHex(proof.signature[0]),
|
|
12480
|
-
starknet.num.toHex(proof.signature[1]),
|
|
12481
|
-
starknet.num.toHex(proof.expiration)
|
|
12482
|
-
];
|
|
12483
|
-
}
|
|
12484
|
-
function buildChangeOwnersCall(accountAddress, removeOwnerPubkey, addOwnerPubkey, ownerAlive) {
|
|
12485
|
-
if (!ownerAlive) {
|
|
12486
|
-
throw new Error(
|
|
12487
|
-
"Replacing the signing owner requires an owner-alive proof from the new owner. Sign ownerAliveTypedData with the new owner key and pass it here."
|
|
12488
|
-
);
|
|
12489
|
-
}
|
|
12490
|
-
return changeOwners(
|
|
12491
|
-
accountAddress,
|
|
12492
|
-
[computeOwnerGuid(removeOwnerPubkey)],
|
|
12493
|
-
[addOwnerPubkey],
|
|
12494
|
-
ownerAlive
|
|
12495
|
-
);
|
|
12496
|
-
}
|
|
12497
12443
|
function buildAddOwnerCall(accountAddress, addOwnerPubkey) {
|
|
12498
12444
|
return changeOwners(accountAddress, [], [addOwnerPubkey]);
|
|
12499
12445
|
}
|
|
@@ -13246,20 +13192,20 @@ function createMediaWallet(config) {
|
|
|
13246
13192
|
}
|
|
13247
13193
|
};
|
|
13248
13194
|
}
|
|
13195
|
+
|
|
13196
|
+
// src/session/session-wallet.ts
|
|
13249
13197
|
async function adoptSessionWallet(api, saveAddress) {
|
|
13250
13198
|
const wallet = await api.getSessionWallet();
|
|
13251
13199
|
if (wallet) saveAddress(wallet.walletAddress);
|
|
13252
13200
|
return wallet;
|
|
13253
13201
|
}
|
|
13254
|
-
|
|
13255
|
-
|
|
13256
|
-
const
|
|
13257
|
-
const
|
|
13258
|
-
|
|
13259
|
-
const
|
|
13260
|
-
|
|
13261
|
-
const result = await api.setupWalletKey({ newOwnerPubkey: sealed.ownerPubKey, signature, expiration });
|
|
13262
|
-
deps.saveOwner({ ...sealed, address: result.walletAddress });
|
|
13202
|
+
async function claimSessionWallet(api, walletAddress, deps) {
|
|
13203
|
+
const saved = deps.loadOwner();
|
|
13204
|
+
const resuming = saved !== null && normalizeWalletAddress(saved.address) === normalizeWalletAddress(walletAddress);
|
|
13205
|
+
const sealed = resuming ? saved : { ...(await deps.createOwnerKey()).sealed, address: walletAddress };
|
|
13206
|
+
if (!resuming) deps.saveOwner(sealed);
|
|
13207
|
+
const { removeOwnerGuid } = await api.setupWalletKey({ newOwnerPubkey: sealed.ownerPubKey });
|
|
13208
|
+
if (removeOwnerGuid) await deps.removeOwner(sealed, removeOwnerGuid);
|
|
13263
13209
|
}
|
|
13264
13210
|
|
|
13265
13211
|
exports.ADMIN_HEADERS = ADMIN_HEADERS;
|
|
@@ -13315,7 +13261,6 @@ exports.buildAddOwnerCall = buildAddOwnerCall;
|
|
|
13315
13261
|
exports.buildAdminSessionTypedData = buildAdminSessionTypedData;
|
|
13316
13262
|
exports.buildCancelEscapeCall = buildCancelEscapeCall;
|
|
13317
13263
|
exports.buildCancellationTypedData = buildCancellationTypedData;
|
|
13318
|
-
exports.buildChangeOwnersCall = buildChangeOwnersCall;
|
|
13319
13264
|
exports.buildCompleteEscapeOwnerCall = buildCompleteEscapeOwnerCall;
|
|
13320
13265
|
exports.buildCreateCreatorCoinCall = buildCreateCreatorCoinCall;
|
|
13321
13266
|
exports.buildDeployAccountParams = buildDeployAccountParams;
|
|
@@ -13329,6 +13274,7 @@ exports.buildSetFirstGuardianCall = buildSetFirstGuardianCall;
|
|
|
13329
13274
|
exports.buildTriggerEscapeOwnerCall = buildTriggerEscapeOwnerCall;
|
|
13330
13275
|
exports.buybackQuoteRaw = buybackQuoteRaw;
|
|
13331
13276
|
exports.canRemoveDevice = canRemoveDevice;
|
|
13277
|
+
exports.claimSessionWallet = claimSessionWallet;
|
|
13332
13278
|
exports.coinToRaw = toRaw;
|
|
13333
13279
|
exports.completeDeployment = completeDeployment;
|
|
13334
13280
|
exports.computeAccountAddress = computeAccountAddress;
|
|
@@ -13378,7 +13324,6 @@ exports.isValidStarknetAddress = isValidStarknetAddress;
|
|
|
13378
13324
|
exports.mintedTokenIdFromReceipt = mintedTokenIdFromReceipt;
|
|
13379
13325
|
exports.normalizeSiwsSignature = normalizeSiwsSignature;
|
|
13380
13326
|
exports.normalizeWalletAddress = normalizeWalletAddress;
|
|
13381
|
-
exports.ownerAliveTypedData = ownerAliveTypedData;
|
|
13382
13327
|
exports.ownerConstructorCalldata = ownerConstructorCalldata;
|
|
13383
13328
|
exports.parseAccountAddress = parseAccountAddress;
|
|
13384
13329
|
exports.parseAdminHeaders = parseAdminHeaders;
|
|
@@ -13391,7 +13336,6 @@ exports.requestSiwsToken = requestSiwsToken;
|
|
|
13391
13336
|
exports.sealPrivateKey = sealPrivateKey;
|
|
13392
13337
|
exports.selfFundedExecutor = selfFundedExecutor;
|
|
13393
13338
|
exports.sessionKeyHashOf = sessionKeyHashOf;
|
|
13394
|
-
exports.setupSessionWalletKey = setupSessionWalletKey;
|
|
13395
13339
|
exports.signAdminRequest = signAdminRequest;
|
|
13396
13340
|
exports.signWithPrivateKey = signWithPrivateKey;
|
|
13397
13341
|
exports.sponsoredExecutor = sponsoredExecutor;
|