5
5
makeSignDoc ,
6
6
makeAuthInfoBytes ,
7
7
} from "@cosmjs/proto-signing"
8
- import { Uint64 } from "@cosmjs/math" ;
9
8
import {
10
9
DeliverTxResponse ,
11
10
GasPrice ,
@@ -18,9 +17,9 @@ import {
18
17
SequenceResponse ,
19
18
SignerData ,
20
19
AminoTypes ,
21
- createDefaultAminoConverters
20
+ createDefaultAminoConverters ,
21
+ accountFromAny
22
22
} from "@cosmjs/stargate"
23
- import { EthAccount } from "./types-proto/ethermint/types/v1/account.js" ;
24
23
import { Tendermint34Client , Tendermint37Client } from "@cosmjs/tendermint-rpc"
25
24
import { createDefaultIdentityRegistry } from "./registry.js"
26
25
import {
@@ -48,7 +47,7 @@ import {
48
47
assert ,
49
48
assertDefined
50
49
} from '@cosmjs/utils'
51
- import { encodeSecp256k1Pubkey , Pubkey , SinglePubkey , encodeEd25519Pubkey , StdFee , makeSignDoc as makeSignDocAmino , MultisigThresholdPubkey } from '@cosmjs/amino'
50
+ import { StdFee , makeSignDoc as makeSignDocAmino } from '@cosmjs/amino'
52
51
import { Int53 } from '@cosmjs/math'
53
52
import { fromBase64 } from '@cosmjs/encoding'
54
53
import {
@@ -60,11 +59,7 @@ import { SignMode } from 'cosmjs-types/cosmos/tx/signing/v1beta1/signing.js'
60
59
import { Any } from './types-proto/google/protobuf/any.js'
61
60
import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin.js'
62
61
import Long from 'long'
63
- import { PubKey as CosmosCryptoEd25519Pubkey } from "cosmjs-types/cosmos/crypto/ed25519/keys.js" ;
64
- import { PubKey as CosmosCryptoSecp256k1Pubkey } from "cosmjs-types/cosmos/crypto/secp256k1/keys.js" ;
65
62
import { PubKey as CommonPubKey } from "cosmjs-types/cosmos/crypto/secp256k1/keys.js" ;
66
- import { Secp256k1 } from "./compatability/secp256k1.js" ;
67
- import { LegacyAminoPubKey } from "cosmjs-types/cosmos/crypto/multisig/keys.js"
68
63
import {
69
64
QueryAddressDetailsRequest ,
70
65
QueryAddressDetailsResponse ,
@@ -169,7 +164,7 @@ export class SwisstronikSigningStargateClient extends SigningStargateClient {
169
164
this . _signer = signer
170
165
if ( options . gasPrice ) this . _gasPrice = options . gasPrice
171
166
172
- const { accountParser = this . accountFromAny , aminoTypes = new AminoTypes ( createDefaultAminoConverters ( ) ) , } = options ;
167
+ const { accountParser = accountFromAny , aminoTypes = new AminoTypes ( createDefaultAminoConverters ( ) ) , } = options ;
173
168
this . overridenAccountParser = accountParser ;
174
169
this . _aminoTypes = aminoTypes ;
175
170
}
@@ -432,74 +427,6 @@ export class SwisstronikSigningStargateClient extends SigningStargateClient {
432
427
return signInfos
433
428
}
434
429
435
- private accountFromAny ( input : Any ) : Account {
436
- console . log ( '[DEBUG] Using overriden account parser' )
437
- console . log ( '[DEBUG] Input - ' , input )
438
- const { value } = input
439
- console . log ( 'DEBUG: value to decode' , Buffer . from ( value ) . toString ( 'hex' ) )
440
- const account = EthAccount . decode ( value )
441
- console . log ( '[DEBUG] account' , account )
442
- const { address, pubKey, accountNumber, sequence } = account . baseAccount ! ;
443
- const pubkey = pubKey ? this . decodePubkey ( pubKey ) : null ;
444
- return {
445
- address : address ,
446
- pubkey : pubkey ,
447
- accountNumber : this . uint64FromProto ( accountNumber ) . toNumber ( ) ,
448
- sequence : this . uint64FromProto ( sequence ) . toNumber ( ) ,
449
- } ;
450
- }
451
-
452
- private uint64FromProto ( input : number | Long ) : Uint64 {
453
- return Uint64 . fromString ( input . toString ( ) ) ;
454
- }
455
-
456
- private decodePubkey ( pubkey : Any ) : Pubkey {
457
- switch ( pubkey . typeUrl ) {
458
- case "/ethermint.crypto.v1.ethsecp256k1.PubKey" :
459
- case "/cosmos.crypto.secp256k1.PubKey" :
460
- case "/cosmos.crypto.ed25519.PubKey" : {
461
- return this . anyToSinglePubkey ( pubkey ) ;
462
- }
463
- case "/cosmos.crypto.multisig.LegacyAminoPubKey" : {
464
- return this . anyToMultiPubkey ( pubkey ) ;
465
- }
466
- default :
467
- throw new Error ( `Pubkey type_url ${ pubkey . typeUrl } not recognized` ) ;
468
- }
469
- }
470
-
471
- private anyToMultiPubkey ( pubkey : Any ) : MultisigThresholdPubkey {
472
- const { publicKeys, threshold } = LegacyAminoPubKey . decode ( pubkey . value ) ;
473
- const keys = publicKeys . map ( ( key ) => this . anyToSinglePubkey ( key ) ) ;
474
- return {
475
- type : "tendermint/PubKeyMultisigThreshold" ,
476
- value : {
477
- pubkeys : keys ,
478
- threshold : String ( threshold )
479
- } ,
480
- } ;
481
- }
482
-
483
- private anyToSinglePubkey ( pubkey : Any ) : SinglePubkey {
484
- switch ( pubkey . typeUrl ) {
485
- case "/ethermint.crypto.v1.ethsecp256k1.PubKey" :
486
- const { key } = CommonPubKey . decode ( pubkey . value ) ;
487
- const compressedKey = Secp256k1 . compressPubkey ( key ) ;
488
- return encodeSecp256k1Pubkey ( compressedKey ) ;
489
- case "/cosmos.crypto.secp256k1.PubKey" : {
490
- const { key } = CosmosCryptoSecp256k1Pubkey . decode ( pubkey . value ) ;
491
- return encodeSecp256k1Pubkey ( key ) ;
492
- }
493
- case "/cosmos.crypto.ed25519.PubKey" : {
494
- const { key } = CosmosCryptoEd25519Pubkey . decode ( pubkey . value ) ;
495
- return encodeEd25519Pubkey ( key ) ;
496
- }
497
- default :
498
- throw new Error ( `Pubkey type_url ${ pubkey . typeUrl } not recognized as single public key type` ) ;
499
- }
500
- }
501
-
502
-
503
430
public async queryAddressDetails ( address : string ) {
504
431
const response = await this . forceGetTmClient ( ) . abciQuery ( {
505
432
path : `/swisstronik.compliance.Query/AddressDetails` ,
0 commit comments