diff --git a/dev/scripts/src/scripts/populateTxAndSign.ts b/dev/scripts/src/scripts/populateTxAndSign.ts deleted file mode 100644 index 8ace8b8560..0000000000 --- a/dev/scripts/src/scripts/populateTxAndSign.ts +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2021-2024 Prosopo (UK) Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// #!/usr/bin/env node -// import { hexToString, hexToU8a, u8aToHex } from '@polkadot/util' -// import { Environment } from '../src/env' -// import { blake2AsU8a, encodeAddress } from '@polkadot/util-crypto' -// import { Option, GenericAccountId } from '@polkadot/types' -// -// require('dotenv').config() - -// async function main () { -// const env = new Environment(undefined) -// await env.isReady() -// const contractApi = new ProsopoContractApi(env) -// const serviceOrigin = 'http://localhost:9229' -// const dappContract = '5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y' -// const mnemonic = '//Alice' -// -// if (mnemonic) { -// const signerPair = env.network.keyring.addFromMnemonic(mnemonic) -// const senderAddress = signerPair.address -// const davePair = env.network.keyring.addFromMnemonic('//Dave') -// console.log(davePair.address) -// // let emptyOption: (typeName: keyof InterfaceTypes) => Option; -// const args = [serviceOrigin, dappContract, new Option(env.network.registry, GenericAccountId)] -// const method = 'dappRegister' -// const encodedArgs = contractApi.encodeArgs(method, args) -// console.log(new Option(env.network.registry, GenericAccountId).toU8a()) -// // console.log(u8aToHex(encodedArgs)); -// console.log(encodedArgs) -// const populatedTx = await env.contract?.populateTransaction.dappRegister(...encodedArgs, { gasLimit: 8705000000 }) -// console.log(encodeAddress(populatedTx!.callParams!.dest)) -// console.log(populatedTx!.callParams!.gasLimit.toString()) -// console.log(u8aToHex(populatedTx!.callParams!.inputData)) -// const payload = u8aToHex(populatedTx!.callParams!.inputData) -// console.log('Payload generated with no signer present in environment\n') -// console.log(`Payload: ${payload}`) -// await env.changeSigner(mnemonic) -// const signature = signerPair.sign(hexToU8a(payload), { withType: true }) -// console.log(`Signature: ${u8aToHex(signature)}`) -// console.log(`Decoding 0x42b45efa: ${hexToString('0x42b45efa')}`) -// console.log(`Decoding 0x1501: ${hexToString('0x1501')}`) -// // decodeU8a -// console.log(new Option(env.network.registry, GenericAccountId, null).toU8a()) -// process.exit(0) -// } -// } -// -// main() -// .catch((error) => { -// console.error(error) -// process.exit() -// }) diff --git a/packages/common/src/signer.ts b/packages/common/src/signer.ts deleted file mode 100644 index 6c30ba9913..0000000000 --- a/packages/common/src/signer.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2021-2024 Prosopo (UK) Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Copyright 2017-2023 @polkadot/react-signer authors & contributors -// SPDX-License-Identifier: Apache-2.0 -import { objectSpread } from '@polkadot/util/object' -import type { KeyringPair } from '@polkadot/keyring/types' -import type { Registry, SignerPayloadJSON } from '@polkadot/types/types' -import type { Signer, SignerResult } from '@polkadot/api/types' - -let id = 0 - -export default class AccountSigner implements Signer { - readonly #keyringPair: KeyringPair - readonly #registry: Registry - - constructor(registry: Registry, keyringPair: KeyringPair) { - this.#keyringPair = keyringPair - this.#registry = registry - } - - public async signPayload(payload: SignerPayloadJSON): Promise { - return new Promise((resolve): void => { - const signed = this.#registry - .createType('ExtrinsicPayload', payload, { version: payload.version }) - .sign(this.#keyringPair) - - resolve(objectSpread({ id: ++id }, signed)) - }) - } -}