@@ -7,8 +7,8 @@ import { StrKey } from '../strkey';
7
7
* Converts a Stellar address (in G... or M... form) to an `xdr.MuxedAccount`
8
8
* structure, using the ed25519 representation when possible.
9
9
*
10
- * This supports full muxed accounts by default , where an M... address will
11
- * resolve to both its underlying G... address and an ID.
10
+ * This supports full muxed accounts, where an ` M...` address will resolve to
11
+ * both its underlying ` G...` address and an integer ID.
12
12
*
13
13
* @param {string } address G... or M... address to encode into XDR
14
14
* @returns {xdr.MuxedAccount } a muxed account object for this address string
@@ -72,12 +72,16 @@ export function encodeMuxedAccount(address, id) {
72
72
73
73
/**
74
74
* Extracts the underlying base (G...) address from an M-address.
75
- * @param {string } address a muxed account address (M ...)
75
+ * @param {string } address an account address (either M... or G ...)
76
76
* @return {string } a Stellar public key address (G...)
77
77
*/
78
78
export function extractBaseAddress ( address ) {
79
+ if ( StrKey . isValidEd25519PublicKey ( address ) ) {
80
+ return address ;
81
+ }
82
+
79
83
if ( ! StrKey . isValidMed25519PublicKey ( address ) ) {
80
- throw new TypeError ( 'address should be a muxed account (M...)' ) ;
84
+ throw new TypeError ( `expected muxed account (M...), got ${ address } ` ) ;
81
85
}
82
86
83
87
const muxedAccount = decodeAddressToMuxedAccount ( address ) ;
0 commit comments