-
Notifications
You must be signed in to change notification settings - Fork 195
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
feat: supporting WELLDONE Wallet in wallet-ts
#193
base: dev
Are you sure you want to change the base?
Conversation
packages/wallet-ts/src/strategies/cosmos-wallet-strategy/strategies/Welldone.ts
Show resolved
Hide resolved
packages/wallet-ts/src/strategies/cosmos-wallet-strategy/strategies/Welldone.ts
Show resolved
Hide resolved
packages/wallet-ts/src/strategies/cosmos-wallet-strategy/strategies/Welldone.ts
Show resolved
Hide resolved
packages/wallet-ts/src/strategies/cosmos-wallet-strategy/strategies/Welldone.ts
Show resolved
Hide resolved
packages/wallet-ts/src/strategies/wallet-strategy/strategies/Welldone.ts
Show resolved
Hide resolved
packages/wallet-ts/src/utils/wallets/welldone/WelldoneWallet.ts
Outdated
Show resolved
Hide resolved
packages/wallet-ts/src/utils/wallets/welldone/WelldoneWallet.ts
Outdated
Show resolved
Hide resolved
Hi, @bangjelkoski |
return { | ||
signed: signDoc, | ||
signature: { | ||
pub_key: encodeSecp256k1Pubkey( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested this on Injective tho? Because we are using another pubkey encoding/signing scheme and I think this will not work for us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bangjelkoski
When I tested it with simple counter example it worked well. But I agree that it's wrong. I'll fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, thanks, ping me when its done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
injective-ts/packages/sdk-ts/src/core/modules/tx/utils/tx.ts
Lines 14 to 46 in 06e2f85
export const getPublicKey = ({ | |
chainId, | |
key, | |
}: { | |
chainId: string | |
key: string | GoogleProtobufAny.Any | |
}) => { | |
if (typeof key !== 'string') { | |
return key | |
} | |
let proto | |
let path | |
let baseProto | |
if (chainId.startsWith('injective')) { | |
proto = CosmosCryptoSecp256k1Keys.PubKey.create() | |
baseProto = CosmosCryptoSecp256k1Keys.PubKey | |
path = '/injective.crypto.v1beta1.ethsecp256k1.PubKey' | |
} else if (chainId.startsWith('evmos')) { | |
proto = CosmosCryptoSecp256k1Keys.PubKey.create() | |
baseProto = CosmosCryptoSecp256k1Keys.PubKey | |
path = '/ethermint.crypto.v1.ethsecp256k1.PubKey' | |
} else { | |
proto = CosmosCryptoSecp256k1Keys.PubKey.create() | |
baseProto = CosmosCryptoSecp256k1Keys.PubKey | |
path = '/cosmos.crypto.secp256k1.PubKey' | |
} | |
proto.key = Buffer.from(key, 'base64') | |
return createAny(baseProto.encode(proto).finish(), path) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bangjelkoski Thank you! I modified the code using getPublicKey
function. Please check it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check it. @bangjelkoski
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did but there are some pending changes requested below that are still open and not implemented
@daoauth @Yoon-Suji can we update the PR so we can finally finish it? |
@bangjelkoski Yes, I already updated my code so we can finish :) |
|
||
authInfo.signerInfos.forEach((signerInfo) => { | ||
if (signerInfo.publicKey) { | ||
signerInfo.publicKey.typeUrl = '/cosmos.crypto.secp256k1.PubKey' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be related to the chainId, not hardcoded for Cosmos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bangjelkoski
WELLDONE Wallet use ‘secp245k1’ instead of ‘ethsecp256k1’ for unity with other cosmos chains. Therefore the injective account provided in the wallet is also made of ‘secp255k1’.
However, in the case of using MsgBroadCaster
, the method createSignerinfo()
is used in the process of making txRaw, and inside that method, it uses getPublicKey()
that put publicKey’s type to '/injective.crypto.v1beta1.ethsecp256k1.PubKey' when the chainId starts with injective.
https://github.com/InjectiveLabs/injective-ts/blob/master/packages/sdk-ts/src/core/modules/tx/utils/tx.ts#L14
Therefore, in order to prepare for these exceptions, we added a part that changes the pubkey of authinfo to ‘secp256k1’ if you want to sign using WELLDONE Wallet. This is because we can use ‘stargate’ with the same environment as other cosmos chains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now change to '/injective.crypto.v1beta1.ethsecp256k1.PubKey'
method: 'dapp:signTransaction', | ||
params: [`0x${Buffer.from(signBytes).toString('hex')}`], | ||
}) | ||
const pubKey = getPublicKey({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blank space above
return { | ||
signed: signDoc, | ||
signature: { | ||
pub_key: pubKey as any, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you cast it as any
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because getPublicKey()
return type is Any
. So it throws an error that "Property 'type' is missing in type 'Any' but required in type 'Pubkey'."
return { | ||
signed: signDoc, | ||
signature: { | ||
pub_key: encodeSecp256k1Pubkey( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did but there are some pending changes requested below that are still open and not implemented
How about these changes: #193 (comment) |
chanage to /injective.crypto.v1beta1.ethsecp256k1.PubKey
i change to /injective.crypto.v1beta1.ethsecp256k1.PubKey |
WalkthroughThe recent update introduces the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (9)
- packages/wallet-ts/src/strategies/cosmos-wallet-strategy/strategies/Welldone.ts (1 hunks)
- packages/wallet-ts/src/strategies/wallet-strategy/WalletStrategy.ts (2 hunks)
- packages/wallet-ts/src/strategies/wallet-strategy/strategies/Welldone.ts (1 hunks)
- packages/wallet-ts/src/types/enums.ts (1 hunks)
- packages/wallet-ts/src/utils/wallets/cosmos/utils.ts (4 hunks)
- packages/wallet-ts/src/utils/wallets/index.ts (1 hunks)
- packages/wallet-ts/src/utils/wallets/welldone/WelldoneWallet.ts (1 hunks)
- packages/wallet-ts/src/utils/wallets/welldone/index.ts (1 hunks)
- packages/wallet-ts/src/utils/wallets/welldone/welldone.d.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- packages/wallet-ts/src/utils/wallets/welldone/index.ts
Additional comments: 11
packages/wallet-ts/src/utils/wallets/index.ts (1)
- 6-6: The addition of the
welldone
module export is correctly implemented and aligns with the PR's objective to support the WELLDONE Wallet.packages/wallet-ts/src/utils/wallets/welldone/welldone.d.ts (1)
- 1-17: The interface definitions for
RequestParams
andWalletProvider
, along with the extension of the globalWindow
interface, are correctly implemented and align with the PR's objectives for integrating WELLDONE Wallet support.packages/wallet-ts/src/types/enums.ts (1)
- 19-19: The addition of the
Welldone
value to theWallet
enum is correctly implemented and necessary for the library to recognize and interact with the WELLDONE Wallet.packages/wallet-ts/src/utils/wallets/cosmos/utils.ts (3)
- 5-5: Importing
WalletProvider
from../welldone/welldone
is necessary for the changes related to the WELLDONE Wallet support.- 30-30: Expanding the
isCosmosBrowserWallet
function to includeWallet.Welldone
is correctly implemented and aligns with the PR's objectives.- 52-59: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [43-56]
Updating the
isCosmosWalletInstalled
function to check for the presence ofdapp
in the wallet provider object forWallet.Welldone
is correctly implemented and necessary for the integration.packages/wallet-ts/src/strategies/cosmos-wallet-strategy/strategies/Welldone.ts (1)
- 1-133: The
Welldone
class implementingConcreteCosmosWalletStrategy
is correctly implemented, including methods for wallet interaction that align with the PR's objectives. The explicit handling of unsupported operations and consistent error handling are notable.packages/wallet-ts/src/utils/wallets/welldone/WelldoneWallet.ts (1)
- 1-209: The
WelldoneWallet
class is correctly implemented, including methods for wallet interaction that align with the PR's objectives. The explicit handling of unsupported operations, consistent error handling, and the method to check for supported networks are notable.packages/wallet-ts/src/strategies/wallet-strategy/strategies/Welldone.ts (1)
- 1-209: The
Welldone
class implementingConcreteWalletStrategy
is correctly implemented, including methods for wallet interaction that align with the PR's objectives. The explicit handling of unsupported operations and consistent error handling are notable.packages/wallet-ts/src/strategies/wallet-strategy/WalletStrategy.ts (2)
- 25-25: The import statement for the
Welldone
strategy is correctly placed and follows the existing pattern of importing wallet strategies. This ensures that theWelldone
class is available for use within theWalletStrategy
class.- 106-107: The integration of the
Welldone
strategy within thecreateStrategy
function is correctly implemented. It follows the established pattern for integrating new wallet strategies, ensuring consistency and maintainability. The use of the spread operator to pass arguments is appropriate and aligns with the implementation of other strategies.
Description
Hello, We are WELLDONE Studio team from DSRV. We want to add supporting WELLDONE Wallet in
wallet-ts
.WELLDONE extension wallet is multi-chain wallet that support Injective protocol. You can find more information about WELLDONE Wallet here.
Summary by CodeRabbit