Skip to content

Commit

Permalink
Merge pull request #84 from perawallet/next-release
Browse files Browse the repository at this point in the history
  • Loading branch information
mucahit authored Dec 1, 2022
2 parents 624274c + 7869cd9 commit b2bed93
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.6",
"version": "1.0.7",
"name": "@perawallet/connect",
"description": "JavaScript SDK for integrating Pera Wallet to web applications.",
"main": "dist/index.js",
Expand Down
10 changes: 9 additions & 1 deletion src/PeraWalletConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,15 @@ class PeraWalletConnect {

try {
try {
const response = await this.connector!.sendCustomRequest(formattedSignTxnRequest);
const {silent} = await getPeraConnectConfig(this.network);

const response = await this.connector!.sendCustomRequest(
formattedSignTxnRequest,
{
forcePushNotification: !silent
}
);

// We send the full txn group to the mobile wallet.
// Therefore, we first filter out txns that were not signed by the wallet.
// These are received as `null`.
Expand Down
10 changes: 6 additions & 4 deletions src/modal/peraWalletConnectModalUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ function createModalWrapperOnDOM(modalId: string) {

function openPeraWalletConnectModal(modalConfig: PeraWalletModalConfig) {
return (uri: string) => {
const root = createModalWrapperOnDOM(PERA_WALLET_CONNECT_MODAL_ID);
const newURI = `${uri}&algorand=true`;
const {isWebWalletAvailable, shouldDisplayNewBadge, shouldUseSound} = modalConfig;
if (!document.getElementById(PERA_WALLET_CONNECT_MODAL_ID)) {
const root = createModalWrapperOnDOM(PERA_WALLET_CONNECT_MODAL_ID);
const newURI = `${uri}&algorand=true`;
const {isWebWalletAvailable, shouldDisplayNewBadge, shouldUseSound} = modalConfig;

root.innerHTML = `<pera-wallet-connect-modal uri="${newURI}" is-web-wallet-avaliable="${isWebWalletAvailable}" should-display-new-badge="${shouldDisplayNewBadge}" should-use-sound="${shouldUseSound}"></pera-wallet-connect-modal>`;
root.innerHTML = `<pera-wallet-connect-modal uri="${newURI}" is-web-wallet-avaliable="${isWebWalletAvailable}" should-display-new-badge="${shouldDisplayNewBadge}" should-use-sound="${shouldUseSound}"></pera-wallet-connect-modal>`;
}
};
}

Expand Down
8 changes: 7 additions & 1 deletion src/util/api/peraWalletConnectApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function fetchPeraConnectConfig(network: PeraWalletNetwork) {
use_sound: boolean | undefined;
display_new_badge: boolean | undefined;
servers: string[] | undefined;
silent: boolean | undefined;
}>(configURL, {cache: "no-store"});
}

Expand All @@ -31,7 +32,8 @@ async function getPeraConnectConfig(network: PeraWalletNetwork) {
webWalletURL: "",
isWebWalletAvailable: false,
shouldDisplayNewBadge: false,
shouldUseSound: true
shouldUseSound: true,
silent: false
};

try {
Expand All @@ -49,6 +51,10 @@ async function getPeraConnectConfig(network: PeraWalletNetwork) {
peraWalletConfig.shouldUseSound = response.use_sound!;
}

if (typeof response.silent !== "undefined") {
peraWalletConfig.silent = response.silent!;
}

peraWalletConfig = {
...peraWalletConfig,
bridgeURL: shuffleArray(response.servers || [])[0] || "",
Expand Down
1 change: 1 addition & 0 deletions src/util/api/peraWalletConnectApiTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export interface PeraWalletConfig {
isWebWalletAvailable: boolean;
shouldDisplayNewBadge: boolean;
shouldUseSound: boolean;
silent: boolean;
}

0 comments on commit b2bed93

Please sign in to comment.