Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/chains/polkadot_1/ChainPolkadotV1.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainActionType, ChainInfo, ChainType, CryptoCurve, ChainEntityName, ChainDate } from '../../models'
import { ChainActionType, ChainType, CryptoCurve, ChainEntityName, ChainDate } from '../../models'
import { ChainError } from '../../errors'
import { Chain } from '../../interfaces'
import {
Expand All @@ -13,9 +13,10 @@ import {
import { PolkadotChainState } from './polkadotChainState'
import { notImplemented } from '../../helpers'
import { PolkadotChainActionType } from './models/chainActionType'
import { PolkadotTransactionAction } from './models/transactionModels'
import { PolkadotTransactionAction, PolkadotTransactionOptions } from './models/transactionModels'
import { PolkadotAccount } from './polkadotAccount'
import { PolkadotTransaction } from './polkadotTransaction'
import { PolkadotCrypto } from './polkadotCrypto'

import * as polkadotCrypto from './polkadotCrypto'
import * as ethcrypto from '../ethereum_1/ethCrypto'
Expand Down Expand Up @@ -136,15 +137,20 @@ class ChainPolkadotV1 implements Chain {
return new PolkadotCreateAccount(this._chainState, options)
}

private newTransaction = (options?: any): PolkadotTransaction => {
private newTransaction = (options?: PolkadotTransactionOptions): PolkadotTransaction => {
this.assertIsConnected()
return new PolkadotTransaction(this._chainState, options)
}

private newCrypto = (options?: any): PolkadotCrypto => {
return new PolkadotCrypto(this._chainState, options)
}

public new = {
Account: this.newAccount,
CreateAccount: this.newCreateAccount,
Transaction: this.newTransaction,
Crypto: this.newCrypto,
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
16 changes: 8 additions & 8 deletions src/chains/polkadot_1/examples/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ async function run() {
})
console.log('decrypted payload:', decryptedPayload)

const publicKey1 = toPolkadotPublicKey(
'0x2e438c99bd7ded27ed921919e1d5ee1d9b1528bb8a2f6c974362ad1a9ba7a6f59a452a0e4dfbc178ab5c5c090506bd7f0a6659fd3cf0cc769d6c17216d414163',
)
// const publicKey1 = toPolkadotPublicKey(
// '0x2e438c99bd7ded27ed921919e1d5ee1d9b1528bb8a2f6c974362ad1a9ba7a6f59a452a0e4dfbc178ab5c5c090506bd7f0a6659fd3cf0cc769d6c17216d414163',
// )

const privateKey1 = toPolkadotPrivateKey('0x7b0c4bdbc24fd7b6045e9001dbe93f1e46478dedcfcefbc42180ac79fd08ce28')
// const privateKey1 = toPolkadotPrivateKey('0x7b0c4bdbc24fd7b6045e9001dbe93f1e46478dedcfcefbc42180ac79fd08ce28')

const encrypted2 = await para.encryptWithPublicKey('text to encrypt 2', publicKey1)
console.log('encrypted text 2:', encrypted2)
const decrypted2 = await para.decryptWithPrivateKey(encrypted2, privateKey1)
console.log('decrypted text 2:', decrypted2)
// const encrypted2 = await para.encryptWithPublicKey('text to encrypt 2', publicKey1)
// console.log('encrypted text 2:', encrypted2)
// const decrypted2 = await para.decryptWithPrivateKey(encrypted2, privateKey1)
// console.log('decrypted text 2:', decrypted2)
}

;(async () => {
Expand Down
Loading