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

extending cli to work with tribbles #10936

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tgrecojs
Copy link
Contributor

@tgrecojs tgrecojs commented Feb 4, 2025

Test PR

# running the test
~/agoric-sdk/packages/fast-usdc yarn ava ./test/cli/airdrop-commands.test.js
# values retrieved from `makeSmartWalletKit`
inspecting walletKit capabilities :::: {
  fromBoard: { convertSlotToVal: [Function: convertSlotToVal] },
  marshaller: {
    toCapData: [Function: toCapData],
    fromCapData: [Function: fromCapData],
    serialize: [Function: toCapData],
    unserialize: [Function: fromCapData]
  },
  readLatestHead: [Function: readLatestHead],
  readPublished: [Function: readPublished],
  unserializeHead: [Function: unserializeHead],
  vstorage: {
    url: [Function: url],
    decode: [Function: decode],
    readLatest: [AsyncFunction: readLatest],
    keys: [AsyncFunction: keys],
    readAt: [AsyncFunction: readAt],
    readFully: [AsyncFunction: readFully]
  },
  agoricNames: {
    brand: {
      ATOM: [Object [Alleged: BoardRemoteATOM brand]],
      BLD: [Object [Alleged: BoardRemoteBLD brand]],
      DAI_axl: [Object [Alleged: BoardRemoteDAI_axl brand]],
      DAI_grv: [Object [Alleged: BoardRemoteDAI_grv brand]],
      IST: [Object [Alleged: BoardRemoteIST brand]],
      Invitation: [Object [Alleged: BoardRemoteZoe Invitation brand]],
      ToyUSD: [Object [Alleged: BoardRemoteToyUSD brand]],
      Tribbles: [Object [Alleged: BoardRemoteTribbles brand]],
      Tribbles1: [Object [Alleged: BoardRemoteTribbles1 brand]],
      Tribbles2: [Object [Alleged: BoardRemoteTribbles2 brand]],
      Tribbles3: [Object [Alleged: BoardRemoteTribbles3 brand]],
      Tribbles4: [Object [Alleged: BoardRemoteTribbles4 brand]],
      TribblesXnet: [Object [Alleged: BoardRemoteTribblesXnet brand]],
      USDC_axl: [Object [Alleged: BoardRemoteUSDC_axl brand]],
      dATOM: [Object [Alleged: BoardRemotedATOM brand]],
      timer: [Object [Alleged: BoardRemotetimerBrand]]
    },
    instance: {
      'ATOM-USD price feed': [Object [Alleged: BoardRemoteInstanceHandle]],
      VaultFactory: [Object [Alleged: BoardRemoteInstanceHandle]],
      VaultFactoryGovernor: [Object [Alleged: BoardRemoteInstanceHandle]],
      auctioneer: [Object [Alleged: BoardRemoteInstanceHandle]],
      'dATOM-USD price feed': [Object [Alleged: BoardRemoteInstanceHandle]],
      econCommitteeCharter: [Object [Alleged: BoardRemoteInstanceHandle]],
      economicCommittee: [Object [Alleged: BoardRemoteInstanceHandle]],
      feeDistributor: [Object [Alleged: BoardRemoteInstanceHandle]],
      provisionPool: [Object [Alleged: BoardRemoteInstanceHandle]],
      'psm-IST-DAI_axl': [Object [Alleged: BoardRemoteInstanceHandle]],
      'psm-IST-DAI_grv': [Object [Alleged: BoardRemoteInstanceHandle]],
      'psm-IST-ToyUSD': [Object [Alleged: BoardRemoteInstanceHandle]],
      'psm-IST-USDC_axl': [Object [Alleged: BoardRemoteInstanceHandle]],
      reserve: [Object [Alleged: BoardRemoteInstanceHandle]],
      reserveGovernor: [Object [Alleged: BoardRemoteInstanceHandle]],
      'scaledPriceAuthority-ATOM': [Object [Alleged: BoardRemoteInstanceHandle]],
      'scaledPriceAuthority-dATOM': [Object [Alleged: BoardRemoteInstanceHandle]],
      tribblesAirdrop: [Object [Alleged: BoardRemoteInstanceHandle]],
      tribblesAirdrop1: [Object [Alleged: BoardRemoteInstanceHandle]],
      tribblesAirdrop2: [Object [Alleged: BoardRemoteInstanceHandle]],
      tribblesAirdrop3: [Object [Alleged: BoardRemoteInstanceHandle]],
      tribblesAirdrop4: [Object [Alleged: BoardRemoteInstanceHandle]],
      walletFactory: [Object [Alleged: BoardRemoteInstanceHandle]],
      tribblesXnetDeployment: [Object [Alleged: BoardRemoteInstanceHandle]]
    },
    vbankAsset: {
      'ibc/06362C6F7F4FB702B94C13CD2E7C03DEC357683FD978936340B43FBFBC5351EB': [Object],
      'ibc/3914BDEF46F429A26917E4D8D434620EC4817DC6B6E68FB327E190902F1E9242': [Object],
      'ibc/3D5291C23D776C3AA7A7ABB34C7B023193ECD2BC42EA19D3165B2CF9652117E7': [Object],
      'ibc/4B53406F2FD21ABE4EF15977D0585D0C1B9C1DBBA1F911BD1463F42B067FB4D8': [Object],
      'ibc/toyDAtom': [Object],
      'ibc/toyusdc': [Object],
      ubld: [Object],
      uist: [Object],
      utribbles: [Object],
      utribbles1: [Object],
      utribbles2: [Object],
      utribbles3: [Object],
      utribbles4: [Object],
      utribblesxnet: [Object]
    },
    reverse: {
      board00848: 'ATOM',
      board0566: 'BLD',
      board02437: 'DAI_axl',
      board05039: 'DAI_grv',
      board0257: 'IST',
      board0074: 'Invitation',
      board02733: 'ToyUSD',
      board05970: 'Tribbles',
      board05674: 'Tribbles1',
      board03378: 'Tribbles2',
      board00282: 'Tribbles3',
      board00694: 'Tribbles4',
      board01998: 'TribblesXnet',
      board03935: 'USDC_axl',
      board00990: 'dATOM',
      board0425: 'timer',
      board02656: 'ATOM-USD price feed',
      board01151: 'VaultFactory',
      board02963: 'VaultFactoryGovernor',
      board03850: 'auctioneer',
      board03687: 'dATOM-USD price feed',
      board02152: 'econCommitteeCharter',
      board04542: 'economicCommittee',
      board06053: 'feeDistributor',
      board04154: 'provisionPool',
      board00360: 'psm-IST-DAI_axl',
      board04661: 'psm-IST-DAI_grv',
      board06458: 'psm-IST-ToyUSD',
      board01759: 'psm-IST-USDC_axl',
      board04149: 'reserve',
      board00855: 'reserveGovernor',
      board05262: 'scaledPriceAuthority-ATOM',
      board04091: 'scaledPriceAuthority-dATOM',
      board05669: 'tribblesAirdrop',
      board03773: 'tribblesAirdrop1',
      board04277: 'tribblesAirdrop2',
      board03281: 'tribblesAirdrop3',
      board02393: 'tribblesAirdrop4',
      board05557: 'walletFactory',
      board02897: 'tribblesXnetDeployment'
    }
  },
  networkConfig: {
    chainName: 'agoricxnet-14',
    gci: 'https://xnet.rpc.agoric.net:443/genesis',
    peers: [ '[email protected]:26656' ],
    rpcAddrs: [ 'https://xnet.rpc.agoric.net:443' ],
    apiAddrs: [ 'https://xnet.api.agoric.net:443' ],
    seeds: [ '[email protected]:26656' ]
  },
  getLastUpdate: [Function: getLastUpdate],
  getCurrentWalletRecord: [Function: getCurrentWalletRecord],
  storedWalletState: [AsyncFunction: storedWalletState],
  pollOffer: [AsyncFunction: pollOffer]
}
  ✘ [fail]: airdrop-commands › tribbles airdrop program Rejected promise returned by test
    ℹ node Airdrop claimer send --proof [{"hash":"65841582aae8dcb596cb38ff196ac070f83bd019b879ed97041e6be416a1d385","direction":"left"},{"hash":"d0bb415aaec20b82f17bb886d2c48ee7c3259af5010f53005641803aba7a2175","direction":"right"},{"hash":"6c745c21ba3edb5109aae76d9fd7a4a8dca6432966b4db8a18ddc9d9cb154580","direction":"right"},{"hash":"f38a7b08ac5a9b5a25d50bf562bdfccde70bb54802cd7efb2ffe7f9d8def424d","direction":"right"},{"hash":"403f53a2a7b81f1323d66cc8a8965d5dbeba25cf77e731101eae8689fcb0bbee","direction":"right"},{"hash":"d4f10c6b26ef2bbfb127e12fd1d98791d5b718286e230ab9b843d8ce8f41b87a","direction":"right"},{"hash":"64f6e4008ca2c1bb635da596d907c1370df8a24a0261f3af1b6bcf8905190ee1","direction":"right"},{"hash":"1d990892f1fe1f8d5c0af3664eb13b327776f961e6461384e323ebcb9921a14f","direction":"right"},{"hash":"cf780e6e280c26d5c951eb9a42c1b1e0c07d30d414656d82f4ad9312605c341c","direction":"right"},{"hash":"702b3d244dc26e284ff0339ed0915a71f8ca5154e7e53b4066ecc41fc5b76da4","direction":"right"},{"hash":"4760036b289220fa586c87e0a3cfb78b124a5c4dc5e5d6227d2df4384b8c16b6","direction":"right"}] --pubkey AnEGbxH55aKu/9zIbgVDV2qXC43bpIqtZdHTKV8BAM58 --tier 0
