-
Notifications
You must be signed in to change notification settings - Fork 41
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
Implementing getBalances, getBalance, getAddress and canSign methods #24
Conversation
aabf433
to
41a52d9
Compare
41a52d9
to
c04e25e
Compare
Coinbase.apiClients.address!.createAddress = mockReturnValue(mockAddressModel); | ||
wallet = await Wallet.create(); | ||
}); | ||
it("should return true when the wallet initialized ", () => { |
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.
Can we test when the wallet does not have a seed?
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.
@alex-stone Based on my understanding, wallet = await Wallet.create();
does not provide an option to include or exclude a seed. Regardless of whether we use Wallet.create
or Wallet.init
, the Wallet class will always have a master wallet after creation. I added this method to ensure parity with the Ruby SDK. Please let me know if there's any specific aspect you're concerned about or if I have misunderstood your point.
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.
Synced offline: Let's add that when we add listing wallets support
src/coinbase/tests/wallet_test.ts
Outdated
@@ -171,4 +184,156 @@ describe("Wallet Class", () => { | |||
expect(newWallet).toBeInstanceOf(Wallet); | |||
}); | |||
}); | |||
|
|||
describe(".defaultAddress", () => { |
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.
If we're aiming for consistency with ruby and are using the .
prefixes, we should do:
describe(".classMethod", ...
and
describe("#instanceMethod", ...
E.g.
describe(".defaultAddress", () => { | |
describe("#defaultAddress", () => { |
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.
Sure, I'm going to update this. I will also update all test files. (tracking with PSDK-165)
* @returns Whether the Wallet has a seed with which to derive keys and sign transactions. | ||
*/ | ||
public canSign(): boolean { | ||
return this.master.publicKey !== undefined; |
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.
Shouldn't this just be this.publicKey !== undefined
?
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.
const defaultAddress = wallet.defaultAddress(); | ||
const address = wallet.getAddress(defaultAddress?.getId()); | ||
expect(address).toBeInstanceOf(Address); | ||
expect(address?.getId()).toBe(address.getId()); |
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.
Could also have this just assert on the mockAddressModel.AddresId
to reduce coupling on getAddress
behavior.
}); | ||
}); | ||
|
||
describe(".networkId", () => { |
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.
This and wlaletId
should probably be #
too
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.
Sure, I will have a PR for this changes (PSDK-165)
Coinbase.apiClients.address!.createAddress = mockReturnValue(mockAddressModel); | ||
wallet = await Wallet.create(); | ||
}); | ||
it("should return true when the wallet initialized ", () => { |
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.
Synced offline: Let's add that when we add listing wallets support
What changed? Why?
I am adding the
getBalances
,getBalance
,getAddress
, andcanSign
methods, along with their respective test cases.Qualified Impact