forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wallet-ext: use bg service for signing (MystenLabs#6941)
* ts-sdk: deserialize a public key from base64 data and schema * wallet-ext: move signing to background service * creates a new SignerWithProvider that communicates with the bg service to sign the data * this will allow to remove key pairs from the UI. closes: APPS-279
- Loading branch information
1 parent
f61ae12
commit f741812
Showing
14 changed files
with
247 additions
and
52 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,5 @@ | ||
--- | ||
"@mysten/sui.js": minor | ||
--- | ||
|
||
Add method to deserialize a public key, using it's schema and base64 data |
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
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
45 changes: 45 additions & 0 deletions
45
apps/wallet/src/ui/app/background-client/BackgroundServiceSigner.ts
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,45 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { SignerWithProvider } from '@mysten/sui.js'; | ||
|
||
import type { BackgroundClient } from '.'; | ||
import type { | ||
Base64DataBuffer, | ||
Provider, | ||
SignaturePubkeyPair, | ||
SuiAddress, | ||
TxnDataSerializer, | ||
} from '@mysten/sui.js'; | ||
|
||
export class BackgroundServiceSigner extends SignerWithProvider { | ||
readonly #address: SuiAddress; | ||
readonly #backgroundClient: BackgroundClient; | ||
|
||
constructor( | ||
address: SuiAddress, | ||
backgroundClient: BackgroundClient, | ||
provider?: Provider, | ||
serializer?: TxnDataSerializer | ||
) { | ||
super(provider, serializer); | ||
this.#address = address; | ||
this.#backgroundClient = backgroundClient; | ||
} | ||
|
||
async getAddress(): Promise<string> { | ||
return this.#address; | ||
} | ||
|
||
signData(data: Base64DataBuffer): Promise<SignaturePubkeyPair> { | ||
return this.#backgroundClient.signData(this.#address, data); | ||
} | ||
|
||
connect(provider: Provider): SignerWithProvider { | ||
return new BackgroundServiceSigner( | ||
this.#address, | ||
this.#backgroundClient, | ||
provider | ||
); | ||
} | ||
} |
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
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
Oops, something went wrong.