From e08bed8a0d99f5bbc0f8a34fc37afdc7a284093e Mon Sep 17 00:00:00 2001 From: devdanco Date: Fri, 22 Mar 2024 13:52:37 +0100 Subject: [PATCH] chore: update types --- packages/sdk/src/utils/metamaskSigning.ts | 8 ++++---- packages/sdk/src/utils/signTx.ts | 8 +++----- packages/type-definitions/src/index.ts | 9 +-------- packages/types/src/interfaces/definitions.ts | 9 +-------- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/packages/sdk/src/utils/metamaskSigning.ts b/packages/sdk/src/utils/metamaskSigning.ts index 8f28dce..4df008d 100644 --- a/packages/sdk/src/utils/metamaskSigning.ts +++ b/packages/sdk/src/utils/metamaskSigning.ts @@ -18,7 +18,7 @@ interface SigningResult { } export interface SignTypedData_v4 { - dotAddress: string; + ethAddress: string; payload: GenericExtrinsicPayloadV4; signature: HexString | null; } @@ -66,10 +66,10 @@ function makeSignOptions(api: ApiPromise, partialOptions: Partial, provider: SDKProvider): Promise { const ethAddress = provider.selectedAddress; - const dotAddress = encodeAddress(blake2AsU8a(hexToU8a(ethAddress)), 42); + // const dotAddress = encodeAddress(blake2AsU8a(hexToU8a(ethAddress)), 42); const options: Partial = {}; - const signingInfo = await api.derive.tx.signingInfo(dotAddress, options.nonce, options.era); + const signingInfo = await api.derive.tx.signingInfo(ethAddress!, options.nonce, options.era); const eraOptions = makeEraOptions(api, api.registry, options, signingInfo); const payload = tx.inner.signature.createPayload(tx.method as Call, eraOptions); const raw_payload = payload.toU8a({ method: true }); @@ -84,7 +84,7 @@ export async function signTypedData_v4(api: ApiPromise, tx: SubmittableExtrinsic }); return { - dotAddress, + ethAddress: ethAddress!, payload, signature: signature || null } diff --git a/packages/sdk/src/utils/signTx.ts b/packages/sdk/src/utils/signTx.ts index f9bcef6..36f793d 100644 --- a/packages/sdk/src/utils/signTx.ts +++ b/packages/sdk/src/utils/signTx.ts @@ -182,13 +182,11 @@ export const signTx = async ( return; } - const { dotAddress, payload, signature } = signRes; - const created_signature = api.createType('MultiSignature', { - Eth: hexToU8a(signature), - }); + const { ethAddress, payload, signature } = signRes; + const created_signature = api.createType('EthereumSignature', hexToU8a(signature)) metamaskTx.addSignature( - dotAddress, + ethAddress, created_signature.toHex(), payload.toHex() ); diff --git a/packages/type-definitions/src/index.ts b/packages/type-definitions/src/index.ts index e5f90f4..4e5a630 100644 --- a/packages/type-definitions/src/index.ts +++ b/packages/type-definitions/src/index.ts @@ -5,14 +5,7 @@ export const mTypes = { seed: "H256", proof: "H512" }, - MultiSignature: { - _enum: { - Ed25519: 'Ed25519Signature', - Sr25519: 'Sr25519Signature', - Ecdsa: 'EcdsaSignature', - Eth: 'EcdsaSignature', - } - }, + EthereumSignature: "EcdsaSignature", Header: { parentHash: "Hash", number: "Compact", diff --git a/packages/types/src/interfaces/definitions.ts b/packages/types/src/interfaces/definitions.ts index a35b4b6..ebf46c7 100644 --- a/packages/types/src/interfaces/definitions.ts +++ b/packages/types/src/interfaces/definitions.ts @@ -4,14 +4,7 @@ export default { seed: "H256", proof: "H512" }, - MultiSignature: { - _enum: { - Ed25519: 'Ed25519Signature', - Sr25519: 'Sr25519Signature', - Ecdsa: 'EcdsaSignature', - Eth: 'EcdsaSignature', - } - }, + EthereumSignature: "EcdsaSignature", Header: { parentHash: "Hash", number: "Compact",