Last active
March 5, 2021 06:53
-
-
Save taurenshaman/de4cb3ce973ac53799723124cb1b703b to your computer and use it in GitHub Desktop.
F:\Github\pw-core\src\providers\raw-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Provider, Platform } from './provider'; | |
import { Address, AddressType } from '..'; | |
import { Blake2bSigner } from '../signers/blake2b-signer'; | |
// 基于DummyProvider修改 | |
export class RawProvider extends Provider { | |
secret: string; | |
signer: Blake2bSigner; | |
sign(message: string): Promise<string> { | |
console.log('message', message); | |
return this.signer.signMessage(message); | |
} | |
constructor(secret: string, platform: Platform = Platform.ckb) { | |
super(platform); | |
this.secret = secret; | |
this.signer = new Blake2bSigner(this, secret); | |
} | |
async init(): Promise<Provider> { | |
if (this.platform === Platform.eth) { | |
this.address = new Address( | |
'0x26C5F390FF2033CbB44377361c63A3Dd2DE3121d', | |
AddressType.eth | |
); | |
} else { | |
this.address = new Address( | |
'ckt1qyqxpayn272n8km2k08hzldynj992egs0waqnr8zjs', | |
AddressType.ckb | |
); | |
} | |
return this; | |
} | |
async close() { | |
console.log('do nothing'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment