@medialane/sdk 0.109.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.
@@ -11701,11 +11701,12 @@ function computeAccountAddress(ownerPubkey, salt = 0) {
11701
11701
  }
11702
11702
  var STARKNET_SIGNER_TYPE = "0x537461726b6e6574205369676e6572";
11703
11703
  var OPTION_NONE = "0x1";
11704
+ var OPTION_SOME = "0x0";
11704
11705
  var SIGNER_STARKNET = "0x0";
11705
11706
  function computeOwnerGuid(ownerPubkey) {
11706
11707
  return starknet.hash.computePoseidonHash(STARKNET_SIGNER_TYPE, starknet.num.toHex(ownerPubkey));
11707
11708
  }
11708
- function changeOwners(accountAddress, guidsToRemove, pubkeysToAdd) {
11709
+ function changeOwners(accountAddress, guidsToRemove, pubkeysToAdd, ownerAlive) {
11709
11710
  return {
11710
11711
  contractAddress: accountAddress,
11711
11712
  entrypoint: "change_owners",
@@ -11714,12 +11715,54 @@ function changeOwners(accountAddress, guidsToRemove, pubkeysToAdd) {
11714
11715
  ...guidsToRemove,
11715
11716
  starknet.num.toHex(pubkeysToAdd.length),
11716
11717
  ...pubkeysToAdd.flatMap((p) => [SIGNER_STARKNET, starknet.num.toHex(p)]),
11717
- OPTION_NONE
11718
+ ...ownerAlive ? ownerAliveCalldata(ownerAlive) : [OPTION_NONE]
11718
11719
  ]
11719
11720
  };
11720
11721
  }
11721
- function buildChangeOwnersCall(accountAddress, removeOwnerPubkey, addOwnerPubkey) {
11722
- return changeOwners(accountAddress, [computeOwnerGuid(removeOwnerPubkey)], [addOwnerPubkey]);
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
+ );
11723
11766
  }
11724
11767
  function buildAddOwnerCall(accountAddress, addOwnerPubkey) {
11725
11768
  return changeOwners(accountAddress, [], [addOwnerPubkey]);
@@ -11958,6 +12001,7 @@ exports.getSiwsStorageKey = getSiwsStorageKey;
11958
12001
  exports.getStoredSiwsToken = getStoredSiwsToken;
11959
12002
  exports.isSiwsTokenValid = isSiwsTokenValid;
11960
12003
  exports.normalizeSiwsSignature = normalizeSiwsSignature;
12004
+ exports.ownerAliveTypedData = ownerAliveTypedData;
11961
12005
  exports.ownerConstructorCalldata = ownerConstructorCalldata;
11962
12006
  exports.parseAdminHeaders = parseAdminHeaders;
11963
12007
  exports.parseCreatorCoinCreated = parseCreatorCoinCreated;