From 3362c0fdfa2c2c3192b71c2e4a0d0c292a7b588e Mon Sep 17 00:00:00 2001 From: Dennis Zoma Date: Tue, 23 Jan 2024 23:00:38 +0700 Subject: [PATCH 1/2] Allow to pass address as signer for web3 extension compatability --- packages/typechain-types/src/tx.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/typechain-types/src/tx.ts b/packages/typechain-types/src/tx.ts index db603b6d..bb784870 100644 --- a/packages/typechain-types/src/tx.ts +++ b/packages/typechain-types/src/tx.ts @@ -54,13 +54,13 @@ type SignAndSendSuccessResponse = { }; export type { - SignAndSendSuccessResponse, + SignAndSendSuccessResponse }; export async function txSignAndSend( nativeAPI: ApiPromise, nativeContract : ContractPromise, - keyringPair : KeyringPair, + signer : KeyringPair | string, title : string, eventHandler : (event: EventRecord[]) => { [index: string]: any; @@ -72,9 +72,9 @@ export async function txSignAndSend( const _realGasLimit = gasLimitAndValue || {gasLimit: undefined, value: undefined}; // estimate gas limit - + const signerAddress = typeof signer === 'string' ? signer : signer.address; const estimatedGasLimit = (await nativeContract.query[title]( - keyringPair.address, + signerAddress, _gasLimitAndValue, ...args )).gasRequired; @@ -87,7 +87,7 @@ export async function txSignAndSend( nativeAPI, nativeContract, title, args, estimatedGasLimitAndValue, ); - return _signAndSend(nativeAPI.registry, submittableExtrinsic, keyringPair, eventHandler); + return _signAndSend(nativeAPI.registry, submittableExtrinsic, signer, eventHandler); } export function buildSubmittableExtrinsic( @@ -123,12 +123,12 @@ export function buildSubmittableExtrinsic( export async function _signAndSend( registry: Registry, extrinsic: SubmittableExtrinsic<'promise'>, - signer: KeyringPair, + signer: KeyringPair | string, eventHandler : (event: EventRecord[]) => { [index: string]: any; }, ): Promise { - const signerAddress = signer.address; + const signerAddress = typeof signer === 'string' ? signer : signer.address; return new Promise((resolve, reject) => { const actionStatus = { From 97769af28f374426c5b43736c6bde892c492df65 Mon Sep 17 00:00:00 2001 From: Dennis Zoma Date: Wed, 13 Mar 2024 10:16:11 +0100 Subject: [PATCH 2/2] fix: Add missing trailing comma --- packages/typechain-types/src/tx.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typechain-types/src/tx.ts b/packages/typechain-types/src/tx.ts index bb784870..b0c93685 100644 --- a/packages/typechain-types/src/tx.ts +++ b/packages/typechain-types/src/tx.ts @@ -54,7 +54,7 @@ type SignAndSendSuccessResponse = { }; export type { - SignAndSendSuccessResponse + SignAndSendSuccessResponse, }; export async function txSignAndSend(