dfinity / ic-repl

Apache License 2.0
70 stars 10 forks source link

Getting principal from a "service" #58

Closed skilesare closed 1 year ago

skilesare commented 1 year ago

I return an actor from one of my functions. Is there a kind of Principal.fromActor type function in icrepl?

variant {
  ok = record {
    id = 0 : nat;
    balance = 0 : nat;
    name = "test icp";
    tokenHolders = 1 : nat;
    totalStake = 0 : nat;
    supply = 1 : nat;
    proxy = service "t6rzw-2iaaa-aaaaa-aaama-cai";
    visibility = variant { Public };
    policy = record {
      minters = variant {
        Minters = vec { principal "sp3hj-caaaa-aaaaa-aaajq-cai" }
      };
      restrictTokenTransfer = true;
      allowTokenBurn = true;
      proposeThreshold = 1 : nat;
      proposers = variant { Open };
      acceptanceThreshold = variant {
        Percent = record {
          percent = 5_000_000 : nat;
          quorum = opt (3_000_000 : nat);
        }
      };
    };
  }
}

call icp_voice.set_voice_address(proxy)

Error: type mismatch: service "tmxop-wyaaa-aaaaa-aaapa-cai" cannot be of type principal I want to grab the principal out of the service. How do I navigate this?

chenyan2002 commented 1 year ago

I will fix it. Meanwhile, you probably have to manually copy that canister id.

skilesare commented 1 year ago

I ended up using grep and sed to pull it out and then initiate a new repl session in bash.

On Fri, Feb 24, 2023 at 7:41 PM Yan @.***> wrote:

I will fix it. Meanwhile, you probably have to manually copy that canister id.

— Reply to this email directly, view it on GitHub https://github.com/chenyan2002/ic-repl/issues/58#issuecomment-1444888581, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE5CO7K4RO6QXETCAHUBR3WZFPODANCNFSM6AAAAAAVGPKLGQ . You are receiving this because you authored the thread.Message ID: @.***>

-- Austin Fatheree twitter: @afat http://twitter.com/afat

chenyan2002 commented 1 year ago

I think I misunderstood your request. You want to convert service/func to principal in the arguments. Similarly, it makes sense to convert principal to service/func as well. Let me think a bit more about how to handle this consistently.