------------------------
{
  instance: Object [Alleged: BoardRemoteInstanceHandle] {
    getBoardId: [Function: getBoardId]
  },
  brand: Object [Alleged: BoardRemoteIST brand] {
    getBoardId: [Function: getBoardId]
  }
}
{
  offer: {
    id: 'offer-AnEGbxH55a',
    invitationSpec: {
      source: 'agoricContract',
      instancePath: [Array],
      callPipe: [Array]
    },
    proposal: { give: [Object] },
    offerArgs: {
      proof: '[{"hash":"65841582aae8dcb596cb38ff196ac070f83bd019b879ed97041e6be416a1d385","direction":"left"},{"hash":"d0bb415aaec20b82f17bb886d2c48ee7c3259af5010f53005641803aba7a2175","direction":"right"},{"hash":"6c745c21ba3edb5109aae76d9fd7a4a8dca6432966b4db8a18ddc9d9cb154580","direction":"right"},{"hash":"f38a7b08ac5a9b5a25d50bf562bdfccde70bb54802cd7efb2ffe7f9d8def424d","direction":"right"},{"hash":"403f53a2a7b81f1323d66cc8a8965d5dbeba25cf77e731101eae8689fcb0bbee","direction":"right"},{"hash":"d4f10c6b26ef2bbfb127e12fd1d98791d5b718286e230ab9b843d8ce8f41b87a","direction":"right"},{"hash":"64f6e4008ca2c1bb635da596d907c1370df8a24a0261f3af1b6bcf8905190ee1","direction":"right"},{"hash":"1d990892f1fe1f8d5c0af3664eb13b327776f961e6461384e323ebcb9921a14f","direction":"right"},{"hash":"cf780e6e280c26d5c951eb9a42c1b1e0c07d30d414656d82f4ad9312605c341c","direction":"right"},{"hash":"702b3d244dc26e284ff0339ed0915a71f8ca5154e7e53b4066ecc41fc5b76da4","direction":"right"},{"hash":"4760036b289220fa586c87e0a3cfb78b124a5c4dc5e5d6227d2df4384b8c16b6","direction":"right"}]',
      tier: 0,
      pubkey: 'AnEGbxH55aKu/9zIbgVDV2qXC43bpIqtZdHTKV8BAM58'
    }
  }
}


 airdrop-commands › tribbles airdrop program
  test/cli/airdrop-commands.test.js:231

   230:
   231:   const action = marshalData.fromCapData(JSON.parse(out.join('')));
   232:

  Rejected promise returned by test. Reason:

  Error {
    message: 'internal: decodeRemotableFromSmallcaps option must return a remotable: "board0257"',
  }


