@medialane/sdk 0.108.0 → 0.110.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.
@@ -11700,17 +11700,79 @@ function computeAccountAddress(ownerPubkey, salt = 0) {
11700
11700
  );
11701
11701
  }
11702
11702
  var STARKNET_SIGNER_TYPE = "0x537461726b6e6574205369676e6572";
11703
+ var OPTION_NONE = "0x1";
11704
+ var OPTION_SOME = "0x0";
11705
+ var SIGNER_STARKNET = "0x0";
11703
11706
  function computeOwnerGuid(ownerPubkey) {
11704
11707
  return starknet.hash.computePoseidonHash(STARKNET_SIGNER_TYPE, starknet.num.toHex(ownerPubkey));
11705
11708
  }
11706
- function buildChangeOwnersCall(accountAddress, removeOwnerPubkey, addOwnerPubkey) {
11707
- const guidToRemove = computeOwnerGuid(removeOwnerPubkey);
11709
+ function changeOwners(accountAddress, guidsToRemove, pubkeysToAdd, ownerAlive) {
11708
11710
  return {
11709
11711
  contractAddress: accountAddress,
11710
11712
  entrypoint: "change_owners",
11711
- calldata: ["0x1", guidToRemove, "0x1", "0x0", starknet.num.toHex(addOwnerPubkey)]
11713
+ calldata: [
11714
+ starknet.num.toHex(guidsToRemove.length),
11715
+ ...guidsToRemove,
11716
+ starknet.num.toHex(pubkeysToAdd.length),
11717
+ ...pubkeysToAdd.flatMap((p) => [SIGNER_STARKNET, starknet.num.toHex(p)]),
11718
+ ...ownerAlive ? ownerAliveCalldata(ownerAlive) : [OPTION_NONE]
11719
+ ]
11712
11720
  };
11713
11721
  }
11722
+ function ownerAliveTypedData(newOwnerGuid, expiration, chainId) {
11723
+ return {
11724
+ types: {
11725
+ StarknetDomain: [
11726
+ { name: "name", type: "shortstring" },
11727
+ { name: "version", type: "shortstring" },
11728
+ { name: "chainId", type: "shortstring" },
11729
+ { name: "revision", type: "shortstring" }
11730
+ ],
11731
+ "Owner Alive": [
11732
+ { name: "Owner GUID", type: "felt" },
11733
+ { name: "Signature expiration", type: "timestamp" }
11734
+ ]
11735
+ },
11736
+ primaryType: "Owner Alive",
11737
+ domain: { name: "Owner Alive", version: "1", chainId, revision: "1" },
11738
+ message: { "Owner GUID": newOwnerGuid, "Signature expiration": expiration }
11739
+ };
11740
+ }
11741
+ function ownerAliveCalldata(proof) {
11742
+ if (proof.signature.length !== 2) {
11743
+ throw new Error("owner-alive proof needs an r and s from the incoming owner");
11744
+ }
11745
+ return [
11746
+ OPTION_SOME,
11747
+ SIGNER_STARKNET,
11748
+ starknet.num.toHex(proof.newOwnerPubkey),
11749
+ starknet.num.toHex(proof.signature[0]),
11750
+ starknet.num.toHex(proof.signature[1]),
11751
+ starknet.num.toHex(proof.expiration)
11752
+ ];
11753
+ }
11754
+ function buildChangeOwnersCall(accountAddress, removeOwnerPubkey, addOwnerPubkey, ownerAlive) {
11755
+ if (!ownerAlive) {
11756
+ throw new Error(
11757
+ "Handing an account over removes the signing owner, so the account requires an owner-alive proof from the incoming owner. Sign ownerAliveTypedData with the new owner key and pass it here."
11758
+ );
11759
+ }
11760
+ return changeOwners(
11761
+ accountAddress,
11762
+ [computeOwnerGuid(removeOwnerPubkey)],
11763
+ [addOwnerPubkey],
11764
+ ownerAlive
11765
+ );
11766
+ }
11767
+ function buildAddOwnerCall(accountAddress, addOwnerPubkey) {
11768
+ return changeOwners(accountAddress, [], [addOwnerPubkey]);
11769
+ }
11770
+ function buildRemoveOwnerCall(accountAddress, removeOwnerPubkey) {
11771
+ return changeOwners(accountAddress, [computeOwnerGuid(removeOwnerPubkey)], []);
11772
+ }
11773
+ function buildRemoveOwnerByGuidCall(accountAddress, ownerGuid) {
11774
+ return changeOwners(accountAddress, [starknet.num.toHex(ownerGuid)], []);
11775
+ }
11714
11776
  function buildDeployAccountParams(ownerPubkey, salt = 0) {
11715
11777
  return {
11716
11778
  classHash: STARKNET_MEDIAWALLET_CLASS_HASH,
@@ -11781,6 +11843,14 @@ async function getGuardians(provider, address) {
11781
11843
  });
11782
11844
  return decodeGuardiansInfo(res);
11783
11845
  }
11846
+ async function getOwners(provider, address) {
11847
+ const res = await provider.callContract({
11848
+ contractAddress: norm(address),
11849
+ entrypoint: "get_owners_info",
11850
+ calldata: []
11851
+ });
11852
+ return decodeGuardiansInfo(res);
11853
+ }
11784
11854
  async function getEscape(provider, address) {
11785
11855
  const res = await provider.callContract({
11786
11856
  contractAddress: norm(address),
@@ -11886,6 +11956,7 @@ exports.adminRequestDigest = adminRequestDigest;
11886
11956
  exports.assertTransactionSucceeded = assertTransactionSucceeded;
11887
11957
  exports.build1155CancellationTypedData = build1155CancellationTypedData;
11888
11958
  exports.build1155OrderTypedData = build1155OrderTypedData;
11959
+ exports.buildAddOwnerCall = buildAddOwnerCall;
11889
11960
  exports.buildAdminSessionTypedData = buildAdminSessionTypedData;
11890
11961
  exports.buildCancelEscapeCall = buildCancelEscapeCall;
11891
11962
  exports.buildCancellationTypedData = buildCancellationTypedData;
@@ -11896,6 +11967,8 @@ exports.buildDeployAccountParams = buildDeployAccountParams;
11896
11967
  exports.buildFeeCall = buildFeeCall;
11897
11968
  exports.buildLaunchOnEkuboCalls = buildLaunchOnEkuboCalls;
11898
11969
  exports.buildOrderTypedData = buildOrderTypedData;
11970
+ exports.buildRemoveOwnerByGuidCall = buildRemoveOwnerByGuidCall;
11971
+ exports.buildRemoveOwnerCall = buildRemoveOwnerCall;
11899
11972
  exports.buildSetFirstGuardianCall = buildSetFirstGuardianCall;
11900
11973
  exports.buildTriggerEscapeOwnerCall = buildTriggerEscapeOwnerCall;
11901
11974
  exports.buybackQuoteRaw = buybackQuoteRaw;
@@ -11923,10 +11996,12 @@ exports.getEscapeSecurityPeriod = getEscapeSecurityPeriod;
11923
11996
  exports.getGuardians = getGuardians;
11924
11997
  exports.getOrderDetails = getOrderDetails;
11925
11998
  exports.getOrderDetails1155 = getOrderDetails1155;
11999
+ exports.getOwners = getOwners;
11926
12000
  exports.getSiwsStorageKey = getSiwsStorageKey;
11927
12001
  exports.getStoredSiwsToken = getStoredSiwsToken;
11928
12002
  exports.isSiwsTokenValid = isSiwsTokenValid;
11929
12003
  exports.normalizeSiwsSignature = normalizeSiwsSignature;
12004
+ exports.ownerAliveTypedData = ownerAliveTypedData;
11930
12005
  exports.ownerConstructorCalldata = ownerConstructorCalldata;
11931
12006
  exports.parseAdminHeaders = parseAdminHeaders;
11932
12007
  exports.parseCreatorCoinCreated = parseCreatorCoinCreated;