Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart wallet equivalent to suggestIssuer(petname, issuerBoardId) #7226

Open
carlos-kryha opened this issue Mar 23, 2023 · 5 comments
Open

Smart wallet equivalent to suggestIssuer(petname, issuerBoardId) #7226

carlos-kryha opened this issue Mar 23, 2023 · 5 comments
Assignees
Labels
devex developer experience enhancement New feature or request mn2 Issue related to a MN2 dapp namehub-petname issuer naming, petnames, namehubs, ... needs-design vaults_triage DO NOT USE wallet

Comments

@carlos-kryha
Copy link

carlos-kryha commented Mar 23, 2023

What is the Problem Being Solved?

In order for the agoric web wallet to handle arbitrary ERTP assets, we've been using the following frontend code when running a local sim-chain + ag-solo

const {
        abort: ctpAbort,
        dispatch: ctpDispatch,
        getBootstrap,
      } = makeCapTP("CB", (obj: any) => socket.send(JSON.stringify(obj)), otherSide);

      const walletP = getBootstrap();
      E(walletP).suggestIssuer("TOKEN", TOKEN_ISSUER_BOARD_ID)

With ag-solo out of the picture in mainnet 2, how would we go about letting the wallet know about ERPT assets created in our contracts? Assuming we have the asset's issuer boardId readily availble

Description of the Design

Task list that was here was actually addressing a different scope: #8156

Security Considerations

Scaling Considerations

Test Plan

@carlos-kryha carlos-kryha added the enhancement New feature or request label Mar 23, 2023
@ivanlei ivanlei added devex developer experience mn2 Issue related to a MN2 dapp vaults_triage DO NOT USE labels Mar 24, 2023
@ivanlei
Copy link
Contributor

ivanlei commented Jun 28, 2023

Related PR: #5946

@dckc
Copy link
Member

dckc commented Jul 18, 2023

Story: Alice joins a Monopoly Game

updated for "use well-known agoricNames" approach, which is actually more relevant to #8156

In a monopoly-like game dapp, players can trade real estate assets. To join the game, Alice will buy a few pieces of real estate for 0.25 IST.

The game was launched thru chain-wide (BLD staker) governance. In the process, a new "Game Real Estate" issuer and brand were registered as well-known (via agoricNames.issuer, agoricNames.brand). Likewise the game instance is registered in agoricNames.instance.

Alice chooses a few pieces of real-estate using the game UI. The game UI proposes an offer to the game contract of 0.25 for these pieces of real-estate. Alice signs the offer and receives the real estate NFTs.

Details/questions:

  • the AssetKind and decimalPlaces should probably be associated with the issuer and brand throughout

cc @otoole-brendan @turadg

Design Sketch for addIssuer flow

outdated

Details
agoric-sdk/packages/smart-wallet$ yarn test test/test-walletFactory.js -m '*add issuers'

  ✔ [expected fail] wallet owners can add issuers
    ℹ dapp suggests issuer: {
        issuer: Object @Alleged: SEVERED: Game Real Estate Issuer {},
        name: 'Game Real Estate',
      }
    ℹ agoric1addIssuer agrees to action: {
        issuer: Object @Alleged: SEVERED: Game Real Estate Issuer {},
        method: 'addIssuer',
        name: 'Game Real Estate',
      }
    ℹ new issuer reflected in wallet status update: {
        status: {
          error: 'invalid handle bridge action {"issuer":"[Alleged: Game Real Estate IssuerHandle]","method":"addIssuer","name":"Game Real Estate"}',
        },
        updated: 'walletAction',
      }

code:

test.failing('wallet owners can add issuers', async t => {
  let ids = {};

  const onChain = async () => {
    const kit = {
      issuer: makeHandle('Game Real Estate Issuer'),
      brand: makeHandle('Game Real Estate Brand'),
    };

    const board = await t.context.consume.board;
    ids = {
      issuer: board.getId(kit.issuer),
      brand: board.getId(kit.brand),
    };
  };

  await onChain();

  // From vstorage, a dapp might get issuer info such as:
  const refData = {
    body: `#${JSON.stringify({
      name: 'Game Real Estate',
      issuer: '$0.Alleged: Game Real Estate Issuer',
      brand: '$1.Alleged: Game Real Estate Brand',
    })}`,
    slots: [ids.issuer, ids.brand],
  };
  const ctx = makeImportContext();
  const ref = ctx.fromBoard.fromCapData(refData);

  t.log('dapp suggests issuer:', { issuer: ref.issuer, name: ref.name });

  const owner = 'agoric1addIssuer';
  const updates = await E(
    t.context.simpleProvideWallet(owner)
  ).getUpdatesSubscriber();

  const action = harden({
    method: 'addIssuer',
    issuer: ref.issuer,
    name: ref.name,
  });
  t.log(owner, 'agrees to action:', action);
  const actionEncoding = ctx.fromBoard.toCapData(action);
  const addIssuerMsg = {
    type: ActionType.WALLET_SPEND_ACTION,
    owner,
    spendAction: JSON.stringify(actionEncoding),
    blockTime: 0,
    blockHeight: 0,
  };
  assert(t.context.sendToBridge);
  await t.context.sendToBridge(addIssuerMsg);

  const update = await headValue(updates);
  t.log('new issuer reflected in wallet status update:', update);
  t.deepEqual(update, {
    updated: 'addIssuer',
    status: {
      name: 'Game Real Estate',
      brand: ref.brand,
    },
  });
});

todo: review

Related work: petnames

see

@dckc
Copy link
Member

dckc commented Jul 20, 2023

based on the alternative flow where BLD stakers agree to add to agoricNames.issuer in the same core eval script where they start a permissioned contract, I filled in some more detail in a test:

@dckc
Copy link
Member

dckc commented Aug 7, 2023

The current work in progress addresses a different scope; I made a new issue to represent it:

@dckc
Copy link
Member

dckc commented Jan 19, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devex developer experience enhancement New feature or request mn2 Issue related to a MN2 dapp namehub-petname issuer naming, petnames, namehubs, ... needs-design vaults_triage DO NOT USE wallet
Projects
None yet
Development

No branches or pull requests

4 participants