New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add non-breaking muxed account support to fee-bump transactions. #434
Changes from 7 commits
ab8dee3
a569845
954984a
1bdf671
378641b
6d2e9ce
d92bb4a
0dd5b8d
cfc6df0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +149,17 @@ export class MuxedAccount { | |
return new MuxedAccount(new Account(gAddress, sequenceNum), id); | ||
} | ||
|
||
/** | ||
* A helper method to turn an M-address into its underlying G-address. | ||
* | ||
* @param {string} mAddress - muxed address to convert | ||
* @returns {string} underlying G-address | ||
*/ | ||
static parseBaseAddress(mAddress) { | ||
const muxedAccount = decodeAddressToMuxedAccount(mAddress, true); | ||
return encodeMuxedAccountToAddress(muxedAccount, false); | ||
} | ||
|
||
/** | ||
* @return {Account} the underlying account object shared among all muxed | ||
* accounts with this Stellar address | ||
|
@@ -195,6 +206,16 @@ export class MuxedAccount { | |
return this.account.incrementSequenceNumber(); | ||
} | ||
|
||
/** | ||
* Creates another muxed "sub"account from the base with a new ID set | ||
* | ||
* @param {string} id - the ID of the new muxed account | ||
* @return {MuxedAccount} a new instance w/ the specified parameters | ||
*/ | ||
createSubaccount(id) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we need this method can we rename this to However, I think this function confusing. You can't create a muxed account that multiplexes another muxed account. The following code, although verbose, seems much clearer. Is there a reason we can't use it? or a reason we need to be able to create muxed accounts from muxed accounts? muxedAccount.baseAccount().createMuxedAccount(id) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though I completely agree that it's odd to have this method on this object, I added it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is driving the need for this interface compatibility? I don't see anything new calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no true need (especially since nobody is using muxed accounts); I just had it in mind after stellar/js-stellar-sdk#653. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, interesting. In this case, I don't think all accounts should have this capability. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree in theory, but then you cannot use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. Thanks for explaining. For my own understanding, which is limited here, is there no way in JavaScript/TypeScript to specify an interface type that provides a set of functions, so AccountResponse and MuxedAccount don't always have to have the exact same function set as Account, but rather there could be some interface Account that is a common subset that doesn't include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're essentially describing exactly what I want: an interface that covers the common subset of functionality across |
||
return new MuxedAccount(this.account, id); | ||
} | ||
|
||
/** | ||
* @return {xdr.MuxedAccount} the XDR object representing this muxed account's | ||
* G-address and uint64 ID | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of this function is a little confusing. Often functions named
parseX
are understood to "parse X". In this case the function is namedparseBaseAddress
but what it does is "parse an M address".I think it would be easier to understand the intent of this function if it was named
parseMuxedAddress
and it returned all the components of a muxed address. I thought we would have had something like this already, but I guess we don't?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you're saying. We do have that:
MuxedAccount.fromAddress
, but doing M -> G strings becomes unwieldy:(see cfc6df0). How about
extract
overparse
, @leighmcculloch? e.g.