From 098f672981144db314de95a0129a09ef954f2d1b Mon Sep 17 00:00:00 2001 From: "Alex M. - Clockwork" Date: Thu, 16 Jan 2025 13:26:36 +0200 Subject: [PATCH] feat: Add custom signer support --- package.json | 2 +- src/wallet/wallet.ts | 15 +++++++++++++++ yarn.lock | 8 ++++---- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index c54fd5c..c5a208c 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ }, "dependencies": { "@cosmjs/ledger-amino": "^0.32.4", - "@gnolang/tm2-js-client": "^1.2.2", + "@gnolang/tm2-js-client": "^1.2.4", "long": "^5.2.3", "protobufjs": "^7.4.0" } diff --git a/src/wallet/wallet.ts b/src/wallet/wallet.ts index 9772a25..6876b76 100644 --- a/src/wallet/wallet.ts +++ b/src/wallet/wallet.ts @@ -2,6 +2,7 @@ import { AccountWalletOption, BroadcastTransactionMap, CreateWalletOptions, + Signer, Tx, TxFee, Wallet, @@ -37,6 +38,20 @@ export class GnoWallet extends Wallet { return gnoWallet; }; + /** + * Generates a custom signer-based wallet + * @param {Signer} signer the custom signer implementing the Signer interface + * @param {CreateWalletOptions} options the wallet generation options + */ + static override fromSigner = async (signer: Signer): Promise => { + const wallet = await Wallet.fromSigner(signer); + + const gnoWallet: GnoWallet = new GnoWallet(); + gnoWallet.signer = wallet.getSigner(); + + return gnoWallet; + }; + /** * Generates a bip39 mnemonic-based wallet * @param {string} mnemonic the bip39 mnemonic diff --git a/yarn.lock b/yarn.lock index e82ccfc..e746cf0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -428,10 +428,10 @@ dependencies: levn "^0.4.1" -"@gnolang/tm2-js-client@^1.2.2": - version "1.2.2" - resolved "https://registry.yarnpkg.com/@gnolang/tm2-js-client/-/tm2-js-client-1.2.2.tgz#b143a2fb6e76a803412dacdf8c017a031390535f" - integrity sha512-mI+vVulUKawXGono+6udT6VkkKo6E+kX0lcyRIp2Yvk5GwoxoExiKDAY/EYNC3OUKJebjh52nVTVkKZnSfW0GQ== +"@gnolang/tm2-js-client@^1.2.4": + version "1.2.4" + resolved "https://registry.yarnpkg.com/@gnolang/tm2-js-client/-/tm2-js-client-1.2.4.tgz#7f7da6f7e8ad7a48e43438b12153e2e74f49b919" + integrity sha512-zZpqtJD4TXi2UKIsTHJ2t3vqPOkfK9eh66+KOvVjYksgsjtEHl1MRFHL5XKlcclTdjq8aG8PTzovnp0hGSWwgA== dependencies: "@cosmjs/amino" "^0.32.4" "@cosmjs/crypto" "^0.32.4"