Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Creating nft collection using capi #1048

Closed
VadimSaveljev opened this issue Jun 7, 2023 · 5 comments · Fixed by #1105
Closed

Creating nft collection using capi #1048

VadimSaveljev opened this issue Jun 7, 2023 · 5 comments · Fixed by #1105
Assignees
Labels
bug Something is broken

Comments

@VadimSaveljev
Copy link
Contributor

VadimSaveljev commented Jun 7, 2023

My code goes like this

          const sender = pjsSender(local, activeWallet.signer as PjsSigner);

          const createEvents = await local.Nfts.create({
            config: collectionConfig,
            admin: MultiAddress.Id(ss58.decode(activeAccount.address)[1]),
          })
            .signed(
              signature({
                sender: sender(activeAccount.address),
              }),
            )
            .sent()
            .dbgStatus('Create collection:')
            .finalizedEvents()
            .run();
  1. I need a type assertion for PjsSigner to avoid TS errors
    I'm using a Signer type from @polkadot/types which has signPayload parameter as optional, while PjsSigner's signPayload is mandatory.

  2. when executing the code I get an error
    pjs signer: unknown extension ChargeAssetTxPayment

in capi => pjs_sender => convertExtensionCodec I can add a dirty hack and the execution goes further

if (key === 'ChargeAssetTxPayment') {
    return $.field('ChargeAssetTxPayment', $pjs(value));;
}
  1. Is there a better way to convert wallet address string (received from extension) into MultiAddress? And why the difference in formats for admin and sender? Maybe there should be only one and used for both on capi side?
@VadimSaveljev VadimSaveljev added the bug Something is broken label Jun 7, 2023
@robocapi robocapi added this to Capi Jun 7, 2023
@harrysolovay
Copy link
Contributor

  1. activeWallet.signer is from pjs? If so, a lack of fitting type is out of our purview.
  2. Where is signature coming from? Could it be the incorrect signature pattern for the target chain?
  3. Good question!––let's bring this up with @tjjfvi when he returns on Monday.

@VadimSaveljev
Copy link
Contributor Author

@harrysolovay 1. That doesn't make sense to me, so capi has a type PjsSender which literally means it uses/mimics pjs type, but instead of using an actual type from @polkadot/types it has a copy-paste custom implementation, which is not fully updated to mimic the latest revision of that type. Just making the method signPayload optional would fix the issue.

  1. there are two signatures, polkadot and statemint, I'm using statemint
    I can see the method in the code
        ChargeAssetTxPayment: Rune.object({
         assetId: props.assetId,
         tip: tip,
       }),

but don't know why it fails.

@VadimSaveljev
Copy link
Contributor Author

VadimSaveljev commented Jun 9, 2023

Ok, I found the second issue

const pjsExtraKeyMap: Record<string, string> = {
  CheckEra: "era",
  CheckMortality: "era",
  ChargeTransactionPayment: "tip",
  CheckNonce: "nonce",
}

pjs_sender is missing keymap for ChargeAssetTxPayment

@tjjfvi
Copy link
Contributor

tjjfvi commented Jun 23, 2023

PJS has arbitrary hard-coded alternate formats for the extrinsic extra & additional, so in the pjs compat pattern we need to duplicate those transformations. Looks like we were indeed missing ChargeAssetTxPayment. We should have all of them as of #1105, though. I also fixed the typing, so you shouldn't need the cast anymore.

@VadimSaveljev
Copy link
Contributor Author

PJS has arbitrary hard-coded alternate formats for the extrinsic extra & additional, so in the pjs compat pattern we need to duplicate those transformations. Looks like we were indeed missing ChargeAssetTxPayment. We should have all of them as of #1105, though. I also fixed the typing, so you shouldn't need the cast anymore.

Great to hear, I'll check it out later, thanks @tjjfvi

@github-project-automation github-project-automation bot moved this to Done in Capi Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something is broken
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants