-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend,devOps): Split backend (#2043)
# Motivation Here we wish to make the frontend make all its signing API calls to the signing canister. # Changes - Create a signing agent. - Move all signing API calls from the backend agent to the signer agent. # Tests - Existing CI should pass.
- Loading branch information
Showing
7 changed files
with
97 additions
and
57 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import type { BitcoinNetwork, SignRequest } from '$declarations/signer/signer.did'; | ||
import { getBackendActor } from '$lib/actors/actors.ic'; | ||
import type { EthAddress } from '$lib/types/address'; | ||
import type { OptionIdentity } from '$lib/types/identity'; | ||
|
||
export const getBtcAddress = async ({ | ||
identity, | ||
network | ||
}: { | ||
identity: OptionIdentity; | ||
network: BitcoinNetwork; | ||
}): Promise<EthAddress> => { | ||
const { caller_btc_address } = await getBackendActor({ identity }); | ||
return caller_btc_address(network); | ||
}; | ||
|
||
export const getEthAddress = async (identity: OptionIdentity): Promise<EthAddress> => { | ||
const { caller_eth_address } = await getBackendActor({ identity }); | ||
return caller_eth_address(); | ||
}; | ||
|
||
export const signTransaction = async ({ | ||
transaction, | ||
identity | ||
}: { | ||
transaction: SignRequest; | ||
identity: OptionIdentity; | ||
}): Promise<string> => { | ||
const { sign_transaction } = await getBackendActor({ identity }); | ||
return sign_transaction(transaction); | ||
}; | ||
|
||
export const signMessage = async ({ | ||
message, | ||
identity | ||
}: { | ||
message: string; | ||
identity: OptionIdentity; | ||
}): Promise<string> => { | ||
const { personal_sign } = await getBackendActor({ identity }); | ||
return personal_sign(message); | ||
}; | ||
|
||
export const signPrehash = async ({ | ||
hash, | ||
identity | ||
}: { | ||
hash: string; | ||
identity: OptionIdentity; | ||
}): Promise<string> => { | ||
const { sign_prehash } = await getBackendActor({ identity }); | ||
return sign_prehash(hash); | ||
}; |
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