-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: move ExampleNodeWallet to own entrypoint
No need to pollute the global API or bundle size with this.
- Loading branch information
Showing
3 changed files
with
31 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Keypair, TransactionBuilder, hash } from '.' | ||
|
||
/** | ||
* For use with {@link ContractClient} and {@link AssembledTransaction}. | ||
* Implements `signTransaction` and `signAuthEntry` with signatures expected by | ||
* those classes. This is useful for testing and maybe some simple Node | ||
* applications. Feel free to use this as a starting point for your own | ||
* Wallet/TransactionSigner implementation. | ||
*/ | ||
export class ExampleNodeWallet { | ||
constructor( | ||
private keypair: Keypair, | ||
private networkPassphrase: string, | ||
) {} | ||
|
||
signTransaction = async (tx: string) => { | ||
const t = TransactionBuilder.fromXDR(tx, this.networkPassphrase); | ||
t.sign(this.keypair); | ||
return t.toXDR(); | ||
} | ||
|
||
signAuthEntry = async (entryXdr: string): Promise<string> => { | ||
return this.keypair | ||
.sign(hash(Buffer.from(entryXdr, "base64"))) | ||
.toString('base64') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters