Make wallet use Provider not JsonRpcProvider
This commit is contained in:
parent
b72fbb0ed9
commit
1af3ab1a0a
|
@ -82,6 +82,9 @@ method estimateGas*(provider: Provider,
|
||||||
method getChainId*(provider: Provider): Future[UInt256] {.base.} =
|
method getChainId*(provider: Provider): Future[UInt256] {.base.} =
|
||||||
doAssert false, "not implemented"
|
doAssert false, "not implemented"
|
||||||
|
|
||||||
|
method sendRawTransaction*(provider: Provider, rawTransaction: seq[byte]): Future[TransactionResponse] {.base, async.} =
|
||||||
|
doAssert false, "not implemented"
|
||||||
|
|
||||||
method subscribe*(provider: Provider,
|
method subscribe*(provider: Provider,
|
||||||
filter: Filter,
|
filter: Filter,
|
||||||
callback: LogHandler):
|
callback: LogHandler):
|
||||||
|
|
|
@ -3,7 +3,7 @@ import eth/rlp
|
||||||
import eth/common
|
import eth/common
|
||||||
import eth/common/transaction as ct
|
import eth/common/transaction as ct
|
||||||
import stew/byteutils
|
import stew/byteutils
|
||||||
import ./providers/jsonrpc
|
import ./provider
|
||||||
import ./transaction
|
import ./transaction
|
||||||
import ./signer
|
import ./signer
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ type Wallet* = ref object of Signer
|
||||||
privateKey*: PrivateKey
|
privateKey*: PrivateKey
|
||||||
publicKey*: PublicKey
|
publicKey*: PublicKey
|
||||||
address*: Address
|
address*: Address
|
||||||
provider*: ?JsonRpcProvider
|
provider*: ?Provider
|
||||||
|
|
||||||
proc new*(_: type Wallet, pk: string, provider: JsonRpcProvider): Wallet =
|
proc new*(_: type Wallet, pk: string, provider: Provider): Wallet =
|
||||||
result = Wallet()
|
result = Wallet()
|
||||||
result.privateKey = PrivateKey.fromHex(pk).value
|
result.privateKey = PrivateKey.fromHex(pk).value
|
||||||
result.publicKey = result.privateKey.toPublicKey()
|
result.publicKey = result.privateKey.toPublicKey()
|
||||||
|
@ -36,14 +36,14 @@ proc new*(_: type Wallet, pk: string): Wallet =
|
||||||
result.privateKey = PrivateKey.fromHex(pk).value
|
result.privateKey = PrivateKey.fromHex(pk).value
|
||||||
result.publicKey = result.privateKey.toPublicKey()
|
result.publicKey = result.privateKey.toPublicKey()
|
||||||
result.address = Address.init(result.publicKey.toCanonicalAddress())
|
result.address = Address.init(result.publicKey.toCanonicalAddress())
|
||||||
proc connect*(wallet: Wallet, provider: JsonRpcProvider) =
|
proc connect*(wallet: Wallet, provider: Provider) =
|
||||||
wallet.provider = some provider
|
wallet.provider = some provider
|
||||||
proc createRandom*(_: type Wallet): Wallet =
|
proc createRandom*(_: type Wallet): Wallet =
|
||||||
result = Wallet()
|
result = Wallet()
|
||||||
result.privateKey = PrivateKey.random(getRng()[])
|
result.privateKey = PrivateKey.random(getRng()[])
|
||||||
result.publicKey = result.privateKey.toPublicKey()
|
result.publicKey = result.privateKey.toPublicKey()
|
||||||
result.address = Address.init(result.publicKey.toCanonicalAddress())
|
result.address = Address.init(result.publicKey.toCanonicalAddress())
|
||||||
proc createRandom*(_: type Wallet, provider: JsonRpcProvider): Wallet =
|
proc createRandom*(_: type Wallet, provider: Provider): Wallet =
|
||||||
result = Wallet()
|
result = Wallet()
|
||||||
result.privateKey = PrivateKey.random(getRng()[])
|
result.privateKey = PrivateKey.random(getRng()[])
|
||||||
result.publicKey = result.privateKey.toPublicKey()
|
result.publicKey = result.privateKey.toPublicKey()
|
||||||
|
|
Loading…
Reference in New Issue