// Alternative: Async pipe executes functions left to right (sometimes more intuitive)

test('tribbles airdrop program', async t => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steps for running:

  1. pull down tg-cli-extension
  2. cd into agoric-sdk/packages/fast-usdc
  3. execute the following command
yarn ava ./test/cli/airdrop-commands.test.js

Comment on lines +181 to +208
.action(async opts => {
const { proof, tier, pubkey } = opts;
const powers = await collectPowers({
delay: 500,
fetch,
env: { AGORIC_NET: 'xnet' },
})();

const [instance, brand] = await getInstanceAndBrand({
brandName: 'IST',
instanceName: 'tribblesXnetDeployment',
})(powers);
console.log('------------------------');
console.log({ instance, brand });

/** @type {import('@agoric/smart-wallet/src/invitations.js').InvitationSpec} */
const offer = makeClaimAirdropOffer(
{ feeBrand: brand, instanceName: 'tribblesXnetDeployment' },
{ proof, tier, pubkey },
);

console.log({ offer });
outputActionAndHint(
{ method: 'executeOffer', offer },
{ stderr, stdout },
powers.marshaller,
);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the sole action i'm concerned with wiring up as it facilitates claim attempts to be made programatically.

By inspecting the logs, you will see that the code is successful in its efforts to query capabilities that exist on the chain (e.g. instane, brand) as well as their corresponding slot value. However, execution of outputActionAndHint appears to be where trouble arises.

It is programmed to print a string at the end of execution but no such string appears currently thus indicating that there is an issue. Additionally, the offer object is receiving some complaints from VSCode intellisense. I've compared it to OfferSpecs that i am using to submit these very invitations to ensure that it has the correct shape but VSCode continues to say otherwise 🤷‍♂️ .

}).invoke();
await program.parseAsync(argv);

const action = marshalData.fromCapData(JSON.parse(out.join('')));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reason for this test assertion is that it existed in the *commands test file I originally copied as my starting point. The result of this logic is the following error:

 Error {
    message: 'internal: decodeRemotableFromSmallcaps option must return a remotable: "board0257"',
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant