Skip to content
This repository was archived by the owner on Sep 14, 2023. It is now read-only.
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix
  • Loading branch information
harrysolovay committed Apr 4, 2023
commit d6d1b0b25dfa292269618d235ef2014f0a2b4890
25 changes: 10 additions & 15 deletions fluent/ExtrinsicRune.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { blake2_256, hex } from "../crypto/mod.ts"
import { concat } from "../deps/std/bytes.ts"
import { $extrinsic, Signer } from "../frame_metadata/Extrinsic.ts"
import { $ } from "../mod.ts"
import { Rune, ValueRune } from "../rune/mod.ts"
Expand Down Expand Up @@ -33,7 +34,8 @@ export class ExtrinsicRune<out C extends Chain, out U> extends PatternRune<Chain
.encoded(this)

signed<SU>(signatureFactory: SignatureDataFactory<C, U, SU>) {
return Rune.fn($extrinsic)
return Rune
.fn($extrinsic)
.call(this.chain.metadata)
.into(CodecRune)
.encoded(Rune.rec({
Expand All @@ -45,7 +47,8 @@ export class ExtrinsicRune<out C extends Chain, out U> extends PatternRune<Chain
}

encoded() {
return Rune.fn($extrinsic)
return Rune
.fn($extrinsic)
.call(this.chain.metadata)
.into(CodecRune)
.encoded(Rune.rec({
Expand All @@ -55,21 +58,13 @@ export class ExtrinsicRune<out C extends Chain, out U> extends PatternRune<Chain
}

feeEstimate() {
const args = Rune
.fn($extrinsic)
.call(this.chain.metadata)
.map(($c) => $.tuple($c, $.u32))
.into(CodecRune)
.encoded(Rune.tuple([
Rune.rec({
protocolVersion: ExtrinsicRune.PROTOCOL_VERSION,
call: this,
}),
this.encoded().access("length"),
]))
const encoded = this.encoded()
const arg = Rune
.fn(concat)
.call(encoded, encoded.access("length").map((n) => $.u32.encode(n)))
.map(hex.encodePrefixed)
const data = this.chain.connection
.call("state_call", "TransactionPaymentApi_query_info", args)
.call("state_call", "TransactionPaymentApi_query_info", arg)
.map(hex.decode)
return this.chain.metadata
.access("types", "sp_weights.weight_v2.Weight")
Expand Down