Skip to content

Commit

Permalink
chore: update types
Browse files Browse the repository at this point in the history
  • Loading branch information
devdanco committed Mar 22, 2024
1 parent c2eaada commit e08bed8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 25 deletions.
8 changes: 4 additions & 4 deletions packages/sdk/src/utils/metamaskSigning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface SigningResult {
}

export interface SignTypedData_v4 {
dotAddress: string;
ethAddress: string;
payload: GenericExtrinsicPayloadV4;
signature: HexString | null;
}
Expand Down Expand Up @@ -66,10 +66,10 @@ function makeSignOptions(api: ApiPromise, partialOptions: Partial<SignatureOptio

export async function signTypedData_v4(api: ApiPromise, tx: SubmittableExtrinsic<"promise">, provider: SDKProvider): Promise<SignTypedData_v4> {
const ethAddress = provider.selectedAddress;
const dotAddress = encodeAddress(blake2AsU8a(hexToU8a(ethAddress)), 42);
// const dotAddress = encodeAddress(blake2AsU8a(hexToU8a(ethAddress)), 42);
const options: Partial<SignatureOptions> = {};

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 });
Expand All @@ -84,7 +84,7 @@ export async function signTypedData_v4(api: ApiPromise, tx: SubmittableExtrinsic
});

return {
dotAddress,
ethAddress: ethAddress!,
payload,
signature: signature || null
}
Expand Down
8 changes: 3 additions & 5 deletions packages/sdk/src/utils/signTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
Expand Down
9 changes: 1 addition & 8 deletions packages/type-definitions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<BlockNumber>",
Expand Down
9 changes: 1 addition & 8 deletions packages/types/src/interfaces/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<BlockNumber>",
Expand Down

0 comments on commit e08bed8

Please sign in to comment.