stellar / soroban-example-dapp

End-to-End Example Soroban Dapp
Apache License 2.0
1.06k stars 853 forks source link

Use new soroban-cli token create subcommand #20

Closed paulbellamy closed 1 year ago

paulbellamy commented 1 year ago

Use the new soroban-cli token create subcommand from: https://github.com/stellar/soroban-cli/pull/166 This meant I had to update the xdr dependency, and some of the code using that.

paulbellamy commented 1 year ago

I think https://github.com/stellar/soroban-examples/pull/123 will fix the build here

leighmcculloch commented 1 year ago

@paulbellamy Now that soroban-examples is updated I've pushed the dep update in 304e48f and make test passes. I'm not sure how to tell the full scope of this PR so I'm going to leave it open for you to merge, but looks like it is good to go.

leighmcculloch commented 1 year ago

I'm taking a quick look if I can remove the dependence on the token example.

leighmcculloch commented 1 year ago

In 78cce35 I've pushed changes that remove the dependence on soroban-token-contract. Instead of using any utilities in that example crate, the project relies entirely on the soroban-token-spec for code that ships when deployed, and in tests it uses the simpler Signature::Invoker to authenticate as a source account.

I've change the way auth works for two reasons:

@paulbellamy The simpler form of auth works like this:

  1. First set the source account to the account id you want to authenticate as.
  2. Invoke the contract, telling the contract (that uses soroban-auth) that you're signing as the "Invoker", which is the source account in a direct invocation.

For example:

e.set_source_account(&account_id_you_want_auth_as);
client.approve(&Signature::Invoker, ...)
leighmcculloch commented 1 year ago

@paulbellamy For any scripts that need to invoke the token contract, instead of using ed25519 keys/sigs, you can use the --account option:

Screen Shot 2022-10-04 at 12 15 40 AM

Last week I also updated the cli serve subcommand to support account, so this should all be good to go to support any use of accounts in this PR.