1- import { fromBase64 , toBase64 } from "@cosmjs/encoding" ;
1+ import { toBase64 } from "@cosmjs/encoding" ;
22import { v4 as uuid } from "uuid" ;
33import browser , { Windows } from "webextension-polyfill" ;
44
5- import { BuiltTx } from "@heliax/namada-sdk/web" ;
65import { KVStore } from "@namada/storage" ;
76import { SignArbitraryResponse , TxDetails } from "@namada/types" ;
87import { paramsToUrl } from "@namada/utils" ;
@@ -14,6 +13,7 @@ import { SdkService } from "background/sdk";
1413import { VaultService } from "background/vault" ;
1514import { ExtensionBroadcaster } from "extension" ;
1615import { LocalStorage } from "storage" ;
16+ import { fromEncodedTx } from "utils" ;
1717import { EncodedTxData , PendingTx } from "./types" ;
1818
1919export class ApprovalsService {
@@ -50,12 +50,10 @@ export class ApprovalsService {
5050
5151 const pendingTx : PendingTx = {
5252 signer,
53- txs : txs . map ( ( { txBytes, signingDataBytes } ) => ( {
54- txBytes : fromBase64 ( txBytes ) ,
55- signingDataBytes : signingDataBytes . map ( ( bytes ) => fromBase64 ( bytes ) ) ,
56- } ) ) ,
53+ txs : txs . map ( ( encodedTx ) => fromEncodedTx ( encodedTx ) ) ,
5754 checksums,
5855 } ;
56+
5957 await this . txStore . set ( msgId , pendingTx ) ;
6058
6159 const url = `${ browser . runtime . getURL (
@@ -122,16 +120,9 @@ export class ApprovalsService {
122120 throw new Error ( `Signing data for ${ msgId } not found!` ) ;
123121 }
124122
125- const txs = pendingTx . txs . map ( ( { txBytes, signingDataBytes } ) => {
126- return new BuiltTx (
127- txBytes ,
128- signingDataBytes . map ( ( sdBytes ) => [ ...sdBytes ] )
129- ) ;
130- } ) ;
131-
132123 try {
133124 const signedBytes : Uint8Array [ ] = [ ] ;
134- for await ( const tx of txs ) {
125+ for await ( const tx of pendingTx . txs ) {
135126 signedBytes . push ( await this . keyRingService . sign ( tx , signer ) ) ;
136127 }
137128 resolvers . resolve ( signedBytes ) ;
@@ -165,8 +156,8 @@ export class ApprovalsService {
165156 const { tx } = this . sdkService . getSdk ( ) ;
166157
167158 try {
168- const signedTxs = pendingTx . txs . map ( ( { txBytes } , i ) => {
169- return tx . appendSignature ( txBytes , responseSign [ i ] ) ;
159+ const signedTxs = pendingTx . txs . map ( ( { bytes } , i ) => {
160+ return tx . appendSignature ( bytes , responseSign [ i ] ) ;
170161 } ) ;
171162 resolvers . resolve ( signedTxs ) ;
172163 } catch ( e ) {
@@ -303,8 +294,8 @@ export class ApprovalsService {
303294 }
304295
305296 const { tx } = this . sdkService . getSdk ( ) ;
306- return pendingTx . txs . map ( ( { txBytes } ) =>
307- tx . deserialize ( txBytes , pendingTx . checksums || { } )
297+ return pendingTx . txs . map ( ( { bytes } ) =>
298+ tx . deserialize ( bytes , pendingTx . checksums || { } )
308299 ) ;
309300 }
310301
@@ -316,7 +307,7 @@ export class ApprovalsService {
316307 }
317308
318309 if ( pendingTx . txs ) {
319- return pendingTx . txs . map ( ( { txBytes } ) => toBase64 ( txBytes ) ) ;
310+ return pendingTx . txs . map ( ( { bytes } ) => toBase64 ( bytes ) ) ;
320311 }
321312 }
322313
0 commit comments