sporeprotocol / spore-demo

A Spore Protocol Demo based on Next.js + React + Spore SDK
https://a-simple-demo.spore.pro
MIT License
3 stars 8 forks source link

Incorrect address #67

Open GeraldoMarques1 opened 7 months ago

GeraldoMarques1 commented 7 months ago

I’m a developer and just looked your excellent demo site. But I have one question. When I connect wallet using joyid, it shows incorrect address. I attached screenshot. first image is from https://testnet.joyid.dev/ and I think it’s correct address. What’s the reason? And how to mint spore on nervous main net work with correct address? Thanks. image (4) image (3)

GeraldoMarques1 commented 7 months ago

@ahonn @ShookLyngs could you reply?

ahonn commented 7 months ago

Hi @GeraldoMarques1, thanks for your feedback.

Spore-demo is integrated with JoyID through Omnilock for now, which means it follows the same approach as MetaMask. So it is different from the address seen in JoyID (JoyID uses its own lock), you can understand that in the spore demo we are only using JoyID to sign transactions.

We plan to temporarily disable JoyID in the demo to avoid confusion. It will be re-added when we can fully support JoyID. We will explain this situation in the README. At the same time, if you are developing Spore DApp, the Omnilock integration is not recommended.

GeraldoMarques1 commented 7 months ago

@ahonn thanks for your response. I understand, and I'm trying to integrate 'Mint Spore' on my dApp using joyid and nervous network. So I can get ethAddress and ckb address using '@joyid/ckb' but I want to get correct lock. Could you tell me how can I mint spore? thanks.

ahonn commented 7 months ago

@ahonn thanks for your response. I understand, and I'm trying to integrate 'Mint Spore' on my dApp using joyid and nervous network. So I can get ethAddress and ckb address using '@joyid/ckb' but I want to get correct lock. Could you tell me how can I mint spore? thanks.

You can refer to https://github.com/sporeprotocol/spore-demo/issues/69. ckb-dao-cobuild-poc's demo showcasing the management of DAO deposits through the use of a new transaction building protocol named Cobuild. In the poc demo, we have implemented the use of JoyID to manage DAO. You can management spores at same way.

GeraldoMarques1 commented 7 months ago

ok, got it. I wanted to know how to get joyid lock from ckb address

ShookLyngs commented 7 months ago

ok, got it. I wanted to know how to get joyid lock from ckb address

If you mean "get the lock script of a JoyID wallet address", you can use the parseAddress API from lumos:

import { helpers, config, Script } from '@ckb-lumos/lumos';

const joyIdWalletMainnetAddress = 'ckb...';
const lockScript: Script = helpers.parseAddress(joyIdWalletMainnetAddress, { 
  config: config.MAINNET,
});

console.log(lockScript); // { codeHash: ..., hashType: ..., args: ... }
GeraldoMarques1 commented 7 months ago

yes. so I tested. my test ckb address: ckt1qrfrwcdnvssswdwpn3s9v8fp87emat306ctjwsm3nmlkjg8qyza2cqgqqytg65tdzm9prtw3rkjlnk80dyt326sf9sawqks7

and lock is args: "0x0001168d516d16ca11add11da5f9d8ef6917156a092c" codeHash: "0xd23761b364210735c19c60561d213fb3beae2fd6172743719eff6920e020baac" hashType: "type"

but when I mint spore using this address and lock with createSpore from 'spore-sdk/core', I have error. it's related to spore sdk? or any argument is wrong?

ShookLyngs commented 7 months ago

and lock is args: "0x0001168d516d16ca11add11da5f9d8ef6917156a092c" codeHash: "0xd23761b364210735c19c60561d213fb3beae2fd6172743719eff6920e020baac" hashType: "type"

but when I mint spore using this address and lock with createSpore from 'spore-sdk/core', I have error. it's related to spore sdk? or any argument is wrong?

This is a JoyID lock address, and I assume that when you try to construct a transaction and include this address in the fromInfos, it throws an error with a message similar to "not enough capacity in from infos!" If that's the case, the error is caused by Lumos, indicating that the JoyID lock is not officially supported by Lumos.

The cause of the error is that Lumos only collects capacity from known lock scripts (such as the default lock and the Omnilock). If you include a JoyID address in the fromInfos, Lumos doesn't recognize the JoyID lock script and the collection with the JoyID lock script is skipped. As a result, it cannot complete the capacity collection process. This is why the error is thrown.

As far as I know, the Lumos team is still working on supporting the JoyID lock, so a temp solution is to register a CustomLockScriptInfo in your dapp to handle capacity collection and witness-related fields for the JoyID lock script. However, it may present some difficulties. You can refer to the following example in Lumos on how to register a CustomLockScriptInfo : https://github.com/ckb-js/lumos/blob/ad483d9cb55ad38db9604fde456033b9513bc7f1/packages/common-scripts/examples/custom_lock_script_info/custom_lock_script_info.ts

WhiteR4bbitt commented 6 months ago

As far as I know, the Lumos team is still working on supporting the JoyID lock

Looks like it :) for reference: https://github.com/ckb-js/lumos/issues/640